@sema-agent/server 4.3.0 → 5.0.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 (166) hide show
  1. package/USAGE.md +5 -3
  2. package/dist/approval-hmac.js +1 -1
  3. package/dist/approval.d.ts +5 -37
  4. package/dist/approval.js +12 -112
  5. package/dist/auth-bridge.d.ts +0 -1
  6. package/dist/auth-bridge.js +0 -1
  7. package/dist/auth-keys.d.ts +1 -1
  8. package/dist/auth-keys.js +1 -1
  9. package/dist/bench/s1/run-firm.js +1 -1
  10. package/dist/boot/config-center.d.ts +1 -1
  11. package/dist/boot/config-center.js +3 -2
  12. package/dist/boot/reapers.d.ts +1 -2
  13. package/dist/boot/reapers.js +4 -5
  14. package/dist/boot/resolve-spec.d.ts +1 -3
  15. package/dist/boot/resolve-spec.js +21 -35
  16. package/dist/boot/stores.js +1 -1
  17. package/dist/brain.js +3 -1
  18. package/dist/capabilities/center-prompts.d.ts +2 -3
  19. package/dist/capabilities/center-prompts.js +2 -3
  20. package/dist/capabilities/sandbox-file-send.d.ts +0 -2
  21. package/dist/capabilities/sandbox-file-send.js +2 -5
  22. package/dist/capabilities/scenarios.d.ts +0 -9
  23. package/dist/capabilities/scenarios.js +1 -20
  24. package/dist/capabilities/send-user-file-tool.js +3 -3
  25. package/dist/config-center/apply-effective.js +8 -8
  26. package/dist/config-center/types.d.ts +10 -3
  27. package/dist/config-provider.js +6 -11
  28. package/dist/config-types.d.ts +12 -26
  29. package/dist/config.js +95 -68
  30. package/dist/fleet/fleet-bus.js +25 -33
  31. package/dist/fleet-client.js +1 -1
  32. package/dist/http/active-run-conflict.d.ts +2 -0
  33. package/dist/http/active-run-conflict.js +1 -0
  34. package/dist/http/routes/approvals-assistant.d.ts +2 -1
  35. package/dist/http/routes/approvals-assistant.js +10 -96
  36. package/dist/http/routes/capabilities.js +6 -5
  37. package/dist/http/routes/fleet.js +4 -1
  38. package/dist/http/routes/images.js +10 -4
  39. package/dist/http/routes/runs.js +34 -49
  40. package/dist/http/routes/session-sync.d.ts +1 -1
  41. package/dist/http/routes/session-sync.js +2 -1
  42. package/dist/http/routes/tasks.js +7 -7
  43. package/dist/http/routes/trace-usage.js +1 -1
  44. package/dist/http/server.d.ts +1 -6
  45. package/dist/http/server.js +15 -10
  46. package/dist/http/verify-rounds.d.ts +2 -2
  47. package/dist/http/wire-types.d.ts +1 -1
  48. package/dist/images/bake-validate.d.ts +0 -22
  49. package/dist/images/bake-validate.js +0 -4
  50. package/dist/index.d.ts +4 -4
  51. package/dist/index.js +2 -5
  52. package/dist/main.js +5 -9
  53. package/dist/memory-scope.js +2 -2
  54. package/dist/orchestration/workflow-completion-inbox.d.ts +6 -4
  55. package/dist/orchestration/workflow-completion-inbox.js +6 -4
  56. package/dist/plugins/breaker-state-sql.d.ts +2 -3
  57. package/dist/plugins/image-index-sql.d.ts +0 -1
  58. package/dist/plugins/image-index-sql.js +0 -1
  59. package/dist/plugins/local-checkpoint-store.d.ts +1 -1
  60. package/dist/plugins/local-checkpoint-store.js +1 -1
  61. package/dist/plugins/memory-engine-pg.js +2 -1
  62. package/dist/plugins/memory-engine-tidb.js +1 -1
  63. package/dist/plugins/memory-engine-vector-util.d.ts +2 -3
  64. package/dist/plugins/memory-engine-vector-util.js +2 -3
  65. package/dist/plugins/memory-run-store.d.ts +1 -1
  66. package/dist/plugins/memory-session-policy-store.d.ts +1 -1
  67. package/dist/plugins/memory-session-policy-store.js +1 -1
  68. package/dist/plugins/memory-sync-store-pg.js +1 -1
  69. package/dist/plugins/pg-pool.js +8 -10
  70. package/dist/plugins/pg-rate-limiter.d.ts +1 -4
  71. package/dist/plugins/pg-rate-limiter.js +0 -1
  72. package/dist/plugins/roster-store-sql.d.ts +1 -3
  73. package/dist/plugins/roster-store-sql.js +3 -5
  74. package/dist/plugins/store-backend.d.ts +7 -17
  75. package/dist/plugins/store-backend.js +14 -30
  76. package/dist/plugins/tidb-pool.js +4 -28
  77. package/dist/plugins/workflow-journal-store-sql.d.ts +1 -1
  78. package/dist/plugins/workflow-journal-store-sql.js +1 -1
  79. package/dist/principal-jwt.js +2 -2
  80. package/dist/prompts-domain-validate.d.ts +4 -3
  81. package/dist/prompts-domain-validate.js +7 -8
  82. package/dist/router/route-orchestration.js +3 -3
  83. package/dist/run-local.js +5 -4
  84. package/dist/runs.js +8 -6
  85. package/dist/runtime-caps-resolver.d.ts +3 -2
  86. package/dist/runtime-caps-resolver.js +4 -4
  87. package/dist/runtime-governance.d.ts +4 -7
  88. package/dist/runtime-governance.js +12 -17
  89. package/dist/sealed-key.d.ts +1 -1
  90. package/dist/sealed-key.js +1 -1
  91. package/dist/security.d.ts +0 -5
  92. package/dist/security.js +8 -12
  93. package/dist/session-sync.d.ts +0 -2
  94. package/dist/session-sync.js +10 -17
  95. package/dist/spec-fields.js +6 -6
  96. package/dist/task-settings.js +7 -7
  97. package/dist/tool-approval.d.ts +3 -3
  98. package/dist/tool-approval.js +10 -10
  99. package/dist/trace/artifacts.d.ts +11 -0
  100. package/dist/trace/artifacts.js +8 -19
  101. package/dist/trace/ledger-sink.js +7 -1
  102. package/dist/trace/project.d.ts +17 -0
  103. package/dist/trace/project.js +55 -5
  104. package/package.json +2 -2
  105. package/dist/capabilities/oa-tools.d.ts +0 -15
  106. package/dist/capabilities/oa-tools.js +0 -54
  107. package/dist/plugins/approval-store-sql.d.ts +0 -116
  108. package/dist/plugins/approval-store-sql.js +0 -150
  109. package/dist/plugins/file-workflow-journal-store.d.ts +0 -12
  110. package/dist/plugins/file-workflow-journal-store.js +0 -12
  111. package/dist/plugins/pg-approval-store.d.ts +0 -9
  112. package/dist/plugins/pg-approval-store.js +0 -9
  113. package/dist/plugins/pg-breaker-state.d.ts +0 -8
  114. package/dist/plugins/pg-breaker-state.js +0 -8
  115. package/dist/plugins/pg-checkpoint-store.d.ts +0 -10
  116. package/dist/plugins/pg-checkpoint-store.js +0 -10
  117. package/dist/plugins/pg-file-snapshot-store.d.ts +0 -8
  118. package/dist/plugins/pg-file-snapshot-store.js +0 -8
  119. package/dist/plugins/pg-image-bake.d.ts +0 -12
  120. package/dist/plugins/pg-image-bake.js +0 -11
  121. package/dist/plugins/pg-image-index.d.ts +0 -12
  122. package/dist/plugins/pg-image-index.js +0 -11
  123. package/dist/plugins/pg-outcome-ledger.d.ts +0 -12
  124. package/dist/plugins/pg-outcome-ledger.js +0 -11
  125. package/dist/plugins/pg-resume-anchor-store.d.ts +0 -7
  126. package/dist/plugins/pg-resume-anchor-store.js +0 -7
  127. package/dist/plugins/pg-run-store.d.ts +0 -9
  128. package/dist/plugins/pg-run-store.js +0 -9
  129. package/dist/plugins/pg-session-policy-store.d.ts +0 -7
  130. package/dist/plugins/pg-session-policy-store.js +0 -7
  131. package/dist/plugins/pg-session-store.d.ts +0 -12
  132. package/dist/plugins/pg-session-store.js +0 -12
  133. package/dist/plugins/pg-tool-result-store.d.ts +0 -9
  134. package/dist/plugins/pg-tool-result-store.js +0 -9
  135. package/dist/plugins/pg-workflow-journal-store.d.ts +0 -9
  136. package/dist/plugins/pg-workflow-journal-store.js +0 -9
  137. package/dist/plugins/pg-workflow-run-store.d.ts +0 -9
  138. package/dist/plugins/pg-workflow-run-store.js +0 -9
  139. package/dist/plugins/tidb-approval-store.d.ts +0 -8
  140. package/dist/plugins/tidb-approval-store.js +0 -8
  141. package/dist/plugins/tidb-breaker-state.d.ts +0 -7
  142. package/dist/plugins/tidb-breaker-state.js +0 -7
  143. package/dist/plugins/tidb-checkpoint-store.d.ts +0 -9
  144. package/dist/plugins/tidb-checkpoint-store.js +0 -9
  145. package/dist/plugins/tidb-file-snapshot-store.d.ts +0 -8
  146. package/dist/plugins/tidb-file-snapshot-store.js +0 -8
  147. package/dist/plugins/tidb-image-bake.d.ts +0 -12
  148. package/dist/plugins/tidb-image-bake.js +0 -11
  149. package/dist/plugins/tidb-image-index.d.ts +0 -12
  150. package/dist/plugins/tidb-image-index.js +0 -11
  151. package/dist/plugins/tidb-outcome-ledger.d.ts +0 -12
  152. package/dist/plugins/tidb-outcome-ledger.js +0 -12
  153. package/dist/plugins/tidb-resume-anchor-store.d.ts +0 -7
  154. package/dist/plugins/tidb-resume-anchor-store.js +0 -7
  155. package/dist/plugins/tidb-run-store.d.ts +0 -10
  156. package/dist/plugins/tidb-run-store.js +0 -9
  157. package/dist/plugins/tidb-session-policy-store.d.ts +0 -7
  158. package/dist/plugins/tidb-session-policy-store.js +0 -7
  159. package/dist/plugins/tidb-tool-result-store.d.ts +0 -8
  160. package/dist/plugins/tidb-tool-result-store.js +0 -10
  161. package/dist/plugins/tidb-workflow-journal-store.d.ts +0 -9
  162. package/dist/plugins/tidb-workflow-journal-store.js +0 -9
  163. package/dist/plugins/tidb-workflow-run-store.d.ts +0 -10
  164. package/dist/plugins/tidb-workflow-run-store.js +0 -10
  165. package/dist/plugins/workflow-journal-limits.d.ts +0 -12
  166. package/dist/plugins/workflow-journal-limits.js +0 -12
