feat: 支持opencode 自定义模型配置流程#4
Open
Mrjing wants to merge 10 commits into
Open
Conversation
**问题**:LLM provider(如腾讯 MiMo)的内容安全策略偶发会拦截请求,返回 ACP `stopReason: 'refusal'`,此时 LLM 流被中断,assistant record 常常只有截断的 reasoning 没有 text,UI 显示为一条"空回复",用户不知道发生了什么。 **实现**: prompt 返回后检查 `promptRes.stopReason`: - refusal / max_tokens / max_turn_requests 三种非正常结束原因:emit 一条 text 事件(⚠️ 开头的提示段),通过 makeEmitter 同时走两条通道: 1. messageBuilder.pushEvent → 作为 text part 持久化到 DB,刷新后仍可见 2. convertToSessionUpdate → agent_message_chunk SSE 事件,实时展示 - cancelled 不在此处处理(abort 走 catch 分支),end_turn 是正常完成。 **为什么 emit text 而不是 emit error**: error 被前端渲染为 log 级别的小字状态信息,而我们要的是把这段"为什么没有 回复"的解释**作为 assistant 回答的一部分**留在对话流里,让用户下次刷新也能 看到原因。
**现象**:云托管构建 `pnpm build` 报 `cp: cannot stat 'src/agent/runtime/opencode-tool-templates/*.ts'` → exit 1。 **根因**:提交 38114f1 把 opencode tool 模板从 `packages/server/src/agent/runtime/opencode-tool-templates/` 迁移到 `.opencode/tools/`(checked-in,不再需要安装步骤),但遗漏了两处清理: 1. `packages/server/package.json` build 尾部仍执行 `mkdir -p dist/.../opencode-tool-templates && cp src/.../opencode-tool-templates/*.ts ...`, 源目录已不存在 → cp 失败 → 整个 build 失败。 2. `Dockerfile` Stage 2 只拷贝 `dist/`,没拷 `.opencode/`,即便 build 能过运行时也会在 `getOpencodeConfigDir()` 找不到 tools。 **修复**: - package.json:删除 build 末尾的 mkdir/cp 片段,保留三个 tsup 步骤。 - Dockerfile:Stage 2 新增 `COPY --from=build /app/.opencode ./.opencode`。 resolveProjectRoot() 从 dist 向上找到含 packages/server 的 /app → 工具解析为 /app/.opencode/tools/*.ts,与源码运行一致。 - tsconfig.json:顺带清理已失效的 exclude 路径(保留 __tests__ 一行)。 本地验证:pnpm --filter @coder/server build、pnpm type-check、pnpm lint 全绿。
自 38114f1(tool 模板迁入 .opencode/tools/ 并 checked in)以来这些已无调用方: - TOOL_NAMES 常量 + ToolName 导出类型 - resolveTemplateDir()(定位 src/agent/runtime/opencode-tool-templates/, 而该目录已删除) - getInstallDir() - hashFile() + crypto import - InstallResult interface - ensureOpencodeToolsInstalled()(安装器本体) - 3 个对应的环境变量开关:OPENCODE_TOOL_TEMPLATE_DIR / OPENCODE_TOOLS_INSTALL_DIR / OPENCODE_TOOLS_FORCE_REINSTALL 保留两个仍在 opencode-acp-runtime.ts 使用的 export: - resolveProjectRoot() - getOpencodeConfigDir() 文件从 163 行缩到 53 行;顶部注释重写说明新架构(.opencode 签入 + Dockerfile COPY)并留下一句历史说明指向本次清理。
feat: 支持 token hub
fix: 优化 opencode 模型配置流程
Mrjing
added a commit
that referenced
this pull request
May 28, 2026
The dual-write mechanism in SessionStore (PR #4.6) already provides front-end message retrieval via getHistory(). The history-store module only had an interface definition and was never implemented. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.