@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
@@ -1032,7 +1032,8 @@ export interface ToolExecuteContext {
1032
1032
  } | undefined;
1033
1033
  /**
1034
1034
  * RB-201 FO-3 (form-one audit, CC 220 `Ipd`/`ein` parity) — the auto-mode classifier decider ARMED
1035
- * for THIS task (`RuntimeCaps.autoMode === true` AND `RunnerDeps.autoMode` both present; the same
1035
+ * for THIS task (auto-mode intent `RunnerDeps.autoMode` present `RuntimeCaps.autoMode !== false`
1036
+ * — see {@link TaskSpec.autoModeRequested}; the same
1036
1037
  * instance `runToolGate`'s per-call ask review already consults, carrying its own live breaker
1037
1038
  * state — not a fresh one built from raw config). Runner-filled, trusted, undefined when auto-mode
1038
1039
  * is not armed or the tool runs outside a Runner task.
@@ -2608,6 +2609,35 @@ export interface TaskSpec {
2608
2609
  * pending call itself runs once, having been adjudicated). Re-pass the same value the original task used.
2609
2610
  */
2610
2611
  shellGate?: "off" | "always" | "classify";
2612
+ /**
2613
+ * The caller's AUTO-MODE INTENT for this task — the "user turned auto on" half of the classifier
2614
+ * arming (CC 2.1.250 polarity: auto mode is something the USER enables at the permission-mode
2615
+ * seat, and something an ORGANIZATION may only DENY; it is never something an organization grants
2616
+ * on a user's behalf). The engine arms its per-run classifier only when ALL THREE hold:
2617
+ * - this seat is `true` (intent),
2618
+ * - {@link RunnerDeps.autoMode} is present (the deployment is classifier-capable — the trust gate;
2619
+ * classifier RULES still enter ONLY through that face, never through this seat), and
2620
+ * - {@link RuntimeCaps.autoMode} is not `false` (the per-principal DENY bit; ABSENT is NOT a denial).
2621
+ *
2622
+ * **Ownership** — same split as {@link shellGate}: the service layer TRANSLATES the effective
2623
+ * permission mode into this seat (at the same point it translates the mode into `shellGate`);
2624
+ * core only CONSUMES it. Absent ⇒ not an auto-mode task (byte-identical to the pre-seat shape:
2625
+ * asks flow the original chain). Only the literal `true` is a value here: any other present value
2626
+ * (`false`, `"true"`, `1`) is refused at the door (`config.auto_mode_requested_invalid`) rather than
2627
+ * read as either polarity — a marshalled string must never silently arm, or silently disarm, a
2628
+ * classifier.
2629
+ *
2630
+ * **Inheritance**: the intent is session-wide, like a permission mode — an engine-spawned child of
2631
+ * an auto-mode task inherits it through the trusted constraint chain
2632
+ * (`InheritedGate.autoModeRequested`), never through a model-authored argument; the child's own
2633
+ * deny bit and deployment face are still evaluated for the child. **On resume:** the intent the
2634
+ * suspend leg resolved (this seat, or the bit its chain carried) is recorded on the checkpoint's
2635
+ * data half (`CheckpointState.inheritedGate.autoModeRequested`) and read back as one more intent
2636
+ * source, so a redemption in another process arms as the suspend leg did without re-passing the
2637
+ * seat; re-passing it is still honoured (the sources fold by OR). Intent only — the resuming
2638
+ * deployment's face and the resuming principal's deny bit are judged afresh on every leg.
2639
+ */
2640
+ autoModeRequested?: true;
2611
2641
  /** Task-scoped MCP servers, materialized into tools then disposed. */
2612
2642
  mcp?: McpServerSpec[];
2613
2643
  /** Task-scoped A2A peers (remote agents), whose advertised skills mount as `a2a__<peer>__<skill>`
@@ -3539,6 +3569,16 @@ export interface TaskResult {
3539
3569
  * gate): a halt landing AFTER the abort signal already fired neither cut nor stopped anything —
3540
3570
  * that ending belongs to the abort, and this seat stays ABSENT rather than signing someone
3541
3571
  * else's stop with the halt caller's name. Absent everywhere else; never `false`.
3572
+ *
3573
+ * design/384 slice 2 (TRANSITIONAL narrowing): a `"suspended"` / `"needs_review"` terminal does
3574
+ * NOT carry this seat even when a halt was accepted — those statuses mean a durable park WON its
3575
+ * race with the halt (the row is committed and redeemable; the run is waiting to continue), and
3576
+ * "stopped by the person" beside "waiting to resume" was a self-contradictory pair. The halt's
3577
+ * own receipt (`{turnCut}`) and the `task.turn_interrupted` notice still stand — a seat WAS cut.
3578
+ * Transitional: once halt-boundary source accounting lands (slice 3), the boundary-CONSUMED
3579
+ * suspension arms flip to signing (a probe pinning today's suppressed shape goes red then, by
3580
+ * design). The pass-through law is untouched for every OTHER terminal: a halt racing a real
3581
+ * failure/limit — including one that outranks a committed park — still signs.
3542
3582
  */
3543
3583
  haltedByUser?: true;
3544
3584
  /**
@@ -5138,6 +5178,15 @@ export interface TaskStream extends AsyncIterable<TaskEvent> {
5138
5178
  * steer-family `steering.not_running` once the task has finished (teardown included); a halt
5139
5179
  * issued BEFORE the run's first prompt polls the same bounded birth window as {@link steer} and
5140
5180
  * then stops the run before its first model turn (an empty, cleanly-halted completed run).
5181
+ *
5182
+ * **Receipt tension, stated (design/384 slice 2):** `{turnCut:true}` and the
5183
+ * `task.turn_interrupted` notice assert facts about the CUT — a seat was cut, no new model turn
5184
+ * starts — and both stay true even when the gate's durable leg still collects to `suspended`:
5185
+ * a park whose store commit was already in flight (or committed) when the cut landed WINS the
5186
+ * fence race, the row is redeemable, and the result then reads `status:"suspended"` WITHOUT
5187
+ * {@link TaskResult.haltedByUser} (the transitional narrowing documented on that seat). A cut
5188
+ * observed BEFORE the commit makes the park concede instead — no row, no card, and the ordinary
5189
+ * halted ending.
5141
5190
  */
