@sema-agent/server 7.134.0 → 7.136.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 (550) hide show
  1. package/MIGRATION.md +197 -1
  2. package/USAGE.md +147 -42
  3. package/deploy/sema-up/README.md +1 -1
  4. package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
  5. package/deploy/sema-up/chart/values.yaml +1 -1
  6. package/dist/adoption/plan.d.ts +1 -1
  7. package/dist/approval-ask-audit-store.d.ts +24 -24
  8. package/dist/approval-ask-machine.d.ts +2 -2
  9. package/dist/approval-card.d.ts +122 -154
  10. package/dist/approval-card.js +50 -51
  11. package/dist/approval-content-kind.d.ts +23 -5
  12. package/dist/approval-content-kind.js +8 -1
  13. package/dist/approval-deny-reasons.d.ts +1 -1
  14. package/dist/approval-gate-currency.d.ts +22 -3
  15. package/dist/approval-gate-currency.js +44 -18
  16. package/dist/approval-hmac.d.ts +7 -7
  17. package/dist/approval-policy-settlement.d.ts +2 -2
  18. package/dist/approval-reconciler.d.ts +3 -3
  19. package/dist/approval.d.ts +8 -8
  20. package/dist/approval.js +4 -2
  21. package/dist/auth-bridge.d.ts +35 -6
  22. package/dist/auth-bridge.js +20 -3
  23. package/dist/auto-mode-face.d.ts +4 -4
  24. package/dist/background-session-reap.d.ts +2 -2
  25. package/dist/bake-runner/main.d.ts +2 -2
  26. package/dist/bake-runner/runner.d.ts +4 -4
  27. package/dist/bench/s1/live-deps.d.ts +1 -1
  28. package/dist/bench/s1/run-firm.d.ts +1 -1
  29. package/dist/boot/budget-tracing.d.ts +1 -2
  30. package/dist/boot/budget-tracing.js +2 -2
  31. package/dist/boot/coordinators.d.ts +2 -2
  32. package/dist/boot/coordinators.js +2 -2
  33. package/dist/boot/deferred-sandbox-path-env.d.ts +0 -6
  34. package/dist/boot/deferred-sandbox-path-env.js +0 -5
  35. package/dist/boot/engine-lease.d.ts +5 -5
  36. package/dist/boot/execution-env.d.ts +16 -15
  37. package/dist/boot/execution-env.js +19 -21
  38. package/dist/boot/fatal-exit.d.ts +2 -2
  39. package/dist/boot/late-binds.d.ts +1 -1
  40. package/dist/boot/leader.d.ts +1 -1
  41. package/dist/boot/memory-boundary.d.ts +2 -2
  42. package/dist/boot/memory-consolidation.d.ts +15 -15
  43. package/dist/boot/org-memory.js +1 -1
  44. package/dist/boot/parked-revive-gate.d.ts +3 -3
  45. package/dist/boot/parked-revive-gate.js +3 -2
  46. package/dist/boot/reapers.d.ts +4 -4
  47. package/dist/boot/resolve-spec.d.ts +1 -1
  48. package/dist/boot/resolve-spec.js +36 -29
  49. package/dist/boot/runner-deps.d.ts +11 -11
  50. package/dist/boot/runner-deps.js +7 -4
  51. package/dist/boot/session-faces.d.ts +3 -3
  52. package/dist/boot/session-faces.js +11 -30
  53. package/dist/boot/shutdown.d.ts +5 -5
  54. package/dist/boot/side-query-lane.d.ts +2 -2
  55. package/dist/boot/stage-04-stores.d.ts +1 -1
  56. package/dist/boot/stage-05-execution-env.d.ts +1 -1
  57. package/dist/boot/stage-05-execution-env.js +4 -4
  58. package/dist/boot/stage-06-runners.d.ts +1 -1
  59. package/dist/boot/stage-06-runners.js +0 -2
  60. package/dist/boot/stage-07-capability-layer.d.ts +1 -1
  61. package/dist/boot/stage-08-reapers.d.ts +1 -1
  62. package/dist/boot/stage-09-leader.d.ts +1 -1
  63. package/dist/boot/stage-10-http-server.d.ts +1 -1
  64. package/dist/boot/stores.js +4 -4
  65. package/dist/boot/web-admin.d.ts +17 -17
  66. package/dist/boot/web-admin.js +15 -27
  67. package/dist/boot/workflow-orchestration.js +2 -9
  68. package/dist/brain.d.ts +11 -11
  69. package/dist/brain.js +12 -3
  70. package/dist/budget.d.ts +7 -7
  71. package/dist/budget.js +4 -0
  72. package/dist/capabilities/approvals-push.d.ts +4 -4
  73. package/dist/capabilities/builtin-tools.d.ts +5 -5
  74. package/dist/capabilities/center-plugins.d.ts +5 -5
  75. package/dist/capabilities/center-plugins.js +1 -1
  76. package/dist/capabilities/center-prompts.d.ts +1 -1
  77. package/dist/capabilities/center-wiring.d.ts +1 -1
  78. package/dist/capabilities/composite-members.d.ts +1 -1
  79. package/dist/capabilities/execution-lane.d.ts +5 -5
  80. package/dist/capabilities/execution-lane.js +2 -2
  81. package/dist/capabilities/hands-lane.d.ts +5 -5
  82. package/dist/capabilities/mcp-probe.d.ts +11 -7
  83. package/dist/capabilities/sandbox-file-send.d.ts +1 -18
  84. package/dist/capabilities/sandbox-file-send.js +0 -7
  85. package/dist/capabilities/scenarios.d.ts +28 -10
  86. package/dist/capabilities/scenarios.js +15 -5
  87. package/dist/capabilities/send-user-file-tool.d.ts +1 -1
  88. package/dist/capabilities/skills.d.ts +31 -12
  89. package/dist/capabilities/skills.js +23 -17
  90. package/dist/capabilities/tool-defer.d.ts +1 -1
  91. package/dist/capability-facts.d.ts +29 -32
  92. package/dist/capability-facts.js +17 -21
  93. package/dist/center-config-tier.d.ts +1 -1
  94. package/dist/center-credential.d.ts +22 -8
  95. package/dist/center-credential.js +18 -3
  96. package/dist/checkpoint-identity.d.ts +5 -0
  97. package/dist/checkpoint-identity.js +14 -0
  98. package/dist/config-catalog.d.ts +12 -12
  99. package/dist/config-catalog.js +12 -10
  100. package/dist/config-d-migration.js +1 -1
  101. package/dist/config-invariants.d.ts +5 -5
  102. package/dist/config-invariants.js +11 -2
  103. package/dist/config-lkg.d.ts +1 -39
  104. package/dist/config-lkg.js +1 -83
  105. package/dist/config-provider.d.ts +13 -13
  106. package/dist/config-provider.js +2 -1
  107. package/dist/config-types.d.ts +95 -87
  108. package/dist/config.d.ts +26 -24
  109. package/dist/config.js +38 -18
  110. package/dist/cross-session-settings.d.ts +1 -1
  111. package/dist/delegated-session-owner.d.ts +16 -13
  112. package/dist/delegated-session-owner.js +9 -10
  113. package/dist/deployment-governance.d.ts +16 -16
  114. package/dist/deployment-shape.d.ts +127 -0
  115. package/dist/deployment-shape.js +72 -0
  116. package/dist/device-store.d.ts +1 -1
  117. package/dist/device-ws-hub.d.ts +1 -1
  118. package/dist/egress-redirect.d.ts +1 -1
  119. package/dist/elicitation.d.ts +8 -7
  120. package/dist/elicitation.js +9 -8
  121. package/dist/entry-mode-clamp-notice.d.ts +2 -2
  122. package/dist/env-facts.d.ts +10 -9
  123. package/dist/env-facts.js +1 -1
  124. package/dist/env-name-allowlist-knobs.d.ts +5 -5
  125. package/dist/exec-bounds.d.ts +2 -2
  126. package/dist/execution-lane-caps.d.ts +31 -43
  127. package/dist/execution-lane-caps.js +0 -13
  128. package/dist/file-history-capture.d.ts +9 -9
  129. package/dist/file-history-disclosure.d.ts +25 -11
  130. package/dist/file-history-disclosure.js +25 -14
  131. package/dist/fleet/drain-entry.d.ts +2 -2
  132. package/dist/fleet/fleet-bus.d.ts +22 -14
  133. package/dist/fleet/fleet-bus.js +5 -5
  134. package/dist/fleet/fleet-reconciler.d.ts +9 -9
  135. package/dist/fleet/subagent-tail-bus.d.ts +4 -4
  136. package/dist/fleet-client.d.ts +45 -14
  137. package/dist/fleet-client.js +24 -4
  138. package/dist/fleet-lease.d.ts +23 -19
  139. package/dist/fleet-lease.js +31 -23
  140. package/dist/governance-http-status.d.ts +2 -2
  141. package/dist/hooks/hook-llm.d.ts +7 -7
  142. package/dist/hooks/hook-llm.js +14 -8
  143. package/dist/hooks/hook-runner.d.ts +58 -31
  144. package/dist/hooks/hook-runner.js +37 -19
  145. package/dist/host-decision.d.ts +5 -5
  146. package/dist/host-lsp-manager.d.ts +5 -5
  147. package/dist/hosted-posture.d.ts +23 -13
  148. package/dist/hosted-posture.js +4 -9
  149. package/dist/http/admission.d.ts +2 -2
  150. package/dist/http/admission.js +20 -5
  151. package/dist/http/approval-sweeps.d.ts +1 -1
  152. package/dist/http/approval-sweeps.js +2 -1
  153. package/dist/http/checkpoint-ctx.d.ts +62 -17
  154. package/dist/http/checkpoint-ctx.js +78 -35
  155. package/dist/http/dispatch.d.ts +3 -3
  156. package/dist/http/dispatch.js +9 -9
  157. package/dist/http/durable-run-leg.js +4 -3
  158. package/dist/http/idempotency.d.ts +2 -2
  159. package/dist/http/mcp-dial-deadline.d.ts +7 -5
  160. package/dist/http/memory-compliance-failure-reply.d.ts +4 -4
  161. package/dist/http/owner-access.d.ts +4 -6
  162. package/dist/http/owner-access.js +1 -1
  163. package/dist/http/principal-gate.d.ts +7 -7
  164. package/dist/http/principal-gate.js +3 -2
  165. package/dist/http/readiness.d.ts +1 -1
  166. package/dist/http/request-guards.d.ts +4 -4
  167. package/dist/http/request-guards.js +2 -1
  168. package/dist/http/resume-ctx-read.d.ts +9 -23
  169. package/dist/http/resume-ctx-read.js +2 -3
  170. package/dist/http/resume-legs.d.ts +3 -3
  171. package/dist/http/resume-legs.js +11 -8
  172. package/dist/http/route-ctx.d.ts +29 -29
  173. package/dist/http/route-table.d.ts +9 -9
  174. package/dist/http/routes/agents-roster.d.ts +1 -1
  175. package/dist/http/routes/approvals-assistant.d.ts +5 -7
  176. package/dist/http/routes/approvals-assistant.js +101 -26
  177. package/dist/http/routes/background.d.ts +3 -3
  178. package/dist/http/routes/background.js +2 -2
  179. package/dist/http/routes/capabilities.d.ts +1 -1
  180. package/dist/http/routes/capabilities.js +16 -8
  181. package/dist/http/routes/config-catalog.d.ts +1 -1
  182. package/dist/http/routes/devices.d.ts +1 -1
  183. package/dist/http/routes/diagnostics.d.ts +3 -3
  184. package/dist/http/routes/fleet.d.ts +1 -1
  185. package/dist/http/routes/fleet.js +2 -1
  186. package/dist/http/routes/mcp-reconnect.d.ts +4 -4
  187. package/dist/http/routes/mcp-reconnect.js +3 -3
  188. package/dist/http/routes/memory-consolidation.d.ts +1 -1
  189. package/dist/http/routes/notify-wake.d.ts +1 -1
  190. package/dist/http/routes/notify-wake.js +2 -2
  191. package/dist/http/routes/rules.d.ts +1 -1
  192. package/dist/http/routes/runs.js +23 -11
  193. package/dist/http/routes/session-sync.d.ts +1 -1
  194. package/dist/http/routes/session-sync.js +97 -46
  195. package/dist/http/routes/sessions-list.js +1 -1
  196. package/dist/http/routes/sessions.js +43 -53
  197. package/dist/http/routes/tasks.d.ts +1 -1
  198. package/dist/http/routes/trace-usage.d.ts +1 -1
  199. package/dist/http/routes/workflows.d.ts +3 -0
  200. package/dist/http/routes/workflows.js +31 -28
  201. package/dist/http/send.d.ts +5 -5
  202. package/dist/http/server.d.ts +34 -34
  203. package/dist/http/session-inherit-env.d.ts +3 -3
  204. package/dist/http/sse-lifecycle.d.ts +1 -1
  205. package/dist/http/sse-log.d.ts +2 -2
  206. package/dist/http/submit-ctx.js +1 -1
  207. package/dist/http/sync-submit-body.d.ts +1 -1
  208. package/dist/http/verify-rounds.d.ts +1 -1
  209. package/dist/http/wire-types.d.ts +33 -24
  210. package/dist/index.d.ts +1 -0
  211. package/dist/index.js +1 -0
  212. package/dist/instruction-source-notice.d.ts +2 -2
  213. package/dist/key-resolver.d.ts +3 -3
  214. package/dist/lane-home-probe.d.ts +1 -1
  215. package/dist/leader/diffout.d.ts +1 -1
  216. package/dist/leader/diffup.d.ts +2 -2
  217. package/dist/leader/endpoint.d.ts +1 -1
  218. package/dist/leader/fanout.d.ts +1 -1
  219. package/dist/leader/leader.d.ts +4 -4
  220. package/dist/leader/merge.d.ts +3 -3
  221. package/dist/leader/repair-wire.d.ts +1 -1
  222. package/dist/leader/wire.d.ts +6 -6
  223. package/dist/list-entry-display.d.ts +1 -1
  224. package/dist/lsp-evict.d.ts +1 -1
  225. package/dist/mcp-assertion-header.d.ts +1 -1
  226. package/dist/memory-layer-legacy-lock.d.ts +1 -1
  227. package/dist/memory-operator-faces.d.ts +1 -1
  228. package/dist/memory-posture.js +4 -2
  229. package/dist/memory-project-layer.d.ts +1 -1
  230. package/dist/memory-scope.d.ts +19 -19
  231. package/dist/memory-store-refusal.d.ts +4 -4
  232. package/dist/model-entry-headers.d.ts +2 -2
  233. package/dist/model-entry-refusal.d.ts +17 -17
  234. package/dist/model-provider.d.ts +10 -10
  235. package/dist/model-reach-scope.d.ts +1 -1
  236. package/dist/model-route-endpoint.d.ts +6 -6
  237. package/dist/model-route-gap.d.ts +49 -4
  238. package/dist/model-route-gap.js +34 -1
  239. package/dist/model-route-url.d.ts +5 -5
  240. package/dist/model-select.d.ts +15 -6
  241. package/dist/model-select.js +5 -0
  242. package/dist/model-unreachable-notice.d.ts +3 -3
  243. package/dist/namespaced-rule-name.d.ts +15 -5
  244. package/dist/namespaced-rule-name.js +3 -2
  245. package/dist/object-store-buckets.d.ts +13 -0
  246. package/dist/object-store-buckets.js +3 -0
  247. package/dist/observability/corrupt-read-seat.d.ts +9 -9
  248. package/dist/observability/cost-taxonomy.d.ts +1 -1
  249. package/dist/observability/err-text.d.ts +1 -1
  250. package/dist/observability/fail-open.d.ts +17 -13
  251. package/dist/observability/fail-open.js +17 -13
  252. package/dist/observability/metrics.d.ts +3 -3
  253. package/dist/observability/metrics.js +1 -1
  254. package/dist/observability/principal-context.d.ts +4 -1
  255. package/dist/observability/principal-context.js +6 -1
  256. package/dist/observability/run-terminal.d.ts +36 -36
  257. package/dist/observability/secret-env-scrub.d.ts +3 -3
  258. package/dist/observability/tool-trace.d.ts +1 -1
  259. package/dist/operator-ask.d.ts +4 -4
  260. package/dist/orchestration/workflow-agent-session-index.d.ts +3 -3
  261. package/dist/orchestration/workflow-completion-inbox.d.ts +20 -5
  262. package/dist/orchestration/workflow-completion-inbox.js +29 -7
  263. package/dist/orchestration/workflow-notify-journal.d.ts +43 -19
  264. package/dist/orchestration/workflow-notify-journal.js +17 -0
  265. package/dist/outbound-dispatcher.d.ts +4 -4
  266. package/dist/parent-watch.d.ts +4 -4
  267. package/dist/parked-decide.d.ts +20 -18
  268. package/dist/parked-decide.js +31 -11
  269. package/dist/parked-revive-surface.d.ts +7 -7
  270. package/dist/parked-revive-surface.js +2 -3
  271. package/dist/peer-directory.d.ts +5 -4
  272. package/dist/peer-directory.js +6 -6
  273. package/dist/permission-rule-list.d.ts +10 -1
  274. package/dist/permission-rule-list.js +7 -5
  275. package/dist/permission-rule-vocab.d.ts +2 -2
  276. package/dist/plugins/adoption-log-sql.d.ts +1 -1
  277. package/dist/plugins/approval-ask-store-file.d.ts +8 -1
  278. package/dist/plugins/approval-ask-store-file.js +6 -3
  279. package/dist/plugins/approval-ask-store-memory.d.ts +11 -7
  280. package/dist/plugins/approval-ask-store-memory.js +11 -7
  281. package/dist/plugins/approval-ask-store-sql.d.ts +42 -15
  282. package/dist/plugins/approval-ask-store-sql.js +21 -5
  283. package/dist/plugins/approval-exemption-store.d.ts +3 -3
  284. package/dist/plugins/approval-nonce-store.d.ts +3 -3
  285. package/dist/plugins/background-agent-store-sql.d.ts +1 -1
  286. package/dist/plugins/background-shell-support.d.ts +2 -2
  287. package/dist/plugins/blob-backend.d.ts +1 -1
  288. package/dist/plugins/blob-backend.js +2 -1
  289. package/dist/plugins/caching-session-store.d.ts +23 -32
  290. package/dist/plugins/caching-session-store.js +5 -17
  291. package/dist/plugins/checkpoint-index-columns.d.ts +130 -0
  292. package/dist/plugins/checkpoint-index-columns.js +90 -0
  293. package/dist/plugins/checkpoint-store-sql.d.ts +71 -69
  294. package/dist/plugins/checkpoint-store-sql.js +109 -127
  295. package/dist/plugins/device-store-sql.d.ts +7 -6
  296. package/dist/plugins/e2b-orphan-reclaim.d.ts +1 -1
  297. package/dist/plugins/ensure-schema-lock-policy.d.ts +1 -1
  298. package/dist/plugins/file-history-store-sql.d.ts +15 -7
  299. package/dist/plugins/file-history-store-sql.js +55 -36
  300. package/dist/plugins/file-run-store.d.ts +8 -8
  301. package/dist/plugins/fork-routing-session-store.d.ts +2 -2
  302. package/dist/plugins/fork-routing-session-store.js +1 -1
  303. package/dist/plugins/host-platform.d.ts +10 -10
  304. package/dist/plugins/image-bake-store-sql.d.ts +1 -1
  305. package/dist/plugins/image-index-sql.d.ts +1 -1
  306. package/dist/plugins/leader-run-store-sql.d.ts +1 -1
  307. package/dist/plugins/local-checkpoint-store.d.ts +10 -10
  308. package/dist/plugins/local-checkpoint-store.js +7 -7
  309. package/dist/plugins/local-session-store.d.ts +34 -38
  310. package/dist/plugins/local-session-store.js +20 -39
  311. package/dist/plugins/local-session-window.d.ts +1 -1
  312. package/dist/plugins/mailbox-store-sql.d.ts +2 -2
  313. package/dist/plugins/memory-engine-pg.d.ts +1 -1
  314. package/dist/plugins/memory-run-store.d.ts +4 -4
  315. package/dist/plugins/memory-sync-store-pg.d.ts +3 -3
  316. package/dist/plugins/one-time-migrations.d.ts +73 -54
  317. package/dist/plugins/one-time-migrations.js +131 -134
  318. package/dist/plugins/outcome-ledger-sql.d.ts +1 -1
  319. package/dist/plugins/park-commit-watch.d.ts +3 -3
  320. package/dist/plugins/permission-rule-store-file.d.ts +5 -5
  321. package/dist/plugins/permission-rule-store-file.js +12 -19
  322. package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
  323. package/dist/plugins/permission-rule-store-sql.js +67 -24
  324. package/dist/plugins/pg-cost-quota.d.ts +1 -1
  325. package/dist/plugins/pg-pool.d.ts +2 -2
  326. package/dist/plugins/pg-pool.js +5 -2
  327. package/dist/plugins/pg-rate-limiter.d.ts +1 -1
  328. package/dist/plugins/pg-session-storage.d.ts +8 -20
  329. package/dist/plugins/pg-session-storage.js +14 -27
  330. package/dist/plugins/remote-env-adb.d.ts +10 -10
  331. package/dist/plugins/remote-env-device.d.ts +10 -9
  332. package/dist/plugins/remote-env-device.js +6 -2
  333. package/dist/plugins/remote-env-e2b.d.ts +3 -3
  334. package/dist/plugins/remote-env-host.d.ts +16 -16
  335. package/dist/plugins/remote-env-k8s.d.ts +26 -13
  336. package/dist/plugins/remote-env-k8s.js +24 -7
  337. package/dist/plugins/remote-env-local-docker.d.ts +2 -2
  338. package/dist/plugins/remote-env-ssh.d.ts +4 -4
  339. package/dist/plugins/remote-scratchpad.d.ts +2 -3
  340. package/dist/plugins/remote-scratchpad.js +0 -4
  341. package/dist/plugins/remote-shell.d.ts +6 -6
  342. package/dist/plugins/retention-lane-store-sql.d.ts +4 -4
  343. package/dist/plugins/retention-store-sql.d.ts +4 -4
  344. package/dist/plugins/roster-store-sql.d.ts +1 -1
  345. package/dist/plugins/run-store-sql.d.ts +8 -8
  346. package/dist/plugins/s3-answer.d.ts +15 -0
  347. package/dist/plugins/s3-answer.js +5 -0
  348. package/dist/plugins/schema-consistency.d.ts +2 -2
  349. package/dist/plugins/schema-ensure-legs.d.ts +3 -3
  350. package/dist/plugins/schema-indexes.d.ts +1 -1
  351. package/dist/plugins/schema-live-columns.d.ts +1 -1
  352. package/dist/plugins/session-event-payload.d.ts +4 -4
  353. package/dist/plugins/session-fork.d.ts +34 -0
  354. package/dist/plugins/session-fork.js +29 -0
  355. package/dist/plugins/session-ownership.js +1 -1
  356. package/dist/plugins/session-placement.d.ts +1 -1
  357. package/dist/plugins/session-policy-store-sql.d.ts +12 -12
  358. package/dist/plugins/session-store.d.ts +2 -2
  359. package/dist/plugins/session-store.js +2 -2
  360. package/dist/plugins/shared-memory-store-sql.d.ts +2 -2
  361. package/dist/plugins/snapshot-bucket-presence.d.ts +39 -4
  362. package/dist/plugins/snapshot-bucket-presence.js +35 -7
  363. package/dist/plugins/sql-driver.d.ts +8 -8
  364. package/dist/plugins/sql-errors.d.ts +40 -1
  365. package/dist/plugins/sql-errors.js +49 -1
  366. package/dist/plugins/sql-json-column.d.ts +21 -21
  367. package/dist/plugins/sql-row-helpers.d.ts +2 -2
  368. package/dist/plugins/store-backend.d.ts +17 -16
  369. package/dist/plugins/store-backend.js +3 -3
  370. package/dist/plugins/store-contracts.d.ts +21 -21
  371. package/dist/plugins/store-fault.d.ts +4 -0
  372. package/dist/plugins/store-fault.js +8 -0
  373. package/dist/plugins/task-attachment-store.d.ts +2 -2
  374. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  375. package/dist/plugins/tidb-pool.d.ts +2 -2
  376. package/dist/plugins/tidb-pool.js +10 -3
  377. package/dist/plugins/tidb-session-store.d.ts +16 -26
  378. package/dist/plugins/tidb-session-store.js +15 -27
  379. package/dist/plugins/tool-result-store-sql.d.ts +1 -1
  380. package/dist/plugins/usage-window-store-sql.d.ts +3 -3
  381. package/dist/plugins/user-input-ledger-file.d.ts +1 -1
  382. package/dist/plugins/user-input-ledger-sql.d.ts +3 -3
  383. package/dist/plugins/web-search.d.ts +19 -5
  384. package/dist/plugins/web-search.js +20 -5
  385. package/dist/{orchestration/workflow-journal-entry.d.ts → plugins/workflow-journal-payload.d.ts} +23 -32
  386. package/dist/plugins/workflow-journal-payload.js +32 -0
  387. package/dist/plugins/workflow-journal-store-sql.d.ts +28 -14
  388. package/dist/plugins/workflow-journal-store-sql.js +34 -15
  389. package/dist/plugins/workflow-run-store-sql.d.ts +4 -4
  390. package/dist/posture-source.d.ts +11 -11
  391. package/dist/principal-jwt.d.ts +6 -6
  392. package/dist/project-identity.d.ts +3 -3
  393. package/dist/project-memory.d.ts +4 -4
  394. package/dist/read-face-posture.d.ts +7 -7
  395. package/dist/request-declaration-refusal.d.ts +94 -0
  396. package/dist/request-declaration-refusal.js +78 -0
  397. package/dist/request-image-urls.d.ts +6 -0
  398. package/dist/request-image-urls.js +27 -0
  399. package/dist/request-key-closure.d.ts +6 -1
  400. package/dist/request-key-closure.js +5 -2
  401. package/dist/request-value-closure.d.ts +15 -8
  402. package/dist/request-value-closure.js +2 -0
  403. package/dist/router/route-orchestration.d.ts +11 -16
  404. package/dist/router/route-orchestration.js +2 -12
  405. package/dist/rule-entry-list.d.ts +8 -7
  406. package/dist/rule-entry-list.js +2 -9
  407. package/dist/rules-consent.d.ts +6 -6
  408. package/dist/rules-consent.js +2 -0
  409. package/dist/run-cancel-context.d.ts +5 -5
  410. package/dist/run-local.d.ts +10 -10
  411. package/dist/runs.d.ts +13 -11
  412. package/dist/runs.js +15 -1
  413. package/dist/runtime-caps-resolver.d.ts +6 -6
  414. package/dist/runtime-caps-resolver.js +1 -1
  415. package/dist/runtime-governance.d.ts +9 -9
  416. package/dist/sandbox-pkg-source.d.ts +17 -12
  417. package/dist/sandbox-pkg-source.js +14 -9
  418. package/dist/sealed-key.d.ts +22 -3
  419. package/dist/sealed-key.js +47 -4
  420. package/dist/security.d.ts +23 -26
  421. package/dist/security.js +12 -9
  422. package/dist/server-secret-env.d.ts +10 -10
  423. package/dist/session-children-retire.d.ts +1 -1
  424. package/dist/session-error-wire.d.ts +7 -7
  425. package/dist/session-incarnation.d.ts +65 -37
  426. package/dist/session-incarnation.js +30 -12
  427. package/dist/session-policy-wire.d.ts +27 -5
  428. package/dist/session-policy-wire.js +15 -1
  429. package/dist/session-records-skipped-notice.d.ts +1 -1
  430. package/dist/session-row.d.ts +3 -17
  431. package/dist/session-row.js +4 -0
  432. package/dist/session-sync-kernel.d.ts +4 -4
  433. package/dist/session-sync.d.ts +61 -6
  434. package/dist/session-sync.js +55 -10
  435. package/dist/session-titler.d.ts +7 -6
  436. package/dist/session-titler.js +8 -13
  437. package/dist/session-watch.d.ts +3 -3
  438. package/dist/session-watch.js +4 -4
  439. package/dist/sighup-idle.d.ts +2 -2
  440. package/dist/spec-fields.d.ts +4 -4
  441. package/dist/sql-engine-posture.d.ts +3 -3
  442. package/dist/store-posture.d.ts +2 -2
  443. package/dist/stored-request-tool-axes-m19.d.ts +1 -1
  444. package/dist/task-a2a.d.ts +52 -79
  445. package/dist/task-a2a.js +224 -62
  446. package/dist/task-cwd.d.ts +7 -88
  447. package/dist/task-cwd.js +2 -15
  448. package/dist/task-mcp.d.ts +13 -17
  449. package/dist/task-mcp.js +29 -49
  450. package/dist/task-settings.d.ts +30 -18
  451. package/dist/task-settings.js +33 -3
  452. package/dist/task-workflow.d.ts +0 -24
  453. package/dist/task-workflow.js +2 -1
  454. package/dist/terminal.d.ts +5 -5
  455. package/dist/tighten-only-seats.d.ts +7 -6
  456. package/dist/tighten-only-seats.js +1 -1
  457. package/dist/tool-approval.d.ts +166 -207
  458. package/dist/tool-approval.js +61 -61
  459. package/dist/tool-rule-names.d.ts +2 -2
  460. package/dist/trace/core-keyset-guard.d.ts +13 -8
  461. package/dist/trace/engine-notice-wire.d.ts +5 -5
  462. package/dist/trace/engine-notice-wire.js +1 -0
  463. package/dist/trace/exit-seat.d.ts +31 -4
  464. package/dist/trace/exit-seat.js +69 -67
  465. package/dist/trace/ledger-events.d.ts +3 -3
  466. package/dist/trace/ledger-sink.d.ts +1 -1
  467. package/dist/trace/model-segment.d.ts +3 -3
  468. package/dist/trace/project.d.ts +47 -45
  469. package/dist/trace/project.js +33 -1
  470. package/dist/trace/redact.d.ts +61 -31
  471. package/dist/trace/redact.js +394 -153
  472. package/dist/trace/self-minted-wire.d.ts +302 -14
  473. package/dist/trace/self-minted-wire.js +87 -0
  474. package/dist/trace/sema-provenance.d.ts +1 -1
  475. package/dist/trace/task-notification-facets.d.ts +4 -4
  476. package/dist/trace/wire-projection-faces.d.ts +3 -3
  477. package/dist/trace/wire-projection-faces.js +1 -1
  478. package/dist/unattended-permission-mode.d.ts +5 -5
  479. package/dist/url-credential-refusal.d.ts +52 -0
  480. package/dist/url-credential-refusal.js +14 -0
  481. package/dist/url-refusal.d.ts +16 -3
  482. package/dist/url-refusal.js +15 -2
  483. package/dist/usage-analytics.d.ts +2 -2
  484. package/dist/user-input-ledger.d.ts +23 -23
  485. package/dist/web-admin-client/apply-effective.d.ts +5 -5
  486. package/dist/web-admin-client/apply-effective.js +2 -1
  487. package/dist/web-admin-client/apply-ledger.d.ts +2 -2
  488. package/dist/web-admin-client/center-request.d.ts +2 -2
  489. package/dist/web-admin-client/facade.d.ts +5 -5
  490. package/dist/web-admin-client/facade.js +1 -1
  491. package/dist/web-admin-client/hot-keys-registry.d.ts +2 -2
  492. package/dist/web-admin-client/http-client.d.ts +4 -4
  493. package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
  494. package/dist/web-admin-client/pull-state.d.ts +1 -1
  495. package/dist/web-admin-client/read-face.d.ts +2 -2
  496. package/dist/web-admin-client/read-warnings.d.ts +5 -5
  497. package/dist/web-admin-client/restart-signal.d.ts +6 -6
  498. package/dist/web-admin-client/skills-mcp.d.ts +28 -3
  499. package/dist/web-admin-client/skills-mcp.js +29 -1
  500. package/dist/web-admin-client/types.d.ts +16 -9
  501. package/dist/workspace-space.d.ts +32 -3
  502. package/dist/workspace-space.js +26 -0
  503. package/dist/write-protection.d.ts +2 -2
  504. package/package.json +5 -3
  505. package/scripts/drain-check-local.mjs +4 -2
  506. package/scripts/drain-check.mysql.sql +6 -2
  507. package/scripts/drain-check.pg.sql +6 -2
  508. package/skills/loop.md +1 -1
  509. package/skills/schedule.md +1 -1
  510. package/wire-changes/server@7.104.0.json +134 -0
  511. package/wire-changes/server@7.105.0.json +53 -0
  512. package/wire-changes/server@7.106.0.json +475 -0
  513. package/wire-changes/server@7.107.0.json +64 -0
  514. package/wire-changes/server@7.108.0.json +153 -0
  515. package/wire-changes/server@7.109.0.json +46 -0
  516. package/wire-changes/server@7.110.0.json +90 -0
  517. package/wire-changes/server@7.111.0.json +86 -0
  518. package/wire-changes/server@7.112.0.json +60 -0
  519. package/wire-changes/server@7.113.0.json +26 -0
  520. package/wire-changes/server@7.114.0.json +26 -0
  521. package/wire-changes/server@7.115.0.json +97 -0
  522. package/wire-changes/server@7.116.0.json +218 -0
  523. package/wire-changes/server@7.116.1.json +26 -0
  524. package/wire-changes/server@7.117.0.json +65 -0
  525. package/wire-changes/server@7.118.0.json +129 -0
  526. package/wire-changes/server@7.119.0.json +65 -0
  527. package/wire-changes/server@7.120.0.json +89 -0
  528. package/wire-changes/server@7.121.0.json +219 -0
  529. package/wire-changes/server@7.122.0.json +54 -0
  530. package/wire-changes/server@7.123.0.json +26 -0
  531. package/wire-changes/server@7.124.0.json +336 -0
  532. package/wire-changes/server@7.124.1.json +26 -0
  533. package/wire-changes/server@7.125.0.json +111 -0
  534. package/wire-changes/server@7.126.0.json +285 -0
  535. package/wire-changes/server@7.127.0.json +77 -0
  536. package/wire-changes/server@7.127.1.json +26 -0
  537. package/wire-changes/server@7.127.2.json +53 -0
  538. package/wire-changes/server@7.128.0.json +26 -0
  539. package/wire-changes/server@7.129.0.json +106 -0
  540. package/wire-changes/server@7.129.1.json +26 -0
  541. package/wire-changes/server@7.130.0.json +26 -0
  542. package/wire-changes/server@7.131.0.json +118 -0
  543. package/wire-changes/server@7.132.0.json +226 -0
  544. package/wire-changes/server@7.133.0.json +1155 -0
  545. package/wire-changes/server@7.134.0.json +107 -0
  546. package/wire-changes/server@7.135.0.json +174 -0
  547. package/wire-changes/server@7.136.0.json +448 -0
  548. package/dist/http/run-declared-families.d.ts +0 -16
  549. package/dist/http/run-declared-families.js +0 -12
  550. package/dist/orchestration/workflow-journal-entry.js +0 -27
