@davidorex/pi-jit-agents 0.14.6 → 0.26.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/dist/agent-spec.d.ts.map +1 -1
- package/dist/agent-spec.js +69 -5
- package/dist/agent-spec.js.map +1 -1
- package/dist/budget-enforcer.d.ts +43 -0
- package/dist/budget-enforcer.d.ts.map +1 -0
- package/dist/budget-enforcer.js +172 -0
- package/dist/budget-enforcer.js.map +1 -0
- package/dist/compile.d.ts +39 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +357 -24
- package/dist/compile.js.map +1 -1
- package/dist/dispatch-inline.d.ts +25 -0
- package/dist/dispatch-inline.d.ts.map +1 -0
- package/dist/dispatch-inline.js +41 -0
- package/dist/dispatch-inline.js.map +1 -0
- package/dist/field-path.d.ts +32 -0
- package/dist/field-path.d.ts.map +1 -0
- package/dist/field-path.js +48 -0
- package/dist/field-path.js.map +1 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/jit-runtime.d.ts +3 -3
- package/dist/jit-runtime.d.ts.map +1 -1
- package/dist/jit-runtime.js +5 -5
- package/dist/jit-runtime.js.map +1 -1
- package/dist/markers.d.ts +28 -0
- package/dist/markers.d.ts.map +1 -0
- package/dist/markers.js +36 -0
- package/dist/markers.js.map +1 -0
- package/dist/renderer-registry.d.ts +44 -0
- package/dist/renderer-registry.d.ts.map +1 -0
- package/dist/renderer-registry.js +128 -0
- package/dist/renderer-registry.js.map +1 -0
- package/dist/template.d.ts.map +1 -1
- package/dist/template.js +10 -3
- package/dist/template.js.map +1 -1
- package/dist/trace-redactor.d.ts +1 -1
- package/dist/trace-redactor.js +1 -1
- package/dist/trace-writer.js +2 -2
- package/dist/types.d.ts +82 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -3
package/dist/types.d.ts
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
* Implements the jit-agents-spec.md §2 boundary contract: four public surfaces
|
|
5
5
|
* (load, compile, execute, introspect) with typed inputs and outputs.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { ItemLocation } from "@davidorex/pi-context";
|
|
8
|
+
import type { Api, AssistantMessage, Model } from "@earendil-works/pi-ai";
|
|
8
9
|
import type nunjucks from "nunjucks";
|
|
10
|
+
import type { BudgetWarning } from "./budget-enforcer.js";
|
|
11
|
+
import type { RendererRegistry } from "./renderer-registry.js";
|
|
9
12
|
/**
|
|
10
13
|
* A loaded agent specification.
|
|
11
14
|
*
|
|
@@ -39,13 +42,50 @@ export interface AgentSpec {
|
|
|
39
42
|
* against the invocation cwd.
|
|
40
43
|
*/
|
|
41
44
|
outputSchema?: string;
|
|
42
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Block-context references injected into the agent's template environment.
|
|
47
|
+
*
|
|
48
|
+
* Two element shapes are accepted:
|
|
49
|
+
*
|
|
50
|
+
* - **Bare string** (e.g. `"requirements"`): whole-block injection — the
|
|
51
|
+
* entire `.project/<name>.json` payload is read at compile time and
|
|
52
|
+
* surfaced to the template under `_<name>`. This is the established
|
|
53
|
+
* surface and remains unchanged for existing specs.
|
|
54
|
+
*
|
|
55
|
+
* - **Object** ({@link ContextBlockRef}): per-item or scoped injection —
|
|
56
|
+
* declares a specific item id and/or kind-specific focus hints to be
|
|
57
|
+
* resolved by the compile-time injector. Plan 4 (Wave 2) owns the
|
|
58
|
+
* resolution semantics; the parser only typechecks the shape here.
|
|
59
|
+
*/
|
|
60
|
+
contextBlocks?: (string | ContextBlockRef)[];
|
|
43
61
|
/**
|
|
44
62
|
* Directory the spec was loaded from. Internal use — exposed on the type
|
|
45
63
|
* for tier-aware operations but never relied on by consumers directly.
|
|
46
64
|
*/
|
|
47
65
|
readonly loadedFrom: string;
|
|
48
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Typed object form for {@link AgentSpec.contextBlocks} entries.
|
|
69
|
+
*
|
|
70
|
+
* Bare-string entries in `contextBlocks` denote whole-block injection
|
|
71
|
+
* (existing behaviour); object entries denote per-item or scoped injection
|
|
72
|
+
* — the surface Plan 4 (Wave 2) consumes to inject specific block items
|
|
73
|
+
* (e.g. one decision, one feature) rather than entire blocks.
|
|
74
|
+
*
|
|
75
|
+
* `compileAgent` does not yet honour these fields; this interface defines
|
|
76
|
+
* the parsing-time contract only. Plan 4 wires resolution through the
|
|
77
|
+
* cross-block resolver and per-item macros.
|
|
78
|
+
*/
|
|
79
|
+
export interface ContextBlockRef {
|
|
80
|
+
/** Block name, e.g. "decisions", "features". Required. */
|
|
81
|
+
name: string;
|
|
82
|
+
/** Optional ID of a specific item to inject. Plan 4 resolves via cross-block resolver. */
|
|
83
|
+
item?: string;
|
|
84
|
+
/** Optional kind-specific scope hints (e.g., { story: "STORY-001" }). Plan 4 passes through to macros. */
|
|
85
|
+
focus?: Record<string, string>;
|
|
86
|
+
/** Optional traversal depth. 0 = bare-ID refs (default), 1 = inline direct, 2+ recurse. */
|
|
87
|
+
depth?: number;
|
|
88
|
+
}
|
|
49
89
|
/**
|
|
50
90
|
* Options for loadAgent / createAgentLoader.
|
|
51
91
|
*
|
|
@@ -66,6 +106,10 @@ export interface LoadContext {
|
|
|
66
106
|
}
|
|
67
107
|
/**
|
|
68
108
|
* Options for compileAgent.
|
|
109
|
+
*
|
|
110
|
+
* Plan 4 (Wave 2) extends this with two optional fields supporting object-form
|
|
111
|
+
* `contextBlocks` resolution. Both default to internal lazy construction when
|
|
112
|
+
* absent so existing callers (string-only `contextBlocks`) require no changes.
|
|
69
113
|
*/
|
|
70
114
|
export interface CompileContext {
|
|
71
115
|
/** Nunjucks environment from createTemplateEnv — used to render template references. */
|
|
@@ -74,6 +118,22 @@ export interface CompileContext {
|
|
|
74
118
|
input: unknown;
|
|
75
119
|
/** Project root. Used for `.project/` block reads during contextBlocks injection. */
|
|
76
120
|
cwd: string;
|
|
121
|
+
/**
|
|
122
|
+
* Optional renderer registry for per-item macro resolution. When absent,
|
|
123
|
+
* object-form `contextBlocks` entries still inject the resolved item under
|
|
124
|
+
* `_<name>_item`, but the `render_recursive` Nunjucks global cannot
|
|
125
|
+
* dispatch — recursive rendering returns a `[unrendered: <kind>/<id>]`
|
|
126
|
+
* fallback marker rather than throwing.
|
|
127
|
+
*/
|
|
128
|
+
rendererRegistry?: RendererRegistry;
|
|
129
|
+
/**
|
|
130
|
+
* Optional pre-built ID index. When absent and any object-form
|
|
131
|
+
* `contextBlocks` entry needs item resolution (or the `resolve`/
|
|
132
|
+
* `render_recursive` Nunjucks globals are invoked), `compileAgent` builds
|
|
133
|
+
* one on demand via `buildIdIndex(cwd)`. Callers performing many compiles
|
|
134
|
+
* in one pass should build once and pass it in for reuse.
|
|
135
|
+
*/
|
|
136
|
+
idIndex?: Map<string, ItemLocation>;
|
|
77
137
|
}
|
|
78
138
|
/**
|
|
79
139
|
* A compiled agent ready for dispatch.
|
|
@@ -102,6 +162,24 @@ export interface CompiledAgent {
|
|
|
102
162
|
* inspection, not the rendered string.
|
|
103
163
|
*/
|
|
104
164
|
contextValues: Record<string, unknown>;
|
|
165
|
+
/**
|
|
166
|
+
* Optional list of budget-truncation warnings collected during compile.
|
|
167
|
+
*
|
|
168
|
+
* Populated by the `enforceBudget` Nunjucks global registered by
|
|
169
|
+
* `compileAgent`: every macro invocation that exceeds the field's
|
|
170
|
+
* `x-prompt-budget` annotation appends one entry naming the field path,
|
|
171
|
+
* the declared budget, the actual measured token/word counts, and whether
|
|
172
|
+
* truncation was applied. Surfaces composition-time prompt-size signals
|
|
173
|
+
* to callers without breaking existing consumers (optional field; absent
|
|
174
|
+
* when no enforceBudget call has produced a warning during this compile).
|
|
175
|
+
*
|
|
176
|
+
* Distinct from runtime errors — a warning here means the rendered prompt
|
|
177
|
+
* is fully formed but a budgeted field carried more text than its
|
|
178
|
+
* annotation declared. The truncated text appears in the rendered prompt
|
|
179
|
+
* with the `[…truncated to budget]` marker; this array preserves the
|
|
180
|
+
* full warning record for trace / inspection consumers.
|
|
181
|
+
*/
|
|
182
|
+
budgetWarnings?: BudgetWarning[];
|
|
105
183
|
}
|
|
106
184
|
/**
|
|
107
185
|
* Dispatch-time context for executeAgent.
|
|
@@ -128,7 +206,7 @@ export interface DispatchContext {
|
|
|
128
206
|
/**
|
|
129
207
|
* Optional path to a project-extension trace redaction config
|
|
130
208
|
* (`.workflows/monitors/<name>/trace-config.json` shape). When set,
|
|
131
|
-
* `
|
|
209
|
+
* `loadContextRedactionConfig` is invoked once per executeAgent call and
|
|
132
210
|
* the resulting custom patterns are layered atop `BUILTIN_PATTERNS` for
|
|
133
211
|
* every redacted field. When unset / null, only the builtin pattern set
|
|
134
212
|
* applies. Independent of `tracePath` — config loading is a no-op when
|
|
@@ -178,7 +256,7 @@ export interface AgentContract {
|
|
|
178
256
|
name: string;
|
|
179
257
|
role?: string;
|
|
180
258
|
inputSchema?: Record<string, unknown>;
|
|
181
|
-
contextBlocks?: string[];
|
|
259
|
+
contextBlocks?: (string | ContextBlockRef)[];
|
|
182
260
|
outputFormat?: "json" | "text";
|
|
183
261
|
outputSchema?: string;
|
|
184
262
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,E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;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;;;;OAQG;IACH,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,qFAAqF;IACrF,MAAM,EAAE,OAAO,CAAC;IAChB,sDAAsD;IACtD,GAAG,EAAE,gBAAgB,CAAC;IACtB,0CAA0C;IAC1C,KAAK,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;KACb,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,aAAa,CAAC,EAAE,CAAC,MAAM,GAAG,eAAe,CAAC,EAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@davidorex/pi-jit-agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Agent spec compilation and in-process dispatch runtime — the package that owns everything between 'I have a spec' and 'I have a typed result'",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "David Ryan",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"test": "tsx --test src/*.test.ts"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@davidorex/pi-
|
|
62
|
-
"@
|
|
61
|
+
"@davidorex/pi-context": "^0.26.0",
|
|
62
|
+
"@earendil-works/pi-ai": "^0.75.4",
|
|
63
63
|
"nunjucks": "^3.2.4",
|
|
64
64
|
"proper-lockfile": "^4.1.2",
|
|
65
65
|
"yaml": "^2.7.1"
|
|
@@ -67,5 +67,8 @@
|
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/nunjucks": "^3.2.6",
|
|
69
69
|
"@types/proper-lockfile": "^4.1.4"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=22.19.0"
|
|
70
73
|
}
|
|
71
74
|
}
|