agentfootprint 9.56.0 → 9.57.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 +5 -0
- package/dist/cache/CacheDecisionSubflow.js +2 -1
- package/dist/cache/CacheDecisionSubflow.js.map +1 -1
- package/dist/core/Agent.js +18 -0
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +4 -0
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -0
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/callLLM.js +2 -1
- package/dist/core/agent/stages/callLLM.js.map +1 -1
- package/dist/core/agent/stages/window.js +75 -3
- package/dist/core/agent/stages/window.js.map +1 -1
- package/dist/core/agent/window/index.js.map +1 -1
- package/dist/core/agent/window/lastToolResult.js +123 -0
- package/dist/core/agent/window/lastToolResult.js.map +1 -0
- package/dist/core/agent/window/notice.js +58 -6
- package/dist/core/agent/window/notice.js.map +1 -1
- package/dist/core/agent/window/options.js +31 -1
- package/dist/core/agent/window/options.js.map +1 -1
- package/dist/core/agent/window/strategies/drop.js +73 -17
- package/dist/core/agent/window/strategies/drop.js.map +1 -1
- package/dist/core/agent/window/toolNames.js +81 -0
- package/dist/core/agent/window/toolNames.js.map +1 -0
- package/dist/core/agent/window/turns.js +50 -2
- package/dist/core/agent/window/turns.js.map +1 -1
- package/dist/esm/cache/CacheDecisionSubflow.js +2 -1
- package/dist/esm/cache/CacheDecisionSubflow.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +3 -0
- package/dist/esm/core/Agent.js +18 -0
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/buildAgentChart.js +4 -0
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/stages/callLLM.js +2 -1
- package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
- package/dist/esm/core/agent/stages/window.d.ts +10 -0
- package/dist/esm/core/agent/stages/window.js +75 -3
- package/dist/esm/core/agent/stages/window.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +35 -0
- package/dist/esm/core/agent/window/index.d.ts +1 -1
- package/dist/esm/core/agent/window/index.js.map +1 -1
- package/dist/esm/core/agent/window/lastToolResult.d.ts +96 -0
- package/dist/esm/core/agent/window/lastToolResult.js +119 -0
- package/dist/esm/core/agent/window/lastToolResult.js.map +1 -0
- package/dist/esm/core/agent/window/notice.d.ts +14 -4
- package/dist/esm/core/agent/window/notice.js +58 -6
- package/dist/esm/core/agent/window/notice.js.map +1 -1
- package/dist/esm/core/agent/window/options.d.ts +21 -0
- package/dist/esm/core/agent/window/options.js +29 -0
- package/dist/esm/core/agent/window/options.js.map +1 -1
- package/dist/esm/core/agent/window/strategies/drop.d.ts +20 -0
- package/dist/esm/core/agent/window/strategies/drop.js +73 -17
- package/dist/esm/core/agent/window/strategies/drop.js.map +1 -1
- package/dist/esm/core/agent/window/toolNames.d.ts +53 -0
- package/dist/esm/core/agent/window/toolNames.js +76 -0
- package/dist/esm/core/agent/window/toolNames.js.map +1 -0
- package/dist/esm/core/agent/window/turns.d.ts +23 -1
- package/dist/esm/core/agent/window/turns.js +50 -2
- package/dist/esm/core/agent/window/turns.js.map +1 -1
- package/dist/esm/core/agent/window/types.d.ts +84 -0
- package/dist/esm/events/payloads.d.ts +3 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +12 -1
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/evaluator.js +31 -6
- package/dist/esm/lib/injection-engine/evaluator.js.map +1 -1
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +45 -3
- package/dist/esm/lib/injection-engine/factories/defineInstruction.js +38 -4
- package/dist/esm/lib/injection-engine/factories/defineInstruction.js.map +1 -1
- package/dist/esm/lib/injection-engine/promptTemplate.d.ts +76 -0
- package/dist/esm/lib/injection-engine/promptTemplate.js +124 -0
- package/dist/esm/lib/injection-engine/promptTemplate.js.map +1 -0
- package/dist/esm/lib/injection-engine/types.d.ts +60 -3
- package/dist/esm/lib/injection-engine/types.js +25 -3
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/iterationBudget.d.ts +28 -0
- package/dist/esm/lib/iterationBudget.js +31 -0
- package/dist/esm/lib/iterationBudget.js.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +12 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/evaluator.js +31 -6
- package/dist/lib/injection-engine/evaluator.js.map +1 -1
- package/dist/lib/injection-engine/factories/defineInstruction.js +38 -4
- package/dist/lib/injection-engine/factories/defineInstruction.js.map +1 -1
- package/dist/lib/injection-engine/promptTemplate.js +132 -0
- package/dist/lib/injection-engine/promptTemplate.js.map +1 -0
- package/dist/lib/injection-engine/types.js +25 -3
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/lib/iterationBudget.js +35 -0
- package/dist/lib/iterationBudget.js.map +1 -0
- package/dist/types/cache/CacheDecisionSubflow.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +3 -0
- package/dist/types/core/Agent.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/callLLM.d.ts.map +1 -1
- package/dist/types/core/agent/stages/window.d.ts +10 -0
- package/dist/types/core/agent/stages/window.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +35 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/agent/window/index.d.ts +1 -1
- package/dist/types/core/agent/window/index.d.ts.map +1 -1
- package/dist/types/core/agent/window/lastToolResult.d.ts +97 -0
- package/dist/types/core/agent/window/lastToolResult.d.ts.map +1 -0
- package/dist/types/core/agent/window/notice.d.ts +14 -4
- package/dist/types/core/agent/window/notice.d.ts.map +1 -1
- package/dist/types/core/agent/window/options.d.ts +21 -0
- package/dist/types/core/agent/window/options.d.ts.map +1 -1
- package/dist/types/core/agent/window/strategies/drop.d.ts +20 -0
- package/dist/types/core/agent/window/strategies/drop.d.ts.map +1 -1
- package/dist/types/core/agent/window/toolNames.d.ts +54 -0
- package/dist/types/core/agent/window/toolNames.d.ts.map +1 -0
- package/dist/types/core/agent/window/turns.d.ts +23 -1
- package/dist/types/core/agent/window/turns.d.ts.map +1 -1
- package/dist/types/core/agent/window/types.d.ts +84 -0
- package/dist/types/core/agent/window/types.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +3 -1
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/evaluator.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/factories/defineInstruction.d.ts +45 -3
- package/dist/types/lib/injection-engine/factories/defineInstruction.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/promptTemplate.d.ts +77 -0
- package/dist/types/lib/injection-engine/promptTemplate.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/types.d.ts +60 -3
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/lib/iterationBudget.d.ts +29 -0
- package/dist/types/lib/iterationBudget.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -29,14 +29,28 @@
|
|
|
29
29
|
* });
|
|
30
30
|
*/
|
|
31
31
|
import { messagesToolRoleRefusal } from '../messagesSlotRefusal.js';
|
|
32
|
+
import { assertKnownFacts, isTemplate, TEMPLATE_FACTS } from '../promptTemplate.js';
|
|
32
33
|
import { resolveCachePolicy } from '../../../cache/applyCachePolicy.js';
|
|
33
34
|
export function defineInstruction(opts) {
|
|
34
35
|
if (!opts.id || opts.id.trim().length === 0) {
|
|
35
36
|
throw new Error('defineInstruction: `id` is required and must be non-empty.');
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
const words = opts;
|
|
39
|
+
if (words.prompt !== undefined && words.promptTemplate !== undefined) {
|
|
40
|
+
throw new Error(`defineInstruction('${opts.id}'): pass \`prompt\` OR \`promptTemplate\`, not both. ` +
|
|
41
|
+
`They are the same decision spelled two ways, and the library will not pick one for you.`);
|
|
39
42
|
}
|
|
43
|
+
const template = words.promptTemplate;
|
|
44
|
+
const text = template ?? words.prompt;
|
|
45
|
+
if (!text || text.length === 0) {
|
|
46
|
+
throw new Error(`defineInstruction(${opts.id}): \`prompt\` is required — or \`promptTemplate\`, when ` +
|
|
47
|
+
`the words name a run-time fact (${TEMPLATE_FACTS.map((f) => `{{${f}}}`).join(', ')}).`);
|
|
48
|
+
}
|
|
49
|
+
// A template is refused HERE for everything it can be refused for, because
|
|
50
|
+
// everything below this line happens on somebody's paid run.
|
|
51
|
+
const templated = template !== undefined && isTemplate(template);
|
|
52
|
+
if (template !== undefined)
|
|
53
|
+
assertKnownFacts(template, `defineInstruction('${opts.id}')`);
|
|
40
54
|
// Refused at run time as well as in the type, read through a widened view —
|
|
41
55
|
// see defineFact for why the widening is deliberate.
|
|
42
56
|
const raw = opts;
|
|
@@ -49,12 +63,26 @@ export function defineInstruction(opts) {
|
|
|
49
63
|
if (toMessages && raw.role === 'tool') {
|
|
50
64
|
throw new Error(messagesToolRoleRefusal(`defineInstruction('${opts.id}')`));
|
|
51
65
|
}
|
|
66
|
+
if (templated && toMessages) {
|
|
67
|
+
throw new Error(`defineInstruction('${opts.id}'): \`promptTemplate\` cannot target ` +
|
|
68
|
+
`\`slot: 'messages'\`. The messages slot delivers each piece ONCE per run, and its ` +
|
|
69
|
+
`ledger keys by the content itself — so a template that renders differently every ` +
|
|
70
|
+
`action would deliver a new message every action, for the whole run. Use the ` +
|
|
71
|
+
`system-prompt slot (the default), which is re-composed per action by design.`);
|
|
72
|
+
}
|
|
73
|
+
if (templated && opts.cache !== undefined && opts.cache !== 'never') {
|
|
74
|
+
throw new Error(`defineInstruction('${opts.id}'): \`promptTemplate\` cannot be cached ` +
|
|
75
|
+
`(\`cache: '${String(opts.cache)}'\`). A cache marker asserts a STABLE PREFIX, and ` +
|
|
76
|
+
`these bytes change on every action — you would pay the cache-write premium for a ` +
|
|
77
|
+
`guaranteed miss, and the trace would claim a stable prefix that never existed. ` +
|
|
78
|
+
`Leave \`cache\` unset, or say \`cache: 'never'\` out loud.`);
|
|
79
|
+
}
|
|
52
80
|
const trigger = opts.activeWhen
|
|
53
81
|
? { kind: 'rule', activeWhen: opts.activeWhen }
|
|
54
82
|
: { kind: 'always' };
|
|
55
83
|
const inject = toMessages
|
|
56
|
-
? { messages: [{ role: raw.role, content:
|
|
57
|
-
: { systemPrompt:
|
|
84
|
+
? { messages: [{ role: raw.role, content: text }] }
|
|
85
|
+
: { systemPrompt: text };
|
|
58
86
|
const cache = resolveCachePolicy('instruction', opts.cache);
|
|
59
87
|
return Object.freeze({
|
|
60
88
|
id: opts.id,
|
|
@@ -62,6 +90,12 @@ export function defineInstruction(opts) {
|
|
|
62
90
|
flavor: 'instructions',
|
|
63
91
|
trigger,
|
|
64
92
|
inject,
|
|
93
|
+
// TOP-LEVEL, not `metadata` (9.57.0): at least one live path rebuilds
|
|
94
|
+
// `metadata` wholesale, and a lost marker means the literal
|
|
95
|
+
// `{{actionsRemaining}}` reaches the model — the exact class of failure
|
|
96
|
+
// this feature exists to prevent. Top-level fields survive every
|
|
97
|
+
// `{...injection}` spread in the repo.
|
|
98
|
+
...(templated && { templated: true }),
|
|
65
99
|
metadata: Object.freeze({ cache }),
|
|
66
100
|
});
|
|
67
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInstruction.js","sourceRoot":"","sources":["../../../../../src/lib/injection-engine/factories/defineInstruction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"defineInstruction.js","sourceRoot":"","sources":["../../../../../src/lib/injection-engine/factories/defineInstruction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAoHxE,MAAM,UAAU,iBAAiB,CAAC,IAA8B;IAC9D,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IACD,MAAM,KAAK,GAAG,IAAoD,CAAC;IACnE,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,CAAC,EAAE,uDAAuD;YAClF,yFAAyF,CAC5F,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,KAAK,CAAC,cAAc,CAAC;IACtC,MAAM,IAAI,GAAG,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC;IACtC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAA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ure functions over a string (no scope, no I/O, no clock).
|
|
6
|
+
* Role: lib/ layer. Used at DEFINE time to refuse a template naming
|
|
7
|
+
* something that does not exist, and at EVALUATE time to render one
|
|
8
|
+
* — the single moment the context and the content are both in scope
|
|
9
|
+
* (`projectActiveInjection`).
|
|
10
|
+
* Emits: N/A.
|
|
11
|
+
*
|
|
12
|
+
* ## Why a closed vocabulary and not a function
|
|
13
|
+
*
|
|
14
|
+
* `Injection.inject` is static data, so an instruction could be GATED on the
|
|
15
|
+
* iteration and could never SAY it: `activeWhen: (ctx) => ctx.iteration > 22`
|
|
16
|
+
* is expressible, "you have used 23 of your 30 actions" is not. The framework
|
|
17
|
+
* hit this three times itself — `defineStepsHint`, `defineMenuHint` and
|
|
18
|
+
* `defineRelevanceHint` each carry a STATIC body and push their DATA through a
|
|
19
|
+
* tool description, because `inject` cannot render. That workaround only works
|
|
20
|
+
* for content the framework can attach to a tool it owns, which is exactly
|
|
21
|
+
* what a consumer reported: they had to ride the count on their own tool
|
|
22
|
+
* results.
|
|
23
|
+
*
|
|
24
|
+
* The obvious fix — let `inject` be `(ctx) => InjectionContent` — fails on
|
|
25
|
+
* ABSENCE. Given a function, an author writes `${ctx.maxIterations}` and ships
|
|
26
|
+
* *"23 of undefined"*, or writes `?? 0` and ships a fabricated denominator the
|
|
27
|
+
* library cannot tell from a real zero. With named slots the LIBRARY owns
|
|
28
|
+
* absence and applies one rule: if any fact a template names is unavailable,
|
|
29
|
+
* the whole instruction is skipped, by name, on the record. Never a fake zero,
|
|
30
|
+
* never a gap, never the literal placeholder.
|
|
31
|
+
*
|
|
32
|
+
* ## The vocabulary
|
|
33
|
+
*
|
|
34
|
+
* Three words, all about the turn's action budget, because that is the fact
|
|
35
|
+
* the field report measured:
|
|
36
|
+
*
|
|
37
|
+
* `{{action}}` the action about to be taken (1-based)
|
|
38
|
+
* `{{actionBudget}}` how many the turn is allowed
|
|
39
|
+
* `{{actionsRemaining}}` how many are left, never negative
|
|
40
|
+
*
|
|
41
|
+
* It is closed on purpose. A name this file does not know is refused at define
|
|
42
|
+
* time, when a person is looking at the error — not at iteration 23 of a paid
|
|
43
|
+
* run.
|
|
44
|
+
*/
|
|
45
|
+
import type { InjectionContext } from './types.js';
|
|
46
|
+
/** Every fact a `promptTemplate` may name. Closed. */
|
|
47
|
+
export declare const TEMPLATE_FACTS: readonly ["action", "actionBudget", "actionsRemaining"];
|
|
48
|
+
export type TemplateFact = (typeof TEMPLATE_FACTS)[number];
|
|
49
|
+
/** Every name the template asks for, in order of appearance, deduplicated. */
|
|
50
|
+
export declare function placeholdersIn(template: string): readonly string[];
|
|
51
|
+
/** True when this string asks for anything at all. */
|
|
52
|
+
export declare function isTemplate(template: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Refuse a template naming something this library cannot supply — at define
|
|
55
|
+
* time, by name, listing what it CAN supply.
|
|
56
|
+
*
|
|
57
|
+
* @param label the factory + id, so the error names the door the author used
|
|
58
|
+
*/
|
|
59
|
+
export declare function assertKnownFacts(template: string, label: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* The facts a template names that this context cannot supply.
|
|
62
|
+
*
|
|
63
|
+
* `{{action}}` is always available — every evaluation has an iteration. The
|
|
64
|
+
* other two need `ctx.maxIterations`, which an engine driven without an agent
|
|
65
|
+
* (a foreign host, a hand-built evaluation) does not have.
|
|
66
|
+
*/
|
|
67
|
+
export declare function missingFactsFor(template: string, ctx: Pick<InjectionContext, 'iteration' | 'maxIterations'>): readonly string[];
|
|
68
|
+
/**
|
|
69
|
+
* Render, or `undefined` when any named fact is unavailable.
|
|
70
|
+
*
|
|
71
|
+
* ALL-OR-NOTHING by design: a template that says "action 25 of {{gap}}" is
|
|
72
|
+
* worse than no instruction at all, and a template that quietly renders
|
|
73
|
+
* "action 25 of 0" is worse again — the library cannot tell a fabricated zero
|
|
74
|
+
* from a real one, and neither can the model.
|
|
75
|
+
*/
|
|
76
|
+
export declare function renderTemplate(template: string, ctx: Pick<InjectionContext, 'iteration' | 'maxIterations'>): string | undefined;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* promptTemplate — an instruction that can SAY a run-time fact, from a closed
|
|
3
|
+
* vocabulary the library owns.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Pure functions over a string (no scope, no I/O, no clock).
|
|
6
|
+
* Role: lib/ layer. Used at DEFINE time to refuse a template naming
|
|
7
|
+
* something that does not exist, and at EVALUATE time to render one
|
|
8
|
+
* — the single moment the context and the content are both in scope
|
|
9
|
+
* (`projectActiveInjection`).
|
|
10
|
+
* Emits: N/A.
|
|
11
|
+
*
|
|
12
|
+
* ## Why a closed vocabulary and not a function
|
|
13
|
+
*
|
|
14
|
+
* `Injection.inject` is static data, so an instruction could be GATED on the
|
|
15
|
+
* iteration and could never SAY it: `activeWhen: (ctx) => ctx.iteration > 22`
|
|
16
|
+
* is expressible, "you have used 23 of your 30 actions" is not. The framework
|
|
17
|
+
* hit this three times itself — `defineStepsHint`, `defineMenuHint` and
|
|
18
|
+
* `defineRelevanceHint` each carry a STATIC body and push their DATA through a
|
|
19
|
+
* tool description, because `inject` cannot render. That workaround only works
|
|
20
|
+
* for content the framework can attach to a tool it owns, which is exactly
|
|
21
|
+
* what a consumer reported: they had to ride the count on their own tool
|
|
22
|
+
* results.
|
|
23
|
+
*
|
|
24
|
+
* The obvious fix — let `inject` be `(ctx) => InjectionContent` — fails on
|
|
25
|
+
* ABSENCE. Given a function, an author writes `${ctx.maxIterations}` and ships
|
|
26
|
+
* *"23 of undefined"*, or writes `?? 0` and ships a fabricated denominator the
|
|
27
|
+
* library cannot tell from a real zero. With named slots the LIBRARY owns
|
|
28
|
+
* absence and applies one rule: if any fact a template names is unavailable,
|
|
29
|
+
* the whole instruction is skipped, by name, on the record. Never a fake zero,
|
|
30
|
+
* never a gap, never the literal placeholder.
|
|
31
|
+
*
|
|
32
|
+
* ## The vocabulary
|
|
33
|
+
*
|
|
34
|
+
* Three words, all about the turn's action budget, because that is the fact
|
|
35
|
+
* the field report measured:
|
|
36
|
+
*
|
|
37
|
+
* `{{action}}` the action about to be taken (1-based)
|
|
38
|
+
* `{{actionBudget}}` how many the turn is allowed
|
|
39
|
+
* `{{actionsRemaining}}` how many are left, never negative
|
|
40
|
+
*
|
|
41
|
+
* It is closed on purpose. A name this file does not know is refused at define
|
|
42
|
+
* time, when a person is looking at the error — not at iteration 23 of a paid
|
|
43
|
+
* run.
|
|
44
|
+
*/
|
|
45
|
+
import { iterationsRemainingOf } from '../iterationBudget.js';
|
|
46
|
+
/** Every fact a `promptTemplate` may name. Closed. */
|
|
47
|
+
export const TEMPLATE_FACTS = ['action', 'actionBudget', 'actionsRemaining'];
|
|
48
|
+
/**
|
|
49
|
+
* What a placeholder looks like. Whitespace inside the braces is tolerated so
|
|
50
|
+
* `{{ action }}` and `{{action}}` are the same thing; anything else is not a
|
|
51
|
+
* placeholder at all and is left exactly as written.
|
|
52
|
+
*/
|
|
53
|
+
const PLACEHOLDER = /\{\{\s*([A-Za-z0-9_]+)\s*\}\}/g;
|
|
54
|
+
/** Every name the template asks for, in order of appearance, deduplicated. */
|
|
55
|
+
export function placeholdersIn(template) {
|
|
56
|
+
const names = [];
|
|
57
|
+
for (const match of template.matchAll(PLACEHOLDER)) {
|
|
58
|
+
const name = match[1];
|
|
59
|
+
if (!names.includes(name))
|
|
60
|
+
names.push(name);
|
|
61
|
+
}
|
|
62
|
+
return names;
|
|
63
|
+
}
|
|
64
|
+
/** True when this string asks for anything at all. */
|
|
65
|
+
export function isTemplate(template) {
|
|
66
|
+
return placeholdersIn(template).length > 0;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Refuse a template naming something this library cannot supply — at define
|
|
70
|
+
* time, by name, listing what it CAN supply.
|
|
71
|
+
*
|
|
72
|
+
* @param label the factory + id, so the error names the door the author used
|
|
73
|
+
*/
|
|
74
|
+
export function assertKnownFacts(template, label) {
|
|
75
|
+
const unknown = placeholdersIn(template).filter((name) => !TEMPLATE_FACTS.includes(name));
|
|
76
|
+
if (unknown.length === 0)
|
|
77
|
+
return;
|
|
78
|
+
throw new Error(`${label}: promptTemplate names ${unknown.map((u) => `{{${u}}}`).join(', ')}, which this ` +
|
|
79
|
+
`library does not supply. The vocabulary is closed and has three words: ` +
|
|
80
|
+
`${TEMPLATE_FACTS.map((f) => `{{${f}}}`).join(', ')}. It is closed so that a name ` +
|
|
81
|
+
`nobody can fill is refused here, where you are looking, rather than rendering as a ` +
|
|
82
|
+
`literal in front of the model on iteration 23 of a paid run.`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The facts a template names that this context cannot supply.
|
|
86
|
+
*
|
|
87
|
+
* `{{action}}` is always available — every evaluation has an iteration. The
|
|
88
|
+
* other two need `ctx.maxIterations`, which an engine driven without an agent
|
|
89
|
+
* (a foreign host, a hand-built evaluation) does not have.
|
|
90
|
+
*/
|
|
91
|
+
export function missingFactsFor(template, ctx) {
|
|
92
|
+
if (ctx.maxIterations !== undefined)
|
|
93
|
+
return [];
|
|
94
|
+
return placeholdersIn(template).filter((name) => name === 'actionBudget' || name === 'actionsRemaining');
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Render, or `undefined` when any named fact is unavailable.
|
|
98
|
+
*
|
|
99
|
+
* ALL-OR-NOTHING by design: a template that says "action 25 of {{gap}}" is
|
|
100
|
+
* worse than no instruction at all, and a template that quietly renders
|
|
101
|
+
* "action 25 of 0" is worse again — the library cannot tell a fabricated zero
|
|
102
|
+
* from a real one, and neither can the model.
|
|
103
|
+
*/
|
|
104
|
+
export function renderTemplate(template, ctx) {
|
|
105
|
+
if (missingFactsFor(template, ctx).length > 0)
|
|
106
|
+
return undefined;
|
|
107
|
+
const max = ctx.maxIterations;
|
|
108
|
+
return template.replace(PLACEHOLDER, (whole, name) => {
|
|
109
|
+
switch (name) {
|
|
110
|
+
case 'action':
|
|
111
|
+
return String(ctx.iteration);
|
|
112
|
+
case 'actionBudget':
|
|
113
|
+
return max === undefined ? whole : String(max);
|
|
114
|
+
case 'actionsRemaining':
|
|
115
|
+
return max === undefined ? whole : String(iterationsRemainingOf(max, ctx.iteration));
|
|
116
|
+
default:
|
|
117
|
+
// Unreachable through the factories — `assertKnownFacts` refused it at
|
|
118
|
+
// define time. Left as written rather than blanked, so a template that
|
|
119
|
+
// somehow got here is diagnosable instead of silently gappy.
|
|
120
|
+
return whole;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=promptTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promptTemplate.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/promptTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,sDAAsD;AACtD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,kBAAkB,CAAU,CAAC;AAItF;;;;GAIG;AACH,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAErD,8EAA8E;AAC9E,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GA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AI,EAAE,CAAC;YACb,KAAK,QAAQ;gBACX,OAAO,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC/B,KAAK,cAAc;gBACjB,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjD,KAAK,kBAAkB;gBACrB,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;YACvF;gBACE,uEAAuE;gBACvE,uEAAuE;gBACvE,6DAA6D;gBAC7D,OAAO,KAAK,CAAC;QACjB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -107,6 +107,28 @@ export interface InjectionContent {
|
|
|
107
107
|
export interface InjectionContext {
|
|
108
108
|
/** Current ReAct iteration (1-based). */
|
|
109
109
|
readonly iteration: number;
|
|
110
|
+
/**
|
|
111
|
+
* The turn's ACTION BUDGET — the agent's `maxIterations` (9.57.0).
|
|
112
|
+
*
|
|
113
|
+
* Absent only when the engine was driven without one (a hand-built
|
|
114
|
+
* evaluation, a foreign host). Every agent-mounted evaluation carries it.
|
|
115
|
+
*
|
|
116
|
+
* It arrives PAIRED with {@link iterationsRemaining}: both are present or
|
|
117
|
+
* neither is. A count without a denominator is the exact fabrication this
|
|
118
|
+
* pairing exists to prevent — "you have used 23" says nothing, and "23 of
|
|
119
|
+
* undefined" says something false.
|
|
120
|
+
*/
|
|
121
|
+
readonly maxIterations?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Actions left in this turn — `maxIterations - iteration`, never negative
|
|
124
|
+
* (9.57.0). Computed by `iterationsRemainingOf`, the same one function the
|
|
125
|
+
* cache decision and the request assembly use, so the three cannot drift by
|
|
126
|
+
* one. Zero at the out-of-budget wrap-up call, which legally runs at
|
|
127
|
+
* `maxIterations + 1`.
|
|
128
|
+
*
|
|
129
|
+
* Paired with {@link maxIterations} — see there.
|
|
130
|
+
*/
|
|
131
|
+
readonly iterationsRemaining?: number;
|
|
110
132
|
/** The current user message that started this turn. */
|
|
111
133
|
readonly userMessage: string;
|
|
112
134
|
/**
|
|
@@ -318,6 +340,22 @@ export interface Injection {
|
|
|
318
340
|
readonly trigger: InjectionTrigger;
|
|
319
341
|
/** WHAT to contribute (one or more slots). */
|
|
320
342
|
readonly inject: InjectionContent;
|
|
343
|
+
/**
|
|
344
|
+
* `true` when `inject.systemPrompt` is a TEMPLATE — it names run-time facts
|
|
345
|
+
* from the closed vocabulary in `promptTemplate.ts` and must be rendered
|
|
346
|
+
* before it reaches anything (9.57.0).
|
|
347
|
+
*
|
|
348
|
+
* Top-level rather than a `metadata` key on purpose. At least one live path
|
|
349
|
+
* rebuilds `metadata` wholesale (`toolsFromActiveSkill`), and a marker lost
|
|
350
|
+
* there means the literal `{{actionsRemaining}}` reaches the model — the
|
|
351
|
+
* exact class of failure this feature exists to prevent. Top-level fields
|
|
352
|
+
* survive every `{...injection}` spread in the repo.
|
|
353
|
+
*
|
|
354
|
+
* The template text stays in `inject.systemPrompt`, so the nine build-time
|
|
355
|
+
* readers that ask length/existence questions about it keep answering them
|
|
356
|
+
* unchanged.
|
|
357
|
+
*/
|
|
358
|
+
readonly templated?: true;
|
|
321
359
|
/**
|
|
322
360
|
* Optional flavor-specific metadata. Engine ignores keys it doesn't
|
|
323
361
|
* recognize; flavor factories use this for opt-in fields without
|
|
@@ -345,7 +383,13 @@ export interface InjectionEvaluation {
|
|
|
345
383
|
readonly active: readonly Injection[];
|
|
346
384
|
readonly skipped: ReadonlyArray<{
|
|
347
385
|
readonly id: string;
|
|
348
|
-
|
|
386
|
+
/**
|
|
387
|
+
* `'unknown-fact'` (9.57.0): a templated instruction named a run-time fact
|
|
388
|
+
* this evaluation cannot supply, so the WHOLE instruction was skipped.
|
|
389
|
+
* All-or-nothing by design — a rendered gap, or a fabricated zero, is
|
|
390
|
+
* worse than an instruction that did not speak.
|
|
391
|
+
*/
|
|
392
|
+
readonly reason: 'predicate-threw' | 'unknown-trigger-kind' | 'unknown-fact';
|
|
349
393
|
readonly error?: string;
|
|
350
394
|
}>;
|
|
351
395
|
}
|
|
@@ -445,5 +489,18 @@ export interface ActiveInjection {
|
|
|
445
489
|
}>;
|
|
446
490
|
};
|
|
447
491
|
}
|
|
448
|
-
/**
|
|
449
|
-
|
|
492
|
+
/**
|
|
493
|
+
* Project a full Injection (with functions) into a scope-safe POJO.
|
|
494
|
+
*
|
|
495
|
+
* `ctx` (9.57.0) is THE rendering seam: it is the one moment the context and
|
|
496
|
+
* the content are both in scope, and every downstream reader — the slots, the
|
|
497
|
+
* cache decision, Deliver, the ledger, the recorders, a foreign host —
|
|
498
|
+
* continues to see the same static `ActiveInjection` it always saw. Optional,
|
|
499
|
+
* so a caller from before 9.57.0 still compiles.
|
|
500
|
+
*
|
|
501
|
+
* A TEMPLATED injection projected with no usable ctx comes back with NO
|
|
502
|
+
* `systemPrompt` at all. Absence is honest; a literal `{{actionsRemaining}}`
|
|
503
|
+
* in front of the model is not. Through the engine that path is unreachable —
|
|
504
|
+
* `evaluateInjections` has already skipped such an injection by name.
|
|
505
|
+
*/
|
|
506
|
+
export declare function projectActiveInjection(inj: Injection, ctx?: Pick<InjectionContext, 'iteration' | 'maxIterations'>): ActiveInjection;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* iteration. Slot subflows emit `agentfootprint.context.injected`
|
|
17
17
|
* for each InjectionRecord they place.
|
|
18
18
|
*/
|
|
19
|
+
import { renderTemplate } from './promptTemplate.js';
|
|
19
20
|
/**
|
|
20
21
|
* The iteration's tool-result batch, in call order — with the singular
|
|
21
22
|
* fallback applied (9.16.0). THE one reader for batch-aware evaluation:
|
|
@@ -28,14 +29,35 @@
|
|
|
28
29
|
export function toolResultsOf(ctx) {
|
|
29
30
|
return ctx.toolResults ?? (ctx.lastToolResult ? [ctx.lastToolResult] : []);
|
|
30
31
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Project a full Injection (with functions) into a scope-safe POJO.
|
|
34
|
+
*
|
|
35
|
+
* `ctx` (9.57.0) is THE rendering seam: it is the one moment the context and
|
|
36
|
+
* the content are both in scope, and every downstream reader — the slots, the
|
|
37
|
+
* cache decision, Deliver, the ledger, the recorders, a foreign host —
|
|
38
|
+
* continues to see the same static `ActiveInjection` it always saw. Optional,
|
|
39
|
+
* so a caller from before 9.57.0 still compiles.
|
|
40
|
+
*
|
|
41
|
+
* A TEMPLATED injection projected with no usable ctx comes back with NO
|
|
42
|
+
* `systemPrompt` at all. Absence is honest; a literal `{{actionsRemaining}}`
|
|
43
|
+
* in front of the model is not. Through the engine that path is unreachable —
|
|
44
|
+
* `evaluateInjections` has already skipped such an injection by name.
|
|
45
|
+
*/
|
|
46
|
+
export function projectActiveInjection(inj, ctx) {
|
|
33
47
|
// Project per-skill metadata that slot subflows need to dispatch on.
|
|
34
48
|
// `surfaceMode` drives the system-prompt-suppression decision.
|
|
35
49
|
// `autoActivate` drives runtime tool gating: it tells the tools slot that
|
|
36
50
|
// this skill's tools are not in the static registry and must be readmitted
|
|
37
51
|
// while it is active.
|
|
38
52
|
const meta = inj.metadata;
|
|
53
|
+
// Rendered HERE, once, so the projection every reader shares is already
|
|
54
|
+
// plain text. `undefined` = a template whose facts this ctx cannot supply,
|
|
55
|
+
// and then the piece is absent rather than gappy.
|
|
56
|
+
const systemPrompt = inj.templated === true && inj.inject.systemPrompt !== undefined
|
|
57
|
+
? ctx === undefined
|
|
58
|
+
? undefined
|
|
59
|
+
: renderTemplate(inj.inject.systemPrompt, ctx)
|
|
60
|
+
: inj.inject.systemPrompt;
|
|
39
61
|
const out = {
|
|
40
62
|
id: inj.id,
|
|
41
63
|
flavor: inj.flavor,
|
|
@@ -51,7 +73,7 @@ export function projectActiveInjection(inj) {
|
|
|
51
73
|
cache: meta.cache,
|
|
52
74
|
}),
|
|
53
75
|
inject: {
|
|
54
|
-
...(
|
|
76
|
+
...(systemPrompt !== undefined && systemPrompt.length > 0 && { systemPrompt }),
|
|
55
77
|
...(inj.inject.messages && { messages: inj.inject.messages.map((m) => ({ ...m })) }),
|
|
56
78
|
...(inj.inject.tools && {
|
|
57
79
|
tools: inj.inject.tools.map((t) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/injection-engine/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAwRrD;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,GAAqB;IAMjD,OAAO,GAAG,CAAC,WAAW,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC;AA+LD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CACpC,GAAc,EACd,GAA2D;IAE3D,qEAAqE;IACrE,+DAA+D;IAC/D,0EAA0E;IAC1E,2EAA2E;IAC3E,sBAAsB;IACtB,MAAM,IAAI,GAAG,GAAG,CAAC,QAEJ,CAAC;IACd,wEAAwE;IACxE,2EAA2E;IAC3E,kDAAkD;IAClD,MAAM,YAAY,GAChB,GAAG,CAAC,SAAS,KAAK,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,YAAY,KAAK,SAAS;QAC7D,CAAC,CAAC,GAAG,KAAK,SAAS;YACjB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC;QAChD,CAAC,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@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* iterationBudget — how many actions a turn has left, computed in ONE place.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: One pure function. No imports, no state, no clock.
|
|
5
|
+
* Role: Leaf. Three layers ask this question and used to answer it three
|
|
6
|
+
* times: the cache decision (`CachePolicyContext.iterationsRemaining`),
|
|
7
|
+
* the request assembly (`CacheStrategy.prepareRequest`), and — since
|
|
8
|
+
* 9.57.0 — the injection engine, which puts the number in front of
|
|
9
|
+
* the MODEL.
|
|
10
|
+
* Emits: N/A.
|
|
11
|
+
*
|
|
12
|
+
* Three copies of `Math.max(0, max - iteration)` were three chances to be off
|
|
13
|
+
* by one, and the one that matters most is the new one: a model told "5 remain"
|
|
14
|
+
* that actually has 4 will plan a step it cannot take. So there is one
|
|
15
|
+
* implementation and every caller uses it.
|
|
16
|
+
*
|
|
17
|
+
* `Math.max(0, …)` rather than a raw subtraction because `iteration` legally
|
|
18
|
+
* exceeds `maxIterations` by one: the out-of-budget wrap-up call (9.56.0) runs
|
|
19
|
+
* at `max + 1`. "0 remain" is the truth there. A negative count would be
|
|
20
|
+
* arithmetic leaking into a sentence a person reads.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Actions left in this turn — never negative.
|
|
24
|
+
*
|
|
25
|
+
* @param maxIterations the turn's action cap
|
|
26
|
+
* @param iteration the action about to be taken (1-based)
|
|
27
|
+
*/
|
|
28
|
+
export declare function iterationsRemainingOf(maxIterations: number, iteration: number): number;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* iterationBudget — how many actions a turn has left, computed in ONE place.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: One pure function. No imports, no state, no clock.
|
|
5
|
+
* Role: Leaf. Three layers ask this question and used to answer it three
|
|
6
|
+
* times: the cache decision (`CachePolicyContext.iterationsRemaining`),
|
|
7
|
+
* the request assembly (`CacheStrategy.prepareRequest`), and — since
|
|
8
|
+
* 9.57.0 — the injection engine, which puts the number in front of
|
|
9
|
+
* the MODEL.
|
|
10
|
+
* Emits: N/A.
|
|
11
|
+
*
|
|
12
|
+
* Three copies of `Math.max(0, max - iteration)` were three chances to be off
|
|
13
|
+
* by one, and the one that matters most is the new one: a model told "5 remain"
|
|
14
|
+
* that actually has 4 will plan a step it cannot take. So there is one
|
|
15
|
+
* implementation and every caller uses it.
|
|
16
|
+
*
|
|
17
|
+
* `Math.max(0, …)` rather than a raw subtraction because `iteration` legally
|
|
18
|
+
* exceeds `maxIterations` by one: the out-of-budget wrap-up call (9.56.0) runs
|
|
19
|
+
* at `max + 1`. "0 remain" is the truth there. A negative count would be
|
|
20
|
+
* arithmetic leaking into a sentence a person reads.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Actions left in this turn — never negative.
|
|
24
|
+
*
|
|
25
|
+
* @param maxIterations the turn's action cap
|
|
26
|
+
* @param iteration the action about to be taken (1-based)
|
|
27
|
+
*/
|
|
28
|
+
export function iterationsRemainingOf(maxIterations, iteration) {
|
|
29
|
+
return Math.max(0, maxIterations - iteration);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=iterationBudget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterationBudget.js","sourceRoot":"","sources":["../../../src/lib/iterationBudget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,aAAqB,EAAE,SAAiB;IAC5E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;AAEH,oEAAoE;AACpE,8DAA8D;AAC9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oC;AAEpC,uEAAuE;AACvE,uEAAuE;AACvE,oEAAoE;AACpE,sEAAsE;AACtE,8CAA8C;AAE9C,wEAAwE;AACxE,sEAAsE;AACtE,sEAAsE;AACtE,gDAO4B;AAN1B,sGAAA,SAAS,OAAA;AACT,oHAAA,uBAAuB,OAAA;AAEvB,2GAAA,cAAc,OAAA;AAKhB,yEAAyE;AACzE,0EAA0E;AAC1E,qEAAqE;AACrE,iEAAiE;AACjE,yDAOqC;AANnC,iGAAA,IAAI,OAAA;AAQN,qEAAqE;AACrE,wEAAwE;AACxE,uEAAuE;AACvE,oEAAoE;AACpE,yDAAyD;AACzD,wEAAwE;AACxE,gDAAgD;AAChD,wEAAwE;AACxE,gEAAgE;AAEhE,wEAAwE;AACxE,wEAAwE;AACxE,uDAAuD;AAEvD,mEAAmE;AACnE,oEAAoE;AACpE,sDAAsD"}
|
|
@@ -60,6 +60,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
60
60
|
exports.diffActiveBySlot = exports.routeActiveInjections = exports.buildInjectionEngineSubflow = exports.EMPTY_ACTIVE_BY_SLOT = void 0;
|
|
61
61
|
const footprintjs_1 = require("footprintjs");
|
|
62
62
|
const typedEmit_js_1 = require("../../recorders/core/typedEmit.js");
|
|
63
|
+
const iterationBudget_js_1 = require("../iterationBudget.js");
|
|
63
64
|
const evaluator_js_1 = require("./evaluator.js");
|
|
64
65
|
const types_js_1 = require("./types.js");
|
|
65
66
|
const skillGraph_js_1 = require("./skillGraph.js");
|
|
@@ -112,6 +113,13 @@ function makeEvaluateStage(injections, nextSkill, explainNextSkill, supersededEn
|
|
|
112
113
|
: undefined;
|
|
113
114
|
const baseCtx = {
|
|
114
115
|
iteration,
|
|
116
|
+
// The action budget, as ONE fact with two spellings (9.57.0). Written
|
|
117
|
+
// together so the pairing invariant — both or neither — is a property
|
|
118
|
+
// of this object literal rather than a rule somebody has to remember.
|
|
119
|
+
...(args.maxIterations !== undefined && {
|
|
120
|
+
maxIterations: args.maxIterations,
|
|
121
|
+
iterationsRemaining: (0, iterationBudget_js_1.iterationsRemainingOf)(args.maxIterations, iteration),
|
|
122
|
+
}),
|
|
115
123
|
userMessage: args.userMessage ?? '',
|
|
116
124
|
history: args.history ?? [],
|
|
117
125
|
...(args.lastToolResult && { lastToolResult: args.lastToolResult }),
|
|
@@ -259,7 +267,10 @@ function makeEvaluateStage(injections, nextSkill, explainNextSkill, supersededEn
|
|
|
259
267
|
// survive footprintjs's transactional scope buffer (which clones on
|
|
260
268
|
// write). Tool schemas are preserved + tagged by injectionId so the
|
|
261
269
|
// Agent's closure-held registry can look up the executable.
|
|
262
|
-
|
|
270
|
+
// The ctx goes in (9.57.0): this is the one moment the context and the
|
|
271
|
+
// content are both in scope, so a templated instruction is rendered here
|
|
272
|
+
// and every reader downstream sees the same plain text it always saw.
|
|
273
|
+
const activePOJOs = evaluation.active.map((inj) => (0, types_js_1.projectActiveInjection)(inj, ctx));
|
|
263
274
|
scope.$setValue('activeInjections', activePOJOs);
|
|
264
275
|
const routing = routingEntriesOf(evaluation.active);
|
|
265
276
|
// Structural copy (the events layer stays decoupled from `CursorMove`), and a
|