@@ -1,5 +1,5 @@
1
1
  /**
2
- * S-790 / S-506([ref] §2)—— **会话化身**:一个会话 id 是座位,化身是这一位住客。
2
+ * [ref] / [ref]([ref] §2)—— **会话化身**:一个会话 id 是座位,化身是这一位住客。
3
3
  *
4
4
  * 会话 id 由调用方自选,删掉之后同一个 id 可以被别人(或同一个人)重新登记(`boot/session-faces.ts` 的级联删除注自认)。
5
5
  * 本仓大量持久状态只按会话 id 分区,于是「上一位住客留下的东西」会在下一位名下继续起作用。化身令牌给「是不是同一位住客」
@@ -11,32 +11,43 @@
11
11
  * 化身沿用。删除随行消失,同 id 重新登记铸新的。
12
12
  * · **值是不透明随机串**(`randomUUID()`,v4:没有时间戳、没有机器信息 —— 刻意不用 uuidv7,那一形带铸造时刻)。只拿来比较。
13
13
  * · **一格、一个解码**:住客令牌是会话**行**上的一格 —— SQL `session_meta.incarnation`(两方言)、local 后端的会话元数据边档那一格
14
- * (`plugins/local-session-store.ts` 的 `session-incarnations.json`)。每只店对它只有**一次读**(`sessionFaceOf`),行上的值只经
15
- * {@link incarnationFromCell} 解码;别的读法都从这一次读派生(下一节),没有第二份。
16
- * · **读口唯一**:会话店的 `sessionFaceOf(sessionId) → { owner, incarnation } | undefined`,一次读同时给两样
17
- * (两次独立读在删除 / 重登记的缝里能拼出混世代组合,与 `getHead` 同一条理由)。`undefined` = 没有这只会话。
18
- * · **读到空化身 ⇒ 响亮拒**({@link SessionIncarnationMissingError}):一次性迁移(`plugins/one-time-migrations.ts` 登记表 M5)
19
- * 之后,空值只可能来自没铸化身的写腿或人为改库 —— 把它当「通配」就是让任何人都能和这一行比成同一位住客。
14
+ * (`plugins/local-session-store.ts` 的 `session-incarnations.json`)。行上的值只经 {@link incarnationFromCell} 解码。
15
+ * · **按 id 读只有一只:core 的 `SessionStore.headOf(id)`**(core 7.55.0 [ref] S2;`{ owner, incarnation, leafId }`,同一行、同一次读 ——
16
+ * 两次独立读在删除 / 重登记的缝里能拼出混世代组合)。`undefined` = 没有这只会话。店把行读成头只经 {@link headFromRow}:化身那一格按
17
+ * `absent` 读(空 / 非串 ⇒ `undefined` = 住客未知,core 的同一读法)。按 id 问属主 / 住客 / 叶子的每一个读者都是这一只读的投影 ——
18
+ * 本仓此前每只店各有五只按 id 读(`ownerOf` / `incarnationOf` / `sessionFaceOf` / `getHead` / `getLeafId`),同一行的五个读者,全部退役。
19
+ * 「店有没有这只读」只判一处:{@link headReadOf}。
20
+ * · **头答自会话行;会话内容读不出只是叶子那一格的事**(三种会话店一律):有没有这只会话、归谁、哪一位住客,只问行(SQL `session_meta`;
21
+ * local 店 = 会话元数据边档那一格)。头里唯一可能取自会话**内容**的一格是叶子(local 店的叶子取自会话存档的末条条目,SQL 的叶子是行上的一列)——
22
+ * 内容读不出时,头照答行上的属主与住客,叶子那一格带着读它时撞上的那只故障({@link UnreadableLeaf}),**谁读叶子谁收到它**。
23
+ * 于是只判归属的读者(授权门、各路由的属主门、删除的围栏、住客读)对坏内容与好内容同答,内容的故障只让门放行之后读内容的那一位看见;
24
+ * 行本身读不出(local:边档里还没有这只会话的那一格、要从存档推出它在不在,而存档读不出)⇒ 头读整只拒(读故障,不是答案)。
25
+ * · **两头是不是同一位住客:core 的 `compareOccupants`**(三答 `same` / `different` / `unknown`;任一侧没有行或没有令牌 ⇒ `unknown`,
26
+ * `unknown` 永不当 `same`)。本仓自写的比较(`sameSessionOccupant`)退役:同一个问题只有引擎那一只判官。
27
+ * · **一位活住客必须有令牌 —— 读到空化身 ⇒ 响亮拒**({@link SessionIncarnationMissingError}):本仓比 core 多的那一条律,只住在一处 ——
28
+ * 把头投成 {@link SessionFace}(属主 + 一只令牌)的 {@link sessionFaceOfHead}(批量来源读与换装回读用同一只 {@link sessionFaceFromRow})。
29
+ * 要拿令牌去**写**(带化身条件的 UPDATE、认领、空间分区键)或要响亮区分「行坏了」的读者经它;只**比较**两头的读者用 `compareOccupants`。
30
+ * 空值只可能来自没铸化身的写腿、人为改库,或跳过了 7.104.0–7.135.x(那几版的起服迁移给存量行铸令牌,窗关后已删码)直接升上来的库 ——
31
+ * 把它当「通配」就是让任何人都能和这一行比成同一位住客。
20
32
  * · **不上 wire、不进模型上下文、不进日志正文**:日志里要点名时只打 {@link incarnationLogPrefix}(前 8 位)。
21
33
  *
22
- * ## 谁读它(全部派生自那一格)
23
- * · `/decide` 的 parked 赎回腿(`parked-decide.ts`):claim 前读一次、claim 后再读一次,会话不在或化身变了 ⇒ 回滚 claim、
34
+ * ## 谁读它(全部派生自那一只头读)
35
+ * · `/decide` 的 parked 赎回腿(`parked-decide.ts`):claim 前读一次、claim 后再读一次,会话不在或不是同一位住客 ⇒ 回滚 claim、
24
36
  * 答既有的 `409 decide.not_parked`;赎回面(`parked-revive-surface.ts`)只在属主相等**且**两次读是同一位住客时交继承座。
25
37
  * · core 的记忆引擎:Runner 读**它取到的那只会话**的 `getMetadata().incarnation`(SQL 两店的 wake 带出这一列;local 店交出的会话
26
38
  * 在元数据上答边档那一格),不再有宿主座。
27
- * · 按 id 读的消费方(没取会话的那一侧 —— k8s 工作区空间的分区,`boot/execution-env.ts`):core 的 `SessionStore.incarnationOf`,
28
- * 三只店都实装为 `sessionFaceOf` 的化身那一半;缓存包装层原样转发。「店有没有这只读」只判一处:{@link incarnationReadOf}。
39
+ * · 没取会话的那一侧(k8s 工作区空间的分区,`boot/execution-env.ts`):会话店的 `headOf`,经 {@link sessionFaceOfHead} 拿令牌;缓存包装层原样转发。
29
40
  */
