@sema-agent/server 7.136.0 → 7.138.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 (327) hide show
  1. package/MIGRATION.md +501 -139
  2. package/README.md +1 -0
  3. package/README.zh-CN.md +1 -0
  4. package/USAGE.md +149 -34
  5. package/deploy/sema-up/README.md +14 -0
  6. package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +7 -1
  7. package/deploy/sema-up/stack/sema-stack-cluster.yaml +7 -1
  8. package/dist/approval-card.d.ts +21 -14
  9. package/dist/approval-card.js +1 -0
  10. package/dist/approval-content-kind.d.ts +6 -0
  11. package/dist/approval-content-kind.js +7 -0
  12. package/dist/approval-gate-currency.d.ts +48 -6
  13. package/dist/approval-gate-currency.js +16 -9
  14. package/dist/approval-hmac.d.ts +13 -1
  15. package/dist/approval-hmac.js +1 -1
  16. package/dist/approval.js +3 -3
  17. package/dist/audit.js +1 -0
  18. package/dist/auth-bridge.js +2 -2
  19. package/dist/background-agent-name.d.ts +5 -0
  20. package/dist/background-agent-name.js +5 -0
  21. package/dist/boot/budget-tracing.d.ts +1 -12
  22. package/dist/boot/deployment-mods.d.ts +46 -16
  23. package/dist/boot/deployment-mods.js +82 -6
  24. package/dist/boot/execution-env.d.ts +24 -1
  25. package/dist/boot/execution-env.js +69 -6
  26. package/dist/boot/governance-seams.d.ts +10 -17
  27. package/dist/boot/governance-seams.js +5 -17
  28. package/dist/boot/leader.d.ts +3 -0
  29. package/dist/boot/leader.js +1 -0
  30. package/dist/boot/org-delivery.js +15 -2
  31. package/dist/boot/reapers.d.ts +3 -0
  32. package/dist/boot/reapers.js +15 -1
  33. package/dist/boot/resolve-spec.d.ts +7 -0
  34. package/dist/boot/resolve-spec.js +36 -26
  35. package/dist/boot/retention-lane.d.ts +11 -5
  36. package/dist/boot/retention-lane.js +2 -2
  37. package/dist/boot/runner-deps.d.ts +7 -3
  38. package/dist/boot/runner-deps.js +1 -0
  39. package/dist/boot/stage-03-store-backend.d.ts +1 -1
  40. package/dist/boot/stage-04-stores.d.ts +2 -13
  41. package/dist/boot/stage-05-execution-env.d.ts +6 -13
  42. package/dist/boot/stage-05-execution-env.js +17 -5
  43. package/dist/boot/stage-06-runners.d.ts +6 -13
  44. package/dist/boot/stage-06-runners.js +10 -3
  45. package/dist/boot/stage-07-capability-layer.d.ts +7 -13
  46. package/dist/boot/stage-07-capability-layer.js +3 -3
  47. package/dist/boot/stage-08-reapers.d.ts +7 -13
  48. package/dist/boot/stage-08-reapers.js +2 -1
  49. package/dist/boot/stage-09-leader.d.ts +7 -13
  50. package/dist/boot/stage-09-leader.js +2 -2
  51. package/dist/boot/stage-10-http-server.d.ts +7 -13
  52. package/dist/boot/stage-10-http-server.js +6 -3
  53. package/dist/boot/stores.d.ts +1 -1
  54. package/dist/boot/web-admin.d.ts +5 -2
  55. package/dist/boot/web-admin.js +3 -3
  56. package/dist/brain.js +5 -5
  57. package/dist/broker/broker.d.ts +89 -0
  58. package/dist/broker/broker.js +287 -0
  59. package/dist/broker/constants.d.ts +39 -0
  60. package/dist/broker/constants.js +15 -0
  61. package/dist/broker/http1.d.ts +111 -0
  62. package/dist/broker/http1.js +256 -0
  63. package/dist/broker/lease-book.d.ts +87 -0
  64. package/dist/broker/lease-book.js +142 -0
  65. package/dist/broker/lease-file.d.ts +60 -0
  66. package/dist/broker/lease-file.js +127 -0
  67. package/dist/broker/main.d.ts +2 -0
  68. package/dist/broker/main.js +20 -0
  69. package/dist/budget.d.ts +17 -15
  70. package/dist/budget.js +2 -2
  71. package/dist/capabilities/composite-members.d.ts +2 -1
  72. package/dist/capabilities/composite-members.js +2 -1
  73. package/dist/capabilities/engine-capabilities.js +1 -0
  74. package/dist/capabilities/mcp-probe.d.ts +36 -11
  75. package/dist/capabilities/mcp-probe.js +44 -5
  76. package/dist/capabilities/scenarios.d.ts +23 -8
  77. package/dist/capabilities/scenarios.js +13 -8
  78. package/dist/capabilities/skills.d.ts +28 -5
  79. package/dist/capabilities/skills.js +8 -0
  80. package/dist/capability-facts.d.ts +6 -0
  81. package/dist/capability-facts.js +5 -0
  82. package/dist/center-credential-renewer.js +5 -1
  83. package/dist/checkpoint-ctx-seal-m28.d.ts +3 -10
  84. package/dist/checkpoint-ctx-seal-m28.js +1 -1
  85. package/dist/checkpoint-identity.d.ts +13 -6
  86. package/dist/config-catalog.js +16 -7
  87. package/dist/config-types.d.ts +24 -7
  88. package/dist/config.d.ts +1 -1
  89. package/dist/config.js +42 -13
  90. package/dist/deployment-governance.d.ts +2 -2
  91. package/dist/deployment-governance.js +7 -9
  92. package/dist/deployment-shape.d.ts +6 -6
  93. package/dist/device-ws-protocol.d.ts +1 -0
  94. package/dist/device-ws-protocol.js +2 -1
  95. package/dist/file-history-disclosure.d.ts +4 -2
  96. package/dist/file-history-disclosure.js +2 -0
  97. package/dist/gate-settlement.d.ts +71 -0
  98. package/dist/gate-settlement.js +40 -0
  99. package/dist/hooks/classic-stations.d.ts +12 -54
  100. package/dist/hooks/classic-stations.js +1 -0
  101. package/dist/hooks/command-spawn.d.ts +2 -2
  102. package/dist/hooks/hook-runner.js +14 -14
  103. package/dist/http/admission.js +14 -9
  104. package/dist/http/approval-sweeps.js +4 -3
  105. package/dist/http/caller-trust.d.ts +2 -1
  106. package/dist/http/caller-trust.js +1 -3
  107. package/dist/http/checkpoint-ctx.d.ts +48 -7
  108. package/dist/http/checkpoint-ctx.js +40 -0
  109. package/dist/http/dispatch.d.ts +4 -0
  110. package/dist/http/dispatch.js +18 -10
  111. package/dist/http/durable-run-leg.d.ts +5 -1
  112. package/dist/http/durable-run-leg.js +5 -3
  113. package/dist/http/health-self-report.d.ts +2 -2
  114. package/dist/http/memory-compliance-failure-reply.js +3 -0
  115. package/dist/http/principal-gate.d.ts +15 -10
  116. package/dist/http/principal-gate.js +48 -9
  117. package/dist/http/resume-legs.d.ts +7 -31
  118. package/dist/http/resume-legs.js +185 -126
  119. package/dist/http/route-ctx.d.ts +38 -53
  120. package/dist/http/route-ctx.js +2 -5
  121. package/dist/http/routes/a2a-serve.js +10 -4
  122. package/dist/http/routes/agents-roster.d.ts +1 -1
  123. package/dist/http/routes/agents-roster.js +5 -1
  124. package/dist/http/routes/approvals-assistant.js +24 -10
  125. package/dist/http/routes/capabilities.js +23 -11
  126. package/dist/http/routes/mcp-reconnect.d.ts +3 -2
  127. package/dist/http/routes/mcp-reconnect.js +7 -7
  128. package/dist/http/routes/memory-consolidation.d.ts +1 -1
  129. package/dist/http/routes/memory-origin.d.ts +1 -1
  130. package/dist/http/routes/rules.js +3 -3
  131. package/dist/http/routes/runs.js +13 -8
  132. package/dist/http/routes/session-sync.js +42 -6
  133. package/dist/http/routes/sessions.js +6 -3
  134. package/dist/http/routes/side-query.js +2 -3
  135. package/dist/http/routes/tasks.js +794 -780
  136. package/dist/http/server.d.ts +35 -25
  137. package/dist/http/stored-body-replay.d.ts +3 -3
  138. package/dist/http/stored-body-replay.js +6 -1
  139. package/dist/http/wire-types.d.ts +66 -33
  140. package/dist/identity-source.d.ts +65 -0
  141. package/dist/identity-source.js +45 -0
  142. package/dist/index.d.ts +2 -0
  143. package/dist/index.js +1 -0
  144. package/dist/leader/wire.d.ts +7 -0
  145. package/dist/leader/wire.js +5 -4
  146. package/dist/mcp-assertion-header.d.ts +51 -40
  147. package/dist/mcp-assertion-header.js +10 -11
  148. package/dist/mcp-authorization-face.d.ts +27 -0
  149. package/dist/mcp-authorization-face.js +15 -0
  150. package/dist/memory-operator-faces.d.ts +13 -4
  151. package/dist/memory-operator-faces.js +1 -17
  152. package/dist/memory-store-refusal.d.ts +3 -3
  153. package/dist/memory-sync-client.js +72 -57
  154. package/dist/memory-sync.d.ts +1 -1
  155. package/dist/model-entry-refusal.d.ts +2 -0
  156. package/dist/model-entry-refusal.js +11 -0
  157. package/dist/model-route-gap.d.ts +6 -22
  158. package/dist/model-route-gap.js +7 -5
  159. package/dist/model-select.d.ts +6 -17
  160. package/dist/model-select.js +0 -3
  161. package/dist/mods-declaration.d.ts +110 -0
  162. package/dist/mods-declaration.js +109 -0
  163. package/dist/namespaced-rule-name.d.ts +1 -1
  164. package/dist/observability/err-text.d.ts +5 -0
  165. package/dist/observability/err-text.js +9 -0
  166. package/dist/observability/fail-open.d.ts +17 -1
  167. package/dist/observability/fail-open.js +17 -1
  168. package/dist/observability/metrics.js +1 -1
  169. package/dist/observability/run-terminal.js +1 -0
  170. package/dist/observability/secret-env-scrub.d.ts +1 -1
  171. package/dist/observability/secret-env-scrub.js +1 -1
  172. package/dist/operator-ask.d.ts +2 -2
  173. package/dist/org-delivery-gate.js +1 -1
  174. package/dist/org-memory-admission.d.ts +2 -2
  175. package/dist/org-memory-admission.js +39 -2
  176. package/dist/parked-decide.d.ts +15 -2
  177. package/dist/parked-decide.js +17 -10
  178. package/dist/peer-directory.js +2 -0
  179. package/dist/peer-seat.d.ts +150 -0
  180. package/dist/peer-seat.js +239 -0
  181. package/dist/permission-rule-list.d.ts +2 -2
  182. package/dist/permission-rule-vocab.d.ts +7 -7
  183. package/dist/permission-rule-vocab.js +3 -3
  184. package/dist/plain-string-record.d.ts +38 -0
  185. package/dist/plain-string-record.js +38 -0
  186. package/dist/plugins/background-agent-store-sql.js +6 -3
  187. package/dist/plugins/caching-session-store.d.ts +5 -0
  188. package/dist/plugins/caching-session-store.js +6 -0
  189. package/dist/plugins/checkpoint-store-sql.d.ts +34 -29
  190. package/dist/plugins/checkpoint-store-sql.js +14 -14
  191. package/dist/plugins/file-history-store-sql.js +10 -16
  192. package/dist/plugins/file-run-store.js +8 -2
  193. package/dist/plugins/k8s-exec-protocol.d.ts +69 -13
  194. package/dist/plugins/k8s-exec-protocol.js +116 -28
  195. package/dist/plugins/k8s-pod-delete-failure.d.ts +25 -0
  196. package/dist/plugins/k8s-pod-delete-failure.js +17 -0
  197. package/dist/plugins/k8s-pod-reaper.d.ts +106 -0
  198. package/dist/plugins/k8s-pod-reaper.js +122 -0
  199. package/dist/plugins/local-checkpoint-store.d.ts +4 -17
  200. package/dist/plugins/local-checkpoint-store.js +3 -4
  201. package/dist/plugins/local-session-store.d.ts +66 -27
  202. package/dist/plugins/local-session-store.js +60 -28
  203. package/dist/plugins/mailbox-store-sql.d.ts +11 -3
  204. package/dist/plugins/mailbox-store-sql.js +103 -15
  205. package/dist/plugins/memory-run-store.js +2 -0
  206. package/dist/plugins/memory-sync-store-pg.d.ts +16 -5
  207. package/dist/plugins/memory-sync-store-tidb.d.ts +3 -3
  208. package/dist/plugins/one-time-migrations.d.ts +34 -12
  209. package/dist/plugins/one-time-migrations.js +51 -9
  210. package/dist/plugins/permission-rule-store-file.js +2 -2
  211. package/dist/plugins/permission-rule-store-sql.d.ts +17 -17
  212. package/dist/plugins/permission-rule-store-sql.js +37 -30
  213. package/dist/plugins/pg-pool.js +4 -0
  214. package/dist/plugins/pg-session-storage.d.ts +10 -2
  215. package/dist/plugins/pg-session-storage.js +20 -7
  216. package/dist/plugins/remote-env-adb.d.ts +6 -1
  217. package/dist/plugins/remote-env-adb.js +2 -1
  218. package/dist/plugins/remote-env-device.d.ts +6 -1
  219. package/dist/plugins/remote-env-device.js +5 -1
  220. package/dist/plugins/remote-env-e2b.d.ts +5 -0
  221. package/dist/plugins/remote-env-e2b.js +2 -1
  222. package/dist/plugins/remote-env-file-error.d.ts +8 -1
  223. package/dist/plugins/remote-env-file-error.js +7 -1
  224. package/dist/plugins/remote-env-host.d.ts +10 -2
  225. package/dist/plugins/remote-env-host.js +8 -2
  226. package/dist/plugins/remote-env-k8s.d.ts +140 -11
  227. package/dist/plugins/remote-env-k8s.js +277 -15
  228. package/dist/plugins/remote-env-local-docker.d.ts +5 -0
  229. package/dist/plugins/remote-env-local-docker.js +2 -1
  230. package/dist/plugins/remote-env-ssh.d.ts +6 -1
  231. package/dist/plugins/remote-env-ssh.js +2 -1
  232. package/dist/plugins/retention-store-sql.d.ts +14 -2
  233. package/dist/plugins/retention-store-sql.js +6 -0
  234. package/dist/plugins/run-store-sql.js +10 -4
  235. package/dist/plugins/session-fork.d.ts +10 -13
  236. package/dist/plugins/session-fork.js +5 -25
  237. package/dist/plugins/session-ownership.d.ts +24 -3
  238. package/dist/plugins/session-ownership.js +24 -5
  239. package/dist/plugins/session-workspace-cell.d.ts +17 -0
  240. package/dist/plugins/session-workspace-cell.js +38 -0
  241. package/dist/plugins/sql-errors.d.ts +23 -2
  242. package/dist/plugins/sql-errors.js +15 -0
  243. package/dist/plugins/store-backend.js +7 -7
  244. package/dist/plugins/store-contracts.d.ts +10 -1
  245. package/dist/plugins/store-fault.d.ts +2 -2
  246. package/dist/plugins/store-fault.js +4 -2
  247. package/dist/plugins/tidb-pool.js +13 -0
  248. package/dist/plugins/tidb-session-store.d.ts +17 -2
  249. package/dist/plugins/tidb-session-store.js +18 -7
  250. package/dist/plugins/tool-result-store-sql.d.ts +13 -6
  251. package/dist/plugins/tool-result-store-sql.js +8 -7
  252. package/dist/plugins/worktree-isolation.d.ts +3 -2
  253. package/dist/plugins/worktree-isolation.js +1 -7
  254. package/dist/project-identity.d.ts +1 -14
  255. package/dist/project-identity.js +0 -4
  256. package/dist/request-key-closure.js +1 -1
  257. package/dist/request-value-closure.d.ts +31 -2
  258. package/dist/request-value-closure.js +7 -1
  259. package/dist/rule-entry-list.d.ts +3 -2
  260. package/dist/rule-entry-list.js +2 -2
  261. package/dist/rules-consent.js +12 -7
  262. package/dist/run-local.d.ts +2 -2
  263. package/dist/run-local.js +12 -6
  264. package/dist/runs.d.ts +7 -1
  265. package/dist/runs.js +8 -2
  266. package/dist/runtime-governance.d.ts +5 -5
  267. package/dist/sandbox-git-lease.d.ts +49 -0
  268. package/dist/sandbox-git-lease.js +60 -0
  269. package/dist/sandbox-git-plane.d.ts +84 -0
  270. package/dist/sandbox-git-plane.js +105 -0
  271. package/dist/security.d.ts +16 -4
  272. package/dist/security.js +8 -3
  273. package/dist/server-secret-env.d.ts +12 -3
  274. package/dist/server-secret-env.js +18 -2
  275. package/dist/session-error-wire.d.ts +14 -6
  276. package/dist/session-error-wire.js +2 -1
  277. package/dist/session-incarnation.d.ts +4 -5
  278. package/dist/session-incarnation.js +2 -2
  279. package/dist/session-policy-wire.d.ts +1 -1
  280. package/dist/session-policy-wire.js +2 -2
  281. package/dist/session-sync.d.ts +1 -1
  282. package/dist/session-workspace.d.ts +130 -0
  283. package/dist/session-workspace.js +83 -0
  284. package/dist/spec-fields.d.ts +44 -14
  285. package/dist/spec-fields.js +33 -12
  286. package/dist/standing-answer-grant.d.ts +2 -13
  287. package/dist/standing-answer-grant.js +0 -7
  288. package/dist/stored-request-prompt-profile-m30.d.ts +49 -0
  289. package/dist/stored-request-prompt-profile-m30.js +25 -0
  290. package/dist/task-a2a.d.ts +44 -14
  291. package/dist/task-a2a.js +46 -20
  292. package/dist/task-mcp.d.ts +34 -21
  293. package/dist/task-mcp.js +46 -22
  294. package/dist/task-settings.d.ts +2 -2
  295. package/dist/tool-approval.d.ts +43 -9
  296. package/dist/tool-approval.js +57 -15
  297. package/dist/tool-rule-names.d.ts +5 -0
  298. package/dist/trace/core-keyset-guard.d.ts +34 -19
  299. package/dist/trace/engine-notice-wire.d.ts +1 -1
  300. package/dist/trace/engine-notice-wire.js +4 -0
  301. package/dist/trace/exit-seat.d.ts +20 -1
  302. package/dist/trace/exit-seat.js +5 -2
  303. package/dist/trace/extension-call-face.d.ts +33 -0
  304. package/dist/trace/extension-call-face.js +39 -0
  305. package/dist/trace/ledger-sink.d.ts +4 -5
  306. package/dist/trace/ledger-sink.js +3 -7
  307. package/dist/trace/project.d.ts +62 -10
  308. package/dist/trace/project.js +49 -9
  309. package/dist/trace/redact.d.ts +18 -6
  310. package/dist/trace/redact.js +154 -60
  311. package/dist/trace/self-minted-wire.d.ts +500 -7
  312. package/dist/trace/self-minted-wire.js +182 -1
  313. package/dist/trace/wire-projection-faces.d.ts +7 -5
  314. package/dist/trace/wire-projection-faces.js +9 -4
  315. package/dist/user-authored-text.d.ts +2 -2
  316. package/dist/user-authored-text.js +16 -1
  317. package/dist/web-admin-client/apply-effective.js +0 -1
  318. package/dist/web-admin-client/center-request.d.ts +23 -4
  319. package/dist/web-admin-client/center-request.js +42 -8
  320. package/dist/web-admin-client/http-client.js +6 -6
  321. package/dist/web-admin-client/skills-mcp.d.ts +8 -4
  322. package/dist/web-admin-client/skills-mcp.js +31 -18
  323. package/dist/web-admin-client/types.d.ts +10 -5
  324. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +11 -5
  325. package/package.json +3 -3
  326. package/wire-changes/server@7.137.0.json +825 -0
  327. package/wire-changes/server@7.138.0.json +446 -0
