agentfootprint 9.84.0 → 9.86.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 (174) hide show
  1. package/CHANGELOG.md +438 -8
  2. package/dist/artifacts/present.js +21 -3
  3. package/dist/artifacts/present.js.map +1 -1
  4. package/dist/artifacts/wants.js +19 -4
  5. package/dist/artifacts/wants.js.map +1 -1
  6. package/dist/core/Agent.js +15 -4
  7. package/dist/core/Agent.js.map +1 -1
  8. package/dist/core/agent/AgentBuilder.js.map +1 -1
  9. package/dist/core/agent/buildAgentChart.js +5 -0
  10. package/dist/core/agent/buildAgentChart.js.map +1 -1
  11. package/dist/core/agent/buildDynamicAgentChart.js +22 -4
  12. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  13. package/dist/core/agent/buildToolRegistry.js +149 -1
  14. package/dist/core/agent/buildToolRegistry.js.map +1 -1
  15. package/dist/core/agent/selfCallNotice.js +20 -7
  16. package/dist/core/agent/selfCallNotice.js.map +1 -1
  17. package/dist/core/agent/skillBrains.js +3 -2
  18. package/dist/core/agent/skillBrains.js.map +1 -1
  19. package/dist/core/agent/stages/routeTurn.js +28 -3
  20. package/dist/core/agent/stages/routeTurn.js.map +1 -1
  21. package/dist/core/agent/stages/stepNudge.js +13 -4
  22. package/dist/core/agent/stages/stepNudge.js.map +1 -1
  23. package/dist/core/agent/stages/toolCalls.js +389 -58
  24. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  25. package/dist/core/agent/stages/wrapUp.js +43 -6
  26. package/dist/core/agent/stages/wrapUp.js.map +1 -1
  27. package/dist/core/agent/window/currentRequest.js +4 -2
  28. package/dist/core/agent/window/currentRequest.js.map +1 -1
  29. package/dist/core/codeRunnerTool.js +25 -6
  30. package/dist/core/codeRunnerTool.js.map +1 -1
  31. package/dist/core/slots/buildToolsSlot.js +20 -4
  32. package/dist/core/slots/buildToolsSlot.js.map +1 -1
  33. package/dist/doors/skill-graph.js +4 -1
  34. package/dist/doors/skill-graph.js.map +1 -1
  35. package/dist/esm/artifacts/present.js +21 -3
  36. package/dist/esm/artifacts/present.js.map +1 -1
  37. package/dist/esm/artifacts/wants.js +19 -4
  38. package/dist/esm/artifacts/wants.js.map +1 -1
  39. package/dist/esm/core/Agent.js +15 -4
  40. package/dist/esm/core/Agent.js.map +1 -1
  41. package/dist/esm/core/agent/AgentBuilder.d.ts +2 -1
  42. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  43. package/dist/esm/core/agent/buildAgentChart.js +5 -0
  44. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  45. package/dist/esm/core/agent/buildDynamicAgentChart.js +22 -4
  46. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  47. package/dist/esm/core/agent/buildToolRegistry.d.ts +157 -0
  48. package/dist/esm/core/agent/buildToolRegistry.js +149 -1
  49. package/dist/esm/core/agent/buildToolRegistry.js.map +1 -1
  50. package/dist/esm/core/agent/selfCallNotice.d.ts +20 -7
  51. package/dist/esm/core/agent/selfCallNotice.js +20 -7
  52. package/dist/esm/core/agent/selfCallNotice.js.map +1 -1
  53. package/dist/esm/core/agent/skillBrains.d.ts +12 -4
  54. package/dist/esm/core/agent/skillBrains.js +3 -2
  55. package/dist/esm/core/agent/skillBrains.js.map +1 -1
  56. package/dist/esm/core/agent/stages/routeTurn.js +28 -3
  57. package/dist/esm/core/agent/stages/routeTurn.js.map +1 -1
  58. package/dist/esm/core/agent/stages/stepNudge.d.ts +13 -4
  59. package/dist/esm/core/agent/stages/stepNudge.js +13 -4
  60. package/dist/esm/core/agent/stages/stepNudge.js.map +1 -1
  61. package/dist/esm/core/agent/stages/toolCalls.d.ts +171 -0
  62. package/dist/esm/core/agent/stages/toolCalls.js +385 -57
  63. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  64. package/dist/esm/core/agent/stages/wrapUp.d.ts +33 -2
  65. package/dist/esm/core/agent/stages/wrapUp.js +41 -5
  66. package/dist/esm/core/agent/stages/wrapUp.js.map +1 -1
  67. package/dist/esm/core/agent/types.d.ts +21 -4
  68. package/dist/esm/core/agent/window/currentRequest.d.ts +4 -2
  69. package/dist/esm/core/agent/window/currentRequest.js +4 -2
  70. package/dist/esm/core/agent/window/currentRequest.js.map +1 -1
  71. package/dist/esm/core/codeRunnerTool.js +25 -6
  72. package/dist/esm/core/codeRunnerTool.js.map +1 -1
  73. package/dist/esm/core/slots/buildToolsSlot.d.ts +1 -1
  74. package/dist/esm/core/slots/buildToolsSlot.js +20 -4
  75. package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
  76. package/dist/esm/doors/skill-graph.d.ts +1 -1
  77. package/dist/esm/doors/skill-graph.js +4 -1
  78. package/dist/esm/doors/skill-graph.js.map +1 -1
  79. package/dist/esm/events/payloads.d.ts +26 -2
  80. package/dist/esm/index.js +6 -5
  81. package/dist/esm/index.js.map +1 -1
  82. package/dist/esm/lib/injection-engine/index.d.ts +1 -1
  83. package/dist/esm/lib/injection-engine/index.js +4 -1
  84. package/dist/esm/lib/injection-engine/index.js.map +1 -1
  85. package/dist/esm/lib/injection-engine/skillGraph.d.ts +56 -0
  86. package/dist/esm/lib/injection-engine/skillGraph.js +29 -3
  87. package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
  88. package/dist/esm/lib/injection-engine/skillSteps.d.ts +20 -1
  89. package/dist/esm/lib/injection-engine/skillSteps.js +24 -3
  90. package/dist/esm/lib/injection-engine/skillSteps.js.map +1 -1
  91. package/dist/esm/lib/injection-engine/skillToolDescriptors.d.ts +18 -0
  92. package/dist/esm/lib/injection-engine/skillToolDescriptors.js +151 -11
  93. package/dist/esm/lib/injection-engine/skillToolDescriptors.js.map +1 -1
  94. package/dist/esm/lib/injection-engine/types.d.ts +12 -10
  95. package/dist/esm/lib/injection-engine/types.js +5 -4
  96. package/dist/esm/lib/injection-engine/types.js.map +1 -1
  97. package/dist/esm/lib/saidByPerson.d.ts +48 -15
  98. package/dist/esm/lib/saidByPerson.js +52 -17
  99. package/dist/esm/lib/saidByPerson.js.map +1 -1
  100. package/dist/esm/lib/spokenIds.d.ts +52 -0
  101. package/dist/esm/lib/spokenIds.js +11 -0
  102. package/dist/esm/lib/spokenIds.js.map +1 -0
  103. package/dist/esm/lib/trace-toolpack/traceToolpack.js +12 -5
  104. package/dist/esm/lib/trace-toolpack/traceToolpack.js.map +1 -1
  105. package/dist/esm/maps/engagement/parkCard.js +7 -1
  106. package/dist/esm/maps/engagement/parkCard.js.map +1 -1
  107. package/dist/index.js +6 -5
  108. package/dist/index.js.map +1 -1
  109. package/dist/lib/injection-engine/index.js +5 -2
  110. package/dist/lib/injection-engine/index.js.map +1 -1
  111. package/dist/lib/injection-engine/skillGraph.js +31 -4
  112. package/dist/lib/injection-engine/skillGraph.js.map +1 -1
  113. package/dist/lib/injection-engine/skillSteps.js +24 -3
  114. package/dist/lib/injection-engine/skillSteps.js.map +1 -1
  115. package/dist/lib/injection-engine/skillToolDescriptors.js +151 -11
  116. package/dist/lib/injection-engine/skillToolDescriptors.js.map +1 -1
  117. package/dist/lib/injection-engine/types.js +5 -4
  118. package/dist/lib/injection-engine/types.js.map +1 -1
  119. package/dist/lib/saidByPerson.js +53 -18
  120. package/dist/lib/saidByPerson.js.map +1 -1
  121. package/dist/lib/spokenIds.js +15 -0
  122. package/dist/lib/spokenIds.js.map +1 -0
  123. package/dist/lib/trace-toolpack/traceToolpack.js +12 -5
  124. package/dist/lib/trace-toolpack/traceToolpack.js.map +1 -1
  125. package/dist/maps/engagement/parkCard.js +7 -1
  126. package/dist/maps/engagement/parkCard.js.map +1 -1
  127. package/dist/types/artifacts/present.d.ts.map +1 -1
  128. package/dist/types/artifacts/wants.d.ts.map +1 -1
  129. package/dist/types/core/Agent.d.ts.map +1 -1
  130. package/dist/types/core/agent/AgentBuilder.d.ts +2 -1
  131. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  132. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  133. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  134. package/dist/types/core/agent/buildToolRegistry.d.ts +157 -0
  135. package/dist/types/core/agent/buildToolRegistry.d.ts.map +1 -1
  136. package/dist/types/core/agent/selfCallNotice.d.ts +20 -7
  137. package/dist/types/core/agent/selfCallNotice.d.ts.map +1 -1
  138. package/dist/types/core/agent/skillBrains.d.ts +12 -4
  139. package/dist/types/core/agent/skillBrains.d.ts.map +1 -1
  140. package/dist/types/core/agent/stages/routeTurn.d.ts.map +1 -1
  141. package/dist/types/core/agent/stages/stepNudge.d.ts +13 -4
  142. package/dist/types/core/agent/stages/stepNudge.d.ts.map +1 -1
  143. package/dist/types/core/agent/stages/toolCalls.d.ts +171 -0
  144. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  145. package/dist/types/core/agent/stages/wrapUp.d.ts +33 -2
  146. package/dist/types/core/agent/stages/wrapUp.d.ts.map +1 -1
  147. package/dist/types/core/agent/types.d.ts +21 -4
  148. package/dist/types/core/agent/types.d.ts.map +1 -1
  149. package/dist/types/core/agent/window/currentRequest.d.ts +4 -2
  150. package/dist/types/core/agent/window/currentRequest.d.ts.map +1 -1
  151. package/dist/types/core/slots/buildToolsSlot.d.ts +1 -1
  152. package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
  153. package/dist/types/doors/skill-graph.d.ts +1 -1
  154. package/dist/types/doors/skill-graph.d.ts.map +1 -1
  155. package/dist/types/events/payloads.d.ts +26 -2
  156. package/dist/types/events/payloads.d.ts.map +1 -1
  157. package/dist/types/index.d.ts.map +1 -1
  158. package/dist/types/lib/injection-engine/index.d.ts +1 -1
  159. package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
  160. package/dist/types/lib/injection-engine/skillGraph.d.ts +56 -0
  161. package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
  162. package/dist/types/lib/injection-engine/skillSteps.d.ts +20 -1
  163. package/dist/types/lib/injection-engine/skillSteps.d.ts.map +1 -1
  164. package/dist/types/lib/injection-engine/skillToolDescriptors.d.ts +18 -0
  165. package/dist/types/lib/injection-engine/skillToolDescriptors.d.ts.map +1 -1
  166. package/dist/types/lib/injection-engine/types.d.ts +12 -10
  167. package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
  168. package/dist/types/lib/saidByPerson.d.ts +48 -15
  169. package/dist/types/lib/saidByPerson.d.ts.map +1 -1
  170. package/dist/types/lib/spokenIds.d.ts +53 -0
  171. package/dist/types/lib/spokenIds.d.ts.map +1 -0
  172. package/dist/types/lib/trace-toolpack/traceToolpack.d.ts.map +1 -1
  173. package/dist/types/maps/engagement/parkCard.d.ts.map +1 -1
  174. package/package.json +1 -1
