@sema-agent/core 7.1.0 → 7.3.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 (64) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/dist/agents/cross-session-envelope.d.ts +145 -0
  3. package/dist/agents/cross-session-envelope.js +195 -0
  4. package/dist/agents/cross-session-judge.d.ts +119 -0
  5. package/dist/agents/cross-session-judge.js +184 -0
  6. package/dist/agents/cross-session-ref.d.ts +52 -0
  7. package/dist/agents/cross-session-ref.js +64 -0
  8. package/dist/agents/list-agents-tool.d.ts +55 -0
  9. package/dist/agents/list-agents-tool.js +94 -0
  10. package/dist/agents/peer-admission.d.ts +17 -1
  11. package/dist/agents/peer-admission.js +19 -2
  12. package/dist/agents/peer-directory.d.ts +208 -0
  13. package/dist/agents/peer-directory.js +272 -0
  14. package/dist/agents/peer-session-drain.d.ts +159 -0
  15. package/dist/agents/peer-session-drain.js +245 -0
  16. package/dist/agents/send-message-tool.d.ts +44 -0
  17. package/dist/agents/send-message-tool.js +181 -16
  18. package/dist/agents/subagent-steps.d.ts +11 -0
  19. package/dist/agents/subagent-steps.js +27 -4
  20. package/dist/core/auto-mode-arming.d.ts +11 -0
  21. package/dist/core/auto-mode-arming.js +7 -1
  22. package/dist/core/auto-mode-prompt.d.ts +5 -0
  23. package/dist/core/auto-mode-prompt.js +2 -1
  24. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  25. package/dist/core/auto-mode-rebuild.js +2 -0
  26. package/dist/core/checkpoint-store.d.ts +203 -3
  27. package/dist/core/checkpoint-store.js +60 -19
  28. package/dist/core/governance-codes.d.ts +1 -1
  29. package/dist/core/governance-codes.js +6 -0
  30. package/dist/core/hooks.d.ts +15 -8
  31. package/dist/core/hooks.js +6 -3
  32. package/dist/core/mailbox-store.d.ts +89 -2
  33. package/dist/core/mailbox-store.js +77 -2
  34. package/dist/core/permission-rule-consent.d.ts +72 -23
  35. package/dist/core/permission-rule-consent.js +115 -26
  36. package/dist/core/permission-rule-model.d.ts +254 -51
  37. package/dist/core/permission-rule-model.js +316 -55
  38. package/dist/core/permission-rule-org.js +13 -6
  39. package/dist/core/remote-env.d.ts +8 -1
  40. package/dist/core/runner/assemble-result.js +2 -1
  41. package/dist/core/runner/prepare-task.d.ts +59 -1
  42. package/dist/core/runner/prepare-task.js +414 -149
  43. package/dist/core/runner/prepare-workspace-restore.d.ts +6 -1
  44. package/dist/core/runner/prepare-workspace-restore.js +2 -1
  45. package/dist/core/runner/runtask.js +16 -5
  46. package/dist/core/runner/tool-output-projection.js +1 -0
  47. package/dist/core/store-contracts/mailbox-store-contract.d.ts +23 -0
  48. package/dist/core/store-contracts/mailbox-store-contract.js +157 -1
  49. package/dist/core/task-notification.d.ts +93 -5
  50. package/dist/core/task-notification.js +31 -4
  51. package/dist/core/tool-policy.d.ts +11 -0
  52. package/dist/core/types.d.ts +155 -21
  53. package/dist/core/untrusted-text.js +17 -1
  54. package/dist/core/wiring-manifest.d.ts +21 -0
  55. package/dist/core/wiring-manifest.js +1 -0
  56. package/dist/index.d.ts +14 -5
  57. package/dist/index.js +13 -4
  58. package/dist/stores/cc/mailbox-store.d.ts +1 -1
  59. package/dist/stores/cc/mailbox-store.js +13 -0
  60. package/dist/stores/file/adoption/marker.d.ts +1 -1
  61. package/dist/stores/file/mailbox-store.d.ts +57 -0
  62. package/dist/stores/file/mailbox-store.js +369 -18
  63. package/package.json +1 -1
  64. package/test/export-surface.snapshot.json +233 -1