@@ -1,6 +1,7 @@
1
1
  import { type A2aServerSpec, type McpServerSpec, type SkillSpec } from "@sema-agent/core";
2
2
  import type { CenterMcp, ScopedA2aPeer } from "../config-types.js";
3
3
  import type { Logger } from "../observability/logger.js";
4
+ import { type PeerDesk, type PeerLease } from "../peer-seat.js";
4
5
  import type { LoadedSkill } from "../capabilities/skills.js";
5
6
  import type { ConfigProvider } from "../config-provider.js";
6
7
  import type { CenterA2aPeer, CenterMcpServer, CenterSkillManifest } from "./types.js";
@@ -53,14 +54,16 @@ export declare function applySkillsManifest(baseline: LoadedSkill[], manifest: {
53
54
  }, bodies: SkillBodySource, logger?: Logger): Promise<LoadedSkill[]>;
54
55
  /**
55
56
  * Resolve center MCP servers (`/effective.mcp`) into core `McpServerSpec`s + the scenarios each applies to.
56
- * env-NAME refs → real values from THIS service's env (secret boundary unchanged); a server with any missing
57
+ * env-NAME refs → real values from THIS service's env (secret boundary unchanged), registered on `desk` under `rosterLease`
58
+ * (the desk's one minting point `mintDeclaration`, called only for an entry that mounts — after every judge below has passed, so a skipped
59
+ * entry never holds a registration): the spec carries the minted reference, never the values. A server with any missing
57
60
  * ref is skipped (`resolveRefs` → null). `enabled:false` skipped. A server whose `toolFaces` / `toolAxes` declaration is
58
61
  * malformed is skipped whole (both are trust-root declarations — the engine's `readToolFaces` / `readMcpToolAxes` judge them). Restart-to-apply
59
62
  * (filtered per scenario in `resolveSpec` via `mcpForScenario`).
60
63
  */