@@ -44,7 +44,7 @@
44
44
  * activates that Skill (lifetime: turn).
45
45
  */
46
46
  Object.defineProperty(exports, "__esModule", { value: true });
47
- exports.buildToolCallsHandler = void 0;
47
+ exports.buildToolCallsHandler = exports.composeReadSkillRefusal = exports.unknownToolResult = exports.atMountedCursor = void 0;
48
48
  const codeRunnerTool_js_1 = require("../../codeRunnerTool.js");
49
49
  const footprintjs_1 = require("footprintjs");
50
50
  const types_js_1 = require("../../../adapters/types.js");
@@ -52,9 +52,11 @@ const typedEmit_js_1 = require("../../../recorders/core/typedEmit.js");
52
52
  const extractSequence_js_1 = require("../../../security/extractSequence.js");
53
53
  const skillTarget_js_1 = require("../../../security/skillTarget.js");
54
54
  const routingPolicy_js_1 = require("../../../lib/injection-engine/routingPolicy.js");
55
+ const skillGraph_js_1 = require("../../../lib/injection-engine/skillGraph.js");
55
56
  const skillToolDescriptors_js_1 = require("../../../lib/injection-engine/skillToolDescriptors.js");
56
57
  const selfCallNotice_js_1 = require("../selfCallNotice.js");