30
- import type { SessionStore } from "@sema-agent/core";
31
- /** 会话元数据的一次读:属主 + 化身(同一行、同一次读)。 */
41
+ import type { SessionHead } from "@sema-agent/core";
42
+ /** 一位活住客:属主 + 它的令牌(同一行、同一次读;投影自会话店的头,见 {@link sessionFaceOfHead})。 */
32
43
  export interface SessionFace {
33
44
  /** `null` = 登记为无主的会话。 */
34
45
  readonly owner: string | null;
35
- /** 这一位住客的化身令牌(非空;空值在读口就响亮拒了)。 */
46
+ /** 这一位住客的化身令牌(非空;空值在投影处就响亮拒了)。 */
36
47
  readonly incarnation: string;
37
48
  }
38
- /** 读口的形(三只会话店 + 缓存包装层同一个签名)。 */
39
- export type SessionFaceReader = (sessionId: string) => Promise<SessionFace | undefined>;
49
+ /** 会话店的按 id 读(core `SessionStore.headOf` 的形):`undefined` = 没有这只会话;读抛 = 读故障,不是答案。 */
50
+ export type HeadRead = (sessionId: string) => Promise<SessionHead | undefined>;
40
51
  /** 铸一只新化身(铸点见头注,只在新建行)。 */
