@sema-agent/core 5.19.0 → 5.21.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 (329) hide show
  1. package/CHANGELOG.md +102 -4
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-transcript-tool.d.ts +30 -0
  4. package/dist/agents/builtin-agents.d.ts +60 -0
  5. package/dist/agents/cascade.d.ts +107 -0
  6. package/dist/agents/cumulative-stats.d.ts +56 -0
  7. package/dist/agents/observer.d.ts +162 -0
  8. package/dist/agents/peer-admission.d.ts +95 -0
  9. package/dist/agents/repair-loop.d.ts +226 -0
  10. package/dist/agents/retain-ledger.d.ts +141 -0
  11. package/dist/agents/roster-store.d.ts +105 -0
  12. package/dist/agents/roster-store.js +3 -0
  13. package/dist/agents/send-message-tool.d.ts +92 -0
  14. package/dist/agents/session-util.d.ts +5 -0
  15. package/dist/agents/subagent-steps.d.ts +66 -0
  16. package/dist/agents/subagent.d.ts +600 -0
  17. package/dist/agents/suspend-guard.d.ts +29 -0
  18. package/dist/agents/teacher.d.ts +75 -0
  19. package/dist/agents/team.d.ts +120 -1
  20. package/dist/agents/tool-filter.d.ts +34 -0
  21. package/dist/agents/verify.d.ts +198 -0
  22. package/dist/bench/metrics.d.ts +455 -0
  23. package/dist/brain/anthropic.d.ts +30 -0
  24. package/dist/brain/circuit-breaker.d.ts +33 -0
  25. package/dist/brain/circuit-breaker.js +14 -3
  26. package/dist/brain/context-overflow.d.ts +60 -3
  27. package/dist/brain/degrading.d.ts +67 -0
  28. package/dist/brain/errors.d.ts +42 -0
  29. package/dist/brain/failover.d.ts +15 -0
  30. package/dist/brain/media-degrade.d.ts +39 -0
  31. package/dist/brain/model-presets.d.ts +31 -0
  32. package/dist/brain/open-responses.d.ts +19 -0
  33. package/dist/brain/openai.d.ts +46 -0
  34. package/dist/brain/reasoning.d.ts +106 -1
  35. package/dist/brain/repetition.d.ts +83 -0
  36. package/dist/brain/request-params.d.ts +56 -0
  37. package/dist/brain/retry.d.ts +46 -0
  38. package/dist/brain/routing.d.ts +12 -0
  39. package/dist/brain/status-sink.d.ts +30 -1
  40. package/dist/brain/stream-engine.d.ts +147 -0
  41. package/dist/brain/stream-shared.d.ts +34 -0
  42. package/dist/brain/terminal-cause.d.ts +31 -0
  43. package/dist/brain/timeout.d.ts +108 -0
  44. package/dist/brain/timeout.js +11 -0
  45. package/dist/brain/tool-call-id.d.ts +20 -0
  46. package/dist/brain/tool-call-repair.d.ts +13 -0
  47. package/dist/config/catalog.d.ts +47 -0
  48. package/dist/config/defaults.d.ts +33 -0
  49. package/dist/core/a2a-task-state.d.ts +53 -0
  50. package/dist/core/a2a.d.ts +51 -0
  51. package/dist/core/arg-summary.d.ts +62 -0
  52. package/dist/core/ask-question.d.ts +272 -2
  53. package/dist/core/auto-compaction.d.ts +467 -0
  54. package/dist/core/auto-compaction.js +20 -6
  55. package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
  56. package/dist/core/auto-mode-prompt.d.ts +27 -0
  57. package/dist/core/auto-mode.d.ts +54 -3
  58. package/dist/core/auto-promote.d.ts +100 -0
  59. package/dist/core/background-agent-store.d.ts +293 -0
  60. package/dist/core/background-agent-store.js +5 -0
  61. package/dist/core/background-shell.d.ts +110 -0
  62. package/dist/core/cache-break-detector.d.ts +34 -0
  63. package/dist/core/canonical-json.d.ts +57 -0
  64. package/dist/core/checkpoint-store.d.ts +1574 -16
  65. package/dist/core/compliance.d.ts +30 -0
  66. package/dist/core/consolidate-scope.d.ts +75 -0
  67. package/dist/core/context-edit.d.ts +99 -0
  68. package/dist/core/context-guard.d.ts +46 -0
  69. package/dist/core/exec-gate.d.ts +44 -0
  70. package/dist/core/exec-output-tail.d.ts +61 -0
  71. package/dist/core/file-snapshot-store.d.ts +104 -0
  72. package/dist/core/fs-write-gate-policy.d.ts +36 -0
  73. package/dist/core/git-worktree-env.d.ts +31 -0
  74. package/dist/core/governance-codes.d.ts +19 -0
  75. package/dist/core/hooks.d.ts +609 -1
  76. package/dist/core/human-input-projection.d.ts +37 -0
  77. package/dist/core/human-input-projection.js +13 -0
  78. package/dist/core/image-downsample.d.ts +74 -0
  79. package/dist/core/locked-config.d.ts +37 -0
  80. package/dist/core/lsp-diagnostics.d.ts +77 -0
  81. package/dist/core/lsp-protocol.d.ts +29 -0
  82. package/dist/core/lsp-session.d.ts +60 -1
  83. package/dist/core/lsp.d.ts +150 -1
  84. package/dist/core/mailbox-store.d.ts +57 -0
  85. package/dist/core/mailbox-store.js +2 -0
  86. package/dist/core/mcp.d.ts +385 -0
  87. package/dist/core/mcp.js +58 -11
  88. package/dist/core/media-byte-cap.d.ts +21 -0
  89. package/dist/core/memory-admission.d.ts +71 -0
  90. package/dist/core/memory-engine/content-origin.d.ts +64 -0
  91. package/dist/core/memory-engine/data-plane.d.ts +43 -0
  92. package/dist/core/memory-engine/dual-root.d.ts +24 -0
  93. package/dist/core/memory-engine/engine.d.ts +230 -0
  94. package/dist/core/memory-engine/engine.js +103 -35
  95. package/dist/core/memory-engine/file-backend.d.ts +155 -0
  96. package/dist/core/memory-engine/frontmatter.d.ts +16 -0
  97. package/dist/core/memory-engine/layout.d.ts +217 -0
  98. package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
  99. package/dist/core/memory-engine/migrate.d.ts +9 -0
  100. package/dist/core/memory-engine/scan.d.ts +12 -0
  101. package/dist/core/memory-engine/scope-contract.d.ts +61 -1
  102. package/dist/core/memory-engine/sync-client.d.ts +87 -0
  103. package/dist/core/memory-engine/sync.d.ts +60 -0
  104. package/dist/core/memory-engine/tools.d.ts +41 -0
  105. package/dist/core/memory-engine/types.d.ts +188 -0
  106. package/dist/core/memory-recall.d.ts +141 -0
  107. package/dist/core/memory-vector.d.ts +20 -0
  108. package/dist/core/memory.d.ts +458 -0
  109. package/dist/core/message-utils.d.ts +6 -0
  110. package/dist/core/oracle-isolation.d.ts +69 -0
  111. package/dist/core/permission-rule-consent.d.ts +138 -0
  112. package/dist/core/permission-rule-model.d.ts +122 -0
  113. package/dist/core/permission-rule-store.d.ts +119 -3
  114. package/dist/core/permission-rules.d.ts +87 -1
  115. package/dist/core/present-plan-tool.d.ts +20 -0
  116. package/dist/core/pricing.d.ts +26 -0
  117. package/dist/core/property-harness.d.ts +86 -0
  118. package/dist/core/protocol-naming.d.ts +38 -0
  119. package/dist/core/protocol-table.d.ts +61 -0
  120. package/dist/core/push-queue.d.ts +1 -0
  121. package/dist/core/remote-env.d.ts +383 -1
  122. package/dist/core/retention-policy.d.ts +40 -0
  123. package/dist/core/retention-policy.js +21 -0
  124. package/dist/core/retention.d.ts +51 -0
  125. package/dist/core/roles.d.ts +59 -0
  126. package/dist/core/runner/active-skill-scope.d.ts +34 -0
  127. package/dist/core/runner/assemble-result.d.ts +134 -0
  128. package/dist/core/runner/compaction-call-options.d.ts +97 -1
  129. package/dist/core/runner/grounding-signal.d.ts +10 -0
  130. package/dist/core/runner/image.d.ts +17 -0
  131. package/dist/core/runner/image.js +29 -15
  132. package/dist/core/runner/memory-consolidation.d.ts +60 -0
  133. package/dist/core/runner/prepare-memory.d.ts +59 -0
  134. package/dist/core/runner/prepare-task.d.ts +1011 -2
  135. package/dist/core/runner/prepare-task.js +51 -14
  136. package/dist/core/runner/prompt-suggestions.d.ts +7 -0
  137. package/dist/core/runner/runtask.d.ts +304 -3
  138. package/dist/core/runner/runtask.js +17 -2
  139. package/dist/core/runner/session-file-state-replay.d.ts +49 -0
  140. package/dist/core/runner/session-rule-policy.d.ts +58 -0
  141. package/dist/core/runner/strict-output-schema.d.ts +18 -3
  142. package/dist/core/runner/synthetic-tools.d.ts +113 -0
  143. package/dist/core/runner/teardown-bounded.d.ts +34 -0
  144. package/dist/core/runner/tool-disclosure.d.ts +227 -0
  145. package/dist/core/runner/tool-output-projection.d.ts +6 -0
  146. package/dist/core/runner/turn-attachments.d.ts +634 -0
  147. package/dist/core/runner/usage-accounting.d.ts +32 -0
  148. package/dist/core/runtime.d.ts +9 -0
  149. package/dist/core/safe-notify.d.ts +64 -0
  150. package/dist/core/safety-axis-vocab.d.ts +23 -0
  151. package/dist/core/safety-merge-corpus.d.ts +37 -0
  152. package/dist/core/scheduler.d.ts +121 -0
  153. package/dist/core/secret-env.d.ts +32 -0
  154. package/dist/core/select-model.d.ts +15 -0
  155. package/dist/core/sensitive-path-policy.d.ts +42 -0
  156. package/dist/core/session-policy-store.d.ts +94 -0
  157. package/dist/core/session-reconcile.d.ts +80 -0
  158. package/dist/core/session-store.d.ts +85 -0
  159. package/dist/core/session.d.ts +153 -0
  160. package/dist/core/shared-memory/contract.d.ts +22 -0
  161. package/dist/core/shared-memory/normalize.d.ts +123 -2
  162. package/dist/core/shared-memory/tools.d.ts +14 -0
  163. package/dist/core/shared-memory/types.d.ts +105 -0
  164. package/dist/core/shutdown-debug.d.ts +6 -0
  165. package/dist/core/side-query.d.ts +38 -0
  166. package/dist/core/side-query.js +6 -1
  167. package/dist/core/skill-tool-specifier.d.ts +72 -0
  168. package/dist/core/skills-directory.d.ts +100 -1
  169. package/dist/core/spec-contract.d.ts +89 -0
  170. package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
  171. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
  172. package/dist/core/store-contracts/contract-harness.d.ts +20 -0
  173. package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
  174. package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
  175. package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
  176. package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
  177. package/dist/core/strategy-store.d.ts +37 -0
  178. package/dist/core/stub-env.d.ts +7 -0
  179. package/dist/core/surrogate-safe-slice.d.ts +35 -0
  180. package/dist/core/task-notification.d.ts +202 -0
  181. package/dist/core/task-outcome.d.ts +53 -0
  182. package/dist/core/task-registry-agent.d.ts +337 -1
  183. package/dist/core/task-registry-agent.js +2 -0
  184. package/dist/core/task-registry-monitor.d.ts +12 -0
  185. package/dist/core/task-registry-shared.d.ts +540 -0
  186. package/dist/core/task-registry.d.ts +343 -0
  187. package/dist/core/task-registry.js +13 -2
  188. package/dist/core/task-tool-shape.d.ts +44 -0
  189. package/dist/core/tighten-task-spec.d.ts +21 -0
  190. package/dist/core/tool-detach.d.ts +21 -0
  191. package/dist/core/tool-errors.d.ts +131 -0
  192. package/dist/core/tool-errors.js +4 -0
  193. package/dist/core/tool-name-aliases.d.ts +27 -0
  194. package/dist/core/tool-policy.d.ts +555 -0
  195. package/dist/core/tool-policy.js +3 -0
  196. package/dist/core/tool-result-budget.d.ts +32 -0
  197. package/dist/core/tool-result-store.d.ts +174 -1
  198. package/dist/core/tools.d.ts +45 -0
  199. package/dist/core/trace.d.ts +323 -0
  200. package/dist/core/types.d.ts +3859 -2
  201. package/dist/core/untrusted-egress.d.ts +8 -0
  202. package/dist/core/untrusted-text.d.ts +156 -0
  203. package/dist/core/usage-window-store.d.ts +95 -0
  204. package/dist/core/version.d.ts +1 -0
  205. package/dist/core/warm-resume.d.ts +17 -0
  206. package/dist/core/wiring-manifest.d.ts +169 -0
  207. package/dist/core/with-retry.d.ts +24 -0
  208. package/dist/core/workflow-journal-store.d.ts +160 -0
  209. package/dist/core/workflow-run-store-contract.d.ts +25 -0
  210. package/dist/core/workflow-run-store.d.ts +119 -0
  211. package/dist/core/workflow-run-store.js +2 -0
  212. package/dist/engine/compaction/compaction.d.ts +256 -1
  213. package/dist/engine/compaction/utils.d.ts +94 -0
  214. package/dist/engine/execution-env/kill-tree.d.ts +29 -0
  215. package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
  216. package/dist/engine/harness/agent-harness.d.ts +116 -0
  217. package/dist/engine/harness/agent-harness.js +3 -14
  218. package/dist/engine/harness/messages.d.ts +15 -0
  219. package/dist/engine/harness/types.d.ts +464 -2
  220. package/dist/engine/llm/diagnostics.d.ts +4 -0
  221. package/dist/engine/llm/event-stream.d.ts +3 -0
  222. package/dist/engine/llm/index.d.ts +7 -0
  223. package/dist/engine/llm/types.d.ts +500 -3
  224. package/dist/engine/llm/validation.d.ts +3 -0
  225. package/dist/engine/loop/agent-loop.d.ts +87 -2
  226. package/dist/engine/loop/runtime-deps.d.ts +7 -0
  227. package/dist/engine/loop/types.d.ts +424 -0
  228. package/dist/engine/lsp/frame-decoder.d.ts +13 -0
  229. package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
  230. package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
  231. package/dist/engine/session/import-validate.d.ts +27 -0
  232. package/dist/engine/session/log-digest.d.ts +93 -0
  233. package/dist/engine/session/memory-repo.d.ts +6 -0
  234. package/dist/engine/session/memory-storage.d.ts +2 -0
  235. package/dist/engine/session/session.d.ts +75 -0
  236. package/dist/engine/session/storage-base.d.ts +8 -0
  237. package/dist/fixtures/index.d.ts +36 -0
  238. package/dist/index.d.ts +17 -2
  239. package/dist/index.js +1 -2
  240. package/dist/internal/harness-types.d.ts +6 -0
  241. package/dist/internal/harness.d.ts +11 -0
  242. package/dist/internal/llm.d.ts +6 -0
  243. package/dist/orchestration/builtin-workflows.d.ts +53 -0
  244. package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
  245. package/dist/orchestration/goal.d.ts +57 -0
  246. package/dist/orchestration/goal.js +3 -0
  247. package/dist/orchestration/run-spec.d.ts +42 -0
  248. package/dist/orchestration/run-spec.js +4 -0
  249. package/dist/orchestration/run-workflow-tool.d.ts +169 -0
  250. package/dist/orchestration/workflow-governance.d.ts +61 -0
  251. package/dist/orchestration/workflow-meta.d.ts +28 -0
  252. package/dist/orchestration/workflow-observe.d.ts +60 -0
  253. package/dist/orchestration/workflow-primitives.d.ts +23 -1
  254. package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
  255. package/dist/orchestration/workflow-script-runner.d.ts +88 -0
  256. package/dist/orchestration/workflow-script-store.d.ts +98 -0
  257. package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
  258. package/dist/orchestration/workflow-types.d.ts +169 -2
  259. package/dist/orchestration/workflow.d.ts +358 -0
  260. package/dist/orchestration/workflow.js +13 -2
  261. package/dist/prompt-assembly/artifact-store.d.ts +33 -0
  262. package/dist/prompt-assembly/artifact.d.ts +25 -0
  263. package/dist/prompt-assembly/assemble.d.ts +20 -0
  264. package/dist/prompt-assembly/composer.d.ts +29 -0
  265. package/dist/prompt-assembly/epoch.d.ts +55 -1
  266. package/dist/prompt-assembly/event-registry.d.ts +35 -0
  267. package/dist/prompt-assembly/explain.d.ts +12 -0
  268. package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
  269. package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
  270. package/dist/prompt-assembly/types.d.ts +115 -0
  271. package/dist/prompts/coordinator.d.ts +27 -0
  272. package/dist/prompts/default.d.ts +539 -0
  273. package/dist/prompts/simple-sections.d.ts +45 -0
  274. package/dist/prompts/supervisor.d.ts +66 -0
  275. package/dist/scenarios/env.d.ts +28 -0
  276. package/dist/scenarios/full-body.d.ts +50 -0
  277. package/dist/scenarios/scenario-registry.d.ts +60 -0
  278. package/dist/scenarios/teacher-quickstart.d.ts +27 -0
  279. package/dist/server/http.d.ts +17 -0
  280. package/dist/stores/cc/lockfile.d.ts +6 -0
  281. package/dist/stores/cc/mailbox-store.d.ts +8 -0
  282. package/dist/stores/cc/roster-adapter.d.ts +4 -0
  283. package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
  284. package/dist/stores/file/background-agent-store.d.ts +24 -0
  285. package/dist/stores/file/background-agent-store.js +2 -1
  286. package/dist/stores/file/checkpoint-store.d.ts +38 -0
  287. package/dist/stores/file/file-snapshot-store.d.ts +25 -0
  288. package/dist/stores/file/fs-atomic.d.ts +155 -0
  289. package/dist/stores/file/index.d.ts +89 -0
  290. package/dist/stores/file/mailbox-store.d.ts +36 -0
  291. package/dist/stores/file/mailbox-store.js +2 -0
  292. package/dist/stores/file/memory-store.d.ts +82 -0
  293. package/dist/stores/file/permission-rule-store.d.ts +79 -0
  294. package/dist/stores/file/session-policy-store.d.ts +28 -0
  295. package/dist/stores/file/session-store.d.ts +40 -0
  296. package/dist/stores/file/shared-ledger.d.ts +83 -0
  297. package/dist/stores/file/tool-result-store.d.ts +11 -0
  298. package/dist/stores/file/usage-window-store.d.ts +18 -0
  299. package/dist/stores/file/workflow-journal-store.d.ts +100 -0
  300. package/dist/stores/file/workflow-run-store.d.ts +11 -0
  301. package/dist/stores/file/workflow-run-store.js +2 -0
  302. package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
  303. package/dist/tools/fs/encoding.d.ts +60 -0
  304. package/dist/tools/fs/fs-bash.d.ts +133 -0
  305. package/dist/tools/fs/fs-pdf.d.ts +28 -0
  306. package/dist/tools/fs/fs-search-tools.d.ts +5 -0
  307. package/dist/tools/fs/fs-shared.d.ts +360 -0
  308. package/dist/tools/fs/fs-write.d.ts +16 -0
  309. package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
  310. package/dist/tools/fs/index.d.ts +79 -0
  311. package/dist/tools/fs/notebook.d.ts +56 -0
  312. package/dist/tools/fs/pdf.d.ts +70 -0
  313. package/dist/tools/fs/pdf.js +8 -2
  314. package/dist/tools/fs/repo-map.d.ts +10 -0
  315. package/dist/tools/fs/safety.d.ts +376 -0
  316. package/dist/tools/fs/search.d.ts +131 -0
  317. package/dist/tools/loop-tick.d.ts +24 -0
  318. package/dist/tools/monitor.d.ts +55 -0
  319. package/dist/tools/scheduler-tools.d.ts +51 -0
  320. package/dist/tools/sql-adapters.d.ts +18 -0
  321. package/dist/tools/sql.d.ts +25 -0
  322. package/dist/tools/task-list.d.ts +77 -0
  323. package/dist/tools/todo.d.ts +8 -0
  324. package/dist/tools/web.d.ts +184 -0
  325. package/dist/tools/web.js +32 -5
  326. package/dist/tools/worktree.d.ts +81 -0
  327. package/package.json +2 -2
  328. package/dist/tools/gitea-issue.d.ts +0 -13
  329. package/dist/tools/gitea-issue.js +0 -75
