@sema-agent/server 7.52.1 → 7.54.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 (342) hide show
  1. package/USAGE.md +7 -1
  2. package/dist/adoption/plan.d.ts +3 -3
  3. package/dist/adoption/quiesce.d.ts +1 -1
  4. package/dist/adoption/sql.d.ts +2 -2
  5. package/dist/adoption/wire.d.ts +1 -1
  6. package/dist/approval-ask-machine.d.ts +2 -2
  7. package/dist/approval-card.d.ts +18 -18
  8. package/dist/approval-deny-reasons.d.ts +1 -1
  9. package/dist/approval-hmac.d.ts +2 -2
  10. package/dist/approval-reconciler.d.ts +14 -14
  11. package/dist/approval.d.ts +2 -2
  12. package/dist/audit.d.ts +4 -4
  13. package/dist/auth-keys.d.ts +6 -6
  14. package/dist/bench/l8/artifact.d.ts +6 -1
  15. package/dist/bench/l8/artifact.js +2 -27
  16. package/dist/bench/l8/escape.d.ts +3 -3
  17. package/dist/bench/l8/index.d.ts +1 -1
  18. package/dist/bench/s1/arms.d.ts +3 -3
  19. package/dist/bench/s1/oracle.d.ts +2 -2
  20. package/dist/bench/s1/reviewer.d.ts +1 -1
  21. package/dist/bench/s1/row.d.ts +5 -5
  22. package/dist/bench/s1/runner-ctx.d.ts +3 -3
  23. package/dist/boot/config-center.d.ts +14 -7
  24. package/dist/boot/config-center.js +4 -2
  25. package/dist/boot/coordinators.d.ts +4 -4
  26. package/dist/boot/crash-last.d.ts +1 -1
  27. package/dist/boot/device-lane.d.ts +3 -3
  28. package/dist/boot/engine-lease.d.ts +4 -4
  29. package/dist/boot/governance-seams.d.ts +5 -5
  30. package/dist/boot/leader.d.ts +5 -5
  31. package/dist/boot/leader.js +2 -0
  32. package/dist/boot/limit-sync.d.ts +1 -1
  33. package/dist/boot/memory-boundary.d.ts +5 -5
  34. package/dist/boot/memory-consolidation.d.ts +8 -2
  35. package/dist/boot/memory-consolidation.js +1 -0
  36. package/dist/boot/org-memory.d.ts +5 -5
  37. package/dist/boot/parked-revive-gate.d.ts +6 -6
  38. package/dist/boot/permission-rules-audit.d.ts +2 -2
  39. package/dist/boot/reapers.d.ts +8 -8
  40. package/dist/boot/resolve-spec.d.ts +4 -4
  41. package/dist/boot/resolve-spec.js +1 -3
  42. package/dist/boot/retention-lane.d.ts +1 -1
  43. package/dist/boot/runner-deps.d.ts +53 -27
  44. package/dist/boot/runner-deps.js +16 -9
  45. package/dist/boot/runtime-caps.d.ts +4 -4
  46. package/dist/boot/session-faces.d.ts +1 -1
  47. package/dist/boot/shutdown.d.ts +10 -10
  48. package/dist/boot/shutdown.js +1 -1
  49. package/dist/boot/side-query-lane.d.ts +14 -14
  50. package/dist/boot/stores.js +5 -0
  51. package/dist/boot/task-list-lane.d.ts +3 -3
  52. package/dist/boot/webfetch-summarize-lane.d.ts +9 -9
  53. package/dist/boot/workflow-orchestration.d.ts +1 -1
  54. package/dist/bounded-session-map.d.ts +1 -1
  55. package/dist/brain.d.ts +3 -3
  56. package/dist/budget.d.ts +3 -3
  57. package/dist/canonical-json.d.ts +53 -0
  58. package/dist/canonical-json.js +48 -0
  59. package/dist/capabilities/center-prompts.d.ts +13 -13
  60. package/dist/capabilities/collab-workflows.d.ts +1 -1
  61. package/dist/capabilities/hands-lane.d.ts +4 -4
  62. package/dist/capabilities/memory-notice.d.ts +4 -4
  63. package/dist/capabilities/prompt.d.ts +2 -2
  64. package/dist/capabilities/sandbox-file-send.d.ts +2 -2
  65. package/dist/capabilities/scenarios.d.ts +16 -16
  66. package/dist/capabilities/skills.d.ts +1 -1
  67. package/dist/capabilities/team.d.ts +13 -12
  68. package/dist/capabilities/tool-defer.d.ts +6 -6
  69. package/dist/config-catalog.d.ts +139 -0
  70. package/dist/config-catalog.js +556 -0
  71. package/dist/config-center/apply-effective.d.ts +42 -30
  72. package/dist/config-center/apply-effective.js +69 -62
  73. package/dist/config-center/apply-ledger.d.ts +6 -6
  74. package/dist/config-center/effective-keys.d.ts +30 -0
  75. package/dist/config-center/effective-keys.js +49 -0
  76. package/dist/config-center/facade.d.ts +6 -5
  77. package/dist/config-center/facade.js +1 -1
  78. package/dist/config-center/hot-keys-registry.d.ts +2 -2
  79. package/dist/config-center/http-client.d.ts +5 -5
  80. package/dist/config-center/mcp-revocation.d.ts +6 -4
  81. package/dist/config-center/mcp-revocation.js +2 -12
  82. package/dist/config-center/restart-signal.d.ts +11 -1
  83. package/dist/config-center/restart-signal.js +4 -10
  84. package/dist/config-center/skills-mcp.d.ts +2 -2
  85. package/dist/config-center/stage-limits.d.ts +3 -3
  86. package/dist/config-center/types.d.ts +42 -59
  87. package/dist/config-invariants.d.ts +1 -1
  88. package/dist/config-lkg.js +7 -1
  89. package/dist/config-provider.d.ts +2 -2
  90. package/dist/config-provider.js +1 -1
  91. package/dist/config-types.d.ts +140 -132
  92. package/dist/config.d.ts +22 -22
  93. package/dist/config.js +2 -1
  94. package/dist/degenerate-instrument.d.ts +1 -1
  95. package/dist/deployment-governance.d.ts +13 -13
  96. package/dist/device-enrollment.d.ts +5 -3
  97. package/dist/device-store.d.ts +17 -3
  98. package/dist/device-store.js +2 -0
  99. package/dist/device-ws-hub.d.ts +10 -5
  100. package/dist/device-ws-hub.js +25 -5
  101. package/dist/device-ws-protocol.d.ts +3 -3
  102. package/dist/digest-form.d.ts +1 -1
  103. package/dist/elicitation.d.ts +1 -1
  104. package/dist/env-facts.d.ts +7 -7
  105. package/dist/execution-lane-caps.d.ts +5 -5
  106. package/dist/fleet/fleet-bus.d.ts +53 -53
  107. package/dist/fleet/fleet-reconciler.d.ts +2 -2
  108. package/dist/fleet/fleet-terminal-window.d.ts +1 -1
  109. package/dist/fleet/subagent-tail-bus.d.ts +3 -3
  110. package/dist/fleet-client.d.ts +3 -3
  111. package/dist/fleet-lease.d.ts +1 -1
  112. package/dist/hooks/branch-transcript.d.ts +2 -2
  113. package/dist/hooks/cc-agent-hook-prompt.d.ts +2 -2
  114. package/dist/hooks/cc-stop-prompt.d.ts +2 -2
  115. package/dist/hooks/hook-llm.d.ts +1 -1
  116. package/dist/hooks/hook-runner.d.ts +5 -5
  117. package/dist/http/active-run-conflict.d.ts +31 -33
  118. package/dist/http/active-run-conflict.js +4 -2
  119. package/dist/http/route-ctx.d.ts +22 -22
  120. package/dist/http/routes/a2a-serve.d.ts +2 -2
  121. package/dist/http/routes/admin-config-refresh.d.ts +1 -1
  122. package/dist/http/routes/admin-drain.d.ts +4 -4
  123. package/dist/http/routes/admin-memory-optout.d.ts +5 -5
  124. package/dist/http/routes/adoption.d.ts +1 -1
  125. package/dist/http/routes/agents-roster.d.ts +1 -1
  126. package/dist/http/routes/approvals-assistant.d.ts +6 -6
  127. package/dist/http/routes/approvals-assistant.js +4 -1
  128. package/dist/http/routes/capabilities.d.ts +1 -1
  129. package/dist/http/routes/capabilities.js +1 -0
  130. package/dist/http/routes/config-catalog.d.ts +28 -0
  131. package/dist/http/routes/config-catalog.js +42 -0
  132. package/dist/http/routes/diagnostics.d.ts +2 -2
  133. package/dist/http/routes/fleet.d.ts +1 -1
  134. package/dist/http/routes/images.d.ts +1 -1
  135. package/dist/http/routes/leader.d.ts +1 -1
  136. package/dist/http/routes/memory-bundle.d.ts +4 -4
  137. package/dist/http/routes/memory-compliance.d.ts +7 -7
  138. package/dist/http/routes/memory-consolidation.d.ts +1 -1
  139. package/dist/http/routes/memory-origin.d.ts +9 -9
  140. package/dist/http/routes/memory-policy.d.ts +3 -3
  141. package/dist/http/routes/notify-wake.d.ts +1 -1
  142. package/dist/http/routes/observability.d.ts +1 -1
  143. package/dist/http/routes/retention-ops.d.ts +1 -1
  144. package/dist/http/routes/rules.d.ts +3 -3
  145. package/dist/http/routes/run-memory-capture.d.ts +1 -1
  146. package/dist/http/routes/runs.d.ts +3 -3
  147. package/dist/http/routes/runs.js +12 -17
  148. package/dist/http/routes/session-sync.d.ts +2 -2
  149. package/dist/http/routes/sessions-list.d.ts +1 -1
  150. package/dist/http/routes/sessions.d.ts +9 -1
  151. package/dist/http/routes/sessions.js +60 -0
  152. package/dist/http/routes/shared-memory.d.ts +1 -1
  153. package/dist/http/routes/side-query.d.ts +1 -1
  154. package/dist/http/routes/tasks.d.ts +1 -1
  155. package/dist/http/routes/trace-usage.d.ts +1 -1
  156. package/dist/http/routes/workflows.d.ts +1 -1
  157. package/dist/http/run-meta.d.ts +1 -1
  158. package/dist/http/send.d.ts +6 -6
  159. package/dist/http/server.d.ts +84 -67
  160. package/dist/http/server.js +39 -10
  161. package/dist/http/sse-lifecycle.d.ts +1 -1
  162. package/dist/http/sse-log.d.ts +6 -6
  163. package/dist/http/verify-rounds.d.ts +3 -3
  164. package/dist/http/wire-gate.d.ts +2 -2
  165. package/dist/http/wire-types.d.ts +57 -38
  166. package/dist/key-resolver.d.ts +1 -1
  167. package/dist/leader/diffout.d.ts +2 -2
  168. package/dist/leader/diffup.d.ts +1 -1
  169. package/dist/leader/endpoint.d.ts +1 -1
  170. package/dist/leader/fanout.d.ts +6 -6
  171. package/dist/leader/grader-env-factory.d.ts +1 -1
  172. package/dist/leader/leader.d.ts +12 -12
  173. package/dist/leader/merge.d.ts +3 -3
  174. package/dist/leader/planner.d.ts +5 -5
  175. package/dist/leader/repair-oracle.d.ts +1 -1
  176. package/dist/leader/wire.d.ts +21 -9
  177. package/dist/leader/wire.js +6 -5
  178. package/dist/lsp/manager.d.ts +2 -2
  179. package/dist/lsp/types.d.ts +1 -1
  180. package/dist/lsp/ws-transport.d.ts +2 -2
  181. package/dist/main.js +12 -2
  182. package/dist/mcp-content-origin.d.ts +1 -1
  183. package/dist/memory-bundle-engine.d.ts +5 -3
  184. package/dist/memory-bundle-engine.js +2 -2
  185. package/dist/memory-operator-faces.d.ts +41 -11
  186. package/dist/memory-operator-faces.js +12 -0
  187. package/dist/memory-origin-fence.d.ts +1 -1
  188. package/dist/memory-origin-fence.js +2 -13
  189. package/dist/memory-posture.d.ts +6 -6
  190. package/dist/memory-scope.d.ts +7 -7
  191. package/dist/model-select.d.ts +5 -5
  192. package/dist/observability/cost-quota.d.ts +6 -6
  193. package/dist/observability/cost-taxonomy.d.ts +2 -2
  194. package/dist/observability/fail-open.d.ts +17 -5
  195. package/dist/observability/fail-open.js +16 -4
  196. package/dist/observability/metrics.d.ts +1 -1
  197. package/dist/observability/prompt-manifest.d.ts +8 -8
  198. package/dist/observability/rate-limit.d.ts +2 -2
  199. package/dist/observability/secret-env-scrub.d.ts +1 -1
  200. package/dist/observability/tool-trace.d.ts +1 -1
  201. package/dist/orchestration/hardened-vm-runner.d.ts +6 -6
  202. package/dist/orchestration/hardened-vm-worker-runner.d.ts +1 -1
  203. package/dist/orchestration/subagent-steer.d.ts +3 -3
  204. package/dist/orchestration/workflow-agent-steer.d.ts +1 -1
  205. package/dist/orchestration/workflow-completion-inbox.d.ts +6 -6
  206. package/dist/orchestration/workflow-notify-journal.d.ts +6 -6
  207. package/dist/parent-watch.d.ts +1 -1
  208. package/dist/parked-decide.d.ts +11 -11
  209. package/dist/plan-cache-probe.d.ts +1 -1
  210. package/dist/plugins/adoption-log-sql.d.ts +4 -4
  211. package/dist/plugins/approval-ask-store-memory.d.ts +1 -1
  212. package/dist/plugins/approval-ask-store-memory.js +12 -0
  213. package/dist/plugins/approval-ask-store-sql.d.ts +39 -17
  214. package/dist/plugins/approval-ask-store-sql.js +23 -6
  215. package/dist/plugins/approval-payload-fingerprint.d.ts +23 -0
  216. package/dist/plugins/approval-payload-fingerprint.js +23 -0
  217. package/dist/plugins/background-agent-store-sql.d.ts +8 -8
  218. package/dist/plugins/background-shell-support.d.ts +12 -12
  219. package/dist/plugins/blob-backend.d.ts +3 -3
  220. package/dist/plugins/breaker-state-sql.d.ts +3 -3
  221. package/dist/plugins/caching-session-store.d.ts +6 -6
  222. package/dist/plugins/checkpoint-store-sql.d.ts +162 -66
  223. package/dist/plugins/checkpoint-store-sql.js +76 -33
  224. package/dist/plugins/device-store-sql.d.ts +4 -3
  225. package/dist/plugins/e2b-orphan-reclaim.d.ts +3 -3
  226. package/dist/plugins/file-history-store-sql.d.ts +9 -8
  227. package/dist/plugins/file-run-store.d.ts +27 -27
  228. package/dist/plugins/fork-routing-session-store.d.ts +9 -9
  229. package/dist/plugins/image-bake-store-sql.d.ts +1 -1
  230. package/dist/plugins/image-index-sql.d.ts +2 -2
  231. package/dist/plugins/k8s-bg-scripts.d.ts +1 -1
  232. package/dist/plugins/k8s-exec-protocol.d.ts +1 -1
  233. package/dist/plugins/leader-run-store-sql.d.ts +1 -1
  234. package/dist/plugins/local-checkpoint-store.d.ts +26 -17
  235. package/dist/plugins/local-checkpoint-store.js +21 -11
  236. package/dist/plugins/local-session-store.d.ts +5 -5
  237. package/dist/plugins/mailbox-store-sql.d.ts +6 -6
  238. package/dist/plugins/memory-embedder-fingerprint.d.ts +2 -2
  239. package/dist/plugins/memory-engine-pg.d.ts +1 -1
  240. package/dist/plugins/memory-engine-tidb.d.ts +1 -1
  241. package/dist/plugins/memory-key-guards.d.ts +3 -3
  242. package/dist/plugins/memory-optout-grant-store-sql.d.ts +10 -10
  243. package/dist/plugins/memory-origin-law.d.ts +13 -13
  244. package/dist/plugins/memory-run-store.d.ts +12 -12
  245. package/dist/plugins/outcome-ledger-sql.d.ts +3 -3
  246. package/dist/plugins/permission-rule-store-file.d.ts +3 -3
  247. package/dist/plugins/permission-rule-store-sql.d.ts +38 -33
  248. package/dist/plugins/permission-rule-store-sql.js +7 -12
  249. package/dist/plugins/pg-cost-quota.d.ts +2 -2
  250. package/dist/plugins/pg-pool.d.ts +29 -2
  251. package/dist/plugins/pg-pool.js +50 -2
  252. package/dist/plugins/pg-query.d.ts +1 -1
  253. package/dist/plugins/pg-rate-limiter.d.ts +2 -2
  254. package/dist/plugins/pg-session-storage.d.ts +9 -9
  255. package/dist/plugins/remote-env-adb.d.ts +1 -1
  256. package/dist/plugins/remote-env-device.d.ts +6 -4
  257. package/dist/plugins/remote-env-device.js +4 -1
  258. package/dist/plugins/remote-env-e2b.d.ts +11 -11
  259. package/dist/plugins/remote-env-file-error.d.ts +2 -2
  260. package/dist/plugins/remote-env-host.d.ts +10 -10
  261. package/dist/plugins/remote-env-k8s.d.ts +7 -7
  262. package/dist/plugins/remote-env-local-docker.d.ts +1 -1
  263. package/dist/plugins/remote-env-ssh.d.ts +9 -9
  264. package/dist/plugins/remote-scratchpad.d.ts +1 -1
  265. package/dist/plugins/resume-anchor-store-sql.d.ts +1 -1
  266. package/dist/plugins/retention-lane-store-sql.d.ts +2 -2
  267. package/dist/plugins/retention-store-sql.d.ts +11 -11
  268. package/dist/plugins/roster-store-sql.d.ts +6 -8
  269. package/dist/plugins/run-store-sql.d.ts +12 -12
  270. package/dist/plugins/scheduler-support.d.ts +1 -1
  271. package/dist/plugins/send-user-file.d.ts +1 -1
  272. package/dist/plugins/session-capture-record-store-sql.d.ts +99 -0
  273. package/dist/plugins/session-capture-record-store-sql.js +110 -0
  274. package/dist/plugins/session-placement.d.ts +1 -1
  275. package/dist/plugins/session-policy-store-sql.d.ts +2 -2
  276. package/dist/plugins/session-store.d.ts +3 -3
  277. package/dist/plugins/shared-memory-store-sql.d.ts +5 -5
  278. package/dist/plugins/sql-driver.d.ts +7 -7
  279. package/dist/plugins/sql-errors.d.ts +2 -2
  280. package/dist/plugins/sql-escape.d.ts +1 -1
  281. package/dist/plugins/sql-row-helpers.d.ts +1 -1
  282. package/dist/plugins/store-backend.d.ts +32 -19
  283. package/dist/plugins/store-backend.js +5 -1
  284. package/dist/plugins/store-contracts.d.ts +9 -9
  285. package/dist/plugins/task-list-store-sql.d.ts +3 -3
  286. package/dist/plugins/tidb-cost-quota.d.ts +3 -3
  287. package/dist/plugins/tidb-pool.d.ts +13 -0
  288. package/dist/plugins/tidb-pool.js +9 -0
  289. package/dist/plugins/tidb-rate-limiter.d.ts +2 -2
  290. package/dist/plugins/tidb-session-storage.d.ts +2 -2
  291. package/dist/plugins/tidb-session-store.d.ts +11 -11
  292. package/dist/plugins/tool-result-store-sql.d.ts +8 -8
  293. package/dist/plugins/usage-window-store-sql.d.ts +3 -3
  294. package/dist/plugins/web-search.d.ts +7 -7
  295. package/dist/plugins/workflow-journal-store-sql.d.ts +6 -6
  296. package/dist/plugins/workflow-run-store-sql.d.ts +1 -1
  297. package/dist/plugins/write-behind-counter.d.ts +6 -6
  298. package/dist/principal-jwt.d.ts +2 -2
  299. package/dist/project-memory.d.ts +1 -1
  300. package/dist/prompts-domain-validate.d.ts +8 -8
  301. package/dist/question.d.ts +3 -3
  302. package/dist/resource-suspend.d.ts +4 -4
  303. package/dist/resource-window.d.ts +3 -3
  304. package/dist/router/route-orchestration.d.ts +1 -1
  305. package/dist/rules-consent.d.ts +48 -40
  306. package/dist/run-local.d.ts +5 -5
  307. package/dist/runs.d.ts +19 -19
  308. package/dist/runtime-caps-resolver.d.ts +6 -6
  309. package/dist/runtime-governance.d.ts +11 -7
  310. package/dist/runtime-governance.js +23 -1
  311. package/dist/security.d.ts +13 -13
  312. package/dist/session-leaf-bus.d.ts +1 -1
  313. package/dist/session-sync-content.d.ts +4 -4
  314. package/dist/session-sync-kernel.d.ts +2 -2
  315. package/dist/session-sync.d.ts +13 -13
  316. package/dist/session-titler.d.ts +1 -1
  317. package/dist/session-watch.d.ts +3 -3
  318. package/dist/shared-memory-scope-authorizer.d.ts +4 -4
  319. package/dist/sighup-idle.d.ts +1 -1
  320. package/dist/spec-fields.d.ts +20 -20
  321. package/dist/ssh-host-key.d.ts +5 -5
  322. package/dist/store-live-probe.d.ts +2 -2
  323. package/dist/task-cwd.d.ts +11 -11
  324. package/dist/task-mcp.d.ts +5 -5
  325. package/dist/task-settings.d.ts +35 -35
  326. package/dist/task-workflow.d.ts +3 -3
  327. package/dist/text-bidi.d.ts +1 -1
  328. package/dist/tool-approval.d.ts +186 -182
  329. package/dist/tool-approval.js +247 -120
  330. package/dist/trace/core-keyset-guard.d.ts +19 -5
  331. package/dist/trace/engine-notice-wire.d.ts +7 -7
  332. package/dist/trace/engine-notice-wire.js +2 -0
  333. package/dist/trace/injection-tier.d.ts +11 -21
  334. package/dist/trace/injection-tier.js +3 -4
  335. package/dist/trace/ledger-events.d.ts +3 -3
  336. package/dist/trace/ledger-sink.d.ts +7 -7
  337. package/dist/trace/project.d.ts +31 -30
  338. package/dist/trace/project.js +1 -0
  339. package/dist/turn-activity.d.ts +4 -4
  340. package/dist/usage-analytics.d.ts +1 -1
  341. package/dist/wall-clock-jump-guard.d.ts +3 -3
  342. package/package.json +6 -6
