agentfootprint 8.4.0 → 8.6.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/CLAUDE.md +2 -1
- package/dist/core/Agent.js +132 -2
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/RunnerBase.js +7 -1
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +23 -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 +6 -0
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +163 -10
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/slots/buildToolsSlot.js +9 -1
- package/dist/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +51 -2
- package/dist/esm/core/Agent.js +132 -2
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/RunnerBase.js +7 -1
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +19 -1
- package/dist/esm/core/agent/AgentBuilder.js +23 -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 +6 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.d.ts +45 -0
- package/dist/esm/core/agent/stages/toolCalls.js +163 -10
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +26 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +13 -0
- package/dist/esm/core/slots/buildToolsSlot.js +9 -1
- package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +17 -0
- package/dist/esm/identity/CredentialConsentRequiredError.d.ts +63 -0
- package/dist/esm/identity/CredentialConsentRequiredError.js +65 -0
- package/dist/esm/identity/CredentialConsentRequiredError.js.map +1 -0
- package/dist/esm/identity/consent.d.ts +81 -0
- package/dist/esm/identity/consent.js +85 -0
- package/dist/esm/identity/consent.js.map +1 -0
- package/dist/esm/identity.d.ts +2 -0
- package/dist/esm/identity.js +1 -0
- package/dist/esm/identity.js.map +1 -1
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +12 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +28 -4
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/index.d.ts +1 -1
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillBodyDelivery.d.ts +65 -0
- package/dist/esm/lib/injection-engine/skillBodyDelivery.js +110 -0
- package/dist/esm/lib/injection-engine/skillBodyDelivery.js.map +1 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +77 -8
- package/dist/esm/lib/injection-engine/skillGraph.js +83 -29
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillTools.d.ts +22 -1
- package/dist/esm/lib/injection-engine/skillTools.js +39 -7
- package/dist/esm/lib/injection-engine/skillTools.js.map +1 -1
- package/dist/esm/lib/mcp/mcpServe.js +11 -1
- package/dist/esm/lib/mcp/mcpServe.js.map +1 -1
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +11 -2
- package/dist/esm/recorders/observability/RouteRecorder.js +58 -6
- package/dist/esm/recorders/observability/RouteRecorder.js.map +1 -1
- package/dist/identity/CredentialConsentRequiredError.js +69 -0
- package/dist/identity/CredentialConsentRequiredError.js.map +1 -0
- package/dist/identity/consent.js +91 -0
- package/dist/identity/consent.js.map +1 -0
- package/dist/identity.js +3 -1
- package/dist/identity.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +28 -4
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillBodyDelivery.js +116 -0
- package/dist/lib/injection-engine/skillBodyDelivery.js.map +1 -0
- package/dist/lib/injection-engine/skillGraph.js +83 -29
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/skillTools.js +39 -7
- package/dist/lib/injection-engine/skillTools.js.map +1 -1
- package/dist/lib/mcp/mcpServe.js +11 -1
- package/dist/lib/mcp/mcpServe.js.map +1 -1
- package/dist/recorders/observability/RouteRecorder.js +58 -6
- package/dist/recorders/observability/RouteRecorder.js.map +1 -1
- package/dist/types/core/Agent.d.ts +51 -2
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/RunnerBase.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts +19 -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/stages/toolCalls.d.ts +45 -0
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +26 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/slots/buildToolsSlot.d.ts +13 -0
- package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +17 -0
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/identity/CredentialConsentRequiredError.d.ts +64 -0
- package/dist/types/identity/CredentialConsentRequiredError.d.ts.map +1 -0
- package/dist/types/identity/consent.d.ts +82 -0
- package/dist/types/identity/consent.d.ts.map +1 -0
- package/dist/types/identity.d.ts +2 -0
- package/dist/types/identity.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts +12 -0
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.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/skillBodyDelivery.d.ts +66 -0
- package/dist/types/lib/injection-engine/skillBodyDelivery.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/skillGraph.d.ts +77 -8
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillTools.d.ts +22 -1
- package/dist/types/lib/injection-engine/skillTools.d.ts.map +1 -1
- package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -1
- package/dist/types/recorders/observability/RouteRecorder.d.ts +11 -2
- package/dist/types/recorders/observability/RouteRecorder.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
*/
|
|
57
57
|
import type { FlowChart } from 'footprintjs';
|
|
58
58
|
import { type ActiveInjection, type Injection, type InjectionContext } from './types.js';
|
|
59
|
+
import { type CursorMove } from './skillGraph.js';
|
|
59
60
|
export interface InjectionEngineConfig {
|
|
60
61
|
/**
|
|
61
62
|
* The Injection list. Frozen at build time. To change at runtime,
|
|
@@ -70,6 +71,17 @@ export interface InjectionEngineConfig {
|
|
|
70
71
|
* (the keystone). Absent → `currentSkillId` is never written (no graph routing).
|
|
71
72
|
*/
|
|
72
73
|
readonly nextSkill?: (ctx: InjectionContext) => string | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* The same resolver, reporting the clause that WON (`graph.explainNextSkill`,
|
|
76
|
+
* 8.5.0). Preferred over `nextSkill` when present — the stage takes the cursor
|
|
77
|
+
* from `.to`, so the graph is still consulted exactly once per iteration, and
|
|
78
|
+
* stamps the cause on `context.evaluated` as `cursorMove`.
|
|
79
|
+
*
|
|
80
|
+
* Optional for forward-compat with graphs built before it existed; without it
|
|
81
|
+
* the stage falls back to `nextSkill` and emits no `cursorMove` (an observer
|
|
82
|
+
* then sees exactly what it saw in 8.4.0).
|
|
83
|
+
*/
|
|
84
|
+
readonly explainNextSkill?: (ctx: InjectionContext) => CursorMove;
|
|
73
85
|
}
|
|
74
86
|
/** One routed entry per (active injection × slot it contributes to). */
|
|
75
87
|
export interface RoutedInjection {
|
|
@@ -73,7 +73,7 @@ export function buildInjectionEngineSubflow(config) {
|
|
|
73
73
|
return flowChart('Gather', gatherStage, 'gather', {
|
|
74
74
|
description: "Snapshot this turn's injection inputs (iteration, history, last tool, LLM-activated)",
|
|
75
75
|
})
|
|
76
|
-
.addFunction('Evaluate', makeEvaluateStage(injections, config.nextSkill), 'evaluate', 'Evaluate every Injection trigger; produce activeInjections + metadata')
|
|
76
|
+
.addFunction('Evaluate', makeEvaluateStage(injections, config.nextSkill, config.explainNextSkill), 'evaluate', 'Evaluate every Injection trigger; produce activeInjections + metadata')
|
|
77
77
|
.addFunction('Route', routeStage, 'route', 'Partition active injections into per-slot buckets (system-prompt / messages / tools)')
|
|
78
78
|
.addFunction('Delta', deltaStage, 'delta', 'Per-slot delta vs last turn: what activated / deactivated / stayed')
|
|
79
79
|
.build();
|
|
@@ -90,7 +90,7 @@ function gatherStage(scope) {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
// ── Stage 2: Evaluate (logic identical to the old single stage) ──────────
|
|
93
|
-
function makeEvaluateStage(injections, nextSkill) {
|
|
93
|
+
function makeEvaluateStage(injections, nextSkill, explainNextSkill) {
|
|
94
94
|
return (scope) => {
|
|
95
95
|
const args = scope.$getArgs();
|
|
96
96
|
const ctx = {
|
|
@@ -110,8 +110,13 @@ function makeEvaluateStage(injections, nextSkill) {
|
|
|
110
110
|
// (`nextSkillCursor`) because `currentSkillId` arrives as a readonly INPUT
|
|
111
111
|
// here; the mount's outputMapper maps it onto the parent's mutable
|
|
112
112
|
// `currentSkillId` for the next iteration. Skill-graph agents only.
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
// ONE consultation of the graph per iteration: when the graph can explain
|
|
114
|
+
// itself (8.5.0) the cursor comes out of `.to`, so asking for the cause costs
|
|
115
|
+
// nothing extra and cannot answer a different destination than the routing did.
|
|
116
|
+
const move = explainNextSkill ? explainNextSkill(ctx) : undefined;
|
|
117
|
+
const routes = explainNextSkill !== undefined || nextSkill !== undefined;
|
|
118
|
+
const cursor = move ? move.to : nextSkill ? nextSkill(ctx) : undefined;
|
|
119
|
+
if (routes) {
|
|
115
120
|
scope.$setValue('nextSkillCursor', cursor);
|
|
116
121
|
}
|
|
117
122
|
const evaluation = evaluateInjections(injections, ctx);
|
|
@@ -141,6 +146,15 @@ function makeEvaluateStage(injections, nextSkill) {
|
|
|
141
146
|
const activePOJOs = evaluation.active.map(projectActiveInjection);
|
|
142
147
|
scope.$setValue('activeInjections', activePOJOs);
|
|
143
148
|
const routing = routingEntriesOf(evaluation.active);
|
|
149
|
+
// Structural copy (the events layer stays decoupled from `CursorMove`), and a
|
|
150
|
+
// POJO so it survives the emit channel's clone.
|
|
151
|
+
const cursorMove = move
|
|
152
|
+
? {
|
|
153
|
+
...(move.from !== undefined && { from: move.from }),
|
|
154
|
+
...(move.to !== undefined && { to: move.to }),
|
|
155
|
+
by: move.by,
|
|
156
|
+
}
|
|
157
|
+
: undefined;
|
|
144
158
|
// Aggregate evaluation metadata is pure OBSERVABILITY — no flow stage
|
|
145
159
|
// reads it — so it goes out the EMIT channel where a recorder/Lens can
|
|
146
160
|
// observe "what was considered, what won, what was skipped and why".
|
|
@@ -158,7 +172,17 @@ function makeEvaluateStage(injections, nextSkill) {
|
|
|
158
172
|
skillCatalog: skillCatalogOf(injections),
|
|
159
173
|
// Routing PROVENANCE for active skill-graph injections — the decision path
|
|
160
174
|
// / edge that reached each. Undefined when none came from a skillGraph().
|
|
175
|
+
//
|
|
176
|
+
// NOTE the difference from `cursorMove` below, which is the whole reason the
|
|
177
|
+
// latter exists: `routing[]` is BUILD-TIME provenance ("how is this skill
|
|
178
|
+
// reachable at all"), stamped once by the compiler. It answers per SKILL, not
|
|
179
|
+
// per HOP. Reading it as the cause of this turn's move is what made a model
|
|
180
|
+
// pick get recorded under a declared edge's label.
|
|
161
181
|
...(routing && { routing }),
|
|
182
|
+
// How the CURSOR actually moved this iteration, straight from the clause that
|
|
183
|
+
// won inside the resolver (8.5.0). Skill-graph agents only; absent for a graph
|
|
184
|
+
// built before `explainNextSkill` existed.
|
|
185
|
+
...(cursorMove && { cursorMove }),
|
|
162
186
|
});
|
|
163
187
|
};
|
|
164
188
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildInjectionEngineSubflow.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/buildInjectionEngineSubflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EACL,sBAAsB,GAIvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"buildInjectionEngineSubflow.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/buildInjectionEngineSubflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EACL,sBAAsB,GAIvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,wBAAwB,EAAsC,MAAM,iBAAi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C;QAC1D,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;KACvD,CAAC;AACJ,CAAC;AAED;6EAC6E;AAC7E,SAAS,cAAc,CACrB,UAAgC;IAEhC,OAAO,UAAU;SACd,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC;SACnC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,kBAAkB,EAAE,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,sEAAsE;AACtE,SAAS,iBAAiB,CAAC,MAA4B;IACrD,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -18,6 +18,6 @@ export { buildListSkillsTool, buildReadSkillTool, type SkillToolPair } from './s
|
|
|
18
18
|
export { defineSteering, type DefineSteeringOptions } from './factories/defineSteering.js';
|
|
19
19
|
export { defineFact, type DefineFactOptions } from './factories/defineFact.js';
|
|
20
20
|
export { defineInjection, type DefineInjectionOptions, type InjectionFlavor, } from './factories/defineInjection.js';
|
|
21
|
-
export { skillGraph, decideSkill, SKILL_GRAPH_METADATA_KEY, type SkillGraph, type SkillGraphBuilder, type SkillRouteOptions, type SkillEntryOptions, type TreeOptions, type SkillEdge, type SkillEdgeKind, type SkillNode, type DecisionNode, type SkillRouting, type SkillRoutingStep, type EntryScore, type EntryScoring, type SkillGraphConfig, type SkillGraphFlatConfig, type SkillGraphTreeConfig, type SkillGraphStart, type SkillGraphStep, type BuildOptions, type GraphCheckMode, type GraphCheckup, type GraphProblem, type GraphProblemCode, } from './skillGraph.js';
|
|
21
|
+
export { skillGraph, decideSkill, SKILL_GRAPH_METADATA_KEY, type SkillGraph, type SkillGraphBuilder, type SkillRouteOptions, type SkillEntryOptions, type TreeOptions, type SkillEdge, type SkillEdgeKind, type SkillNode, type DecisionNode, type SkillRouting, type SkillRoutingStep, type CursorMove, type CursorMoveCause, type EntryScore, type EntryScoring, type SkillGraphConfig, type SkillGraphFlatConfig, type SkillGraphTreeConfig, type SkillGraphStart, type SkillGraphStep, type BuildOptions, type GraphCheckMode, type GraphCheckup, type GraphProblem, type GraphProblemCode, } from './skillGraph.js';
|
|
22
22
|
export { keywordScorer, embeddingScorer, rankEntries, type EntryScorer, type EntryScorerInput, type EntryCandidate, } from './entryScorer.js';
|
|
23
23
|
export { checkSkillContract, checkSkillContracts, skillToolNames } from './skillContract.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,+DAA+D;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,SAAS;AACT,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EACL,2BAA2B,GAE5B,MAAM,kCAAkC,CAAC;AAE1C,gFAAgF;AAChF,OAAO,EAAE,iBAAiB,EAAiC,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAA6B,MAAM,oCAAoC,CAAC;AAEpG,OAAO,EACL,WAAW,EACX,kBAAkB,GAKnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAE9E,8EAA8E;AAC9E,+EAA+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CAAC;AAE9F,OAAO,EAAE,cAAc,EAA8B,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EAAE,UAAU,EAA0B,MAAM,2BAA2B,CAAC;AAE/E,6EAA6E;AAC7E,0EAA0E;AAC1E,qDAAqD;AACrD,OAAO,EACL,eAAe,GAGhB,MAAM,gCAAgC,CAAC;AAExC,4EAA4E;AAC5E,8EAA8E;AAC9E,OAAO,EACL,UAAU,EACV,WAAW,EACX,wBAAwB,GA4BzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,eAAe,EACf,WAAW,GAIZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a skill's BODY actually lands — and the one combination where the honest
|
|
3
|
+
* answer is "nowhere" (8.5.0).
|
|
4
|
+
*
|
|
5
|
+
* `surfaceMode` names a delivery CHANNEL, and `'tool-only'` names the channel that
|
|
6
|
+
* only exists when the model calls `read_skill`: the body is returned as that tool's
|
|
7
|
+
* result, and the system slot suppresses it by design (`buildSystemPromptSlot`,
|
|
8
|
+
* mirrored in `routeActiveInjections`). That is exactly right for a skill `read_skill`
|
|
9
|
+
* activates, which is what the mode was designed against and what every shipped
|
|
10
|
+
* Block-C test covers.
|
|
11
|
+
*
|
|
12
|
+
* It is a hole for a skill the GRAPH activates. A route target, a flat entry and a
|
|
13
|
+
* decision-tree leaf all activate off the cursor, without any `read_skill` call — so
|
|
14
|
+
* the tool result never happens, the system slot suppresses the body anyway, and the
|
|
15
|
+
* body reaches the model through no channel at all. The skill's TOOLS still arrive,
|
|
16
|
+
* which makes it worse than the skill not loading: the model is handed the tools of a
|
|
17
|
+
* procedure it was never told.
|
|
18
|
+
*
|
|
19
|
+
* The rule that closes it is the one 8.4.0 already uses for the `read_skill` gate:
|
|
20
|
+
* `trigger.kind === 'llm-activated'` is precisely "read_skill can really activate
|
|
21
|
+
* this". A skill may claim the read_skill delivery channel exactly when read_skill is
|
|
22
|
+
* what activates it.
|
|
23
|
+
*
|
|
24
|
+
* Refusal rather than a quiet fall back to the system slot, because the author wrote
|
|
25
|
+
* `'tool-only'` to keep the body OUT of the system prompt (token cost, attention
|
|
26
|
+
* placement). Silently putting it back would honour the activation and break the
|
|
27
|
+
* declaration — a different lie, not a fix. `'both'` already means "deliver it either
|
|
28
|
+
* way", so the refusal has a real, one-word answer to name.
|
|
29
|
+
*/
|
|
30
|
+
import type { Injection } from './types.js';
|
|
31
|
+
import { type SurfaceMode } from './factories/defineSkill.js';
|
|
32
|
+
/**
|
|
33
|
+
* The surface mode a skill will be TREATED as at runtime.
|
|
34
|
+
*
|
|
35
|
+
* Today the runtime compares the literal string, so `'auto'` is its own mode and
|
|
36
|
+
* lands in the system slot — pass no provider and that is what you get back, which
|
|
37
|
+
* is the truth about the current engine.
|
|
38
|
+
*
|
|
39
|
+
* Pass a provider (and model) to ask the OTHER question: what would `'auto'` become
|
|
40
|
+
* if the `resolveSurfaceMode` cascade were wired into the runtime? It resolves to
|
|
41
|
+
* `'tool-only'` for every non-Claude provider, so wiring it in without this guard
|
|
42
|
+
* would silently open the delivered-nowhere hole for every OpenAI / Bedrock / Ollama
|
|
43
|
+
* user at once. Routing both questions through ONE function is what keeps that from
|
|
44
|
+
* being a future accident: the refusal below is written against this, so the day the
|
|
45
|
+
* cascade is wired in, the guard already covers it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolvedSurfaceModeOf(skill: Injection, provider?: string, model?: string): SurfaceMode;
|
|
48
|
+
/**
|
|
49
|
+
* Can this skill's body be delivered through the `read_skill` tool result?
|
|
50
|
+
*
|
|
51
|
+
* Only if `read_skill` is what activates it. `'llm-activated'` is the one trigger
|
|
52
|
+
* kind that reads `activatedInjectionIds`, which is the only thing a `read_skill`
|
|
53
|
+
* call writes — the same clause the gate's open-skill rule turns on (8.4.0).
|
|
54
|
+
*/
|
|
55
|
+
export declare function activatesByRead(skill: Injection): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Refuse every skill that claims the `read_skill` delivery channel without being
|
|
58
|
+
* activated by `read_skill`. Returns the message, or `undefined` when all is well.
|
|
59
|
+
*
|
|
60
|
+
* Runs over the FINAL injection list — the agent is the only place that sees every
|
|
61
|
+
* skill's compiled trigger, whichever call registered it — and names every offender,
|
|
62
|
+
* because `skillsFromDir({ surfaceMode: 'tool-only' })` under a graph refuses a whole
|
|
63
|
+
* directory at once and a list is debuggable where one sample is not.
|
|
64
|
+
*/
|
|
65
|
+
export declare function toolOnlyDeliveryRefusal(injections: readonly Injection[]): string | undefined;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a skill's BODY actually lands — and the one combination where the honest
|
|
3
|
+
* answer is "nowhere" (8.5.0).
|
|
4
|
+
*
|
|
5
|
+
* `surfaceMode` names a delivery CHANNEL, and `'tool-only'` names the channel that
|
|
6
|
+
* only exists when the model calls `read_skill`: the body is returned as that tool's
|
|
7
|
+
* result, and the system slot suppresses it by design (`buildSystemPromptSlot`,
|
|
8
|
+
* mirrored in `routeActiveInjections`). That is exactly right for a skill `read_skill`
|
|
9
|
+
* activates, which is what the mode was designed against and what every shipped
|
|
10
|
+
* Block-C test covers.
|
|
11
|
+
*
|
|
12
|
+
* It is a hole for a skill the GRAPH activates. A route target, a flat entry and a
|
|
13
|
+
* decision-tree leaf all activate off the cursor, without any `read_skill` call — so
|
|
14
|
+
* the tool result never happens, the system slot suppresses the body anyway, and the
|
|
15
|
+
* body reaches the model through no channel at all. The skill's TOOLS still arrive,
|
|
16
|
+
* which makes it worse than the skill not loading: the model is handed the tools of a
|
|
17
|
+
* procedure it was never told.
|
|
18
|
+
*
|
|
19
|
+
* The rule that closes it is the one 8.4.0 already uses for the `read_skill` gate:
|
|
20
|
+
* `trigger.kind === 'llm-activated'` is precisely "read_skill can really activate
|
|
21
|
+
* this". A skill may claim the read_skill delivery channel exactly when read_skill is
|
|
22
|
+
* what activates it.
|
|
23
|
+
*
|
|
24
|
+
* Refusal rather than a quiet fall back to the system slot, because the author wrote
|
|
25
|
+
* `'tool-only'` to keep the body OUT of the system prompt (token cost, attention
|
|
26
|
+
* placement). Silently putting it back would honour the activation and break the
|
|
27
|
+
* declaration — a different lie, not a fix. `'both'` already means "deliver it either
|
|
28
|
+
* way", so the refusal has a real, one-word answer to name.
|
|
29
|
+
*/
|
|
30
|
+
import { resolveSurfaceMode } from './factories/defineSkill.js';
|
|
31
|
+
/** A skill's declared surface mode, before any provider resolution. */
|
|
32
|
+
function declaredSurfaceModeOf(skill) {
|
|
33
|
+
const meta = skill.metadata;
|
|
34
|
+
return meta?.surfaceMode ?? 'auto';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The surface mode a skill will be TREATED as at runtime.
|
|
38
|
+
*
|
|
39
|
+
* Today the runtime compares the literal string, so `'auto'` is its own mode and
|
|
40
|
+
* lands in the system slot — pass no provider and that is what you get back, which
|
|
41
|
+
* is the truth about the current engine.
|
|
42
|
+
*
|
|
43
|
+
* Pass a provider (and model) to ask the OTHER question: what would `'auto'` become
|
|
44
|
+
* if the `resolveSurfaceMode` cascade were wired into the runtime? It resolves to
|
|
45
|
+
* `'tool-only'` for every non-Claude provider, so wiring it in without this guard
|
|
46
|
+
* would silently open the delivered-nowhere hole for every OpenAI / Bedrock / Ollama
|
|
47
|
+
* user at once. Routing both questions through ONE function is what keeps that from
|
|
48
|
+
* being a future accident: the refusal below is written against this, so the day the
|
|
49
|
+
* cascade is wired in, the guard already covers it.
|
|
50
|
+
*/
|
|
51
|
+
export function resolvedSurfaceModeOf(skill, provider, model) {
|
|
52
|
+
const declared = declaredSurfaceModeOf(skill);
|
|
53
|
+
if (declared !== 'auto' || provider === undefined)
|
|
54
|
+
return declared;
|
|
55
|
+
return resolveSurfaceMode(provider, model);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Can this skill's body be delivered through the `read_skill` tool result?
|
|
59
|
+
*
|
|
60
|
+
* Only if `read_skill` is what activates it. `'llm-activated'` is the one trigger
|
|
61
|
+
* kind that reads `activatedInjectionIds`, which is the only thing a `read_skill`
|
|
62
|
+
* call writes — the same clause the gate's open-skill rule turns on (8.4.0).
|
|
63
|
+
*/
|
|
64
|
+
export function activatesByRead(skill) {
|
|
65
|
+
return skill.trigger.kind === 'llm-activated';
|
|
66
|
+
}
|
|
67
|
+
/** How a refused skill is identified back to its author, so a directory-sized
|
|
68
|
+
* refusal reads as a list of names and reasons rather than one mystery. */
|
|
69
|
+
function describeRouting(skill) {
|
|
70
|
+
const routing = skill.metadata
|
|
71
|
+
?.skillGraph;
|
|
72
|
+
if (routing?.via === 'route') {
|
|
73
|
+
return routing.from
|
|
74
|
+
? `a route target (the graph routes "${routing.from}" → "${skill.id}")`
|
|
75
|
+
: 'a route target';
|
|
76
|
+
}
|
|
77
|
+
if (routing?.via === 'entry')
|
|
78
|
+
return 'a graph entry';
|
|
79
|
+
if (routing?.via === 'tree')
|
|
80
|
+
return 'a decision-tree leaf';
|
|
81
|
+
return `activated by rule (trigger '${skill.trigger.kind}')`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Refuse every skill that claims the `read_skill` delivery channel without being
|
|
85
|
+
* activated by `read_skill`. Returns the message, or `undefined` when all is well.
|
|
86
|
+
*
|
|
87
|
+
* Runs over the FINAL injection list — the agent is the only place that sees every
|
|
88
|
+
* skill's compiled trigger, whichever call registered it — and names every offender,
|
|
89
|
+
* because `skillsFromDir({ surfaceMode: 'tool-only' })` under a graph refuses a whole
|
|
90
|
+
* directory at once and a list is debuggable where one sample is not.
|
|
91
|
+
*/
|
|
92
|
+
export function toolOnlyDeliveryRefusal(injections) {
|
|
93
|
+
const offenders = injections.filter((i) => i.flavor === 'skill' &&
|
|
94
|
+
resolvedSurfaceModeOf(i) === 'tool-only' &&
|
|
95
|
+
!activatesByRead(i) &&
|
|
96
|
+
(i.inject.systemPrompt ?? '').length > 0);
|
|
97
|
+
if (offenders.length === 0)
|
|
98
|
+
return undefined;
|
|
99
|
+
const list = offenders.map((s) => ` • "${s.id}" — ${describeRouting(s)}`).join('\n');
|
|
100
|
+
const subject = offenders.length === 1 ? 'This skill sets' : 'These skills set';
|
|
101
|
+
const its = offenders.length === 1 ? 'its' : 'their';
|
|
102
|
+
return (`Agent: ${subject} surfaceMode: 'tool-only', which delivers the body as the ` +
|
|
103
|
+
`read_skill tool result — but nothing here activates by read_skill, so ${its} ` +
|
|
104
|
+
`body would reach the model NOWHERE: the system slot suppresses a tool-only body ` +
|
|
105
|
+
`by design, and no read_skill call happens to carry it.\n${list}\n` +
|
|
106
|
+
`Use 'both' (system prompt AND tool result) or 'system-prompt'. Only a skill ` +
|
|
107
|
+
`read_skill actually activates — trigger 'llm-activated', which is every skill a ` +
|
|
108
|
+
`graph does not route — can be 'tool-only'.`);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=skillBodyDelivery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillBodyDelivery.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/skillBodyDelivery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,kBAAkB,EAAoB,MAAM,4BAA4B,CAAC;AAElF,uEAAuE;AACvE,SAAS,qBAAqB,CAAC,KAAgB;IAC7C,MAAM,IAAI,GAAG,KAAK,CAAC,QAAqD,CAAC;IACzE,OAAO,IAAI,EAAE,WAAW,IAAI,MAAM,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAgB,EAChB,QAAiB,EACjB,KAAc;IAEd,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ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AAC,CAAC,EAAE,OAAO,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtF,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,kBAAkB,CAAC;IAChF,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;IACrD,OAAO,CACL,UAAU,OAAO,4DAA4D;QAC7E,yEAAyE,GAAG,GAAG;QAC/E,kFAAkF;QAClF,2DAA2D,IAAI,IAAI;QACnE,8EAA8E;QAC9E,kFAAkF;QAClF,4CAA4C,CAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
*
|
|
13
13
|
* **v2 keystone — `from` IS enforced (a sticky cursor state machine).** A skill
|
|
14
14
|
* graph is a state machine over skills; the engine tracks which node it is in via
|
|
15
|
-
* `InjectionContext.currentSkillId` (the cursor). One pure resolver — `
|
|
16
|
-
* (see `
|
|
15
|
+
* `InjectionContext.currentSkillId` (the cursor). One pure resolver — `resolveCursor`
|
|
16
|
+
* (see `makeResolveCursor`), of which `nextSkill(ctx)` is the `.to` projection — is the
|
|
17
|
+
* single source of truth: each route target B
|
|
17
18
|
* compiles to the trigger `nextSkill(ctx) === B`, which delivers `from`-gating
|
|
18
19
|
* (an edge `A→B` fires only while the cursor is on A — no cross-skill edge bleed),
|
|
19
20
|
* stickiness (the cursor stays on B until an edge leaves B), and a clean handoff
|
|
@@ -24,16 +25,26 @@
|
|
|
24
25
|
* compiled trigger is always a `rule`. `toMermaid()` renders declared === drawn.
|
|
25
26
|
*
|
|
26
27
|
* A decision `tree()` routes per-iteration by stable `ctx` predicates (no cursor)
|
|
27
|
-
* and is unaffected by `from`-gating.
|
|
28
|
+
* and is unaffected by `from`-gating. It has no cursor for `read_skill` to move
|
|
29
|
+
* either, so `reachableSkills()` is EMPTY there and the gate refuses a leaf pick
|
|
30
|
+
* (8.5.0) — see `reachableSkills` for why honouring it would break three of this
|
|
31
|
+
* module's own invariants.
|
|
28
32
|
*
|
|
29
33
|
* **The model moves too (`read_skill`).** Scoped `read_skill` bounds the model to
|
|
30
34
|
* `reachableSkills(cursor)` — the declared successors of where it stands, plus the
|
|
31
35
|
* entries. A pick the gate ACCEPTS moves the cursor exactly like a declared edge
|
|
32
|
-
* does (`ctx.pendingSkillPick`, honoured in `
|
|
36
|
+
* does (`ctx.pendingSkillPick`, honoured in `makeResolveCursor`), so what the gate
|
|
33
37
|
* allows and what actually takes effect are the same set. A declared edge that
|
|
34
38
|
* fires the same turn wins (`D1 > D2`, docs/design/skill-graph.md §4A.1) and the
|
|
35
39
|
* run emits `agentfootprint.skill.reroute_superseded` rather than leaving the
|
|
36
40
|
* model's answered-"activated" claim quietly unmet.
|
|
41
|
+
*
|
|
42
|
+
* **The resolver says WHY, it is not asked to be guessed.** `explainNextSkill(ctx)`
|
|
43
|
+
* returns the destination AND the winning clause (`CursorMove`), decided at the same
|
|
44
|
+
* `return`. The agent stamps it on `context.evaluated` as `cursorMove`, which is how
|
|
45
|
+
* `routeRecorder()` can tell a model pick from a declared edge that happens to point
|
|
46
|
+
* at the same skill (8.5.0 — before, the drawn build-time provenance was read as the
|
|
47
|
+
* per-hop cause, so a model pick was recorded under a declared edge's label).
|
|
37
48
|
*/
|
|
38
49
|
import type { Injection, InjectionContext } from './types.js';
|
|
39
50
|
import type { Embedder } from '../../memory/embedding/types.js';
|
|
@@ -152,8 +163,15 @@ export interface TreeOptions {
|
|
|
152
163
|
* A decision tree routes to EXACTLY ONE skill per iteration, so each leaf is
|
|
153
164
|
* stamped `autoActivate: 'currentSkill'` — its `inject.tools` reach the LLM
|
|
154
165
|
* ONLY when the tree routes there, instead of every skill's tools landing in
|
|
155
|
-
* the always-on static registry on every call.
|
|
156
|
-
*
|
|
166
|
+
* the always-on static registry on every call.
|
|
167
|
+
*
|
|
168
|
+
* `read_skill` cannot reach another LEAF mid-run (8.5.0): a tree has no cursor to
|
|
169
|
+
* move, and this "exactly one leaf" property is one of the reasons — admitting a
|
|
170
|
+
* second leaf would put two leaves' tools on the wire and make the dev-mode
|
|
171
|
+
* exactly-one monitor warn. It said otherwise until 8.5.0, and the pick was
|
|
172
|
+
* accepted and then silently dropped. The escape hatch is a skill registered
|
|
173
|
+
* BESIDE the graph (`.skill(x)`, `.selfExplain()`), which really does activate by
|
|
174
|
+
* `read_skill` and is admitted from anywhere.
|
|
157
175
|
*
|
|
158
176
|
* Default `true`. Set `false` for the legacy additive behavior (all leaves'
|
|
159
177
|
* tools always visible). A leaf that sets its OWN `autoActivate` in
|
|
@@ -188,6 +206,33 @@ export interface DecisionNode {
|
|
|
188
206
|
* other `decideSkill(...)` results. (Renamed from `decide` in v7 to avoid
|
|
189
207
|
* colliding with footprintjs's `decide()`.) */
|
|
190
208
|
export declare function decideSkill(predicate: (ctx: InjectionContext) => boolean, whenTrue: DecisionNode | Injection, whenFalse: DecisionNode | Injection, label?: string): DecisionNode;
|
|
209
|
+
/**
|
|
210
|
+
* WHY the cursor landed where it did on one iteration — the winning clause of the
|
|
211
|
+
* one cursor resolver, reported rather than guessed (8.5.0).
|
|
212
|
+
*
|
|
213
|
+
* • `'entry'` — cold start: the first entry whose `when` passed;
|
|
214
|
+
* • `'route'` — a declared, `from`-gated edge fired (D1);
|
|
215
|
+
* • `'model-pick'` — no declared edge fired, so the model's gate-accepted
|
|
216
|
+
* `read_skill` pick moved the cursor (D2), at cold start or mid-run;
|
|
217
|
+
* • `'stay'` — nothing fired; the cursor is sticky and stayed put;
|
|
218
|
+
* • `'none'` — no cursor at all (cold start with nothing to enter, or a
|
|
219
|
+
* decision `tree()`, which routes by predicate and has no cursor).
|
|
220
|
+
*
|
|
221
|
+
* This exists because the DRAWN provenance on a skill (`metadata.skillGraph`) answers
|
|
222
|
+
* "how is this skill reachable" — a build-time fact — and was being read as "how did
|
|
223
|
+
* we get here this turn". A model pick into a skill that also has a declared edge was
|
|
224
|
+
* therefore attributed to that edge, label and all, in the recorded route.
|
|
225
|
+
*/
|
|
226
|
+
export type CursorMoveCause = 'entry' | 'route' | 'model-pick' | 'stay' | 'none';
|
|
227
|
+
/** The cursor resolver's full answer: where, and by which clause. */
|
|
228
|
+
export interface CursorMove {
|
|
229
|
+
/** The cursor after this iteration (what `nextSkill` returns). */
|
|
230
|
+
readonly to?: string;
|
|
231
|
+
/** The cursor before it. */
|
|
232
|
+
readonly from?: string;
|
|
233
|
+
/** The winning clause. */
|
|
234
|
+
readonly by: CursorMoveCause;
|
|
235
|
+
}
|
|
191
236
|
/** A node in the drawn graph — a `predicate` diamond or a `skill` box. */
|
|
192
237
|
export interface SkillNode {
|
|
193
238
|
readonly id: string;
|
|
@@ -256,6 +301,19 @@ export interface SkillGraph {
|
|
|
256
301
|
* by predicate (no cursor) and returns the unchanged `ctx.currentSkillId`.
|
|
257
302
|
*/
|
|
258
303
|
nextSkill(ctx: InjectionContext): string | undefined;
|
|
304
|
+
/**
|
|
305
|
+
* The same answer as `nextSkill`, plus WHICH CLAUSE produced it — the resolver
|
|
306
|
+
* reporting its own reasoning instead of a consumer inferring it from the drawn
|
|
307
|
+
* provenance (8.5.0). `explainNextSkill(ctx).to === nextSkill(ctx)`, always: there
|
|
308
|
+
* is one resolver and `nextSkill` is a thin projection of this one, so the two can
|
|
309
|
+
* never drift.
|
|
310
|
+
*
|
|
311
|
+
* The agent threads this into the injection engine, which stamps the result on
|
|
312
|
+
* `agentfootprint.context.evaluated` as `cursorMove` — that is what lets
|
|
313
|
+
* `routeRecorder()` mark a model-pick hop as a model pick instead of borrowing the
|
|
314
|
+
* label of a declared edge that never fired.
|
|
315
|
+
*/
|
|
316
|
+
explainNextSkill(ctx: InjectionContext): CursorMove;
|
|
259
317
|
/**
|
|
260
318
|
* The REACHABLE set — which skills the model may `read_skill`-jump to from the
|
|
261
319
|
* current cursor. The agent's runtime gate rejects any `read_skill('id')` whose
|
|
@@ -263,8 +321,19 @@ export interface SkillGraph {
|
|
|
263
321
|
* • cold start (`currentSkillId` undefined) → the entry skills;
|
|
264
322
|
* • otherwise → the current skill's direct successors ∪ the entry skills, minus
|
|
265
323
|
* the current skill itself (deliberate "stay" is the no-tool-call ReAct stop).
|
|
266
|
-
*
|
|
267
|
-
*
|
|
324
|
+
*
|
|
325
|
+
* A decision `tree()` returns EMPTY (8.5.0). A tree routes by predicate on every
|
|
326
|
+
* iteration and has no cursor to jump: its leaves compile to `rule` triggers, and a
|
|
327
|
+
* `read_skill` call writes only `activatedInjectionIds`, which a `rule` trigger does
|
|
328
|
+
* not read. Until 8.5.0 this returned all the leaves, so the gate accepted a leaf
|
|
329
|
+
* pick, the tool answered "activated for the next iteration", and the leaf never
|
|
330
|
+
* activated. That is the same clause 8.4.0 already applies everywhere else — a skill
|
|
331
|
+
* is open only when its trigger is `llm-activated` — reaching the one set that had
|
|
332
|
+
* escaped it. The escape hatch under a tree is the OPEN skills (anything registered
|
|
333
|
+
* beside the graph: `.skill(x)`, `.selfExplain()`), which the agent's gate still
|
|
334
|
+
* admits from any cursor.
|
|
335
|
+
*
|
|
336
|
+
* Pure + deterministic.
|
|
268
337
|
*/
|
|
269
338
|
reachableSkills(currentSkillId?: string): readonly string[];
|
|
270
339
|
/**
|