@sema-agent/server 7.2.0 → 7.4.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.
Files changed (140) hide show
  1. package/README.md +2 -1
  2. package/README.zh-CN.md +1 -1
  3. package/USAGE.md +26 -1
  4. package/dist/approval-ask-machine.d.ts +39 -0
  5. package/dist/approval-ask-machine.js +101 -0
  6. package/dist/approval-card.d.ts +244 -0
  7. package/dist/approval-card.js +237 -0
  8. package/dist/approval-deny-reasons.d.ts +56 -0
  9. package/dist/approval-deny-reasons.js +54 -0
  10. package/dist/approval-reconciler.d.ts +174 -0
  11. package/dist/approval-reconciler.js +307 -0
  12. package/dist/boot/coordinators.d.ts +1 -0
  13. package/dist/boot/coordinators.js +39 -4
  14. package/dist/boot/deferred-sandbox-path-env.d.ts +99 -0
  15. package/dist/boot/deferred-sandbox-path-env.js +279 -0
  16. package/dist/boot/execution-env.js +11 -1
  17. package/dist/boot/lexical-path-env.d.ts +10 -0
  18. package/dist/boot/lexical-path-env.js +88 -0
  19. package/dist/boot/reapers.d.ts +34 -0
  20. package/dist/boot/reapers.js +198 -23
  21. package/dist/boot/resolve-spec.js +97 -33
  22. package/dist/capabilities/center-prompts.js +4 -1
  23. package/dist/capabilities/oa-tools.d.ts +15 -0
  24. package/dist/capabilities/oa-tools.js +54 -0
  25. package/dist/config-types.d.ts +68 -1
  26. package/dist/config.d.ts +1 -0
  27. package/dist/config.js +138 -2
  28. package/dist/elicitation.d.ts +4 -0
  29. package/dist/elicitation.js +7 -3
  30. package/dist/finance/cost-taxonomy.d.ts +34 -0
  31. package/dist/finance/cost-taxonomy.js +26 -0
  32. package/dist/hooks/hook-runner.js +32 -0
  33. package/dist/http/routes/capabilities.js +14 -0
  34. package/dist/http/routes/diagnostics.d.ts +84 -0
  35. package/dist/http/routes/diagnostics.js +140 -0
  36. package/dist/http/routes/runs.d.ts +1 -0
  37. package/dist/http/routes/runs.js +548 -16
  38. package/dist/http/routes/tasks.js +175 -12
  39. package/dist/http/server.d.ts +6 -1
  40. package/dist/http/server.js +120 -4
  41. package/dist/http/sse-log.d.ts +51 -0
  42. package/dist/http/sse-log.js +64 -0
  43. package/dist/http/wire-types.d.ts +20 -5
  44. package/dist/main.js +35 -4
  45. package/dist/observability/fail-open.d.ts +98 -0
  46. package/dist/observability/fail-open.js +216 -0
  47. package/dist/observability/prompt-manifest.d.ts +13 -0
  48. package/dist/observability/prompt-manifest.js +8 -0
  49. package/dist/plugins/approval-ask-store-memory.d.ts +38 -0
  50. package/dist/plugins/approval-ask-store-memory.js +299 -0
  51. package/dist/plugins/approval-ask-store-sql.d.ts +341 -0
  52. package/dist/plugins/approval-ask-store-sql.js +705 -0
  53. package/dist/plugins/approval-store-sql.d.ts +116 -0
  54. package/dist/plugins/approval-store-sql.js +151 -0
  55. package/dist/plugins/background-agent-store-sql.js +20 -1
  56. package/dist/plugins/checkpoint-store-sql.d.ts +84 -9
  57. package/dist/plugins/checkpoint-store-sql.js +297 -16
  58. package/dist/plugins/file-workflow-journal-store.d.ts +12 -0
  59. package/dist/plugins/file-workflow-journal-store.js +12 -0
  60. package/dist/plugins/local-checkpoint-store.d.ts +6 -5
  61. package/dist/plugins/local-checkpoint-store.js +4 -0
  62. package/dist/plugins/pg-approval-store.d.ts +9 -0
  63. package/dist/plugins/pg-approval-store.js +9 -0
  64. package/dist/plugins/pg-breaker-state.d.ts +8 -0
  65. package/dist/plugins/pg-breaker-state.js +8 -0
  66. package/dist/plugins/pg-checkpoint-store.d.ts +10 -0
  67. package/dist/plugins/pg-checkpoint-store.js +10 -0
  68. package/dist/plugins/pg-file-snapshot-store.d.ts +8 -0
  69. package/dist/plugins/pg-file-snapshot-store.js +8 -0
  70. package/dist/plugins/pg-image-bake.d.ts +12 -0
  71. package/dist/plugins/pg-image-bake.js +11 -0
  72. package/dist/plugins/pg-image-index.d.ts +12 -0
  73. package/dist/plugins/pg-image-index.js +11 -0
  74. package/dist/plugins/pg-outcome-ledger.d.ts +12 -0
  75. package/dist/plugins/pg-outcome-ledger.js +11 -0
  76. package/dist/plugins/pg-pool.js +11 -0
  77. package/dist/plugins/pg-resume-anchor-store.d.ts +7 -0
  78. package/dist/plugins/pg-resume-anchor-store.js +7 -0
  79. package/dist/plugins/pg-run-store.d.ts +9 -0
  80. package/dist/plugins/pg-run-store.js +9 -0
  81. package/dist/plugins/pg-session-policy-store.d.ts +7 -0
  82. package/dist/plugins/pg-session-policy-store.js +7 -0
  83. package/dist/plugins/pg-session-store.d.ts +12 -0
  84. package/dist/plugins/pg-session-store.js +12 -0
  85. package/dist/plugins/pg-tool-result-store.d.ts +9 -0
  86. package/dist/plugins/pg-tool-result-store.js +9 -0
  87. package/dist/plugins/pg-workflow-journal-store.d.ts +9 -0
  88. package/dist/plugins/pg-workflow-journal-store.js +9 -0
  89. package/dist/plugins/pg-workflow-run-store.d.ts +9 -0
  90. package/dist/plugins/pg-workflow-run-store.js +9 -0
  91. package/dist/plugins/store-backend.d.ts +18 -0
  92. package/dist/plugins/store-backend.js +10 -0
  93. package/dist/plugins/tidb-approval-store.d.ts +8 -0
  94. package/dist/plugins/tidb-approval-store.js +8 -0
  95. package/dist/plugins/tidb-breaker-state.d.ts +7 -0
  96. package/dist/plugins/tidb-breaker-state.js +7 -0
  97. package/dist/plugins/tidb-checkpoint-store.d.ts +9 -0
  98. package/dist/plugins/tidb-checkpoint-store.js +9 -0
  99. package/dist/plugins/tidb-file-snapshot-store.d.ts +8 -0
  100. package/dist/plugins/tidb-file-snapshot-store.js +8 -0
  101. package/dist/plugins/tidb-image-bake.d.ts +12 -0
  102. package/dist/plugins/tidb-image-bake.js +11 -0
  103. package/dist/plugins/tidb-image-index.d.ts +12 -0
  104. package/dist/plugins/tidb-image-index.js +11 -0
  105. package/dist/plugins/tidb-outcome-ledger.d.ts +12 -0
  106. package/dist/plugins/tidb-outcome-ledger.js +12 -0
  107. package/dist/plugins/tidb-pool.js +27 -4
  108. package/dist/plugins/tidb-resume-anchor-store.d.ts +7 -0
  109. package/dist/plugins/tidb-resume-anchor-store.js +7 -0
  110. package/dist/plugins/tidb-run-store.d.ts +10 -0
  111. package/dist/plugins/tidb-run-store.js +9 -0
  112. package/dist/plugins/tidb-session-policy-store.d.ts +7 -0
  113. package/dist/plugins/tidb-session-policy-store.js +7 -0
  114. package/dist/plugins/tidb-tool-result-store.d.ts +8 -0
  115. package/dist/plugins/tidb-tool-result-store.js +10 -0
  116. package/dist/plugins/tidb-workflow-journal-store.d.ts +9 -0
  117. package/dist/plugins/tidb-workflow-journal-store.js +9 -0
  118. package/dist/plugins/tidb-workflow-run-store.d.ts +10 -0
  119. package/dist/plugins/tidb-workflow-run-store.js +10 -0
  120. package/dist/plugins/workflow-journal-limits.d.ts +12 -0
  121. package/dist/plugins/workflow-journal-limits.js +12 -0
  122. package/dist/question.d.ts +21 -14
  123. package/dist/question.js +83 -34
  124. package/dist/runs.d.ts +16 -1
  125. package/dist/runs.js +61 -3
  126. package/dist/runtime-caps-resolver.d.ts +7 -1
  127. package/dist/runtime-caps-resolver.js +65 -3
  128. package/dist/sema-registry.d.ts +41 -0
  129. package/dist/sema-registry.js +40 -0
  130. package/dist/spec-fields.d.ts +4 -0
  131. package/dist/spec-fields.js +6 -0
  132. package/dist/task-settings.d.ts +36 -15
  133. package/dist/task-settings.js +19 -5
  134. package/dist/tool-approval.d.ts +296 -3
  135. package/dist/tool-approval.js +1074 -50
  136. package/dist/trace/core-keyset-guard.d.ts +2 -2
  137. package/dist/trace/ledger-sink.js +14 -1
  138. package/dist/trace/project.d.ts +90 -0
  139. package/dist/trace/project.js +188 -0
  140. package/package.json +5 -4