@@ -0,0 +1,23 @@
1
+ import { createLogger } from "../observability/logger.js";
2
+ const fingerprintLogger = createLogger();
3
+ function canonicalFingerprintJson(v) {
4
+ if (v === null || typeof v !== "object")
5
+ return JSON.stringify(v) ?? "null";
6
+ if (Array.isArray(v))
7
+ return `[${v.map(canonicalFingerprintJson).join(",")}]`;
8
+ const entries = Object.entries(v)
9
+ .filter(([, val]) => val !== undefined)
10
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
11
+ return `{${entries.map(([k, val]) => `${JSON.stringify(k)}:${canonicalFingerprintJson(val)}`).join(",")}}`;
12
+ }
13
+ export function approvalPayloadFingerprint(v) {
14
+ try {
15
+ const fp = canonicalFingerprintJson([v.updatedInput ?? null, v.answer ?? null, v.reason ?? null]);
16
+ return fp;
17
+ }
18
+ catch (e) {
19
+ fingerprintLogger.warn("approval decision payload is not serializable — idempotent replay refused", { error: e instanceof Error ? e.message : String(e) });
20
+ return null;
21
+ }
22
+ }
23
+ //# sourceMappingURL=approval-payload-fingerprint.js.map
@@ -1,10 +1,10 @@
1
1
  /**
2
- * BackgroundAgentStore SQL twins(design/151 S1 server 半场,[1503] 提货单②)——core
2
+ * BackgroundAgentStore SQL twins([ref] S1 server 半场,[ref] 提货单②)——core
3
3
  * `RunnerDeps.backgroundAgentStore` / `SubagentToolOptions.background.agentStore` 的 TiDB/PG
4
4
  * 双方言实现:每个后台子代(`a*` 句柄)一行 durable 执行记录。
5
5
  *
6
6
  * 语义对齐真源 = core `InMemoryBackgroundAgentStore`(dist/core/background-agent-store.js),
7
- * 契约四条([1503] 必守):
7
+ * 契约四条([ref] 必守):
8
8
  * 1. `put` create-once:重复 (scope, handle) 键 → `BackgroundAgentStoreError("agent_record.already_exists")`
9
9
  * (唯一键原子,多副本安全);scope 缺席/空串拒收(与 core 同文案——default-deny 谓词下无 scope 的
10
10
  * 行会经 fallback 面变成公共可读)。
@@ -14,15 +14,15 @@
14
14
  * recentSteps 可能是大 blob);session 锚 = `sessionScoped ? owner : parentSessionId`,写入时物化为
15
15
  * `session_anchor` 列(anchor 为 NULL 的行 `= ?` 恒假 = core `anchor !== sessionId` 同义)。
16
16
  * 4. `delete` 条件删(可选 rev CAS);`reap` 三策略与 core 逐条同形(staleRunning 翻 failed 走
17
- * rev-CAS 逐行,竞态输了跳过不计;terminal maxAge/keep 按 spawnedAt DESC)。[1522] LOW6 记账:裸
17
+ * rev-CAS 逐行,竞态输了跳过不计;terminal maxAge/keep 按 spawnedAt DESC)。[ref] LOW6 记账:裸
18
18
  * `reap` 的批删 IN 无上界、stale 臂全量拉 record_json——server 自己的 retention 只走
19
19
  * reapDurableAgents(core 编排,不触这两条);第三方直调超大 scope 时自行分批。
20
20
  *
21
21
  * 行形:`record_json` = 全量真源(get 逐位读回);查询/谓词列全是投影,写入时从 record 物化
22
22
  * (展示列 name/agent_type 截到列宽 + PG 侧过 lossy 清洗——真源仍在 record_json;身份键列
23
23
  * scope/handle/owner/session 锚**不清洗不截断**:改写身份键会让行与 engine 查询键错位,含不可存
24
- * 字节的身份键=写入失败 fail-loud,与 [1439] 协议数据拒绝式同向)。
25
- * PG unstorable bytes([1439] 三层定谳):record/usage 走 `pgSafeJsonStringify`(观测/内容面 lossy
24
+ * 字节的身份键=写入失败 fail-loud,与 [ref] 协议数据拒绝式同向)。
25
+ * PG unstorable bytes([ref] 三层定谳):record/usage 走 `pgSafeJsonStringify`(观测/内容面 lossy
26
26
  * U+FFFD,与 run 行/journal 同族;终报含真 NUL 的病态输入换替换标记,内容面不失行);TiDB TEXT 存 verbatim。
27
27
  *
28
28
  * 键列 = 字节等价(TiDB VARBINARY / PG COLLATE "C"——roster F2 同案:PAD SPACE/大小写近撞不得穿过
@@ -52,7 +52,7 @@ export declare class TiDBBackgroundAgentStore implements BackgroundAgentStore {
52
52
  update(handle: string, scope: string, record: BackgroundAgentRecord, expect: {
53
53
  rev: number;
54
54
  }): Promise<boolean>;
55
- /** core 1.383([1565] 提货单)REQUIRED 新方法——原子守卫 CAS(claim 的 reservation/rollback/finalize
55
+ /** core 1.383([ref] 提货单)REQUIRED 新方法——原子守卫 CAS(claim 的 reservation/rollback/finalize
56
56
  * 绑定字段态非仅 rev:rev 可因无关写移动而字段义已变)。语义逐字对齐 core InMemoryBackgroundAgentStore
57
57
  * ({@link parkGuardConditions} 顶注)。 */