61
64
  export declare function resolveMcpServers(mcp: {
62
65
  servers: CenterMcpServer[];
63
- }, logger?: Logger): CenterMcp;
66
+ }, desk: Pick<PeerDesk, "declare">, rosterLease: PeerLease, logger?: Logger): CenterMcp;
64
67
  /** The MCP servers applicable to a scenario: tagged with it, or untagged (global). undefined when none.
65
68
  * [ref]:alias 窗撤销,单键命中(同 `skillsForScenario`)。 */
66
69
  export declare function mcpForScenario(center: CenterMcp | undefined, scenario: string): McpServerSpec[] | undefined;
@@ -68,7 +71,8 @@ export declare function mcpForScenario(center: CenterMcp | undefined, scenario:
68
71
  * DESIGN-269 §2.1 —— resolve center A2A peers (`/effective.a2a`) into core `A2aServerSpec`s + the scenarios
69
72
  * each applies to. Exact sibling of {@link resolveMcpServers}, same three rules:
70
73
  * · header-NAME refs → real values from THIS service's env (the secret boundary is unchanged — the center
71
- * never holds the bearer). A peer with ANY missing ref is SKIPPED wholesale (`resolveRefs` → null):
74
+ * never holds the bearer), registered on `desk` under `rosterLease` (`mintDeclaration`, only for a peer that mounts); the spec carries the minted
75
+ * reference, never the values. A peer with ANY missing ref is SKIPPED wholesale (`resolveRefs` → null):
72
76
  * dialing a remote AGENT with half the credentials is the wrong failure direction.
