DoSun
0755facc63
Merge pull request #75 from Askhz/fix/credentials-path-and-fields
...
fix: 移除闲置字段id/name,认证文件路径改为~/.costrict/share/auth.json
2026-05-13 09:57:09 +08:00
Askhz
902b7d4ed5
fix: 移除闲置字段id/name,认证文件路径改为~/.costrict/share/auth.json
...
Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-13 09:54:40 +08:00
DoSun
ef151d84ba
feat(server): 借鉴 vibe-kanban 优化子进程管理与消息可靠性
...
- 添加内存消息缓冲区,解决 tab 切换后用户消息丢失问题
- prompt() 去除重复 waitReady(),减少不必要的等待
- 新增 kill_on_drop 工具(FinalizationRegistry),待后续启用
- 新增权限模式 hooks 自动配置(仅在显式指定 permission_mode 时生效)
- 清除 serve 模式下的调试 timing 日志
2026-05-12 20:38:35 +08:00
DoSun
daa2dce7b9
Merge pull request #70 from y574444354/feat/server-refactor-90331
...
feat(server): support reading subagent transcripts
2026-05-12 19:14:04 +08:00
DoSun
be821416e5
Merge pull request #71 from Askhz/fix/server-agent-switch
...
fix(server): 修复内置 agent 切换时系统提示未注入及 @agent 出现在用户消息中的问题
2026-05-12 17:54:11 +08:00
Askhz
e7c384bca5
fix(server): 修复内置 agent 切换时系统提示未注入及 @agent 出现在用户消息中的问题
...
- set_agent 控制消息处理中,查找对应 AgentDefinition 并将其 getSystemPrompt()
写入 options.systemPrompt,使 QueryEngine.ask() 能正确使用 agent 系统提示
- 将 "build"(前端默认模式的显示名称)处理为 undefined,切换回默认模式时
同步清空 options.systemPrompt 和 mainThreadAgentType
- /prompt 和 /prompt_async 接口不再将 agentMentions (@agent-*) 拼入 content,
该语法仅用于 REPL 命令模式,出现在 server 模式的 prompt 中会被模型误解
Co-Authored-By: Sonnet-4.6-CoStrict <noreply@anthropic.com>
2026-05-12 17:50:07 +08:00
DoSun
d29801aad2
fix(server): resolve rebase conflicts and align tests with new architecture
2026-05-12 16:56:56 +08:00
DoSun
edb72b447b
fix(server): return latest N messages instead of first N in messages endpoint
2026-05-12 16:50:09 +08:00
DoSun
86fac2bd75
feat(server): support deleting non-resident sessions with disk cleanup
2026-05-12 16:50:09 +08:00
DoSun
1a440af30b
feat: 对齐 OpenCode 即时推送架构,session status 事件绕过队列直接推送
...
- sessionState.ts: 单 listener → Set 多订阅者,新增 registerSdkEventConsumer 绕过 SDK 事件队列
- sdkEventQueue.ts: SessionStateChangedEvent 从队列系统移除
- print.ts: runHeadlessStreaming 注册直接消费者,事件即时 output.enqueue()
- query.ts: queryLoop 每轮迭代发送 running 心跳
- server/routes/session.ts: prompt_async 立即 emit busy(不等子进程 init),历史会话先解析 body 再恢复
- server/sessionHandle.ts: prompt() 检测已 busy 时跳过重复 emit
- server/eventBus.ts: 添加 SSE publish 耗时日志
- server/server.ts: 传递 eventBus 给 sessionRoutes
- 新增 16 个 sessionState 多订阅者 + SDK consumer 测试
2026-05-12 16:49:26 +08:00
DoSun
5890d16b3a
feat(server): emit session.updated on title generation with fallback
2026-05-12 16:49:05 +08:00
DoSun
58b4b5e354
fix(server): include created_at in session.created SSE event
...
The session.created event only had session_id and status, causing
downstream adapters to produce empty time objects and new sessions
landing in the 'older' group.
2026-05-12 16:49:05 +08:00
DoSun
922bcf7660
fix(server): accept client messageID to enable optimistic message dedup
2026-05-12 16:48:59 +08:00
林凯90331
6e8d54da6c
feat(server): support reading subagent transcripts
...
Add fallback in readSessionMessages() to locate subagent transcript files under <project>/<session>/subagents/agent-<id>.jsonl when the sessionId is actually an agentId. Extract entryToSessionMessage and readMessagesFromLines helpers for reuse between main and subagent transcripts.
Also route 'system' messages through the 'message' event in sessionMessageRouter so subscribers can observe them.
Signed-off-by: 林凯90331 <90331@sangfor.com>
Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-12 16:30:45 +08:00
DoSun
d18a2af37d
Merge pull request #65 from Askhz/fix/server-agent-switch
...
fix(server): 支持按 prompt 动态切换 agent
2026-05-12 14:50:52 +08:00
costrict
b6c353977d
fix(server): 支持按 prompt 动态切换 agent
...
- sessionHandle 添加 --agent spawn 参数和 setAgent() 控制请求
- prompt/prompt_async 路由提取 body.agent 并调用 setAgent
- print.ts 添加 set_agent 控制请求处理
- controlSchemas 添加 SDKControlSetAgentRequestSchema
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 14:42:42 +08:00
DoSun
c147cf7578
Merge pull request #62 from Askhz/fix/server-exe-feature-args
...
fix(server): 修复 csc.exe server 模式下探针进程因 --feature 参数崩溃导致模型列表为空
2026-05-11 21:02:00 +08:00
Askhz
40dc2720d0
fix(server): 修复 csc.exe server 模式下探针进程因 --feature 参数崩溃导致模型列表为空
...
Bun 将源码编译为独立可执行文件后,process.argv[1] 变为内部虚拟路径
(B:/~BUN/root/cli.js),该路径含 / 被误判为脚本模式,导致 saveChildSpawnPrefix
为子进程生成 --feature / -d 参数。子进程(csc.exe 本身)不识别这些 Bun
运行时参数,以 exit code 1 退出,探针失败,/provider/capabilities 返回空模型。
修复:
- getScriptArgsForChild: 识别并跳过 Bun snapshot 虚拟路径前缀 (B:/~BUN/, /snapshot/)
- saveChildSpawnPrefix: 仅在 scriptArgs 非空(脚本模式)时才生成 --feature/define 参数
- build.ts: 补充 Step 7 编译独立可执行文件 csc.exe / csc
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 20:59:10 +08:00
DoSun
ad2d4508c8
Merge pull request #58 from Askhz/fix/delete-session
...
fix: DELETE 历史 session 时删除磁盘 transcript 文件
2026-05-11 16:15:27 +08:00
Askhz
0a93873e3d
fix: DELETE 历史 session 时删除磁盘 transcript 文件
...
- PATCH 接口:历史 session 不在内存时不再 404,直接返回成功
- DELETE 接口:历史 session 通过 resolveSessionFilePath 定位并删除磁盘 .jsonl 文件
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 16:11:52 +08:00
DoSun
3aab6fb889
fix: 修复 services/utils 层 strict 模式类型错误
...
- api/errors: formatAPIError 参数类型适配
- rawDump/logger: 导出可同时作为函数和对象调用的 log
- rawDump/worker: postJson body 类型断言、reduce 泛型标注
- sideQueryOpenAICompat: tool_calls 类型收窄为 FunctionToolCall
2026-05-11 14:33:50 +08:00
DoSun
5d6b31398a
fix: strict 模式类型修复 + 恢复 allow-dangerously-skip-permissions 选项
...
- LogoV2: 抽取 ChannelsNoticeIfLoaded 消除重复,修复 nullability
- main.tsx: 恢复 --allow-dangerously-skip-permissions 选项
- global.d.ts: 添加 doubaoime-asr 模块类型声明
2026-05-11 14:33:44 +08:00
DoSun
c96fe77c45
fix(server): 修复 strict 模式下类型错误
...
- errors.ts: status 转为 ContentfulStatusCode
- server.ts: BunServer 泛型参数修正
- transcriptReader.ts: 补充 compactMetadata 类型声明
2026-05-11 14:33:37 +08:00
DoSun
799ed96b37
feat(server): prompt 支持 parts/agent 传递,import 迁移至子模块
...
- session route: ssePrompt 支持 parts 参数,支持 agent mentions
- session route: createSession 支持自定义 session_id
- provider/sessionManager: InitData import 从 types.js 统一导入
2026-05-11 14:33:31 +08:00
DoSun
3ebfb2c05d
refactor(server): 拆分 SessionHandle 为三个子模块
...
- childSpawn.ts: spawn 参数构建、INIT_TIMEOUT_MS、save/loadChildSpawnPrefix
- sessionControlChannel.ts: control response pending 管理
- sessionMessageRouter.ts: stdout 消息路由 + opencode 事件发射
- sessionHandle.ts: 精简为编排层,委托给子模块
- types.ts: 统一导出 InitData/PendingPermission/PendingQuestion
2026-05-11 14:33:23 +08:00
DoSun
7c3d9da000
Merge pull request #57 from y574444354/feat/cloud-question
...
Feat/cloud question
2026-05-11 14:16:24 +08:00
林凯90331
1ef4182a9e
fix(server): resolve merge conflicts with feat/server-refactor
...
- event.ts: combine /event endpoint with cwdFilter support,
remove unused /global/event endpoint
- sessionHandle.ts: keep INIT_TIMEOUT_MS, emitOpencodeEvent,
emitBusyStatus, toPermissionKey and extractPatterns
Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-11 13:31:24 +08:00
林凯90331
009e9f0c49
feat(server): opencode-compatible question/permission with AskUserQuestion popup support
...
- emit opencode-compatible SSE events for questions and permissions
(flat shape with top-level session_id for wrapEventStream routing)
- adapt question API (/question, /question/:id/reply, /question/:id/reject)
for AskUserQuestion and elicitation workflows
- fix AskUserQuestion tool name matching and guard against double-wrapped events
- allow requiresUserInteraction tools to ask user even in bypassPermissions mode
- avoid blocking on session init to prevent cold-start timeout
- add /global/event SSE endpoint and cwdFilter support
- add question routes and session handle tests
Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-11 12:54:44 +08:00
DoSun
434ee9e806
feat: session status 改造为 prompt 级别 busy/idle 三态,SSE 事件和 status 接口按 cwd 过滤
...
- 新增 SessionBusyStatus 类型(idle/busy/retry),替代进程生命周期状态
- SessionHandle 在 prompt/result/abort/close/error 中追踪 busyStatus 并通过 EventBus 发布 session.status SSE 事件
- /session/status 接口返回扁平 Record<string, SessionBusyStatus>,支持按 cwd 过滤
- EventBus 支持客户端 cwdFilter,SSE 事件按工作空间过滤推送
- sessionManager 在 create/delete 时注册/注销 sessionCwd 映射
2026-05-11 09:26:15 +08:00
林凯90331
59d3460554
Merge remote-tracking branch 'origin/feat/server-refactor' into feat/cloud-question
2026-05-09 18:18:55 +08:00
DoSun
7e04ca159b
Merge pull request #52 from Askhz/feat/serve-session-create
...
Feat/serve session create
2026-05-09 18:00:21 +08:00
Askhz
550dbb5532
feat: serve 模式支持 resume 历史会话继续对话
...
- prompt/prompt_async 接口找不到内存 session 时自动从磁盘历史恢复
- 从 transcript 读取历史 session 的原始 cwd,保证子进程在正确目录启动
- resume 时不传 --session-id 避免与 --resume 冲突(csc 限制)
- sessionManager.createSession 支持传入指定 sessionId,resume 时复用历史 id
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 17:54:25 +08:00
林凯90331
0b36424820
feat(server/question): adapt question API to opencode-compatible format
...
Refactor csc serve question endpoints to match opencode/app-ai-native
expected data models and request/response shapes:
- GET /question now returns QuestionRequest[] (direct array) instead of
{ questions: [...] }
- POST /question/:id/reply accepts { answers: string[][] } mapping to
selected option labels per question
- POST /question/:id/reject no longer requires a request body
- Support dual question sources:
- MCP Elicitation (converted to opencode format with enum→options)
- AskUserQuestionTool permissions exposed as questions
- Add conversion helpers: convertAskUserQuestionToOpencode,
convertElicitationToOpencode, buildElicitationContent
- Reply to AskUserQuestionTool via replyPermission('allow') with
constructed updatedInput.answers map
Also includes serve-mode infrastructure improvements:
- Session routes auto-create sessions on demand via getOrCreateSession
- Set CSC_SERVE_MODE env var in child process spawn
- Skip push-suggestion stream waiting in serve mode
Add comprehensive unit tests for question route opencode conversion.
Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-09 17:52:43 +08:00
Askhz
f34325f60a
feat: 修复 serve 模式新建会话及消息读取问题
...
- tsconfig.json 加 baseUrl 修复 dev 模式子进程 src/* 路径别名解析
- waitReady/initReject 修复:子进程退出时正确 reject,避免永久 pending
- POST /session 等待子进程 ready 后再返回,避免立即发 prompt 崩溃
- transcriptReader pathCache 不缓存 null,文件未写入时下次可重新查找
- session/status 用 prompting 判断 busy/idle,prompt 结束后正确变为 idle
- /agent 接口补充默认 build 模式
- message.ts 使用 spawnCwd 定位 transcript 文件
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 17:35:05 +08:00
DoSun
265ff7d864
fix: 中断对话时添加 is_interrupted 标记并优化 abort 响应速度
...
- QueryEngine: result 消息新增 is_interrupted 字段,标识用户中断
- sessionHandle: abort() 不再等待子进程退出,改为等待 result 事件(2s 超时兜底)
2026-05-09 16:37:03 +08:00
DoSun
6274c0e2be
fix: 过滤子进程内部合成消息(model switch breadcrumb)不转发给前端
2026-05-09 11:43:10 +08:00
DoSun
0393ce927d
feat: GET /permission 响应格式对齐前端 PermissionRequest 类型
...
- 工具名 PascalCase 映射为小写 permission key(匹配 i18n)
- 从 tool input 提取 patterns(file_path/command 等)
- 补齐 sessionID/id/tool/callID/metadata/always 字段
2026-05-09 11:18:46 +08:00
DoSun
9c3441331c
feat: serve 模式默认启用权限问询(acceptEdits)并修复回复链路
...
- 默认权限模式从 undefined 改为 acceptEdits(工作目录内读写自动放行)
- 始终传递 --permission-prompt-tool stdio 给子进程
- 修复 updatedInput 为 undefined 导致子进程 Zod 解析失败
- always 回复附带 updatedPermissions + decisionClassification
- 新增 permission_replied/question_replied SSE 事件通知 UI 撤销弹窗
- hook_callback 控制请求自动回复防止子进程阻塞
- PendingPermission 保存 permission_suggestions 供 always 回复使用
2026-05-09 11:10:13 +08:00
DoSun
e37e9d3ad5
feat: enable stream_event forwarding for serve mode streaming
...
QueryEngine previously guarded stream_event yields behind includePartialMessages,
which was undefined in serve mode. Remove the guard so stream_event messages
always flow to the child process stdout. Add stream_event handling in
sessionHandle.routeMessage to emit via EventBus for downstream consumers.
2026-05-09 10:04:19 +08:00
DoSun
862a16c295
Merge pull request #50 from Askhz/feat/server-add-session
...
feat: serve 模式 session 列表按工作目录过滤
2026-05-09 10:01:45 +08:00
Askhz
aca6133318
feat: serve 模式 session 列表按工作目录过滤
...
从请求头 x-csc-directory 读取工作目录(cs-cloud 通过此头传递),
GET /session 和 GET /session/status 只返回该目录下的历史会话
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 09:59:26 +08:00
DoSun
5c3f1e16db
fix: read workspace from x-csc-directory header in session creation
2026-05-08 19:02:09 +08:00
DoSun
02161dd2a6
fix: pass dynamic provider_id from initData instead of hardcoding
...
- Add _providerId field to SessionHandle, extracted from initData.account.apiProvider
- Include provider_id in user message emit, assistant message fallback, and session.ready
- Revert getProviderId normalization (keep raw value from subprocess)
2026-05-08 18:59:00 +08:00
DoSun
e258f58fd7
fix: normalize provider ID to anthropic (was firstParty causing model validation mismatch)
...
The subprocess returns apiProvider='firstParty' for direct Anthropic access,
but the adapter hardcodes providerID='anthropic' in SSE events. This mismatch
causes the frontend's isModelValid check to fail, clearing the model selector.
2026-05-08 18:42:51 +08:00
DoSun
880782b1dd
fix: remove debug logs, add model fallback, fix prompt_async flow
...
- Remove process.stderr.write debug logs from sessionHandle and prompt_async
- Add model fallback in assistant message (use this._model if msg.model missing)
- Add model field to user message emit for adapter consumption
- Wait for session ready before setModel/prompt in prompt_async
- Return 200 JSON instead of 204 No Content from prompt_async
- Set Bun.serve idleTimeout to 255s to prevent connection drops
2026-05-08 18:42:51 +08:00
DoSun
d7a65170cd
Merge pull request #48 from y574444354/feat/favorite-migrate
...
Feat/favorite migrate
2026-05-08 18:42:01 +08:00
林凯90331
9a2469f8a8
Merge remote-tracking branch 'origin/feat/server-refactor' into feat/favorite-migrate
2026-05-08 18:34:37 +08:00
DoSun
8261385cbb
Merge pull request #49 from Askhz/feat/server-add-session
...
Feat/server add session
2026-05-08 18:34:17 +08:00
林凯90331
41dbd44b4e
feat(hub): migrate favorite command with auto-enable, real-time toggle and server refactor
...
- Migrate favorite command from opencode to csc with /hub command
- Rename /favorite → /cloud-enabled → /knowledge-hub → /hub
- Auto-enable cloud favorites on startup without manual Update button
- Toggle items immediately on check/uncheck without Update button
- Add favorite REST routes and kh alias (later removed)
- Fix UDS socket path length exceeding macOS sockaddr_un.sun_path limit
- Add AbortController timeout to CoStrict fetch to prevent startup blocking
- Fix build robustness (handle missing download-ripgrep script)
- Merge server refactor: Hono-based HTTP API, session management, transcript reader
- Add serve API docs, server module unit tests, and cloud command handler
Signed-off-by: 林凯90331 <90331@sangfor.com>
Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-08 18:18:44 +08:00
Askhz
231c76df84
fix: 完善 serve 模式 session 列表接口
...
- GET /session/:id 支持从磁盘历史记录 fallback,修复历史 session 404
- 过滤无意义的管理命令会话(/exit、/model、/login 等)
- 保留 /crewpilot:plan 等有意义的斜杠命令触发的会话
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 18:12:22 +08:00