@sema-agent/core 7.65.0 → 7.66.1

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 (129) hide show
  1. package/CHANGELOG.md +269 -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-session-drain.d.ts +51 -12
  7. package/dist/agents/peer-session-drain.js +44 -31
  8. package/dist/agents/read-inbox-tool.d.ts +6 -2
  9. package/dist/agents/read-inbox-tool.js +18 -5
  10. package/dist/agents/subagent.d.ts +3 -1
  11. package/dist/agents/subagent.js +79 -75
  12. package/dist/brain/reasoning.d.ts +2 -0
  13. package/dist/brain/reasoning.js +1 -0
  14. package/dist/core/allow-entry.d.ts +9 -0
  15. package/dist/core/allow-entry.js +7 -1
  16. package/dist/core/ask-origin.d.ts +23 -3
  17. package/dist/core/ask-origin.js +11 -1
  18. package/dist/core/engine-notice.d.ts +3 -3
  19. package/dist/core/governance-codes.js +1 -0
  20. package/dist/core/human-input-projection.d.ts +9 -0
  21. package/dist/core/human-input-projection.js +13 -0
  22. package/dist/core/input-author.d.ts +66 -6
  23. package/dist/core/input-author.js +21 -3
  24. package/dist/core/memory-engine/consolidation.d.ts +23 -9
  25. package/dist/core/memory-engine/consolidation.js +30 -5
  26. package/dist/core/memory-engine/control-plane-adoption.d.ts +11 -10
  27. package/dist/core/memory-engine/control-plane-adoption.js +54 -29
  28. package/dist/core/memory-engine/delegation-settlement.d.ts +18 -12
  29. package/dist/core/memory-engine/delegation-settlement.js +36 -26
  30. package/dist/core/memory-engine/engine.d.ts +17 -6
  31. package/dist/core/memory-engine/engine.js +78 -35
  32. package/dist/core/memory-engine/file-backend.d.ts +4 -1
  33. package/dist/core/memory-engine/file-backend.js +5 -1
  34. package/dist/core/memory-engine/index.d.ts +2 -2
  35. package/dist/core/memory-engine/index.js +2 -2
  36. package/dist/core/memory-engine/layout.d.ts +57 -36
  37. package/dist/core/memory-engine/layout.js +109 -134
  38. package/dist/core/memory-engine/memory-backend-contract.js +7 -7
  39. package/dist/core/memory-engine/memory-deployment.d.ts +3 -2
  40. package/dist/core/memory-engine/memory-deployment.js +6 -3
  41. package/dist/core/memory-engine/origin-clearance.d.ts +43 -15
  42. package/dist/core/memory-engine/origin-clearance.js +143 -55
  43. package/dist/core/model-receipt.d.ts +2 -1
  44. package/dist/core/model-receipt.js +5 -0
  45. package/dist/core/mods/dollar.d.ts +12 -0
  46. package/dist/core/mods/kernel/dispatch.d.ts +3 -1
  47. package/dist/core/mods/kernel/dispatch.js +5 -2
  48. package/dist/core/mods/kernel/events.d.ts +3 -1
  49. package/dist/core/mods/kernel/events.js +2 -2
  50. package/dist/core/mods/prompt-submit.d.ts +4 -0
  51. package/dist/core/mods/prompt-submit.js +24 -0
  52. package/dist/core/mods/stations.d.ts +23 -4
  53. package/dist/core/mods/stations.js +14 -7
  54. package/dist/core/retired-host-table-account.d.ts +19 -0
  55. package/dist/core/retired-host-table-account.js +28 -0
  56. package/dist/core/retired-tool-name-account.d.ts +60 -0
  57. package/dist/core/retired-tool-name-account.js +32 -0
  58. package/dist/core/roles.d.ts +3 -1
  59. package/dist/core/roles.js +5 -2
  60. package/dist/core/runner/compact-session.js +2 -1
  61. package/dist/core/runner/contracts.d.ts +1 -1
  62. package/dist/core/runner/gate-exit.js +9 -2
  63. package/dist/core/runner/memory-consolidation-driver.js +2 -2
  64. package/dist/core/runner/prepare-config-doors.js +1 -1
  65. package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
  66. package/dist/core/runner/prepare-delegation-surface.js +5 -3
  67. package/dist/core/runner/prepare-inherited-gate.js +2 -0
  68. package/dist/core/runner/prepare-memory.js +26 -5
  69. package/dist/core/runner/prepare-park-ask.d.ts +2 -0
  70. package/dist/core/runner/prepare-park-ask.js +3 -1
  71. package/dist/core/runner/prepare-policy-chain.js +2 -1
  72. package/dist/core/runner/prepare-project-context.js +2 -2
  73. package/dist/core/runner/prepare-question-face.d.ts +2 -2
  74. package/dist/core/runner/prepare-task.d.ts +5 -1
  75. package/dist/core/runner/prepare-task.js +5 -4
  76. package/dist/core/runner/prepare-wiring-manifest.js +5 -4
  77. package/dist/core/runner/prompt-suggestions.js +1 -1
  78. package/dist/core/runner/run-identity-wiring.js +2 -2
  79. package/dist/core/runner/run-leg.js +3 -3
  80. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  81. package/dist/core/runner/run-notification-lane.js +2 -2
  82. package/dist/core/runner/runtask.js +6 -3
  83. package/dist/core/runner/steer-admission.d.ts +11 -2
  84. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  85. package/dist/core/runner/stream-steer-verb.js +67 -14
  86. package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -27
  87. package/dist/core/runner/sub-agent-deny-lists.js +22 -33
  88. package/dist/core/runner-deps.d.ts +4 -4
  89. package/dist/core/shell-run-candidates.js +3 -3
  90. package/dist/core/side-query.js +1 -1
  91. package/dist/core/skill-grant.d.ts +7 -0
  92. package/dist/core/skill-grant.js +14 -5
  93. package/dist/core/task-event.d.ts +14 -0
  94. package/dist/core/tool-policy.js +2 -3
  95. package/dist/core/tool-spec.d.ts +13 -3
  96. package/dist/core/user-attachment.d.ts +5 -1
  97. package/dist/core/user-attachment.js +11 -5
  98. package/dist/engine/harness/agent-harness.d.ts +19 -11
  99. package/dist/engine/harness/agent-harness.js +7 -4
  100. package/dist/engine/llm/types.d.ts +22 -10
  101. package/dist/index.d.ts +4 -2
  102. package/dist/index.js +3 -1
  103. package/dist/shell/lex.d.ts +50 -15
  104. package/dist/shell/lex.js +43 -9
  105. package/dist/tools/fs/fs-bash.js +3 -3
  106. package/dist/tools/fs/removal-targets.d.ts +8 -2
  107. package/dist/tools/fs/removal-targets.js +31 -4
  108. package/dist/tools/fs/shell-read-argv.js +7 -1
  109. package/dist/tools/fs/shell-read-bindings.d.ts +21 -5
  110. package/dist/tools/fs/shell-read-bindings.js +130 -44
  111. package/dist/tools/fs/shell-read-plan.js +95 -29
  112. package/dist/tools/fs/shell-read-sourced.d.ts +25 -0
  113. package/dist/tools/fs/shell-read-sourced.js +119 -0
  114. package/dist/tools/fs/shell-read-word.d.ts +2 -2
  115. package/dist/tools/fs/shell-read-word.js +4 -5
  116. package/dist/tools/fs/shell-read-workdir.d.ts +19 -3
  117. package/dist/tools/fs/shell-read-workdir.js +60 -15
  118. package/dist/tools/fs/shell-reentry-text.d.ts +10 -2
  119. package/dist/tools/fs/shell-reentry-text.js +11 -4
  120. package/package.json +2 -2
  121. package/test/export-surface.snapshot.json +13 -7
  122. package/wire-changes/core-stores-sql@7.66.0.json +30 -0
  123. package/wire-changes/core-stores-sql@7.66.1.json +30 -0
  124. package/wire-changes/core@7.66.0.json +1218 -0
  125. package/wire-changes/core@7.66.1.json +46 -0
  126. package/wire-changes/mods-kernel@7.66.0.json +65 -0
  127. package/wire-changes/mods-kernel@7.66.1.json +30 -0
  128. package/wire-changes/primitives@7.66.0.json +30 -0
  129. package/wire-changes/primitives@7.66.1.json +30 -0