73
77
  * · `enabled:false` skipped.
74
78
  * · restart-to-apply (filtered per scenario in `resolveSpec` via {@link a2aForScenario}).
@@ -83,7 +87,7 @@ export declare function mcpForScenario(center: CenterMcp | undefined, scenario:
83
87
  */
84
88
  export declare function resolveA2aPeers(a2a: {
85
89
  peers: CenterA2aPeer[];
86
- }, logger?: Logger): ScopedA2aPeer[];
90
+ }, desk: Pick<PeerDesk, "declare">, rosterLease: PeerLease, logger?: Logger): ScopedA2aPeer[];
87
91
  /** The A2A peers applicable to a scenario: tagged with it, or untagged (global). undefined when none.
88
92
  * Twin of {@link mcpForScenario} — `undefined` (not `[]`) is load-bearing: an empty array would put an
89
93
  * `a2a: []` key on the spec, i.e. "this deployment declares an empty peer set", where absence means
@@ -1,8 +1,9 @@
1
1
  import { readMcpSourceLabel } from "../mcp-source-label.js";
2
2
  import { skillContentHash } from "@sema-agent/settings-schema";
3
- import { readMcpToolAxes, readToolFaces } from "@sema-agent/core";
3
+ import { judgeSessionMetaKey, readMcpToolAxes, readToolFaces } from "@sema-agent/core";
4
4
  import { MCP_CONTENT_ORIGINS, describeBadContentOrigin, describeBadWireName, isContentOriginWord, isUsableWireName } from "@sema-agent/settings-schema";
5
- import { noteMcpAssertionHeaderNotSent, sentMcpAssertionHeaderMember, withholdsMcpAssertionHeader } from "../mcp-assertion-header.js";
5
+ import { noteMcpAssertionHeaderNotSent, withholdsMcpAssertionHeader } from "../mcp-assertion-header.js";
6
+ import { mintDeclaration, peerSentence } from "../peer-seat.js";
6
7
  import { SHA256_HEX_RE } from "../digest-form.js";
7
8
  export function skillToolListsOf(source) {
8
9
  return {
@@ -115,7 +116,7 @@ function resolveRefs(refs, server, kind, logger, event = "web_admin_mcp_env_miss
115
116
  }
116
117
  return out;
117
118
  }
118
- export function resolveMcpServers(mcp, logger) {
119
+ export function resolveMcpServers(mcp, desk, rosterLease, logger) {
119
120
  const out = [];
120
121
  const reservedNames = (mcp.servers ?? []).map((s) => s.name);
121
122
  for (const s of mcp.servers ?? []) {
@@ -147,7 +148,7 @@ export function resolveMcpServers(mcp, logger) {
147
148
  if (!facesRead.ok) {
148
149
  logger?.warn("web_admin_mcp_tool_faces_invalid", {
149
150
  server: s.name,
150
- problem: facesRead.problem,
151
+ problem: peerSentence(facesRead.problem),
151
152
  note: "server SKIPPED — a toolFaces overlay is a NARROWING declaration (its pathTarget is what the sensitive-path / write fences read); mounting the server without it would silently drop the protection you declared. Fix the entry and republish.",
152
153
  });
153
154
  continue;
@@ -157,20 +158,31 @@ export function resolveMcpServers(mcp, logger) {
157
158
  if (!axesRead.ok) {
158
159
  logger?.warn("web_admin_mcp_tool_axes_invalid", {
159
160
  server: s.name,
160
- problem: axesRead.problem,
161
+ problem: peerSentence(axesRead.problem),
161
162
  note: "server SKIPPED — a toolAxes declaration is a TRUST-ROOT declaration (it can lower an effect so a call skips the approval fence, or raise one); mounting the server without it, or with a half of it, would silently change what you declared. Fix the entry and republish.",
162
163
  });
163
164
  continue;
164
165
  }
165
166
  const toolAxes = axesRead.toolAxes === undefined ? {} : { toolAxes: axesRead.toolAxes };
167
+ const metaKey = judgeSessionMetaKey(s.sessionMetaKey);
168
+ if ("problem" in metaKey) {
169
+ logger?.warn("web_admin_mcp_session_meta_key_invalid", {
170
+ server: s.name,
171
+ problem: peerSentence(metaKey.problem),
172
+ note: "server SKIPPED — its sessionMetaKey cannot ride (the engine's judge refused it); mounting the server without the key would silently drop the session id it declared it needs. Fix the entry and republish.",
173
+ });
174
+ continue;
175
+ }
176
+ const sessionMetaKey = metaKey.key === undefined ? {} : { sessionMetaKey: metaKey.key };
166
177
  if (s.transport.kind === "stdio") {
167
178
  const env = resolveRefs(s.transport.envRefs, s.name, "env", logger);
168
179
  if (env === null)
169
180
  continue;
170
- out.push({
171
- scenarios: s.scenarios ?? [],
172
- spec: { name: s.name, transport: { kind: "stdio", command: s.transport.command, args: s.transport.args, ...(Object.keys(env).length ? { env } : {}) }, ...allow, ...elicit, ...contentOrigin, ...source, ...toolFaces, ...toolAxes },
173
- });
181
+ const draft = {
182
+ spec: { name: s.name, transport: { kind: "stdio", command: s.transport.command, args: s.transport.args }, ...allow, ...elicit, ...contentOrigin, ...source, ...toolFaces, ...toolAxes, ...sessionMetaKey },
183
+ pieces: env,
184
+ };
185
+ out.push({ scenarios: s.scenarios ?? [], spec: mintDeclaration(desk, draft, rosterLease) });
174
186
  }
175
187
  else {
176
188
  const headers = resolveRefs(s.transport.headerRefs, s.name, "header", logger);
@@ -178,10 +190,11 @@ export function resolveMcpServers(mcp, logger) {
178
190
  continue;
179
191
  if (withholdsMcpAssertionHeader(s.transport.assertionHeader))
180
192
  noteMcpAssertionHeaderNotSent(logger, s.name);
181
- out.push({
182
- scenarios: s.scenarios ?? [],
183
- spec: { name: s.name, transport: { kind: "http", url: s.transport.url, ...(Object.keys(headers).length ? { headers } : {}), ...(s.transport.principalHeader ? { principalHeader: s.transport.principalHeader } : {}), ...sentMcpAssertionHeaderMember(s.transport.assertionHeader) }, ...allow, ...elicit, ...contentOrigin, ...source, ...toolFaces, ...toolAxes },
184
- });
193
+ const draft = {
194
+ spec: { name: s.name, transport: { kind: "http", url: s.transport.url, ...(s.transport.principalHeader ? { principalHeader: s.transport.principalHeader } : {}) }, ...allow, ...elicit, ...contentOrigin, ...source, ...toolFaces, ...toolAxes, ...sessionMetaKey },
195
+ pieces: headers,
196
+ };
197
+ out.push({ scenarios: s.scenarios ?? [], spec: mintDeclaration(desk, draft, rosterLease) });
185
198
  }
186
199
  }
187
200
  if (out.length > 0)
@@ -195,7 +208,7 @@ export function mcpForScenario(center, scenario) {
195
208
  const hit = servers.filter((s) => s.scenarios.length === 0 || s.scenarios.includes(scenario)).map((s) => s.spec);
196
209
  return hit.length > 0 ? hit : undefined;
197
210
  }
198
- export function resolveA2aPeers(a2a, logger) {
211
+ export function resolveA2aPeers(a2a, desk, rosterLease, logger) {
199
212
  const out = [];
200
213
  for (const p of a2a.peers ?? []) {
201
214
  if (p.enabled === false)
@@ -210,17 +223,17 @@ export function resolveA2aPeers(a2a, logger) {
210
223
  const headers = resolveRefs(p.headerRefs, p.name, "header", logger, "web_admin_a2a_env_missing", "skipping this A2A peer — referenced env var is unset in this service");
211
224
  if (headers === null)
212
225
  continue;
213
- out.push({
214
- scenarios: p.scenarios ?? [],
226
+ const draft = {
215
227
  spec: {
216
228
  name: p.name,
217
229
  url: p.url,
218
230
  ...(p.cardUrl ? { cardUrl: p.cardUrl } : {}),
219
- ...(Object.keys(headers).length ? { headers } : {}),
220
231
  ...(p.principalHeader ? { principalHeader: p.principalHeader } : {}),
221
232
  ...(p.allowSkills && p.allowSkills.length > 0 ? { allowSkills: p.allowSkills } : {}),
222
233
  },
223
- });
234
+ pieces: headers,
235
+ };
236
+ out.push({ scenarios: p.scenarios ?? [], spec: mintDeclaration(desk, draft, rosterLease) });
224
237
  }
225
238
  if (out.length > 0)
226
239
  logger?.info("web_admin_a2a", { peers: out.map((p) => p.spec.name) });
@@ -75,11 +75,11 @@ export interface CenterModel {
75
75
  * the ONLY way to keep per-model tuning that lived in env (`MODEL_FREQUENCY_PENALTY` etc.) — see the
76
76
  * review-gw heterogeneous-roster migration. MUST be static per published version (prompt-cache prefix). */