@@ -24,13 +24,14 @@ import { type ToolManifestRow } from "../../prompt-assembly/tool-catalog.js";
24
24
  import type { ToolDisclosureManifest } from "../trace.js";
25
25
  import { type ClearedProjectionLedger, type ContextEditMachine, type OccurrenceIndex } from "../context-edit.js";
26
26
  import type { TaskNotificationPayload } from "../task-notification.js";
27
+ import type { RemoteExecutionEnv, SnapshotId } from "../remote-env.js";
27
28
  import { type CwdRef, type ReadFace } from "../../tools/fs/index.js";
28
29
  import { type WorkflowSizeGuideline } from "../../orchestration/workflow-size-guideline.js";
29
30
  import type { Runner } from "./runtask.js";
30
31
  import { type CheckpointGate, type CheckpointState, type CheckpointToken, type ResourceLedger, type PlatformLimitReason, type ResourceLimitReason } from "../checkpoint-store.js";
31
32
  import { type WiringManifest } from "../wiring-manifest.js";
32
33
  import type { ActiveWorktreeSession, AgentMessage, AgentTool, ExecutionEnv } from "../../internal/harness.js";
33
- import type { NestedUsageAccum, RunnerDeps, TaskEvent, TaskResult, TaskSpec, ToolActivity, ToolEffect } from "../types.js";
34
+ import type { NestedUsageAccum, RemoteEnvFailureNote, RunnerDeps, TaskEvent, TaskResult, TaskSpec, ToolActivity, ToolEffect } from "../types.js";
34
35
  import type { RepairBundle } from "../../agents/repair-loop.js";
35
36
  /** Test seam (mirrors `__resetToolModelGateAnnouncements`): never called by production code.
36
37
  * Re-arms BOTH arms (a WeakMap has no clear — it is re-minted). */
@@ -40,6 +41,13 @@ export declare function __resetMaterializeEnvAnnouncements(): void;
40
41
  * seam below (console latch only): tests here legitimately reuse ONE sink across prepares to pin
41
42
  * the per-sink dedup itself, so the seam must be able to re-arm a still-referenced sink. */
42
43
  export declare function __resetToolModelGateAnnouncements(): void;
44
+ /**
45
+ * The model gate's per-session READ face ({@link WiringManifest.modelGate}) — projected from the SAME
46
+ * gate decision {@link announceToolModelGate} reads (one source; the notice is the operator-sink
47
+ * dialect, this the manifest dialect). `undefined` when no default-mounted tool was trimmed on this
48
+ * run. The restore sentence is the notice's, verbatim.
49
+ */
50
+ export declare const TOOL_MODEL_GATE_RESTORE_SENTENCE = "restore via TaskSpec.restoreGatedTools, SEMA_TOOL_MODEL_GATE=off, or RunnerDeps.toolModelGate: false";
43
51
  export { __resetReadFaceClampAnnouncement } from "./prepare-hands-readface.js";
44
52
  /**
45
53
  * design/164 件四 — how long before an execution environment's declared `lifetimeMs` expires the engine
@@ -1176,6 +1184,19 @@ export interface InheritedGate {
1176
1184
  }>;
1177
1185
  /** The chain's effective shell-gate doctrine — the child folds it by max-rank with its own spec. */
1178
1186
  shellGate?: "off" | "always" | "classify";