@@ -1,14 +1,17 @@
1
1
  import { compileToolSelector, valveLeaves, deniedProtocolTools, delegationListWhere, isCanonicalToolName, isToolSelectorLayer, listReaches, notAListSentence, toolListsDigest, notAStringSentence, readAllowedToolList, readDeniedEntry, readDeniedToolList } from "../../agents/tool-filter.js";
2
2
  import { readToolNameList, valueTypeLabel } from "../tool-name-list.js";
3
- import { compileAllowList, inertEntryPhrase, renderListEntry, rootFacingToolNames } from "../allow-entry.js";
3
+ import { compileAllowList, inertEntryPhrase, isRetiredLeftOut, renderListEntry, rootFacingToolNames } from "../allow-entry.js";
4
4
  import { inlineUntrusted } from "../untrusted-text.js";
5
+ import { deliverEngineNotice } from "../engine-notice.js";
5
6
  import { ENGINE_TOOLS } from "../tool-catalog-entries.js";
6
7
  import { callerToolNameProblem } from "../caller-tool-name.js";
7
8
  import { mintNamespacePrefix } from "../protocol-naming.js";
8
9
  import { PROTOCOL_TABLE, protocolOf } from "../protocol-table.js";
9
10
  import { grantWildcardRefusalOf, mountedToolNames, splitNamespacedName } from "../tool-name-aliases.js";
11
+ import { POLICY_NAME_REFUSAL_CODE, retiredToolNameNotice } from "../retired-tool-name-account.js";
10
12
  import { projectionToolNames } from "../tool-policy.js";
11
13
  import { declaredDelegationNameOf } from "../delegation-name.js";