77
77
  extraBody?: Record<string, unknown>;
78
- /** registry-core 0.10.13 ([ref]/[ref]⑤c): per-model behavior-slot mitigation sentences, mirrors core
79
- * `Model.promptGuidance` (core 1.303+ assembles them into the volatile tail's per-model position).
80
- * Same category as `extraBody`: logical model metadata, carried verbatim — without this projection the
81
- * configured sentences parse fine in registry-core but never reach the assembly face ([ref]① 排雷:
82
- * the missing leg made every promptGuidance pilot a false control). */
78
+ /** registry-core 0.10.13 ([ref]/[ref]⑤c): per-model behavior-slot sentences. core 7.56.0 ([ref]) retired the engine seat
79
+ * (`Model.promptGuidance`; per-model guidance is now a prompt overlay keyed on the model's declared traits), while the
80
+ * settings-schema `ModelEntry` still accepts the key. It is carried here ONLY so the [ref] judge (`judgeCatalogEntry`)
81
+ * can see it: a non-empty list refuses the entry (`config.model_entry_invalid`, field `promptGuidance`) instead of the
82
+ * sentences being silently dropped; `toModel` never mints it onto a core `Model`. */
83
83
  promptGuidance?: string[];
84
84
  /**
85
85
  * [ref](7.108.0)—— 这条条目发给供应商的**附加请求头**(部署 ↔ 供应商的契约;今天只有 `anthropic-beta`),上 core 的 per-model
@@ -170,6 +170,11 @@ export interface CenterMcpServer {
170
170
  * (同批解析透明键 `authForm` / `entryKind` 的语义归连接器,本层仍只承载。)
171
171
  */
