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