dsh-swarm-console 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ - insert:
2
+ - id: swarm-console
3
+ name: dsh-swarm-console
4
+ config:
5
+ externalAgents: {}
6
+ capabilityRouting: true
package/docs/DETAIL.md ADDED
@@ -0,0 +1,60 @@
1
+ # Swarm Console
2
+
3
+ 在 DSH 里调用一个外部 agent 执行一次任务,返回结构化的停止原因与文本结果。
4
+
5
+ ## 配置 externalAgents
6
+
7
+ 在插件配置里给出 agent 画像表。令牌只写环境变量名,不写令牌值:
8
+
9
+ ```yaml
10
+ externalAgents:
11
+ deepseek:
12
+ baseUrl: https://api.deepseek.com/v1
13
+ apiKeyEnv: DEEPSEEK_API_KEY
14
+ models: [deepseek-flash]
15
+ capabilities: [reasoning, chinese]
16
+ capabilityRouting: true
17
+ ```
18
+
19
+ 每个条目必须有 `baseUrl`、`apiKeyEnv`、`models` 三项,缺一项插件激活即报错(不静默跳过)。
20
+
21
+ ## 调用 swarm_run
22
+
23
+ 参数:
24
+
25
+ ```js
26
+ { task: '要做的任务', agent: 'deepseek', model: 'deepseek-flash' }
27
+ ```
28
+
29
+ `task` 必填;`agent` 省略时,若只配了一个 external agent 就自动用它;`model` 省略时用画像里的第一个。
30
+
31
+ 返回:
32
+
33
+ ```js
34
+ { stopReason: 'completed' | 'cancelled' | 'error', text: '文本结果', ms: 1234 }
35
+ ```
36
+
37
+ `stopReason='cancelled'` 表示调用被取消(`exec.signal` 触发),不抛异常。
38
+
39
+ ## verify v1 三工具(实验性)
40
+
41
+ - `verify_contract({objective, constraints, criteria})` → `{contractId}`,契约内容冻结成 12 位 id
42
+ - `verify_run({contractId, checks})` → `{decision: 'GREEN'|'YELLOW'|'RED', reasons, evidenceHash, reproCmd?}`
43
+ - `verify_status({contractId})` → 有记录时 `{known:true, decision, at}`;未知契约 `{known:false}`(不返回三态值)
44
+
45
+ 三态规则:缺证据 YELLOW;任一 check 失败 RED(必带可复制执行的 `reproCmd`);全部有证据且通过 GREEN。
46
+
47
+ **放行入口(v1)**:斜杠命令 `/gate-approve <contractId>`、`/gate-retry <contractId>`、`/gate-status <contractId>`。放行只能由用户触发——斜杠命令由用户在交互界面直接输入,图中没有对应的模型工具,模型无法代替用户调用,H3(放行只能由用户触发)由这个结构保证,不依赖运行时身份判断。非 GREEN 时 `/gate-approve` 直接拒绝并提示先 retry。门禁卡(action-cards)为可选增强,仅在挂载该服务的 profile 生效。
48
+
49
+ 每次命令执行会在会话日志留下 `command/run` 与 `command/done` 事件,可作为放行/重试的机器证据。
50
+
51
+ **`gate-retry` 语义**:用空证据重算,结果必为 YELLOW(提示补证据);它只刷新决定时间戳,不伪造通过证据。要转 GREEN 需重新执行 `verify_run` 并提供真实证据。
52
+
53
+ ## 已知限制
54
+
55
+ - 还没有画布 —— 看不到 agent 节点、连线或过程可视化
56
+ - 交付门禁为 v1 实验:证据存**进程内 Map**,DSH 重启即丢,不做持久化
57
+ - 本插件以 **link 方式**装进当前 profile;新增的 `verify_*` 工具需**重启 DSH** 才会注册,未重启时宿主只看到 `swarm_run`
58
+ - 门禁卡 GUI 截图与 approve/retry 事件流:当前为**未验证项**,待宿主重启后补
59
+ - 图标未提供 —— 当前回落 DSH 默认图标
60
+ - `swarm_run` 只支持一次调用,不支持多轮对话或子 agent 编排
@@ -0,0 +1,48 @@
1
+ # v1 验收记录
2
+
3
+ ## 1. 验收范围
4
+
5
+ - 版本:0.1.0,基准提交 `58dc124`
6
+ - 覆盖:阶段 3A(可安装 Host 插件骨架)、阶段 4(verify v1 三态门禁)、阶段 5(发布配置)
7
+ - 本文事实以 `58dc124` 为准;放行入口为斜杠命令,门禁卡为可选增强(当前 profile 未挂载 action-cards)
8
+
9
+ ## 2. 机器证据(会话日志 session.v4.jsonl.zstd,3186 事件)
10
+
11
+ 评审侧逐帧解出的五条 command 事件:
12
+
13
+ | seq | 事件对 | 命令 | 结果 |
14
+ |---|---|---|---|
15
+ | 3150 / 3151 | command/run → command/done | `gate-status` | success:GREEN,尚未放行 |
16
+ | 3152 / 3153 | command/run → command/done | `gate-approve` | success:已由用户放行(approved) |
17
+ | 3154 / 3155 | command/run → command/done | `gate-status` | success:已由 user 放行 @ 时间戳 |
18
+ | 3156 / 3157 | command/run → command/done | `gate-approve` | error:非 GREEN 不可放行,请先 /gate-retry |
19
+ | 3158 / 3159 | command/run → command/done | `gate-retry` | success:重算 YELLOW,需补证据 |
20
+
21
+ **全日志模型侧 gate 类工具调用 0 次** —— H3(放行只能由用户触发)由结构保证:斜杠命令由用户在交互界面输入,模型中不存在对应工具。
22
+
23
+ ## 3. 三条硬规则与反证
24
+
25
+ | 规则 | 内容 | 反证(已实测) |
26
+ |---|---|---|
27
+ | H1 | 证据先于验收:没有 evidence 的 criterion 不算通过 | 某 criterion 的 `checkIds` 为空 → 判定必为 YELLOW,不判 GREEN |
28
+ | H2 | RED 必须给可执行的最小复现命令 | 失败 check 未提供 `cmd` → `makeEvidence` 抛错;gate 兜底给 `echo "check X 未提供 cmd" && exit 1`,经 `sh -c` 执行退出非 0 |
29
+ | H3 | 放行只能由用户触发 | agent 身份调 `act(approve)` → refused 并留拒绝事件;实机全日志模型侧 gate 工具调用 0 次 |
30
+
31
+ ## 4. 未验证项(如实记录)
32
+
33
+ - **Plugins 列表 GUI 截图待补**:非阻塞,图标已提供,待宿主渲染后补图
34
+ - **npm publish 与市场提交未执行**:由用户执行,本仓库不代为操作凭据
35
+
36
+ ## 5. 复现命令
37
+
38
+ ```bash
39
+ npm run gate # 七段门禁一键验证
40
+ node --test plugin/test/*.test.mjs # core / verify / gate-skill / commands 单测
41
+
42
+ # 手动在 DSH 会话里输入(把 <id> 换成 verify_contract 返回的 contractId)
43
+ /gate-status <id>
44
+ /gate-retry <id>
45
+ /gate-approve <id>
46
+ ```
47
+
48
+ 每次命令执行会在会话日志留下 `command/run` 与 `command/done` 事件,可作为放行/重试的机器证据。
package/icon.svg ADDED
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
2
+ stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
3
+ <circle cx="5.6" cy="6" r="2.1"/>
4
+ <circle cx="5.6" cy="18" r="2.1"/>
5
+ <circle cx="13" cy="12" r="2.1"/>
6
+ <path d="M7.6 6.9 11.1 10.6"/>
7
+ <path d="M7.6 17.1 11.1 13.4"/>
8
+ <path d="M15.7 12.6 17.9 14.8 21.4 10.4"/>
9
+ </svg>
package/index.js ADDED
@@ -0,0 +1,353 @@
1
+ /**
2
+ * Swarm Console —— 可安装的 DSH Host 插件骨架(阶段3A)。
3
+ * 只做一件事:把一个任务交给一个外部 agent 执行一次,返回 stopReason / text / ms。
4
+ * 画布与交付门禁尚未实现(见 docs/DETAIL.md)。
5
+ *
6
+ * 复用 plugin/lib/adapter.js 的 callChat —— 唯一实现在包内,不复制第二份。
7
+ * src/external-agent-adapter.js 是反向 re-export 的兼容 shim。
8
+ */
9
+ import { callChat } from './lib/adapter.js'
10
+ import { z } from './lib/core/mini-schema.js'
11
+ import { verifyContract, verifyRun, verifyStatus, guardCaller, gateApprove, gateRetry, gateStatus } from './lib/core/verify.js'
12
+
13
+ export const inject = ['tools']
14
+
15
+ /**
16
+ * 校验画像表。每个条目必须有 baseUrl / apiKeyEnv / models 三项,
17
+ * 缺一就 throw —— 激活即失败,不静默跳过。
18
+ */
19
+ function validateAgents(agents) {
20
+ if (typeof agents !== 'object' || agents === null || Array.isArray(agents)) {
21
+ throw new Error('externalAgents 必须是对象')
22
+ }
23
+ for (const [name, p] of Object.entries(agents)) {
24
+ if (typeof p !== 'object' || p === null) {
25
+ throw new Error(`externalAgents.${name} 必须是对象`)
26
+ }
27
+ for (const key of ['baseUrl', 'apiKeyEnv', 'models']) {
28
+ const v = p[key]
29
+ const bad = key === 'models' ? !Array.isArray(v) || v.length === 0 : typeof v !== 'string' || v.trim() === ''
30
+ if (bad) throw new Error(`externalAgents.${name}.${key} 缺失或格式不对(必须是 ${key === 'models' ? '非空数组' : '非空字符串'})`)
31
+ }
32
+ }
33
+ }
34
+
35
+ /** 选一个画像:显式 agent → 唯一条目 → 报错。 */
36
+ function pickAgent(agents, requested) {
37
+ if (typeof requested === 'string' && requested !== '') {
38
+ if (agents[requested] === undefined) throw new Error(`未知的 agent "${requested}"`)
39
+ return { name: requested, profile: agents[requested] }
40
+ }
41
+ const names = Object.keys(agents)
42
+ if (names.length === 1) return { name: names[0], profile: agents[names[0]] }
43
+ if (names.length === 0) throw new Error('没有配置任何 externalAgents')
44
+ throw new Error('指定了多个 externalAgents,请用 agent 参数指明用哪一个')
45
+ }
46
+
47
+ /**
48
+ * 跑一次外部 agent。取消时返回 cancelled,不抛。
49
+ * signal 从 exec 透传给 callChat;callChat 内部会把 abort 转成异常,这里捕获后归一化。
50
+ */
51
+ async function runExternal(agents, args, signal) {
52
+ const { profile } = pickAgent(agents, args.agent)
53
+ const prompt = typeof args.task === 'string' ? args.task : ''
54
+ if (prompt.trim() === '') throw new Error('task 不能为空')
55
+
56
+ try {
57
+ const text = await callChat({
58
+ profile,
59
+ prompt,
60
+ model: typeof args.model === 'string' && args.model !== '' ? args.model : undefined,
61
+ signal,
62
+ })
63
+ return { stopReason: 'completed', text }
64
+ } catch (error) {
65
+ // 取消:exec.signal 触发,或底层 AbortError —— 不抛,归一化成 cancelled
66
+ const aborted = (signal && signal.aborted) || error?.name === 'AbortError' ||
67
+ /abort/i.test(String(error?.message ?? ''))
68
+ if (aborted) return { stopReason: 'cancelled', text: '' }
69
+ return { stopReason: 'error', text: String(error?.message ?? error) }
70
+ }
71
+ }
72
+
73
+ export function apply(ctx, config) {
74
+ const agents = config?.externalAgents ?? {}
75
+ validateAgents(agents)
76
+
77
+ ctx.effect(() => ctx.tools.register({
78
+ name: 'swarm_run',
79
+ description: '把一个任务交给一个外部 agent 执行一次,返回 stopReason 与文本结果。',
80
+ parameters: {
81
+ type: 'object',
82
+ properties: {
83
+ agent: { type: 'string', description: 'externalAgents 里的键;省略则用唯一的那个' },
84
+ task: { type: 'string' },
85
+ model: { type: 'string' },
86
+ },
87
+ required: ['task'],
88
+ additionalProperties: false,
89
+ },
90
+ output: {
91
+ schema: {
92
+ type: 'object',
93
+ properties: {
94
+ stopReason: { type: 'string' },
95
+ text: { type: 'string' },
96
+ ms: { type: 'number' },
97
+ },
98
+ required: ['stopReason', 'text', 'ms'],
99
+ },
100
+ render: (args, value) => [{ type: 'text', text: `[${value.stopReason}] ${value.text}` }],
101
+ },
102
+ async execute(args, exec) {
103
+ const t0 = Date.now()
104
+ const { stopReason, text } = await runExternal(agents, args, exec?.signal)
105
+ return { stopReason, text, ms: Date.now() - t0 }
106
+ },
107
+ }))
108
+
109
+ registerVerifyTools(ctx)
110
+ registerGateCommands(ctx)
111
+ // 卡片与 skill 是可选增强(仅在挂载 action-cards 的 profile 生效);v1 默认入口是斜杠命令。
112
+ // 两者都各自降级,任一失败都不阻塞 verify_* 三工具与斜杠命令。
113
+ registerGateSkill(ctx)
114
+ registerGateCard(ctx)
115
+ }
116
+
117
+ /**
118
+ * C1/C2 · 门禁放行斜杠命令(v1 默认入口,用户触发,不走模型工具)。
119
+ * commands 由 dsh base 自带;仍走 inject 保持挂载时机安全。
120
+ * 命令名 kebab-case、不带斜杠;handler 返回 {kind:'success'|'error', text}。
121
+ */
122
+ function registerGateCommands(ctx) {
123
+ if (typeof ctx.inject !== 'function') return
124
+ ctx.inject(['commands'], (ctx) => {
125
+ const commands = ctx.commands
126
+ if (!commands || typeof commands.register !== 'function') return
127
+ const defs = [
128
+ {
129
+ name: 'gate-approve',
130
+ description: '放行一个已 GREEN 的门禁契约(仅用户可触发)',
131
+ input: { hint: '<contractId>' },
132
+ handler: ({ rawInput }) => gateApprove({ contractId: String(rawInput ?? '').trim() }),
133
+ },
134
+ {
135
+ name: 'gate-retry',
136
+ description: '重跑某契约的门禁校验并刷新决定',
137
+ input: { hint: '<contractId>' },
138
+ handler: ({ rawInput }) => gateRetry({ contractId: String(rawInput ?? '').trim() }),
139
+ },
140
+ {
141
+ name: 'gate-status',
142
+ description: '查看某契约的最近门禁决定与放行状态',
143
+ input: { hint: '<contractId>' },
144
+ handler: ({ rawInput }) => gateStatus({ contractId: String(rawInput ?? '').trim() }),
145
+ },
146
+ ]
147
+ for (const def of defs) ctx.effect(() => commands.register(def))
148
+ })
149
+ }
150
+
151
+ /**
152
+ * 必改1 · 注册运行期 skill,让门禁卡的 propose_action 可用。
153
+ * DSH action-cards 的规则:根 Agent 必须先加载该种类声明的 Skill,propose_action 才会出现。
154
+ * 宿主无 skills 服务或注册失败时静默跳过(只影响卡片,不影响三工具)。
155
+ */
156
+ const GATE_SKILL_NAME = 'dsh-swarm-console-verify'
157
+ const GATE_SKILL_CONTENT = [
158
+ '# Swarm Console 门禁',
159
+ '',
160
+ '当你需要把任务契约冻结、跑证据校验、或让用户对门禁结论做放行决定时使用本 skill。',
161
+ '流程:verify_contract → verify_run → verify_status;结论为 GREEN/YELLOW/RED。',
162
+ '',
163
+ '- 先调用 verify_contract 冻结目标与验收条件,拿到 contractId。',
164
+ '- 再调用 verify_run 得到判定。RED 的复现命令会随输出给出,可复制执行。',
165
+ '- 需要用户决定时,用 propose_action 提议门禁卡(action: dsh-swarm-console/gate)。',
166
+ '- approve = 用户放行,仅在 GREEN 时允许;非 GREEN 不得 approve,应 retry。',
167
+ '- retry = 重跑校验并刷新卡片;只有用户可以操作卡片,agent 代批会被拒绝。',
168
+ '',
169
+ '不要用本 skill 承诺画布或多阶段状态机(尚未实现)。',
170
+ ].join('\n')
171
+
172
+ function registerGateSkill(ctx) {
173
+ // 可选服务走 inject:apply 阶段同步 get 时,晚挂载的服务还没就绪。
174
+ // 服务缺席时 inject 不触发回调,不抛错,verify_* 三工具照常注册。
175
+ try {
176
+ if (typeof ctx.inject !== 'function') return
177
+ ctx.inject(['skills'], (ctx) => {
178
+ try {
179
+ const skills = ctx.skills
180
+ if (!skills || typeof skills.register !== 'function') return
181
+ ctx.effect(() => skills.register({
182
+ name: GATE_SKILL_NAME,
183
+ description: 'Swarm Console 交付门禁:冻结契约、跑证据校验、由用户 approve/retry。',
184
+ content: GATE_SKILL_CONTENT,
185
+ source: 'runtime', // SkillRegistration 必填;缺它 skill 能注册但加载失败
186
+ invocation: { modelInvocable: true, userInvocable: true },
187
+ }))
188
+ } catch {
189
+ // 注册失败不阻塞三工具
190
+ }
191
+ })
192
+ } catch {
193
+ // inject 本身失败也不阻塞
194
+ }
195
+ }
196
+
197
+ /** D5 · 三个 verify 工具。核心逻辑在 lib/core/verify.js,这里只做薄封装。 */
198
+ function registerVerifyTools(ctx) {
199
+ const defs = [
200
+ {
201
+ name: 'verify_contract',
202
+ description: '冻结一个任务契约(目标/约束/验收条件),返回 contract.id。契约内容变化会换 id。',
203
+ parameters: {
204
+ type: 'object',
205
+ properties: {
206
+ objective: { type: 'string' },
207
+ constraints: { type: 'array', items: { type: 'string' } },
208
+ criteria: {
209
+ type: 'array',
210
+ items: {
211
+ type: 'object',
212
+ properties: {
213
+ id: { type: 'string' },
214
+ text: { type: 'string' },
215
+ checkIds: { type: 'array', items: { type: 'string' } },
216
+ },
217
+ required: ['id', 'text'],
218
+ },
219
+ },
220
+ },
221
+ required: ['objective'],
222
+ additionalProperties: false,
223
+ },
224
+ output: {
225
+ schema: { type: 'object', properties: { contractId: { type: 'string' } }, required: ['contractId'] },
226
+ render: (args, v) => [{ type: 'text', text: `contract ${v.contractId} 已冻结` }],
227
+ },
228
+ execute: async (args) => verifyContract(args),
229
+ },
230
+ {
231
+ name: 'verify_run',
232
+ description: '按策略跑一次证据校验,返回 GREEN/YELLOW/RED 三态与可复现命令。',
233
+ parameters: {
234
+ type: 'object',
235
+ properties: {
236
+ contractId: { type: 'string' },
237
+ checks: { type: 'array', items: { type: 'object' } },
238
+ },
239
+ required: ['contractId'],
240
+ additionalProperties: false,
241
+ },
242
+ output: {
243
+ schema: {
244
+ type: 'object',
245
+ properties: {
246
+ decision: { type: 'string' }, reasons: { type: 'array', items: { type: 'string' } },
247
+ evidenceHash: { type: 'string' }, reproCmd: { type: 'string' },
248
+ missing: { type: 'array', items: { type: 'string' } },
249
+ },
250
+ required: ['decision', 'reasons', 'evidenceHash'],
251
+ },
252
+ render: (args, v) => {
253
+ const lines = [`门禁 ${v.decision}:${v.reasons.join(';')}`]
254
+ // 必改2:RED 必带可复制复现命令;YELLOW 附缺失证据摘要
255
+ if (v.decision === 'RED') {
256
+ lines.push(v.reproCmd ? `复现:${v.reproCmd}` : '复现:未提供命令(异常)')
257
+ }
258
+ if (v.decision === 'YELLOW' && Array.isArray(v.missing) && v.missing.length > 0) {
259
+ lines.push(`缺失证据:${v.missing.join(';')}`)
260
+ }
261
+ return [{ type: 'text', text: lines.join('\n') }]
262
+ },
263
+ },
264
+ execute: async (args, exec) => {
265
+ // D4: diff 取宿主 workspaceChanges,不自建 diff
266
+ const wc = exec?.workspaceChanges ?? {}
267
+ const diffEvidence = typeof wc.summary === 'string' ? wc.summary : (typeof wc.diff === 'string' ? wc.diff : undefined)
268
+ const evidenceInput = args.checks ? { checks: args.checks, diff: diffEvidence } : undefined
269
+ return verifyRun({ contractId: args.contractId, evidenceInput })
270
+ },
271
+ },
272
+ {
273
+ name: 'verify_status',
274
+ description: '查某个契约最近一次门禁决定与时间。',
275
+ parameters: {
276
+ type: 'object',
277
+ properties: { contractId: { type: 'string' } },
278
+ required: ['contractId'],
279
+ additionalProperties: false,
280
+ },
281
+ output: {
282
+ schema: {
283
+ type: 'object',
284
+ properties: { known: { type: 'boolean' }, decision: { type: 'string' }, at: { type: 'string' } },
285
+ required: ['known'],
286
+ },
287
+ render: (args, v) => [{
288
+ type: 'text',
289
+ text: v.known ? `最近决定 ${v.decision}${v.at ? ' @ ' + v.at : ''}` : '未知 contractId,尚无门禁记录',
290
+ }],
291
+ },
292
+ execute: async (args) => verifyStatus({ contractId: args.contractId }),
293
+ },
294
+ ]
295
+ for (const def of defs) ctx.effect(() => ctx.tools.register(def))
296
+ }
297
+
298
+ /**
299
+ * D5 · 门禁卡片种类。
300
+ * 用 ctx.get('actionCards') 可选获取 —— 宿主未装 action-cards 服务时跳过(不阻塞 swarm_run)。
301
+ * details 用零依赖 mini-schema 满足 safeParse 鸭子类型。
302
+ */
303
+ function registerGateCard(ctx) {
304
+ // 仅在挂载 action-cards 的 profile 生效;v1 默认放行入口是斜杠命令(见 registerGateCommands)。
305
+ // 可选服务走 inject:actionCards 来自另一层 bundle,晚于本插件挂载,apply 时 get 取不到。
306
+ if (typeof ctx.inject !== 'function') return
307
+ ctx.inject(['actionCards'], (ctx) => {
308
+ const cards = ctx.actionCards
309
+ if (!cards || typeof cards.register !== 'function') return
310
+
311
+ const details = z.object({
312
+ decision: z.enum(['GREEN', 'YELLOW', 'RED']),
313
+ reasons: z.array(z.string()),
314
+ contractId: z.string({ nonempty: true }),
315
+ reproCmd: z.optional(z.string()),
316
+ })
317
+
318
+ ctx.effect(() => cards.register({
319
+ action: 'dsh-swarm-console/gate',
320
+ skill: GATE_SKILL_NAME,
321
+ invitation: '验收结论已出。请查看门禁卡片并选择 approve 放行或 retry 重跑。',
322
+ details,
323
+ verbs: { approve: { writes: true }, retry: { writes: true } },
324
+ openPhases: ['proposed', 'refused'],
325
+ async act(agent, proposal, verb, payload) {
326
+ // H3:放行只能由用户触发。非用户(subagent / 代码发起)拒绝并记事件。
327
+ const guard = guardCaller(agent, (a, decision) => cards.record(a, decision))
328
+ if (guard) return guard
329
+
330
+ const { contractId, decision } = proposal.details
331
+ if (verb === 'approve') {
332
+ if (decision !== 'GREEN') {
333
+ cards.record(agent, { callId: proposal.callId, action: proposal.action, phase: 'refused', data: { reason: '非 GREEN 不可放行' } })
334
+ return { status: 'refused', reason: '非 GREEN 不可放行' }
335
+ }
336
+ const d = { callId: proposal.callId, action: proposal.action, phase: 'approved', data: { contractId } }
337
+ cards.record(agent, d)
338
+ return { status: 'settled', decision: d }
339
+ }
340
+ if (verb === 'retry') {
341
+ const r = verifyRun({ contractId, evidenceInput: payload?.evidence })
342
+ const d = {
343
+ callId: proposal.callId, action: proposal.action, phase: 'proposed',
344
+ data: { contractId, decision: r.decision, reasons: r.reasons, ...(r.reproCmd ? { reproCmd: r.reproCmd } : {}) },
345
+ }
346
+ cards.record(agent, d)
347
+ return { status: 'settled', decision: d }
348
+ }
349
+ return { status: 'refused', reason: `未知操作 ${verb}` }
350
+ },
351
+ }))
352
+ })
353
+ }