41
52
  export declare function mintSessionIncarnation(): string;
42
53
  /** 日志里点名一只化身时唯一允许的形:前 8 位。完整令牌不进任何日志正文。 */
@@ -46,11 +57,6 @@ export declare function incarnationLogPrefix(incarnation: string): string;
46
57
  * 把其中每一只化身形的串截成 {@link incarnationLogPrefix}(前 8 位 + `…`)。规则只有一条:完整令牌不进日志正文;前 8 位留着对账。
47
58
  */
48
59
  export declare function redactIncarnations(text: string): string;
49
- /**
50
- * 两次读是不是**同一位住客**:都在、化身逐字相等。任一次读不到(会话不在)⇒ 不是 —— 没有「读不到就当相同」的臂。
51
- * 属主是否等于某个身份是调用方自己的判据(赎回面比的是卡的权威 principal),不在这里。
52
- */
53
- export declare function sameSessionOccupant(before: SessionFace | undefined, after: SessionFace | undefined): boolean;
54
60
  /**
55
61
  * 会话行在、化身却是空的 —— 响亮拒(头注「读到空化身」一条)。具名类型:调用方按类型认它,不按文案。
56
62
  * 文案不带任何令牌(本来就是空的),只点名会话 id 与出路。
@@ -62,32 +68,54 @@ export declare class SessionIncarnationMissingError extends Error {
62
68
  }
63
69
  /**
64
70
  * 空化身那一格怎么读 —— {@link incarnationFromCell} 的参数(一只解码,两种**显式**读法;不是两只函数):
65
- * · `refuse`(缺省,读口):一位活住客必须有令牌 ⇒ 空 / 非串 = {@link SessionIncarnationMissingError}(响亮拒,不当通配);
66
- * · `absent`:调用方问的是「这一格里有没有一只令牌」,空 / 非串的答案是**没有**(`undefined`)—— 会话树删除时的空间键
67
- * (没有令牌 = 没有空间,不回收缓存卷)与整段换装的沿用判据(没有令牌 = 铸一只新的)。
71
+ * · `refuse`(缺省,活住客的投影 {@link sessionFaceFromRow} / {@link sessionFaceOfHead}):一位活住客必须有令牌 ⇒ 空 / 非串 =
72
+ * {@link SessionIncarnationMissingError}(响亮拒,不当通配);SQL 两店 wake 带出的会话元数据同此读;
73
+ * · `absent`:调用方问的是「这一格里有没有一只令牌」,空 / 非串的答案是**没有**(`undefined`)—— 店读出的头({@link headFromRow},
74
+ * core 的「住客未知」)、会话树删除时的空间键(没有令牌 = 没有空间,不回收缓存卷)与整段换装的沿用判据(没有令牌 = 铸一只新的)。
68
75
  */