57
58
  const types_js_2 = require("../../../maps/engagement/types.js");
59
+ const spokenIds_js_1 = require("../../../lib/spokenIds.js");
58
60
  const types_js_3 = require("../../../identity/types.js");
59
61
  const capability_js_1 = require("../../../artifacts/capability.js");
60
62
  const wants_js_1 = require("../../../artifacts/wants.js");
@@ -133,61 +135,212 @@ function reportingCredentials(provider, scope, toolName) {
133
135
  };
134
136
  }
135
137
  /**
136
- * The re-prompt a refused `read_skill` gets back. It is the model's only feedback,
137
- * so it names what IS allowed rather than only what isn't.
138
+ * Is this `read_skill` target the cursor's own skill AND is that cursor
139
+ * MOUNTED — the one owner of "this call would change nothing" (9.86.0).
138
140
  *
139
- * Three shapes, because "not reachable" has three different reasons and only the
140
- * first two share a fix:
141
- * • something is reachable → name it, and ask for one of those;
142
- * • a decision `tree()` → nothing is EVER reachable by `read_skill`, because a
143
- * tree has no cursor to move (8.5.0). Saying "no skills are reachable from
144
- * here" would invite the model to try again from somewhere else; there is no
145
- * "elsewhere", so the message explains the tree instead;
146
- * • a flat graph that happens to be at a dead end → the original message.
141
+ * ── WHY POSITION ALONE IS NOT THE ANSWER ────────────────────────────────
142
+ *
143
+ * `classifySkillTarget` answers a question about POSITION: is the target where
144
+ * the cursor stands? For most of the loop that settles it — the cursor's body
145
+ * is in that call's system prompt and its tools are on that call's wire, so
146
+ * asking to read it activates nothing, moves nothing and reveals nothing the
147
+ * request did not already carry.
148
+ *
149
+ * A PARKED map breaks that. Parking suppresses a map's contribution and leaves
150
+ * the cursor exactly where it was, so at a parked cursor the very same id is a
151
+ * RE-ENGAGEMENT: the gate admits it, the map engages, and the member's body and
152
+ * tools ride again on the next pass. That call moves something, which makes it
153
+ * a capability, which makes it the policy's question to answer.
154
+ *
155
+ * The dispatch gate has known this since 9.59.0 — it tests re-engagement BEFORE
156
+ * its self-call arm, which is this same fact written as two ordered arms. The
157
+ * `skill_read` permission gate, 480 lines upstream, has no arms to order: it
158
+ * asks one question and either spends the policy check or skips it, and it was
159
+ * asking `classifySkillTarget` alone. So a role whose checker hid a skill could
160
+ * have the model un-park and re-activate it. This function is the question that
161
+ * gate now asks, over the parked set `parkedNow` hands both of them.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * atMountedCursor({ cursor: 'audit', target: 'audit' }); // true — a stay
166
+ * atMountedCursor({ cursor: 'audit', target: 'audit', parked: new Set(['audit']) }); // false — a re-engagement
167
+ * atMountedCursor({ cursor: 'audit', target: 'billing' }); // false — a move
168
+ * ```
147
169
  */