@@ -1,6 +1,4 @@
1
1
  import { normalizeAgentName } from "@sema-agent/core";
2
- /** 兼容名保留(测试/历史引用),现=core 导出直引(私拷已删)。 */
3
- export const normalizeAgentNameLocal = normalizeAgentName;
4
2
  export const ROSTER_TABLE = "agent_roster";
5
3
  /** 行 → RosterEntry(缺席键省略,core 形逐字;session_scoped 数值/布尔双方言归一)。
6
4
  * core 1.365 BREAKING:owner/scope 升类型必填——两方言 CREATE 直接建成 NOT NULL(当年的「清死行 +
@@ -114,7 +112,7 @@ export async function ensurePgRosterSchema(q) {
114
112
  /** upsert 参数序(两方言共用;core 1.365 起 owner/scope 类型必填——键列直取,与 core upsertKey 同键)。 */
115
113
  function upsertParams(entry, now) {
116
114
  return [
117
- normalizeAgentNameLocal(entry.name),
115
+ normalizeAgentName(entry.name),
118
116
  entry.owner,
119
117
  entry.scope,
120
118
  entry.name,
@@ -148,7 +146,7 @@ export class TiDBRosterStore {
148
146
  session_scoped = VALUES(session_scoped), root_session_id = VALUES(root_session_id), model = VALUES(model), created_at_ms = VALUES(created_at_ms), recorded_at_ms = VALUES(recorded_at_ms)`, p.map((v) => (typeof v === "boolean" ? (v ? 1 : 0) : v)));
149
147
  }
150
148
  async resolve(name, access) {
151
- const key = normalizeAgentNameLocal(name);
149
+ const key = normalizeAgentName(name);
152
150
  if (key === "")
153
151
  return undefined;
154
152
  const [rows] = (await this.pool.query(`SELECT ${COLS} FROM ${ROSTER_TABLE} WHERE ${RESOLVE_WHERE_TIDB} ORDER BY created_at_ms DESC, recorded_at_ms DESC, agent_id DESC LIMIT 1`, [key, access.scope ?? null, access.owner ?? null, access.sessionId ?? null, access.sessionId ?? null]));
@@ -185,7 +183,7 @@ export class PgRosterStore {
185
183
  recorded_at_ms = EXCLUDED.recorded_at_ms`, upsertParams(entry, this.clock()));
186
184
  }
187
185
  async resolve(name, access) {
188
- const key = normalizeAgentNameLocal(name);
186
+ const key = normalizeAgentName(name);
189
187
  if (key === "")
190
188
  return undefined;
191
189
  const { rows } = await this.q(`SELECT ${COLS} FROM ${ROSTER_TABLE} WHERE ${RESOLVE_WHERE_PG} ORDER BY created_at_ms DESC, recorded_at_ms DESC, agent_id DESC LIMIT 1`, [key, access.scope ?? null, access.owner ?? null, access.sessionId ?? null, access.sessionId ?? null]);
@@ -3,27 +3,19 @@ import type { Pool as PgPool } from "pg";
3
3
  import type { SessionStore, SessionPolicyStore, FileSnapshotStore, WorkflowJournalStore, ToolResultStore } from "@sema-agent/core";
4
4
  import { type FileSnapshotBounds } from "@sema-agent/core";
5
5
  import { type OutcomeSink } from "./file-outcome-sink.js";
6
- import { type InboxWarn } from "./tidb-workflow-run-store.js";
6
+ import { type InboxWarn } from "./workflow-run-store-sql.js";
7
7
  import { FileRunStore } from "./file-run-store.js";
8
8
  import { LocalCheckpointStore } from "./local-checkpoint-store.js";
9
9
  import { FileResumeAnchorStore } from "./file-resume-anchor-store.js";
10
10
  import { type ApprovalExemptionStore } from "./approval-exemption-store.js";
11
11
  import { type SendFileLedger } from "./send-file-ledger.js";
12
- import { TiDBResumeAnchorStore } from "./tidb-resume-anchor-store.js";
13
- import { PgResumeAnchorStore } from "./pg-resume-anchor-store.js";
12
+ import { TiDBResumeAnchorStore, PgResumeAnchorStore } from "./resume-anchor-store-sql.js";
14
13
  import type { ServiceConfig } from "../config-types.js";
15
- import { TiDBRunStore } from "./tidb-run-store.js";
16
- import { PgRunStore } from "./pg-run-store.js";
17
- import { TiDBCheckpointStore } from "./tidb-checkpoint-store.js";
18
- import { PgCheckpointStore } from "./pg-checkpoint-store.js";
19
- import { TiDBApprovalStore } from "./tidb-approval-store.js";
20
- import { PgApprovalStore } from "./pg-approval-store.js";
21
- import { TiDBImageIndex } from "./tidb-image-index.js";
22
- import { PgImageIndex } from "./pg-image-index.js";
23
- import { TiDBImageBake } from "./tidb-image-bake.js";
24
- import { PgImageBake } from "./pg-image-bake.js";
25
- import { TiDBBreakerState } from "./tidb-breaker-state.js";
26
- import { PgBreakerState } from "./pg-breaker-state.js";
14
+ import { TiDBRunStore, PgRunStore } from "./run-store-sql.js";
15
+ import { TiDBCheckpointStore, PgCheckpointStore } from "./checkpoint-store-sql.js";
16
+ import { TiDBImageIndex, PgImageIndex } from "./image-index-sql.js";
17
+ import { TiDBImageBake, PgImageBake } from "./image-bake-store-sql.js";
18
+ import { TiDBBreakerState, PgBreakerState } from "./breaker-state-sql.js";
27
19
  import { TiDBCostQuota } from "./tidb-cost-quota.js";
28
20
  import { PgCostQuota } from "./pg-cost-quota.js";
29
21
  import { TiDBRateLimiter } from "./tidb-rate-limiter.js";
@@ -79,7 +71,6 @@ export type ServiceWorkflowJournalStore = WorkflowJournalStore & {
79
71
  * TaskResult-bearing table (the per-run deleteByRun has no run-store reap hook). Local InMemory omits it. */
80
72
  reapExpired?(now: number, maxAgeMs: number): Promise<number>;
81
73
  };
82
- export type ApprovalStore = TiDBApprovalStore | PgApprovalStore;
83
74
  export type ImageIndex = TiDBImageIndex | PgImageIndex;
84
75
  export type ImageBake = TiDBImageBake | PgImageBake;
85
76
  /** The FULL checkpoint store (core CheckpointStore + the service operator-queue/ctx methods listPending/
@@ -155,7 +146,6 @@ export interface StoreBackend {
155
146
  checkpoint?(logger?: {
156
147
  info?(msg: string, meta?: unknown): void;
157
148
  }): CheckpointStoreFull;
158
- approval?(): ApprovalStore;
159
149
  toolResult?(): ToolResultStoreFull;
160
150
  imageIndex?(): ImageIndex;
161
151
  imageBake?(): ImageBake;
@@ -4,48 +4,34 @@
4
4
  * subsystem. main.ts wires through this instead of `new TiDB*(pool)` so `DB_BACKEND=pg` boots the whole service on
5
5
  * PG with zero call-site churn. The twins are interchangeable behaviourally (one shared real-DB integration suite
6
6
  * keeps them in lock-step); the unions below exist only because TS private fields make the concrete classes
7
- * nominally distinct (run/approval/imageIndex/imageBake have no core interface — the rest implement one).
7
+ * nominally distinct (run/imageIndex/imageBake have no core interface — the rest implement one).
8
8
  */
9
9
  import { homedir } from "node:os";
10
10
  import { join } from "node:path";
11
11
  import { FileStorageBackend, FileSessionRepo, DEFAULT_SNAPSHOT_BOUNDS } from "@sema-agent/core";
12
- import { FileWorkflowJournalStore } from "./file-workflow-journal-store.js";
13
- import { TiDBOutcomeLedger } from "./tidb-outcome-ledger.js";
14
- import { PgOutcomeLedger } from "./pg-outcome-ledger.js";
12
+ import { FileWorkflowJournalStore } from "@sema-agent/core";
13
+ import { TiDBOutcomeLedger, PgOutcomeLedger } from "./outcome-ledger-sql.js";
15
14
  import { FileOutcomeSink } from "./file-outcome-sink.js";
16
- import { TiDBWorkflowRunStore, TiDBWorkflowCompletionInbox, TiDBWorkflowNotifyJournalStore } from "./tidb-workflow-run-store.js";
17
- import { PgWorkflowRunStore, PgWorkflowCompletionInbox, PgWorkflowNotifyJournalStore } from "./pg-workflow-run-store.js";
15
+ import { TiDBWorkflowRunStore, TiDBWorkflowCompletionInbox, TiDBWorkflowNotifyJournalStore, PgWorkflowRunStore, PgWorkflowCompletionInbox, PgWorkflowNotifyJournalStore } from "./workflow-run-store-sql.js";
18
16
  import { FileRunStore } from "./file-run-store.js";
19
17
  import { LocalSessionStore } from "./local-session-store.js";
20
18
  import { LocalCheckpointStore } from "./local-checkpoint-store.js";
21
19
  import { FileResumeAnchorStore } from "./file-resume-anchor-store.js";
22
20
  import { TiDBApprovalExemptionStore, PgApprovalExemptionStore, FileApprovalExemptionStore } from "./approval-exemption-store.js";
23
21
  import { TiDBSendFileLedger, PgSendFileLedger, FileSendFileLedger } from "./send-file-ledger.js";
24
- import { TiDBResumeAnchorStore } from "./tidb-resume-anchor-store.js";
25
- import { PgResumeAnchorStore } from "./pg-resume-anchor-store.js";
26
- import { TiDBSessionPolicyStore } from "./tidb-session-policy-store.js";
27
- import { PgSessionPolicyStore } from "./pg-session-policy-store.js";
28
- import { TiDBWorkflowJournalStore } from "./tidb-workflow-journal-store.js";
29
- import { PgWorkflowJournalStore } from "./pg-workflow-journal-store.js";
30
- import { TiDBFileSnapshotStore } from "./tidb-file-snapshot-store.js";
31
- import { PgFileSnapshotStore } from "./pg-file-snapshot-store.js";
22
+ import { TiDBResumeAnchorStore, PgResumeAnchorStore } from "./resume-anchor-store-sql.js";
23
+ import { TiDBSessionPolicyStore, PgSessionPolicyStore } from "./session-policy-store-sql.js";
24
+ import { TiDBWorkflowJournalStore, PgWorkflowJournalStore } from "./workflow-journal-store-sql.js";
25
+ import { TiDBFileSnapshotStore, PgFileSnapshotStore } from "./file-snapshot-store-sql.js";
32
26
  import { MinioBlobBackend, SqlBlobBackend } from "./blob-backend.js";
33
27
  import { createTidbPool, ensureSchema as ensureTidbSchema } from "./tidb-pool.js";
34
28
  import { createPgPool, ensurePgSchema, pgPoolOptions } from "./pg-pool.js";
35
- import { TiDBRunStore } from "./tidb-run-store.js";
36
- import { PgRunStore } from "./pg-run-store.js";
37
- import { TiDBCheckpointStore } from "./tidb-checkpoint-store.js";
38
- import { PgCheckpointStore } from "./pg-checkpoint-store.js";
39
- import { TiDBApprovalStore } from "./tidb-approval-store.js";
40
- import { PgApprovalStore } from "./pg-approval-store.js";
41
- import { TiDBToolResultStore } from "./tidb-tool-result-store.js";
42
- import { PgToolResultStore } from "./pg-tool-result-store.js";
43
- import { TiDBImageIndex } from "./tidb-image-index.js";
44
- import { PgImageIndex } from "./pg-image-index.js";
45
- import { TiDBImageBake } from "./tidb-image-bake.js";
46
- import { PgImageBake } from "./pg-image-bake.js";
47
- import { TiDBBreakerState } from "./tidb-breaker-state.js";
48
- import { PgBreakerState } from "./pg-breaker-state.js";
29
+ import { TiDBRunStore, PgRunStore } from "./run-store-sql.js";
30
+ import { TiDBCheckpointStore, PgCheckpointStore } from "./checkpoint-store-sql.js";
31
+ import { TiDBToolResultStore, PgToolResultStore } from "./tool-result-store-sql.js";
32
+ import { TiDBImageIndex, PgImageIndex } from "./image-index-sql.js";
33
+ import { TiDBImageBake, PgImageBake } from "./image-bake-store-sql.js";
34
+ import { TiDBBreakerState, PgBreakerState } from "./breaker-state-sql.js";
49
35
  import { TiDBCostQuota } from "./tidb-cost-quota.js";
50
36
  import { PgCostQuota } from "./pg-cost-quota.js";
51
37
  import { TiDBRateLimiter } from "./tidb-rate-limiter.js";
@@ -117,7 +103,6 @@ class TiDBBackend {
117
103
  completionInbox(onWarn) { return new TiDBWorkflowCompletionInbox(this.pool, onWarn); } // P1: cross-replica push half
118
104
  notifyJournal() { return new TiDBWorkflowNotifyJournalStore(this.pool); } // 1.108: cross-replica at-least-once notify
119
105
  checkpoint(logger) { return new TiDBCheckpointStore(this.pool, logger); }
120
- approval() { return new TiDBApprovalStore(this.pool); }
121
106
  toolResult() { return new TiDBToolResultStore(this.pool); }
122
107
  imageIndex() { return new TiDBImageIndex(this.pool); }
123
108
  imageBake() { return new TiDBImageBake(this.pool); }
@@ -151,7 +136,6 @@ class PgBackend {
151
136
  completionInbox(onWarn) { return new PgWorkflowCompletionInbox(this.pool, onWarn); } // P1: cross-replica push half
152
137
  notifyJournal() { return new PgWorkflowNotifyJournalStore(this.pool); } // 1.108: cross-replica at-least-once notify
153
138
  checkpoint(logger) { return new PgCheckpointStore(this.pool, logger); }
154
- approval() { return new PgApprovalStore(this.pool); }
155
139
  toolResult() { return new PgToolResultStore(this.pool); }
156
140
  imageIndex() { return new PgImageIndex(this.pool); }
157
141
  imageBake() { return new PgImageBake(this.pool); }
@@ -198,32 +198,8 @@ export const SCHEMA_STATEMENTS = [
198
198
  PRIMARY KEY (session_id),
199
199
  KEY idx_task (task_id)
200
200
  )`,
201
- // Human-in-the-loop approval gate (F4). A pending row is durable so an operator's decision can
202
- // arrive on any instance; the instance running the task polls this row to release its wait.
203
- `CREATE TABLE IF NOT EXISTS approval (
204
- id VARCHAR(64) NOT NULL,
205
- task_id VARCHAR(64) NULL,
206
- session_id VARCHAR(64) NULL,
207
- owner VARCHAR(190) NULL,
208
- -- scope — single-DB fleet scope guard (defense-in-depth): the run's tenant identity (owner-sourced), so the
209
- -- approval READ paths (getStatus / get / listPending / decide) can null-safe-filter on it. A NULL scope row
210
- -- (an untenanted run — and, on the pre-folding schema, any PRE-MIGRATION row) is matched by a NULL scope arg
211
- -- via MySQL <=> / PG IS NOT DISTINCT FROM — see tidb-approval-store.ts / pg-approval-store.ts.
212
- -- expireStale deliberately stays GLOBAL (fleet maintenance, not a tenant read).
213
- scope VARCHAR(190) NULL,
214
- tool_name VARCHAR(190) NOT NULL,
215
- args JSON NULL,
216
- status VARCHAR(16) NOT NULL,
217
- reason TEXT NULL,
218
- decided_by VARCHAR(190) NULL,
219
- created_at DATETIME(3) NOT NULL,
220
- decided_at DATETIME(3) NULL,
221
- PRIMARY KEY (id),
222
- KEY idx_owner_status (owner, status),
223
- -- idx_scope_status: the scope-filtered READ paths (listPending WHERE scope <=> ?) would full-scan without it.
224
- KEY idx_scope_status (scope, status),
225
- KEY idx_status (status)
226
- )`,
201
+ // ([2354]/[2356] A-5,5.0.0:F4 轮询车道的 `approval` DDL 已随车道退役——存量库里的旧表留置不动,
202
+ // 代码零读写;durable 门只用下面的 checkpoint 表。)
227
203
  // Durable-checkpoint (core 1.67 / design/45): a policy `ask` persisted as a suspended task so an operator
228
204
  // can `resume` it from any replica. `checkpoint` = core's blob + CAS status; `outcome` persisted on resolve
229
205
  // (R20 #1). Timestamps are epoch-ms BIGINT (the core Checkpoint uses ms numbers, not DATETIME).
@@ -396,7 +372,7 @@ export const SCHEMA_STATEMENTS = [
396
372
  // = JSON.stringify(TaskResult). The (run_id, ordinal) PK makes append IDEMPOTENT (ON DUPLICATE KEY = OVERWRITE /
397
373
  // last-write-wins) so a resumed run re-appending its replayed prefix verbatim leaves no dup — the byte-match of
398
374
  // core's InMemoryWorkflowJournalStore (byOrdinal.set). LOAD-BEARING (a resume replays it), unlike the best-effort
399
- // task_event observation log. GC'd by the run reaper (deleteByRun). See tidb-workflow-journal-store.ts.
375
+ // task_event observation log. GC'd by the run reaper (deleteByRun). See workflow-journal-store-sql.ts.
400
376
  `CREATE TABLE IF NOT EXISTS workflow_journal (
401
377
  run_id VARCHAR(191) NOT NULL,
402
378
  ordinal INT NOT NULL,
@@ -621,7 +597,7 @@ export const SCHEMA_STATEMENTS = [
621
597
  // Admission sentinel: ONE always-present row per builder pool, `SELECT … FOR UPDATE`-locked to SERIALIZE the
622
598
  // createBakeIfIdle busy-check+insert. A bare conditional INSERT…SELECT WHERE NOT EXISTS does NOT serialize two
623
599
  // concurrent admissions under TiDB's REPEATABLE READ (nor PG's READ COMMITTED), so without this lock two keyless
624
- // POSTs can both admit a non-dryRun bake. Dialect-uniform with the PG twin (pg-image-bake.ts).
600
+ // POSTs can both admit a non-dryRun bake. Dialect-uniform with the PG twin (image-bake-store-sql.ts).
625
601
  `CREATE TABLE IF NOT EXISTS image_bake_admit (
626
602
  pool VARCHAR(32) NOT NULL,
627
603
  PRIMARY KEY (pool)
@@ -8,7 +8,7 @@
8
8
  * {@link import("@sema-agent/core").InMemoryWorkflowJournalStore} (single-replica, lost on crash); this is the
9
9
  * byte-match durable twin so a workflow survives a replica crash and RESUMES (replay the longest unchanged
10
10
  * PREFIX of recorded `ctx.agent` results, run only the first changed/new call + everything after it live). The
11
- * journal is LOAD-BEARING (unlike the best-effort {@link import("./tidb-run-store.js")} observation layer):
11
+ * journal is LOAD-BEARING (unlike the best-effort {@link import("./run-store-sql.js")} observation layer):
12
12
  * append/load failures MUST throw — a silently-dropped entry would silently re-run already-done work.
13
13
  *
14
14
  * Schema = `workflow_journal (run_id, ordinal) PK` (DDL in tidb-pool.ts / pg-pool.ts ensureSchema). `ordinal`
@@ -1,5 +1,5 @@
1
1
  import { callKeyOrdinal } from "@sema-agent/core";
2
- import { oversizeJournalResult } from "./workflow-journal-limits.js";
2
+ import { oversizeJournalResult } from "@sema-agent/core";
3
3
  import { mysqlDriver, pgDriver } from "./sql-driver.js";
4
4
  const DEFAULT_RESUME_CLAIM_TTL_MS = 60 * 60 * 1000;
5
5
  export class SqlWorkflowJournalStore {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * design/80 D-G: principal crypto-binding (the direct-door IDENTITY gate) + the combined direct-door proof
3
- * verifier. Split out of `security.ts` (design/158 A13, internal-lossless — the facade re-exports every symbol
4
- * below unchanged; `verifyDirectDoorProof` imports {@link verifyApprovalHmac} from `./approval-hmac.js` for the
3
+ * verifier. Split out of `security.ts` (design/158 A13; consumers import from HERE [2354] cleared the security.ts compat re-exports;
4
+ * `verifyDirectDoorProof` imports {@link verifyApprovalHmac} from `./approval-hmac.js` for the
5
5
  * integrity half of the combined proof; `security.ts`'s own `verifiedPrincipal` imports {@link verifyPrincipalJwt}
6
6
  * from here for the direct-door identity branch).
7
7
  *
@@ -41,9 +41,10 @@ export interface PromptsDomainFaces {
41
41
  }
42
42
  /**
43
43
  * prompts 域候选门 v2(validateCenterPrompts 的双轴升级;整拒语义不变=任一在场轴坏形 ⇒ 整个 prompts
44
- * 面拒绝采用,LKG/内置继续服务)。两形都认:
45
- * - legacy 平铺( schemaVersion 键)= declaration 轴单轴(存量 center 停发平铺前的兼容窗);
46
- * - `{schemaVersion:1, declarations?, catalog?}`(registry-core `EffectivePromptsWire`)= 至少一轴。
44
+ * 面拒绝采用,LKG/内置继续服务)。唯一认可形=`{schemaVersion:1, declarations?, catalog?}`
45
+ * (registry-core `EffectivePromptsWire`)至少一轴。[2373]B-9(5.0.0):legacy 平铺兼容窗到期删——
46
+ * 0.13.0 起 EffectivePromptsWire 首字段是 `schemaVersion: z.ZodLiteral<1>`,与 server 共用 ^0.13.0
47
+ * 合规 center 不可能再发平铺;非合规体=响亮拒绝(整拒落 LKG/内置),不再静默吸收。
47
48
  * catalog 轴的语义权威=core `verifyPromptArtifact`(形/digest 逐位复算/ARTIFACT_LIMITS/compatibleCore
48
49
  * range 全在 core 一处——[1242]③ a 解,上限单真源永不漂)。
49
50
  */
@@ -3,7 +3,7 @@
3
3
  * lens2 §G:`config-lkg.ts → capabilities/center-prompts.ts` 是全仓唯一一条显式分层反向边,config 层
4
4
  * 值 import capabilities 层)。本模块只依赖 node 内置 + `@sema-agent/core`,不依赖 capabilities/
5
5
  * config 任何东西,config-lkg(LKG 读侧复判)与 capabilities(候选门)同引即无反向边。
6
- * center-prompts.ts 原位置 re-export 保兼容,语义/文案零改动——逐字搬运。
6
+ * 消费者直引本模块([2354] 兼容面全清:center-prompts.ts 的原位兼容 re-export 已删);语义/文案零改动——逐字搬运。
7
7
  *
8
8
  * ─── 以下为原 center-prompts.ts 的判形半场,注释原样保留 ───
9
9
  *
@@ -107,9 +107,10 @@ export const CORE_ENGINE_VERSION = (() => {
107
107
  })();
108
108
  /**
109
109
  * prompts 域候选门 v2(validateCenterPrompts 的双轴升级;整拒语义不变=任一在场轴坏形 ⇒ 整个 prompts
110
- * 面拒绝采用,LKG/内置继续服务)。两形都认:
111
- * - legacy 平铺( schemaVersion 键)= declaration 轴单轴(存量 center 停发平铺前的兼容窗);
112
- * - `{schemaVersion:1, declarations?, catalog?}`(registry-core `EffectivePromptsWire`)= 至少一轴。
110
+ * 面拒绝采用,LKG/内置继续服务)。唯一认可形=`{schemaVersion:1, declarations?, catalog?}`
111
+ * (registry-core `EffectivePromptsWire`)至少一轴。[2373]B-9(5.0.0):legacy 平铺兼容窗到期删——
112
+ * 0.13.0 起 EffectivePromptsWire 首字段是 `schemaVersion: z.ZodLiteral<1>`,与 server 共用 ^0.13.0
113
+ * 合规 center 不可能再发平铺;非合规体=响亮拒绝(整拒落 LKG/内置),不再静默吸收。
113
114
  * catalog 轴的语义权威=core `verifyPromptArtifact`(形/digest 逐位复算/ARTIFACT_LIMITS/compatibleCore
114
115
  * range 全在 core 一处——[1242]③ a 解,上限单真源永不漂)。
115
116
  */
@@ -118,10 +119,8 @@ export function validatePromptsDomain(raw) {
118
119
  return { ok: false, error: "prompts is not an object" };
119
120
  const w = raw;
120
121
  if (w.schemaVersion === undefined) {
121
- const legacy = validateCenterPrompts(raw);
122
- if (!legacy.ok)
123
- return legacy;
124
- return { ok: true, value: { declarations: legacy.value, identity: `${legacy.value.contentDigest}+-`, axes: ["declarations"] } };
122
+ // [2373]B-9:平铺形拒绝(兼容窗 5.0.0 到期)。文案带指引=下游冒烟立刻可自修,不是哑谜。
123
+ return { ok: false, error: "prompts payload has no schemaVersion — the legacy flat shape was retired in 5.0.0; wrap as {schemaVersion:1, declarations:{...}} (registry-core EffectivePromptsWire)" };
125
124
  }
126
125
  if (w.schemaVersion !== 1)
127
126
  return { ok: false, error: `unsupported prompts schemaVersion ${String(w.schemaVersion)}` };
@@ -19,7 +19,7 @@
19
19
  * router's chosen arm per trap; the objective hidden-test oracle confirms danger→SUP prevents + competent→single
20
20
  * is not-worse) BEFORE it is wired into the live task path — never ship an unvalidated router.
21
21
  */
22
- import { canonicalToolName } from "@sema-agent/core";
22
+ import {} from "@sema-agent/core";
23
23
  /**
24
24
  * The routing decision (pure). Order matters: explicit caller choice first, then (a) danger, then (b) structural,
25
25
  * else the single default. `team` is NEVER produced here — it only ever appears via {@link RoutingSignals.explicitMode}.
@@ -105,7 +105,7 @@ export function isIsolatedExecEnv(provider, runtimeClass) {
105
105
  * a notebook ungated (the exact "write tool bypasses the SUP gate" hole the review-HIGH closed for Edit/Write).
106
106
  * Curated, NOT derived from HAND_TOOL_EFFECTS: that taxonomy is replay-safety (Write="idempotent"; Bash="write" but
107
107
  * shell-gated), not "is an fs mutation". CANONICAL names only (core 1.202 retired MultiEdit into an Edit alias —
108
- * `canonicalToolName` in the check below folds a replayed legacy "MultiEdit" call onto "Edit", so batch edits stay
108
+ * (5.0.0:折叠面退役——重放的旧名调用由 core roster 层响亮 miss,不再折到 "Edit";raw 直比)
109
109
  * gated without a stale alias entry here). */
110
110
  const WRITE_HAND_TOOLS = new Set(["Edit", "Write", "NotebookEdit"]);
111
111
  /**
@@ -119,7 +119,7 @@ const WRITE_HAND_TOOLS = new Set(["Edit", "Write", "NotebookEdit"]);
119
119
  export function supPostureOverrides() {
120
120
  const ask = (toolName) => ({ action: "ask", message: `${toolName} gated by supervisor routing (capability-danger task)`, decisionReason: "rule" });
121
121
  const writeGate = {
122
- check: (req) => (WRITE_HAND_TOOLS.has(canonicalToolName(req.toolName)) ? ask(req.toolName) : { action: "allow" }),
122
+ check: (req) => (WRITE_HAND_TOOLS.has(req.toolName) ? ask(req.toolName) : { action: "allow" }),
123
123
  };
124
124
  return { shellGate: "always", toolPolicy: writeGate };
125
125
  }
package/dist/run-local.js CHANGED
@@ -30,7 +30,8 @@ import { Runner, uuidv7, parseModelMention, FileStorageBackend, NodeLspManager,
30
30
  import { createBrain } from "./brain.js";
31
31
  import { ForkRoutingSessionStore } from "./plugins/fork-routing-session-store.js";
32
32
  import { taskWallClockSec } from "./task-workflow.js";
33
- import { validatePromptsDomain, applyCatalogToSource, CORE_ENGINE_VERSION } from "./capabilities/center-prompts.js";
33
+ import { applyCatalogToSource } from "./capabilities/center-prompts.js";
34
+ import { validatePromptsDomain, CORE_ENGINE_VERSION } from "./prompts-domain-validate.js";
34
35
  import { loadConfig, logConfigDiagnostics, numEnv } from "./config.js";
35
36
  import { createConfigProvider } from "./config-provider.js";
36
37
  import { applyEffective, resolveMcpServers, mcpForScenario } from "./config-center/facade.js";
@@ -40,7 +41,8 @@ import { loadSkills } from "./capabilities/skills.js";
40
41
  import { GiteaClient } from "./capabilities/repo-tools.js";
41
42
  import { webSearchConfigFromEnv, createWebSearchBackend } from "./plugins/web-search.js";
42
43
  import { buildScenarios, selectScenario, centerScenarios } from "./capabilities/scenarios.js";
43
- import { HttpError, memoryEngineBackendFor, memorySpecForRequest } from "./security.js";
44
+ import { HttpError } from "./security.js";
45
+ import { memoryEngineBackendFor, memorySpecForRequest } from "./memory-scope.js";
44
46
  import { createMemorySyncRunner, createMemorySyncTransport } from "./memory-sync-client.js";
45
47
  import { buildPricing } from "./budget.js";
46
48
  import { createKeyResolver } from "./key-resolver.js";
@@ -395,7 +397,6 @@ export async function runLocal(argv, deps = {}) {
395
397
  const webSearch = webSearchCfg ? createWebSearchBackend(webSearchCfg) : undefined;
396
398
  const scenarioDeps = {
397
399
  runner, subRunner, model: "default", skills, repoClient, metrics, logger,
398
- oaApiBaseUrl: config.oaApiBaseUrl, oaServiceToken: config.oaServiceToken, oaIssue: config.oaIssue,
399
400
  ...(webSearch ? { webSearch } : {}),
400
401
  brandIdentity: true, // run-local is always a local/TOC deployment → brand the default scenario as Sema.
401
402
  };
@@ -411,7 +412,7 @@ export async function runLocal(argv, deps = {}) {
411
412
  const requested = args.scenario ?? config.defaultScenario;
412
413
  const scenarioName = scenarios[requested] ? requested : "default";
413
414
  // A scenario may THROW HttpError synchronously when a prerequisite is unmet (e.g. `scan` needs
414
- // GIT_API_BASEURL + a repo; `oa` needs OA_* + an authenticated principal neither of which a one-shot CLI
415
+ // GIT_API_BASEURL + a repo — which a one-shot CLI may not
415
416
  // supplies). The server catches this in resolveSpec/prepareSpec and returns a clean 4xx; here we mirror that
416
417
  // with the doctor-style UX (message to stderr + exit 2) instead of letting it bubble to the fatal exit-1 path.
417
418
  let cap;
package/dist/runs.js CHANGED
@@ -65,10 +65,12 @@ export async function backgroundAgentOutput(registry, handle, access, agentStore
65
65
  * onServedTerminal (ack the completion as served) and suppress the workflow completion push. Refusals
66
66
  * return the registry's own not_found shape, indistinguishable from an unknown handle (the route 404s it). */
67
67
  const TASK_HANDLE_KINDS = new Set(["background_bash", "monitor", "background_agent"]);
68
- /** 1.250 复审 F1(HIGH):durable 回落的**形判门**——`getAccessibleTask` 是精确键(不 trim、不查 legacy
69
- * 别名),而 core `pollTask/stopTask` 是通用解析面(先 trim、`resolveInternal` legacyToTaskId
70
- * stopTask 还有 byName 臂)。裸 `!row` 回落会让垫充空白句柄(" "+wfId)/legacy shellId/agent 名字从
71
- * 回落缝穿进 live 分支——kind 门要防的 onServedTerminal/游标消费/按名 stop 全部复活(复审实测复现)
68
+ /** 1.250 复审 F1(HIGH):durable 回落的**形判门**——`getAccessibleTask` 是精确键(不 trim、不查
69
+ * 别名),而 core `pollTask/stopTask` 是通用解析面(先 trim;[2380] RB-479-A②:`legacyToTaskId`
70
+ * shellId 索引已随 5.0.0 整族删,b* task_id 是唯一 registry 地址——本门防的「legacy shellId 穿缝」
71
+ * 一臂如今在 core 层就响亮 not_found;stopTask 仍有 byName )。裸 `!row` 回落会让垫充空白句柄
72
+ * (" "+wfId)/agent 名字从回落缝穿进 live 分支——kind 门要防的 onServedTerminal/游标消费/按名 stop
73
+ * 全部复活(复审实测复现)。
72
74
  * 只有 **a\* 精确形**才回落:`DURABLE_AGENT_HANDLE_RE` = core 公共导出(core 1.369,[1518] ask 即答
73
75
  * ——两边判词同源,镜像私拷已删)。残余(documented):恰为 a\* 形的 agent **名字**
74
76
  * 在无 durable 行时仍会进 core stopTask 的 byName 臂——同 access 元组内、名字域与句柄域同形的病态窄面,
@@ -526,8 +528,8 @@ promptManifests) {
526
528
  // the top stream NEVER carries it), so this sink is the ONLY path a tick reaches the top-run consumers. 1.78
527
529
  // (review HIGH): fan it out to the DURABLE event log too (via the shared whitelist+redact builder, fire-and-
528
530
  // forget — `++seq` is a sync increment so sink-vs-loop appends get unique seqs), not just the fleet bus —
529
- // previously no fleet bus wired ⇒ ticks dropped entirely, and the stream-switch task_progress case below is
530
- // forward-compat only (dead against core ≤1.208). core swallow-guards a throwing sink.
531
+ // previously no fleet bus wired ⇒ ticks dropped entirely, and the stream-switch task_progress case below was
532
+ // forward-compat then [2373]B-4:floor ^4.0.0 下它是热路径(腐注方向已翻转,勿按旧注当死支)。core swallow-guards a throwing sink.
531
533
  const fwdInternals = {
532
534
  onForwardEvent: (e) => {
533
535
  fleetPublisher?.onForwardEvent(e);
@@ -68,8 +68,9 @@ export interface EntitlementsResolverOpts {
68
68
  *
69
69
  * `autoMode`(core 1.276.0 `RuntimeCaps.autoMode`):auto-mode 分类器 per-principal
70
70
  * 开闸线,极性同 allowObservers(`=== true` 显式 opt-in,默认 OFF;真执行还要 deployment 装配
71
- * `RunnerDeps.autoMode` 分类器面=信任门,center 键只是 entitlement 半场)。registry-core 类型未收编
72
- * unknown 宽读透传(allowObservers 0.10.2 期同款先例);center 发键即活。 */
71
+ * `RunnerDeps.autoMode` 分类器面=信任门,center 键只是 entitlement 半场)。[2373]B-6a:registry-core
72
+ * 0.13.0 已把 autoMode 收进 EntitlementRuntimeCaps(types.d.ts:1786)——宽读逃逸期结束,现为类型直读
73
+ * (allowObservers 同款收编先例)。 */
73
74
  export declare function toCoreRuntimeCaps(ent: EntitlementRuntimeCaps | null | undefined): RuntimeCaps | undefined;
74
75
  /** A MISCONFIG diagnostic (review MEDIUM): a worker-scoped `wpt_<self>` pull token REQUIRES `?worker=<self>` to
75
76
  * resolve per-principal caps — so a `wpt_` token with NO `SEMA_REGISTRY_WORKER` set will 403
@@ -20,13 +20,13 @@ const defaultLogger = createLogger();
20
20
  *
21
21
  * `autoMode`(core 1.276.0 `RuntimeCaps.autoMode`):auto-mode 分类器 per-principal
22
22
  * 开闸线,极性同 allowObservers(`=== true` 显式 opt-in,默认 OFF;真执行还要 deployment 装配
23
- * `RunnerDeps.autoMode` 分类器面=信任门,center 键只是 entitlement 半场)。registry-core 类型未收编
24
- * unknown 宽读透传(allowObservers 0.10.2 期同款先例);center 发键即活。 */
23
+ * `RunnerDeps.autoMode` 分类器面=信任门,center 键只是 entitlement 半场)。[2373]B-6a:registry-core
24
+ * 0.13.0 已把 autoMode 收进 EntitlementRuntimeCaps(types.d.ts:1786)——宽读逃逸期结束,现为类型直读
25
+ * (allowObservers 同款收编先例)。 */
25
26
  export function toCoreRuntimeCaps(ent) {
26
27
  if (!ent)
27
28
  return undefined;
28
- // 宽读(additive wide-read):registry-core 0.10.3 类型未含 autoMode,center 下发先行时走 unknown 读。
29
- const autoMode = ent.autoMode;
29
+ const autoMode = ent.autoMode; // [2373]B-6a:0.13.0 类型直读(宽读逃逸已收编)
30
30
  const badCap = (v) => v !== undefined && typeof v !== "boolean";
31
31
  if (badCap(ent.allowWorkflows) || badCap(ent.forceDurableGate) || badCap(ent.allowFork) || badCap(ent.allowObservers) || badCap(autoMode)) {
32
32
  throw new Error("runtimeCaps from center carries a non-boolean cap (contract breach — fail closed)");
@@ -29,13 +29,10 @@ export type CommandRule = {
29
29
  command: string;
30
30
  decision: "allow" | "ask" | "deny";
31
31
  };
32
- /** True when `name` names a DELEGATION tool — the subagent tool (CC-187 canonical `"Agent"`, core 1.202
33
- * `DEFAULT_SUBAGENT_TOOL_NAME`; legacy alias `"Task"`). CANONICAL-space compare (`canonicalToolName`) so both
34
- * spellings match the pre-1.202 raw `!== "Task"` compare in the read-only strip (main.ts) silently stopped
35
- * matching when core renamed the tool (fail-open: a plan-mode / hands-read-only parent could delegate to a
36
- * WRITABLE-hands child, because core does not propagate handsReadOnly to a delegated child).
37
- * core 1.257 (design/136 BREAKING): the standalone `Fork` tool is retired — a fork is now
38
- * `Agent(subagent_type:"fork")`, i.e. an Agent call, already matched by DEFAULT_SUBAGENT_TOOL_NAME. */
32
+ /** True when `name` names a DELEGATION tool — the subagent tool(CC-187 canonical `"Agent"`,core
33
+ * `DEFAULT_SUBAGENT_TOOL_NAME`)。5.0.0 RB-476:折叠面退役,RAW 比对 core 单源常量——旧名("Task")
34
+ * core roster 层响亮 miss,不再需要归一;单源常量本身就防了当年 1.202 改名时裸字符串失配的
35
+ * fail-open(那个教训的解=引用常量,不是折叠)。 */
39
36
  export declare function isDelegationToolName(name: string): boolean;
40
37
  /** The hands-read-only DELEGATION STRIP (the main.ts governed-spec site, extracted here so the actual filter —
41
38
  * not just the name predicate — is pinned by tests): core does not propagate `handsReadOnly` to a delegated
@@ -23,17 +23,13 @@
23
23
  * path-prefixed commands all bypass the argv[0] match (they route to `ask`, fail-closed, but are not blocked by
24
24
  * name). Real isolation is the `executionEnv` sandbox. Same caveat core documents on `createCoarseCommandNamePolicy`.
25
25
  */
26
- import { canonicalToolName, combinePolicies, createCoarseCommandNamePolicy, DEFAULT_SUBAGENT_TOOL_NAME, parseLeadingCommandName, tightenTaskSpec, } from "@sema-agent/core";
27
- /** True when `name` names a DELEGATION tool — the subagent tool (CC-187 canonical `"Agent"`, core 1.202
28
- * `DEFAULT_SUBAGENT_TOOL_NAME`; legacy alias `"Task"`). CANONICAL-space compare (`canonicalToolName`) so both
29
- * spellings match the pre-1.202 raw `!== "Task"` compare in the read-only strip (main.ts) silently stopped
30
- * matching when core renamed the tool (fail-open: a plan-mode / hands-read-only parent could delegate to a
31
- * WRITABLE-hands child, because core does not propagate handsReadOnly to a delegated child).
32
- * core 1.257 (design/136 BREAKING): the standalone `Fork` tool is retired — a fork is now
33
- * `Agent(subagent_type:"fork")`, i.e. an Agent call, already matched by DEFAULT_SUBAGENT_TOOL_NAME. */
26
+ import { combinePolicies, createCoarseCommandNamePolicy, DEFAULT_SUBAGENT_TOOL_NAME, parseLeadingCommandName, tightenTaskSpec, } from "@sema-agent/core";
27
+ /** True when `name` names a DELEGATION tool — the subagent tool(CC-187 canonical `"Agent"`,core
28
+ * `DEFAULT_SUBAGENT_TOOL_NAME`)。5.0.0 RB-476:折叠面退役,RAW 比对 core 单源常量——旧名("Task")
29
+ * core roster 层响亮 miss,不再需要归一;单源常量本身就防了当年 1.202 改名时裸字符串失配的
30
+ * fail-open(那个教训的解=引用常量,不是折叠)。 */
34
31
  export function isDelegationToolName(name) {
35
- const c = canonicalToolName(name);
36
- return c === DEFAULT_SUBAGENT_TOOL_NAME;
32
+ return name === DEFAULT_SUBAGENT_TOOL_NAME;
37
33
  }
38
34
  /** The hands-read-only DELEGATION STRIP (the main.ts governed-spec site, extracted here so the actual filter —
39
35
  * not just the name predicate — is pinned by tests): core does not propagate `handsReadOnly` to a delegated
@@ -77,10 +73,9 @@ function createCommandAskListPolicy(askCommands, tools = COARSE_SHELL_TOOLS) {
77
73
  const ask = (message) => ({ action: "ask", message, decisionReason: "rule" });
78
74
  return {
79
75
  check(req) {
80
- // Out of scope for non-shell tools: this gate only speaks about shell command names. Canonical-space
81
- // lookup ("Bash" has no alias today — identity; uniform with every other service policy face, so a
82
- // future core alias or a pre-rename durable replay can't slip the gate).
83
- if (!shellTools.has(canonicalToolName(req.toolName)))
76
+ // Out of scope for non-shell tools: this gate only speaks about shell command names. RAW(5.0.0):
77
+ // live 名恒 canonical,pre-rename 重放由 core 响亮拒——折叠臂退役。
78
+ if (!shellTools.has(req.toolName))
84
79
  return { action: "allow" };
85
80
  const command = req.args?.command;
86
81
  if (typeof command !== "string")
@@ -100,9 +95,9 @@ function createCommandAskListPolicy(askCommands, tools = COARSE_SHELL_TOOLS) {
100
95
  * (letters/digits and `. _ - +`, covering `python3.11`/`docker-compose`/`g++`) and reject the rest FAIL-LOUD at
101
96
  * config-apply. 🔴 Kept ALIGNED with the `@sema-agent/registry-core` contract-layer regex (center fixed the
102
97
  * glob→exact contract bug in 0.1.26 + publish-validates with this SAME pattern) so the contract gate and this
103
- * defense-in-depth gate agree. The dep is
104
- * `^0.1.26` (additive-compatible), so an additive contract bump stays aligned; a contract regex CHANGE would
105
- * need this updated in lockstep (the two layers are coupled by design, not by a frozen byte-equality guarantee). */
98
+ * defense-in-depth gate agree. [2373]B-11:旧注靠「dep=^0.1.26 additive 窗」论证对齐,地板抬到 ^0.13.0 后
99
+ * 该论证失效——现由机器钉逐字节对表(test/runtime-governance.test.ts 读安装包正则比对),lockstep 不再
100
+ * 是注释请求。2026-08-02 亲核 0.13.0 dist/types.js:703:两正则逐字节相同。 */
106
101
  const VALID_COMMAND_NAME = /^[A-Za-z0-9._+-]+$/;
107
102
  /** The three legal per-command decisions (mirrors the registry `runtime.commandPolicy[].decision` enum). */
108
103
  const VALID_DECISIONS = new Set(["allow", "ask", "deny"]);
@@ -76,7 +76,7 @@ export declare function ensureSealedKeyStore(dir: string, logger?: Logger): Prom
76
76
  *
77
77
  * HONESTY over fake automation: that endpoint is ADMIN-gated, and a fleet worker only holds
78
78
  * SERVICE_PULL_TOKEN — so automatic registration works ONLY when the operator deliberately provides
79
- * an admin token (SEMA_REGISTRY_ADMIN_TOKEN / REGISTRY_ADMIN_TOKEN in this service's env). Without
79
+ * an admin token (SEMA_REGISTRY_ADMIN_TOKEN in this service's env; the REGISTRY_ADMIN_TOKEN alias was tombstoned in 5.0.0). Without
80
80
  * one we do the next-best REAL thing: print the FULL public key + id at boot (a public key is not a
81
81
  * secret) with the exact registration instructions, and warn that the web "paste key" face stays
82
82
  * dark for this host until an admin registers it. Never throws (fire-and-forget from boot).
@@ -150,7 +150,7 @@ export async function ensureSealedKeyStore(dir, logger) {
150
150
  *
151
151
  * HONESTY over fake automation: that endpoint is ADMIN-gated, and a fleet worker only holds
152
152
  * SERVICE_PULL_TOKEN — so automatic registration works ONLY when the operator deliberately provides
153
- * an admin token (SEMA_REGISTRY_ADMIN_TOKEN / REGISTRY_ADMIN_TOKEN in this service's env). Without
153
+ * an admin token (SEMA_REGISTRY_ADMIN_TOKEN in this service's env; the REGISTRY_ADMIN_TOKEN alias was tombstoned in 5.0.0). Without
154
154
  * one we do the next-best REAL thing: print the FULL public key + id at boot (a public key is not a
155
155
  * secret) with the exact registration instructions, and warn that the web "paste key" face stays
156
156
  * dark for this host until an admin registers it. Never throws (fire-and-forget from boot).
@@ -3,8 +3,6 @@ import { type SessionStore, type SessionTreeEntry } from "@sema-agent/core";
3
3
  import type { ServiceConfig } from "./config-types.js";
4
4
  import type { TaskRequestBody } from "./http/wire-types.js";
5
5
  import type { StagingHandle } from "./session-sync-kernel.js";
6
- export { parseApprovalHmacKeys, parsePrincipalJwks } from "./auth-keys.js";
7
- export type { ApprovalHmacKey, PrincipalJwtKey } from "./auth-keys.js";
8
6
  /** One row of the session-list projection (CC /resume picker) — the durable session abstraction's enumeration
9
7
  * output (§0.5). Mirrors {@link RunStore}'s shipped `SessionSummary` shape so the wire response is unchanged. */
10
8
  export interface SessionListItem {
@@ -215,7 +213,4 @@ export declare function ssoVerifiedPrincipal(req: IncomingMessage): string | und
215
213
  export declare function setSsoScope(req: IncomingMessage, scope: string): void;
216
214
  export declare function ssoVerifiedScope(req: IncomingMessage): string | undefined;
217
215
  export declare function verifiedPrincipal(req: IncomingMessage, config: ServiceConfig): string | undefined;
218
- export { memoryScopeFor, memoryEngineRemoteLanePosture, memoryEngineBackendFor, memorySpecForRequest } from "./memory-scope.js";
219
- export { approvalHmacMessage, MAX_APPROVAL_REASON_CHARS, verifyApprovalHmac } from "./approval-hmac.js";
220
- export { verifyPrincipalJwt, approvalBnd, verifyDirectDoorProof } from "./principal-jwt.js";
221
216
  //# sourceMappingURL=security.d.ts.map
package/dist/security.js CHANGED
@@ -3,9 +3,8 @@ import { PROJECT_ID_REGEX } from "@sema-agent/registry-core";
3
3
  // design/158 A4: the env→key-set decoders (parseApprovalHmacKeys / parsePrincipalJwks + their row types) moved to
4
4
  // the leaf ./auth-keys.js so config.ts's env-load no longer value-imports this whole auth module (lens2 §F). The
5
5
  // verifiers that consume the parsed key-sets now live in ./approval-hmac.js / ./principal-jwt.js (design/158 A13);
6
- // the four names are RE-EXPORTED for compat.
7
- export { parseApprovalHmacKeys, parsePrincipalJwks } from "./auth-keys.js";
8
- import { memoryScopeFor } from "./memory-scope.js"; // design/158 N17: see re-export block below (moved to ./memory-scope.js)
6
+ // import all four names from ./auth-keys.js directly ([2354] 兼容面全清 — the compat re-export here is gone).
7
+ import { memoryScopeFor } from "./memory-scope.js"; // design/158 N17: moved to ./memory-scope.js (this file's createAuthorizer still calls it)
9
8
  // design/158 A13: the approval-envelope HMAC (integrity) group and the principal-JWT/direct-door (identity)
10
9
  // group moved VERBATIM to ./approval-hmac.js and ./principal-jwt.js respectively — this file's own
11
10
  // `verifiedPrincipal` still calls verifyPrincipalJwt for the direct-door branch (value import below); every
@@ -333,15 +332,12 @@ export function verifiedPrincipal(req, config) {
333
332
  }
334
333
  // design/158 N17: memoryScopeFor / memoryEngineRemoteLanePosture / memoryEngineBackendFor / memorySpecForRequest
335
334
  // moved VERBATIM to the leaf ./memory-scope.js (security.ts's name says auth; these four resolve memory-plane
336
- // config, unrelated). Re-exported here so existing importers (main.ts, config.ts, http/server.ts, run-local.ts,
337
- // index.ts, tests) keep working untouched — this file's own createAuthorizer below still calls memoryScopeFor.
338
- export { memoryScopeFor, memoryEngineRemoteLanePosture, memoryEngineBackendFor, memorySpecForRequest } from "./memory-scope.js";
339
- // design/158 A13: approval-envelope HMAC (integrity, {@link verifyApprovalHmac}/{@link approvalHmacMessage}/
340
- // MAX_APPROVAL_REASON_CHARS) and principal-JWT/direct-door proof (identity, {@link verifyPrincipalJwt}/
335
+ // config, unrelated). Import them from ./memory-scope.js directly ([2354] 兼容面全清 the compat re-export here
336
+ // is gone); this file's own createAuthorizer below still calls memoryScopeFor.
337
+ // design/158 A13: approval-envelope HMAC (integrity, verifyApprovalHmac/approvalHmacMessage/
338
+ // MAX_APPROVAL_REASON_CHARS) and principal-JWT/direct-door proof (identity, verifyPrincipalJwt/
341
339
  // approvalBnd/verifyDirectDoorProof) moved VERBATIM to ./approval-hmac.js and ./principal-jwt.js — this file
342
340
  // keeps only the authenticator/principal-shape/SSO-mount group (createAuthorizer, verifiedPrincipal,
343
- // assertPrincipalShape, principalFrom, setSsoPrincipal/setSsoScope) plus this re-export so existing
344
- // importers of the moved names keep working unchanged.
345
- export { approvalHmacMessage, MAX_APPROVAL_REASON_CHARS, verifyApprovalHmac } from "./approval-hmac.js";
346
- export { verifyPrincipalJwt, approvalBnd, verifyDirectDoorProof } from "./principal-jwt.js";
341
+ // assertPrincipalShape, principalFrom, setSsoPrincipal/setSsoScope). Import the moved names from their
342
+ // new homes directly ([2354] 兼容面全清 — the compat re-exports here are gone).
347
343
  //# sourceMappingURL=security.js.map
@@ -30,8 +30,6 @@ export interface FileSnapshotImportFace {
30
30
  * seam is absent (an older/in-memory dev store). Callers gate on the RETURN VALUE, not a separate `typeof` check,
31
31
  * so there is exactly one place that knows the shape of the probe. */
32
32
  export declare function fileSnapshotImportFace(fs: unknown): FileSnapshotImportFace | undefined;
33
- export { stagingIdFor, STAGING_ID_MARKER, realIdOfStaging, classifySyncRelationship, classifySyncRelationshipByIds, SyncConflictError } from "./session-sync-kernel.js";
34
- export type { StagingHandle, ImportStagingStore, SyncRelation } from "./session-sync-kernel.js";
35
33
  /**
36
34
  * The portable state of ONE session, ready to replay into another backend. Blobs are deliberately NOT inlined
37
35
  * (§5: a turn's working-tree blobs can be tens of MiB → OOM/413 if buffered); each snapshot carries only its