172
172
  toolAxes?: unknown;
173
+ /**
174
+ * core 7.58.0 `McpServerSpec.sessionMetaKey` —— 声明了它的服务器,引擎在每次 `tools/call` 的 `_meta` 下以这把键放这条腿的会话 id。
175
+ * 承载形 `unknown`(与 {@link CenterMcpServer.toolAxes} 同姿):判官只有引擎根导出的 `judgeSessionMetaKey`(`resolveMcpServers` 在铸 spec 那一刻问它;坏形整条 server 不进)。
176
+ */
177
+ sessionMetaKey?: unknown;
173
178
  transport: {
174
179
  kind: "stdio";
175
180
  command: string;
@@ -18,8 +18,11 @@ dials the device, so the device needs no inbound port, no public address and no
18
18
 
19
19
  **Discovery before you connect**: `GET /v1/capabilities` carries a `deviceExecutor` key — either `false`
20
20
  (this deployment has no device lane) or an object `{ enabled: true, protocolVersion, maxInflightPerDevice,
21
- wsPath, management }`. Read `wsPath` from there rather than hardcoding it: the path is part of the wire
22
- contract and reading it means a future path change is not a cross-repo break. `protocolVersion` tells you
21
+ wsPath, management, relayUrl? }`. Read `wsPath` from there rather than hardcoding it: the path is part of the wire
22
+ contract and reading it means a future path change is not a cross-repo break. `relayUrl` (server 7.137.0+) is present
23
+ only when the operator declared one (`DEVICE_RELAY_URL`): the engine sits behind a relay or gateway and the device
24
+ must dial that absolute `ws://` / `wss://` URL verbatim instead of the engine's own address — do not rebuild it from
25
+ the engine address and `wsPath`. Absent ⇒ dial the engine's own address at `wsPath`, as before. `protocolVersion` tells you
23
26
  which protocol **revision** the server speaks before you spend a handshake finding out (§2.1: the revision decides
24
27
  which `errorCode` words the server accepts from you).
