@sema-agent/core 7.64.0 → 7.66.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 (192) hide show
  1. package/CHANGELOG.md +571 -0
  2. package/dist/agents/delegation-registry-seat.d.ts +15 -0
  3. package/dist/agents/delegation-registry-seat.js +13 -0
  4. package/dist/agents/org-delivery-gate.d.ts +8 -1
  5. package/dist/agents/org-delivery-gate.js +9 -3
  6. package/dist/agents/peer-held-queue.js +1 -1
  7. package/dist/agents/peer-idle.js +1 -1
  8. package/dist/agents/peer-session-drain.d.ts +51 -12
  9. package/dist/agents/peer-session-drain.js +47 -34
  10. package/dist/agents/read-inbox-tool.d.ts +6 -2
  11. package/dist/agents/read-inbox-tool.js +18 -5
  12. package/dist/agents/subagent.d.ts +3 -1
  13. package/dist/agents/subagent.js +84 -77
  14. package/dist/brain/reasoning.d.ts +2 -0
  15. package/dist/brain/reasoning.js +1 -0
  16. package/dist/core/allow-entry.d.ts +9 -0
  17. package/dist/core/allow-entry.js +7 -1
  18. package/dist/core/ask-origin.d.ts +23 -3
  19. package/dist/core/ask-origin.js +11 -1
  20. package/dist/core/auto-promote.d.ts +3 -2
  21. package/dist/core/background-agent-store.d.ts +7 -0
  22. package/dist/core/checkpoint-store.d.ts +2 -3
  23. package/dist/core/context-settings.d.ts +1 -2
  24. package/dist/core/context-settings.js +1 -1
  25. package/dist/core/engine-attestation.d.ts +2 -2
  26. package/dist/core/engine-notice.d.ts +13 -1
  27. package/dist/core/engine-notice.js +3 -1
  28. package/dist/core/file-history-store.d.ts +2 -2
  29. package/dist/core/file-history-store.js +0 -4
  30. package/dist/core/gate-fold.js +3 -1
  31. package/dist/core/governance-codes.d.ts +6 -4
  32. package/dist/core/governance-codes.js +5 -3
  33. package/dist/core/human-input-projection.d.ts +9 -0
  34. package/dist/core/human-input-projection.js +13 -0
  35. package/dist/core/input-author.d.ts +66 -6
  36. package/dist/core/input-author.js +21 -3
  37. package/dist/core/leg-identity.d.ts +18 -2
  38. package/dist/core/leg-identity.js +5 -7
  39. package/dist/core/mailbox-store.d.ts +1 -1
  40. package/dist/core/memory-engine/consolidation.d.ts +30 -10
  41. package/dist/core/memory-engine/consolidation.js +41 -6
  42. package/dist/core/memory-engine/control-objects.d.ts +36 -3
  43. package/dist/core/memory-engine/control-objects.js +134 -12
  44. package/dist/core/memory-engine/control-plane-adoption.d.ts +13 -9
  45. package/dist/core/memory-engine/control-plane-adoption.js +58 -31
  46. package/dist/core/memory-engine/delegation-settlement.d.ts +75 -52
  47. package/dist/core/memory-engine/delegation-settlement.js +211 -228
  48. package/dist/core/memory-engine/dual-root.d.ts +3 -2
  49. package/dist/core/memory-engine/dual-root.js +5 -1
  50. package/dist/core/memory-engine/engine.d.ts +33 -16
  51. package/dist/core/memory-engine/engine.js +213 -177
  52. package/dist/core/memory-engine/file-backend.d.ts +21 -12
  53. package/dist/core/memory-engine/file-backend.js +58 -104
  54. package/dist/core/memory-engine/index.d.ts +2 -2
  55. package/dist/core/memory-engine/index.js +2 -2
  56. package/dist/core/memory-engine/layout.d.ts +184 -83
  57. package/dist/core/memory-engine/layout.js +267 -172
  58. package/dist/core/memory-engine/memory-age.d.ts +12 -0
  59. package/dist/core/memory-engine/memory-age.js +17 -0
  60. package/dist/core/memory-engine/memory-backend-contract.js +12 -11
  61. package/dist/core/memory-engine/memory-deployment.d.ts +4 -3
  62. package/dist/core/memory-engine/memory-deployment.js +6 -3
  63. package/dist/core/memory-engine/origin-clearance.d.ts +43 -15
  64. package/dist/core/memory-engine/origin-clearance.js +142 -58
  65. package/dist/core/memory-engine/tools.d.ts +2 -2
  66. package/dist/core/memory-engine/tools.js +7 -7
  67. package/dist/core/memory-engine/types.d.ts +16 -10
  68. package/dist/core/memory-vector.d.ts +6 -14
  69. package/dist/core/memory.d.ts +0 -462
  70. package/dist/core/memory.js +0 -333
  71. package/dist/core/model-receipt.d.ts +2 -1
  72. package/dist/core/model-receipt.js +5 -0
  73. package/dist/core/mods/dollar.d.ts +12 -0
  74. package/dist/core/mods/kernel/dispatch.d.ts +3 -1
  75. package/dist/core/mods/kernel/dispatch.js +5 -2
  76. package/dist/core/mods/kernel/events.d.ts +3 -1
  77. package/dist/core/mods/kernel/events.js +2 -2
  78. package/dist/core/mods/prompt-submit.d.ts +4 -0
  79. package/dist/core/mods/prompt-submit.js +24 -0
  80. package/dist/core/mods/stations.d.ts +23 -4
  81. package/dist/core/mods/stations.js +14 -7
  82. package/dist/core/permission-rule-consent.d.ts +49 -18
  83. package/dist/core/permission-rule-consent.js +59 -38
  84. package/dist/core/permission-rule-store.d.ts +24 -14
  85. package/dist/core/retention.d.ts +2 -7
  86. package/dist/core/retention.js +0 -1
  87. package/dist/core/retired-host-table-account.d.ts +19 -0
  88. package/dist/core/retired-host-table-account.js +28 -0
  89. package/dist/core/retired-tool-name-account.d.ts +60 -0
  90. package/dist/core/retired-tool-name-account.js +32 -0
  91. package/dist/core/roles.d.ts +3 -1
  92. package/dist/core/roles.js +5 -2
  93. package/dist/core/runner/classifier-ladder.d.ts +3 -1
  94. package/dist/core/runner/classifier-ladder.js +2 -2
  95. package/dist/core/runner/compact-session.js +2 -1
  96. package/dist/core/runner/contracts.d.ts +9 -9
  97. package/dist/core/runner/delegation-owner.d.ts +0 -8
  98. package/dist/core/runner/delegation-owner.js +1 -3
  99. package/dist/core/runner/gate-exit.js +9 -2
  100. package/dist/core/runner/memory-consolidation-driver.js +2 -2
  101. package/dist/core/runner/prepare-config-doors.js +1 -1
  102. package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
  103. package/dist/core/runner/prepare-delegation-surface.js +5 -3
  104. package/dist/core/runner/prepare-gate-stations.d.ts +8 -5
  105. package/dist/core/runner/prepare-gate-stations.js +13 -5
  106. package/dist/core/runner/prepare-inherited-gate.js +2 -0
  107. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  108. package/dist/core/runner/prepare-memory.js +35 -14
  109. package/dist/core/runner/prepare-policy-chain.js +12 -3
  110. package/dist/core/runner/prepare-project-context.js +2 -2
  111. package/dist/core/runner/prepare-task.d.ts +9 -1
  112. package/dist/core/runner/prepare-task.js +6 -5
  113. package/dist/core/runner/prepare-wiring-manifest.js +5 -4
  114. package/dist/core/runner/prompt-suggestions.js +1 -1
  115. package/dist/core/runner/run-identity-wiring.js +2 -2
  116. package/dist/core/runner/run-leg.js +3 -3
  117. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  118. package/dist/core/runner/run-notification-lane.js +2 -2
  119. package/dist/core/runner/runtask.js +6 -3
  120. package/dist/core/runner/steer-admission.d.ts +11 -2
  121. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  122. package/dist/core/runner/stream-steer-verb.js +67 -14
  123. package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -8
  124. package/dist/core/runner/sub-agent-deny-lists.js +22 -8
  125. package/dist/core/runner-deps.d.ts +4 -4
  126. package/dist/core/secret-env.d.ts +2 -2
  127. package/dist/core/secret-env.js +6 -20
  128. package/dist/core/session-store.d.ts +6 -6
  129. package/dist/core/session-store.js +3 -3
  130. package/dist/core/shell-run-candidates.js +3 -3
  131. package/dist/core/side-query.js +1 -1
  132. package/dist/core/skill-grant.d.ts +7 -0
  133. package/dist/core/skill-grant.js +14 -5
  134. package/dist/core/store-contracts/background-agent-store-contract.js +13 -0
  135. package/dist/core/task-event.d.ts +14 -0
  136. package/dist/core/task-notification.d.ts +35 -8
  137. package/dist/core/task-notification.js +31 -13
  138. package/dist/core/task-registry-agent.js +1 -0
  139. package/dist/core/task-registry-shared.d.ts +4 -0
  140. package/dist/core/tool-errors.d.ts +3 -3
  141. package/dist/core/tool-policy.js +2 -3
  142. package/dist/core/tool-spec.d.ts +20 -10
  143. package/dist/core/user-attachment.d.ts +5 -1
  144. package/dist/core/user-attachment.js +11 -5
  145. package/dist/core/write-protect.d.ts +16 -0
  146. package/dist/core/write-protect.js +10 -0
  147. package/dist/engine/harness/agent-harness.d.ts +19 -11
  148. package/dist/engine/harness/agent-harness.js +7 -4
  149. package/dist/engine/llm/types.d.ts +22 -10
  150. package/dist/engine/session/repo-utils.d.ts +14 -4
  151. package/dist/engine/session/repo-utils.js +5 -4
  152. package/dist/index.d.ts +10 -8
  153. package/dist/index.js +9 -7
  154. package/dist/prompts/default.d.ts +1 -2
  155. package/dist/scenarios/full-body.d.ts +1 -1
  156. package/dist/shell/lex.d.ts +50 -15
  157. package/dist/shell/lex.js +43 -9
  158. package/dist/stores/file/adoption/adopt.d.ts +1 -1
  159. package/dist/stores/file/index.d.ts +1 -15
  160. package/dist/stores/file/index.js +1 -15
  161. package/dist/stores/file/permission-rule-store.d.ts +12 -1
  162. package/dist/stores/file/permission-rule-store.js +31 -4
  163. package/dist/stores/file/session-store.js +1 -1
  164. package/dist/tools/fs/fs-bash.js +3 -3
  165. package/dist/tools/fs/removal-targets.d.ts +8 -2
  166. package/dist/tools/fs/removal-targets.js +31 -4
  167. package/dist/tools/fs/shell-read-argv.js +7 -1
  168. package/dist/tools/fs/shell-read-bindings.d.ts +21 -5
  169. package/dist/tools/fs/shell-read-bindings.js +130 -44
  170. package/dist/tools/fs/shell-read-plan.js +95 -29
  171. package/dist/tools/fs/shell-read-sourced.d.ts +25 -0
  172. package/dist/tools/fs/shell-read-sourced.js +119 -0
  173. package/dist/tools/fs/shell-read-word.d.ts +2 -2
  174. package/dist/tools/fs/shell-read-word.js +4 -5
  175. package/dist/tools/fs/shell-read-workdir.d.ts +19 -3
  176. package/dist/tools/fs/shell-read-workdir.js +60 -15
  177. package/dist/tools/fs/shell-reentry-text.d.ts +10 -2
  178. package/dist/tools/fs/shell-reentry-text.js +11 -4
  179. package/package.json +2 -2
  180. package/test/export-surface.snapshot.json +21 -79
  181. package/wire-changes/core-stores-sql@7.65.0.json +30 -0
  182. package/wire-changes/core-stores-sql@7.66.0.json +30 -0
  183. package/wire-changes/core@7.65.0.json +1650 -0
  184. package/wire-changes/core@7.66.0.json +1218 -0
  185. package/wire-changes/mods-kernel@7.65.0.json +30 -0
  186. package/wire-changes/mods-kernel@7.66.0.json +65 -0
  187. package/wire-changes/primitives@7.65.0.json +337 -0
  188. package/wire-changes/primitives@7.66.0.json +30 -0
  189. package/dist/core/memory-recall.d.ts +0 -208
  190. package/dist/core/memory-recall.js +0 -136
  191. package/dist/stores/file/memory-store.d.ts +0 -124
  192. package/dist/stores/file/memory-store.js +0 -353