@@ -0,0 +1,84 @@
1
+ /**
2
+ * #154 件二+件三 —— **装配自证**域:启动期静态自检(拒启判据)与 operator 诊断读面
3
+ * (`GET /v1/diagnostics/wiring`)。
4
+ *
5
+ * 🔴 两件为什么同住一个模块:它们回答的是同一个问题(「这台 worker 到底接了什么线」),只是一个在 boot
6
+ * 用它拒绝启动、一个在运行期把它读给 operator。分成两处 = 拒启用的判据与诊断报的读数会各自演化,而
7
+ * 「拒启说没矛盾、诊断页显示矛盾」正是本设计要消灭的那类装配谎言。故 boot 半场是本文件导出的**纯函数**
8
+ * (可单测、无 I/O),路由半场只是它的读口。
9
+ *
10
+ * 分层:本模块不值 import `server.ts`(那条边会闭合运行时装载环),对它只有 `import type`。
11
+ */
12
+ import type { IncomingMessage, ServerResponse } from "node:http";
13
+ import type { WiringManifest } from "@sema-agent/core";
14
+ import { type StreamApprovalGate, type StreamApprovalGateInput } from "../../tool-approval.js";
15
+ import type { RouteCtx } from "../route-ctx.js";
16
+ /** 流内审批门的读数形:上场即 `"active"`,否则是那五个合取项里**第一个**不满足的原因词
17
+ * (与 `resolveStreamApprovalGate` 同一闭集,新增 reason 在此处编译红)。 */
18
+ export type StreamApprovalGateReading = "active" | Extract<StreamApprovalGate, {
19
+ active: false;
20
+ }>["reason"];
21
+ /** server 自己的装配谓词读数(core 的静态半场之外的那一半:本仓在这台 worker 上做出的判断)。 */
22
+ export interface ServerWiringGates {
23
+ streamApproval: StreamApprovalGateReading;
24
+ durableApproval: boolean;
25
+ checkpointStore: boolean;
26
+ }
27
+ /** `buildServerWiringGates` 的入参 = 三个谓词各自的**真输入**(不接受已算好的布尔:那样这里读到的就
28
+ * 不再是装配现场的事实,而是别处算完可能已漂的复述)。 */
29
+ export interface ServerWiringGateInput {
30
+ toolApprovalEnabled: boolean;
31
+ streamApprovalEnabled: boolean;
32
+ /** 谓词自己的入参类型(结构形,不 import store 依赖树)—— 取型而非重述,两处不可能漂。 */
33
+ backend: StreamApprovalGateInput["backend"];
34
+ /** 在场性即事实;本面不取实例,故 `unknown` 足够(取窄型会把整棵 store 类型树拖进诊断域)。 */
35
+ checkpointStore: unknown;
36
+ durableApproval: boolean;
37
+ }
38
+ /** 纯数据产物(`build*`):三个门的当前读数。`streamApproval` 走**单一谓词**
39
+ * `resolveStreamApprovalGate` —— 与 `/v1/capabilities` 的 `streamApproval` 位、与回决口的 501 门同一个
40
+ * 符号,所以诊断页读到的与消费端撞到的行为不可能不同。 */
41
+ export declare function buildServerWiringGates(input: ServerWiringGateInput): ServerWiringGates;
42
+ /** 启动自检的判决:`refusals` 非空 ⇒ 拒启(装配谎言);`warnings` ⇒ 留痕但放行。 */
43
+ export interface StaticWiringAudit {
44
+ refusals: readonly string[];
45
+ warnings: readonly string[];
46
+ }
47
+ /** 自检输入 = core 的静态半场 + 我方装配现场的两件事实。 */
48
+ export interface StaticWiringFacts {
49
+ /** core `describeStaticWiring(deps, specTemplate)` 的产物。 */
50
+ manifest: WiringManifest;
51
+ /** 我方喂给 `resolveStreamApprovalGate` 的 `parkFacility` 实参(= checkpoint 店在场 ∧ DURABLE_APPROVAL)。 */
52
+ parkFacility: boolean;
53
+ /** store backend 的种类;`undefined` = env-only worker(无 backend)。 */
54
+ backendKind: "mysql" | "pg" | "local" | undefined;
55
+ }
56
+ /**
57
+ * 三项对表(设计稿件二)。判据全是**两个独立谓词对同一件事的答案**,矛盾即装配谎言 —— 装配谎言不是
58
+ * 「配置不理想」,是「服务端对自己接了什么线的两套说法互斥」,继续启动只会把矛盾带进运行期的每一条腿。
59
+ *
60
+ * ① park 设施:core 从 `spec.checkpointStore ?? deps.checkpointStore` 判 `parkLane.capable`,我方从
61
+ * `backend.checkpoint ∧ DURABLE_APPROVAL` 判 `parkFacility` 并据此决定流内审批协议上不上场。两者
62
+ * 不等 ⇒ 协议按「窗到期能 park」上场而引擎侧根本不 park(结局是 core fail-closed deny),或反之
63
+ * 白白关掉一个可用的协议。`capable` 真而 `effective` 不真同样致命:能力在、这条部署形上却不会真的
64
+ * park,窗到期依旧无降级目的地。
65
+ * ② 会话店持久性:manifest 声明 `declared_durable` 而后端是 local / 根本没有后端 ⇒ 「重启存活」的声明
66
+ * 没有介质兑现。这条与 memory+durable 两条既有拒启同族(声明与介质必须对得上)。
67
+ * ③ interaction posture 声明 `interactive` 却没有任何 question 投递面 ⇒ 只 **warn**:core 在 prepare 时
68
+ * 会按腿拒,boot 先一步把话说成人话。不拒启,因为部署形本身可能只是暂时没接活体面,而 core 侧已有
69
+ * 兜底门 —— 拒启会把一个可运行的部署挡在门外。
70
+ * ④ park 车道的持久性读数不可信时 ⇒ **warn**(理由与这条判据为什么不是拒启,见其行内注)。
71
+ *
72
+ * 判决分两级是有判据的:**拒启**留给「两个谓词对同一件事互斥」(其中一个必错,继续跑就是带着谎言服务);
73
+ * **警告**留给「读数不可信/声明不完整」(信号本身还不足以断定谁错,据此拒启会挡住正常部署)。
74
+ */
75
+ export declare function buildStaticWiringAudit(facts: StaticWiringFacts): StaticWiringAudit;
76
+ /**
77
+ * boot 消费口:`refusals` 非空即抛(拒启,与 memory+durable 两条既有拒启同族的 fail-loud 形),
78
+ * `warnings` 逐条 warn。返回判决本体,调用方可以继续把读数打进启动 info 行。
79
+ */
80
+ export declare function assertStaticWiringConsistent(facts: StaticWiringFacts, logger: {
81
+ warn: (msg: string, meta?: Record<string, unknown>) => void;
82
+ } | undefined): StaticWiringAudit;
83
+ export declare function handleDiagnostics(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
84
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1,140 @@
1
+ import { resolveStreamApprovalGate } from "../../tool-approval.js";
2
+ import { sendJson, sendError } from "../send.js";
3
+ import { gatedPrincipal, explicitOperatorOk } from "../principal-gate.js";
4
+ /** 纯数据产物(`build*`):三个门的当前读数。`streamApproval` 走**单一谓词**
5
+ * `resolveStreamApprovalGate` —— 与 `/v1/capabilities` 的 `streamApproval` 位、与回决口的 501 门同一个
6
+ * 符号,所以诊断页读到的与消费端撞到的行为不可能不同。 */
7
+ export function buildServerWiringGates(input) {
8
+ const gate = resolveStreamApprovalGate({
9
+ toolApprovalEnabled: input.toolApprovalEnabled,
10
+ streamApprovalEnabled: input.streamApprovalEnabled,
11
+ backend: input.backend,
12
+ parkFacility: input.checkpointStore !== undefined,
13
+ });
14
+ return {
15
+ streamApproval: gate.active ? "active" : gate.reason,
16
+ durableApproval: input.durableApproval,
17
+ checkpointStore: input.checkpointStore !== undefined,
18
+ };
19
+ }
20
+ /**
21
+ * 三项对表(设计稿件二)。判据全是**两个独立谓词对同一件事的答案**,矛盾即装配谎言 —— 装配谎言不是
22
+ * 「配置不理想」,是「服务端对自己接了什么线的两套说法互斥」,继续启动只会把矛盾带进运行期的每一条腿。
23
+ *
24
+ * ① park 设施:core 从 `spec.checkpointStore ?? deps.checkpointStore` 判 `parkLane.capable`,我方从
25
+ * `backend.checkpoint ∧ DURABLE_APPROVAL` 判 `parkFacility` 并据此决定流内审批协议上不上场。两者
26
+ * 不等 ⇒ 协议按「窗到期能 park」上场而引擎侧根本不 park(结局是 core fail-closed deny),或反之
27
+ * 白白关掉一个可用的协议。`capable` 真而 `effective` 不真同样致命:能力在、这条部署形上却不会真的
28
+ * park,窗到期依旧无降级目的地。
29
+ * ② 会话店持久性:manifest 声明 `declared_durable` 而后端是 local / 根本没有后端 ⇒ 「重启存活」的声明
30
+ * 没有介质兑现。这条与 memory+durable 两条既有拒启同族(声明与介质必须对得上)。
31
+ * ③ interaction posture 声明 `interactive` 却没有任何 question 投递面 ⇒ 只 **warn**:core 在 prepare 时
32
+ * 会按腿拒,boot 先一步把话说成人话。不拒启,因为部署形本身可能只是暂时没接活体面,而 core 侧已有
33
+ * 兜底门 —— 拒启会把一个可运行的部署挡在门外。
34
+ * ④ park 车道的持久性读数不可信时 ⇒ **warn**(理由与这条判据为什么不是拒启,见其行内注)。
35
+ *
36
+ * 判决分两级是有判据的:**拒启**留给「两个谓词对同一件事互斥」(其中一个必错,继续跑就是带着谎言服务);
37
+ * **警告**留给「读数不可信/声明不完整」(信号本身还不足以断定谁错,据此拒启会挡住正常部署)。
38
+ */
39
+ export function buildStaticWiringAudit(facts) {
40
+ const refusals = [];
41
+ const warnings = [];
42
+ const park = facts.manifest.parkLane;
43
+ if (park.capable !== facts.parkFacility) {
44
+ refusals.push(`park facility contradiction: the engine's static wiring says parkLane.capable=${park.capable} while this server assembled its approval gates with parkFacility=${facts.parkFacility}. ` +
45
+ `One of the two is wrong about the same checkpoint store — refusing to start rather than serving a worker whose approval lane can silently fail closed. ` +
46
+ `Check DURABLE_APPROVAL and the backend's checkpoint face (they are what both predicates read).`);
47
+ }
48
+ else if (facts.parkFacility && park.effective !== true) {
49
+ refusals.push(`park facility contradiction: this server assembled its approval gates with parkFacility=true, but the engine's static wiring resolves parkLane.effective=${JSON.stringify(park.effective)} (reasons: ${park.reasons.join(", ") || "none"}). ` +
50
+ `A window expiry would then have no degradation target and adjudicate as a fail-closed deny — refusing to start.`);
51
+ }
52
+ // 判据写成「不在持久集合里」而不是「是 local」是有方向的:将来多一种 backend kind 时,它会**拒启**
53
+ // 直到有人显式把它判进持久集,而不是静默通过 —— 声明与介质的对表,失败方向必须朝拒绝那边。
54
+ if (facts.manifest.session.store === "declared_durable" && facts.backendKind !== "mysql" && facts.backendKind !== "pg") {
55
+ refusals.push(`session store durability contradiction: the engine's static wiring reports session.store="declared_durable" while the store backend is ${facts.backendKind === undefined ? "absent (env-only worker)" : `"${facts.backendKind}"`}. ` +
56
+ `A durable declaration with no durable medium is a claim nothing can honor — refusing to start. Wire DB_BACKEND=mysql|pg, or fix the store's durability declaration.`);
57
+ }
58
+ // park 车道的**持久性读数**(codex 交叉复审 2026-08-07 R2-F2,验真后部分采纳)。`capable` 说的是
59
+ // 「有没有 checkpoint 店」、`effective` 说的是「这条部署形会不会真 park」—— 两者都为真时仍可能是一个
60
+ // 重启即丢的店,那样窗到期后被 park 的审批在重启后无法赎回,而流内审批协议正是拿 park 当降级目的地。
61
+ // 🔴 为什么是 **warn 而不是拒启**:本仓的 SQL/local checkpoint 店**都还没有 `durability` 声明**,core
62
+ // 因此对每一个真持久部署都读出 `process_local`。据此拒启会拿一个不可信信号挡住 100% 的现存 durable
63
+ // 部署 —— 那不是查出矛盾。根治在店侧补声明;在那之前,把「这个读数不可信」响亮说出来,不静默。
64
+ if (facts.parkFacility && facts.manifest.parkLane.checkpointDurability !== "declared_durable") {
65
+ warnings.push(`park facility is enabled but the checkpoint store does not declare durable storage ` +
66
+ `(parkLane.checkpointDurability=${JSON.stringify(facts.manifest.parkLane.checkpointDurability ?? null)}). ` +
67
+ `A parked approval survives a restart only on a durable store — and the in-tree checkpoint adapters currently declare no durability at all, so this reading cannot yet distinguish "really process-local" from "nobody declared it". ` +
68
+ `Treat park-lane recovery as unproven until the adapter declares its durability.`);
69
+ }
70
+ if (facts.manifest.interaction.posture === "interactive" && facts.manifest.question.wired !== "wired") {
71
+ warnings.push(`interactionPosture declares "interactive" but no question delivery face is wired (question.wired=${JSON.stringify(facts.manifest.question.wired)}) — ` +
72
+ `every leg that asks a question will be refused by the engine at prepare time. Wire the live question seam (ASK_QUESTION_ENABLED), or declare the headless posture.`);
73
+ }
74
+ return { refusals, warnings };
75
+ }
76
+ /**
77
+ * boot 消费口:`refusals` 非空即抛(拒启,与 memory+durable 两条既有拒启同族的 fail-loud 形),
78
+ * `warnings` 逐条 warn。返回判决本体,调用方可以继续把读数打进启动 info 行。
79
+ */
80
+ export function assertStaticWiringConsistent(facts, logger) {
81
+ const audit = buildStaticWiringAudit(facts);
82
+ for (const w of audit.warnings)
83
+ logger?.warn("wiring_static_warning", { detail: w });
84
+ if (audit.refusals.length > 0) {
85
+ throw new Error(`static wiring self-check failed — refusing to start:\n${audit.refusals.map((r) => ` · ${r}`).join("\n")}`);
86
+ }
87
+ return audit;
88
+ }
89
+ export async function handleDiagnostics(req, res, url, ctx) {
90
+ const miss = { fell: false };
91
+ await handleDiagnosticsBody(req, res, url, ctx, miss);
92
+ return !miss.fell;
93
+ }
94
+ async function handleDiagnosticsBody(req, res, url, ctx, miss) {
95
+ const { deps } = ctx;
96
+ // 件三:「这台 worker 到底接了什么线」一屏看清 = core 的静态半场(含 `governance` 段 —— 本面**就是**
97
+ // 那个段的 operator 受众)+ server 自己三个装配谓词的读数。
98
+ //
99
+ // 门 = `explicitOperatorOk`(**不是** `isOperator`)。执法条件是**名单在场 ∨ 多租户**,不是只看
100
+ // `REQUIRE_PRINCIPAL`:本件的 SSE 腿对同一段 governance 恒判 `explicitOperatorOk`,若这里只在
101
+ // REQUIRE_PRINCIPAL 时判,「列了 operator 名单却没开 REQUIRE_PRINCIPAL」的部署上就成了流里关着、
102
+ // 端点上开着 —— 一个秘密两套门,严的那道白严(codex 交叉复审 2026-08-07 R2-F1,验真后采纳)。
103
+ // 名单为空 ∧ 非多租户 = 单租户 turnkey:该部署没有 operator 这个概念,唯一的用户就是 operator,
104
+ // 边界由全局 service-credential 门把守(与 `GET /v1/outcomes` 同裁)。
105
+ // 401 由更上游的全局门给出,本域只判 operator 与否。
106
+ //
107
+ // ⚠️ 与 SSE 腿的**残余不对称**(显式裁定,不是疏忽):turnkey 形上流里仍然谁都拿不到治理段,而本端点
108
+ // 给。理由=流是多订阅面且身份来自连接、端点是一次显式的 operator 请求;失败方向因此在流那侧更严。
109
+ //
110
+ // **不含** per-leg effective 历史:治理段只存在于 live 帧的 operator 投影里,durable 账本恒存剥后形
111
+ // (账本写时不知道未来读者是谁)。历史考古是另一件事,不在本面伪装成有。
112
+ if (req.method === "GET" && url === "/v1/diagnostics/wiring") {
113
+ if (deps.config.operatorPrincipals.length > 0 || deps.config.requirePrincipal) {
114
+ const principal = gatedPrincipal(req, deps.config);
115
+ if (!explicitOperatorOk(principal, deps.config.operatorPrincipals)) {
116
+ sendError(res, 403, "auth.operator_only", "wiring diagnostics are operator-only on a multi-tenant worker");
117
+ return;
118
+ }
119
+ }
120
+ // 静态半场是 **composition root 在 boot 算的**(与拒启自检同一份产物,不可能与它不同)。缺席 ⇒ 这个
121
+ // 进程不是由 main.ts 装起来的(测试夹具形),此面诚实地不存在 —— 落到全局 404,而不是回一个空壳 200。
122
+ if (!deps.staticWiring) {
123
+ miss.fell = true;
124
+ return;
125
+ }
126
+ sendJson(res, 200, {
127
+ static: deps.staticWiring,
128
+ serverGates: buildServerWiringGates({
129
+ toolApprovalEnabled: deps.toolApproval !== undefined,
130
+ streamApprovalEnabled: deps.config.streamApproval?.enabled === true,
131
+ backend: deps.backend,
132
+ checkpointStore: deps.checkpointStore,
133
+ durableApproval: deps.config.durableApproval === true,
134
+ }),
135
+ });
136
+ return;
137
+ }
138
+ miss.fell = true;
139
+ }
140
+ //# sourceMappingURL=diagnostics.js.map
@@ -22,6 +22,7 @@ export declare const RUN_COMPACT_RE: RegExp;
22
22
  export declare const ELICIT_RESPOND_RE: RegExp;
23
23
  export declare const QUESTION_RESPOND_RE: RegExp;
24
24
  export declare const TOOL_APPROVAL_RESPOND_RE: RegExp;
25
+ export declare const TASK_ASK_DECISION_RE: RegExp;
25
26
  export declare const RUN_SUBAGENT_STEER_RE: RegExp;
26
27
  export declare const RUN_SUBAGENT_RESUME_RE: RegExp;
27
28
  export declare const RUN_SUBAGENT_OUTPUT_RE: RegExp;