69
76
  export type EmptyIncarnationReading = "refuse" | "absent";
70
77
  /**
71
- * 行上化身那一格的**唯一解码**(三只店的 `sessionFaceOf`、SQL 两店 wake 带出的会话元数据、留存删除的空间键、整段换装的沿用判据都经它 ——
78
+ * 行上化身那一格的**唯一解码**(店读出的头、活住客的投影、SQL 两店 wake 带出的会话元数据、留存删除的空间键、整段换装的沿用判据都经它 ——
72
79
  * 「是不是一只令牌」只判这一处)。非空字符串 ⇒ 那只令牌;否则按 `empty`({@link EmptyIncarnationReading}):缺省 `refuse` ⇒
73
80
  * {@link SessionIncarnationMissingError},`absent` ⇒ `undefined`。
74
81
  */
75
82
  export declare function incarnationFromCell(sessionId: string, cell: unknown, empty?: "refuse"): string;
76
83
  export declare function incarnationFromCell(sessionId: string, cell: unknown, empty: "absent"): string | undefined;
77
- /** 店把一行原始列读成 {@link SessionFace} 的唯一口(三只店共用;化身那一格经 {@link incarnationFromCell})。 */
84
+ /** 一行原始列 → {@link SessionFace}(属主 + 一只令牌)的唯一口:化身那一格经 {@link incarnationFromCell} 的 `refuse` 读法(空 ⇒ 响亮拒)。
85
+ * 按 id 的读者经 {@link sessionFaceOfHead};批量来源读(委派继承律)与 staged 换装的回读直接从行列经它。 */
78
86
  export declare function sessionFaceFromRow(sessionId: string, owner: string | null, incarnation: unknown): SessionFace;
79
- /** 按 id 读住客(core `SessionStore.incarnationOf` 的形):`undefined` = 没有这只会话;读抛 = 读故障,不是答案。 */
80
- export type IncarnationRead = (sessionId: string) => Promise<string | undefined>;
81
87
  /**
82
- * 「这只会话店能不能按 id 答住客」—— 全仓**只判这一处**:起服门(`assertWorkspaceSpaceReadable`)与 k8s 工作区空间的每 run 读
83
- * (`createK8sRunEnvFactory`)读的是同一只返回值(装配第 5 段判一次)。缺席 = 店没有实装 `incarnationOf`。
88
+ * 头的叶子那一格读不出 —— 会话**内容**读不出时的那只故障(local 店:会话存档读不出,例如存档首行的会话头坏了;行上的属主与住客照样读得出)。
89
+ * {@link headFromRow} 收它:头照答属主与住客,叶子那一格带着这只故障,读 `leafId` 的那一位收到它本身(同一只错误对象,码与句子原样 ——
90
+ * 上 wire 时照旧经 `sessionErrorHttp` 映射)。规则见头注「头答自会话行」一条。
91
+ */
92
+ export declare class UnreadableLeaf {
93
+ readonly fault: unknown;
94
+ constructor(fault: unknown);
95
+ }
96
+ /** 店把一行读成 core {@link SessionHead} 的唯一口(SQL 两孪生、local 店同调):化身那一格按 `absent` 读(空 / 非串 ⇒ `undefined` = 住客未知,
97
+ * 与 core 的读法同义 —— 拒不拒是投影的事,见 {@link sessionFaceOfHead})。叶子那一格读不出({@link UnreadableLeaf})⇒ 头照答属主与住客,
98
+ * 读 `leafId` 的那一位收到那只故障 —— 永不把读不出的叶子答成 `null`(`null` = 空会话)。 */
99
+ export declare function headFromRow(sessionId: string, owner: string | null, incarnation: unknown, leaf: string | null | UnreadableLeaf): SessionHead;
100
+ /**
101
+ * 🔴 **会话内容读不读得出 —— 会话路由在门放行之后判它的唯一读法**:读头的叶子。内容读不出的头({@link UnreadableLeaf})在这一读上抛那只故障本身
102
+ * (码 `corrupt_session`,经 `sessionErrorHttp` 的 open 面落 500);读得出 ⇒ 叶子 id(`null` = 空会话)。
103
+ * 谁在**门放行之后**要动这只会话的内容(读叶子本身、开事件流、改名 —— 改名答的是列表行,列表读存档),谁就经它读一次;
104
+ * 门之前不许读(非属主对坏档与对好档同答,见头注「头答自会话行」)。三个口各写一句 `head.leafId` 与各写一句"存档坏了怎么办"是同一件事的三种答法
105
+ * (修前:头探针 500、事件流 200 零帧 —— 观察探针把每拍读叶子抛出的故障当瞬时错吞掉 —— 改名 404 —— 列表跳过读不出的存档,会话被说成不存在)。
106
+ * SQL 两店的叶子是行上的一列,永不抛 ⇒ 这一读在 SQL 上恒等于 `head.leafId`,这条判据只对内容与行分居两处的店(local)有牙。
107
+ * 事件流只在开流之前判一次;流开了之后存档才坏,观察探针仍把读叶子的故障当瞬时错续探(流不断、不再产出新帧)。
84
108
  */
85
- export declare function incarnationReadOf(store: Pick<SessionStore, "incarnationOf"> | undefined): IncarnationRead | undefined;
109
+ export declare function leafOfAdmittedHead(head: SessionHead): string | null;
110
+ /** 一只头 → 一位活住客({@link SessionFace}):`undefined` 头 = 没有这只会话 ⇒ `undefined`;行在而没有令牌 ⇒ {@link SessionIncarnationMissingError}
111
+ * (本仓的那条律只住在这里 + {@link sessionFaceFromRow})。 */
112
+ export declare function sessionFaceOfHead(sessionId: string, head: SessionHead): SessionFace;
113
+ export declare function sessionFaceOfHead(sessionId: string, head: SessionHead | undefined): SessionFace | undefined;
86
114
  /**
87
- * 「这只会话店能不能按 id 答住客脸(属主 + 化身一次读)」—— 与 {@link incarnationReadOf} 同一处判法、同一个「能不能」:
88
- * 空间缓存卷的回收用它一次拿两位(属主要与这次删除验过的那位相符,化身是空间键)。店没有这只读口 ⇒ `undefined`(回收不做,不响)。
115
+ * 「这只会话店有没有按 id 读(`headOf`)」—— 全仓**只判这一处**:授权口、各路由的属主门、能力位、起服门、k8s 工作区空间的每 run 读与
116
+ * 委派继承律读的都是这一只返回值。缺席 = 店没有实装 `headOf`(读不出属主 / 住客 / 叶子,调用方各按自己的 fail-closed 臂处置)。
89
117
  */
90
- export declare function sessionFaceReadOf(store: object | undefined): SessionFaceReader | undefined;
118
+ export declare function headReadOf(store: object | undefined): HeadRead | undefined;
91
119
  /**
92
120
  * session-sync **整段换装**(replace)时化身的去留 —— 三只店共用的一句判据:换装删掉再插回的是**同一位住客**的那一行
93
121
  * (删除带属主门),所以行在、属主相同、那一格里有一只令牌(唯一解码 {@link incarnationFromCell} 的 `absent` 读法)⇒ 沿用;
@@ -99,12 +127,12 @@ export declare function carriedIncarnation(sessionId: string, prior: {
99
127
  } | undefined, owner: string | null): string;
100
128
  /**
101
129
  * `session_meta.incarnation` 的列定义 —— 两方言各一句,**唯一属主**:中央 DDL(`tidb-pool.ts` / `pg-session-storage.ts` 的
102
- * `CREATE TABLE session_meta`)与一次性迁移 M5 的 `ADD COLUMN`(`plugins/one-time-migrations.ts`)都内插这同一串,
103
- * 于是「新库建出来的列」与「存量库补上的列」逐字同形(S-547 起服列册探针比的是列名,形由这里保证)。
130
+ * `CREATE TABLE session_meta`)内插这同一串;存量库缺这一列时,起服列册探针(`schema-consistency.ts`)拒启,拒句里的 `ALTER TABLE … ADD COLUMN …`
131
+ * 由同一份建表语句解析生成 ⇒ 「新库建出来的列」与「运维按拒句补上的列」逐字同形(探针比的是列名,形由这里保证)。
104
132
  *
105
133
  * `NOT NULL DEFAULT ''`:空串就是「没铸过」的唯一表示 —— 读口对它响亮拒({@link SessionIncarnationMissingError})。
106
134
  * 缺省值只为两件事存在:①存量表 `ADD COLUMN` 在两方言上一句成立(PG 对非空表加无缺省的 NOT NULL 列直接拒);
107
- * ②一条漏铸的写腿落下的是**读得出来的错**(读口拒),而不是一条插入期的 500 —— 两形都 fail-closed,前者还能被迁移补上。
135
+ * ②一条漏铸的写腿落下的是**读得出来的错**(读口拒),而不是一条插入期的 500 —— 两形都 fail-closed。
108
136
  * 宽度 64:`randomUUID()` 是 36 字符,留出余量但不给任意长串留位。
109
137
  */
