@sema-agent/server 7.137.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 (209) hide show
  1. package/MIGRATION.md +328 -139
  2. package/README.md +1 -0
  3. package/README.zh-CN.md +1 -0
  4. package/USAGE.md +67 -20
  5. package/dist/approval-card.d.ts +21 -14
  6. package/dist/approval-card.js +1 -0
  7. package/dist/audit.js +1 -0
  8. package/dist/background-agent-name.d.ts +5 -0
  9. package/dist/background-agent-name.js +5 -0
  10. package/dist/boot/budget-tracing.d.ts +1 -12
  11. package/dist/boot/deployment-mods.d.ts +46 -16
  12. package/dist/boot/deployment-mods.js +82 -6
  13. package/dist/boot/governance-seams.d.ts +10 -17
  14. package/dist/boot/governance-seams.js +5 -17
  15. package/dist/boot/leader.d.ts +3 -0
  16. package/dist/boot/leader.js +1 -0
  17. package/dist/boot/org-delivery.js +15 -2
  18. package/dist/boot/resolve-spec.d.ts +3 -0
  19. package/dist/boot/resolve-spec.js +23 -12
  20. package/dist/boot/retention-lane.d.ts +11 -5
  21. package/dist/boot/retention-lane.js +2 -2
  22. package/dist/boot/runner-deps.d.ts +7 -3
  23. package/dist/boot/runner-deps.js +1 -0
  24. package/dist/boot/stage-04-stores.d.ts +1 -12
  25. package/dist/boot/stage-05-execution-env.d.ts +3 -12
  26. package/dist/boot/stage-05-execution-env.js +7 -4
  27. package/dist/boot/stage-06-runners.d.ts +3 -12
  28. package/dist/boot/stage-06-runners.js +5 -2
  29. package/dist/boot/stage-07-capability-layer.d.ts +3 -12
  30. package/dist/boot/stage-07-capability-layer.js +2 -2
  31. package/dist/boot/stage-08-reapers.d.ts +3 -12
  32. package/dist/boot/stage-09-leader.d.ts +3 -12
  33. package/dist/boot/stage-09-leader.js +2 -2
  34. package/dist/boot/stage-10-http-server.d.ts +3 -12
  35. package/dist/boot/stage-10-http-server.js +4 -2
  36. package/dist/boot/web-admin.d.ts +5 -2
  37. package/dist/boot/web-admin.js +3 -3
  38. package/dist/brain.js +5 -5
  39. package/dist/budget.d.ts +17 -15
  40. package/dist/budget.js +2 -2
  41. package/dist/capabilities/mcp-probe.d.ts +36 -11
  42. package/dist/capabilities/mcp-probe.js +44 -5
  43. package/dist/capability-facts.d.ts +6 -0
  44. package/dist/capability-facts.js +5 -0
  45. package/dist/checkpoint-identity.d.ts +13 -6
  46. package/dist/config-catalog.js +7 -1
  47. package/dist/config-types.d.ts +15 -7
  48. package/dist/config.js +8 -5
  49. package/dist/deployment-shape.d.ts +6 -6
  50. package/dist/gate-settlement.d.ts +71 -0
  51. package/dist/gate-settlement.js +40 -0
  52. package/dist/hooks/classic-stations.d.ts +1 -0
  53. package/dist/hooks/classic-stations.js +1 -0
  54. package/dist/hooks/command-spawn.d.ts +2 -2
  55. package/dist/hooks/hook-runner.js +14 -14
  56. package/dist/http/admission.js +4 -2
  57. package/dist/http/dispatch.d.ts +4 -0
  58. package/dist/http/dispatch.js +3 -0
  59. package/dist/http/durable-run-leg.js +4 -2
  60. package/dist/http/memory-compliance-failure-reply.js +3 -0
  61. package/dist/http/resume-legs.d.ts +5 -11
  62. package/dist/http/resume-legs.js +136 -91
  63. package/dist/http/route-ctx.d.ts +30 -51
  64. package/dist/http/route-ctx.js +2 -5
  65. package/dist/http/routes/a2a-serve.js +10 -4
  66. package/dist/http/routes/agents-roster.d.ts +1 -1
  67. package/dist/http/routes/agents-roster.js +5 -1
  68. package/dist/http/routes/approvals-assistant.js +6 -6
  69. package/dist/http/routes/capabilities.js +12 -10
  70. package/dist/http/routes/mcp-reconnect.d.ts +3 -2
  71. package/dist/http/routes/mcp-reconnect.js +7 -5
  72. package/dist/http/routes/memory-consolidation.d.ts +1 -1
  73. package/dist/http/routes/memory-origin.d.ts +1 -1
  74. package/dist/http/routes/rules.js +3 -3
  75. package/dist/http/routes/runs.js +11 -7
  76. package/dist/http/routes/sessions.js +6 -4
  77. package/dist/http/routes/side-query.js +2 -3
  78. package/dist/http/routes/tasks.js +792 -780
  79. package/dist/http/server.d.ts +31 -25
  80. package/dist/http/wire-types.d.ts +14 -6
  81. package/dist/identity-source.d.ts +1 -1
  82. package/dist/index.d.ts +2 -0
  83. package/dist/index.js +1 -0
  84. package/dist/leader/wire.d.ts +7 -0
  85. package/dist/leader/wire.js +5 -4
  86. package/dist/mcp-assertion-header.d.ts +51 -40
  87. package/dist/mcp-assertion-header.js +10 -11
  88. package/dist/mcp-authorization-face.d.ts +27 -0
  89. package/dist/mcp-authorization-face.js +15 -0
  90. package/dist/memory-operator-faces.d.ts +13 -4
  91. package/dist/memory-operator-faces.js +1 -17
  92. package/dist/memory-sync-client.js +72 -57
  93. package/dist/memory-sync.d.ts +1 -1
  94. package/dist/model-route-gap.d.ts +6 -22
  95. package/dist/model-route-gap.js +7 -5
  96. package/dist/mods-declaration.d.ts +110 -0
  97. package/dist/mods-declaration.js +109 -0
  98. package/dist/observability/err-text.d.ts +5 -0
  99. package/dist/observability/err-text.js +9 -0
  100. package/dist/observability/fail-open.d.ts +5 -1
  101. package/dist/observability/fail-open.js +5 -1
  102. package/dist/observability/secret-env-scrub.d.ts +1 -1
  103. package/dist/observability/secret-env-scrub.js +1 -1
  104. package/dist/parked-decide.d.ts +15 -2
  105. package/dist/parked-decide.js +14 -8
  106. package/dist/peer-seat.d.ts +150 -0
  107. package/dist/peer-seat.js +239 -0
  108. package/dist/permission-rule-vocab.d.ts +7 -7
  109. package/dist/permission-rule-vocab.js +3 -3
  110. package/dist/plain-string-record.d.ts +38 -0
  111. package/dist/plain-string-record.js +38 -0
  112. package/dist/plugins/background-agent-store-sql.js +6 -3
  113. package/dist/plugins/caching-session-store.d.ts +5 -0
  114. package/dist/plugins/caching-session-store.js +6 -0
  115. package/dist/plugins/checkpoint-store-sql.d.ts +15 -20
  116. package/dist/plugins/checkpoint-store-sql.js +8 -8
  117. package/dist/plugins/file-history-store-sql.js +3 -2
  118. package/dist/plugins/k8s-pod-reaper.d.ts +2 -8
  119. package/dist/plugins/k8s-pod-reaper.js +3 -3
  120. package/dist/plugins/local-checkpoint-store.d.ts +1 -11
  121. package/dist/plugins/local-checkpoint-store.js +0 -1
  122. package/dist/plugins/local-session-store.d.ts +66 -27
  123. package/dist/plugins/local-session-store.js +60 -28
  124. package/dist/plugins/mailbox-store-sql.d.ts +11 -3
  125. package/dist/plugins/mailbox-store-sql.js +103 -15
  126. package/dist/plugins/memory-sync-store-pg.d.ts +16 -5
  127. package/dist/plugins/memory-sync-store-tidb.d.ts +3 -3
  128. package/dist/plugins/one-time-migrations.d.ts +6 -3
  129. package/dist/plugins/one-time-migrations.js +3 -4
  130. package/dist/plugins/permission-rule-store-sql.js +21 -13
  131. package/dist/plugins/pg-session-storage.d.ts +10 -2
  132. package/dist/plugins/pg-session-storage.js +18 -5
  133. package/dist/plugins/remote-env-adb.d.ts +3 -1
  134. package/dist/plugins/remote-env-adb.js +1 -1
  135. package/dist/plugins/remote-env-device.d.ts +3 -1
  136. package/dist/plugins/remote-env-device.js +1 -1
  137. package/dist/plugins/remote-env-e2b.d.ts +2 -0
  138. package/dist/plugins/remote-env-e2b.js +1 -1
  139. package/dist/plugins/remote-env-host.d.ts +3 -1
  140. package/dist/plugins/remote-env-host.js +1 -1
  141. package/dist/plugins/remote-env-k8s.d.ts +3 -1
  142. package/dist/plugins/remote-env-k8s.js +1 -1
  143. package/dist/plugins/remote-env-local-docker.d.ts +2 -0
  144. package/dist/plugins/remote-env-local-docker.js +1 -1
  145. package/dist/plugins/remote-env-ssh.d.ts +3 -1
  146. package/dist/plugins/remote-env-ssh.js +1 -1
  147. package/dist/plugins/retention-store-sql.d.ts +14 -2
  148. package/dist/plugins/retention-store-sql.js +6 -0
  149. package/dist/plugins/session-fork.d.ts +10 -13
  150. package/dist/plugins/session-fork.js +5 -25
  151. package/dist/plugins/session-ownership.d.ts +7 -0
  152. package/dist/plugins/session-ownership.js +5 -0
  153. package/dist/plugins/session-workspace-cell.d.ts +17 -0
  154. package/dist/plugins/session-workspace-cell.js +38 -0
  155. package/dist/plugins/store-backend.js +7 -7
  156. package/dist/plugins/tidb-pool.js +6 -0
  157. package/dist/plugins/tidb-session-store.d.ts +17 -2
  158. package/dist/plugins/tidb-session-store.js +16 -5
  159. package/dist/plugins/tool-result-store-sql.d.ts +13 -6
  160. package/dist/plugins/tool-result-store-sql.js +8 -7
  161. package/dist/plugins/worktree-isolation.d.ts +3 -2
  162. package/dist/plugins/worktree-isolation.js +1 -7
  163. package/dist/project-identity.d.ts +1 -14
  164. package/dist/project-identity.js +0 -4
  165. package/dist/rules-consent.js +6 -4
  166. package/dist/run-local.js +12 -6
  167. package/dist/runs.d.ts +7 -1
  168. package/dist/runs.js +6 -1
  169. package/dist/sandbox-git-plane.d.ts +2 -2
  170. package/dist/server-secret-env.d.ts +6 -3
  171. package/dist/server-secret-env.js +4 -2
  172. package/dist/session-incarnation.d.ts +4 -5
  173. package/dist/session-incarnation.js +2 -2
  174. package/dist/session-workspace.d.ts +130 -0
  175. package/dist/session-workspace.js +83 -0
  176. package/dist/spec-fields.d.ts +1 -1
  177. package/dist/standing-answer-grant.d.ts +2 -13
  178. package/dist/standing-answer-grant.js +0 -7
  179. package/dist/task-a2a.d.ts +44 -14
  180. package/dist/task-a2a.js +46 -20
  181. package/dist/task-mcp.d.ts +33 -20
  182. package/dist/task-mcp.js +46 -22
  183. package/dist/tool-approval.d.ts +32 -8
  184. package/dist/tool-approval.js +49 -12
  185. package/dist/trace/core-keyset-guard.d.ts +33 -18
  186. package/dist/trace/engine-notice-wire.d.ts +1 -1
  187. package/dist/trace/engine-notice-wire.js +2 -0
  188. package/dist/trace/exit-seat.d.ts +20 -1
  189. package/dist/trace/exit-seat.js +3 -0
  190. package/dist/trace/extension-call-face.d.ts +33 -0
  191. package/dist/trace/extension-call-face.js +39 -0
  192. package/dist/trace/project.d.ts +25 -7
  193. package/dist/trace/project.js +29 -3
  194. package/dist/trace/redact.js +42 -13
  195. package/dist/trace/self-minted-wire.d.ts +129 -10
  196. package/dist/trace/self-minted-wire.js +62 -3
  197. package/dist/trace/wire-projection-faces.d.ts +6 -6
  198. package/dist/trace/wire-projection-faces.js +6 -5
  199. package/dist/user-authored-text.d.ts +2 -2
  200. package/dist/user-authored-text.js +16 -1
  201. package/dist/web-admin-client/center-request.d.ts +3 -2
  202. package/dist/web-admin-client/center-request.js +2 -3
  203. package/dist/web-admin-client/skills-mcp.d.ts +8 -4
  204. package/dist/web-admin-client/skills-mcp.js +31 -18
  205. package/dist/web-admin-client/types.d.ts +5 -0
  206. package/package.json +3 -3
  207. package/wire-changes/server@7.138.0.json +446 -0
  208. package/dist/http/mcp-remote-text.d.ts +0 -5
  209. package/dist/http/mcp-remote-text.js +0 -7