25
28
 
@@ -136,7 +139,8 @@ Ask for a new enrollment token and try again."* Do not retry the same token afte
136
139
 
137
140
  ### 1.2 Connecting
138
141
 
139
- Open a WebSocket to `wsPath` (`GET`, standard upgrade). The server refuses the upgrade with `404` for any
142
+ Open a WebSocket to `relayUrl` when the capability carries one, otherwise to `wsPath` on the engine's own
143
+ address (`GET`, standard upgrade). The server refuses the upgrade with `404` for any
140
144
  other path, and with `503` while the replica is draining or when its pre-auth connection caps are full.
141
145
  There is no authentication in the upgrade headers — the handshake happens **inside** the protocol.
142
146
 
@@ -336,7 +340,7 @@ base64 inside JSON fields.
336
340
  | Constant | Value | Meaning |
337
341
  |---|---|---|
338
342
  | `DEVICE_WS_PATH` | `/v1/device/ws` | the upgrade path (prefer the `wsPath` from `/v1/capabilities`) |
339
- | `DEVICE_PROTOCOL_VERSION` | `2` | the protocol revision this server speaks (the highest it accepts) |
343
+ | `DEVICE_PROTOCOL_VERSION` | `3` | the protocol revision this server speaks (the highest it accepts) |
340
344
  | `DEVICE_MIN_PROTOCOL_VERSION` | `1` | the lowest revision it accepts; below it (or above the highest), a loud `helloReject` — never a silent downgrade |
