Repository navigation
feat(execution): execution current --json 返回轮次来源 origin - #2549
Merged
Merged
Conversation
daemon 按自己的记录判定当前已证明轮次的来源:im / dispatch / schedule (带 scheduleTaskId)/ trigger(带 triggerSource)/ recovery / unknown。 schema 保持 v1、字段可选,并且只在请求带 fields:["origin"] 时返回,老 CLI 的严格字段校验不受影响。文档补取值表、兼容理由,以及网络隔离沙盒 连不到 daemon loopback 的限制。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 29, 2026 19:23
Owner
Author
|
🚀 Released in v3.56.0 |
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.
改了什么
botmux execution current --json返回的CurrentExecutionDocument原来只有 larkAppId、sessionId、chatId、turnId 等字段,没有说明这一轮是怎么来的。有用户在给内部工具写外部 shim,需要按轮次取凭证,区分「定时任务」和「真人消息」只能去解析 turnId 的schedule:前缀,不稳定。本 PR 新增公开字段origin,这是维护者在看板 #95 选的 B 方案。originimactiveInteractiveTurn显示发送者senderType: 'user';或逐轮记录replyTargets证明发送者不是机器人(与身份校验用同一条规则)dispatchscheduleschedule:<task>:<uuid>。定时任务的自动续跑沿用这个前缀,所以续跑轮次仍判为schedulescheduleTaskIdtriggerreq.source.typetriggerSourcerecoveryordinaryTurnRecovery、failedTurnRecovery、readonlyTaskContinuation恢复标记命中本轮unknownimsrc/core/turn-origin.ts(resolveTurnOrigin)。输入只有已证明的 turnId(attestation 里的proof.turnId)和 daemon 内存里的会话状态。请求方的参数、环境变量、它能写的文件都不参与。请求体里伪造的origin/scheduleTaskId会被忽略,有测试覆盖。isCurrentExecutionDocument的字段白名单加了这三个键。附带字段只能和对应的 origin 一起出现,取值也要合法。capabilities --json新增current_execution_origin_v1。公开契约:为什么是 v1 加可选字段,而不是升 v2
老版本 CLI 会对返回的字段做严格白名单校验,只要多一个键,就会报
current_execution_unverified。为了不影响它们,origin 改成按需返回:fields: ["origin"],daemon 只在收到这个请求时才附上 origin。如果升到 v2,CLI 和 daemon 任一边版本不一致,都会被 schema 校验拒绝,反而会出现不兼容。只读 turnId 等原有字段的调用方行为不变。
/api/current-execution-identity(受管 wrapper 取身份)内部也调同一个函数,但不请求 origin,行为不变。文档
docs/current-execution.md新增一节:可用范围核对了原文档的写法,并补了一条:网络与宿主隔离的沙盒连不到 daemon,包括配了
sandboxNetworkPolicy(slirp4netns--disable-host-loopback)和sandboxNetwork: false两种情况。沙盒里的 127.0.0.1 是它自己网络命名空间的 loopback,访问不到 daemon 的 loopback 端口,命令会直接因连接失败退出。这条在 isolate-run 里实测过(slirp4netns 1.2.0):代码侧的说法与此一致:
resolveSpawnNetworkShape对这两种配置返回loopbackShared: false。测试
test/current-execution.test.ts:im;没有交互记录时,回落到逐轮记录判定,只有证明是人的发送者才判im。dispatch。schedule和任务 id,它的续跑也一样。trigger和triggerSource。recovery。test/ipc-current-execution-route.test.ts:fields时返回 origin,伪造字段无效。test/trigger-session-root-message.test.ts:真实triggerSessionTurn准入后,生成的trg_轮次被登记为trigger/webhook。变异(每条摘掉守卫后对应用例必须变红),全部 14 条都变红:
影响面
trigger-session.ts(准入时多一行登记)、dashboard-ipc-server.ts(/api/current-execution路由读取fields)、cli/current-execution.ts、core/current-execution.ts、cli/capabilities.ts、文档。没有改到其它沙盒任务组的文件。unknown。文档里已写明unknown按「不能确定」处理。来源:维护者在看板 #95 选定的方案 B,问题来自用户反馈。
🤖 Generated with Claude Code