@@ -100,7 +100,7 @@ export type DeclaredKey = ManifestShape & {
100
100
  */
101
101
  export declare const FRAME_ENVELOPE_KEYS: readonly ["type", "sourceTaskId", "bgAgentId"];
102
102
  /** 探针文件要从 `@sema-agent/core` 具名导入的类型(`coreType` 表达式里用到的全部名字)。 */
103
- export declare const WIRE_PROJECTION_CORE_IMPORTS: readonly ["TaskEvent", "TaskNotificationPayload", "WiringManifest", "EngineNotice", "MemoryImportReport", "OriginClearanceRow", "OriginClearanceEvent", "MemoryEntryOrigin", "TraceEvent", "PromptManifestIdentity", "PromptIdentityLayers", "PromptManifestSelectors", "PromptManifestSection", "PromptChainLink", "SupersededOverlay", "ToolDisclosureManifest"];
103
+ export declare const WIRE_PROJECTION_CORE_IMPORTS: readonly ["TaskEvent", "BrainStatus", "TaskNotificationPayload", "WiringManifest", "EngineNotice", "MemoryImportReport", "OriginClearanceRow", "OriginClearanceEvent", "MemoryEntryOrigin", "TraceEvent", "PromptManifestIdentity", "PromptIdentityLayers", "PromptManifestSelectors", "PromptManifestSection", "PromptChainLink", "SupersededOverlay", "ToolDisclosureManifest"];
104
104
  /**
105
105
  * `wiring_manifest` 的 **operator 面多投的那几段**(`wiringManifestOperatorEventData` 在租户形之上加的段)。
106
106
  * operator 行的 `excluded` = 租户行减本常量(派生);四段各自的受众裁定在 `core-keyset-guard.ts` ⑥b。
@@ -129,13 +129,13 @@ export declare const WIRE_PROJECTION_FACES: {
129
129
  readonly tool_start: {
130
130
  readonly projector: "toolStartEventData";
131
131
  readonly coreType: string;
132
- readonly excluded: readonly ["requestedBy"];
132
+ readonly excluded: readonly [];
133
133
  readonly minted: readonly [];
134
134
  };
135
135
  readonly tool_end: {
136
136
  readonly projector: "toolEndEventData";
137
137
  readonly coreType: string;
138
- readonly excluded: readonly ["requestedBy", "answeredBy"];
138
+ readonly excluded: readonly [];
139
139
  readonly minted: readonly [];
140
140
  };
141
141
  readonly tool_progress: {
@@ -171,12 +171,12 @@ export declare const WIRE_PROJECTION_FACES: {
171
171
  readonly workspace_changed: {
172
172
  readonly projector: "workspaceChangedEventData";
173
173
  readonly coreType: string;
174
- readonly excluded: readonly [];
174
+ readonly excluded: readonly ["root", "remote", "entered", "project"];
175
175
  readonly minted: readonly [];
176
176
  };
177
177
  readonly status: {
178
178
  readonly projector: "brainStatusEventData";
179
- readonly coreType: string;
179
+ readonly coreType: `BrainStatus & ${string}`;
180
180
  readonly excluded: readonly [];
181
181
  readonly minted: readonly [];
182
182
  };
@@ -213,7 +213,7 @@ export declare const WIRE_PROJECTION_FACES: {
213
213
  readonly human_input: {
214
214
  readonly projector: "humanInputEventData";
215
215
  readonly coreType: string;
216
- readonly excluded: readonly ["principal"];
216
+ readonly excluded: readonly ["principal", "runOrigin"];
217
217
  readonly minted: readonly [];
218
218
  };
219
219
  readonly task_notification: {
@@ -1,6 +1,7 @@
1
1
  export const FRAME_ENVELOPE_KEYS = ["type", "sourceTaskId", "bgAgentId"];
2
2
  export const WIRE_PROJECTION_CORE_IMPORTS = [
3
3
  "TaskEvent",
4
+ "BrainStatus",
4
5
  "TaskNotificationPayload",
5
6
  "WiringManifest",
6
7
  "EngineNotice",
@@ -26,21 +27,21 @@ function withoutSections(all, drop) {
26
27
  export const WIRE_PROJECTION_FACES = {
27
28
  task_progress: { projector: "taskProgressEventData", coreType: arm("task_progress"), excluded: [], minted: [] },
28
29
  task_started: { projector: "taskStartedEventData", coreType: arm("task_started"), excluded: [], minted: [] },
29
- tool_start: { projector: "toolStartEventData", coreType: arm("tool_start"), excluded: ["requestedBy"], minted: [] },
30
- tool_end: { projector: "toolEndEventData", coreType: arm("tool_end"), excluded: ["requestedBy", "answeredBy"], minted: [] },
30
+ tool_start: { projector: "toolStartEventData", coreType: arm("tool_start"), excluded: [], minted: [] },
31
+ tool_end: { projector: "toolEndEventData", coreType: arm("tool_end"), excluded: [], minted: [] },
31
32
  tool_progress: { projector: "toolProgressEventData", coreType: arm("tool_progress"), excluded: [], minted: [] },
32
33
  tool_disclosure: { projector: "toolDisclosureEventData", coreType: arm("tool_disclosure"), excluded: [], minted: [] },
33
34
  tool_roster_delta: { projector: "toolRosterDeltaEventData", coreType: arm("tool_roster_delta"), excluded: [], minted: [] },
34
35
  diagnostics: { projector: "diagnosticsEventData", coreType: arm("diagnostics"), excluded: [], minted: [] },
35
36
  steering_injected: { projector: "steeringInjectedEventData", coreType: arm("steering_injected"), excluded: [], minted: [] },
36
- workspace_changed: { projector: "workspaceChangedEventData", coreType: arm("workspace_changed"), excluded: [], minted: [] },
37
- status: { projector: "brainStatusEventData", coreType: arm("status"), excluded: [], minted: [] },
37
+ workspace_changed: { projector: "workspaceChangedEventData", coreType: arm("workspace_changed"), excluded: ["root", "remote", "entered", "project"], minted: [] },
38
+ status: { projector: "brainStatusEventData", coreType: `BrainStatus & ${arm("status")}`, excluded: [], minted: [] },
38
39
  compacted: { projector: "compactedEventData", coreType: arm("compacted"), excluded: [], minted: [] },
39
40
  context_usage: { projector: "contextUsageEventData", coreType: arm("context_usage"), excluded: [], minted: [] },
40
41
  turn_end: { projector: "turnEndEventData", coreType: arm("turn_end"), excluded: [], minted: [] },
41
42
  compaction_outcome: { projector: "compactionOutcomeEventData", coreType: arm("compaction_outcome"), excluded: [], minted: [] },
42
43
  compaction_started: { projector: "compactionStartedEventData", coreType: arm("compaction_started"), excluded: [], minted: [] },
43
- human_input: { projector: "humanInputEventData", coreType: arm("human_input"), excluded: ["principal"], minted: [] },
44
+ human_input: { projector: "humanInputEventData", coreType: arm("human_input"), excluded: ["principal", "runOrigin"], minted: [] },
44
45
  task_notification: {
45
46
  projector: "taskNotificationEventData",
46
47
  coreType: `TaskNotificationPayload & ${arm("task_notification")}`,
@@ -1,5 +1,5 @@
1
- /** 非用户正文块的闭集标签(引擎 / 壳注入)。加一个标签 = 改这里一处:下面的正则由本表生成。 */
2
- export declare const INJECTED_BLOCK_TAGS: readonly ["system-reminder", "task-notification", "attachment"];
1
+ /** 非用户正文块的闭集标签(引擎 / 壳注入)。加一个标签 = 改这里一处:下面的正则由本表生成(分支组的序 = 本表的序)。 */
2
+ export declare const INJECTED_BLOCK_TAGS: readonly ["system-reminder", "task-notification", "attachment", "command-name", "command-message", "command-args", "local-command-stdout", "local-command-stderr", "local-command-caveat", "bash-input", "bash-stdout", "bash-stderr", "bash-exit-code", "user-memory-input"];
3
3
  /**
4
4
  * 注入块的唯一一只正则(由 {@link INJECTED_BLOCK_TAGS} 生成)。**只配 `String.prototype.replace` 使用**(带 `g`,
5
5
  * `lastIndex` 有状态,拿去 `.test` / `.exec` 会读到上一次的位置)。
@@ -1,5 +1,20 @@
1
1
  import { redactSecrets } from "./trace/redact.js";
2
- export const INJECTED_BLOCK_TAGS = ["system-reminder", "task-notification", "attachment"];
2
+ export const INJECTED_BLOCK_TAGS = [
3
+ "system-reminder",
4
+ "task-notification",
5
+ "attachment",
6
+ "command-name",
7
+ "command-message",
8
+ "command-args",
9
+ "local-command-stdout",
10
+ "local-command-stderr",
11
+ "local-command-caveat",
12
+ "bash-input",
13
+ "bash-stdout",
14
+ "bash-stderr",
15
+ "bash-exit-code",
16
+ "user-memory-input",
17
+ ];
3
18
  export const INJECTED_BLOCK_RE = new RegExp(`<(${INJECTED_BLOCK_TAGS.join("|")})(?:\\s(?:[^<>"']|"[^"<]*"|'[^'<]*')*?)?(?:\\/>|>[\\s\\S]*?(?:<\\/\\1>|$))\\s*`, "g");
4
19
  export function stripInjectedBlocks(text) {
5
20
  return text.replace(INJECTED_BLOCK_RE, "");
@@ -82,8 +82,9 @@ export interface CenterRequestInit {
82
82
  }
83
83
  /**
84
84
  * 「后面要拼路径的基址」的拒句 —— 中心基址三席(`SEMA_WEB_ADMIN_URL` / `SEMA_WEB_ADMIN_LIVE_URL` / `SEMA_WEB_ADMIN_WEB_URL`)与本实例的
85
- * 公告地址(`FLEET_ADVERTISE_ADDRESS`,中心往它后面拼 `/v1/...`)同读。判官是 settings-schema 的 `httpUrlFlaws`(层级式 http(s) URL;Node 的 fetch
86
- * 认 `file://` / `data:`,配错的地址不许变成读本地文件),本函数只声明这一席禁哪几件({@link PATH_BASE_FORBIDS})。起服时 `config.ts` 判
85
+ * 公告地址(`FLEET_ADVERTISE_ADDRESS`,中心往它后面拼 `/v1/...`)同读。判官是 settings-schema 的 `pathBaseUrlFlaws`(14.7.0 起:这一座位的禁用集
86
+ * userinfo / query / fragment 与判官都在契约包,= `httpUrlFlaws` 配那一集;层级式 http(s) URL,Node 的 fetch 认 `file://` / `data:`,配错的地址不许变成
87
+ * 读本地文件),本仓零禁用集副本,编排器渲染公告地址 env 的一方调的是同一只。起服时 `config.ts` 判
87
88
  * (拒启),请求期 {@link centerFetch} 对同一份基址再判一次(自拼 `ServiceConfig` 的嵌入方也吃同一条规则)。合格 ⇒ `undefined`;否则交回
88
89
  * `<subject> <规则词>; got "<展示面安全形>"` —— 拒句里没有从值里解析出来的任何记号(scheme / userinfo / 主机名),捕获点照原样落日志即可。
89
90
  */
@@ -2,7 +2,7 @@ import settingsSchemaPackage from "@sema-agent/settings-schema/package.json" wit
2
2
  import { AUTH_V1_PATHS } from "@sema-agent/settings-schema/api/auth";
3
3
  import { FLEET_LIVE_PATHS, FLEET_PATHS } from "@sema-agent/settings-schema/fleet";
4
4
  import { CenterCredentialUnavailableError } from "../center-credential.js";
5
- import { WEB_ADMIN_ENV, httpUrlFlaws } from "@sema-agent/settings-schema";
5
+ import { WEB_ADMIN_ENV, httpUrlFlaws, pathBaseUrlFlaws } from "@sema-agent/settings-schema";
6
6
  import { buildHttpUrlRefusal } from "../url-refusal.js";
7
7
  import { egressRedirectRefusal } from "../egress-redirect.js";
8
8
  export const SCHEMA_MAJOR_HEADER = "x-sema-schema-major";
@@ -82,9 +82,8 @@ async function sendToCenter(fix, url, wire) {
82
82
  throw new CenterRedirectRefusedError(res.status, `web-admin center request: ${refusal}`);
83
83
  return res;
84
84
  }
85
- const PATH_BASE_FORBIDS = ["userinfo", "query", "fragment"];
86
85
  export function pathBaseUrlRefusal(subject, raw) {
87
- const flaws = httpUrlFlaws(raw, PATH_BASE_FORBIDS);
86
+ const flaws = pathBaseUrlFlaws(raw);
88
87
  return flaws.length === 0 ? undefined : buildHttpUrlRefusal(subject, raw, flaws);
89
88
  }
90
89
  function assertPathBaseUrl(raw, what) {
@@ -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) });
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/server",
3
- "version": "7.137.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.56.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",