341
345
  | `DEVICE_HELLO_DOMAIN_TAG` | `sema.device.hello.v1` | the handshake signature domain tag (§1.3) |
342
346
 
@@ -365,6 +369,7 @@ the union of the rows up to *N*, and the full set at the current revision is the
365
369
  |---|---|
366
370
  | `1` | `aborted`, `already_exists`, `auth_failed`, `callback_error`, `invalid`, `is_directory`, `not_directory`, `not_found`, `not_supported`, `outcome_unknown`, `permission_denied`, `precondition_failed`, `shell_unavailable`, `spawn_error`, `suspended`, `target_unavailable`, `timeout`, `transport_lost`, `unknown` |
367
371
  | `2` | `liveness_no_output` |
372
+ | `3` | `name_too_long` |
368
373
 
369
374
  Rules: adding a frame or a field is additive and does not raise the revision; adding a word to a closed set the
370
375
  server *accepts from you* (today: the `errorCode` set) raises `DEVICE_PROTOCOL_VERSION` and adds a row here; a
@@ -560,7 +565,7 @@ a moment ago. If you omit `created`, the consumer reports the weaker of the two
560
565
 
561
566
  `message` is required on the failure arm and is shown to the model — make it specific.
562
567
 
563
- This is the full set at the current revision (`2`); the revision table in §2.1 says which revision each word arrived
568
+ This is the full set at the current revision (`3`); the revision table in §2.1 says which revision each word arrived
564
569
  with, and an executor sends only the words of the revision it declared (§1.2).
565
570
 
566
571
  <!-- closed-set: DEVICE_OUTCOME_ERROR_CODES -->
@@ -574,6 +579,7 @@ with, and an executor sends only the words of the revision it declared (§1.2).
574
579
  | `invalid` | the arguments do not make sense for this target (e.g. `readLink` on a non-symlink) |
575
580
  | `is_directory` | a file operation hit a directory |
576
581
  | `liveness_no_output` | **you** killed the command because it produced no output for your own silence window (a hung command); the wall-clock budget `timeoutMs` running out stays `timeout`. The frame has no field for the window length — do not invent one |
582
+ | `name_too_long` | a component of the path is longer than the filesystem's name limit (`NAME_MAX`, 255 bytes; POSIX `ENAMETOOLONG` for such a component) — no directory can hold that name, so it is read upstream as an absence, like `not_found`. A path that is only too long as a whole while every component is short stays `unknown` (such a file may exist, reached from a directory below it). On an exec instruction it is a protocol violation (use `spawn_error` when the process could not be started) and the server reads it as `unknown` |
577
583
  | `not_directory` | a directory operation hit a non-directory |
578
584
  | `not_found` | the path does not exist |
579
585
  | `not_supported` | you do not implement this face (prefer simply not declaring it) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/server",
3
- "version": "7.136.0",
3
+ "version": "7.138.0",
4
4
  "description": "Sema Server — the server/API implementation layer for Sema, wiring core, registry, model providers, and cloud agent execution. Built on @sema-agent/core.",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",
@@ -69,8 +69,8 @@
69
69
  "build:binary:run-local:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/run-local.ts --outfile dist/run-local-darwin-arm64"
70
70
  },
71
71
  "dependencies": {
72
- "@sema-agent/core": "7.55.0",
73
- "@sema-agent/settings-schema": "14.5.0",
72
+ "@sema-agent/core": "7.59.0",
73
+ "@sema-agent/settings-schema": "14.7.0",
74
74
  "e2b": "^2.28.0",
75
75
  "libsodium-wrappers": "^0.8.4",
76
76
  "mysql2": "^3.22.4",