1187
+ /**
1188
+ * The chain's AUTO-MODE INTENT (`TaskSpec.autoModeRequested`, session-wide like a permission mode):
1189
+ * emitted when the spawning task carried the intent itself or inherited it, so an engine-spawned
1190
+ * child of an auto-mode task arms its OWN per-run classifier exactly as its parent did — the
1191
+ * intent half only; the child's deny bit (`RuntimeCaps.autoMode === false`) and deployment face
1192
+ * (`RunnerDeps.autoMode`) are evaluated for the child. Trusted chain data (Runner-assembled, never a
1193
+ * model-authored argument); absent ⇒ the child is an auto-mode task only if its own spec says so.
1194
+ * Persists on the checkpoint's data half (`CheckpointState.inheritedGate.autoModeRequested`) so a
1195
+ * redemption in another process — no seat re-passed, no waking chain — reads the same intent the
1196
+ * suspend leg had; the intent folds by OR across seat, live chain and seed, while the deny bit and
1197
+ * the deployment face stay per-leg.
1198
+ */
1199
+ autoModeRequested?: true;
1179
1200
  /**
1180
1201
  * Org-memory admission freeze (ruled 2026-08-05): the spawning chain's FROZEN admitted org-scope
1181
1202
  * set — every org memory scope the parent actually mounted (deployment-origin + admitted request).
@@ -1896,6 +1917,43 @@ export declare function batchContextAt(messages: AgentMessage[], currentId: stri
1896
1917
  batchToolCallIds: string[];
1897
1918
  completedCallIds: string[];
1898
1919
  };
1920
+ /**
1921
+ * design/384 slice 2 — the ONE compensation for a paused-but-unparked VM, shared by the fence's
1922
+ * post-pause checkpoints (③ in the park closure, ④ in the saga) and the saga's put-failure absent
1923
+ * arm (previously inline there: same two hops, one implementation now, so the three sites cannot
1924
+ * drift). Restores the workspace (bounded transient retry) then re-establishes consistency
1925
+ * (`postResumeInit`), both hops under one INDEPENDENT `AbortSignal.timeout(io.boundMs)` —
1926
+ * deliberately NOT the run/cut signal: the remote contract answers an already-aborted signal
1927
+ * `{ok:false,"aborted"}`, so gating the restore on the very signal whose firing caused the
1928
+ * compensation made it die instantly and strand the paused VM on exactly the run-abort arm that
1929
+ * needs it most. The adapter signal is best-effort (a deaf adapter ignores it), so the caller's
1930
+ * await is ALSO raced against the same bound — bounded decision, three outcomes:
1931
+ * · settled ok ⇒ the VM is running again ({ok:true});
1932
+ * · settled not-ok / threw ⇒ recorded + disclosed, {ok:false} — the caller takes its fatal
1933
+ * fail-closed arm (abort the run; never continue on a paused VM);
1934
+ * · bound fires with the adapter still in flight ⇒ {ok:false} NOW, and the in-flight call
1935
+ * continues DETACHED + swallow-guarded with the late-settlement split:
1936
+ * – late SUCCESS: a running VM now exists with no run and no committed row to own it — the
1937
+ * detached continuation compensates the compensation with `destroy()` (the adapter's own
1938
+ * best-effort contract, swallow-guarded, disclosed);
1939
+ * – late FAILURE: disclosed; the VM is most likely still paused — provider-side TTL/GC
1940
+ * territory, and the disclosure is the end of this engine's obligation (a deaf adapter's
1941
+ * stranded VM is that adapter's own defect surface).
1942
+ * Decide-then-disclose throughout: `io.disclose`/`io.noteFailure` must be swallow-guarded by the
1943
+ * caller's binding, and nothing they do can change the returned verdict. Never throws. Exported for
1944
+ * direct unit pinning (the bounded/deaf/late arms need a small bound; production binds the
1945
+ * `PARK_COMPENSATION_TIMEOUT_MS` constant at the one call-site closure).
1946
+ */
1947
+ export declare function compensateUnparkedPause(remoteEnv: RemoteExecutionEnv, snapshotId: SnapshotId, io: {
1948
+ boundMs: number;
1949
+ noteFailure: (note: RemoteEnvFailureNote) => void;
1950
+ disclose: (err: unknown) => void;
1951
+ }): Promise<{
1952
+ ok: true;
1953
+ } | {
1954
+ ok: false;
1955
+ reason: string;
1956
+ }>;
1899
1957
  /**
1900
1958
  * rescan C5 — the ONE spelling of the placement fields' empty-string discipline: `""` is absence
1901
1959
  * wearing clothes (the resume entry's principal-rung posture), and every placement read that must