110
138
  export declare const SESSION_META_INCARNATION_COLUMN: {
@@ -9,17 +9,14 @@ const INCARNATION_TOKEN_SHAPE = /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9
9
9
  export function redactIncarnations(text) {
10
10
  return text.replace(INCARNATION_TOKEN_SHAPE, (token) => `${incarnationLogPrefix(token)}…`);
11
11
  }
12
- export function sameSessionOccupant(before, after) {
13
- return before !== undefined && after !== undefined && before.incarnation === after.incarnation;
14
- }
15
12
  export class SessionIncarnationMissingError extends Error {
16
13
  sessionId;
17
14
  code = "session.incarnation_missing";
18
15
  constructor(sessionId) {
19
- super(`session ${sessionId} has no incarnation token: every session row is minted one when it is created, and rows written before ` +
20
- `7.104.0 get one from the one-time migration that runs at boot (plugins/one-time-migrations.ts, entry M5). An empty value ` +
21
- `after that means a write path that did not mint one, or a hand-edited row — it is refused rather than read as "matches anyone". ` +
22
- `Restart a 7.104.0+ replica so the migration backfills it, or delete the session.`);
16
+ super(`session ${sessionId} has no incarnation token: every session row is minted one when it is created. An empty value means a write path ` +
17
+ `that did not mint one, a hand-edited row, or a database upgraded from before 7.104.0 straight to a version after 7.135.x (a boot of any ` +
18
+ `version in between minted tokens for the older rows; the code that did so has since been removed) — it is refused rather than read as ` +
19
+ `"matches anyone". Give the row a distinct random token (any opaque string of at most 64 characters), or delete the session.`);
23
20
  this.sessionId = sessionId;
24
21
  this.name = "SessionIncarnationMissingError";
25
22
  }
@@ -41,12 +38,33 @@ export function incarnationFromCell(sessionId, cell, empty = "refuse") {
41
38
  export function sessionFaceFromRow(sessionId, owner, incarnation) {
42
39
  return { owner, incarnation: incarnationFromCell(sessionId, incarnation) };
43
40
  }
44
- export function incarnationReadOf(store) {
45
- const read = store?.incarnationOf;
46
- return typeof read === "function" ? read.bind(store) : undefined;
41
+ export class UnreadableLeaf {
42
+ fault;
43
+ constructor(fault) {
44
+ this.fault = fault;
45
+ }
46
+ }
47
+ export function headFromRow(sessionId, owner, incarnation, leaf) {
48
+ const occupant = incarnationFromCell(sessionId, incarnation, "absent");
49
+ if (!(leaf instanceof UnreadableLeaf))
50
+ return { owner, incarnation: occupant, leafId: leaf };
51
+ const { fault } = leaf;
52
+ return {
53
+ owner,
54
+ incarnation: occupant,
55
+ get leafId() {
56
+ throw fault;
57
+ },
58
+ };
59
+ }
60
+ export function leafOfAdmittedHead(head) {
61
+ return head.leafId;
62
+ }
63
+ export function sessionFaceOfHead(sessionId, head) {
64
+ return head === undefined ? undefined : sessionFaceFromRow(sessionId, head.owner, head.incarnation);
47
65
  }
48
- export function sessionFaceReadOf(store) {
49
- const read = store?.sessionFaceOf;
66
+ export function headReadOf(store) {
67
+ const read = store?.headOf;
50
68
  return typeof read === "function" ? read.bind(store) : undefined;
51
69
  }
52
70
  export function carriedIncarnation(sessionId, prior, owner) {
@@ -2,15 +2,16 @@
2
2
  * 会话规则(`SessionPermissionRules`)的 **wire 面单一属主** —— 两条写入腿(`PUT /v1/sessions/:id/policy` 与
3
3
  * `POST /v1/sessions/:id/sync/import` 的 `policy` 面)的写口读者、`SessionPolicyError` 闭集 → HTTP 的映射、拒句。
4
4
  *
5
- * ── 规则(一句;引擎 7.51.0 #1480 / #1497 起)────────────────────────────────────────────────────────────────────────
5
+ * ── 规则(一句;引擎 7.51.0 [ref] / [ref] 起)────────────────────────────────────────────────────────────────────────
6
6
  * 会话规则在每一站只有一种文法、一只判官 —— 引擎的:写口判官 `judgeSessionRulesWrite`(形 `readSessionRulesShape` → 每条条目的读法
7
7
  * `readRuleEntry`),读回是同一只形读法(SQL 店的 `readSessionRulesBody`)。core 7.51.2 起一行条目的意思由行自带的文法戳 `grammar` 说(判官盖、店整只存、
8
8
  * 读回原样交出);写口的值带 `rev` 而无戳 ⇒ 引擎按存量行的文法读它(`earlier_grammar`,见 {@link describeInertEntry})。引擎的两只**内容**拒码各对应一个本服务码,名字随引擎的词:
9
9
  * · `invalid_shape` ⇒ `400 rules.invalid_shape` —— 规则体不是「一只对象、键都是桶、每只桶是一列字符串」(含退役的 `commandAllow` / `commandDeny`、
10
10
  * 纯空白的目录、`rules` 缺席或不是对象);拒体顶层 = 引擎的形读数 `{ field, got }`(值的**类型**,不回显值),句子 = 引擎的句子原样。
11
11
  * · `inert_entry` ⇒ `400 rules.inert_entry` —— 桶里有一条引擎条目读者读成「什么都不是」的条目(退役名、无前缀的 `__` 名、铸不出的协议段、
12
- * `*`、`mcp__*`、文法不成的 `Bash(`、工具没有那种规则形的 `Monitor(…)` …);拒体顶层 = 引擎的条目读数 `{ field, entry, reason, verdict?, guidance?,
12
+ * `*`、放行桶里的整协议名 `mcp__*`(core 7.55.0 起拒绝桶里它是这一协议的每一只工具,收)、对端段的部分通配 `mcp__git*`、文法不成的 `Bash(`、工具没有那种规则形的 `Monitor(…)` …);拒体顶层 = 引擎的条目读数 `{ field, entry, reason, verdict?, guidance?,
13
13
  * currentName? }`,句子是本服务的({@link describeInertEntry}:引擎那一句的退役名出路指向嵌入方的构造选项 `mountedToolNames`,HTTP 调用方没有这个旋钮)。
14
+ * 能力位 `sessionRulesNamespaceForms`({@link sessionRulesNamespaceFormsHonored})是同一只写口读者的投影:协议命名空间的覆盖形写口真收,位才说有。
14
15
  * 两条写入腿与店拒中继({@link sessionPolicyErrorHttp} / `http/send.ts` 的 `sendSessionPolicyError`)走**同一张映射、同一句、同一份拒体** ——
15
16
  * 写口读者先问一遍只是为了 sync/import 腿在建 staging **之前**整批拒(店拒发生在逐条写的中途),判官仍是引擎那一只。
16
17
  *
@@ -39,6 +40,27 @@ export declare function readWritableSessionPermissionRules(raw: unknown): {
39
40
  refusal: SessionRulesRefusal;
40
41
  rules?: undefined;
41
42
  };
43
+ /**
44
+ * 表里每一员的**覆盖形**三只与一只它覆盖的真工具名 —— 全部由该员自己的 `prefix` / `makeName` 铸出,本仓不手写任何协议前缀:
45
+ * 整对端 `<前缀>peer`、工具段通配 `<前缀>peer__*`、工具段 glob `<前缀>peer__get_*`;`tool` = 同一员的 `<前缀>peer__get_user`(三形都该覆盖到它)。
46
+ * 表加一员,下一次调用里就有它的一行。
47
+ */
48
+ export declare function namespaceCoveringForms(): readonly {
49
+ readonly prefix: string;
50
+ readonly forms: readonly string[];
51
+ readonly tool: string;
52
+ }[];
53
+ /**
54
+ * 能力位 `sessionRulesNamespaceForms` 的**唯一**判据:会话规则记录里协议命名空间的覆盖形,引擎认成「一组工具」**且**写口收。
55
+ * 对 `PROTOCOL_TABLE` 的每一员:① 它的三只覆盖形,引擎的匹配器(`namespacedRuleNameCovers`,会话层与其余规则面同一只)都判得出覆盖那一员的真工具名
56
+ * (只当精确名收的写口不算 ——「收」与「认成一组」是两问);② 三形放进 `toolAllow` 与 `toolDeny` 两桶,两条写入腿共用的写口读者
57
+ * {@link readWritableSessionPermissionRules}(= 引擎写口判官)不拒。表非空 ∧ 每员都过 ⇒ `true`。
58
+ *
59
+ * 位说「有」的依据是写口**真收**,不是「表非空」这个未经验证的蕴含:`PUT /v1/sessions/:id/policy` 与 sync/import 的 `policy` 面调的就是同一只读者,
60
+ * 「位说有而写口恒拒」结构上不可能([ref] 族)。每次请求现算(不缓存):表是引擎的活数据,位随它走;纯函数、零 I/O,代价是几次条目读。
61
+ * 辖域是引擎 / 二进制事实,与本部署有没有会话规则店无关(那是 `sessionPolicy` 的事,一位一事)。
62
+ */
63
+ export declare function sessionRulesNamespaceFormsHonored(): boolean;
42
64
  /** 一条 `SessionRulesRecord` 的问题(`policy[]` 的元素级;规则体的问题原样转载引擎的内容拒)。 */
43
65
  export type SessionRulesRecordProblem =
44
66
  /** `policy` 本身不是数组。 */
@@ -110,15 +132,15 @@ export declare function sessionPolicyErrorFacts(e: SessionPolicyError): Readonly
110
132
  * **数据完整性故障**。这正是 [ref] 词表纪律说的那一形:闭集必须穷尽 `switch`,未知词是**编译**错,
111
133
  * 不是运行期落进某个恰好存在的臂。
112
134
  *
113
- * ⇒ 映射搬到这里(本文件是会话规则 wire 面的单一属主,S-496 先例),两条写入腿、读腿与 2c 重放腿同调它。
135
+ * ⇒ 映射搬到这里(本文件是会话规则 wire 面的单一属主,[ref] 先例),两条写入腿、读腿与 2c 重放腿同调它。
114
136
  * 新增一个词 ⇒ 本 switch 编译红,由人裁定它的状态码与码位,而不是让它静默继承邻居的。
115
137
  *
116
138
  * 逐词:
117
139
  * · `conflict`(409)—— CAS 输了,重读 `rev` 再来。**码位与状态逐字不变**。
118
- * · `loosen_forbidden`(403)—— 非 operator 想放松。**码位与状态逐字不变**。⚠️ 这个词还有**第二个铸点**(S-546 B5,
140
+ * · `loosen_forbidden`(403)—— 非 operator 想放松。**码位与状态逐字不变**。⚠️ 这个词还有**第二个铸点**([ref] B5,
119
141
  * 如实登记、未改):PG 后端的 SQL 双生对含 NUL / 孤代理字节的规则拒收时借用了它
120
142
  * (`plugins/session-policy-store-sql.ts` 的 `pgHasUnstorable` 臂)—— 那一形**既非放宽也非越权**,operator 写同样撞上;
121
- * core 的闭集里没有「输入不可存」这个词,改码位要先裁定新码与 PUT / 2c 导入两条入口同判(DEBTS S-546 B5)。
143
+ * core 的闭集里没有「输入不可存」这个词,改码位要先裁定新码与 PUT / 2c 导入两条入口同判(DEBTS [ref] B5)。
122
144
  * · `corrupt`(**500**)—— 店读不出它自己该读的那份字节(记号/行被列外篡改或撕裂,或存着引擎今天的形读法读不出的规则体)。
123
145
  * 不是 4xx:调用方没做错任何事,它也改不了这件事;不是 503:重试改不了判(修复路径是**人**去改回或删掉那一行,
124
146
  * 而删记号要交出它握着的那个号)。
@@ -1,4 +1,4 @@
1
- import { PROTOCOL_TABLE, SessionPolicyError, judgeSessionRulesWrite } from "@sema-agent/core";
1
+ import { PROTOCOL_TABLE, SessionPolicyError, judgeSessionRulesWrite, namespacedRuleNameCovers } from "@sema-agent/core";
2
2
  import { displayListEntry } from "./list-entry-display.js";
3
3
  function isSessionRulesRefusal(e) {
4
4
  return e instanceof SessionPolicyError && (e.code === "invalid_shape" || e.code === "inert_entry");
@@ -13,6 +13,20 @@ export function readWritableSessionPermissionRules(raw) {
13
13
  throw e;
14
14
  }
15
15
  }
16
+ const PROBE_PEER = "peer";
17
+ const PROBE_TOOL = "get_user";
18
+ export function namespaceCoveringForms() {
19
+ return PROTOCOL_TABLE.map((ns) => ({
20
+ prefix: ns.prefix,
21
+ forms: [`${ns.prefix}${PROBE_PEER}`, ns.makeName(PROBE_PEER, "*"), ns.makeName(PROBE_PEER, "get_*")],
22
+ tool: ns.makeName(PROBE_PEER, PROBE_TOOL),
23
+ }));
24
+ }
25
+ export function sessionRulesNamespaceFormsHonored() {
26
+ const probes = namespaceCoveringForms();
27
+ return (probes.length > 0 &&
28
+ probes.every(({ forms, tool }) => forms.every((form) => namespacedRuleNameCovers(form, tool)) && readWritableSessionPermissionRules({ toolAllow: [...forms], toolDeny: [...forms] }).refusal === undefined));
29
+ }
16
30
  export function readSessionRulesRecords(raw) {
17
31
  if (!Array.isArray(raw))
18
32
  return { problem: { kind: "not-an-array" } };
@@ -1,6 +1,6 @@
1
1
  import type { EngineNoticeCode, FileStorageCorruptReadInfo, SessionRepo } from "@sema-agent/core";
2
2
  import { type EngineNoticeRouter } from "./trace/engine-notice-wire.js";
3
- /** 码常量型 = core 码册(#1240 入册:受众 user、铸者 `NOTICE_MINTER` = `"server"`)。 */
3
+ /** 码常量型 = core 码册([ref] 入册:受众 user、铸者 `NOTICE_MINTER` = `"server"`)。 */
4
4
  export declare const SESSION_RECORDS_SKIPPED: EngineNoticeCode;
5
5
  /**
6
6
  * 披露座上的「作用域在场则记」腿(装配点 = `plugins/store-backend.ts` 里喂给 `LocalSessionStore` 的那只
@@ -1,19 +1,3 @@
1
- /**
2
- * 会话行的**可写位**(`title` / `pinned`)—— `PATCH /v1/sessions/:id` 的体闭集、两键的判据,与 2c 导入同读的那一套(唯一属主)。
3
- *
4
- * ## 一列一事实,写者次序成文
5
- * · `title` 是一列(SQL `session_meta.title` / local 标题边档),两个写者,一条律:**用户**经会话店唯一写口 `patchSessionMeta`
6
- * **无条件**写 —— 写一个串 = 改名,写 `null` = **清回自动标题**(列回到 NULL);**自动标题器**经 `setTitleIfNull` **只填 NULL**
7
- * (每次提交按列读一次:列是 NULL 才起名,见 `session-titler.ts`)。所以清与填是同一列同一律:用户清掉之后,下一次提交由自动标题器
8
- * 照常填;用户写过串的会话,自动标题器永不覆盖(无条件写盖得掉自动标题,NULL 守卫盖不掉用户标题)。没有第二列(不另设 `userTitle` /
9
- * `label`)。清的拼法只有 `null` 一种 —— 空串 `""` 是坏体(`request.body_shape`),不是「清」。
10
- * · `pinned` 是一列布尔,缺省 `false`;列表行**恒在场**(置顶是会话的状态,不是能力)。
11
- *
12
- * ## 上界 = 列宽
13
- * {@link SESSION_TITLE_MAX_CHARS} 是 `title` 列的宽度,两方言 DDL 内插的就是这一个数(`tidb-pool.ts` / `pg-session-storage.ts`),
14
- * wire 上界与存储上界是同一个事实。按**字符**计(Unicode 码点 —— 与 MySQL 协议 utf8mb4 / PostgreSQL 的 `VARCHAR(n)` 同一单位),
15
- * 不按 UTF-16 位计。自动标题器自己的显示预算(`session-titler.ts` 的 `TITLE_MAX_CHARS`)更短,落在这个上界之内。
16
- */
17
1
  /** `title` 列的宽度(字符)= 用户标题的上界。两方言 DDL 内插它。 */
18
2
  export declare const SESSION_TITLE_MAX_CHARS = 120;
19
3
  /** 会话行的可写位(体闭集;两键至少一键)。会话店唯一写口 `patchSessionMeta` 的形参。`title: null` = 清回自动标题(列写 NULL)。 */
@@ -28,7 +12,9 @@ export interface SessionRowProblem {
28
12
  }
29
13
  /**
30
14
  * `title` 一格的**唯一**读者(PATCH 体与 2c 导入同读)。`null` ⇒ 清回自动标题;串 ⇒ 1..{@link SESSION_TITLE_MAX_CHARS} 个字符、首尾无空白、
31
- * 不含 C0 控制字符({@link C0_CONTROL}),存原文(不脱敏、不改写);空串 ⇒ `request.body_shape`(清的拼法只有 `null`);其余 ⇒ `request.field_invalid`。
15
+ * 不含 C0 控制字符({@link C0_CONTROL})、至少有一个可见字符(经 core 的 `normalizePeerName` 不为空 —— NFKC → 去控制 / 格式码点 → trim;
16
+ * 与跨会话对端目录判「这一行有没有可用名」是**同一只**判据,`peer-directory.ts`),存原文(不脱敏、不改写);空串 ⇒ `request.body_shape`(清的拼法只有 `null`);其余 ⇒ `request.field_invalid`。
17
+ * 三道串判的先后固定:边空白 → C0 → 无可见字符(带 C0 的串先报 C0)。
32
18
  */
33
19
  export declare function readSessionTitle(v: unknown): {
34
20
  readonly title: string | null;
@@ -1,7 +1,9 @@
1
+ import { normalizePeerName } from "@sema-agent/core";
1
2
  export const SESSION_TITLE_MAX_CHARS = 120;
2
3
  const SESSION_ROW_PATCH_KEYS = { title: true, pinned: true };
3
4
  const BODY_SHAPE_MESSAGE = "the body must be a JSON object carrying at least one of `title` and `pinned`, and nothing else";
4
5
  const EMPTY_TITLE_MESSAGE = "title must not be the empty string — send `null` to clear it back to the automatic title";
6
+ const INVISIBLE_TITLE_MESSAGE = "title must contain at least one visible character";
5
7
  const C0_CONTROL = /[\u0000-\u001f]/u;
6
8
  export function readSessionTitle(v) {
7
9
  if (v === null)
@@ -16,6 +18,8 @@ export function readSessionTitle(v) {
16
18
  return { problem: { code: "request.field_invalid", message: "title must not start or end with whitespace" } };
17
19
  if (C0_CONTROL.test(v))
18
20
  return { problem: { code: "request.field_invalid", message: "title must not contain control characters (U+0000 to U+001F)" } };
21
+ if (normalizePeerName(v) === "")
22
+ return { problem: { code: "request.field_invalid", message: INVISIBLE_TITLE_MESSAGE } };
19
23
  return { title: v };
20
24
  }
21
25
  export function readSessionPinned(v) {
@@ -23,7 +23,7 @@ import type { SessionFace } from "./session-incarnation.js";
23
23
  *
24
24
  * Invariants the implementations uphold:
25
25
  * - The staging rows live under `stagingId = ${realSessionId}#stg-${token}` (the `#` is illegal in a real uuidv7, so
26
- * it can NEVER collide with a real session id) and have NO `session_meta` row → they are INVISIBLE to wake / ownerOf
26
+ * it can NEVER collide with a real session id) and have NO `session_meta` row → they are INVISIBLE to wake / the head read (`headOf`)
27
27
  * / listSessions (the existing orphan invariant) until `commit`'s transaction COMMITs the real session_meta row together
28
28
  * with the swap (the sole commit point; a fresh push claims that row first inside the same txn, invisible to everyone else
29
29
  * until COMMIT). A crash before commit leaves only collectable orphan staging rows, never a half-session.
@@ -59,8 +59,8 @@ export interface StagingHandle {
59
59
  abort(): Promise<void>;
60
60
  }
61
61
  /**
62
- * What a staged commit is conditioned on (S-1938 — one gate predicate, two phases). `expectedOwner` = the owner cell the import's gate
63
- * judged when it opened the staging, in the `ownerOf` reading: `undefined` = no such session (a fresh push), `null` = ownerless, a string =
62
+ * What a staged commit is conditioned on ([ref] — one gate predicate, two phases). `expectedOwner` = the owner cell the import's gate
63
+ * judged when it opened the staging, in the head-read reading (`headOf(id)?.owner`): `undefined` = no such session (a fresh push), `null` = ownerless, a string =
64
64
  * that owner. The route judges `mayTouch` on that cell at Phase A and again on the session's current cell right before Phase B commits; the
65
65
  * commit itself lands only on that same cell — each store compares it inside the commit txn (local: inside the session's write lock) and, when
66
66
  * the cell differs, rolls back and throws {@link StagedCommitOwnerChangedError} without writing a byte. The compare is on the owner cell, not
@@ -80,7 +80,7 @@ export interface StagedCommitOptions {
80
80
  export declare class StagedCommitOwnerChangedError extends SessionError {
81
81
  constructor(sessionId: string);
82
82
  }
83
- /** The owner-cell comparison of {@link StagedCommitOptions.expectedOwner} against a store's own `ownerOf`-shaped read (`undefined` = no row). */
83
+ /** The owner-cell comparison of {@link StagedCommitOptions.expectedOwner} against a store's own owner read (`headOf(id)?.owner`; `undefined` = no row). */
84
84
  export declare function ownerCellIs(expectedOwner: string | null | undefined, actual: string | null | undefined): boolean;
85
85
  /** A session store that can stage a streamed import (P1d-β). The 3 backends implement it; the in-memory dev store
86
86
  * does not → the method is optional (the route 501s when absent, parity with the other §0.5 optional seams). */
@@ -45,12 +45,43 @@
45
45
  */
46
46
  import type { StoreBackend } from "./plugins/store-backend.js";
47
47
  import { type SyncRelation } from "./session-sync-kernel.js";
48
- import { type SessionTreeEntry, type SessionRulesRecord, type FileHistoryExport, type FileHistoryResult, type SessionPermissionRules, type StoredSessionRules, type SessionPolicyStore } from "@sema-agent/core";
48
+ import { type SessionTreeEntry, type SessionRulesRecord, type FileHistoryError, type FileHistoryExport, type FileHistoryResult, type SessionPermissionRules, type StoredSessionRules, type SessionPolicyStore } from "@sema-agent/core";
49
49
  import type { ServiceFileHistoryStore, ServiceSessionPolicyStore, ResumeAnchorStore } from "./plugins/store-backend.js";
50
+ /**
51
+ * core 7.55.0 [ref] T2([ref]):一只会话的文件历史**读不全**(撕裂 / 读不出的边界、读不出的跟踪集 —— 店的 `exportHistory` 答 `{ ok: false }`,`adopt_failed`
52
+ * 带店判的 `permanence`)。它**不是**「没有历史」:读成 `null` 的同步会把这只会话的全部 rewind 历史丢在路上、还答成功。会话同步的两只拉取口
53
+ * (manifest、history blob)对它答同一句 503 `state.file_history_unreadable`(路由 `sendPullUnreadable`;连接类故障在拉取口同码同体键答 `permanence: "transient"`)。
54
+ */
55
+ export declare class FileHistoryUnreadableError extends Error {
56
+ readonly sessionId: string;
57
+ readonly failure: FileHistoryError;
58
+ readonly code = "state.file_history_unreadable";
59
+ constructor(sessionId: string, failure: FileHistoryError);
60
+ }
61
+ /**
62
+ * 一只会话的文件历史导出 —— `exportHistory` 三臂的**唯一读法**(会话同步两只拉取口都经它):`{ ok: true, history }` ⇒ 信封;`{ ok: true, history: null }`
63
+ * ⇒ `null`(没有可导出的,null 的唯一意思);`{ ok: false }` ⇒ 抛 {@link FileHistoryUnreadableError}(读不全不是没有)。店不带 `exportHistory` ⇒ 不是 2c 历史源 ⇒ `null`。
64
+ */
65
+ export declare function exportedFileHistory(store: Pick<ServiceFileHistoryStore, "exportHistory">, sessionId: string): Promise<FileHistoryExport | null>;
50
66
  /** A blob getter: content-addressed bytes for a sha256 hash, or `undefined` if the source can't supply them.
51
67
  * Returned by {@link exportSessionManifest} (closes over the source store); consumed wherever a caller pulls
52
68
  * content-addressed history bytes lazily (the live PUSH route's `importHistory` replay). */
53
69
  export type BlobGetter = (hash: string) => Promise<Uint8Array | undefined>;
70
+ /** blob 两面(`putBlob` / `getBlob`)齐备的文件历史店(marker 门,不做名字探测:local 的引擎文件店带同名私有助手)。 */
71
+ export type SyncBlobHistoryStore = ServiceFileHistoryStore & {
72
+ readonly syncBlobFaces: true;
73
+ } & {
74
+ [P in "putBlob" | "getBlob"]-?: NonNullable<ServiceFileHistoryStore[P]>;
75
+ };
76
+ /**
77
+ * 「这只文件历史店有没有 blob 两面」的**唯一**读法:marker `syncBlobFaces`(只有 SQL 两只店立它)∧ 两面在场。能力事实 `sessionSyncFileHistory`(capability-facts)
78
+ * 与取值口 {@link blobGetterOf} 都读它 —— 事实说有,取值口就通到事实店的 `getBlob`;事实说没有,取值口恒空。
79
+ * 名字探测(`store.getBlob?.…`)不可靠:core 的 local 文件店带与服务面同名的**私有**助手(同形 `putBlob` 已被 marker 挡过一次),名字探会错拿到它。
80
+ */
81
+ export declare function syncBlobFacesOf(store: ServiceFileHistoryStore): SyncBlobHistoryStore | undefined;
82
+ /** 一只文件历史店自己的 blob 取值口({@link BlobGetter}):从 {@link syncBlobFacesOf} 派生 —— 有 blob 两面 ⇒ 绑在店上的 `getBlob`;没有(core 的 local 文件店)⇒ 恒答 `undefined`(「这里取不到」)。
83
+ * 拉取面(manifest 的 `getBlob`)、identical 自愈臂、提交臂三处读同一只,不各写一份「无面则 undefined」。 */
84
+ export declare function blobGetterOf(store: ServiceFileHistoryStore): BlobGetter;
54
85
  /** The history-import capability face of a `FileHistoryStore` (`importHistory` is OPTIONAL on the core
55
86
  * contract — a store without it cannot be a 2c history sink). */
56
87
  export interface FileHistoryImportFace {
@@ -61,6 +92,21 @@ export interface FileHistoryImportFace {
61
92
  * `undefined` when absent. Callers gate on the RETURN VALUE, not a separate `typeof` check, so there is
62
93
  * exactly one place that knows the shape of the probe. */
63
94
  export declare function fileHistoryImportFace(fs: unknown): FileHistoryImportFace | undefined;
95
+ /**
96
+ * {@link replayFileHistory} 的结果 = 店的 {@link FileHistoryResult};失败臂可再带 `missingBlob` —— 这一次尝试里**重放自己交给店的 getter 亲口答过 `undefined`** 的那枚 hash
97
+ * (「这枚 blob 不在」是 getter 观察到的事实,不是从店码里猜的:同一个 `adopt_failed` 也可能是取值抛了 / 发布步撞上库的故障,那两形 `missingBlob` 缺席)。
98
+ * 下发口({@link sendFileHistoryReplayFailure} 在路由里)据它铸 wire `missing_blob`,否则原样送店的码。
99
+ */
100
+ export type FileHistoryReplayResult = {
101
+ readonly ok: true;
102
+ } | {
103
+ readonly ok: false;
104
+ readonly error: FileHistoryError;
105
+ readonly missingBlob?: string;
106
+ };
107
+ export type FileHistoryReplayFailure = Extract<FileHistoryReplayResult, {
108
+ ok: false;
109
+ }>;
64
110
  /**
65
111
  * The 2c PUSH replay of a session's file-history graph — keep-SOURCE convergence over core's
66
112
  * non-destructive-target law. `importHistory` refuses a target that already holds a DIFFERENT graph
@@ -75,10 +121,14 @@ export declare function fileHistoryImportFace(fs: unknown): FileHistoryImportFac
75
121
  * is left EMPTY — worse than the moment before this call, but strictly self-healing: the client re-PUTs
76
122
  * the blob and re-POSTs, and the retry lands on an empty target (importHistory's first-import arm).
77
123
  * The alternative (keeping the old graph) would wedge every retry on the same typed conflict forever.
124
+ *
125
+ * 缺 blob 的事实只在这里读一次:每次尝试给店的 getter 都包一层观察,店取到 `undefined` 就记下那枚 hash(按次计,替换臂的第二次尝试从空白起),
126
+ * 失败时随结果交出({@link FileHistoryReplayResult.missingBlob})。预检({@link sessionSyncFileHistory} 事实 + `hasBlobs`)管「这台部署根本收不到 / 索引里没有」,
127
+ * 这里管「预检过了而这一枚取不到」(对象存储里已丢 / 校验和不符按缺席读 / 预检与重放之间被孤儿回收清走)—— 同一只不变量的两端,wire 上同一个词。
78
128
  */
79
129
  export declare function replayFileHistory(store: ServiceFileHistoryStore, scope: string, envelope: FileHistoryExport, srcGetBlob: BlobGetter, opts: {
80
130
  allowReplace: boolean;
81
- }): Promise<FileHistoryResult>;
131
+ }): Promise<FileHistoryReplayResult>;
82
132
  /**
83
133
  * The portable state of ONE session, ready to replay into another backend. Blobs are deliberately NOT inlined
84
134
  * (§5: a turn's working-tree blobs can be tens of MiB → OOM/413 if buffered); each snapshot carries only its
@@ -147,7 +197,7 @@ export interface SessionManifest {
147
197
  * with the history store's own export verb.)
148
198
  */
149
199
  export declare function exportSessionManifest(sessionId: string, srcBackend: StoreBackend,
150
- /** S-589:文件历史读**装配结果**(捕获脸),不直取 `srcBackend.fileHistory()` —— 「这台部署有没有文件历史店」
200
+ /** [ref]:文件历史读**装配结果**(捕获脸),不直取 `srcBackend.fileHistory()` —— 「这台部署有没有文件历史店」
151
201
  * 只在 `assembleFileHistory` 判一次。同一个后端铸的同一只店,四店同源的不变式不变。 */
152
202
  historyStore: ServiceFileHistoryStore): Promise<{
153
203
  manifest: SessionManifest;
@@ -165,14 +215,19 @@ export declare function planSync(sessionId: string, srcBackend: StoreBackend, ds
165
215
  * 无条件写都 rev+1,而 rev 是 operator 乐观锁的 CAS 令牌(`PutRulesOptions.expectedRev`),
166
216
  * 幂等重试/无害重复同步不该把在途 CAS 打失败。归一化用 core 的 `normalizeRules`(store 落盘
167
217
  * 前走同一函数 ⇒ 两侧同坐标);它略过店的戳 `rev` / `gen`(`listBySession` 的 rules 含 rev,
168
- * 它不是内容;core 7.51.0 #1474 起 `normalizeRules` 自己略过,修前的 `stripRev` 包裹随之退役)。
218
+ * 它不是内容;core 7.51.0 [ref] 起 `normalizeRules` 自己略过,修前的 `stripRev` 包裹随之退役)。
169
219
  * 两侧过的是同一只形读法(core 7.51.0 `readSessionRulesShape`):`incoming` 由写口读者(引擎的写口判官)交出,`stored` 由店的读回交出 ——
170
220
  * 店读回读不出形的行答 `corrupt`、根本到不了这里,所以 `normalizeRules` 对两侧都不抛(修前本仓的读回比引擎宽,另有一只判官先挡一次)。
171
221
  * 🔴 字节同 ≠ 意思同(core 7.51.2 行自带文法戳;codex r1 [high] 验真):`normalizeRules` 把店的戳 `rev` / `gen` / `grammar` 都略过,而同一串桶字节在两种文法里是两句话 ——
172
222
  * 目的行无戳(文法 0:`toolAllow` 里的 `Bash(rm:*)` 什么都不放行)、导入记录带 `grammar: 1`(放行 rm),只比字节会判「同内容」、零次 putRules、同步答 200 而目的行仍是旧意思。
173
223
  * 所以字节同之外还问引擎的收紧比对 `loosenReasons` **双向**(两侧各在自己的文法里读:`stored` 带 `rev`,`incoming` 带 `grammar`):两个方向都「没放宽」才是同一句话;
174
- * 意思不同就交给 `putRules` 的判官(非 operator ⇒ `loosen_forbidden`;operator ⇒ 改写成当前文法、盖戳)。本仓仍零处读 / 比戳值;意思由引擎说。 */
175
- export declare function sameRulesContent(stored: StoredSessionRules | null, incoming: SessionPermissionRules): boolean;
224
+ * 意思不同就交给 `putRules` 的判官(非 operator ⇒ `loosen_forbidden`;operator ⇒ 改写成当前文法、盖戳)。本仓仍零处读 / 比戳值;意思由引擎说。
225
+ * 🔴 core 7.55.0 [ref]:行还有一格 **operator 部分**(`StoredSessionRules.operatorRules`:非 operator 的写只能收回非 operator 写加上去的东西;缺席 = 整行归 operator)。
226
+ * 桶同、意思同,这一次写仍可能挪动它 —— operator 重放把整行变成 operator 的(引擎写口判官的答:operator 写的值整只归 operator)。只比桶会判「同内容」⇒ 零次 putRules ⇒
227
+ * 属主盖过戳的目的行保持「属主收得回」,源端 operator 断言过的条目在目的端被属主一条非 operator 的写收回(安全轴的静默放宽)。所以第三问:这一次写之后的部分
228
+ * = 引擎写口判官对(目的行, 记录, 这次重放的态度)的答,与目的行现有的部分按同一读法(缺席 = 整行)比;不同就交给 `putRules`。判官拒 ⇒ 原样上抛(`putRules` 会拒同一句)。
229
+ * `operator` 必填:同一份记录在 operator 与非 operator 的重放下是两种写(漏传是编译错,不是一条静默的读法)。 */
230
+ export declare function sameRulesContent(stored: StoredSessionRules | null, incoming: SessionPermissionRules, operator: boolean): boolean;
176
231
  /** [ref] ① 的重放腿共享实现:PUSH 路由的两条 policy 重放腿(Phase A identical 短路支 / Phase B
177
232
  * commit 后支)都从这里走 —— 等内容跳过(rev 零漂移),真变更照常落地(E6 tighten-only 门在
178
233
  * putRules 内部,此处不重述)。 */