58
58
  updateIf(handle: string, scope: string, record: BackgroundAgentRecord, expect: {
@@ -79,7 +79,7 @@ export declare class TiDBBackgroundAgentStore implements BackgroundAgentStore {
79
79
  * 翻转集里」把 doomed 拆两批删 —— 重叠那批照样真删、只是不再计数。两边都不能用「doomed.size 当删除数」
80
80
  * 近似:并发写者(真心跳复活)会让 `status <> 'running'` 守卫少删几行,那时 doomed.size 会虚高。 */
81
81
  reap(scope: string, now: number, opts?: ReapOpts): Promise<number>;
82
- /** core 1.368([1516]②)可选接口成员落位(原 server 扩展 listReapScopes 更名对齐):当前持行
82
+ /** core 1.368([ref]②)可选接口成员落位(原 server 扩展 listReapScopes 更名对齐):当前持行
83
83
  * scope 枚举——reaper 的 per-scope 联合 reap 入口。JS 侧 sort 与 core InMemory 逐字节同序
84
84
  * (SQL ORDER BY 按 collation,非码元序)。 */
85
85
  listScopes(): Promise<string[]>;
@@ -92,7 +92,7 @@ export declare class PgBackgroundAgentStore implements BackgroundAgentStore {
92
92
  update(handle: string, scope: string, record: BackgroundAgentRecord, expect: {
93
93
  rev: number;
94
94
  }): Promise<boolean>;
95
- /** core 1.383([1565] 提货单)REQUIRED 新方法(TiDB twin 同案注释)。PG 侧占位符是显式编号 `$N`
95
+ /** core 1.383([ref] 提货单)REQUIRED 新方法(TiDB twin 同案注释)。PG 侧占位符是显式编号 `$N`
96
96
  * (不像 TiDB `?` 靠数组顺序)——`n` 是跑动计数器,只在真正消耗一个占位符(非 IS NULL 分支)时前增。 */
97
97
  updateIf(handle: string, scope: string, record: BackgroundAgentRecord, expect: {
98
98
  rev: number;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design/103 — shared support for the remote (TOB) `BackgroundShellCapability` implementations.
2
+ * [ref] — shared support for the remote (TOB) `BackgroundShellCapability` implementations.
3
3
  *
4
4
  * core defines the seam (`@sema-agent/core` `BackgroundShellCapability` + `hasBackgroundShell`) and ships the TOC
5
5
  * reference (`NodeExecutionEnv`). This module centralises the **security + lifecycle red-lines** that EVERY remote
@@ -7,23 +7,23 @@
7
7
  * primitives and cannot accidentally re-implement (or skip) an invariant:
8
8
  *
9
9
  * - **opaque shellId** — a fresh `bg_<n>_<uuid>` brand, NEVER derived from the provider's job/pid (超范围红线,
10
- * design/103 §3.8). The provider id lives only inside the driver state.
10
+ * [ref] §3.8). The provider id lives only inside the driver state.
11
11
  * - **owned-id isolation** — `poll`/`kill` look the shellId up in THIS manager's registry; an id from another env
12
- * (or a forged one) is `not_found`, never resolved against the provider (design/103 §3.8 / interface 超范围契约).
12
+ * (or a forged one) is `not_found`, never resolved against the provider ([ref] §3.8 / interface 超范围契约).
13
13
  * - **maxConcurrent** — counts only `running` shells (terminal entries are kept for residual polling but free their
14
14
  * slot, so "TaskStop one first" is actionable — matches the TOC `maxConcurrent 终态占槽` review fix).
15
15
  * - **timeout hard wall** — a control-plane timer kills the shell and flips it to `killed` at the bounded BG
16
- * timeout (design/103 §3.6); the driver may set an additional provider-level backstop ≥ this wall.
17
- * - **dispose** — kills + cleans up EVERY shell, best-effort, MUST NOT throw, idempotent (design/103 §3.7).
16
+ * timeout ([ref] §3.6); the driver may set an additional provider-level backstop ≥ this wall.
17
+ * - **dispose** — kills + cleans up EVERY shell, best-effort, MUST NOT throw, idempotent ([ref] §3.7).
18
18
  *
19
- * The two transports legitimately take different "按-id-可重读" paths (design/103 §5.2): E2B holds a resident
19
+ * The two transports legitimately take different "按-id-可重读" paths ([ref] §5.2): E2B holds a resident
20
20
  * `CommandHandle` reader feeding a control-plane tail buffer (path ②); kata/k8s buffers into pod-side files
21
21
  * re-read by byte cursor on each poll (path ①). Both are expressed through {@link BackgroundShellDriver}.
22
22
  */
23
23
  import { BackgroundShellError } from "@sema-agent/core";
24
24
  import type { BackgroundShellId, BackgroundPoll, BackgroundSpawnOptions, Result } from "@sema-agent/core";
25
25
  import { StringDecoder } from "node:string_decoder";
26
- /** Per-端 background capability bounds, surfaced as `backgroundCapabilities` on the env (design/103 §3.1/§3.6).
26
+ /** Per-端 background capability bounds, surfaced as `backgroundCapabilities` on the env ([ref] §3.1/§3.6).
27
27
  *
28
28
  * ⚠️ 有据不接:core 契约的 `retainBackgroundProcesses` 能力字段【有意】不在此声明(2026-07-08 定谳):
29
29
  * TB 的声明与兑现全在 core 自己 runtime 内闭环(sema-tb bin 进程内 TOC local env 声明,core task-registry
@@ -79,7 +79,7 @@ export interface DriverPoll {
79
79
  stdout: string;
80
80
  /** New stderr since last read. */
81
81
  stderr: string;
82
- /** Total output bytes the process has produced from start (cursor metadata; design/103 §3.4). */
82
+ /** Total output bytes the process has produced from start (cursor metadata; [ref] §3.4). */
83
83
  bytesFromStart: number;
84
84
  /** Bytes permanently lost to head-eviction before this read's cursor (0 if none). */
85
85
  bytesDroppedBeforeCursor: number;
@@ -112,7 +112,7 @@ export declare class BackgroundShellManager<S> {
112
112
  private readonly shells;
113
113
  private counter;
114
114
  constructor(driver: BackgroundShellDriver<S>, caps: BackgroundCaps);
115
- /** [1116] 六轮复审:destroy 端判「还有 shell 依赖 spool 文件吗」——running(驻留 keep-alive)与
115
+ /** [ref] 六轮复审:destroy 端判「还有 shell 依赖 spool 文件吗」——running(驻留 keep-alive)与
116
116
  * terminal 残余(dispose 前仍可轮询)都算;有=env 不得整树删 spool 根(逐 shell 清理归 dispose 面)。 */
117
117
  hasShells(): boolean;
118
118
  /** Count live shells; KillShell/timeout flip a shell out of `running` and free its slot. */
@@ -123,7 +123,7 @@ export declare class BackgroundShellManager<S> {
123
123
  shellId: BackgroundShellId;
124
124
  }, BackgroundShellError>>;
125
125
  /**
126
- * design/116 detach (clay 排,1.81): adopt an EXTERNALLY-created RUNNING process as a background shell — the
126
+ * [ref] detach (clay 排,1.81): adopt an EXTERNALLY-created RUNNING process as a background shell — the
127
127
  * mid-flight ctrl+b path, where the process was spawned by a FOREGROUND `exec` and must move under this
128
128
  * manager's ownership instead of being killed. The `builder` receives the same {@link LaunchCtx} a driver
129
129
  * `launch` would (terminal notification + the bounded BG timeout it may use as a backstop) and returns the
@@ -143,7 +143,7 @@ export declare class BackgroundShellManager<S> {
143
143
  * all-or-nothing: put every operation that can throw BEFORE the first side effect, or clean up on the throw
144
144
  * path itself. Today's three lane builders are entirely non-throwing (listener attach + object construction).
145
145
  */
146
- /** #131-T0:两条注册腿共用的 BG 超时钳制。非有限值(NaN/±Infinity)当缺席回退 default——
146
+ /** [ref]-T0:两条注册腿共用的 BG 超时钳制。非有限值(NaN/±Infinity)当缺席回退 default——
147
147
  * Math.max/min 对 NaN 全塌 NaN,setTimeout(NaN) 被 Node 折成 1ms = 后台 shell 秒杀
148
148
  * (方向反转:想给超时变成即杀;同族判例 TASK_TIMEOUT_SEC / leader 旋钮非法值)。 */
149
149
  private boundedBgTimeoutSec;
@@ -154,7 +154,7 @@ export declare class BackgroundShellManager<S> {
154
154
  private register;
155
155
  poll(shellId: BackgroundShellId): Promise<Result<BackgroundPoll, BackgroundShellError>>;
156
156
  kill(shellId: BackgroundShellId): Promise<Result<void, BackgroundShellError>>;
157
- /** Kill + clean up EVERY shell. Best-effort, MUST NOT throw, idempotent (design/103 §3.7).
157
+ /** Kill + clean up EVERY shell. Best-effort, MUST NOT throw, idempotent ([ref] §3.7).
158
158
  *
159
159
  * core `except` 契约(background-shell.d.ts:core runtask 尾调 `{except: keepAlive}`):
160
160
  * 这些 shellId **留活**——session 驻留 persistent Monitor 的进程,其全部意义就是跨 turn 存活;run-end
@@ -50,7 +50,7 @@ export declare class SqlBlobBackend implements BlobBackend {
50
50
  private readonly pool;
51
51
  /** Effective per-blob cap: explicit ctor value wins; else tidb=SQL_BLOB_DEFAULT_MAX_BYTES, pg=uncapped. */
52
52
  private readonly capBytes;
53
- /** Blob-domain table (S-15 blob 域隔离:file-history 域用自己的表,reap/GC 不跨域)。代码内字面量,非用户输入。 */
53
+ /** Blob-domain table ([ref] blob 域隔离:file-history 域用自己的表,reap/GC 不跨域)。代码内字面量,非用户输入。 */
54
54
  private readonly table;
55
55
  constructor(dialect: "tidb" | "pg", pool: MysqlPool | PgPool, maxBytes?: number, table?: string);
56
56
  /** The created_at-refreshing content-addressed upsert — VERBATIM the tidb/pg stores' `putBlobRow`. Refreshes
@@ -70,7 +70,7 @@ export declare class SqlBlobBackend implements BlobBackend {
70
70
  * excluded referenced hashes). Best-effort: a delete error is swallowed (under-delete is harmless). */
71
71
  deleteBlobs(hashes: string[]): Promise<number>;
72
72
  }
73
- /** SHARED index op(workspace 浏览面 #3,[1894]②)—— per-blob 字节数,读 SQL INDEX 的 `byte_len`
73
+ /** SHARED index op(workspace 浏览面 #3,[ref]②)—— per-blob 字节数,读 SQL INDEX 的 `byte_len`
74
74
  * 列(sqlHasBlobs 同款单 IN 查询;MinIO 后端的 bytes-NULL 索引行同样带 byte_len,两后端同源)。
75
75
  * tree/file 面的 size 投影与「超限先拒后拉」都靠它——绝不为拿大小去 getBlob 整块字节。 */
76
76
  export declare function sqlBlobSizes(dialect: "tidb" | "pg", pool: MysqlPool | PgPool, hashes: string[]): Promise<Map<string, number>>;
@@ -119,7 +119,7 @@ export declare class MinioBlobBackend implements BlobBackend {
119
119
  * path). The file-snapshot stores ALWAYS pass the pool, so the live reference-tracking always has the index. */
120
120
  private readonly indexPool?;
121
121
  private readonly indexDialect?;
122
- /** Blob-domain index table (S-15 域隔离,SqlBlobBackend.table 同款;默认 = E19 纪元的 snapshot_blob)。 */
122
+ /** Blob-domain index table ([ref] 域隔离,SqlBlobBackend.table 同款;默认 = E19 纪元的 snapshot_blob)。 */
123
123
  private readonly indexTable;
124
124
  constructor(cfg: MinioBlobBackendConfig, index?: {
125
125
  dialect: "tidb" | "pg";
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Cross-replica circuit-breaker state (core 1.38 `BreakerState`) — SINGLE-FILE DUAL-DIALECT
3
- * (design/158 A12 定型半场). ONE implementation, TWO dialects; the historical `TiDBBreakerState` /
4
- * `PgBreakerState` class names survive as thin ctor subclasses in THIS file ([2354]: the old per-dialect shim files are deleted) so every consumer (store-backend.ts, the
3
+ * ([ref] A12 定型半场). ONE implementation, TWO dialects; the historical `TiDBBreakerState` /
4
+ * `PgBreakerState` class names survive as thin ctor subclasses in THIS file ([ref]: the old per-dialect shim files are deleted) so every consumer (store-backend.ts, the
5
5
  * fake-pool unit suites, the real dual-DB integration suite) is untouched.
6
6
  *
7
7
  * core's `createCircuitBreakerBrain` defaults to a per-PROCESS Map → on a multi-replica deployment
@@ -18,7 +18,7 @@
18
18
  * learns a peer already opened the breaker — self-healing, never wrong in a dangerous direction).
19
19
  *
20
20
  * Strict per-call linearizable state would need an async `BreakerState` from core (a separate effort);
21
- * for a consultative breaker, eventually-consistent write-through is the right trade (see core design/20).
21
+ * for a consultative breaker, eventually-consistent write-through is the right trade (see core [ref]).
22
22
  *
23
23
  * ── Dialect deltas, kept EXPLICIT (the ONLY place the two engines actually differ) ─────────────────
24
24
  * - placeholders `?` vs `$n`
@@ -56,7 +56,7 @@ export declare class CachingSessionStore implements SessionStore {
56
56
  * wrapper, so without forwarding `noteTaskRun?.()` silently no-ops and lastRunId stays null (review BLOCKER). Pure
57
57
  * pass-through to the inner store's in-mem map — no cache interaction. (TiDB/PG don't implement it → not bound.)
58
58
  * Return type matches core's `SessionStore.noteTaskRun?(): void | Promise<void>` (review: don't narrow to void).
59
- * #499(core 5.65 增量批):第三参 = engine runId。绑定用的是 `.bind(inner)`(整函数),运行期本就
59
+ * [ref](core 5.65 增量批):第三参 = engine runId。绑定用的是 `.bind(inner)`(整函数),运行期本就
60
60
  * 三参全转 —— 这里把**声明**对齐到 core 的三参形,免得读这行类型的人以为缝上只有两参(fork-routing
61
61
  * 的两参形正是在运行期真丢过第三参的那个病,同批修)。内店(LocalSessionStore)今日仍是两参消费,
62
62
  * runId 落地候 sessions 列表 wire 键的 spec 节拍(见本批提货报告件1b)。 */
@@ -67,7 +67,7 @@ export declare class CachingSessionStore implements SessionStore {
67
67
  /** E18 — delegate the leaf read straight to inner (a cache-bypassing single SELECT; the resume-at turn-capture
68
68
  * reads the DURABLE leaf, not a possibly-stale cached view — same discipline as the §0.5 repo ops above). */
69
69
  readonly getLeafId?: (sessionId: string) => Promise<string | null>;
70
- /** [1196] 六轮复审:owner+leafId 原子快照透传(cache-bypassing,getLeafId 同姿势)。 */
70
+ /** [ref] 六轮复审:owner+leafId 原子快照透传(cache-bypassing,getLeafId 同姿势)。 */
71
71
  readonly getHead?: (sessionId: string) => Promise<{
72
72
  owner: string | null;
73
73
  leafId: string | null;
@@ -86,7 +86,7 @@ export declare class CachingSessionStore implements SessionStore {
86
86
  /** 轴A #1(1.254):core B-17 forget 面(evict 本地 + 转发 inner 可选面)。 */
87
87
  forget?: (sessionId: string) => void | Promise<void>;
88
88
  readonly importEntries?: (sessionId: string, owner: string | null, entries: SessionTreeEntry[]) => Promise<void>;
89
- /** [2024](cli 取证)2c session-sync P1d-β — delegated STAGED import seam. 此前 staging 族不在本类的逐方法
89
+ /** [ref](cli 取证)2c session-sync P1d-β — delegated STAGED import seam. 此前 staging 族不在本类的逐方法
90
90
  * 转发白名单里 ⇒ 默认部署(SESSION_CACHE_TTL_SEC=300 把真店包进本类)PUSH Phase A 恒 501
91
91
  * `capability.session_store_required`,而 capabilities().sessionSync 谓词三项(backend/exportEntries/
92
92
  * fileHistoryStore)都被转发了 ⇒ 照报 true(能力面谎)。转发形:handle 的 `commit` 是唯一写真 id 的
@@ -101,7 +101,7 @@ export declare class CachingSessionStore implements SessionStore {
101
101
  * `sessionId`, so a stale warm handle for that id is evicted on success (next acquire re-wakes from the new log). */
102
102
  readonly replaceEntries?: (sessionId: string, owner: string | null, entries: SessionTreeEntry[]) => Promise<void>;
103
103
  /**
104
- * #270 车1 —— 内层店的 `retention` **声明**(core `RetentionDeclaring`)。
104
+ * [ref] 车1 —— 内层店的 `retention` **声明**(core `RetentionDeclaring`)。
105
105
  *
106
106
  * 🔴 为什么这一格必须转发,而且方向比别的转发更要命:生产默认 `SESSION_CACHE_TTL_SEC=300` 会把真店
107
107
  * 包进本类,于是 boot 递给 `assertRetentionCapability` 的就是**包装层**。core 对缺席是 fail-closed
@@ -111,7 +111,7 @@ export declare class CachingSessionStore implements SessionStore {
111
111
  */
112
112
  readonly retention?: RetentionDeclaration;
113
113
  /**
114
- * #292 C18 —— 内层店的 **placement 声明**转发。
114
+ * [ref] C18 —— 内层店的 **placement 声明**转发。
115
115
  *
116
116
  * 🔴 这一格与 {@link retention} 是同一条教训的同一族(而且更狠):生产默认 `SESSION_CACHE_TTL_SEC=300`
117
117
  * 把真店包进本类,于是 boot 递给 core 的就是**包装层**。core 的铸造门判「row store ∧ **session 店声明**」
@@ -120,7 +120,7 @@ export declare class CachingSessionStore implements SessionStore {
120
120
  * 只读快照而非 getter:声明是店的构造期常量(会变的声明本身就是缺陷)。
121
121
  */
122
122
  readonly placements?: SessionStore["placements"];
123
- /** #292:placed 分区的两只读面(reap 分区腿 / 准入探针)——同款转发理由:reaper 与准入判据拿到的
123
+ /** [ref]:placed 分区的两只读面(reap 分区腿 / 准入探针)——同款转发理由:reaper 与准入判据拿到的
124
124
  * 是包装层,不转发 = 分区腿静默不可用、暖命中的 claim 关门静默失效。缺席则不设(诚实降级)。 */
125
125
  readonly listPlaced?: (kind: "subagent", opts?: {
126
126
  olderThanMs?: number;