14
+ import { announceDigest } from "./announce-once-ledger.js";
12
15
  export function renamedDelegationMountSentence(...rosters) {
13
16
  for (const tools of rosters) {
14
17
  if (!Array.isArray(tools))
@@ -74,7 +77,6 @@ function refused(message, code, reason) {
74
77
  e.detail = { reason };
75
78
  return e;
76
79
  }
77
- export const POLICY_NAME_REFUSAL_CODE = "config.legacy_tool_name";
78
80
  const POLICY_NAME_PROBLEMS_SHOWN = 32;
79
81
  const POLICY_NAME_ENTRY_CHARS = 128;
80
82
  export function policyNameRefusal(first, more) {
@@ -84,31 +86,6 @@ export function policyNameRefusal(first, more) {
84
86
  e.detail = { problems: listed.slice(0, POLICY_NAME_PROBLEMS_SHOWN), total: 1 + more.length };
85
87
  return e;
86
88
  }
87
- const LAYER_WORD = {
88
- caller_policy: "the run's tool policy",
89
- session_rules: "the session's stored permission rules",
90
- ancestor_session_rules: "the stored permission rules of an ancestor session",
91
- };
92
- const RETIRED_NOTICE_ENTRIES_SHOWN = 32;
93
- export function retiredToolNameNotice(layer, entries, sessionId) {
94
- const unique = [];
95
- const seen = new Set();
96
- for (const e of entries) {
97
- const key = `${e.field}\u0000${e.entry}`;
98
- if (seen.has(key))
99
- continue;
100
- seen.add(key);
101
- unique.push(e);
102
- }
103
- const one = unique.length === 1;
104
- const shown = unique.slice(0, 5).map((e) => `${e.field}-list entry "${e.entry}"`);
105
- const more = unique.length > shown.length ? ` and ${unique.length - shown.length} more` : "";
106
- return {
107
- code: POLICY_NAME_REFUSAL_CODE,
108
- message: `${LAYER_WORD[layer]} holds ${shown.join(", ")}${more}, ${one ? "a RETIRED tool name" : "RETIRED tool names"} that ${one ? "reaches" : "reach"} no tool in this run's roster — ${one ? "it guards" : "they guard"} nothing, and the run goes on without ${one ? "it" : "them"}. Remove ${one ? "the entry" : "the entries"} from the list.`,
109
- detail: { layer, entries: unique.slice(0, RETIRED_NOTICE_ENTRIES_SHOWN).map((e) => ({ field: e.field, entry: e.entry, layer: e.layer, guidance: e.guidance })), total: unique.length, sessionId },
110
- };
111
- }
112
89
  const LIST_WORD = { allowed: "allowed tools", denied: "denied tools" };
113
90
  const NEAR_MISS_EFFECT = {
114
91
  allowed: "it admits nothing, so the tool it was written for is not granted",
@@ -141,7 +118,7 @@ const KEPT_ENTRY = {
141
118
  };
142
119
  const KEPT_ENTRY_UNLISTED_POOL = "so it is kept here: the pool this delegation tool hands its child cannot be listed, and the spawned child judges the entry against its own roster (another spelling of a tool it carries refuses the child before it starts; an exact name takes effect; a name nothing answers to there stays in force for a tool of that name mounted later)";
143
120
  const PEER_WORD = { mcp: "MCP server", a2a: "A2A peer" };
144
- function judgeToolNameList(where, side, value, universe, advise, code) {
121
+ function judgeToolNameList(where, side, value, universe, advise, code, retired) {
145
122
  for (const { entry, name: toolName, content: written } of readableToolNameList(where, side, value, code)) {
146
123
  if (toolName === "*" && !written)
147
124
  continue;
@@ -168,6 +145,10 @@ function judgeToolNameList(where, side, value, universe, advise, code) {
168
145
  advise(new Error(`${where} declares ${renderListEntry(entry)} in its denied tools: this list reads tool names, not content, so the whole tool "${inlineUntrusted(name, 80)}" is denied. ${DENY_LIST_NAMES_ONLY}`));
169
146
  continue;
170
147
  }
148
+ if (retired !== undefined && side === "denied" && universe.complete && flaw !== undefined && isRetiredLeftOut(flaw, universe.known) && flaw.guidance !== undefined) {
149
+ retired({ field: "deny", entry: inlineUntrusted(entry, 120), layer: "task_selector", guidance: flaw.guidance, source: inlineUntrusted(where, 160) });
150
+ continue;
151
+ }
171
152
  const phrase = flaw !== undefined ? inertEntryPhrase(flaw) : renderListEntry(entry);
172
153
  const undeclared = split !== undefined && split.peer !== "" && !split.peer.includes("*") && !universe.peers.has(mintNamespacePrefix(split.ns, split.peer));
173
154
  const why = undeclared ? `no ${PEER_WORD[split.ns.id]} named "${inlineUntrusted(split.peer, 80)}" is declared for this task` : universe.complete ? "no tool of this task answers to that name" : "no tool this run can list answers to that name";
@@ -300,6 +281,8 @@ export function boundOwnToolLists(record, own) {
300
281
  }
301
282
  export function judgeRunToolLists(input) {
302
283
  const { spec, tools, onceLedger, sessionId } = input;
284
+ const retiredLeftOut = [];
285
+ const retire = (entry) => void retiredLeftOut.push(entry);
303
286
  const advise = (err) => {
304
287
  try {
305
288
  onceLedger.onError(err, { phase: "config", sessionId });
@@ -327,15 +310,16 @@ export function judgeRunToolLists(input) {
327
310
  if (!input.judgedUpstream) {
328
311
  const root = rootFacingUniverse(input.ownBy !== undefined ? new Set([...mounted, input.ownBy.toolName]) : mounted, pool, withOwnServers(definitionServers));
329
312
  const own = [["allowed", input.own.allow], ["denied", input.own.exclude]];
330
- const tell = input.toldUpstream === true ? () => undefined : advise;
313
+ const silent = () => undefined;
314
+ const told = input.toldUpstream === true;
331
315
  for (const [side, value] of own)
332
- judgeToolNameList(ownWhere ?? (side === "allowed" ? "TaskSpec.allowTools" : "TaskSpec.excludeTools"), side, value, root, tell, "config.tool_face_control");
316
+ judgeToolNameList(ownWhere ?? (side === "allowed" ? "TaskSpec.allowTools" : "TaskSpec.excludeTools"), side, value, root, told ? silent : advise, "config.tool_face_control", told ? silent : retire);
333
317
  }
334
318
  const childUniverses = (servers) => pool.tools.length > 0 ? pool.tools.map((t) => childFacingUniverse(poolOf([t]), withOwnServers(servers))) : [childFacingUniverse(poolOf([]), withOwnServers(servers))];
335
319
  for (const def of spec.agents ?? []) {
336
320
  for (const universe of childUniverses(def.mcp)) {
337
321
  judgeToolNameList(`TaskSpec.agents: agent "${def.name}"`, "allowed", def.allowTools, universe, advise, "config.agent.unknown_tool");
338
- judgeToolNameList(`TaskSpec.agents: agent "${def.name}"`, "denied", def.denyTools, universe, advise, "config.agent.unknown_tool");
322
+ judgeToolNameList(`TaskSpec.agents: agent "${def.name}"`, "denied", def.denyTools, universe, advise, "config.agent.unknown_tool", retire);
339
323
  }
340
324
  }
341
325
  const replaced = new Set((spec.agents ?? []).map((d) => d.name));
@@ -346,11 +330,16 @@ export function judgeRunToolLists(input) {
346
330
  const faceWhere = delegationListWhere(t.name, face.name);
347
331
  const faceUniverse = childFacingUniverse(poolOf([t]), withOwnServers(face.servers));
348
332
  judgeToolNameList(faceWhere, "allowed", face.allowTools, faceUniverse, advise, "config.agent.unknown_tool");
349
- judgeToolNameList(faceWhere, "denied", face.denyTools, faceUniverse, advise, "config.agent.unknown_tool");
333
+ judgeToolNameList(faceWhere, "denied", face.denyTools, faceUniverse, advise, "config.agent.unknown_tool", retire);
350
334
  }
351
335
  }
352
336
  judgeToolNameList(delegationListWhere(t.name, undefined), "allowed", t.agentToolLevelAllowTools, universe, advise, "config.agent.unknown_tool");
353
- judgeToolNameList(delegationListWhere(t.name, undefined), "denied", t.agentToolLevelDenyTools, universe, advise, "config.agent.unknown_tool");
337
+ judgeToolNameList(delegationListWhere(t.name, undefined), "denied", t.agentToolLevelDenyTools, universe, advise, "config.agent.unknown_tool", retire);
338
+ }
339
+ if (retiredLeftOut.length > 0) {
340
+ const notice = retiredToolNameNotice("task_selector", retiredLeftOut, sessionId);
341
+ const whole = [...new Set(retiredLeftOut.map((e) => `${e.field}\u0000${e.entry}\u0000${e.source ?? ""}`))].sort();
342
+ onceLedger.oncePerSession(announceDigest(`${POLICY_NAME_REFUSAL_CODE}:task_selector`, JSON.stringify(whole)), () => deliverEngineNotice(input.onNotice, notice));
354
343
  }
355
344
  }
356
345
  export function judgeHostToolCeiling(layers, agent, above = []) {
@@ -354,7 +354,7 @@ export interface RunnerDeps {
354
354
  crossBoundaryPosture?: "single_user" | "multi_tenant";
355
355
  /**
356
356
  * design/383 §2.1b — an optional host-supplied carrier for the session capture opt-out record
357
- * (per memory plane, keyed by that plane's control dir). Absent = the control-plane file trio
357
+ * (per memory plane, keyed by that plane's control dir). Absent = the `capture` objects of the engine's governance store (#3484: the File store over the plane's control dir, or the store the backend carries)
358
358
  * (single-process/single-host deployments: byte-identical behavior). A deployment whose control
359
359
  * plane does not survive into resume replicas (the stateless multi-replica server form) supplies
360
360
  * a durable store here; see {@link import("./memory-engine/layout.js").SessionCaptureRecordStore}
@@ -991,9 +991,9 @@ export interface RunnerDeps {
991
991
  * WHO consumes this deployment's principal inbox (`principal.inbox`, where the
992
992
  * organization's delivery gate appends cross-principal letters; the mailbox contract's fourth chain).
993
993
  * Absent = no consumer, no lane (byte for byte as before); a deployment that mounts a gate DECLARES
994
- * `{ assistant: "<agent handle>" }` (the scope's assistant is the only consumer; no terminal leg touches the
995
- * box) or `"terminals"` (each terminal drains the box as a second lane; a held letter's decision is the
996
- * letter's own field in the box, so every terminal reads the same one). Letters are judged on the principal's
994
+ * `{ assistant: "<agent handle>" }` (the only consumer; no terminal leg touches the box; an agent handle is `a` and 6–32 lower-case
995
+ * hex digits, the shape the task registry mints) or `"terminals"` (each terminal drains the box as a second lane; a held letter's
996
+ * decision is the letter's own field in the box, so every terminal reads the same one). Letters are judged on the principal's
997
997
  * `crossSessionInbound` layers (managed, user), held when unset. ANY other value fails the prepare of a leg
998
998
  * that drains a session box with `config.principal_inbox_consumer_invalid` (`detail.reason: "malformed"`).
999
999
  */
@@ -1,4 +1,4 @@
1
- import { arithmeticTextIsPlain, compoundValueHidesRun, expansionHidesRun, heredocBodyHidesRun, lexShell, namesRedirectDescriptor, PARSE_FAILURE_SENTENCE, } from "../shell/lex.js";
1
+ import { arithmeticTextIsPlain, heredocBodyHidesRun, lexShell, namesRedirectDescriptor, PARSE_FAILURE_SENTENCE, wordHidesRun, } from "../shell/lex.js";
2
2
  import { shellWordsOf } from "../shell/shell-words.js";
3
3
  import { isLauncherAssignmentOperand } from "../tools/fs/bash-program-position.js";
4
4
  import { extglobOpenerIn } from "../tools/fs/bash-readonly-classifier.js";
@@ -50,7 +50,7 @@ function wordOf(w) {
50
50
  }
51
51
  const literalIn = (w, set) => w !== undefined && w.expands === false && set.has(w.text);
52
52
  const bareAssignment = (w) => lexedWordOf(w)?.assignment?.bare === true;
53
- const hidesRun = (w) => w.expansions.some((p) => p.expansion !== undefined && expansionHidesRun(p.expansion)) || (w.assignment?.subscript !== undefined && !arithmeticTextIsPlain(w.assignment.subscript.raw)) || compoundValueHidesRun(w);
53
+ const hidesRun = wordHidesRun;
54
54
  const CASE_ARM_UNREAD = "a `case` arm terminator outside a `case` this lane reads";
55
55
  const EXTGLOB_UNREAD = "an extended pattern (`?(…)` `*(…)` `+(…)` `@(…)` `!(…)`) is one this reader does not expand";
56
56
  export function readShellCommand(source) {
@@ -122,7 +122,7 @@ export function readShellCommand(source) {
122
122
  return;
123
123
  }
124
124
  if (t.kind === "word") {
125
- if (!namesRedirectDescriptor(t, tokens[i + 1]))
125
+ if (!namesRedirectDescriptor(tokens[i + 1]))
126
126
  seg.words.push(word(t));
127
127
  return;
128
128
  }
@@ -58,7 +58,7 @@ export async function runSideQuery(spec, deps) {
58
58
  ? { tools: spec.tools.map((t) => ({ name: t.name, description: t.description, parameters: t.parameters })) }
59
59
  : {}),
60
60
  };
61
- const thinking = resolved.thinking ?? resolved.model.defaultThinking;
61
+ const thinking = resolved.thinking;
62
62
  const auth = await spec.getApiKeyAndHeaders?.(resolved.model);
63
63
  const options = {
64
64
  ...(spec.signal !== undefined ? { signal: spec.signal } : {}),
@@ -3,6 +3,7 @@ import type { PermissionMode } from "./ask-origin.js";
3
3
  import { type PermissionSeatInputs, type PermissionSeatReading } from "./mode-policy.js";
4
4
  import type { AgentTool } from "../internal/harness-types.js";
5
5
  import { type SkillGrantBindingMembers } from "./skill-grant-binding.js";
6
+ import { type EngineNotice } from "./engine-notice.js";
6
7
  import { type AllowEntryGateSeats, type AllowEntryInert, type AllowEntryJudgeContext, type CompiledAllowEntry } from "./allow-entry.js";
7
8
  /** Who wrote a row: the `Skill` tool on a successful activation, prepare for a skill the person invoked by name, or a
8
9
  * delegated child's seed from its parent. */
@@ -120,6 +121,12 @@ export interface SkillGrantHit {
120
121
  }
121
122
  /** The refusal a deny hit writes: a deny row's, or an activation's whose deny entries read as nothing. */
122
123
  export declare function skillDenyDecision(hit: SkillGrantHit): PermissionResult;
124
+ /**
125
+ * Tell the entries of a skill's `disallowed-tools` that name a tool the engine retired with no successor — the half of the inert reading a
126
+ * skill's activation does NOT refuse on (see {@link unreadDenyOf}) — as ONE retired-name notice (layer `skill_table`, each entry's `source`
127
+ * the skill), and answer `inert` without them: they are no line of the "grants or refuses nothing" notice. Nothing to tell ⇒ `inert` as given.
128
+ */
129
+ export declare function tellRetiredSkillDeny(onNotice: ((notice: EngineNotice) => void) | undefined, inert: readonly SkillInertEntry[], sessionId: string, roster: ReadonlySet<string>): readonly SkillInertEntry[];
123
130
  /** The run's deny rows over `req` through `lane` — the refusal they write, or undefined (no lane, no row). The one
124
131
  * reading the gate's regular decision, its approved-edit round and the resumed execution boundary share. */
125
132
  export declare function skillRowRefusal(lane: Pick<SkillGrantLane, "denying"> | undefined, req: ToolCallRequest): PermissionResult | undefined;
@@ -5,8 +5,10 @@ import { inlineUntrusted } from "./untrusted-text.js";
5
5
  import { boundInputHashOf } from "./canonical-json.js";
6
6
  import { NOT_BINDABLE } from "./skill-grant-binding.js";
7
7
  import { readToolNameList } from "./tool-name-list.js";
8
+ import { deliverEngineNotice } from "./engine-notice.js";
9
+ import { retiredToolNameNotice } from "./retired-tool-name-account.js";
8
10
  import { closestName } from "./closest-name.js";
9
- import { allowingRows, strippedInAuto, compileAllowList, readRuleEntry, inertEntryPhrase, judgeAllowEntries, nonListValueLabel, renderListEntry, spelledListEntry } from "./allow-entry.js";
11
+ import { allowingRows, strippedInAuto, compileAllowList, isRetiredLeftOut, readRuleEntry, inertEntryPhrase, judgeAllowEntries, nonListValueLabel, renderListEntry, spelledListEntry } from "./allow-entry.js";
10
12
  export const SKILL_GRANT_ORIGINS = Object.freeze(["model", "user", "inherited"]);
11
13
  const FROZEN_SKILL_GRANT_ORIGINS = new Set(["model", "inherited"]);
12
14
  export function skillNamedBy(args, skills) {
@@ -121,8 +123,15 @@ export function skillDenyDecision(hit) {
121
123
  decisionReason: "skill",
122
124
  };
123
125
  }
124
- function unreadDenyOf(inert) {
125
- return inert.filter((i) => i.list === "disallowed-tools");
126
+ function unreadDenyOf(inert, roster) {
127
+ return inert.filter((i) => i.list === "disallowed-tools" && !isRetiredLeftOut(i, roster));
128
+ }
129
+ export function tellRetiredSkillDeny(onNotice, inert, sessionId, roster) {
130
+ const retired = inert.filter((i) => i.list === "disallowed-tools" && isRetiredLeftOut(i, roster));
131
+ if (retired.length === 0)
132
+ return inert;
133
+ deliverEngineNotice(onNotice, retiredToolNameNotice("skill_table", retired.map((e) => ({ field: "deny", entry: inlineUntrusted(e.entry, 120), layer: "skill_table", guidance: e.guidance ?? "", source: `Skill ${inlineUntrusted(e.skill, 80)}` })), sessionId));
134
+ return inert.filter((i) => !retired.includes(i));
126
135
  }
127
136
  export function skillRowRefusal(lane, req) {
128
137
  const hit = lane?.denying(req);
@@ -220,7 +229,7 @@ export class SkillGrantTable {
220
229
  }
221
230
  activate(skill, origin) {
222
231
  const { rows, inert } = compileSkillGrant(skill, origin, this.mountedNames());
223
- const unreadDeny = unreadDenyOf(inert);
232
+ const unreadDeny = unreadDenyOf(inert, this.mountedNames());
224
233
  if (unreadDeny.length > 0)
225
234
  throw skillDenyUnreadable(skill.name, unreadDeny, "activation");
226
235
  for (const row of rows)
@@ -260,7 +269,7 @@ export class SkillGrantTable {
260
269
  if (at === undefined || !isSkillActivationCall(req, at.skills, at.skillToolName))
261
270
  return undefined;
262
271
  const skill = skillNamedBy(req.args, at.skills);
263
- const unread = skill === undefined ? [] : unreadDenyOf(compileSkillGrant(skill, "model", this.mountedNames()).inert);
272
+ const unread = skill === undefined ? [] : unreadDenyOf(compileSkillGrant(skill, "model", this.mountedNames()).inert, this.mountedNames());
264
273
  return skill === undefined || unread.length === 0 ? undefined : { skill: skill.name, entries: unread.map((i) => i.entry), readsAsNothing: unread };
265
274
  }
266
275
  }
@@ -1061,6 +1061,13 @@ export type TaskEvent = ({
1061
1061
  * rides the account the screening entrance mints — the `"applied"` frame of an objective, a parked steer or a wake's
1062
1062
  * message, the `"queued"` frame of a live steer. Absent ⇒ the text went as it came. */
1063
1063
  rewrittenBy?: readonly string[];
1064
+ /** Who wrote THIS input, when it is not the operator ({@link import("./input-author.js").InputAuthor}): `"extension"` for an
1065
+ * extension's prompt (`$.prompt.submit`), `"observer"` for an observer's report relayed to the child it watches. Rides
1066
+ * both frames of a live steer's account (`"queued"`, `"applied"`). Absent ⇒ the operator (a person, or the host relaying
1067
+ * one) — every input of the public verbs. Render a non-operator input as its author's, never as the person's. */
1068
+ author?: Exclude<import("./input-author.js").InputAuthor, "operator">;
1069
+ /** The calling registration's name, beside `author: "extension"` (and only there). */
1070
+ extension?: string;
1064
1071
  } & TaskEventIdentity) | ({
1065
1072
  /**
1066
1073
  * design/99 §E3/§E10 — a live BRAIN-LAYER status the brain would otherwise absorb
@@ -1382,6 +1389,13 @@ export interface HumanInputAttachment {
1382
1389
  readonly kind?: UserAttachmentKind;
1383
1390
  readonly outcome: UserAttachmentOutcome;
1384
1391
  readonly label: string;
1392
+ /** The extension of the leg that refused this attachment at its `prompt.mention` station, by its registration name — the same author
1393
+ * type {@link ExtensionRequester} and {@link RewriteAuthor} record elsewhere. Present only on a `not_attached` attachment whose refusal
1394
+ * the dispatch names: an extension's `{ deny }` / `{ type: null }` answer, or an extension whose handler failed (threw, ran past its
1395
+ * budget, answered what the station refuses). Absent on every attachment that reached the model, and when no extension is to be named:
1396
+ * a read rule's refusal, the run's cancel, the engine's own fault, and a bad spelling handed down the chain (which handler handed it
1397
+ * is not said). A display and audit fact; it decides nothing. */
1398
+ readonly declinedBy?: ExtensionRequester;
1385
1399
  }
1386
1400
  /**
1387
1401
  * Outcome of a manual {@link TaskStream.compact} request (the enum names align with
@@ -3,7 +3,7 @@ import { homedir } from "node:os";
3
3
  import { argsReadFrom, carryArgsReadFrom, withArgsReading } from "./effective-path-target.js";
4
4
  import { editRewrittenSentence, readRejudge, rewriteChasedSentence } from "./rewrite-rejudge.js";
5
5
  import { brandPolicyAskClass } from "./ask-class.js";
6
- import { decisionAskClassesOf, headlessDenialMessage, joinAskReasons } from "./ask-origin.js";
6
+ import { decisionAskClassesOf, headlessDenialMessage, joinAskReasons, unresolvedAskDenialMessage } from "./ask-origin.js";
7
7
  import { attest, attestationOf, engineSentenceOf, isEngineAttestation, mergeAttestation, mintAttestation, withAttestation } from "./engine-attestation.js";
8
8
  import { ownReadRootCandidate, readRootGrantSeat } from "./read-root-grant-screen.js";
9
9
  import { DECIDED_VIA, decidersNote, isDecidedVia, policyDeciderOf, settledByDecider } from "./gate-outcome.js";
@@ -1341,8 +1341,7 @@ async function resolveAskArms(req, onAsk, signal, onLateSettlement) {
1341
1341
  if (ok === "unavailable") {
1342
1342
  return {
1343
1343
  action: "deny",
1344
- message: `approval required for "${req.toolName}" but the approver reported unavailable (no reachable ` +
1345
- `operator for this ask) and no durable approval gate is armed — denied fail-closed: ${req.message}`,
1344
+ message: unresolvedAskDenialMessage("approver_unavailable", req.toolName, req.message, false),
1346
1345
  decisionReason: "mode",
1347
1346
  settlement: settledByNobody("approver_unavailable"),
1348
1347
  approverUnavailable: true,
@@ -1160,9 +1160,10 @@ export interface ToolExecuteContext {
1160
1160
  * a floor no selection loosens (the `memoryPersistenceCapable:false` floor's exact law, on the
1161
1161
  * privacy axis). Trusted Runner-filled seat, never a model/tool argument.
1162
1162
  *
1163
- * DUAL FORM (#511 件2): on a deployment whose capture record store is synchronous (the default
1164
- * file trio) this is a plain boolean, byte-identical to before; a Promise-form
1165
- * {@link RunnerDeps.memoryCaptureRecordStore} makes the live read answer a `Promise<boolean>`.
1163
+ * DUAL FORM (#511 件2): on a deployment whose capture record store answers synchronously (a host
1164
+ * store) this is a plain boolean; the default carrier (the governance store's `capture` objects,
1165
+ * #3484) and a Promise-form {@link RunnerDeps.memoryCaptureRecordStore} make the live read answer a
1166
+ * `Promise<boolean>`.
1166
1167
  * Consumers must `await` (identity on the boolean arm) — a bare `=== true` on the Promise arm
1167
1168
  * would coin `false`, the exact un-floored escape this seat closes.
1168
1169
  */
@@ -1315,6 +1316,15 @@ export interface ToolExecuteContext {
1315
1316
  * park in its subtree). Same discipline as `principal`: inherit verbatim off the trusted seat.
1316
1317
  */
1317
1318
  checkpointStoreForChildren?: import("./checkpoint-store.js").CheckpointStore | "disabled";
1319
+ /**
1320
+ * The registry the host run's background tasks live in — the one its leg end (the owed-delivery reading), TaskStop, ListAgents
1321
+ * and its teardown read. Runner-filled, read-only, NEVER a model/tool argument; ABSENT when the tool runs outside a Runner task.
1322
+ * A delegation tool registers its background children here (C-R1143, #2280): its `background.registry` option is the
1323
+ * out-of-task fallback only, and inside a task an option naming a different registry is refused at spawn
1324
+ * (`config.invalid_task_registry`) — the same reading the bag's `checkpointStore` member has against
1325
+ * {@link checkpointStoreForChildren}.
1326
+ */
1327
+ taskRegistry?: import("./task-registry.js").TaskRegistry;
1318
1328
  /**
1319
1329
  * The host run's checkpoint SCOPE, for its children — the scope this run's own parked rows land in (the one
1320
1330
  * value its prepare derived; a delegated host's is the scope ITS parent handed it, so a whole tree answers
@@ -23,7 +23,7 @@
23
23
  * message's text blocks with no separator.
24
24
  */
25
25
  import type { ImageContent, TextContent, UserAttachmentSupply, UserMessageAttachment } from "../internal/llm.js";
26
- import type { HumanInputAttachment } from "./task-event.js";
26
+ import type { ExtensionRequester, HumanInputAttachment } from "./task-event.js";
27
27
  import { type ModelFileReader } from "../tools/fs/fs-read.js";
28
28
  import { type ImageDownsampler } from "./image-downsample.js";
29
29
  import type { SyntheticReadJudge } from "./synthetic-read-verdict.js";
@@ -135,6 +135,10 @@ export interface MintedAttachmentFrame {
135
135
  readonly attachment: UserMessageAttachment;
136
136
  };
137
137
  readonly commit?: () => void;
138
+ /** The extension a `prompt.mention` outcome names as this attachment's refuser ({@link HumanInputAttachment.declinedBy}, which
139
+ * {@link humanInputAttachmentsOf} projects it into). Not part of the transcript record: the `human_input` frame is built from the
140
+ * frames this run just minted. */
141
+ readonly declinedBy?: ExtensionRequester;
138
142
  }
139
143
  export interface ReadUserAttachmentsInput {
140
144
  screened: readonly ScreenedUserAttachment[];
@@ -1,4 +1,5 @@
1
1
  import { quoteDataLabel, userAttachmentOf } from "../internal/llm.js";
2
+ import { readExtensionRequester } from "./extension-requester.js";
2
3
  import { READ_OUTCOMES } from "../tools/fs/fs-read.js";
3
4
  import { renderDirectoryListing } from "../tools/fs/dir-entries.js";
4
5
  import { MAX_READ_OUTPUT_CHARS } from "../tools/fs/fs-shared.js";
@@ -12,6 +13,7 @@ import { DEFAULT_CHARS_PER_TOKEN, estimateTokens, uuidv7 } from "../internal/har
12
13
  import { thrownText } from "./thrown-value.js";
13
14
  import { optionKeys, receiveMembers } from "./own-property-receipt.js";
14
15
  import { guardBudget } from "./context-guard.js";
16
+ import { namedRegistration } from "./mods/kernel/registration.js";
15
17
  import { failedHandlerClause } from "./mods/stations.js";
16
18
  import { agentIdOf } from "./leg-identity.js";
17
19
  import { extensionWords } from "./untrusted-egress.js";
@@ -319,7 +321,7 @@ const declineOf = (x) => isPlainObject(x) && Object.keys(x).length === 1 && ((ty
319
321
  : undefined;
320
322
  async function readMentioned(a, ordinal, input, mentions) {
321
323
  const label = a.supply === "path" ? a.path : a.name;
322
- const declined = (text) => ({ supply: a.supply, label, outcome: "not_attached", shape: "file", data: [{ type: "text", text }], notes: [{ kind: "extension_declined" }], unscanned: [label, text], truncated: false });
324
+ const declined = (text, by) => ({ supply: a.supply, label, outcome: "not_attached", shape: "file", data: [{ type: "text", text }], notes: [{ kind: "extension_declined" }], unscanned: [label, text], truncated: false, ...(by !== undefined ? { declinedBy: by } : {}) });
323
325
  const window = a.supply === "path" && a.lines !== undefined ? { offset: a.lines.start, ...(a.lines.end !== undefined ? { limit: a.lines.end - a.lines.start + 1 } : {}) } : {};
324
326
  const e = { mention: declarationOf(a, ordinal), ...(mentions.agentId !== undefined ? { agentId: mentions.agentId } : {}), ...(a.supply === "path" ? { path: a.path, ...window } : {}) };
325
327
  const reads = new Map();
@@ -345,12 +347,16 @@ async function readMentioned(a, ordinal, input, mentions) {
345
347
  if (outcome.kind === "aborted")
346
348
  return declined("Not attached: the run was cancelled while an extension was judging it.");
347
349
  if (outcome.kind === "failed")
348
- return declined(`Not attached: a prompt.mention extension ${failedHandlerClause(outcome)}.`);
350
+ return declined(`Not attached: a prompt.mention extension ${failedHandlerClause(outcome)}.`, refuserOf(outcome));
349
351
  const read = typeof outcome.answer === "object" && outcome.answer !== null ? reads.get(outcome.answer) : undefined;
350
352
  if (read !== undefined)
351
353
  return read;
352
354
  const reason = declineOf(outcome.answer)?.reason;
353
- return declined(`Not attached: extension "${extensionWords(outcome.answeredBy ?? "engine", 80)}" declined it${reason !== undefined ? `: ${extensionWords(reason, 300)}` : ""}.`);
355
+ return declined(`Not attached: extension "${extensionWords(outcome.answeredBy ?? "engine", 80)}" declined it${reason !== undefined ? `: ${extensionWords(reason, 300)}` : ""}.`, refuserOf(outcome));
356
+ }
357
+ function refuserOf(outcome) {
358
+ const named = namedRegistration(outcome.kind === "failed" ? outcome.registration : outcome.answeredBy);
359
+ return named === undefined ? undefined : readExtensionRequester({ kind: "extension", name: named });
354
360
  }
355
361
  function respelled(a, handed) {
356
362
  if (a.supply !== "path") {
@@ -480,7 +486,7 @@ function mintFrame(r, at, seat) {
480
486
  const result = r.result;
481
487
  const extra = scan.effects.counts.length > 0 || scan.effects.windows.length > 0 ? [scan.effects] : [];
482
488
  const commit = result !== undefined || extra.length > 0 ? () => seat.commit(result, extra, attachmentTransmissionId(at)) : undefined;
483
- return { seed: { content, attachment }, ...(commit !== undefined ? { commit } : {}) };
489
+ return { seed: { content, attachment }, ...(commit !== undefined ? { commit } : {}), ...(r.declinedBy !== undefined ? { declinedBy: r.declinedBy } : {}) };
484
490
  }
485
491
  function refuseFramesOverWindow(frames, model, window) {
486
492
  const budget = guardBudget(model, window.overlay());
@@ -585,7 +591,7 @@ export function lastAttachmentFrameOf(entries, id) {
585
591
  }
586
592
  }
587
593
  export function humanInputAttachmentsOf(frames) {
588
- return frames.map(({ seed: { attachment: a } }) => ({ ordinal: a.ordinal, ...(a.kind !== undefined ? { kind: a.kind } : {}), outcome: a.outcome, label: a.label }));
594
+ return frames.map(({ seed: { attachment: a }, declinedBy }) => ({ ordinal: a.ordinal, ...(a.kind !== undefined ? { kind: a.kind } : {}), outcome: a.outcome, label: a.label, ...(declinedBy !== undefined ? { declinedBy } : {}) }));
589
595
  }
590
596
  export function createAttachmentDelivery() {
591
597
  const pending = new Map();
@@ -73,12 +73,12 @@ export interface UserMessageProvenance {
73
73
  * task notifications, steering, recall) but never under user authority — see UserMessage.provenance. */
74
74
  provenance?: "engine-note";
75
75
  /** Who wrote the input this frame's CONTENT is ({@link InputAuthor}) — an input relayed by the engine (a TaskStream steer, the
76
- * observer's report), not engine-authored guidance. Rides only WITH `provenance:"engine-note"` (the projection semantics are
77
- * identical — visible, never `[user]` authority); what it changes is the run-control judgment: the human-halt hold below
78
- * treats an authored frame as input (always passes) while an engine-authored one is held, and only a frame whose author
79
- * counts as the operator's (`countsAsOperator`) is the person's input — parkable across a pause, on the undelivered-input
80
- * account. Minter-stated at the single relay seam that mints such frames — never inferred from text. Metadata only; not
81
- * persisted on the message. */
76
+ * observer's report, an extension's prompt), not engine-authored guidance. Rides only WITH `provenance:"engine-note"` (the
77
+ * projection semantics are identical — visible, never `[user]` authority); what it changes is the run-control judgment: only
78
+ * a frame whose author counts as the operator's (`countsAsOperator`) is the person's input — it passes the human-halt hold
79
+ * below, is parkable across a pause and is on the undelivered-input account; another author's is held by the hold like an
80
+ * engine-authored one. Minter-stated at the single relay seam that mints such frames — never inferred from text. Metadata
81
+ * only; not persisted on the message. */
82
82
  author?: InputAuthor;
83
83
  /** #1036 — the frame's injection-queue dedup key, persisted on the message it becomes
84
84
  * ({@link UserMessage.engineNoteKey}) so a reader of the TRANSCRIPT alone can join an entry back
@@ -183,6 +183,10 @@ export declare class AgentHarness<TSkill extends Skill = Skill, TPromptTemplate
183
183
  * the phase reads `"turn"` through all of that. Nothing awaits between this read and the injection
184
184
  * it gates, so a `true` cannot go stale under its caller. */
185
185
  get acceptsInjections(): boolean;
186
+ /** Is a prompt in flight — the harness takes an injection (`steer` / `followUp` refuse `invalid_state` while it is not)? The one
187
+ * reading of that fact: the injection verbs refuse on it, {@link acceptsInjections} conjoins it, and a producer that must know
188
+ * before it waits whether a loop has begun taking input (the steer relay's input window) reads it. */
189
+ get takingInput(): boolean;
186
190
  /** design/74 R3-A: the one-way clean-stop latch — SET iff this set is non-empty. When set, the boundary consults
187
191
  * answer true so the loop exits CLEANLY (emit `agent_end` + return) WITHOUT an abort/interrupt — the path a
188
192
  * resource-slice suspend needs (an abort would trip the orphan-[INTERRUPTED] reconcile = corrupt resume). It is
@@ -299,7 +303,9 @@ export declare class AgentHarness<TSkill extends Skill = Skill, TPromptTemplate
299
303
  * legitimately continues the run, otherwise handed to the terminal sweep (payload frames park
300
304
  * losslessly; payload-less boundary advisories end with the run, the same best-effort fate
301
305
  * their mint sites already accept for a final turn).
302
- * Caller/user-provenance input always passes — it is the awaited direction. One predicate here
306
+ * The operator's input always passes — it is the awaited direction; an input another author wrote (an extension's prompt, an
307
+ * observer's report) is held at the drain like an engine-authored frame, and the steer relay that carries it refuses it at
308
+ * entry (it reads this hold before its screen). One predicate here
303
309
  * instead of a per-lane check at every injection site: a future engine lane that never heard of
304
310
  * the halt is held by construction rather than by remembering. `nextTurn` is deliberately NOT
305
311
  * gated: its splice opens a NEW run (idle-park redelivery), and a halt belongs to the run that
@@ -408,10 +414,12 @@ export declare class AgentHarness<TSkill extends Skill = Skill, TPromptTemplate
408
414
  private createContext;
409
415
  private createStreamFn;
410
416
  /** May a drain take this frame now? The one predicate of the drain, the immediate re-check and {@link pendingInjectionCount}.
411
- * A person's or caller's frame always may. An engine-authored frame is held — a drained steer makes a request — under
412
- * the human-halt hold ({@link engineInjectionsHeld}), and an ADVISORY is held where the loop's own work owes no request
413
- * (`continuing` false): it rides a request, never makes one; a notification's payload is an event and may continue a
414
- * run. Held frames stay queued: later input drains past them, an owed drain takes them, else they end with the run. */
417
+ * The operator's frame always may ({@link isOperatorInput}). Any other frame — engine-authored, or an input another author
418
+ * wrote (an extension's prompt, an observer's report) — is held under the human-halt hold ({@link engineInjectionsHeld}): a
419
+ * drained frame makes a request, and only the person restarts a run they stopped. An ADVISORY is held as well where the
420
+ * loop's own work owes no request (`continuing` false): it rides a request, never makes one; a notification's payload is an
421
+ * event and may continue a run. Held frames stay queued: later input drains past them, an owed drain takes them, else they
422
+ * end with the run. */
415
423
  private isDrainable;
416
424
  private drainQueuedMessages;
417
425
  /** #389 — drop these frames from the in-flight account (they went back on a queue, or they landed). */
@@ -207,7 +207,10 @@ export class AgentHarness {
207
207
  session;
208
208
  phase = "idle";
209
209
  get acceptsInjections() {
210
- return this.phase !== "idle" && !this.aborting && !this.stopRequested;
210
+ return this.takingInput && !this.aborting && !this.stopRequested;
211
+ }
212
+ get takingInput() {
213
+ return this.phase !== "idle";
211
214
  }
212
215
  stopRequestSources = new Set();
213
216
  get stopRequested() {
@@ -610,7 +613,7 @@ export class AgentHarness {
610
613
  };
611
614
  }
612
615
  isDrainable(m, continuing) {
613
- if (!engineAuthoredInjections.has(m))
616
+ if (isOperatorInput(m))
614
617
  return true;
615
618
  if (this.engineInjectionsHeld?.() === true)
616
619
  return false;
@@ -1191,14 +1194,14 @@ export class AgentHarness {
1191
1194
  }
1192
1195
  }
1193
1196
  async steer(text, options) {
1194
- if (this.phase === "idle") {
1197
+ if (!this.takingInput) {
1195
1198
  throw new AgentHarnessError("invalid_state", "Cannot steer while idle");
1196
1199
  }
1197
1200
  this.refuseHeldEngineInjection(options);
1198
1201
  return await this.enqueueInjection(this.steerQueue, text, options);
1199
1202
  }
1200
1203
  async followUp(text, options) {
1201
- if (this.phase === "idle") {
1204
+ if (!this.takingInput) {
1202
1205
  throw new AgentHarnessError("invalid_state", "Cannot follow up while idle");
1203
1206
  }
1204
1207
  this.refuseHeldEngineInjection(options);
@@ -16,8 +16,9 @@ export type ImagesProvider = string;
16
16
  /**
17
17
  * Effort/intensity TIERS (no "off" — this is the value a provider effort field takes). ⚠ Name clash
18
18
  * by history with the loop-layer `ThinkingLevel` (engine/loop/types.ts), which is the SEVEN-value
19
- * on/off+tier knob ("off" | these six). Rule of thumb: harness/task config uses the loop's 7-tier
20
- * type; provider compat fields (`reasoningEffortLevels`/`effortLevels`) use this 6-tier one.
19
+ * on/off+tier knob ("off" | these six). Rule of thumb: harness/task config and the model entry's
20
+ * requested default (`Model.defaultThinking`, typed {@link ModelThinkingLevel}) use the 7-tier set; the
21
+ * effort ladders a provider compat declares (`reasoningEffortLevels`/`effortLevels`) use this 6-tier one.
21
22
  */
22
23
  export type ThinkingLevel = "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
23
24
  export type ModelThinkingLevel = "off" | ThinkingLevel;
@@ -980,15 +981,26 @@ export interface Model<TApi extends Api = Api> {
980
981
  * (`brain/model-capability.ts`), which also says what an undeclared capability means. */
981
982
  reasoning?: boolean;
982
983
  /**
983
- * design/111 — this model's DEFAULT thinking level (per-model preset). The thinking-resolution chain is
984
- * `spec.thinking ?? role.thinking ?? model.defaultThinking` (prepare-task) — a caller/role still overrides, but
985
- * a model that should "think by default" (e.g. an Anthropic reasoning model defaulting to `medium`) declares it
986
- * here instead of every task/role re-specifying. Absent ⇒ no model-level default (chain falls to `undefined` =
987
- * thinking off unless a caller/role asks). It is the REQUESTED tier; the per-endpoint clamp (`resolveReasoning`/
988
- * `reasoningEffortLevels`) still bounds it — a stock-OpenAI endpoint clamps `max`→`high`, while an
989
- * `anthropic-messages` budget endpoint honors the full range up to `max` unclamped.
984
+ * design/111 — this model's DEFAULT thinking level: the tier a request to this model takes when neither the
985
+ * caller nor its role names one. The chain `spec.thinking ?? role.thinking ?? model.defaultThinking` is read in
986
+ * ONE place, `resolveTaskModel` (`ResolvedRole.thinking`), and every engine lane that resolves a model through it
987
+ * (the run, a side query, a compaction pass, the next-prompt suggestions) takes that one answer.
988
+ *
989
+ * `"off"` is a tier like the others: the request then carries the explicit off — the wire's disable key where it
990
+ * spells one (`thinkingOffSpelled`) — which is what a default-on gateway (a Qwen chat template) needs to stop
991
+ * thinking on a request that asked for nothing. It is NOT "no default": ABSENT is no default, and a request that
992
+ * names no tier then writes no thinking key at all, so the provider's default governs (a default-on gateway thinks).
993
+ *
994
+ * The two types stay apart: this member takes the seven tiers (`ModelThinkingLevel`), while the effort ladder a model
995
+ * declares (`compat.reasoningEffortLevels`, `compat.effortLevels`) stays the six enabled tiers ({@link ThinkingLevel}) —
996
+ * off is a tier a request asks for, spelled by the off arm of the wire, never a rung the clamp compares against.
997
+ *
998
+ * It is the REQUESTED tier, read exactly as a request's own: the per-endpoint clamp (`resolveReasoning` /
999
+ * `reasoningEffortLevels`) still bounds it — a stock-OpenAI endpoint clamps `max`→`high` — and a model that does
1000
+ * not hold `reasoning` carries none of it. A value that is not one of the seven tiers is refused where the model
1001
+ * is received (the model door, `config.unknown_role` / `not_a_model_ref`), never read as absence.
990
1002
  */
991
- defaultThinking?: ThinkingLevel;
1003
+ defaultThinking?: ModelThinkingLevel;
992
1004
  /**
993
1005
  * Maps OpenClaw thinking levels to provider/model-specific values.
994
1006
  * Missing keys use provider defaults. null marks a level as unsupported.