@@ -1,9 +1,17 @@
1
1
  import type { NormalizedMemorySpec } from "./memory.js";
2
+ /** Where a requested org scope came from — the trust axis of the dual-origin model above. */
2
3
  export type MemoryScopeOrigin = "deployment" | "request";
4
+ /** One org scope submitted for admission, with its origin. */
3
5
  export interface MemoryScopeRequest {
4
6
  scope: string;
5
7
  origin: MemoryScopeOrigin;
6
8
  }
9
+ /**
10
+ * The resolver's verdict — exactly two states. `ok: true` carries the FROZEN admitted projection:
11
+ * `scopes` must be a subset of the requested org scopes (an unrequested grant is a resolver fault ⇒
12
+ * refused), and `writeScope` is the explicit org write grant (`null` = org write face stays
13
+ * read-only). `ok: false` refuses the whole prepare.
14
+ */
7
15
  export type MemoryAdmissionVerdict = {
8
16
  ok: true;
9
17
  scopes: readonly string[];
@@ -12,40 +20,103 @@ export type MemoryAdmissionVerdict = {
12
20
  ok: false;
13
21
  reason: string;
14
22
  };
23
+ /**
24
+ * The trusted deployment resolver ({@link import("./types.js").RunnerDeps.memoryScopeAdmission}).
25
+ * Receives ONLY the org-parsed scopes (non-org scopes are not its business), each tagged with its
26
+ * origin, plus the run's principal. Both async and sync forms are accepted.
27
+ */
15
28
  export type MemoryScopeAdmission = (input: {
16
29
  principal: string | undefined;
17
30
  requested: ReadonlyArray<MemoryScopeRequest>;
18
31
  requestedWriteScope: MemoryScopeRequest | null;
19
32
  }) => MemoryAdmissionVerdict | Promise<MemoryAdmissionVerdict>;
33
+ /** Inputs to {@link admitMemoryScopes} — assembled by the prepare path (prepare-memory.ts). */
20
34
  export interface MemoryAdmissionInput {
21
35
  memorySpec: NormalizedMemorySpec;
22
36
  principal: string | undefined;
23
37
  admission: MemoryScopeAdmission | undefined;
38
+ /** The deployment's self-certified org scopes (`RunnerDeps.deploymentMemoryScopes`). */
24
39
  deploymentScopes: ReadonlySet<string>;
40
+ /** Compliance capability `org_memory_mount` denied for this principal (the veto covers the
41
+ * REQUEST-origin plane — deployment-origin scopes are the operator's own declaration). */
25
42
  orgMemoryDenied: boolean;
43
+ /** True when the denial above came from a compliance-resolver fault (transient code family). */
26
44
  complianceDegraded: boolean;
45
+ /** The parent chain's frozen admitted org set; `undefined` on a top-level task. A delegated child
46
+ * with an absent/older-shape chain gets the fail-closed empty set from the caller. */
27
47
  parentAdmittedOrgScopes: readonly string[] | undefined;
48
+ /** The SESSION freeze (resume legs): this session's own verdict at suspend. `undefined` = no
49
+ * prior adjudication. Constrains the FINAL admitted projection regardless of origin — a
50
+ * request-origin scope outside it refuses the prepare; a deployment-origin scope outside it is
51
+ * dropped and disclosed; a write grant absent from it collapses to read-only. */
28
52
  priorOwnVerdict: OwnOrgAdmissionVerdict | undefined;
53
+ /** The monotonic governance-provenance bit (adversarial round 5): true when this leg's TREE is
54
+ * org-governed — the deployment surface is configured here, or ANY ancestor/prior leg recorded
55
+ * the bit (`InheritedGate.orgAdmissionGoverned`, persisted on checkpoints). Counts as governance
56
+ * evidence even when every admitted set en route is EMPTY: a governed parent's org-less child,
57
+ * resumed on a surface-less worker, must still refuse org-shaped non-v2 scopes. Trees that never
58
+ * had a governance surface never mint the bit and keep the opaque posture. */
29
59
  governedProvenance: boolean;
30
60
  }
61
+ /** The admission outcome the prepare path applies to the memory spec before materialization. */
31
62
  export interface MemoryAdmissionOutcome {
63
+ /** The spec's read layering with any resolver-dropped DEPLOYMENT-origin org scopes removed. */
32
64
  scopes: string[];
65
+ /** The effective write face (org write not explicitly granted ⇒ narrowed to `null`). */
33
66
  writeScope: string | null;
67
+ /** The frozen verdict for the child chain: every org scope this task actually mounts. */
34
68
  admittedOrgScopes: string[];
69
+ /** Deployment-origin org scopes narrowed away (by a present resolver, or by the session freeze) —
70
+ * disclosed, never silent. */
35
71
  droppedDeploymentScopes: string[];
72
+ /** True when an org writeScope was narrowed to read-only (disclosed by the caller). */
36
73
  writeScopeNarrowed: boolean;
74
+ /** The session's own frozen verdict to PERSIST at suspend — present iff this leg ADJUDICATED an
75
+ * org plane (the spec requested org scopes), including the adjudicated-empty case. `undefined`
76
+ * for an org-less task (nothing to freeze). */
37
77
  ownVerdict: OwnOrgAdmissionVerdict | undefined;
38
78
  }
79
+ /**
80
+ * Fold the delegation-chain FREEZE a prepare leg runs under (adversarial-review adoption,
81
+ * 2026-08-05). For a DELEGATED leg an undefined chain verdict reads fail-closed as the EMPTY set
82
+ * (an older-shape chain must never read as "unconstrained"); a top-level leg simply has no chain
83
+ * constraint. The SESSION freeze (the leg's own suspend-time verdict) is a separate input to
84
+ * {@link admitMemoryScopes} (`priorOwnVerdict`) — it must constrain the FINAL admitted projection
85
+ * regardless of origin (deployment-origin scopes bypass the chain freeze, not the session freeze),
86
+ * so it cannot ride this chain-side fold.
87
+ */
39
88
  export declare function foldAdmissionFreeze(input: {
40
89
  delegated: boolean;
41
90
  inherited: readonly string[] | undefined;
42
91
  }): readonly string[] | undefined;
92
+ /**
93
+ * The session's OWN frozen org verdict: what THIS session actually mounted (and what write grant it
94
+ * held) at its last suspend. Persisted on the checkpoint (ownAdmittedOrgScopes /
95
+ * ownAdmittedOrgWriteScope) — including an ADJUDICATED-EMPTY `scopes: []` (a session whose whole org
96
+ * request was narrowed away must not read as "org-less" on resume). `writeScope: null` = the org
97
+ * write face was read-only.
98
+ */
43
99
  export interface OwnOrgAdmissionVerdict {
44
100
  scopes: readonly string[];
45
101
  writeScope: string | null;
46
102
  }
103
+ /**
104
+ * #22 — read a durable background-agent row's recorded org verdict (module header, cross-process
105
+ * arm). TOTAL by construction: it answers a verdict for every row, so no caller ever has an
106
+ * "unknown" to fold. An absent field is the ZERO verdict (`{scopes: [], writeScope: null}`), never
107
+ * `undefined` — `undefined` is this module's spelling of "no prior adjudication constrains this
108
+ * leg", and handing that to a leg whose original verdict cannot be proven is precisely the
109
+ * widening the record exists to prevent. Structural parameter (not the record type) so the record
110
+ * schema keeps its single owner and this module stays free of a store import.
111
+ */
47
112
  export declare function readDurableOrgAdmission(row: {
48
113
  admittedOrgScopes?: readonly string[];
49
114
  admittedOrgWriteScope?: string | null;
50
115
  }): OwnOrgAdmissionVerdict;
116
+ /**
117
+ * Adjudicate the org scopes of a task's normalized memory spec. Returns the outcome to apply, or
118
+ * throws a coded refusal (`memory.admission_required` — transient control-plane absence/fault;
119
+ * `memory.admission_denied` — terminal policy refusal; `config.compliance_denied`/`_required` — the
120
+ * compliance veto). A spec with no org scopes passes through untouched (zero cost, zero change).
121
+ */
51
122
  export declare function admitMemoryScopes(input: MemoryAdmissionInput): Promise<MemoryAdmissionOutcome>;
@@ -1,27 +1,91 @@
1
+ /**
2
+ * design/178 §3 — the tool content-origin classification (three tiers by CAPABILITY, fail-closed).
3
+ *
4
+ * The question this face answers per mounted tool: can invoking it bring content from OUTSIDE the
5
+ * deployment's trust boundary into the session — and therefore, via the automatic harvest path,
6
+ * into long-term memory? Three tiers:
7
+ *
8
+ * - "external" — network-retrieval families and external protocol channels. Invocation marks the
9
+ * session's memory POLLUTED (one-way, durable; the polluted harvest quarantines).
10
+ * - "execution" — general execution (shell/exec). A NAMED residual channel: it can reach external
11
+ * content indirectly, but the two industry anchors this tier is calibrated against
12
+ * gate on network/protocol families only, and excluding every shell session would
13
+ * disable memory for the main coding scenario. Not polluting by default; the
14
+ * `execIsExternalContent` strict knob upgrades it to external.
15
+ * - "local" — purely local reads/computation.
16
+ *
17
+ * WHO CLASSIFIES (single-source rule): core built-ins declare `contentOrigin` on their own ToolSpec
18
+ * (the classification lives with the tool definition); protocol tools (MCP/A2A) are structurally
19
+ * external (the channel itself crosses the boundary); a HOST tool declares its own — and when it
20
+ * does not, the default is EXTERNAL (fail-closed: unknown = external), overridable only through the
21
+ * explicit `TaskSpec.memory.trustedTools` allowlist. A core-mounted built-in without a declaration
22
+ * defaults local: core owns those definitions, and the fail-closed default exists for tools core
23
+ * CANNOT vouch for, not for its own.
24
+ *
25
+ * There is deliberately no "gate inactive" state: every mounted tool gets a class.
26
+ */
1
27
  import type { ToolContentOrigin } from "../types.js";
2
28
  export interface ClassifyToolContentOriginInput {
29
+ /** The tool's own `contentOrigin` declaration (ToolSpec/AgentTool carry) — wins when present. */
3
30
  declared?: ToolContentOrigin;
31
+ /** True ⇔ the name belongs to a protocol namespace (mcp__/a2a__ …) — an external channel. */
4
32
  isProtocolTool: boolean;
33
+ /** True ⇔ the tool came from the caller/host surface (`TaskSpec.tools`), not a core mount. */
5
34
  isCallerTool: boolean;
35
+ /** True ⇔ `TaskSpec.memory.trustedTools` names this tool (explicit host exemption). */
6
36
  trusted: boolean;
7
37
  }
8
38
  export declare function classifyToolContentOrigin(input: ClassifyToolContentOriginInput): ToolContentOrigin;
39
+ /**
40
+ * Declare `origin` on a tool object built OUTSIDE `defineTool` — a raw AgentTool literal, which is
41
+ * how core's protocol-facing tools are constructed. The axis rides the tool object untyped, exactly
42
+ * as `defineTool` spreads it, and this function is the ONE place that cast lives; the classifier
43
+ * reads the same property either way, so the "classification lives with the tool definition" rule
44
+ * holds for both construction styles.
45
+ */
9
46
  export declare function withContentOrigin<T extends object>(tool: T, origin: ToolContentOrigin): T;
47
+ /** One offered agent type's tool narrowing, as the delegation tool declares it. */
10
48
  export interface AgentToolFace {
11
49
  name: string;
12
50
  allowTools?: readonly string[];
13
51
  denyTools?: readonly string[];
52
+ /** True ⇔ a child of this type is itself handed a delegation tool (the depth budget permits another
53
+ * level and this face does not exclude the delegation tool). Such a child can reach any SIBLING
54
+ * face, so its own narrowing is not the boundary — see {@link delegationCallIsExternal}. */
14
55
  canRedelegate?: boolean;
15
56
  }
57
+ /** One tool in the pool a delegated child draws from — enough to classify it, nothing more. */
16
58
  export interface AgentPoolTool {
17
59
  name: string;
18
60
  aliases?: readonly string[];
19
61
  contentOrigin?: ToolContentOrigin;
20
62
  }
63
+ /**
64
+ * design/178 §3 (ruled 2026-08-08) — classify ONE delegation call by the child's tool face.
65
+ *
66
+ * A child that can reach a network or protocol tool returns content from outside the trust boundary
67
+ * just as surely as calling that tool in this session would, and the parent's transcript is where it
68
+ * lands. The judgment is STATIC — the child's face is known from its definition before the call — so
69
+ * nothing here tracks what the child actually did (runtime provenance is the v2 ticket). That makes
70
+ * it conservative in the safe direction: a child that COULD reach external content counts as having
71
+ * done so.
72
+ *
73
+ * `pool` is the CHILD'S pool, not the parent's roster: a delegation tool carries its own tool set, and
74
+ * the two are explicitly allowed to differ — a parent mounting nothing but the delegation tool can
75
+ * hand its children a network tool. Comparing against the parent's roster would call that local.
76
+ *
77
+ * FAIL-CLOSED on ignorance: an unnamed type, a type the delegation tool does not offer, a tool that
78
+ * declares no faces, or a pool that cannot be enumerated statically (a spawn-time tool factory) is
79
+ * EXTERNAL. "We could not tell" and "it is safe" are different answers.
80
+ */
21
81
  export declare function delegationCallIsExternal(input: {
22
82
  requestedType: string | undefined;
23
83
  faces: ReadonlyArray<AgentToolFace> | undefined;
84
+ /** Undefined ⇔ the child's pool is not statically knowable ⇒ fail closed. */
24
85
  pool: ReadonlyArray<AgentPoolTool> | undefined;
86
+ /** Whether one pool tool carries a polluting class — the caller owns the deployment's config. */
25
87
  isPolluting: (tool: AgentPoolTool) => boolean;
26
88
  }): boolean;
89
+ /** Whether a tool of `origin` pollutes the session's memory when invoked (strict = the
90
+ * `execIsExternalContent` upgrade). */
27
91
  export declare function contentOriginPollutes(origin: ToolContentOrigin, strict: boolean): boolean;
@@ -1,14 +1,23 @@
1
1
  import type { HarvestRejection, MemoryBackend, MemoryEntry, NotePatch, PatchReport, ScanFinding } from "./types.js";
2
+ /** Default per-file byte cap — SAME value as the host engine's MAX_MEMORY_BYTES (独立轨 F3: a 60KB
3
+ * entry legal on the host must not be re-rejected every remote round; one cap, one truth). */
2
4
  export declare const REMOTE_HARVEST_PER_FILE_BYTES: number;
5
+ /** Missing-file ratio above which the harvest refuses wholesale (engine MASS_DELETION_FUSE_RATIO). */
3
6
  export declare const REMOTE_MASS_DELETION_FUSE_RATIO = 0.5;
7
+ /** File-count cap per harvest (host DEFAULT_MAX_MEMORY_FILES parity — codex H10). */
4
8
  export declare const REMOTE_HARVEST_MAX_FILES = 500;
9
+ /** Max DIRECTORY nesting depth below the memory root (host DEFAULT_MAX_ENTRY_DEPTH parity — the
10
+ * host's `scanEntryFiles` walks a subdir only while `depth + 1 <= maxDepth`, so it counts directory
11
+ * levels, NOT path segments: `a/b/c/note.md` (3 dirs) is accepted, `a/b/c/d/note.md` refused). */
5
12
  export declare const REMOTE_HARVEST_MAX_DEPTH = 3;
6
13
  export interface RemoteMemoryFile {
14
+ /** Path RELATIVE to the sandbox memory root, `/`-separated (e.g. `pref-editor.md`, `org-acme/x.md`). */
7
15
  relPath: string;
8
16
  content: string;
9
17
  }
10
18
  export interface RemoteMemoryBaseline {
11
19
  writeScope: string | null;
20
+ /** Every file materialized into the sandbox, with its commit-time identity (the CAS base). */
12
21
  files: Array<{
13
22
  relPath: string;
14
23
  id: string;
@@ -16,29 +25,53 @@ export interface RemoteMemoryBaseline {
16
25
  scope: string;
17
26
  readonly: boolean;
18
27
  }>;
28
+ /** Directory names of ALL read-only layers — including ZERO-entry ones (复审 D2): the harvest's
29
+ * containment prefixes are otherwise inferred from `files`, so an empty inherited layer would be
30
+ * invisible and a planted `<dir>/new.md` would slip in as a writeScope add. Optional (additive):
31
+ * a baseline serialized before this field keeps the files-inferred prefixes only. */
19
32
  readonlyDirs?: string[];
20
33
  }
21
34
  export interface RemoteMaterialization {
35
+ /** Ship these into the sandbox memory root (the deployment owns the transport + any chmod). */
22
36
  files: Array<RemoteMemoryFile & {
23
37
  readonly: boolean;
24
38
  }>;
39
+ /** Keep this (serializable) and pass it to {@link harvestFilesToPatches} at harvest time. */
25
40
  baseline: RemoteMemoryBaseline;
26
41
  }
42
+ /**
43
+ * Project backend entries into a shippable file list. Layout mirrors the host engine: the
44
+ * writeScope's entries sit at the memory root, every other scope under `<scopeDirName>/`
45
+ * (read-only inherited layers). Excluded: budget stubs (a remote v1 materializes full bodies only)
46
+ * and the derived MEMORY.md index (the deployment may render its own).
47
+ */
27
48
  export declare function materializeEntriesToFiles(backend: MemoryBackend, scopes: readonly string[], writeScope: string | null): Promise<RemoteMaterialization>;
28
49
  export interface RemoteHarvestResult {
50
+ /** Feed to `backend.applyPatches` (the deployment owns the call + the resulting PatchReport). */
29
51
  patches: NotePatch[];
30
52
  rejections: HarvestRejection[];
53
+ /** Baseline files absent from the read-back set (info; NEVER a delete — tombstones only). */
31
54
  missing: string[];
55
+ /** Set instead of patches when the mass-deletion fuse trips (deployment surfaces it, human call). */
32
56
  incident?: {
33
57
  kind: "mass_deletion";
34
58
  detail: string;
35
59
  };
60
+ /** Canonical projections (minted ids / completed frontmatter) the deployment SHOULD write back into
61
+ * the sandbox after the backend commit succeeds, keyed by relPath — same promotion discipline as
62
+ * the host engine (project only what applied; see {@link projectionsToWriteBack}). */
36
63
  projections: Array<{
37
64
  relPath: string;
38
65
  entry: MemoryEntry;
39
66
  content: string;
40
67
  }>;
41
68
  }
69
+ /**
70
+ * The pure gate+diff core over files read back from a remote sandbox. Same judgment order as the
71
+ * host engine's harvest: readonly-layer tamper → rejection (restore is the deployment's I/O);
72
+ * missing + fuse; per-file size cap → scan rule set (secret/injection/filename) → parse →
73
+ * id-immutability (baseline id wins) → tombstone-only delete → CAS update / rename / add.
74
+ */
42
75
  export declare function harvestFilesToPatches(baseline: RemoteMemoryBaseline, files: readonly RemoteMemoryFile[], opts?: {
43
76
  perFileBytes?: number;
44
77
  massDeletionFuseRatio?: number;
@@ -46,6 +79,8 @@ export declare function harvestFilesToPatches(baseline: RemoteMemoryBaseline, fi
46
79
  maxDepth?: number;
47
80
  now?: () => number;
48
81
  }): RemoteHarvestResult;
82
+ /** After `backend.applyPatches(result.patches)`, the projections worth writing back into the sandbox:
83
+ * only those whose (id, non-delete op) actually APPLIED — the host engine's promotion discipline. */
49
84
  export declare function projectionsToWriteBack(result: RemoteHarvestResult, report: PatchReport): Array<{
50
85
  relPath: string;
51
86
  content: string;
@@ -54,6 +89,14 @@ export interface InboundEntryFinding {
54
89
  id: string;
55
90
  findings: ScanFinding[];
56
91
  }
92
+ /**
93
+ * design/142 §3③ — the central-side inbound gate as a PURE function. A sync channel is a write path
94
+ * that bypasses the harvest gate by construction (same class as git pull, §2.7): before entries from
95
+ * another plane touch an authority disk, screen body + slug + size with the SAME rule set the
96
+ * harvest gate runs. Gate logic single-sourced in core; the execution seat rides the data plane
97
+ * (service calls this in its write face). Returns findings per OFFENDING entry only — empty array =
98
+ * the batch is clean.
99
+ */
57
100
  export declare function screenInboundEntries(entries: readonly MemoryEntry[], opts?: {
58
101
  perFileBytes?: number;
59
102
  }): InboundEntryFinding[];
@@ -1,15 +1,39 @@
1
1
  import type { ParsedScopeKey } from "./scope-contract.js";
2
2
  import type { HarvestReport } from "./types.js";
3
3
  import type { MemoryInjection } from "./engine.js";
4
+ /** The personal plane's shared mount under the config root (ALL projects, one home — the plane is
5
+ * keyed by scope, not by repo: `user:alice` is the same disk from every checkout). */
4
6
  export declare function derivePersonalMemoryDir(configRoot: string): string;
5
7
  export declare function derivePersonalControlDir(configRoot: string): string;
6
8
  export interface ScopePlanes {
9
+ /** proj:/legacy scopes — the repo/path-keyed plane (order preserved). */
7
10
  project: string[];
11
+ /** user:/userproj:/org: scopes — the home-mount plane (order preserved). codex 复审 B1: `org` is
12
+ * CENTRAL-authority (§2 表), so it routes with the personal keys — under a pinned in-repo File
13
+ * backend an org layer projected into the repo would leak tenant-shared memory into commit
14
+ * history. The mount is still the "personal" directory (one home plane; the plane is about
15
+ * WHERE-NOT-to-project, not about ownership — org's authority disk is the central DB anyway). */
8
16
  personal: string[];
17
+ /** Which plane owns the write face (null = read-only layering everywhere). */
9
18
  writePlane: "project" | "personal" | null;
10
19
  }
20
+ /** Classify a v2 session's scopes into planes. writeScope routes by its OWN key kind (it need not
21
+ * be listed in scopes — normalizeMemorySpec contract). */
11
22
  export declare function classifyScopePlanes(scopes: readonly string[], writeScope: string | null): ScopePlanes;
23
+ /** True when the classified session needs the dual-root assembly at all. */
12
24
  export declare function needsDualRoots(planes: ScopePlanes): boolean;
25
+ /** Convenience for the placement gate: the parsed keys that stay on the PROJECT plane. */
13
26
  export declare function parsedProjectPlane(planes: ScopePlanes, writeScope: string | null): ParsedScopeKey[];
27
+ /**
28
+ * Merge the two planes' injections into ONE block. Plane order is fixed: PROJECT first (the stable
29
+ * prefix — repo knowledge changes less often than personal notes), PERSONAL second; the instruction
30
+ * (trusted half, "where to write") comes from whichever plane owns the write face and leads the
31
+ * block, exactly like the single-root layout. v1 deliberately merges at BLOCK granularity — scope
32
+ * interleaving across planes is not reproduced (documented; the within-plane order is untouched).
33
+ */
14
34
  export declare function mergeInjections(project: MemoryInjection | undefined, personal: MemoryInjection | undefined): MemoryInjection;
35
+ /** Merge the two planes' harvest reports into the single report the runner surfaces. Counters add,
36
+ * lists concatenate, `ok` ANDs, the first incident wins the seat (both are still visible via the
37
+ * merged lists). 独立轨 F7: pass the WRITE plane's report as `a` — first-argument fields (incident
38
+ * seat, degraded seat) prefer `a`, and the write plane's degradation is the one that matters. */
15
39
  export declare function mergeHarvestReports(a: HarvestReport, b: HarvestReport): HarvestReport;