@@ -464,8 +464,18 @@ export function classifyAsk(d, facts) {
464
464
  const askClass = ASK_CLASSES.find((c) => classes.has(c));
465
465
  return { classes, askClass, row: foldArbitrationRow(classes, facts.readFace, facts.askFace), ...(facts.askFace !== undefined ? { askFace: facts.askFace } : {}) };
466
466
  }
467
+ export function unresolvedAskDenialMessage(cause, toolName, question, parkFailed) {
468
+ if (cause === "approver_unavailable") {
469
+ return `approval required for "${toolName}" but the approver reported unavailable (no reachable operator for this ask)${parkFailed ? "" : " and no durable approval gate is armed"} — denied fail-closed: ${question}`;
470
+ }
471
+ return `Permission for this tool use was denied: it requires interactive approval, and permission prompts are not available in this session (nobody can be asked to approve "${toolName}" in this run — headless auto-deny). The action was NOT performed. Do not claim it succeeded${parkFailed ? "" : ", and do not retry it in this session"} — report the limitation to the user, or suggest an alternative. What was requested: ${question}`;
472
+ }
473
+ export function unresolvedAskQuestionOf(cause, toolName, text) {
474
+ const stem = unresolvedAskDenialMessage(cause, toolName, "", false);
475
+ return text.startsWith(stem) ? text.slice(stem.length) : undefined;
476
+ }
467
477
  export function headlessDenialMessage(toolName, askMessage) {
468
- return `Permission for this tool use was denied: it requires interactive approval, and permission prompts are not available in this session (nobody can be asked to approve "${toolName}" in this run — headless auto-deny). The action was NOT performed. Do not claim it succeeded, and do not retry it in this session — report the limitation to the user, or suggest an alternative. What was requested: ${askMessage}`;
478
+ return unresolvedAskDenialMessage("no_approver_wired", toolName, askMessage, false);
469
479
  }
470
480
  const REFUSED_CAPABILITY_GUIDANCE = "IMPORTANT: you may try to accomplish this with other tools that would naturally be used for it (for example `head` instead of `cat`), but do not work around this denial in malicious ways — for example, do not use your ability to run tests to run non-test actions; only work around it in reasonable ways that keep to the intent behind it. If you believe this capability is essential to complete the user's request, STOP and explain to the user what you were trying to do and why you need this permission, and let the user decide how to proceed.";