5142
5191
  halt(): Promise<{
5143
5192
  turnCut: boolean;
@@ -5229,9 +5278,16 @@ export interface WorkflowGovernanceBaseline {
5229
5278
  /**
5230
5279
  * design/99 §K — the per-principal runtime ENTITLEMENTS the engine enforces server-side, resolved by a
5231
5280
  * deployment via {@link RunnerDeps.runtimeCapsResolver} from center's `GET /api/config/effective?principal=`.
5232
- * Every field is TIGHTEN-ONLY (a cap only ever DENIES or FORCES; `undefined` = no per-principal restriction).
5233
- * Only the two caps the ENGINE can enforce live here; `allowUltracode`/`allowBypassPermissions` are
5234
- * shell-UX / service-settings-layer concerns (see {@link RunnerDeps.runtimeCapsResolver}).
5281
+ * Every field is TIGHTEN-ONLY (a cap only ever DENIES or FORCES) but the family carries THREE
5282
+ * polarities, and "absent" does not read the same on each:
5283
+ * · DENY-shaped, `false` denies / absent is no restriction: {@link allowWorkflows}, {@link allowFork},
5284
+ * {@link autoMode} (the per-principal deny bit of a user-enabled mode), {@link allowMemoryOptOut}
5285
+ * (the one member whose resolver-FAULT degrade is allow, on the privacy axis);
5286
+ * · GRANT-shaped, `=== true` opts in / absent is OFF: {@link allowObservers};
5287
+ * · FORCE-shaped, `true` mandates / absent is the caller's opt-in default: {@link forceDurableGate}
5288
+ * (binds only where a checkpoint store is wired; announced `config.durable_gate_unavailable` where none is).
5289
+ * These six are the caps the ENGINE enforces; `allowUltracode`/`allowBypassPermissions` are shell-UX /
5290
+ * service-settings-layer concerns (see {@link RunnerDeps.runtimeCapsResolver}).
5235
5291
  */
5236
5292
  export interface RuntimeCaps {
5237
5293
  /** `false` DENIES workflow self-orchestration for this principal server-side — even on a deployment that is
@@ -5260,18 +5316,29 @@ export interface RuntimeCaps {
5260
5316
  /** `true` FORCES this principal's run onto the durable-approval path: the engine synthesizes a
5261
5317
  * `durableApproval{scope: principal}` so a policy `ask` suspends to the wire (a per-tool CC-faithful gate)
5262
5318
  * even when the caller did not opt in — center's fleet-wide "interactive runs gate" mandate. A
5263
- * caller-supplied `TaskSpec.durableApproval` always wins (it may carry a tighter scope/ttl). */
5319
+ * caller-supplied `TaskSpec.durableApproval` always wins (it may carry a tighter scope/ttl).
5320
+ * The mandate binds only where a {@link RunnerDeps.checkpointStore} is wired — the park facility it
5321
+ * forces the run onto. On a store-less deployment it has no facility: the leg announces
5322
+ * `config.durable_gate_unavailable` once (before its first ask), every ask resolves on the live chain
5323
+ * (a live approver / question face in-stream, or the fail-closed deny with none), no durable record
5324
+ * is written, and a live question face is consulted rather than vetoed (a mandate that cannot park
5325
+ * must not demote a reachable person into the model answering for them). */
5264
5326
  forceDurableGate?: boolean;
5265
5327
  /**
5266
- * design/143 批2 (CC 2.1.207 auto mode): route a surviving permission `ask` to the
5267
- * small-model security CLASSIFIER before any human/durable resolution (allow run; block deny
5268
- * `source:"classifier"`; classifier failure FAIL-CLOSED back to the original ask chain).
5269
- * **POLARITY: `=== true` EXPLICIT opt-in, default OFF** (same as {@link allowObservers} — auto mode
5270
- * hands a model the ask-resolution power for this principal's session; that is never implied).
5271
- * Arming ALSO requires the deployment to be classifier-capable ({@link RunnerDeps.autoMode} the
5272
- * trust gate lives there: classifier RULES enter only through the deployment assembly face, never a
5273
- * repo-controlled plane; the CC 2.1.207 three-source invariant). `true` on an incapable
5274
- * deployment resolves to a no-op (asks flow the original chain; no warn the gate, not a mistake).
5328
+ * The per-principal auto-mode DENY bit (CC 2.1.250 polarity the mirror of the settings-plane
5329
+ * `permissions.disableAutoMode` ratchet: an organization may only take auto mode AWAY; it is the
5330
+ * USER who turns it on, at the task's intent seat {@link TaskSpec.autoModeRequested}).
5331
+ *
5332
+ * **POLARITY: `=== false` DENIES; ABSENT IS NOT A DENIAL.** This is the family's deny-shaped
5333
+ * member (like {@link allowWorkflows} / {@link allowFork}), NOT a grant-shaped one like
5334
+ * {@link allowObservers}: a deployment with no entitlement source at all resolves `undefined` here
5335
+ * and still arms on intent + capability. `true` is accepted and means the same as absent (no
5336
+ * per-principal restriction) it is not a grant, and it cannot arm a task whose intent seat is
5337
+ * unset. The arming itself: intent ∧ {@link RunnerDeps.autoMode} present ∧ this bit not `false`
5338
+ * (allow → run; block → deny `source:"classifier"`; classifier failure → FAIL-CLOSED back to the
5339
+ * original ask chain). The trust gate is unchanged: classifier RULES enter only through the
5340
+ * deployment assembly face, never a repo-controlled plane (the CC 2.1.207 three-source invariant).
5341
+ * A denial resolves to a no-op (asks flow the original chain; no warn — the gate, not a mistake).
5275
5342
  */
5276
5343
  autoMode?: boolean;
5277
5344
  /**
@@ -5751,6 +5818,23 @@ export interface EngineNotice {
5751
5818
  * `onNotice` sink per value (console arm once per process) instead of lying in wait; where the
5752
5819
  * value IS in force the prepare refuses with the same code as `TaskResult.errorCode` (one
5753
5820
  * fact, one code, two loudness dialects); `detail: { raw }`.
5821
+ * - `"config.durable_gate_unavailable"` — the per-principal `forceDurableGate` entitlement is in
5822
+ * force on a leg whose deployment wired NO checkpoint store. The entitlement is a mandate
5823
+ * ("every interactive ask of this principal gates durably"), and a mandate with no park
5824
+ * facility cannot be honored: no ask of the leg can suspend, so each one resolves on the LIVE
5825
+ * chain — a live approver / question face answers in-stream, and with none the ask is denied
5826
+ * fail-closed — and NO durable approval record is written. The ask routing itself is not
5827
+ * changed by the notice (a store-less leg never could park); the notice is the loud half of a
5828
+ * posture that used to degrade silently, disclosed before the first ask of the leg. Audience
5829
+ * `"user"` (the person whose asks will not be recorded is entitled to that; the operator hears
5830
+ * it through the sink as always). Once per prepared task leg — a resume or a delegated child
5831
+ * is its own leg and says so again; `detail: { sessionId, runId, principal?, cause, liveApprover,
5832
+ * liveQuestionFace }` — `cause` is `"no_deployment_store"` (the deployment wired none) or
5833
+ * `"task_store_null"` (`TaskSpec.checkpointStore: null`, the per-run off switch, on a leg
5834
+ * whose deployment may well have a store: the fix is the task's); `liveApprover` /
5835
+ * `liveQuestionFace`: whether a live seat will EFFECTIVELY answer the leg's permission asks /
5836
+ * questions in-stream (a delegated child under an inherited content mandate reads `false`
5837
+ * even with a face wired — the marker withholds the question), or the fail-closed deny will.
5754
5838
  *
5755
5839
  * - `"task.user_steer_undrained"` / `"task.user_followup_undrained"` (#259) — user steers /
5756
5840
  * follow-ups whose receipts said "queued" were still in their queue at agent_end: the run
@@ -5791,6 +5875,10 @@ export interface EngineNotice {
5791
5875
  * `detail: { cause: "user_halt", sessionId, runId, taskId? }` — no `inputId` and no
5792
5876
  * `actorId`, because no text entered the model and the verb carries no caller identity. A
5793
5877
  * consumer keying `detail.inputId` off this row must treat it as ABSENT on this lane.
5878
+ * Fence tension (design/384 slice 2): this notice asserts THE CUT only — when the cut
5879
+ * raced a durable park whose commit was already in flight, the gate's durable leg may
5880
+ * still collect to `suspended` (park wins, row redeemable, no `haltedByUser`); the notice
5881
+ * stands beside that terminal without contradiction, because a seat really was cut.
5794
5882
  * In both lanes: one notice per REAL cut (a `now` that found nothing in flight or whose frame
5795
5883
  * already rode the imminent boundary, and a halt with nothing in flight, announce nothing — no
5796
5884
  * false interrupt claims); `runId` (#499) is the INVOCATION that was cut (the other two ids are
@@ -5998,6 +6086,24 @@ export interface EngineNotice {
5998
6086
  * disposition table with the error dispositions. The loser MUST NOT retry into the winner's
5999
6087
  * account. A consumer diffing its own table against the catalog must not add a row for it.
6000
6088
  *
6089
+ * - `"config.peer_lane_unmounted"` (design/385 §1.2⑥) — `RunnerDeps.peerDirectory` is wired but
6090
+ * the cross-session lane could not mount on this leg: no `mailboxStore`, or one that does not
6091
+ * declare `crossProcessSafe: true` (several terminals would share one session box on luck). The
6092
+ * seat is inert for the run (no ListAgents, peer addresses refuse with the same reason). Once per
6093
+ * prepared leg; `detail: { reason, code, mailboxWired, sessionId, runId }`. Audience `"operator"`
6094
+ * (a wiring fact; the fix is the deployment's).
6095
+ * - `"peer.inbound_disposition"` (design/385 §1.2④ / §4.6) — a message parked in THIS session's
6096
+ * own box was settled at the drain WITHOUT reaching the model. `detail.disposition` is the arm:
6097
+ * `"refused"` (this session's `crossSessionInbound` setting, or a record whose typed fields
6098
+ * cannot be rendered canonically), `"admission_refused"` (the drain-stage admission re-check:
6099
+ * duplicate / hop loop / runaway — `cause` names it), `"notice_unrouted"` (a notice-kind record
6100
+ * — idle/delivery notice — met a build with no notice face: settled without delivery, never
6101
+ * ridden through the peer-message envelope), or `"held"` (mode parity held it; the
6102
+ * held-message review face is not mounted in this build, so the message STAYS PARKED and the
6103
+ * drain stops at it — disclosed once per seq per leg). `detail: { disposition, cause, seq, box,
6104
+ * fromSession?, sessionId, runId }`. Audience `"user"`: the session's user is the one who did
6105
+ * not receive it.
6106
+ *
6001
6107
  * - `"delegation.transcript_integrity"` (subagent transcript persistence) — a durable agent row
6002
6108
  * with a BOUND transcript sessionId met a session store that attests `not_found` for it: the
6003
6109
  * deployment's declared transcript durability is being contradicted by reality. Announced at
@@ -6638,11 +6744,15 @@ export interface RunnerDeps {
6638
6744
  * resolver, or an unset cap) = NO per-principal restriction (TIGHTEN-ONLY: a cap can only ever DENY or
6639
6745
  * FORCE; absence falls back to the deployment-level default). Symmetric with {@link sessionPolicyStore}.
6640
6746
  *
6641
- * core enforces only the caps it CAN enforce in the engine: `allowWorkflows` (the third stage of the
6642
- * workflows gate — task opt-in ∧ deployment capability ∧ this) and `forceDurableGate` (forces a run onto
6643
- * the durable-approval path so a policy `ask` suspends to the wire). `allowUltracode` is a shell/UX concern
6644
- * (reasoning-tier, not a core primitive); `allowBypassPermissions` is enforced at the service settings-
6645
- * resolution layer (the engine sees only a resolved policy, never a "this allow came from bypass" signal).
6747
+ * core enforces the six caps it CAN enforce in the engine (polarity per member on {@link RuntimeCaps}):
6748
+ * `allowWorkflows` (the third stage of the workflows gate — task opt-in ∧ deployment capability ∧ this),
6749
+ * `allowFork` (the Agent-fork route), `allowObservers` (explicit opt-in for observer auto-spawn),
6750
+ * `autoMode` (the per-principal deny bit of the user-enabled auto mode), `allowMemoryOptOut` (may this
6751
+ * principal declare a capture opt-out), and `forceDurableGate` (forces a run onto the durable-approval
6752
+ * path so a policy `ask` suspends to the wire — where a checkpoint store is wired; a store-less leg
6753
+ * announces `config.durable_gate_unavailable`). `allowUltracode` is a shell/UX concern (reasoning-tier,
6754
+ * not a core primitive); `allowBypassPermissions` is enforced at the service settings-resolution layer
6755
+ * (the engine sees only a resolved policy, never a "this allow came from bypass" signal).
6646
6756
  */
6647
6757
  runtimeCapsResolver?: (principal: string | undefined) => RuntimeCaps | undefined | Promise<RuntimeCaps | undefined>;
6648
6758
  /**
@@ -6711,8 +6821,10 @@ export interface RunnerDeps {
6711
6821
  retentionPolicy?: import("./retention.js").RetentionPolicy;
6712
6822
  /**
6713
6823
  * design/143 批2b — the auto-mode classifier's DEPLOYMENT assembly face. This is the
6714
- * capability half of the arming AND-gate: a run arms auto mode only when the per-principal
6715
- * entitlement grants it ({@link RuntimeCaps.autoMode}` === true`) AND this face is present.
6824
+ * CAPABILITY arm of the three-arm arming: a run arms auto mode only when the task carries the
6825
+ * auto-mode INTENT ({@link TaskSpec.autoModeRequested}, or the same bit inherited on the chain by an
6826
+ * engine-spawned child) AND this face is present AND the per-principal DENY bit is not set
6827
+ * ({@link RuntimeCaps.autoMode}` !== false` — absent is not a denial).
6716
6828
  *
6717
6829
  * 🔐 Trust gate (the CC 2.1.207 three-source invariant): classifier RULES enter EXCLUSIVELY
6718
6830
  * here — a deployment-constructed object, never a `TaskSpec` field, never a repo-file plane. The
@@ -6878,6 +6990,28 @@ export interface RunnerDeps {
6878
6990
  * absent means the default table, not "guard off". Threaded into the auto-mounted SendMessage as
6879
6991
  * `SendMessageToolOptions.admission`; read per call (a value change governs the next message). */
6880
6992
  peerAdmission?: Partial<import("../agents/peer-admission.js").PeerAdmissionConfig>;
6993
+ /**
6994
+ * design/385 §2.1 / §5.1 — the peer-session DIRECTORY: the discovery truth of the cross-session
6995
+ * lane (other sessions of this engine for the same user). A HOST implements the contract (cli: the
6996
+ * pid-keyed registration files; server: its session table) and writes the rows; the engine only
6997
+ * reads them. Seat semantics = the mailbox seat's: NO seat, NO lane — every face stays byte-identical
6998
+ * to a pre-385 build. With the seat wired the engine (a) mounts `ListAgents` (alias `ListPeers`),
6999
+ * (b) opens SendMessage's `session.<id>` address arm and its last `name [ref]` rung, (c) drains this
7000
+ * session's own `session.<sessionId>` box at every turn boundary (the mailbox contract's third
7001
+ * consumption chain), and (d) splices the cross-session rule into the auto-mode classifier slot.
7002
+ * HARD PRECONDITION (design/385 §1.2⑥): `mailboxStore` must be wired AND declare
7003
+ * `crossProcessSafe: true`; otherwise the lane is REFUSED at prepare with a named
7004
+ * `config.peer_lane_unmounted` notice (never mounted on luck), and the seat is inert for that run.
7005
+ */
7006
+ peerDirectory?: import("../agents/peer-directory.js").PeerDirectory;
7007
+ /**
7008
+ * design/385 §4.4 — this deployment's `crossSessionInbound` setting LAYERS for the drain-point
7009
+ * judgment (managed / user / repo, resolved by `resolveCrossSessionInboundSetting` — explicit value
7010
+ * wins, unset ⇒ mode parity, an unrecognized value forces `hold` loudly). Read at every drain, so a
7011
+ * host that re-reads its settings files hands the current layers through a getter. Absent = unset
7012
+ * everywhere (mode parity, the CC default). Inert without {@link peerDirectory}.
7013
+ */
7014
+ crossSessionInbound?: import("../agents/cross-session-judge.js").CrossSessionInboundSettingLayers | (() => import("../agents/cross-session-judge.js").CrossSessionInboundSettingLayers);
6881
7015
  /**
6882
7016
  * design/164 件五 — DEPLOYMENT-level usage governance: allowances that span TASKS, evaluated per
6883
7017
  * principal (or once for the whole deployment when a task declares none). A different axis from
@@ -196,7 +196,23 @@ export const ENGINE_ENVELOPES = Object.freeze([
196
196
  tag: "teammate-message",
197
197
  kind: "framing",
198
198
  mint: "agents/send-message-tool.ts (INTERPOLATED tag — invisible to the literal census)",
199
- guard: "escapeEnvelopeTag(TEAMMATE_MESSAGE_TAG, …) on body/summary + escapeAttributeValue on attributes",
199
+ guard: "body through neutralizePeerBody (the authority family, ENGINE_AUTHORITY_ENVELOPE_TAGS) + escapeEnvelopeTag(TEAMMATE_MESSAGE_TAG, …); summary/teammate_id through escapeAttributeValue",
200
+ fenced: false,
201
+ disclosed: false,
202
+ },
203
+ {
204
+ tag: "agent-message",
205
+ kind: "framing",
206
+ mint: "core/task-notification.ts renderAgentMessageFrame (INTERPOLATED tag — invisible to the literal census; the child → parent uplink carrier)",
207
+ guard: "body through neutralizePeerBody (the authority family, ENGINE_AUTHORITY_ENVELOPE_TAGS — the one helper the three peer carriers share) + escapeEnvelopeTag(AGENT_MESSAGE_TAG, …); the from attribute through attrEscape",
208
+ fenced: false,
209
+ disclosed: false,
210
+ },
211
+ {
212
+ tag: "cross-session-message",
213
+ kind: "framing",
214
+ mint: "agents/cross-session-envelope.ts buildCrossSessionEnvelope / encodeCcPeerFrame (INTERPOLATED tag — invisible to the literal census)",
215
+ guard: "model-face body through neutralizePeerBody (the authority family, ENGINE_AUTHORITY_ENVELOPE_TAGS) + escapeEnvelopeTag(CROSS_SESSION_MESSAGE_TAG, …); every attribute value typed + under its own regex grammar at build, and the parser rebuilds-and-compares (round trip) before accepting any field. The CC wire codec carries bytes as-is (containment is applied at injection when the model face is re-minted)",
200
216
  fenced: false,
201
217
  disclosed: false,
202
218
  },
@@ -175,6 +175,21 @@ export interface WiringManifest {
175
175
  memoryAdmission: boolean;
176
176
  retention: boolean;
177
177
  };
178
+ /**
179
+ * EFFECTIVE half only, present iff the model gate trimmed a default-mounted tool from THIS run's
180
+ * roster: the per-session READ face of the same fact `config.tool_model_gate_removed` announces on
181
+ * the operator sink (one notice per sink, not per session — a client that needs "which default tools
182
+ * did MY session lose" reads it here). `class` = the gate class the table keyed the trim on, `removed`
183
+ * = the wire names not mounted, `restore` = the three valves in one sentence. Minted from the SAME
184
+ * gate decision the notice reads (one source, projected twice); absent = no trim on this run. A gate
185
+ * table with several classes trimming at once reports the FIRST class here and every removed name
186
+ * across classes in `removed` (the notice keeps its per-class lines).
187
+ */
188
+ modelGate?: {
189
+ class: string;
190
+ removed: readonly string[];
191
+ restore: string;
192
+ };
178
193
  /** EFFECTIVE half only — a short, non-sensitive fingerprint (sha256 prefix over the canonical
179
194
  * JSON of this manifest's own resolved facts; every field here is an enum/boolean/count, no
180
195
  * secrets) so an operator can correlate legs that ran under the same resolved assembly. */
@@ -231,6 +246,12 @@ export interface WiringFacts {
231
246
  complianceWired: boolean;
232
247
  memoryAdmissionWired: boolean;
233
248
  retentionPolicyWired: boolean;
249
+ /** Effective half only — see {@link WiringManifest.modelGate}; the static half has no roster to trim. */
250
+ modelGate?: {
251
+ class: string;
252
+ removed: readonly string[];
253
+ restore: string;
254
+ };
234
255
  }
235
256
  /** Named view of the deps seats the static half reads (a `Pick` of the real {@link RunnerDeps} —
236
257
  * single-source shapes, no parallel hand-copied interface). */
@@ -117,6 +117,7 @@ export function deriveWiringManifest(facts) {
117
117
  memoryAdmission: facts.memoryAdmissionWired,
118
118
  retention: facts.retentionPolicyWired,
119
119
  },
120
+ ...(facts.half === "effective" && facts.modelGate !== undefined ? { modelGate: { class: facts.modelGate.class, removed: [...facts.modelGate.removed], restore: facts.modelGate.restore } } : {}),
120
121
  };
121
122
  if (facts.half === "effective") {
122
123
  const { leg: _leg, ...assembly } = manifest;
package/dist/index.d.ts CHANGED
@@ -95,7 +95,7 @@ export { READ_FACE_DEFAULT_DENY_ENTRIES, READ_FACE_BUILTIN_DENY_TABLE, READ_DENY
95
95
  export { deploymentReadFaceClampNotice, resolveReadFace, type ReadFace, type ReadFaceInputs } from "./tools/fs/index.js";
96
96
  export { WRITE_PROTECTED_DEFAULT_TABLE, resolveWriteProtectedTable, compileWriteProtection, type WriteProtectedEntry, type WriteProtectedRow, type WriteProtectedKind, type WriteProtectedHit, type WriteProtectionMatcher, } from "./core/write-protect.js";
97
97
  export { InMemoryToolResultStore, OFFLOAD_TOOL_NAME, DEFAULT_TOOL_RESULT_THRESHOLD_CHARS, assertSafeToolResultRef, buildToolResultRef, toolResultContentSegment, MAX_MINTED_TOOL_RESULT_REF_CHARS, type ToolResultProvenance, assertToolResultProvenanceMatch, normalizeToolResultProvenance, toolResultProvenanceOf, ToolResultRefConflictError, TOOL_RESULT_REF_CONFLICT_CODE, type ToolResultStore, type ToolResultSlice, type ToolResultDeletionReport, } from "./core/tool-result-store.js";
98
- export { InMemoryCheckpointStore, CheckpointError, mintCheckpointId, mintCheckpointToken, checkpointVersionOf, CURRENT_CHECKPOINT_VERSION, MAX_SUPPORTED_CHECKPOINT_VERSION, ORG_ADMISSION_CHECKPOINT_VERSION, F012_CHECKPOINT_VERSION, REAL_APPROVAL_CHECKPOINT_VERSION, RESOURCE_CHECKPOINT_VERSION, TOKEN_CHECKPOINT_VERSION, debitLedger, remainingBudgetMicroUsd, remainingTokens, winnerFromOutcome, validatePendingSteer, readPendingSteerQueue, appendPendingSteer, MAX_PENDING_STEER_CHARS, MAX_PENDING_STEER_ENTRIES, PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES, PENDING_STEER_FROZEN_FIELDS, ACTOR_ASSERTION_FROZEN_FIELDS, MAX_ACTOR_FIELD_CHARS, MAX_STEER_INPUT_ID_CHARS, LEGACY_PENDING_STEER_INPUT_ID, type ActorAssertion, type PendingSteerEntry, type PendingSteerInput, riskSeverity, buildRiskDescriptor, summarizeCheckpoint, type RiskDescriptor, type ProbeCause, type ProbeCauseOperands, type CheckpointStore, type CheckpointSummary, type Checkpoint, type CheckpointToken, type CheckpointGate, type CheckpointState, type SerializedCheckpointState, type CheckpointFaultMode, type PendingAction, type ResumeOutcome, type ResolvedOutcome, type ReopenReason, type ResolveExpectation, type SafetyAxis, type RealApprovalGateBit, type ResourceLedger, type ResourceLimitReason, type PlatformLimitReason, } from "./core/checkpoint-store.js";
98
+ export { InMemoryCheckpointStore, CheckpointError, mintCheckpointId, mintCheckpointToken, checkpointVersionOf, CURRENT_CHECKPOINT_VERSION, MAX_SUPPORTED_CHECKPOINT_VERSION, ORG_ADMISSION_CHECKPOINT_VERSION, F012_CHECKPOINT_VERSION, REAL_APPROVAL_CHECKPOINT_VERSION, RESOURCE_CHECKPOINT_VERSION, TOKEN_CHECKPOINT_VERSION, debitLedger, remainingBudgetMicroUsd, remainingTokens, winnerFromOutcome, validatePendingSteer, readPendingSteerQueue, appendPendingSteer, MAX_PENDING_STEER_CHARS, MAX_PENDING_STEER_ENTRIES, PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES, PENDING_STEER_FROZEN_FIELDS, ACTOR_ASSERTION_FROZEN_FIELDS, MAX_ACTOR_FIELD_CHARS, MAX_STEER_INPUT_ID_CHARS, LEGACY_PENDING_STEER_INPUT_ID, type ActorAssertion, type PendingSteerEntry, type PendingSteerInput, riskSeverity, buildRiskDescriptor, summarizeCheckpoint, type RiskDescriptor, type ProbeCause, type ProbeCauseOperands, type CheckpointStore, type CheckpointSummary, type Checkpoint, type CheckpointToken, type CheckpointGate, type CheckpointState, type SerializedCheckpointState, type CheckpointFaultMode, type PendingAction, type ResumeOutcome, type ResolvedOutcome, type ReopenReason, type ResolveExpectation, type TerminalClaimIntent, type TerminalClaimOutcome, type SafetyAxis, type RealApprovalGateBit, type ResourceLedger, type ResourceLimitReason, type PlatformLimitReason, } from "./core/checkpoint-store.js";
99
99
  export { InMemoryUsageWindowStore, GLOBAL_USAGE_KEY, EMPTY_USAGE_WINDOW_RECORD, chargeUsageRecord, readUsageRecord, usageRetryAfterMs, resolveUsageWindows, type UsageWindow, type UsageWindowStore, type UsageWindowReading, type UsageWindowRecord, type UsageSlot, type UsageBucketRow, } from "./core/usage-window-store.js";
100
100
  export { FileUsageWindowStore } from "./stores/file/usage-window-store.js";
101
101
  export { ENV_LIFETIME_SUSPEND_MARGIN_MS, USAGE_WINDOW_REAP_MARGIN_MS } from "./core/runner/prepare-task.js";
@@ -118,14 +118,14 @@ export { createSensitivePathPolicy, RECOMMENDED_SENSITIVE_PATTERNS } from "./cor
118
118
  export { createFsWriteGatePolicy, type FsWriteGatePolicyOptions } from "./core/fs-write-gate-policy.js";
119
119
  export { RETIRED_TOOL_NAMES } from "./core/tool-name-aliases.js";
120
120
  export { DEFAULT_SUBAGENT_TOOL_NAME } from "./agents/subagent.js";
121
- export { renderTaskNotificationXml, taskNotificationDedupKey, isDelegatedAgentTerminal, isTerminalTaskNotification, SystemInjectionQueue, type TaskNotificationPayload, type TaskNotificationStatus, type ExternalNotificationInput, type SystemInjection, type SystemInjectionPriority, SYSTEM_INJECTION_PRIORITIES, isSystemInjectionPriority, } from "./core/task-notification.js";
121
+ export { renderTaskNotificationXml, taskNotificationDedupKey, isDelegatedAgentTerminal, isTerminalTaskNotification, SystemInjectionQueue, type TaskNotificationPayload, type TaskNotificationStatus, type ExternalNotificationInput, type SystemInjection, type SystemInjectionPriority, SYSTEM_INJECTION_PRIORITIES, isSystemInjectionPriority, AGENT_MESSAGE_TAG, renderAgentMessageFrame, type SemaProvenance, } from "./core/task-notification.js";
122
122
  export { describeStaticWiring, deriveWiringManifest, deriveAskEffective, resolveDeclaredDurability, resolveSubagentTranscriptTier, type SubagentTranscriptTier, resolveAskSeamForm, resolveQuestionSeam, countElicitOptIns, type WiringManifest, type WiringFacts, type WiringLegKind, type AskSeamForm, type AskEffective, type QuestionChannelState, type SeamProvenance, type ParkLaneReason, type ManifestDurability, type StaticWiringDeps, type StaticWiringSpec, } from "./core/wiring-manifest.js";
123
123
  export { probeParkRoundTrip, durableParkGapOf, durableParkGapFor, PARK_SELFCHECK_SCOPE_PREFIX, type ParkSelfCheckResult, type ParkProbeFinding, type ParkProbeFindingCode, } from "./core/park-selfcheck.js";
124
124
  export { type StoreDurability } from "./core/checkpoint-store.js";
125
125
  export { type StoreFidelity } from "./core/checkpoint-store.js";
126
126
  export { projectHumanInput, buildHumanInputEvent, type HumanInputSource, type HumanInputFrame, type HumanInputEvent, type HumanInputDelivery, } from "./core/human-input-projection.js";
127
127
  export { TaskRegistry, defaultTaskRegistry, createTaskOutputTool, createTaskStopTool, type SemaTaskType, type SemaTaskStatus, type SemaTaskHandle, type ParkedClaimTicket, type TaskAccess, type UnifiedTaskOutput, type TaskRetrievalStatus, type StopSource, type RegisterMonitorInput, type MonitorTimers, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccessWorkflowRun, DURABLE_AGENT_HANDLE_RE, } from "./core/task-registry.js";
128
- export { InMemoryMailboxStore, type MailboxStore, type MailboxMessage, type MailboxLease, MailboxStoreError, MAILBOX_TOMBSTONED_RECIPIENT_CODE, } from "./core/mailbox-store.js";
128
+ export { InMemoryMailboxStore, type MailboxStore, type MailboxMessage, type MailboxLease, MailboxStoreError, type MailboxStoreErrorCode, MAILBOX_TOMBSTONED_RECIPIENT_CODE, type MailboxAppendMessage, type MailboxPeerMeta, type MailboxPeerFromMode, type MailboxPeerRecordKind, MAILBOX_PEER_FROM_MODES, MAILBOX_PEER_RECORD_KINDS, MAILBOX_INVALID_PEER_META_CODE, MAILBOX_CROSS_PROCESS_UNSAFE_CODE, readMailboxPeerMeta, mailboxCrossProcessMountVerdict, type MailboxCrossProcessVerdict, } from "./core/mailbox-store.js";
129
129
  export { FileMailboxStore, type FileMailboxStoreOptions } from "./stores/file/mailbox-store.js";
130
130
  export { createFileTaskListStore } from "./stores/file/task-list-store.js";
131
131
  export { createCcFileTaskListStore } from "./stores/cc/task-list-store.js";
@@ -166,7 +166,7 @@ export { createPermissionRulePolicy, validatePermissionRules, parsePermissionRul
166
166
  * and nothing more. Removal is exported without ceremony, because narrowing on a user's behalf is
167
167
  * allowed and widening is not.
168
168
  */
169
- export { parseAllowRuleText, formatAllowRuleText, ruleAdmitsCommand, findAdmittingRule, suggestRulesForCommand, scopeCoversCwd, pathWithinRoot, isRuleLive, renderUntrustedCommandText, BARE_INTERPRETER_NAMES, MAX_RULE_TEXT_CHARS, type PersistedAllowRule, type RuleTombstone, type RuleScope, type RuleDot, type RuleAdd, type RuleAddOrigin, type RuleOffer, type SegmentRuleSuggestion, type SegmentCoverage, type RuleReject, type RuleRejectCode, type ParsedAllowRule, type PersistedRuleTool, type PersistedRuleMatch, } from "./core/permission-rule-model.js";
169
+ export { parseAllowRuleText, formatAllowRuleText, ruleAdmitsCommand, findAdmittingRule, suggestRulesForCommand, scopeCoversCwd, pathWithinRoot, isRuleLive, renderUntrustedCommandText, stripFormatCharacters, UNCOVERED_SEGMENT_REASON_BASELINE, RULE_OFFERS_ABSENCE_BASELINE, type UncoveredSegmentDetail, type EditedRuleBreadthWarning, directoryRuleAdmits, BARE_INTERPRETER_NAMES, MAX_RULE_TEXT_CHARS, type PersistedAllowRule, type RuleTombstone, type RuleScope, type RuleDot, type RuleAdd, type RuleAddOrigin, type RuleOffer, type RuleOfferBatchMember, type SegmentRuleSuggestion, type SegmentCoverage, type RuleReject, type RuleRejectCode, type ParsedAllowRule, type PersistedRuleTool, type PersistedRuleMatch, } from "./core/permission-rule-model.js";
170
170
  export { removePersistedRule, applyTombstones, sameScope, isValidConsentScope, isValidDurableScope, InMemoryPermissionRuleStore, EMPTY_RULE_STORE, type PermissionRuleStore, type PermissionRuleStoreProvider, type StoredAllowRules, type RemoveResult, type PutResult, joinRuleStates, screenRuleSyncState, collectBelowFrontier, ruleSyncVector, joinFrontiers, dotAtOrBelowFrontier, sameRuleOwner, type RuleSyncState, type RuleSyncFrontier, type RuleSyncDrop, type RuleSyncLandingReport, type RuleOwner, type QuarantinedRuleAdd, PERMISSION_RULE_WRITER, writerOf, foldDelta, addDotsOf, assertDeleteDeltaCarriesNoAdd, assertRedemptionNotQuarantined, assertWriteDeltaScopeDurable, type PermissionRuleWriter, type WritablePermissionRuleStore, type RuleWriteDelta, type RuleAddDelta, type RuleDeleteDelta, type RuleSyncJoinDelta, type RawRuleSyncState, type RedemptionAuthorization, } from "./core/permission-rule-store.js";
171
171
  export { syncPermissionRules, parseRuleSyncResponse, PERMISSION_RULE_SYNC_PATH, LOCAL_OWNER_UNSYNCABLE_CODE, type PermissionRuleSyncTransport, type PermissionRuleSyncResult, type RuleSyncRequestBody, type RuleSyncResponseBody, } from "./core/permission-rule-sync.js";
172
172
  export { InMemorySessionRuleOverlay, type SessionRuleOverlay, type SessionRuleOverlayAdd, type SessionRuleOverlayApplyResult, } from "./core/permission-rule-session.js";
@@ -232,7 +232,7 @@ export { sessionRepoContract } from "./core/store-contracts/session-repo-contrac
232
232
  export { toolResultStoreContract } from "./core/store-contracts/tool-result-store-contract.js";
233
233
  export { fileHistoryStoreContract } from "./core/store-contracts/file-history-store-contract.js";
234
234
  export { permissionRuleSyncContract, type PermissionRuleSyncContractHooks } from "./core/store-contracts/permission-rule-sync-contract.js";
235
- export { MAILBOX_CONTRACT_SCOPE, mailboxStoreContract, mailboxAckOwnershipContract, mailboxBundledOnlyContract, mailboxTombstonedRecipientContract, type MailboxTombstonedRecipientContractHooks, } from "./core/store-contracts/mailbox-store-contract.js";
235
+ export { MAILBOX_CONTRACT_SCOPE, mailboxStoreContract, mailboxAckOwnershipContract, mailboxBundledOnlyContract, mailboxTombstonedRecipientContract, type MailboxTombstonedRecipientContractHooks, mailboxCrossProcessContract, type MailboxCrossProcessContractHooks, } from "./core/store-contracts/mailbox-store-contract.js";
236
236
  export { BACKGROUND_AGENT_CONTRACT_SCOPE, backgroundAgentStoreContract, backgroundAgentStoreScopesContract, } from "./core/store-contracts/background-agent-store-contract.js";
237
237
  export { type BackgroundAgentStore, type BackgroundAgentRecord, type BackgroundAgentRowSummary, type BackgroundAgentUsage, canAccessAgentRecord, STALE_RUNNING_REAP_ATTRIBUTION, BackgroundAgentStoreError, InMemoryBackgroundAgentStore, reconcileParkedAgents, queryBackgroundAgents, type BackgroundAgentQuery, } from "./core/background-agent-store.js";
238
238
  export { serveDurableAgentRowLane, buildAgentPollDetails, type AgentPollDetailsInput, } from "./core/task-registry-agent.js";
@@ -252,6 +252,15 @@ export { createSubagentTool, FORK_SUBAGENT_TYPE, GENERAL_PURPOSE_SUBAGENT_TYPE,
252
252
  export { getSessionRetainLedger, releaseSessionRetainLedger, } from "./agents/retain-ledger.js";
253
253
  export { createSendMessageTool, createAgentContinuationVerb, SEND_MESSAGE_TOOL_NAME, type SendMessageToolOptions, type AgentContinuationReceipt } from "./agents/send-message-tool.js";
254
254
  export { createPeerAdmission, peerAdmissionFor, judgePeerAdmission, resolvePeerAdmissionConfig, PEER_ADMISSION_DEFAULTS, PEER_HOP_CHAIN_WINDOW, PEER_MESSAGE_NOTICE, createPeerSelfRef, createPeerInboundChainRef, peerAxisToken, appendHopToken, type PeerAdmission, type PeerAdmissionConfig, type PeerAdmissionOptions, type PeerAdmissionRequest, type PeerAdmissionVerdict, type PeerAdmissionRefusal, type PeerRefusalCode, type PeerAxisTag, type PeerIdentity, type PeerSelfRef, type PeerInboundChainRef, } from "./agents/peer-admission.js";
255
+ export { CROSS_SESSION_MESSAGE_TAG, CROSS_SESSION_MESSAGE_NOTICE, PERMISSION_MODE_CLASSES, isPermissionModeClass, CrossSessionCodecError, PEER_HOP_TOKEN_HEX, PEER_HOP_CHAIN_CARRY_WINDOW, encodePeerAddress, isCanonicalPeerAddress, encodeScopeAttribute, decodeScopeAttribute, canonicalPeerDisplayName, buildCrossSessionEnvelope, parseCrossSessionEnvelope, clampHopChain, encodeCcPeerFrame, decodeCcPeerFrame, type PermissionModeClass, type CrossSessionEnvelopeFields, type CrossSessionEnvelopeParse, type CrossSessionEnvelopeRefusal, type CcPeerFrameFields, type CcPeerFrameParse, } from "./agents/cross-session-envelope.js";
256
+ export { CROSS_SESSION_INBOUND_SETTINGS, isCrossSessionInboundSetting, resolveCrossSessionInboundSetting, CROSS_SESSION_HOLD_CAUSES, describeCrossSessionHoldCause, judgeCrossSessionInbound, foldPermissionModeClass, PEER_SEND_VERDICT_CODES, peerSendVerdictSeverity, type CrossSessionInboundSetting, type CrossSessionSettingSource, type CrossSessionInboundSettingLayers, type ResolvedCrossSessionInboundSetting, type CrossSessionHoldCause, type CrossSessionInboundVerdict, type CrossSessionInboundInput, type PeerSendVerdictCode, type PeerSendVerdict, } from "./agents/cross-session-judge.js";
257
+ export { PEER_REF_MIN, PEER_REF_MAX, PEER_REF_RE, mintPeerRef, formatPeerNameRef, parsePeerNameRef, normalizePeerName, PEER_ADDRESS_PREFIXES, reservedPeerNameReason, type PeerRefEntry, } from "./agents/cross-session-ref.js";
258
+ export { PEER_SESSION_RECORD_SCHEMA_VERSION, PEER_SESSION_RECORD_MAX_BYTES, SESSION_BOX_PREFIX, peerSessionBoxHandle, isPeerSessionId, PEER_SESSION_ID_GRAMMAR, parsePeerSessionAddress, readPeerSessionRecord, defaultPeerLivenessProbe, isPeerSessionProcessAlive, mintPeerSessionCandidates, resolvePeerSessions, createInMemoryPeerDirectory, vetPeerRegistryDirectory, judgePeerRecordFile, type PeerSessionRecord, type PeerSessionLiveness, type PeerSessionTempo, type PeerSessionRecordRefusal, type PeerSessionRecordRead, type PeerLivenessProbe, type PeerDirectory, type PeerDirectoryAccess, type PeerSessionCandidate, type PeerSessionResolution, type InMemoryPeerDirectory, type PeerRegistryDirectoryRefusal, type PeerRegistryDirectoryVerdict, } from "./agents/peer-directory.js";
259
+ export { createListAgentsTool, LIST_AGENTS_TOOL_NAME, LIST_AGENTS_TOOL_ALIAS, LIST_AGENTS_MAX_RESULT_CHARS, type ListAgentsToolOptions, type ListAgentsRow } from "./agents/list-agents-tool.js";
260
+ export { CROSS_SESSION_CLASSIFIER_RULE } from "./agents/cross-session-envelope.js";
261
+ export { PEER_SESSION_ID_UNGRAMMATICAL_CODE, type PeerLaneMountVerdict } from "./agents/peer-session-drain.js";
262
+ export { renderCrossSessionMessageFrame } from "./core/task-notification.js";
263
+ export { type PeerAdmissionStage } from "./agents/peer-admission.js";
255
264
  export { createAgentTranscriptTool, AGENT_TRANSCRIPT_TOOL_NAME, type AgentTranscriptToolOptions, } from "./agents/agent-transcript-tool.js";
256
265
  export { defineAgent } from "./agents/agent-definition.js";
257
266
  export { builtinAgentDefinitions, BUILTIN_READONLY_DENY_TOOLS, EXPLORE_WHEN_TO_USE, EXPLORE_WHEN_TO_USE_LEAN, PLAN_WHEN_TO_USE, EXPLORE_SYSTEM_PROMPT, PLAN_SYSTEM_PROMPT, } from "./agents/builtin-agents.js";
package/dist/index.js CHANGED
@@ -95,14 +95,14 @@ export { createSensitivePathPolicy, RECOMMENDED_SENSITIVE_PATTERNS } from "./cor
95
95
  export { createFsWriteGatePolicy } from "./core/fs-write-gate-policy.js";
96
96
  export { RETIRED_TOOL_NAMES } from "./core/tool-name-aliases.js";
97
97
  export { DEFAULT_SUBAGENT_TOOL_NAME } from "./agents/subagent.js";
98
- export { renderTaskNotificationXml, taskNotificationDedupKey, isDelegatedAgentTerminal, isTerminalTaskNotification, SystemInjectionQueue, SYSTEM_INJECTION_PRIORITIES, isSystemInjectionPriority, } from "./core/task-notification.js";
98
+ export { renderTaskNotificationXml, taskNotificationDedupKey, isDelegatedAgentTerminal, isTerminalTaskNotification, SystemInjectionQueue, SYSTEM_INJECTION_PRIORITIES, isSystemInjectionPriority, AGENT_MESSAGE_TAG, renderAgentMessageFrame, } from "./core/task-notification.js";
99
99
  export { describeStaticWiring, deriveWiringManifest, deriveAskEffective, resolveDeclaredDurability, resolveSubagentTranscriptTier, resolveAskSeamForm, resolveQuestionSeam, countElicitOptIns, } from "./core/wiring-manifest.js";
100
100
  export { probeParkRoundTrip, durableParkGapOf, durableParkGapFor, PARK_SELFCHECK_SCOPE_PREFIX, } from "./core/park-selfcheck.js";
101
101
  export {} from "./core/checkpoint-store.js";
102
102
  export {} from "./core/checkpoint-store.js";
103
103
  export { projectHumanInput, buildHumanInputEvent, } from "./core/human-input-projection.js";
104
104
  export { TaskRegistry, defaultTaskRegistry, createTaskOutputTool, createTaskStopTool, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccessWorkflowRun, DURABLE_AGENT_HANDLE_RE, } from "./core/task-registry.js";
105
- export { InMemoryMailboxStore, MailboxStoreError, MAILBOX_TOMBSTONED_RECIPIENT_CODE, } from "./core/mailbox-store.js";
105
+ export { InMemoryMailboxStore, MailboxStoreError, MAILBOX_TOMBSTONED_RECIPIENT_CODE, MAILBOX_PEER_FROM_MODES, MAILBOX_PEER_RECORD_KINDS, MAILBOX_INVALID_PEER_META_CODE, MAILBOX_CROSS_PROCESS_UNSAFE_CODE, readMailboxPeerMeta, mailboxCrossProcessMountVerdict, } from "./core/mailbox-store.js";
106
106
  export { FileMailboxStore } from "./stores/file/mailbox-store.js";
107
107
  export { createFileTaskListStore } from "./stores/file/task-list-store.js";
108
108
  export { createCcFileTaskListStore } from "./stores/cc/task-list-store.js";
@@ -126,7 +126,7 @@ export { AUTO_MODE_BASE_PROMPT, AUTO_MODE_PERMISSIONS_EXTERNAL } from "./core/au
126
126
  export { AUTO_MODE_ARMING_RECIPE_VERSION, autoModeArmingRecipeOf, sanitizeAutoModeArmingRecipe, foldAutoModeArming, } from "./core/auto-mode-arming.js";
127
127
  export { rebuildAutoModeDecider, } from "./core/auto-mode-rebuild.js";
128
128
  export { createPermissionRulePolicy, validatePermissionRules, parsePermissionRule, wildcardMatch, isNamespacedCoveringRuleName, namespacedRuleNameCovers, } from "./core/permission-rules.js";
129
- export { parseAllowRuleText, formatAllowRuleText, ruleAdmitsCommand, findAdmittingRule, suggestRulesForCommand, scopeCoversCwd, pathWithinRoot, isRuleLive, renderUntrustedCommandText, BARE_INTERPRETER_NAMES, MAX_RULE_TEXT_CHARS, } from "./core/permission-rule-model.js";
129
+ export { parseAllowRuleText, formatAllowRuleText, ruleAdmitsCommand, findAdmittingRule, suggestRulesForCommand, scopeCoversCwd, pathWithinRoot, isRuleLive, renderUntrustedCommandText, stripFormatCharacters, UNCOVERED_SEGMENT_REASON_BASELINE, RULE_OFFERS_ABSENCE_BASELINE, directoryRuleAdmits, BARE_INTERPRETER_NAMES, MAX_RULE_TEXT_CHARS, } from "./core/permission-rule-model.js";
130
130
  export { removePersistedRule, applyTombstones, sameScope, isValidConsentScope, isValidDurableScope, InMemoryPermissionRuleStore, EMPTY_RULE_STORE, joinRuleStates, screenRuleSyncState, collectBelowFrontier, ruleSyncVector, joinFrontiers, dotAtOrBelowFrontier, sameRuleOwner, PERMISSION_RULE_WRITER, writerOf, foldDelta, addDotsOf, assertDeleteDeltaCarriesNoAdd, assertRedemptionNotQuarantined, assertWriteDeltaScopeDurable, } from "./core/permission-rule-store.js";
131
131
  export { syncPermissionRules, parseRuleSyncResponse, PERMISSION_RULE_SYNC_PATH, LOCAL_OWNER_UNSYNCABLE_CODE, } from "./core/permission-rule-sync.js";
132
132
  export { InMemorySessionRuleOverlay, } from "./core/permission-rule-session.js";
@@ -191,7 +191,7 @@ export { sessionRepoContract } from "./core/store-contracts/session-repo-contrac
191
191
  export { toolResultStoreContract } from "./core/store-contracts/tool-result-store-contract.js";
192
192
  export { fileHistoryStoreContract } from "./core/store-contracts/file-history-store-contract.js";
193
193
  export { permissionRuleSyncContract } from "./core/store-contracts/permission-rule-sync-contract.js";
194
- export { MAILBOX_CONTRACT_SCOPE, mailboxStoreContract, mailboxAckOwnershipContract, mailboxBundledOnlyContract, mailboxTombstonedRecipientContract, } from "./core/store-contracts/mailbox-store-contract.js";
194
+ export { MAILBOX_CONTRACT_SCOPE, mailboxStoreContract, mailboxAckOwnershipContract, mailboxBundledOnlyContract, mailboxTombstonedRecipientContract, mailboxCrossProcessContract, } from "./core/store-contracts/mailbox-store-contract.js";
195
195
  export { BACKGROUND_AGENT_CONTRACT_SCOPE, backgroundAgentStoreContract, backgroundAgentStoreScopesContract, } from "./core/store-contracts/background-agent-store-contract.js";
196
196
  export { canAccessAgentRecord, STALE_RUNNING_REAP_ATTRIBUTION, BackgroundAgentStoreError, InMemoryBackgroundAgentStore, reconcileParkedAgents, queryBackgroundAgents, } from "./core/background-agent-store.js";
197
197
  export { serveDurableAgentRowLane, buildAgentPollDetails, } from "./core/task-registry-agent.js";
@@ -209,6 +209,15 @@ export { createSubagentTool, FORK_SUBAGENT_TYPE, GENERAL_PURPOSE_SUBAGENT_TYPE,
209
209
  export { getSessionRetainLedger, releaseSessionRetainLedger, } from "./agents/retain-ledger.js";
210
210
  export { createSendMessageTool, createAgentContinuationVerb, SEND_MESSAGE_TOOL_NAME } from "./agents/send-message-tool.js";
211
211
  export { createPeerAdmission, peerAdmissionFor, judgePeerAdmission, resolvePeerAdmissionConfig, PEER_ADMISSION_DEFAULTS, PEER_HOP_CHAIN_WINDOW, PEER_MESSAGE_NOTICE, createPeerSelfRef, createPeerInboundChainRef, peerAxisToken, appendHopToken, } from "./agents/peer-admission.js";
212
+ export { CROSS_SESSION_MESSAGE_TAG, CROSS_SESSION_MESSAGE_NOTICE, PERMISSION_MODE_CLASSES, isPermissionModeClass, CrossSessionCodecError, PEER_HOP_TOKEN_HEX, PEER_HOP_CHAIN_CARRY_WINDOW, encodePeerAddress, isCanonicalPeerAddress, encodeScopeAttribute, decodeScopeAttribute, canonicalPeerDisplayName, buildCrossSessionEnvelope, parseCrossSessionEnvelope, clampHopChain, encodeCcPeerFrame, decodeCcPeerFrame, } from "./agents/cross-session-envelope.js";
213
+ export { CROSS_SESSION_INBOUND_SETTINGS, isCrossSessionInboundSetting, resolveCrossSessionInboundSetting, CROSS_SESSION_HOLD_CAUSES, describeCrossSessionHoldCause, judgeCrossSessionInbound, foldPermissionModeClass, PEER_SEND_VERDICT_CODES, peerSendVerdictSeverity, } from "./agents/cross-session-judge.js";
214
+ export { PEER_REF_MIN, PEER_REF_MAX, PEER_REF_RE, mintPeerRef, formatPeerNameRef, parsePeerNameRef, normalizePeerName, PEER_ADDRESS_PREFIXES, reservedPeerNameReason, } from "./agents/cross-session-ref.js";
215
+ export { PEER_SESSION_RECORD_SCHEMA_VERSION, PEER_SESSION_RECORD_MAX_BYTES, SESSION_BOX_PREFIX, peerSessionBoxHandle, isPeerSessionId, PEER_SESSION_ID_GRAMMAR, parsePeerSessionAddress, readPeerSessionRecord, defaultPeerLivenessProbe, isPeerSessionProcessAlive, mintPeerSessionCandidates, resolvePeerSessions, createInMemoryPeerDirectory, vetPeerRegistryDirectory, judgePeerRecordFile, } from "./agents/peer-directory.js";
216
+ export { createListAgentsTool, LIST_AGENTS_TOOL_NAME, LIST_AGENTS_TOOL_ALIAS, LIST_AGENTS_MAX_RESULT_CHARS } from "./agents/list-agents-tool.js";
217
+ export { CROSS_SESSION_CLASSIFIER_RULE } from "./agents/cross-session-envelope.js";
218
+ export { PEER_SESSION_ID_UNGRAMMATICAL_CODE } from "./agents/peer-session-drain.js";
219
+ export { renderCrossSessionMessageFrame } from "./core/task-notification.js";
220
+ export {} from "./agents/peer-admission.js";
212
221
  export { createAgentTranscriptTool, AGENT_TRANSCRIPT_TOOL_NAME, } from "./agents/agent-transcript-tool.js";
213
222
  export { defineAgent } from "./agents/agent-definition.js";
214
223
  export { builtinAgentDefinitions, BUILTIN_READONLY_DENY_TOOLS, EXPLORE_WHEN_TO_USE, EXPLORE_WHEN_TO_USE_LEAN, PLAN_WHEN_TO_USE, EXPLORE_SYSTEM_PROMPT, PLAN_SYSTEM_PROMPT, } from "./agents/builtin-agents.js";
@@ -1,4 +1,4 @@
1
- import type { MailboxStore } from "../../core/mailbox-store.js";
1
+ import { type MailboxStore } from "../../core/mailbox-store.js";
2
2
  /** CC's path-component sanitize rule (README §一 Jeo/UJt): non-alphanumerics → "-", lowercased. */
3
3
  export declare function sanitizeCcAgentName(name: string): string;
4
4
  export interface CcFileMailboxStoreOptions {
@@ -1,6 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, rmSync, readdirSync } from "node:fs";
2
2
  import { join, resolve } from "node:path";
3
3
  import { randomUUID } from "node:crypto";
4
+ import { readMailboxPeerMeta } from "../../core/mailbox-store.js";
4
5
  import { atomicWriteFile, canonicalStoreKey } from "../file/fs-atomic.js";
5
6
  import { withCcLock } from "./lockfile.js";
6
7
  const INBOX_FILE_EXT = ".json";
@@ -94,6 +95,15 @@ export function createCcFileMailboxStore(opts) {
94
95
  note(path, `${dropped} malformed inbox entries skipped (first: ${firstReason})`);
95
96
  return kept;
96
97
  };
98
+ const readBackPeerMeta = (raw) => {
99
+ try {
100
+ const meta = readMailboxPeerMeta(raw);
101
+ return meta === undefined ? {} : { peerMeta: meta };
102
+ }
103
+ catch {
104
+ return {};
105
+ }
106
+ };
97
107
  const saveBox = (path, box) => {
98
108
  atomicWriteFile(inboxDir, path, JSON.stringify(box, null, 2));
99
109
  };
@@ -136,6 +146,7 @@ export function createCcFileMailboxStore(opts) {
136
146
  return {
137
147
  append: (scope, handle, msg) => {
138
148
  requireDefaultScope(scope);
149
+ const peerMeta = readMailboxPeerMeta(msg.peerMeta);
139
150
  mkdirSync(inboxDir, { recursive: true });
140
151
  const path = inboxPath(handle);
141
152
  const notes = deferredNotes();
@@ -150,6 +161,7 @@ export function createCcFileMailboxStore(opts) {
150
161
  msg_id: randomUUID(),
151
162
  read: false,
152
163
  ...(msg.hopChain !== undefined ? { hopChain: [...msg.hopChain] } : {}),
164
+ ...(peerMeta !== undefined ? { peerMeta } : {}),
153
165
  });
154
166
  saveBox(path, box);
155
167
  return box.length;
@@ -178,6 +190,7 @@ export function createCcFileMailboxStore(opts) {
178
190
  ...(Array.isArray(e.hopChain) && e.hopChain.every((h) => typeof h === "string")
179
191
  ? { hopChain: e.hopChain.filter((h) => typeof h === "string") }
180
192
  : {}),
193
+ ...readBackPeerMeta(e.peerMeta),
181
194
  }));
182
195
  if (pending.length === 0)
183
196
  return Promise.resolve(null);
@@ -209,7 +209,7 @@ export declare function writeRootAdoptionFile(root: string, content: RootAdoptio
209
209
  * and it is the ONLY thing this function does — it never reaches an object that already exists. So a
210
210
  * store instance constructed BEFORE the marker landed keeps writing for as long as it is held, in
211
211
  * ANOTHER OS process (cross-process sharing of one data dir is the file family's documented
212
- * UNSUPPORTED shape task-list F-14, mailbox RB-249) and, symmetrically, in THIS one (an independent
212
+ * UNSUPPORTED shape for the task-list store — F-14; the mailbox store is the exception since its per-box lock upgrade, see `stores/file/mailbox-store.ts`) and, symmetrically, in THIS one (an independent
213
213
  * store face built before the adoption started; the arc's `LOCK` acquisition excludes a live
214
214
  * `FileStorageBackend`, which is the only shape that takes that lock). Adoption adds no new promise on
215
215
  * either side of that seam — see the freeze note on `adoptLocalDataRoot` for the full division.