148
- function skillRefusal(requestedId, allowed, isTree) {
149
- const head = `read_skill("${requestedId}") is not reachable from here. `;
150
- if (allowed.length > 0) {
151
- return `${head}Reachable skills: ${allowed.join(', ')}. Pick one of these, or finish.`;
152
- }
153
- if (isTree) {
154
- return (`read_skill("${requestedId}") cannot move a decision tree. A tree routes by ` +
155
- 'predicate on every iteration — it has no cursor to jump, so this skill would ' +
156
- 'not activate even though the tool accepted the name. Answer with the skill the ' +
157
- 'tree routed to, or finish.');
170
+ function atMountedCursor(args) {
171
+ const stay = (0, skillGraph_js_1.classifySkillTarget)({
172
+ ...(args.cursor !== undefined && { cursor: args.cursor }),
173
+ target: args.target,
174
+ }) === 'self';
175
+ return stay && args.parked?.has(args.target) !== true;
176
+ }
177
+ exports.atMountedCursor = atMountedCursor;
178
+ /**
179
+ * What a call to a name nothing can dispatch gets back (9.86.0).
180
+ *
181
+ * `Unknown tool: X` was the whole sentence, on both dispatch doors, while
182
+ * `mcpServe` — the same library, one directory away — had been answering
183
+ * "Unknown tool 'rm_rf'. Served tools: echo, delete_account." for releases. The
184
+ * model that mistyped a name, or named one from a restored transcript, was told
185
+ * only that it was wrong, never what would have worked, and the cheapest repair
186
+ * (read the roster) was the one it could not make.
187
+ *
188
+ * The roster is the DISPATCH set — `registryByName` plus the provider cache —
189
+ * because that is the true statement about resolution: these are the names that
190
+ * answered to something. It is deliberately NOT the offer: the wire is narrowed
191
+ * by steps, parks and postures, and a held-out tool still dispatches by name, so
192
+ * an offer-shaped list would be a different (and here, false) claim.
193
+ *
194
+ * ── AND IT SAYS "RESOLVED", NOT "COULD BE DISPATCHED" ───────────────────
195
+ *
196
+ * The first draft said "Tools that could be dispatched on that call". Two gates
197
+ * sit between resolution and a tool running — the `tool_call` permission check
198
+ * and the middleware chain — so a name in this map can resolve and still be
199
+ * refused, and the sentence promised the model a dispatch the very next gate
200
+ * would decline. Neither gate is asked here: a `PermissionChecker` is a port
201
+ * (a hub call per name, with its own events and its own audit rows), and
202
+ * spending a whole permission sweep to phrase an error is a cost the sentence
203
+ * does not need. It reports what this map DID — resolve a name — and claims
204
+ * nothing about what would have happened next.
205
+ *
206
+ * The roster is role-filtered before it gets here (`dispatchRoster`), so a tool
207
+ * belonging to a skill the caller's policy hides is never named; and when the
208
+ * filter empties a stocked roster the clause is DROPPED, because "no tool name
209
+ * resolved" would be a denial of what the dispatch map is holding.
210
+ *
211
+ * Anchored past tense, like every other persistent result: "on that call" binds
212
+ * the roster to the finished call the result answers, so a later iteration that
213
+ * adds or drops a provider tool cannot make this sentence wrong. No exhortation
214
+ * — the model does not need to be told to try again.
215
+ *
216
+ * Exported for the producer registry, and used by BOTH dispatch doors so they
217
+ * cannot drift.
218
+ */
219
+ function unknownToolResult(toolName, dispatchable) {
220
+ const head = `Unknown tool '${toolName}' on that call.`;
221
+ if (dispatchable.named.length > 0) {
222
+ return (`${head} Tool names that resolved to an implementation on that ` +
223
+ `call: ${dispatchable.named.join(', ')}.`);
158
224
  }
159
- return `${head}No skills are reachable from here — answer with the current skill, or finish.`;
225
+ // Held-but-unnameable: the map had entries this caller may not be told about.
226
+ // Omission is free; the negative below would be false.
227
+ return dispatchable.held
228
+ ? head
229
+ : `${head} No tool name resolved to an implementation on that call.`;
160
230
  }
231
+ exports.unknownToolResult = unknownToolResult;
161
232
  /**
162
- * The re-prompt a POSTURE-refused `read_skill` gets back (SG-C `strictness`).
163
- * The pick was REACHABLE — the graph would have granted it — so the message
164
- * must teach the posture, not the map: who routes here, and what the model may
165
- * still do (open skills, staying, finishing).
233
+ * THE ONE COMPOSER of every `read_skill` refusal (9.86.0) — reachability,
234
+ * posture and tree, from one set of inputs.
235
+ *
236
+ * ── WHY ONE ─────────────────────────────────────────────────────────────
237
+ *
238
+ * There were two, and they disagreed. `skillRefusal` named "Reachable skills:
239
+ * beta" from the graph's raw hop set; `postureRefusal`, forty lines below it in
240
+ * the same gate, answered a model that took that offer up with "read_skill here
241
+ * reaches only the open skills: gamma". Same call, same turn, opposite claims —
242
+ * and the second one cost a refusal from the escalation budget to discover.
243
+ * Neither had heard of the role filter, so both could name a skill the caller's
244
+ * policy hides. One composer, handed the FILTERED sets and the posture that
245
+ * will judge the next pick, cannot contradict itself that way.
246
+ *
247
+ * ── THE TENSE DISCIPLINE (the law `selfCallNotice` is written against) ──
248
+ *
249
+ * A tool result is composed on iteration N and re-read by the model on every
250
+ * later call of the turn, including the tool-less wrap-up. So every clause here
251
+ * is a PAST fact about ONE named call — the call the model made `read_skill`
252
+ * on — anchored by the phrase "that call", never by deixis ("this turn", "the
253
+ * call you just made") and never by a forecast ("you can call", "pick one of
254
+ * these"). What the model may do NEXT is owned by the `read_skill` DESCRIPTION,
255
+ * which is recomposed for every single request and may therefore speak in the
256
+ * present. Two owners, one tense each, and they can no longer disagree.
257
+ *
258
+ * ── AND WHY IT NEVER NAMES A HOP THE POSTURE WOULD DECLINE ──────────────
259
+ *
260
+ * Under `'rails'` the model does not route at all; under `'guard'` it routes
261
+ * only from an outstanding menu. Naming hops there is an offer the very next
262
+ * arm of this gate refuses. So those arms name no hop: they say who DID route,
263
+ * and (when there are any) which open skills were admitted anyway — open skills
264
+ * never reach the posture arm, so that clause cannot be contradicted.
265
+ *
266
+ * ── AND WHY AN EMPTY LIST IS NEVER A DENIAL ─────────────────────────────
267
+ *
268
+ * Every set arrives as {@link SpokenIds}, which carries whether the UNFILTERED
269
+ * set held anything. That is the difference between "nothing was reachable" and
270
+ * "nothing reachable may be named", and this composer used to say the first
271
+ * when the second was true — over a graph that was routing the cursor the whole
272
+ * time. Where the filter empties a set, the clause is omitted. A model told the
273
+ * map is a dead end stops asking for the door it may not be shown.
274
+ *
275
+ * Exported so a producer registry can list it beside the other model-facing
276
+ * composers rather than re-deriving what it says.
166
277
  */
167
- function postureRefusal(requestedId, posture, turnRoute, currentSkillId, openIds) {
168
- const openClause = openIds.length > 0
169
- ? ` read_skill here reaches only the open skills: ${openIds.join(', ')}.`
278
+ function composeReadSkillRefusal(args) {
279
+ const { requestedId, targetClass, cursorId, hops, openIds, isTree, posture, menuOffered, routedDecisively, } = args;
280
+ const head = `read_skill("${requestedId}") was not granted on that call: `;
281
+ // Open skills are the one list every arm may name: they are admitted from
282
+ // every cursor and no posture governs them (the posture arm below is reached
283
+ // only by hops), so naming them cannot be falsified by the next call. There is
284
+ // no negative arm here and there never was — an unnamed open set is simply
285
+ // omitted, which is the shape the two arms below now share.
286
+ const openClause = openIds.named.length > 0
287
+ ? ` Open skills were admitted on that call: ${openIds.named.join(', ')}.`
170
288
  : '';
171
- if (posture === 'rails') {
172
- return (`read_skill("${requestedId}") was declined: this graph runs on rails — turn starts ` +
173
- `resolve by declared rule or scorer and transitions by declared routes; the model ` +
174
- `does not route itself.${openClause} Continue with the skill you are in` +
175
- `${currentSkillId !== undefined ? ` ('${currentSkillId}')` : ''}, or finish.`);
289
+ if (posture !== undefined) {
290
+ if (posture === 'rails') {
291
+ return (`${head}this graph's 'rails' posture reserves routing to the framework — turn ` +
292
+ `starts resolve by declared rule or scorer and transitions by declared routes — ` +
293
+ `so a model pick was not admitted on that call.${openClause}`);
294
+ }
295
+ if (menuOffered !== undefined && menuOffered.named.length > 0) {
296
+ return (`${head}this graph's 'guard' posture admits a routing pick only from the menu the ` +
297
+ `framework offered, and '${requestedId}' was not on it. The menu outstanding when ` +
298
+ `that call was made: ${menuOffered.named.join(', ')}.${openClause}`);
299
+ }
300
+ // A menu WAS outstanding and not one of its ids may be named to this
301
+ // caller. Neither of the other two sentences is available: naming the menu
302
+ // would leak it, and "no menu was outstanding" is false — as is the
303
+ // "declared routes moved the cursor instead" clause that rides with it,
304
+ // which is a second assertion about a turn that did not route that way. So
305
+ // this arm says the one thing that is true of that call and stops.
306
+ if (menuOffered !== undefined && menuOffered.held) {
307
+ return (`${head}this graph's 'guard' posture admits a routing pick only from the menu the ` +
308
+ `framework offered, and '${requestedId}' was not admitted on that call.${openClause}`);
309
+ }
310
+ return (`${head}this graph's 'guard' posture admits a routing pick only while the framework ` +
311
+ `has declared ambiguity, and no menu was outstanding when that call was made` +
312
+ `${routedDecisively === true ? " — the turn's start had already been resolved decisively" : ''}` +
313
+ `. Declared routes moved the cursor instead.${openClause}`);
176
314
  }
177
- // guard — either no menu is outstanding, or the pick was off it.
178
- if (turnRoute?.offered !== undefined && (0, routingPolicy_js_1.menuOutstanding)(turnRoute, currentSkillId)) {
179
- return (`read_skill("${requestedId}") was declined: under this graph's 'guard' posture a ` +
180
- `routing pick must come from the offered menu — ${turnRoute.offered.join(', ')} — or ` +
181
- `stay (answer without calling read_skill).${openClause}`);
315
+ if (isTree === true) {
316
+ return (`${head}this map is a decision tree. A tree routes by predicate on every iteration ` +
317
+ `and keeps no cursor, so there was nothing for that pick to move and ` +
318
+ `'${requestedId}' was not activated by it.${openClause}`);
182
319
  }
183
- const decidedBy = turnRoute?.by === 'intent' || turnRoute?.by === 'entry'
184
- ? `the turn's start was resolved decisively this turn`
185
- : `no routing ambiguity is open this turn`;
186
- return (`read_skill("${requestedId}") was declined: this graph's 'guard' posture admits a ` +
187
- `routing pick only while the framework has declared ambiguity (an offered menu), and ` +
188
- `${decidedBy}; declared routes handle transitions.${openClause} Continue with the ` +
189
- `skill you are in${currentSkillId !== undefined ? ` ('${currentSkillId}')` : ''}, or finish.`);
320
+ // Reachability. `targetClass` is 'unreachable' by the time the gate calls
321
+ // this arm — 'self' is answered by the notice, 'hop' and 'open' are admitted
322
+ // — and it is carried rather than re-derived so the sentence and the verdict
323
+ // read the same classification.
324
+ const from = cursorId !== undefined ? `'${cursorId}'` : "the turn's start";
325
+ // The gate reaches this arm only with `'unreachable'`; the weaker sentence is
326
+ // for a caller that refused an admissible class for a reason of its own, and
327
+ // it is deliberately not an invented explanation of one.
328
+ const reason = targetClass === 'unreachable'
329
+ ? `'${requestedId}' was not reachable from ${from}.`
330
+ : `'${requestedId}' was not admitted from ${from}.`;
331
+ // OMIT, NEVER DENY. Three cases, not two: hops to name, no hops at all, and
332
+ // hops the graph holds that this caller may not be told about. The third used
333
+ // to fall into the second and assert "No skill was reachable from 'alpha'"
334
+ // while the graph routed 'alpha' to a skill the role hides — a denial of what
335
+ // the run holds, and the one shape omission is always safe against.
336
+ const hopClause = hops.named.length > 0
337
+ ? ` Skills reachable from ${from} when that call was made: ${hops.named.join(', ')}.`
338
+ : hops.held
339
+ ? ''
340
+ : ` No skill was reachable from ${from} when that call was made.`;
341
+ return `${head}${reason}${hopClause}${openClause}`;
190
342
  }
343
+ exports.composeReadSkillRefusal = composeReadSkillRefusal;
191
344
  /**
192
345
  * The args a `pauseHere` / `askHuman` call was running with, read back on the
193
346
  * far side of the pause (8.13.0).
@@ -778,6 +931,35 @@ function buildToolCallsHandler(deps) {
778
931
  }
779
932
  const currentSkillId = scope.currentSkillId;
780
933
  const hops = deps.allowedSkillIds(currentSkillId);
934
+ // ── A PROPOSAL TO THE CURSOR'S OWN SKILL IS A STAY (9.86.0) ──────
935
+ // `makeReachableSkills` filters the cursor out of its own successor
936
+ // set — right for a MOVE, and this judge read it as "not reachable"
937
+ // and refused. A tool saying "stay where you are" asks for the state
938
+ // the run is already in: there is no cursor to move, no activation to
939
+ // append, and nothing to refuse. It is accepted as a no-op — no
940
+ // `pendingToolTransition`, no cursor move, and no `[tool effect
941
+ // refused: …]` suffix on a result that proposed nothing wrong.
942
+ //
943
+ // The event carries the existing `'accepted'` outcome plus an
944
+ // ADDITIVE `stay: true`, deliberately not a new enum member: an
945
+ // exhaustive switch over `outcome` in a consumer must keep compiling.
946
+ if ((0, skillGraph_js_1.classifySkillTarget)({
947
+ ...(currentSkillId !== undefined && { cursor: currentSkillId }),
948
+ target,
949
+ hops,
950
+ }) === 'self') {
951
+ (0, typedEmit_js_1.typedEmit)(scope, 'agentfootprint.tools.effect', {
952
+ kind: 'propose-transition',
953
+ outcome: 'accepted',
954
+ stay: true,
955
+ toolName: call.toolName,
956
+ toolCallId: call.toolCallId,
957
+ iteration: call.iteration,
958
+ targetSkillId: target,
959
+ reason: effect.reason,
960
+ });
961
+ continue;
962
+ }
781
963
  if (!hops.includes(target)) {
782
964
  refuse('propose-transition', `propose-transition → '${target}' was refused: '${target}' is not reachable from ` +
783
965
  `${currentSkillId !== undefined ? `'${currentSkillId}'` : 'the turn start'} per ` +
@@ -1427,6 +1609,62 @@ function buildToolCallsHandler(deps) {
1427
1609
  const cached = providerToolCache?.current ?? [];
1428
1610
  return cached.find((t) => t.schema.name === toolName);
1429
1611
  };
1612
+ /**
1613
+ * Every member id of every map the kernel currently holds PARKED (9.86.0
1614
+ * fix pass) — asked of `parkedMemberIds`, the kernel's own owner of the fact.
1615
+ *
1616
+ * ONE reader for TWO gates. The `skill_read` permission gate and the graph's
1617
+ * dispatch gate both have to tell a stay from a re-engagement, and they sit
1618
+ * 480 lines apart; the second computed this and the first did not, which is
1619
+ * exactly how a role-hidden parked member became re-activatable. Answers with
1620
+ * `undefined` when no engagement plan is mounted, which is every agent that
1621
+ * never called `.maps()`.
1622
+ */
1623
+ const parkedNow = (scope) => deps.engagementPlan === undefined
1624
+ ? undefined
1625
+ : (0, types_js_2.parkedMemberIds)(deps.engagementPlan, scope.mapEngagement);
1626
+ /**
1627
+ * Every name `lookupTool` would resolve, in resolution order, through the
1628
+ * role filter (9.86.0) — the roster `unknownToolResult` names.
1629
+ *
1630
+ * Derived from the SAME two sources the lookup reads, so a name it reports is
1631
+ * a name that resolved. Then filtered by the SAME fact every other sentence in
1632
+ * this stage filters by: `scope.hiddenSkillIds`, the per-iteration answer to
1633
+ * "which skills may this caller be told about". The first draft applied
1634
+ * neither, and named a hidden skill's tool to a role that may not see the
1635
+ * skill — the leak the `read_skill` refusals had just closed, reappearing one
1636
+ * sentence over because the roster read the dispatch map raw.
1637
+ *
1638
+ * A tool is unnameable only when EVERY skill declaring it is hidden
1639
+ * (`deps.toolDeclaringSkills`, the build-time owner of that fact). A tool two
1640
+ * skills share is still named when either is visible — the same
1641
+ * sole-owner rule the step hold-out uses, for the same reason: a shared name
1642
+ * is somebody's escape hatch. Names nobody declares from a skill — static
1643
+ * `.tool()` registrations, `read_skill`, `skip_step`, provider-delivered
1644
+ * tools — have no owning skill and are never filtered.
1645
+ *
1646
+ * DISPATCH IS UNTOUCHED. `lookupTool` still resolves every name in the map:
1647
+ * a narrowing may take a name out of a sentence, never out of the dispatch
1648
+ * map. This filter governs only what the model is TOLD.
1649
+ */
1650
+ const dispatchRoster = (scope) => {
1651
+ const names = [...registryByName.keys()];
1652
+ const seen = new Set(names);
1653
+ for (const t of externalToolProvider ? providerToolCache?.current ?? [] : []) {
1654
+ if (seen.has(t.schema.name))
1655
+ continue;
1656
+ seen.add(t.schema.name);
1657
+ names.push(t.schema.name);
1658
+ }
1659
+ const hidden = new Set(scope.hiddenSkillIds ?? []);
1660
+ if (hidden.size === 0)
1661
+ return { named: names, held: names.length > 0 };
1662
+ const declaredBy = deps.toolDeclaringSkills;
1663
+ return (0, spokenIds_js_1.spoken)(names, (name) => {
1664
+ const owners = declaredBy?.get(name);
1665
+ return owners === undefined || owners.some((id) => !hidden.has(id));
1666
+ });
1667
+ };
1430
1668
  /**
1431
1669
  * The after-tool moment: the chain's last word, on a call that RAN.
1432
1670
  *
@@ -1484,7 +1722,7 @@ function buildToolCallsHandler(deps) {
1484
1722
  // resume can't re-pause (resume returns void), so that is surfaced as an error.
1485
1723
  const resolveCredentialAndExecute = async (scope, tool, toolName, args, toolCallId, iteration, env) => {
1486
1724
  if (!tool)
1487
- return { result: `Unknown tool: ${toolName}`, error: true };
1725
+ return { result: unknownToolResult(toolName, dispatchRoster(scope)), error: true };
1488
1726
  // Declared artifact arguments (9.22.0) — the same resolution the batch
1489
1727
  // loop applies, at this door: a resumed call's refs are judged exactly
1490
1728
  // as an inline call's, BEFORE credentials, and a refusal means the tool
@@ -2117,7 +2355,37 @@ function buildToolCallsHandler(deps) {
2117
2355
  (0, types_js_1.checkerGoverns)(permissionChecker, 'skill_read')) {
2118
2356
  const requestedSkillId = callArgs.id;
2119
2357
  if (typeof requestedSkillId === 'string' && requestedSkillId.length > 0) {
2120
- await askCapability('skill_read', (0, skillTarget_js_1.skillTarget)(requestedSkillId), `Skill '${requestedSkillId}' is not available in this context.`);
2358
+ // ── A SELF-CALL AT A MOUNTED CURSOR EXERCISES NO CAPABILITY ───
2359
+ // (9.86.0.) A MOUNTED cursor's own skill is already served: its
2360
+ // body is in that call's system prompt and its tools are on that
2361
+ // call's wire. Asking to read it activates nothing, moves nothing,
2362
+ // and reveals nothing the request did not already carry — so there
2363
+ // is no capability here for a policy to grant or deny, and denying
2364
+ // it told the model its current skill was "not available in this
2365
+ // context" while it was standing in it. That is the exact sentence
2366
+ // the self-call arm exists to stop the model reading. The gate's
2367
+ // self-call arm answers instead.
2368
+ //
2369
+ // A PARKED cursor is the one case where the same id is not a
2370
+ // no-op, and the skip is scoped to exclude it (9.86.0 fix pass):
2371
+ // parking suppressed the map's contribution, so the dispatch gate
2372
+ // 480 lines below reads that call as a RE-ENGAGEMENT and serves the
2373
+ // body and tools again on the next pass. That moves something, so
2374
+ // the policy keeps the question. `atMountedCursor` is where that
2375
+ // rule lives; the dispatch gate writes the same rule as two ordered
2376
+ // arms over the same `parkedNow` set. Every OTHER id still goes
2377
+ // through the policy, unchanged — this narrows nothing a role could
2378
+ // see.
2379
+ const stay = atMountedCursor({
2380
+ ...(typeof scope.currentSkillId === 'string' && {
2381
+ cursor: scope.currentSkillId,
2382
+ }),
2383
+ target: requestedSkillId,
2384
+ parked: parkedNow(scope),
2385
+ });
2386
+ if (!stay) {
2387
+ await askCapability('skill_read', (0, skillTarget_js_1.skillTarget)(requestedSkillId), `Skill '${requestedSkillId}' is not available in this context.`);
2388
+ }
2121
2389
  }
2122
2390
  }
2123
2391
  // ── Check-in gate (evidence-carrying human consent) ──────────────
@@ -2321,7 +2589,7 @@ function buildToolCallsHandler(deps) {
2321
2589
  if (!credentialBlocked && !wantsBlocked) {
2322
2590
  try {
2323
2591
  if (!tool)
2324
- throw new Error(`Unknown tool: ${tc.name}`);
2592
+ throw new Error(unknownToolResult(tc.name, dispatchRoster(scope)));
2325
2593
  // Set BEFORE the await: a tool that throws has still run, and a
2326
2594
  // tool that does not exist has not. This flag is the entire
2327
2595
  // precondition of the after-tool moment below.
@@ -2493,9 +2761,44 @@ function buildToolCallsHandler(deps) {
2493
2761
  const reqId = callArgs.id;
2494
2762
  if (typeof reqId === 'string' && reqId.length > 0) {
2495
2763
  const currentSkillId = scope.currentSkillId;
2764
+ // ── ADMISSION reads the graph; every SENTENCE reads the filter ──
2765
+ // Two sets, deliberately (9.86.0). `admissible` is the routing law:
2766
+ // what the graph and the mount actually grant, unfiltered, because a
2767
+ // narrowing may take a schema off the wire but never a name out of
2768
+ // the dispatch map — role visibility governs what the model is TOLD,
2769
+ // not what the gate admits. `hopsNamed` / `openNamed` are what any
2770
+ // sentence, and the `skill.rejected` payload, may NAME: the same
2771
+ // hidden set the description filtered itself with, resolved once by
2772
+ // the tools slot and carried here on scope. Without it the refusals
2773
+ // read the raw sets and could name a skill this role may never see —
2774
+ // the leak the description closed, one stage downstream. (A hidden
2775
+ // skill cannot reach this gate anyway: the `skill_read` permission
2776
+ // gate above denies it first, on the same checker. The filter is
2777
+ // what keeps that true by construction rather than by coincidence.)
2778
+ const hiddenIds = new Set(scope.hiddenSkillIds ?? []);
2779
+ const mayName = (id) => !hiddenIds.has(id);
2496
2780
  const hops = deps.allowedSkillIds(currentSkillId);
2497
- skillHop = hops.includes(reqId);
2498
- const allowed = dedupeIds([...hops, ...(deps.openSkillIds ?? [])]);
2781
+ const openAll = deps.openSkillIds ?? [];
2782
+ // `spoken` keeps BOTH halves — what may be named, and whether the
2783
+ // graph held anything before the filter ran. A composer handed only
2784
+ // the filtered array cannot tell "nothing was reachable" from
2785
+ // "nothing reachable may be named", and it used to assert the first.
2786
+ const hopsSpoken = (0, spokenIds_js_1.spoken)(hops, mayName);
2787
+ const openSpoken = (0, spokenIds_js_1.spoken)(openAll, mayName);
2788
+ const hopsNamed = hopsSpoken.named;
2789
+ const openNamed = openSpoken.named;
2790
+ // The ONE owner of "is this target the cursor?" — the same function
2791
+ // the description, the tool-effects judge and the permission gate
2792
+ // switch on, so a stay means the same thing in all four.
2793
+ const targetClass = (0, skillGraph_js_1.classifySkillTarget)({
2794
+ ...(currentSkillId !== undefined && { cursor: currentSkillId }),
2795
+ target: reqId,
2796
+ hops,
2797
+ open: openAll,
2798
+ });
2799
+ skillHop = targetClass === 'hop';
2800
+ const admissible = dedupeIds([...hops, ...openAll]);
2801
+ const allowed = dedupeIds([...hopsNamed, ...openNamed]);
2499
2802
  // ── The RE-ENGAGEMENT arm (9.59.0) — a third admission class ──
2500
2803
  // A pick must be routed by INTENT. The reachable set deliberately
2501
2804
  // excludes the node the cursor already occupies (`makeReachableSkills`
@@ -2513,15 +2816,13 @@ function buildToolCallsHandler(deps) {
2513
2816
  // false, `pendingSkillPick` stays unwritten, and the pick lands on
2514
2817
  // `acceptedSkillPicks`, which the kernel's renewal feed reads as
2515
2818
  // explicit evidence and re-engages on the very next pass.
2516
- const parked = deps.engagementPlan === undefined
2517
- ? undefined
2518
- : (0, types_js_2.parkedMemberIds)(deps.engagementPlan, scope.mapEngagement);
2819
+ const parked = parkedNow(scope);
2519
2820
  const reengaging = parked?.has(reqId) === true;
2520
2821
  if (reengaging) {
2521
2822
  // Admitted. Nothing to refuse and no posture to apply: this is
2522
2823
  // not a hop, and a posture governs routing, not engagement.
2523
2824
  }
2524
- else if (currentSkillId !== undefined && reqId === currentSkillId) {
2825
+ else if (targetClass === 'self') {
2525
2826
  // ── The SELF-CALL arm (9.84.0) — BEFORE reachability ─────────
2526
2827
  // The cursor is in neither half of `allowed`, by construction:
2527
2828
  // `makeReachableSkills` filters it out of its own successor set
@@ -2596,9 +2897,16 @@ function buildToolCallsHandler(deps) {
2596
2897
  });
2597
2898
  noteSkillRefusal(scope, iteration);
2598
2899
  }
2599
- else if (!allowed.includes(reqId)) {
2900
+ else if (!admissible.includes(reqId)) {
2600
2901
  skillRejected = true;
2601
- result = skillRefusal(reqId, allowed, deps.skillGraphIsTree === true);
2902
+ result = composeReadSkillRefusal({
2903
+ requestedId: reqId,
2904
+ targetClass,
2905
+ ...(currentSkillId !== undefined && { cursorId: currentSkillId }),
2906
+ hops: hopsSpoken,
2907
+ openIds: openSpoken,
2908
+ ...(deps.skillGraphIsTree === true && { isTree: true }),
2909
+ });
2602
2910
  (0, typedEmit_js_1.typedEmit)(scope, 'agentfootprint.skill.rejected', {
2603
2911
  requestedId: reqId,
2604
2912
  ...(currentSkillId !== undefined && { currentSkillId }),
@@ -2620,7 +2928,30 @@ function buildToolCallsHandler(deps) {
2620
2928
  if (refusedByPosture) {
2621
2929
  skillRejected = true;
2622
2930
  skillHop = false; // a refused pick must not move the cursor below
2623
- result = postureRefusal(reqId, deps.skillStrictness, turnRoute, currentSkillId, deps.openSkillIds ?? []);
2931
+ // The posture arm names NO hop — under 'rails' the model does
2932
+ // not route, and under 'guard' it routes only from a menu — so
2933
+ // the composer is handed the menu when there IS one and an
2934
+ // empty hop list either way. Open skills are still named:
2935
+ // they never reach this arm, so nothing here can decline them.
2936
+ const menuNamed = turnRoute?.offered !== undefined && (0, routingPolicy_js_1.menuOutstanding)(turnRoute, currentSkillId)
2937
+ ? (0, spokenIds_js_1.spoken)(turnRoute.offered, mayName)
2938
+ : undefined;
2939
+ result = composeReadSkillRefusal({
2940
+ requestedId: reqId,
2941
+ targetClass,
2942
+ ...(currentSkillId !== undefined && { cursorId: currentSkillId }),
2943
+ // No hop is named under a posture, and the graph's hop set
2944
+ // is not this arm's subject — `held: false` is the honest
2945
+ // shape, not a claim that nothing was reachable (this arm
2946
+ // never composes the reachability clause at all).
2947
+ hops: { named: [], held: false },
2948
+ openIds: openSpoken,
2949
+ posture: deps.skillStrictness,
2950
+ ...(menuNamed !== undefined && { menuOffered: menuNamed }),
2951
+ ...((turnRoute?.by === 'intent' || turnRoute?.by === 'entry') && {
2952
+ routedDecisively: true,
2953
+ }),
2954
+ });
2624
2955
  (0, typedEmit_js_1.typedEmit)(scope, 'agentfootprint.skill.rejected', {
2625
2956
  requestedId: reqId,
2626
2957
  ...(currentSkillId !== undefined && { currentSkillId }),