471
481
  export function dontAskRefusalMessage(input) {
@@ -16,8 +16,9 @@ export type AutoPromoteTerminal = "auto_promote" | "candidate_only" | "needs_hum
16
16
  */
17
17
  export interface PromotedRecord {
18
18
  /**
19
- * Gate-2 chokepoint result: the promotable write landed WITH a positive utility verdict (memory.ts:240),
20
- * or it was absent/ungated. Only `"present_positive"` is gate-passing; `"absent_or_ungated"` ⇒ needs_human.
19
+ * Gate-2 result: the promotable write landed WITH a positive utility verdict, or it was absent/ungated. The core
20
+ * ships no Gate-2 door since 7.65.0 — the caller computes this verdict itself and hands it in. Only
21
+ * `"present_positive"` is gate-passing; `"absent_or_ungated"` ⇒ needs_human.
21
22
  */
22
23
  gate2Verdict: "present_positive" | "absent_or_ungated";
23
24
  }
@@ -38,6 +38,13 @@ export interface BackgroundAgentRecord {
38
38
  * restart, intermediate spawner sessions are dead ends — "everything under this host session"
39
39
  * keys on THIS field (listBySession matches it as a second arm), not on an alias walk. */
40
40
  rootSessionId?: string;
41
+ /** The occupant of {@link rootSessionId}'s row (its `SessionMetadata.incarnation`) as the spawning tree held it — the other
42
+ * half of the root anchor's address, written beside it by the registration that creates the row. A revival reads it back
43
+ * with the anchor, so the frames its subtree escalates to the root are addressed to the occupant the tree was born under
44
+ * (delivered while that occupant holds the root, discarded and announced once the id was created again). ABSENT = the
45
+ * spawning tree held no occupant for its root, or a row an earlier release wrote: the revived tree's root occupant is
46
+ * then unknown. A store returns it as written, absent as absent. */
47
+ rootSessionIncarnation?: string;
41
48
  parentTaskId?: string;
42
49
  /** The agent's name — the spawner's explicit one, or the one the engine derives from `handle`
43
50
  * (`engineAgentName`) when the spawn named none. Written by the registration that creates the row, so
@@ -18,8 +18,7 @@ export { BINDING_CHECKPOINT_VERSION, CHECKPOINT_CONFIG_REFUSAL_CODES, CHECKPOINT
18
18
  /**
19
19
  * design/45 — the **durable-checkpoint** primitive: cross-process / resumable `suspend`/`resume`.
20
20
  *
21
- * A {@link CheckpointStore} is the third pluggable durable seam (alongside `ToolResultStore` and
22
- * `MemoryStore`): a token-addressable store of "enough state to resume a suspended task", with an
21
+ * A {@link CheckpointStore} is a pluggable durable seam (alongside `ToolResultStore`): a token-addressable store of "enough state to resume a suspended task", with an
23
22
  * **atomic CAS `resolve`** so a token is acted on **exactly once** even across replicas / double
24
23
  * approvals. Two profiles share this one seam (design/43 原语 4, proven by two service instances):
25
24
  *
@@ -2131,7 +2130,7 @@ export declare function summarizeCheckpoint(cp: Checkpoint, disclose?: (sentence
2131
2130
  */
2132
2131
  export declare function summarizeStoredCheckpoint(cp: Checkpoint, memo: WeakMap<Checkpoint, CheckpointRowVerdict>, disclose?: (sentence: string) => void): CheckpointSummary;
2133
2132
  /**
2134
- * The pluggable durable seam (design/45 §2.1). Symmetric with `ToolResultStore`/`MemoryStore`:
2133
+ * The pluggable durable seam (design/45 §2.1). Symmetric with `ToolResultStore`:
2135
2134
  * create-once `put`, `get`, an **atomic CAS `resolve`** (the once-only foundation), and a `reap` for TTL
2136
2135
  * expiry. A durable backend (TiDB) makes resume cross-replica; the default in-memory impl is single
2137
2136
  * instance / tests only.
@@ -44,7 +44,7 @@ export interface ContextWindowOverlay {
44
44
  * only — a pass outside a run is a requested one) and a deployment's overlay carry them, and every one of those
45
45
  * doors judges them with {@link compactionSeatsDefect}.
46
46
  */
47
- declare const COMPACTION_SEATS: readonly ["autoCompact", "manualCompact"];
47
+ export declare const COMPACTION_SEATS: readonly ["autoCompact", "manualCompact"];
48
48
  export type CompactionSeat = (typeof COMPACTION_SEATS)[number];
49
49
  /**
50
50
  * The seats' ONE judgment, for every bag that carries them (a task's `compaction`, a `Runner.compactSession` request's
@@ -131,4 +131,3 @@ export declare function compactionEnabled(seat: CompactionSeat, requested: Reado
131
131
  * number there is.
132
132
  */
133
133
  export declare function physicalWindowOf(model: Model, overlay: ContextWindowOverlay | undefined): number;
134
- export {};
@@ -4,7 +4,7 @@ import { RETIRED_COMPACTION_SEAT_KEYS, retiredKeyOf, retiredKeyRefusal } from ".
4
4
  import { describeRejectedValue } from "./tool-search-setting.js";
5
5
  const OVERLAY_KEYS = optionKeys()({ contextTokens: 0, autoCompactTokens: 0, autoCompact: 0, manualCompact: 0 });
6
6
  const OVERLAY_READ_NAMES = Object.freeze([...OVERLAY_KEYS, ...Object.keys(RETIRED_COMPACTION_SEAT_KEYS)]);
7
- const COMPACTION_SEATS = Object.freeze(["autoCompact", "manualCompact"]);
7
+ export const COMPACTION_SEATS = Object.freeze(["autoCompact", "manualCompact"]);
8
8
  const SEAT_REACH = Object.freeze({
9
9
  autoCompact: "false switches off the passes the engine starts by itself",
10
10
  manualCompact: "false refuses the passes a caller asks for",
@@ -71,8 +71,8 @@ export interface EngineAttestation {
71
71
  * is the engine's generic question (the chain's entry mint, {@link import("./ask-origin.js").chainAskReasonsOf}, writes no
72
72
  * entry for one), and the literals it quotes. Valid only while the decision's `message` is still that sentence — a later
73
73
  * layer that spread the decision and put its own words in `message` keeps them, and the account then reads as absent.
74
- * Written only by the station that composed the sentence, for that sentence (the write gate's and the plan mode's questions;
75
- * the ask resolver's refusal that quotes one of them); a composer cannot state it (an unbranded record is refused). */
74
+ * Written only by the station that composed the sentence, for that sentence (the write gate's and the plan mode's questions,
75
+ * and the longer text `askWithTableSentence` makes of one of them; the ask resolver's refusal that quotes one of them); a composer cannot state it (an unbranded record is refused). */
76
76
  readonly sentence?: EngineSentence;
77
77
  /** The askers a station read off this ask where it first received it, before it narrated the sentence (an inherited station
78
78
  * floating an ancestor's ask back into this leg's fold: its mark frames, its denial-limit fallback's sentence). The chain's
@@ -612,6 +612,15 @@ export interface EngineNotice {
612
612
  * sessionId }` — `entries` every one, `entry` through the same reading as `permission.allowed_tool_not_granted`'s;
613
613
  * `reader` ∈ `no_rule` / `named_no_tool` / `grammar_revised`; `rewrite.by` = `operator_write_without_rev`; `rulesSessionId` the session
614
614
  * whose rules they are (an ancestor's on a delegated child), `sessionId` the run that read them.
615
+ * - `"config.legacy_tool_name"` — a tool policy's `deny` or `ask` list (the run's own policy, the session's stored rules, or the rules
616
+ * an ancestor's session handed down) holds names of tools the engine retired with NO successor (`TaskOutput`, `TeamCreate`, …: the
617
+ * retirement table's `removed` and `folded` lines). Such a name reaches no tool in any roster, so the prepare-time name audit leaves
618
+ * the entry out and the run goes on; this says so, because the person who wrote it believes it guards a tool. A retired name that
619
+ * was RENAMED (it has a successor the entry used to guard) is not here: it is still refused at prepare with the name to write, and
620
+ * the same code rides that thrown error. Audience `user`. Once per audited layer per prepared task, and only when the run goes on.
621
+ * `detail: { layer, entries: [{ field, entry, layer, guidance, source? }], total, sessionId }` — `layer` ∈ `caller_policy` / `session_rules` /
622
+ * `ancestor_session_rules` / `task_selector` (a task's tool-name lists) / `skill_table` (a skill's `disallowed-tools`; `source` names the list's
623
+ * owner), `field` ∈ `deny` / `ask`, `guidance` the retirement table's own line, `entries` unique by (field, entry, source) in scan order (at most 32), `total` every one.
615
624
  * - `"config.durable_gate_unavailable"` — a durable-approval MANDATE is in force on a leg with NO
616
625
  * checkpoint store: the per-principal `forceDurableGate` entitlement, or the task's own
617
626
  * `durableApproval` opt-in with no live approver seat (`durableMandateSourceOf`, the predicate the
@@ -1180,8 +1189,11 @@ export declare function __resetMalformedNoticeSeatAnnouncement(): void;
1180
1189
  * seat defect — the one fact every fallback would otherwise repeat — is announced once per process.
1181
1190
  * · an ABSENT seat goes to the default seat a host installed ({@link setDefaultEngineNoticeSeat}; a function seat as above, and
1182
1191
  * a present seat — non-function included — never falls through to it), else prints the historic `console.warn` line verbatim.
1192
+ * · `admission`, when given, is asked once with the notice as it will leave (after the text pass and the routing lift): `false`
1193
+ * hands it to no seat. A predicate that answers `false` has already said so on its own account (the occupant judge mints its
1194
+ * `delegation.delivery_discarded`); it only judges and never rewrites the notice — the mint stays at the call site.
1183
1195
  */
1184
- export declare function deliverEngineNotice(onNotice: ((notice: EngineNotice) => void) | undefined, notice: EngineNotice): void;
1196
+ export declare function deliverEngineNotice(onNotice: ((notice: EngineNotice) => void) | undefined, notice: EngineNotice, admission?: (notice: EngineNotice) => boolean): void;
1185
1197
  /**
1186
1198
  * #259 loud half, one notice PER FAMILY (`task.user_steer_undrained` / `task.user_followup_undrained`):
1187
1199
  * a consumer routing on `code` alone must never mistake a stranded follow-up for a stranded steer, so
@@ -9,7 +9,7 @@ let malformedNoticeSeatAnnounced = false;
9
9
  export function __resetMalformedNoticeSeatAnnouncement() {
10
10
  malformedNoticeSeatAnnounced = false;
11
11
  }
12
- export function deliverEngineNotice(onNotice, notice) {
12
+ export function deliverEngineNotice(onNotice, notice, admission) {
13
13
  notice = {
14
14
  ...notice,
15
15
  message: typeof notice.message === "string" ? egressText("same-principal", notice.message) : notice.message,
@@ -18,6 +18,8 @@ export function deliverEngineNotice(onNotice, notice) {
18
18
  if (notice.sessionId === undefined && typeof notice.detail?.["sessionId"] === "string") {
19
19
  notice = { ...notice, sessionId: notice.detail["sessionId"] };
20
20
  }
21
+ if (admission !== undefined && !admission(notice))
22
+ return;
21
23
  const seat = onNotice === undefined ? defaultNoticeSeat : onNotice;
22
24
  if (typeof seat === "function") {
23
25
  try {
@@ -639,8 +639,8 @@ export interface FileHistoryBlobExchange {
639
639
  /**
640
640
  * The store's blob exchange, read as one capability: `undefined` when the store carries no `blobExchange`; its three
641
641
  * members, bound, when it carries the whole group; a refusal (`config.invalid_argument`) when the group is not an
642
- * object or a member is missing or not a function. A store that still carries the retired `syncBlobFaces` marker is
643
- * refused too: the capability is the group's presence, and a second word for it is a second reading.
642
+ * object or a member is missing or not a function. The group is the only reading: no other member of the store says
643
+ * anything about the capability.
644
644
  */
645
645
  export declare function fileHistoryBlobExchangeOf(store: FileHistoryStore): FileHistoryBlobExchange | undefined;
646
646
  /**
@@ -249,17 +249,13 @@ function judgeFileHistoryEnvelope(data) {
249
249
  const BLOB_EXCHANGE_MEMBERS = Object.freeze(["put", "get", "has"]);
250
250
  export function fileHistoryBlobExchangeOf(store) {
251
251
  const owner = "FileHistoryStore.blobExchange";
252
- let marker;
253
252
  let group;
254
253
  try {
255
- marker = Reflect.get(store, "syncBlobFaces");
256
254
  group = store.blobExchange;
257
255
  }
258
256
  catch (cause) {
259
257
  throw invalidBlobExchange(`${owner} could not be read (${thrownText(cause)}).`);
260
258
  }
261
- if (marker !== undefined)
262
- throw invalidBlobExchange(`FileHistoryStore carries the retired syncBlobFaces marker — the blob exchange is the ${owner} group (put / get / has): present means the capability, absent means none.`);
263
259
  if (group === undefined)
264
260
  return undefined;
265
261
  if (typeof group !== "object" || group === null)
@@ -5,7 +5,7 @@ import { normalizeReadRootCandidate } from "./read-root-candidate.js";
5
5
  import { engineFailClosedExit, hookDenyExit, settledScreenExit, takeInheritedScreen } from "./runner/gate-exit.js";
6
6
  import { noteRewrite, POLICY_AUTHOR, readRejudge, screenRewrite } from "./rewrite-rejudge.js";
7
7
  import { traceHookCrash } from "./gate-crash-trace.js";
8
- import { writeProtectionMandated, writeProtectionReachOf, writeProtectionTightenDecision } from "./write-protect.js";
8
+ import { askWithTableSentence, writeProtectionMandated, writeProtectionReachOf, writeProtectionTightenDecision } from "./write-protect.js";
9
9
  import { createGateDeadline, awaitWriteProtectionJudgment, gateWaitFailureOf, withGateTimeout } from "./gate-bounded-await.js";
10
10
  import { shellReadFaceWords } from "../tools/fs/shell-read-face.js";
11
11
  import { failedJudgmentDeny } from "./runner/policy-throw.js";
@@ -183,6 +183,8 @@ export async function runGateFold(pass) {
183
183
  else
184
184
  pass.deniedBy = "write_protection";
185
185
  }
186
+ else if (decision?.action === "ask" && decision.message !== undefined && pass.decision.action === "ask")
187
+ pass.decision = askWithTableSentence(pass.decision, decision.message, { toolCallId, toolName });
186
188
  }
187
189
  if (pass.decision.action !== "deny" && input.crossBoundaryCheck?.obligation({ toolName, args: pass.policyRewrite !== undefined ? pass.policyRewrite : pass.currentInput, toolCallId }).mandate === true) {
188
190
  const marks = { requiresRealApproval: true, crossBoundaryMandated: true };
@@ -23,9 +23,9 @@ export declare const GOVERNANCE_CODES: {
23
23
  };
24
24
  export type GovernanceCode = keyof typeof GOVERNANCE_CODES;
25
25
  /**
26
- * `memory.*` error codes DELIBERATELY outside governance: write-gate and engine incident codes
27
- * (secret detection, promotable-gate refusals, announce/partition incidents, tail truncation) —
28
- * mechanical faults and content-safety refusals, not per-principal policy verdicts; they classify
26
+ * `memory.*` error codes DELIBERATELY outside governance: engine incident codes (announce /
27
+ * partition incidents, tail truncation, consolidation outcomes) —
28
+ * mechanical faults and disclosures, not per-principal policy verdicts; they classify
29
29
  * as `logic`. The gate test forces every `memory.*` literal minted in src/ to appear EITHER in
30
30
  * {@link GOVERNANCE_CODES} or here — a new code gets NAMED and dispositioned, never silently
31
31
  * classified.
@@ -145,7 +145,7 @@ export type NoticeAudience = "user" | "operator";
145
145
  * the union's catalog ({@link EngineNotice.code}). The groups below say only which family a row joins,
146
146
  * so the catalog is not written a second time here and the two cannot drift.
147
147
  */
148
- export declare const ENGINE_NOTICE_CODES: readonly ["config.autocompact_window_clamped", "config.env_timeout_discarded", "config.materialize_env_discarded", "config.models_swapped", "config.context_settings_swapped", "config.read_face_swapped", "config.read_face_deployment_clamped", "config.write_face_swapped", "config.write_face_deployment_clamped", "config.read_deny_swapped", "config.tool_model_gate_removed", "config.tool_model_gate_unknown_class", "config.tool_model_gate_env_invalid", "config.artifact_host_invalid", "config.task_root_not_canonical", "config.write_protection_target_view_absent", "config.path_view_unresolved", "config.execution_env_capability_invalid", "config.read_deny_floor_unkept", "config.read_floor_confinement_unavailable", "config.tool_card_undeclared", "config.tool_face_undeclared", "config.tool_face_invalid", "config.forward_sink_failed", "config.durable_gate_unavailable", "config.peer_admission_out_of_range", "config.peer_lane_unmounted", "config.secret_env_scrubbed", "inherit_env.names_withheld", "config.credential_not_withheld", "config.cross_boundary_posture_undeclared", "config.cross_boundary_record_unwritten", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "config.session_rules_earlier_grammar", "permission.allowed_tool_not_granted", "mods.registration_refused", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "classifier.fallback", "classifier.seat_rate_limited", "classifier.role_defaulted", "classifier.contract_broken", "classifier.unavailable", "checkpoint.execution_outcome_unrecorded", "delegation.transcript_integrity", "delegation.ask_unresolvable", "delegation.resume_lane_missing", "delegation.delivery_discarded", "mcp.injection_dropped", "mcp.revocation_probe_failed", "mcp.server_redialed", "mcp.authorization_required", "mcp.credential_echoed", "workflow.governance_key_stripped", "workflow.agent_option_ignored", "memory.session_polluted", "memory.harvest_quarantined", "memory.harvest_refused", "memory.harvest_conflict", "memory.delegation_static_mark_waived", "memory.content_class_declared", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "memory.consolidation_recommended", "memory.consolidation_committed", "memory.consolidation_conflict", "memory.consolidation_incomplete", "memory.consolidation_refused", "memory.consolidation_withheld", "memory.restore_withheld", "memory.project_scope_absent", "route.fallback_to_primary", "route.classifier_unroutable", "route.seat_detached", "advisor.not_attached", "route.credential_origin_mismatch", "route.credential_rebound", "route.response_model_mismatch", "route.tool_call_id_folded", "route.finish_reason_unknown", "route.stream_end_ignored", "route.extra_body_reserved_dropped", "model.capability_downgraded", "model.role_defaulted", "context.tool_turn_repaired", "context.media_removed", "context.tool_schema_removed", "task.user_steer_undrained", "task.user_followup_undrained", "steering.parked_input_blocked", "task.turn_interrupted", "task.halt_unconsumed", "task.late_approval", "task.interrupt_unconsumed", "task.tool_turn_incomplete", "approval.read_root_granted", "approval.read_root_grant_rejected", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "skills.listing_truncated", "agents.listing_truncated", "tool_result.offload_put_failed", "tool_result.media_refused", "config.image_processor_unavailable", "fs.staging_file_left", "fs.staging_file_swept", "session.lineage_rerooted", "instructions.source_changed", "memory.layer_locked_legacy", "server.model_unreachable", "permission.entry_mode_clamped"];
148
+ export declare const ENGINE_NOTICE_CODES: readonly ["config.autocompact_window_clamped", "config.env_timeout_discarded", "config.materialize_env_discarded", "config.models_swapped", "config.context_settings_swapped", "config.read_face_swapped", "config.read_face_deployment_clamped", "config.write_face_swapped", "config.write_face_deployment_clamped", "config.read_deny_swapped", "config.tool_model_gate_removed", "config.tool_model_gate_unknown_class", "config.tool_model_gate_env_invalid", "config.artifact_host_invalid", "config.task_root_not_canonical", "config.write_protection_target_view_absent", "config.path_view_unresolved", "config.execution_env_capability_invalid", "config.read_deny_floor_unkept", "config.read_floor_confinement_unavailable", "config.tool_card_undeclared", "config.tool_face_undeclared", "config.tool_face_invalid", "config.forward_sink_failed", "config.durable_gate_unavailable", "config.peer_admission_out_of_range", "config.peer_lane_unmounted", "config.secret_env_scrubbed", "inherit_env.names_withheld", "config.credential_not_withheld", "config.cross_boundary_posture_undeclared", "config.cross_boundary_record_unwritten", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "config.session_rules_earlier_grammar", "config.legacy_tool_name", "permission.allowed_tool_not_granted", "mods.registration_refused", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "classifier.fallback", "classifier.seat_rate_limited", "classifier.role_defaulted", "classifier.contract_broken", "classifier.unavailable", "checkpoint.execution_outcome_unrecorded", "delegation.transcript_integrity", "delegation.ask_unresolvable", "delegation.resume_lane_missing", "delegation.delivery_discarded", "mcp.injection_dropped", "mcp.revocation_probe_failed", "mcp.server_redialed", "mcp.authorization_required", "mcp.credential_echoed", "workflow.governance_key_stripped", "workflow.agent_option_ignored", "memory.session_polluted", "memory.harvest_quarantined", "memory.harvest_refused", "memory.harvest_conflict", "memory.delegation_static_mark_waived", "memory.content_class_declared", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "memory.consolidation_recommended", "memory.consolidation_committed", "memory.consolidation_conflict", "memory.consolidation_incomplete", "memory.consolidation_refused", "memory.consolidation_withheld", "memory.restore_withheld", "memory.project_scope_absent", "route.fallback_to_primary", "route.classifier_unroutable", "route.seat_detached", "advisor.not_attached", "route.credential_origin_mismatch", "route.credential_rebound", "route.response_model_mismatch", "route.tool_call_id_folded", "route.finish_reason_unknown", "route.stream_end_ignored", "route.extra_body_reserved_dropped", "model.capability_downgraded", "model.role_defaulted", "context.tool_turn_repaired", "context.media_removed", "context.tool_schema_removed", "task.user_steer_undrained", "task.user_followup_undrained", "steering.parked_input_blocked", "task.turn_interrupted", "task.halt_unconsumed", "task.late_approval", "task.interrupt_unconsumed", "task.tool_turn_incomplete", "approval.read_root_granted", "approval.read_root_grant_rejected", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "skills.listing_truncated", "agents.listing_truncated", "tool_result.offload_put_failed", "tool_result.media_refused", "config.image_processor_unavailable", "fs.staging_file_left", "fs.staging_file_swept", "session.lineage_rerooted", "instructions.source_changed", "memory.layer_locked_legacy", "server.model_unreachable", "permission.entry_mode_clamped"];
149
149
  /** A catalogued code (see {@link ENGINE_NOTICE_CODES}); {@link NOTICE_MINTER} says who mints it. NOT the type of
150
150
  * `EngineNotice.code`, which stays `string` — a host forwarding its own notices through the same
151
151
  * sink is a supported shape, and narrowing that field would break it. */
@@ -198,6 +198,7 @@ declare const NOTICE_AUDIENCE_TABLE: {
198
198
  readonly "permission.rule_store_unavailable": "user";
199
199
  readonly "permission.rule_row_dropped": "user";
200
200
  readonly "config.session_rules_earlier_grammar": "user";
201
+ readonly "config.legacy_tool_name": "user";
201
202
  readonly "permission.allowed_tool_not_granted": "user";
202
203
  readonly "mods.registration_refused": "user";
203
204
  readonly "memory.capture_opted_out": "user";
@@ -345,6 +346,7 @@ declare const NOTICE_MINTER_TABLE: {
345
346
  readonly "permission.rule_store_unavailable": "engine";
346
347
  readonly "permission.rule_row_dropped": "engine";
347
348
  readonly "config.session_rules_earlier_grammar": "engine";
349
+ readonly "config.legacy_tool_name": "engine";
348
350
  readonly "permission.allowed_tool_not_granted": "engine";
349
351
  readonly "mods.registration_refused": "engine";
350
352
  readonly "peer.inbound_disposition": "engine";
@@ -12,8 +12,6 @@ export const GOVERNANCE_CODES = {
12
12
  "memory.capture_optout_denied": "terminal",
13
13
  };
14
14
  export const NON_GOVERNANCE_MEMORY_CODES = new Set([
15
- "memory.secret_detected",
16
- "memory.promotable_ungated",
17
15
  "memory.announce_failed",
18
16
  "memory.announcement_withheld",
19
17
  "memory.partition_adopt_failed",
@@ -43,7 +41,6 @@ export const NON_GOVERNANCE_MEMORY_CODES = new Set([
43
41
  "memory.consolidation_withheld",
44
42
  "memory.restore_withheld",
45
43
  "memory.project_scope_absent",
46
- "memory.projection_failed",
47
44
  "memory.observation_settlement_unavailable",
48
45
  "memory.consolidation_disabled",
49
46
  "memory.consolidation_gated",
@@ -97,6 +94,8 @@ export const NON_GOVERNANCE_MEMORY_CODES = new Set([
97
94
  "memory.capture_optout_sweep_failed",
98
95
  "memory.target_outside_store",
99
96
  "memory.scope_home_not_directory",
97
+ "memory.control_plane_links_unsupported",
98
+ "memory.control_plane_strays",
100
99
  "memory.root_anchor_backfilled",
101
100
  "memory.root_reanchored",
102
101
  ]);
@@ -167,6 +166,7 @@ export const ENGINE_NOTICE_CODES = Object.freeze([
167
166
  "permission.rule_store_unavailable",
168
167
  "permission.rule_row_dropped",
169
168
  "config.session_rules_earlier_grammar",
169
+ "config.legacy_tool_name",
170
170
  "permission.allowed_tool_not_granted",
171
171
  "mods.registration_refused",
172
172
  "peer.inbound_disposition",
@@ -283,6 +283,7 @@ const NOTICE_AUDIENCE_TABLE = {
283
283
  "permission.rule_store_unavailable": "user",
284
284
  "permission.rule_row_dropped": "user",
285
285
  "config.session_rules_earlier_grammar": "user",
286
+ "config.legacy_tool_name": "user",
286
287
  "permission.allowed_tool_not_granted": "user",
287
288
  "mods.registration_refused": "user",
288
289
  "memory.capture_opted_out": "user",
@@ -411,6 +412,7 @@ const NOTICE_MINTER_TABLE = {
411
412
  "permission.rule_store_unavailable": "engine",
412
413
  "permission.rule_row_dropped": "engine",
413
414
  "config.session_rules_earlier_grammar": "engine",
415
+ "config.legacy_tool_name": "engine",
414
416
  "permission.allowed_tool_not_granted": "engine",
415
417
  "mods.registration_refused": "engine",
416
418
  "peer.inbound_disposition": "engine",
@@ -53,6 +53,13 @@ export interface HumanInputFrame {
53
53
  * harness's empty-injection no-op stays a no-op — a frame must never materialize from nothing.
54
54
  */
55
55
  export declare function frameMidTurnUserInput(projected: string): string;
56
+ /**
57
+ * The frame of an extension's prompt (`$.prompt.submit`, author `extension`): the extension named, its text, and the tail —
58
+ * the model reads it as the extension's, never as the person's (CC `tzt`, cli316.js:273469). `name` is the calling
59
+ * registration's (the registration-name form: letters, digits, `.`, `_`, `:`, `-`); absent ⇒ the frame names no extension.
60
+ * A blank text passes through untouched (the harness's empty-injection no-op), like the person's frame.
61
+ */
62
+ export declare function frameExtensionInput(name: string | undefined, projected: string): string;
56
63
  /**
57
64
  * Render the speaker envelope for one human-input frame. Pure; see the module contract above.
58
65
  * Call BEFORE any trust framing (`formatHookFeedback` / `delimitUntrusted`) so the label stays
@@ -78,4 +85,6 @@ export declare function buildAppliedHumanInputEvent(input: {
78
85
  principal?: string | undefined;
79
86
  runOrigin?: HumanInputEvent["runOrigin"];
80
87
  rewrittenBy?: readonly string[] | undefined;
88
+ author?: HumanInputEvent["author"];
89
+ extension?: string | undefined;
81
90
  }): HumanInputEvent;
@@ -11,6 +11,13 @@ export function frameMidTurnUserInput(projected) {
11
11
  return projected;
12
12
  return `${MID_TURN_USER_INPUT_HEAD}${projected}${MID_TURN_USER_INPUT_TAIL}`;
13
13
  }
14
+ const EXTENSION_INPUT_TAIL = "\n\nThis is how a prompt an extension submits is surfaced: between turns, starting this turn in the user's place. Address " +
15
+ "the message above.";
16
+ export function frameExtensionInput(name, projected) {
17
+ if (projected.trim().length === 0)
18
+ return projected;
19
+ return `${name !== undefined ? `The extension "${name}"` : "An extension"} sent a message:\n${projected}${EXTENSION_INPUT_TAIL}`;
20
+ }
14
21
  export function projectHumanInput(frame) {
15
22
  if (frame.actor === undefined || frame.source === "system")
16
23
  return frame.text;
@@ -34,6 +41,8 @@ const HANDLED_HUMAN_INPUT_KEYS = {
34
41
  attachments: "forwarded",
35
42
  runOrigin: "forwarded",
36
43
  rewrittenBy: "forwarded",
44
+ author: "forwarded",
45
+ extension: "forwarded",
37
46
  };
38
47
  export function buildHumanInputEvent(input) {
39
48
  void HANDLED_HUMAN_INPUT_KEYS;
@@ -51,6 +60,8 @@ export function buildHumanInputEvent(input) {
51
60
  ...(input.attachments !== undefined && input.attachments.length > 0 ? { attachments: input.attachments.map((a) => ({ ...a })) } : {}),
52
61
  ...(input.runOrigin !== undefined ? { runOrigin: input.runOrigin } : {}),
53
62
  ...(input.rewrittenBy !== undefined ? { rewrittenBy: Object.freeze([...input.rewrittenBy]) } : {}),
63
+ ...(input.author !== undefined ? { author: input.author } : {}),
64
+ ...(input.extension !== undefined ? { extension: input.extension } : {}),
54
65
  };
55
66
  }
56
67
  export function buildAppliedHumanInputEvent(input) {
@@ -65,5 +76,7 @@ export function buildAppliedHumanInputEvent(input) {
65
76
  ...(input.principal !== undefined ? { principal: input.principal } : {}),
66
77
  ...(input.runOrigin !== undefined ? { runOrigin: input.runOrigin } : {}),
67
78
  ...(input.rewrittenBy !== undefined ? { rewrittenBy: input.rewrittenBy } : {}),
79
+ ...(input.author !== undefined ? { author: input.author } : {}),
80
+ ...(input.extension !== undefined ? { extension: input.extension } : {}),
68
81
  });
69
82
  }
@@ -1,5 +1,7 @@
1
1
  import type { RunInternals } from "./runner/contracts.js";
2
- export declare const INPUT_AUTHORS: readonly ["operator", "parent_model", "workflow", "peer", "observer", "engine"];
2
+ import type { ModFrame, ModOrigin } from "./mods/kernel/index.js";
3
+ import type { AssertAllKeysHandled } from "./ask-origin.js";
4
+ export declare const INPUT_AUTHORS: readonly ["operator", "parent_model", "workflow", "peer", "observer", "engine", "extension"];
3
5
  export type InputAuthor = (typeof INPUT_AUTHORS)[number];
4
6
  /** Membership test for {@link InputAuthor}. */
5
7
  export declare function isInputAuthor(v: unknown): v is InputAuthor;
@@ -7,9 +9,31 @@ export declare function isInputAuthor(v: unknown): v is InputAuthor;
7
9
  export type InputAuthorReading = InputAuthor | "unknown";
8
10
  /** The one reader: a member reads as itself, anything else (`undefined` included) as `unknown`. */
9
11
  export declare function readInputAuthor(raw: unknown): InputAuthorReading;
10
- /** THE predicate: does this input count as the operator's — screened by `classic.UserPromptSubmit`, carried across a pause, on
11
- * the person's undelivered-input account? An unreadable word does (a filter's safe side); the five other words do not. */
12
+ /** How the model reads an input that arrives mid-run: `person` — the person's mid-turn frame (a trusted caller's reminder);
13
+ * `extension` — the extension's frame, naming the extension; `verbatim` — the text as the relay hands it (an observer's
14
+ * report already carries its own envelope). */
15
+ export type InputFrame = "person" | "extension" | "verbatim";
16
+ /** One word's row: the three facts the module header names. */
17
+ interface AuthorRow {
18
+ readonly screened: boolean;
19
+ readonly countsAsOperator: boolean;
20
+ readonly frame: InputFrame;
21
+ }
22
+ /** The table, one row per member (a new word does not compile without its row). */
23
+ declare const AUTHOR_ROWS: {
24
+ readonly [A in InputAuthor]: AuthorRow;
25
+ };
26
+ /** The table's fence (docs/CLOSED-SETS.md): `never` while every author has a row. */
27
+ export type AuthorTableCoversEveryAuthor = AssertAllKeysHandled<Exclude<InputAuthor, keyof typeof AUTHOR_ROWS>>;
28
+ /** The word a reading is judged as: a member as itself, `unknown` as the operator's (the row it reads). */
29
+ export declare function judgedAuthorOf(reading: InputAuthorReading): InputAuthor;
30
+ /** Does this input count as the operator's — carried across a pause, on the person's undelivered-input account, past the hold
31
+ * of a run a person stopped? Only the operator's words do (an unreadable word reads as theirs). */
12
32
  export declare function countsAsOperator(reading: InputAuthorReading): boolean;
33
+ /** Does the prompt screen judge this input at the door it enters? The operator's words and an extension's are screened. */
34
+ export declare function isScreened(reading: InputAuthorReading): boolean;
35
+ /** How the model reads this input when it arrives mid-run ({@link InputFrame}). */
36
+ export declare function inputFrameOf(reading: InputAuthorReading): InputFrame;
13
37
  /**
14
38
  * The objective's author on a leg, from the trusted channel's word (`RunInternals.objectiveAuthor`): absent is the public
15
39
  * entry's own mint, `operator` — the host that called `runTask` wrote the objective or relays the person who did; a member is
@@ -21,12 +45,47 @@ export declare function objectiveAuthorOf(declared: unknown, onUnreadable: (erro
21
45
  * otherwise, its objective the recipe's own words (the caller's request rode the recipe's first leg). A composition whose later legs
22
46
  * re-run the caller's objective (a cascade's rungs) does not call it. */
23
47
  export declare function recipeContinuationLeg(internals: RunInternals | undefined): RunInternals;
48
+ /** What the engine's relay is told beside the text, for an input an extension's `$.prompt.submit` call hands it: the call's
49
+ * `frames` and `origin` (the prompt screen is raised under them, so the caller's own handlers stay out of it), the calling
50
+ * registration's name (`extension`) and the call's cancel. Absent for the observer's report. */
51
+ export interface AuthoredRelayCall {
52
+ readonly frames: readonly ModFrame[];
53
+ readonly origin: ModOrigin;
54
+ readonly extension: string;
55
+ /** The door's tier: an extension's prompt waits for the leg's would-otherwise-stop seat (CC `hWe = "later"`). */
56
+ readonly priority: "later";
57
+ readonly signal?: AbortSignal;
58
+ }
59
+ /** The relay's answer, decided when the input is taken (never when it is read): the text that entered the leg — the caller's,
60
+ * or the prompt screen's rewrite of it — or why it did not enter. */
61
+ export type AuthoredRelayAnswer = {
62
+ readonly entered: string;
63
+ } | {
64
+ readonly drop: string;
65
+ };
24
66
  /**
25
67
  * The engine's own relay into a running stream's steer lane, under the author it states. The public `TaskStream.steer` mints
26
- * `operator` on every call; this seat is how the engine hands a stream an input someone else wrote (an observer's report). It
27
- * lives on the stream object the Runner minted — registered here, never on the package face — so no caller can name an author.
68
+ * `operator` on every call; this seat is how the engine hands a stream an input someone else wrote (an observer's report, an
69
+ * extension's prompt). It lives on the stream object the Runner minted — registered here, never on the package face — so no
70
+ * caller can name an author. Every refusal the verb answers (the run not live, the hold of a stopped run, the screen's) is a
71
+ * `drop`; a fault the verb does not answer rejects.
28
72
  */
29
- export type AuthoredSteer = (author: InputAuthor, text: string) => Promise<void>;
73
+ export type AuthoredSteer = (author: InputAuthor, text: string, call?: AuthoredRelayCall) => Promise<AuthoredRelayAnswer>;
74
+ /** Where a leg's loop stands for an input: `before` — the run is live and its loop has not begun taking input (an injection
75
+ * would wait out the birth window); `open` — it takes input; `over` — it will take no more. */
76
+ export type InputWindow = "before" | "open" | "over";
77
+ /** The stream's relay as the leg's `$.prompt.submit` entry reaches it: the relay, and the one fact the relay's birth-window
78
+ * wait reads ({@link InputWindow}) — the entry refuses a call that would wait on the leg it is called from. */
79
+ export interface PromptSubmitSeat {
80
+ readonly relay: AuthoredSteer;
81
+ readonly inputWindow: () => InputWindow;
82
+ }
83
+ /** `$.prompt.submit`'s binding, minted by the stream layer once per stream and filled with that stream's own relay; the leg's
84
+ * entry reads it at call time (unfilled ⇒ the call is dropped). Handed down the leg's prepare as a parameter, never inside the
85
+ * run's internals — those are copied into a child's snapshot, and a child's prompt is never its parent's. */
86
+ export interface PromptSubmitRef {
87
+ seat?: PromptSubmitSeat;
88
+ }
30
89
  /** Register the authored steer of a stream the Runner minted (the driver calls this once per stream). */
31
90
  export declare function bindAuthoredSteer(stream: object, steer: AuthoredSteer): void;
32
91
  /** The authored steer of a stream the Runner minted; `undefined` for any other object. */
@@ -34,3 +93,4 @@ export declare function authoredSteerOf(stream: object): AuthoredSteer | undefin
34
93
  /** The terminal account's sentence for inputs of other authors a run accepted and never delivered: they are dropped, never
35
94
  * carried across a pause and never counted as the person's (the caller hands it to `onError` once, `phase: "degraded"`). */
36
95
  export declare function droppedInputsDisclosure(authors: readonly InputAuthor[]): Error;
96
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { describeRejectedValue } from "./tool-search-setting.js";
2
- export const INPUT_AUTHORS = Object.freeze(["operator", "parent_model", "workflow", "peer", "observer", "engine"]);
2
+ export const INPUT_AUTHORS = Object.freeze(["operator", "parent_model", "workflow", "peer", "observer", "engine", "extension"]);
3
3
  const INPUT_AUTHOR_SET = new Set(INPUT_AUTHORS);
4
4
  export function isInputAuthor(v) {
5
5
  return INPUT_AUTHOR_SET.has(v);
@@ -7,9 +7,27 @@ export function isInputAuthor(v) {
7
7
  export function readInputAuthor(raw) {
8
8
  return isInputAuthor(raw) ? raw : "unknown";
9
9
  }
10
- const COUNTS_AS_OPERATOR = Object.freeze({ operator: true, parent_model: false, workflow: false, peer: false, observer: false, engine: false });
10
+ const row = (screened, countsAsOperator, frame) => Object.freeze({ screened, countsAsOperator, frame });
11
+ const AUTHOR_ROWS = Object.freeze({
12
+ operator: row(true, true, "person"),
13
+ parent_model: row(false, false, "verbatim"),
14
+ workflow: row(false, false, "verbatim"),
15
+ peer: row(false, false, "verbatim"),
16
+ observer: row(false, false, "verbatim"),
17
+ engine: row(false, false, "verbatim"),
18
+ extension: row(true, false, "extension"),
19
+ });
20
+ export function judgedAuthorOf(reading) {
21
+ return reading === "unknown" ? "operator" : reading;
22
+ }
11
23
  export function countsAsOperator(reading) {
12
- return reading === "unknown" || COUNTS_AS_OPERATOR[reading];
24
+ return AUTHOR_ROWS[judgedAuthorOf(reading)].countsAsOperator;
25
+ }
26
+ export function isScreened(reading) {
27
+ return AUTHOR_ROWS[judgedAuthorOf(reading)].screened;
28
+ }
29
+ export function inputFrameOf(reading) {
30
+ return AUTHOR_ROWS[judgedAuthorOf(reading)].frame;
13
31
  }
14
32
  export function objectiveAuthorOf(declared, onUnreadable) {
15
33
  if (declared === undefined)
@@ -4,6 +4,7 @@
4
4
  * mods layer).
5
5
  */
6
6
  import type { HookInvocationIdentity } from "./hooks.js";
7
+ import type { SessionAddress } from "./task-notification.js";
7
8
  import type { AskSourceIdentity } from "./tool-policy.js";
8
9
  /**
9
10
  * The id a delegated leg's events carry as `agentId`: the leg's task id ({@link legTaskIdOf}) — for a background child, the
@@ -70,11 +71,26 @@ export interface NoticeAddress {
70
71
  /** Present on a delegated leg that carries one ({@link agentIdOf}): the agent id the leg's events and its spawner's card name. */
71
72
  readonly agentId?: string;
72
73
  }
74
+ /** Where a leg's user-face notice goes ({@link noticeAddressOf}): the keys it carries, and the session address it is for. */
75
+ export interface NoticeRoute {
76
+ /** The keys the notice carries — spread into its detail as-is. */
77
+ readonly address: NoticeAddress;
78
+ /** The session address a notice routed away from the leg's own session is for: on a delegated leg addressed to its tree's
79
+ * root, the root's id and the root occupant the tree was born under (absent = unknown). A delivery to it is judged like any
80
+ * frame addressed there (`PendingSessionNotifications.discardsStaleNotice`). Never spread into a notice: an occupant token
81
+ * is an addressing fact, not a word the wire carries. Absent when the notice goes to the leg's own session. */
82
+ readonly destination?: SessionAddress;
83
+ }
73
84
  /**
74
85
  * The address of a leg's user-face notice — one rule: a user-face notice goes to the end of the delegation tree a person
75
86
  * watches, and says which leg it came from. A top-level leg's notice is addressed to its own session and carries no source
76
87
  * keys. A delegated leg's notice is addressed to the tree's root session (`internals.rootSessionId`: an intermediate parent
77
88
  * at depth ≥ 2 has no host leg of its own to read it on) and carries the delegated leg's session and agent id — the shape a
78
- * subagent's permission denial takes upstream (the top-level session id plus the agent id).
89
+ * subagent's permission denial takes upstream (the top-level session id plus the agent id). The root is a session address
90
+ * like every other destination: its id and its occupant (`internals.rootSessionIncarnation`), so a notice of a tree whose
91
+ * root was deleted and created again is not delivered to the root's later occupant.
79
92
  */
80
- export declare function noticeAddressOf(askSource: AskSourceIdentity, rootSessionId: string | undefined): NoticeAddress;
93
+ export declare function noticeAddressOf(askSource: AskSourceIdentity, root: {
94
+ readonly rootSessionId?: string;
95
+ readonly rootSessionIncarnation?: string;
96
+ } | undefined): NoticeRoute;
@@ -16,15 +16,13 @@ export function mintAskSourceIdentity(leg) {
16
16
  ...(leg.isDelegatedChild ? { isDelegatedChild: true } : {}),
17
17
  });
18
18
  }
19
- export function noticeAddressOf(askSource, rootSessionId) {
19
+ export function noticeAddressOf(askSource, root) {
20
20
  const own = askSource.sourceSessionId;
21
21
  if (own === undefined || own.length === 0)
22
22
  throw new TypeError("noticeAddressOf: the leg's ask source carries no session");
23
23
  if (askSource.isDelegatedChild !== true)
24
- return { sessionId: own };
25
- return {
26
- sessionId: rootSessionId !== undefined && rootSessionId.length > 0 ? rootSessionId : own,
27
- sourceSessionId: own,
28
- ...(askSource.agentId !== undefined ? { agentId: askSource.agentId } : {}),
29
- };
24
+ return { address: { sessionId: own } };
25
+ const rootId = root?.rootSessionId !== undefined && root.rootSessionId.length > 0 ? root.rootSessionId : undefined;
26
+ const address = { sessionId: rootId ?? own, sourceSessionId: own, ...(askSource.agentId !== undefined ? { agentId: askSource.agentId } : {}) };
27
+ return rootId !== undefined && rootId !== own ? { address, destination: { sessionId: rootId, occupant: root?.rootSessionIncarnation } } : { address };
30
28
  }
@@ -103,7 +103,7 @@ export interface MailboxPeerMeta {
103
103
  * WHO the record is for: the occupant (`SessionMetadata.incarnation`) of the session the writer addressed, as the writer
104
104
  * resolved that address — a park seat from its leg's address, a sender from the recipient's directory row, a notice from the
105
105
  * reply address it answers. A session box outlives its occupant (the id can be deleted and created again, the box stays), so a
106
- * drain hands a record only to the occupant it names ({@link import("./runner/delegation-owner.js").sameOccupant}: absent on
106
+ * drain hands a record only to the occupant it names ({@link import("../engine/session/repo-utils.js").sameOccupant}: absent on
107
107
  * both sides is one occupant — a deployment whose store mints no tokens; absent on one side only is another occupant). A
108
108
  * record for another occupant is discarded with an account, never delivered. An addressing fact, not a secret and not a
109
109
  * credential: it proves nothing about who wrote the record.