@introspection-ai/recipes 0.57.0 → 0.59.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/agents.d.ts +6 -0
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js.map +1 -1
- package/dist/batch/files.d.ts +5 -0
- package/dist/batch/files.d.ts.map +1 -1
- package/dist/batch/files.js +39 -0
- package/dist/batch/files.js.map +1 -1
- package/dist/batch/index.d.ts +33 -7
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +59 -27
- package/dist/batch/index.js.map +1 -1
- package/dist/batch/lines.d.ts +51 -9
- package/dist/batch/lines.d.ts.map +1 -1
- package/dist/batch/lines.js +86 -30
- package/dist/batch/lines.js.map +1 -1
- package/dist/batch/runner.d.ts +44 -5
- package/dist/batch/runner.d.ts.map +1 -1
- package/dist/batch/runner.js +433 -52
- package/dist/batch/runner.js.map +1 -1
- package/dist/compaction.d.ts +11 -0
- package/dist/compaction.d.ts.map +1 -0
- package/dist/compaction.js +27 -0
- package/dist/compaction.js.map +1 -0
- package/dist/issues/arguments.d.ts +51 -1
- package/dist/issues/arguments.d.ts.map +1 -1
- package/dist/issues/arguments.generated.d.ts.map +1 -1
- package/dist/issues/arguments.generated.js +97 -0
- package/dist/issues/arguments.generated.js.map +1 -1
- package/dist/issues/module.d.ts.map +1 -1
- package/dist/issues/module.js +8 -1
- package/dist/issues/module.js.map +1 -1
- package/dist/issues/tool.d.ts.map +1 -1
- package/dist/issues/tool.js +127 -4
- package/dist/issues/tool.js.map +1 -1
- package/dist/issues/types.d.ts +40 -1
- package/dist/issues/types.d.ts.map +1 -1
- package/dist/issues/types.js +8 -1
- package/dist/issues/types.js.map +1 -1
- package/dist/judges/classifier.d.ts +16 -0
- package/dist/judges/classifier.d.ts.map +1 -0
- package/dist/judges/classifier.js +47 -0
- package/dist/judges/classifier.js.map +1 -0
- package/dist/judges/cli-main.d.ts +41 -0
- package/dist/judges/cli-main.d.ts.map +1 -0
- package/dist/judges/cli-main.js +184 -0
- package/dist/judges/cli-main.js.map +1 -0
- package/dist/judges/cli.d.ts +2 -0
- package/dist/judges/cli.d.ts.map +1 -0
- package/dist/judges/cli.js +43 -0
- package/dist/judges/cli.js.map +1 -0
- package/dist/judges/controller.d.ts +78 -0
- package/dist/judges/controller.d.ts.map +1 -0
- package/dist/judges/controller.js +243 -0
- package/dist/judges/controller.js.map +1 -0
- package/dist/judges/definition.d.ts +93 -0
- package/dist/judges/definition.d.ts.map +1 -0
- package/dist/judges/definition.js +105 -0
- package/dist/judges/definition.js.map +1 -0
- package/dist/judges/gate.d.ts +46 -0
- package/dist/judges/gate.d.ts.map +1 -0
- package/dist/judges/gate.js +256 -0
- package/dist/judges/gate.js.map +1 -0
- package/dist/judges/identity.d.ts +21 -0
- package/dist/judges/identity.d.ts.map +1 -0
- package/dist/judges/identity.js +48 -0
- package/dist/judges/identity.js.map +1 -0
- package/dist/judges/index.d.ts +10 -0
- package/dist/judges/index.d.ts.map +1 -0
- package/dist/judges/index.js +10 -0
- package/dist/judges/index.js.map +1 -0
- package/dist/judges/resolve-hooks.d.ts +10 -0
- package/dist/judges/resolve-hooks.d.ts.map +1 -0
- package/dist/judges/resolve-hooks.js +25 -0
- package/dist/judges/resolve-hooks.js.map +1 -0
- package/dist/judges/run.d.ts +130 -0
- package/dist/judges/run.d.ts.map +1 -0
- package/dist/judges/run.js +356 -0
- package/dist/judges/run.js.map +1 -0
- package/dist/judges/session.d.ts +9 -0
- package/dist/judges/session.d.ts.map +1 -0
- package/dist/judges/session.js +109 -0
- package/dist/judges/session.js.map +1 -0
- package/dist/judges/trajectory.d.ts +82 -0
- package/dist/judges/trajectory.d.ts.map +1 -0
- package/dist/judges/trajectory.js +170 -0
- package/dist/judges/trajectory.js.map +1 -0
- package/dist/judges/verdict.d.ts +31 -0
- package/dist/judges/verdict.d.ts.map +1 -0
- package/dist/judges/verdict.js +121 -0
- package/dist/judges/verdict.js.map +1 -0
- package/dist/model-binding.d.ts +12 -0
- package/dist/model-binding.d.ts.map +1 -1
- package/dist/model-binding.js +38 -6
- package/dist/model-binding.js.map +1 -1
- package/dist/prompts/budget.d.ts +28 -0
- package/dist/prompts/budget.d.ts.map +1 -0
- package/dist/prompts/budget.js +31 -0
- package/dist/prompts/budget.js.map +1 -0
- package/dist/prompts/builder.d.ts +32 -0
- package/dist/prompts/builder.d.ts.map +1 -0
- package/dist/prompts/builder.js +22 -0
- package/dist/prompts/builder.js.map +1 -0
- package/dist/prompts/builders/conversation-synthesis.d.ts +106 -0
- package/dist/prompts/builders/conversation-synthesis.d.ts.map +1 -0
- package/dist/prompts/builders/conversation-synthesis.js +495 -0
- package/dist/prompts/builders/conversation-synthesis.js.map +1 -0
- package/dist/prompts/builders/trajectory.d.ts +14 -0
- package/dist/prompts/builders/trajectory.d.ts.map +1 -0
- package/dist/prompts/builders/trajectory.js +66 -0
- package/dist/prompts/builders/trajectory.js.map +1 -0
- package/dist/prompts/fit.d.ts +7 -0
- package/dist/prompts/fit.d.ts.map +1 -0
- package/dist/prompts/fit.js +15 -0
- package/dist/prompts/fit.js.map +1 -0
- package/dist/prompts/index.d.ts +8 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +8 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/registry.d.ts +8 -0
- package/dist/prompts/registry.d.ts.map +1 -0
- package/dist/prompts/registry.js +15 -0
- package/dist/prompts/registry.js.map +1 -0
- package/dist/prompts/spec.d.ts +16 -0
- package/dist/prompts/spec.d.ts.map +1 -0
- package/dist/prompts/spec.js +12 -0
- package/dist/prompts/spec.js.map +1 -0
- package/dist/prompts/template.d.ts +12 -0
- package/dist/prompts/template.d.ts.map +1 -0
- package/dist/prompts/template.js +31 -0
- package/dist/prompts/template.js.map +1 -0
- package/dist/prompts/text.d.ts +5 -0
- package/dist/prompts/text.d.ts.map +1 -0
- package/dist/prompts/text.js +13 -0
- package/dist/prompts/text.js.map +1 -0
- package/dist/recipe/agent.d.ts +11 -1
- package/dist/recipe/agent.d.ts.map +1 -1
- package/dist/recipe/agent.js +76 -1
- package/dist/recipe/agent.js.map +1 -1
- package/dist/recipe/manifest.generated.d.ts +1 -1
- package/dist/recipe/manifest.generated.js +1 -1
- package/dist/recipe/model.d.ts +5 -12
- package/dist/recipe/model.d.ts.map +1 -1
- package/dist/recipe/model.js +197 -263
- package/dist/recipe/model.js.map +1 -1
- package/dist/recipe/session.d.ts +5 -0
- package/dist/recipe/session.d.ts.map +1 -1
- package/dist/recipe/session.js +82 -4
- package/dist/recipe/session.js.map +1 -1
- package/dist/run-controller.d.ts.map +1 -1
- package/dist/run-controller.js +4 -0
- package/dist/run-controller.js.map +1 -1
- package/dist/session.d.ts +6 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +6 -2
- package/dist/session.js.map +1 -1
- package/docs/README.md +1 -0
- package/docs/agent-composition.md +3 -2
- package/docs/issues/README.md +34 -12
- package/docs/judges.md +269 -0
- package/docs/providers.md +12 -3
- package/docs/recipe-format.md +80 -12
- package/docs/recipe-judges.md +149 -61
- package/package.json +14 -6
- package/skills/issues/SKILL.md +28 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trajectory.d.ts","sourceRoot":"","sources":["../../../src/prompts/builders/trajectory.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAIvB,wFAAwF;AACxF,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAwC/C,wFAAwF;AACxF,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,UAAU,CAOxD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,UAAU,CAoB3D,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { canonical, validateJudgeInput, } from "../../judges/trajectory.js";
|
|
2
|
+
import { numberOption, withinBudget, } from "../builder.js";
|
|
3
|
+
import { renderTemplate } from "../template.js";
|
|
4
|
+
import { prefix, suffix } from "../text.js";
|
|
5
|
+
/** What a classifier judge reads at most: Jev's slim was measured at 75k characters. */
|
|
6
|
+
export const CLASSIFIER_BUDGET_TOKENS = 25_000;
|
|
7
|
+
const TRAJECTORY_TEMPLATE = "TRAJECTORY\n{{ transcript }}\n\nSYSTEM INSTRUCTIONS\n{{ system_instructions }}";
|
|
8
|
+
/** A result with one of these is kept whole by Jev's slim. */
|
|
9
|
+
const ERROR_SIGNAL = /error|failed|exception|invalid|denied|not found|timed out/i;
|
|
10
|
+
function render(input, trajectory) {
|
|
11
|
+
return renderTemplate(TRAJECTORY_TEMPLATE, {
|
|
12
|
+
transcript: JSON.stringify(canonical(trajectory), null, 2),
|
|
13
|
+
system_instructions: input.system_instructions?.trim()
|
|
14
|
+
? input.system_instructions
|
|
15
|
+
: "",
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Jev's slim of one tool result, as the slimming study measured it: kept
|
|
20
|
+
* whole when it is short or carries an error signal, else its first `head`
|
|
21
|
+
* and last `tail` units around a marker.
|
|
22
|
+
*/
|
|
23
|
+
function slimResult(value, keepUnder, head, tail) {
|
|
24
|
+
const text = typeof value === "string" ? value : JSON.stringify(value);
|
|
25
|
+
if (text === undefined ||
|
|
26
|
+
text.length <= keepUnder ||
|
|
27
|
+
ERROR_SIGNAL.test(text)) {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
return `${prefix(text, head)} […] ${suffix(text, tail)}`;
|
|
31
|
+
}
|
|
32
|
+
/** An LLM judge reads the whole trajectory and the system instructions it ran under. */
|
|
33
|
+
export const trajectoryLlmJudge = {
|
|
34
|
+
name: "trajectory_llm_judge",
|
|
35
|
+
version: 1,
|
|
36
|
+
build(input, maxTokens) {
|
|
37
|
+
validateJudgeInput(input);
|
|
38
|
+
return withinBudget(render(input, input.trajectory), maxTokens);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A classifier judge reads Jev's slim, the one measured for a yes/no gate: a
|
|
43
|
+
* long tool result keeps its head and tail unless it carries an error
|
|
44
|
+
* signal, so a small budget goes on the conversation without hiding a
|
|
45
|
+
* failure. Options: `keep_under` (400), `head` (150), `tail` (150).
|
|
46
|
+
*/
|
|
47
|
+
export const trajectoryLlmClassify = {
|
|
48
|
+
name: "trajectory_llm_classify",
|
|
49
|
+
version: 1,
|
|
50
|
+
build(input, maxTokens, options) {
|
|
51
|
+
validateJudgeInput(input);
|
|
52
|
+
const keepUnder = numberOption(options, "keep_under", 400);
|
|
53
|
+
const head = numberOption(options, "head", 150);
|
|
54
|
+
const tail = numberOption(options, "tail", 150);
|
|
55
|
+
const trajectory = input.trajectory.map((event) => event.type === "tool_result" && event.content !== undefined
|
|
56
|
+
? {
|
|
57
|
+
...event,
|
|
58
|
+
content: slimResult(event.content, keepUnder, head, tail),
|
|
59
|
+
}
|
|
60
|
+
: event);
|
|
61
|
+
return withinBudget(render(input, trajectory), maxTokens, [
|
|
62
|
+
"slim_tool_results",
|
|
63
|
+
]);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=trajectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trajectory.js","sourceRoot":"","sources":["../../../src/prompts/builders/trajectory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,YAAY,GAGb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAE5C,wFAAwF;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAE/C,MAAM,mBA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C,MAAM,qBAAqB,GAA8B;IAC9D,IAAI,EAAE,yBAAyB;IAC/B,OAAO,EAAE,CAAC;IACV,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,OAAwB;QAC9C,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1B,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC;QAC3D,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAChD,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAChD,KAAK,CAAC,IAAI,KAAK,aAAa,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;YACzD,CAAC,CAAC;gBACE,GAAG,KAAK;gBACR,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC;aAC1D;YACH,CAAC,CAAC,KAAK,CACV,CAAC;QACF,OAAO,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE;YACxD,mBAAmB;SACpB,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** A builder that does not exist, or an input or options it cannot build from. */
|
|
2
|
+
export declare class PromptError extends Error {
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
/** Keep the head and tail of `text`, cutting its middle to fit `maxChars`. */
|
|
6
|
+
export declare function middleCut(text: string, maxChars: number): string;
|
|
7
|
+
//# sourceMappingURL=fit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fit.d.ts","sourceRoot":"","sources":["../../src/prompts/fit.ts"],"names":[],"mappings":"AAEA,kFAAkF;AAClF,qBAAa,WAAY,SAAQ,KAAK;IAC3B,IAAI,SAAiB;CAC/B;AAKD,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKhE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { prefix, suffix } from "./text.js";
|
|
2
|
+
/** A builder that does not exist, or an input or options it cannot build from. */
|
|
3
|
+
export class PromptError extends Error {
|
|
4
|
+
name = "PromptError";
|
|
5
|
+
}
|
|
6
|
+
const MIDDLE_CUT_MARKER = "\n… transcript middle redacted to fit the judge's budget …\n";
|
|
7
|
+
/** Keep the head and tail of `text`, cutting its middle to fit `maxChars`. */
|
|
8
|
+
export function middleCut(text, maxChars) {
|
|
9
|
+
if (text.length <= maxChars)
|
|
10
|
+
return text;
|
|
11
|
+
const available = Math.max(0, maxChars - MIDDLE_CUT_MARKER.length);
|
|
12
|
+
const head = Math.floor(available / 2);
|
|
13
|
+
return `${prefix(text, head)}${MIDDLE_CUT_MARKER}${suffix(text, available - head)}`;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=fit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fit.js","sourceRoot":"","sources":["../../src/prompts/fit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE3C,kFAAkF;AAClF,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,GAAG,aAAa,CAAC;CAC/B;AAED,MAAM,iBAAiB,GACrB,8DAA8D,CAAC;AAEjE,8EAA8E;AAC9E,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,QAAgB;IACtD,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IACzC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACnE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IACvC,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,iBAAiB,GAAG,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { builderId, numberOption, withinBudget, type BuilderOptions, type BuiltPrompt, type PromptBuilder, } from "./builder.js";
|
|
2
|
+
export { middleCut, PromptError } from "./fit.js";
|
|
3
|
+
export { CLASSIFIER_BUDGET_TOKENS, trajectoryLlmClassify, trajectoryLlmJudge, } from "./builders/trajectory.js";
|
|
4
|
+
export { conversationSynthesis, type ConversationMessage, type ConversationModelCall, type ConversationPart, type ConversationSynthesisInput, type ConversationSynthesisState, type PriorObservation, type ResumeState, type SegmentPlan, type SegmentSkip, } from "./builders/conversation-synthesis.js";
|
|
5
|
+
export { MAX_PROMPT_TOKENS, modelBudgetTokens, OUTPUT_RESERVE_TOKENS, promptBudget, CHARS_PER_TOKEN, } from "./budget.js";
|
|
6
|
+
export { PROMPT_BUILDERS, promptBuilder } from "./registry.js";
|
|
7
|
+
export { parsePreprocess, type PreprocessSpec } from "./spec.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,YAAY,EACZ,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { builderId, numberOption, withinBudget, } from "./builder.js";
|
|
2
|
+
export { middleCut, PromptError } from "./fit.js";
|
|
3
|
+
export { CLASSIFIER_BUDGET_TOKENS, trajectoryLlmClassify, trajectoryLlmJudge, } from "./builders/trajectory.js";
|
|
4
|
+
export { conversationSynthesis, } from "./builders/conversation-synthesis.js";
|
|
5
|
+
export { MAX_PROMPT_TOKENS, modelBudgetTokens, OUTPUT_RESERVE_TOKENS, promptBudget, CHARS_PER_TOKEN, } from "./budget.js";
|
|
6
|
+
export { PROMPT_BUILDERS, promptBuilder } from "./registry.js";
|
|
7
|
+
export { parsePreprocess } from "./spec.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,YAAY,GAIb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,GAUtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,YAAY,EACZ,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAuB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PromptBuilder } from "./builder.js";
|
|
2
|
+
type AnyBuilder = PromptBuilder<any, any>;
|
|
3
|
+
/** Every builder a recipe or a batch can name, as `name@version`. */
|
|
4
|
+
export declare const PROMPT_BUILDERS: ReadonlyMap<string, AnyBuilder>;
|
|
5
|
+
/** The builder a recipe names, such as `conversation_synthesis@1`. */
|
|
6
|
+
export declare function promptBuilder(id: string): AnyBuilder;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/prompts/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAS7D,KAAK,UAAU,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAE1C,qEAAqE;AACrE,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAI3D,CAAC;AAEF,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAQpD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { builderId } from "./builder.js";
|
|
2
|
+
import { conversationSynthesis } from "./builders/conversation-synthesis.js";
|
|
3
|
+
import { trajectoryLlmClassify, trajectoryLlmJudge, } from "./builders/trajectory.js";
|
|
4
|
+
import { PromptError } from "./fit.js";
|
|
5
|
+
/** Every builder a recipe or a batch can name, as `name@version`. */
|
|
6
|
+
export const PROMPT_BUILDERS = new Map([trajectoryLlmJudge, trajectoryLlmClassify, conversationSynthesis].map((builder) => [builderId(builder), builder]));
|
|
7
|
+
/** The builder a recipe names, such as `conversation_synthesis@1`. */
|
|
8
|
+
export function promptBuilder(id) {
|
|
9
|
+
const builder = PROMPT_BUILDERS.get(id);
|
|
10
|
+
if (builder === undefined) {
|
|
11
|
+
throw new PromptError(`no prompt builder "${id}"; known: ${[...PROMPT_BUILDERS.keys()].join(", ")}`);
|
|
12
|
+
}
|
|
13
|
+
return builder;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/prompts/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,qEAAqE;AACrE,MAAM,CAAC,MAAM,eAAe,GAAoC,IAAI,GAAG,CACrE,CAAC,kBAAkB,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,GAAG,CACpE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,OAAqB,CAAC,CACzD,CACF,CAAC;AAEF,sEAAsE;AACtE,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,WAAW,CACnB,sBAAsB,EAAE,aAAa,CAAC,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC9E,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BuilderOptions } from "./builder.js";
|
|
2
|
+
/**
|
|
3
|
+
* An agent's or a judge's `preprocess:`: the builder that turns a raw input into
|
|
4
|
+
* its prompt, by `name@version`, alone or with whatever options it reads.
|
|
5
|
+
* The budget comes from the same file's `ai:` models.
|
|
6
|
+
*/
|
|
7
|
+
export type PreprocessSpec = string | {
|
|
8
|
+
builder: string;
|
|
9
|
+
options?: BuilderOptions;
|
|
10
|
+
};
|
|
11
|
+
/** The builder and options a `preprocess:` names; the builder must exist in this release. */
|
|
12
|
+
export declare function parsePreprocess(spec: PreprocessSpec): {
|
|
13
|
+
builder: string;
|
|
14
|
+
options?: BuilderOptions;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../src/prompts/spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAInD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GACxB,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC;AAEzD,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B,CASA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PromptError } from "./fit.js";
|
|
2
|
+
import { promptBuilder } from "./registry.js";
|
|
3
|
+
/** The builder and options a `preprocess:` names; the builder must exist in this release. */
|
|
4
|
+
export function parsePreprocess(spec) {
|
|
5
|
+
const parsed = typeof spec === "string" ? { builder: spec } : spec;
|
|
6
|
+
if (typeof parsed?.builder !== "string") {
|
|
7
|
+
throw new PromptError("preprocess must name a builder, such as conversation_synthesis@1");
|
|
8
|
+
}
|
|
9
|
+
promptBuilder(parsed.builder);
|
|
10
|
+
return parsed;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/prompts/spec.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAU9C,6FAA6F;AAC7F,MAAM,UAAU,eAAe,CAAC,IAAoB;IAIlD,MAAM,MAAM,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnE,IAAI,OAAO,MAAM,EAAE,OAAO,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,WAAW,CACnB,kEAAkE,CACnE,CAAC;IACJ,CAAC;IACD,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class TemplateError extends Error {
|
|
2
|
+
name: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Fill a template's `{{ name }}` placeholders from `slots`. Nothing else is
|
|
6
|
+
* syntax: no loops, conditionals or filters. A placeholder with no slot is an
|
|
7
|
+
* error. A block (text between blank lines) whose placeholders all render
|
|
8
|
+
* empty is dropped, so a section and its heading disappear together without a
|
|
9
|
+
* conditional. Slot text is inserted as given: escaping is the builder's.
|
|
10
|
+
*/
|
|
11
|
+
export declare function renderTemplate(template: string, slots: Readonly<Record<string, string>>): string;
|
|
12
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/prompts/template.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAc,SAAQ,KAAK;IAC7B,IAAI,SAAmB;CACjC;AAOD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACtC,MAAM,CAkBR"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const PLACEHOLDER = /\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;
|
|
2
|
+
export class TemplateError extends Error {
|
|
3
|
+
name = "TemplateError";
|
|
4
|
+
}
|
|
5
|
+
/** The placeholders a template names, in order of first use. */
|
|
6
|
+
function templatePlaceholders(template) {
|
|
7
|
+
return [...new Set([...template.matchAll(PLACEHOLDER)].map((m) => m[1]))];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Fill a template's `{{ name }}` placeholders from `slots`. Nothing else is
|
|
11
|
+
* syntax: no loops, conditionals or filters. A placeholder with no slot is an
|
|
12
|
+
* error. A block (text between blank lines) whose placeholders all render
|
|
13
|
+
* empty is dropped, so a section and its heading disappear together without a
|
|
14
|
+
* conditional. Slot text is inserted as given: escaping is the builder's.
|
|
15
|
+
*/
|
|
16
|
+
export function renderTemplate(template, slots) {
|
|
17
|
+
for (const name of templatePlaceholders(template)) {
|
|
18
|
+
if (!(name in slots)) {
|
|
19
|
+
throw new TemplateError(`template names {{ ${name} }}, which no slot fills`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const blocks = template.split(/\n\n/);
|
|
23
|
+
return blocks
|
|
24
|
+
.filter((block) => {
|
|
25
|
+
const names = templatePlaceholders(block);
|
|
26
|
+
return names.length === 0 || names.some((name) => slots[name] !== "");
|
|
27
|
+
})
|
|
28
|
+
.map((block) => block.replace(PLACEHOLDER, (_, name) => slots[name]))
|
|
29
|
+
.join("\n\n");
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/prompts/template.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,yCAAyC,CAAC;AAE9D,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,GAAG,eAAe,CAAC;CACjC;AAED,gEAAgE;AAChE,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAgB,EAChB,KAAuC;IAEvC,KAAK,MAAM,IAAI,IAAI,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClD,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,aAAa,CACrB,qBAAqB,IAAI,0BAA0B,CACpD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO,MAAM;SACV,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,MAAM,KAAK,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC1C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACb,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC,CAC9D;SACA,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The first `units` UTF-16 units of `value`, never splitting a surrogate pair. */
|
|
2
|
+
export declare function prefix(value: string, units: number): string;
|
|
3
|
+
/** The last `units` UTF-16 units of `value`, never splitting a surrogate pair. */
|
|
4
|
+
export declare function suffix(value: string, units: number): string;
|
|
5
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/prompts/text.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAM3D;AAED,kFAAkF;AAClF,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK3D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The first `units` UTF-16 units of `value`, never splitting a surrogate pair. */
|
|
2
|
+
export function prefix(value, units) {
|
|
3
|
+
const end = units > 0 && /[\uD800-\uDBFF]/.test(value[units - 1] ?? "")
|
|
4
|
+
? units - 1
|
|
5
|
+
: units;
|
|
6
|
+
return value.slice(0, end);
|
|
7
|
+
}
|
|
8
|
+
/** The last `units` UTF-16 units of `value`, never splitting a surrogate pair. */
|
|
9
|
+
export function suffix(value, units) {
|
|
10
|
+
const start = value.length - units;
|
|
11
|
+
return value.slice(/[\uDC00-\uDFFF]/.test(value[start] ?? "") ? start + 1 : start);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/prompts/text.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,KAAa;IACjD,MAAM,GAAG,GACP,KAAK,GAAG,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACzD,CAAC,CAAC,KAAK,GAAG,CAAC;QACX,CAAC,CAAC,KAAK,CAAC;IACZ,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,KAAa;IACjD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;IACnC,OAAO,KAAK,CAAC,KAAK,CAChB,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAC/D,CAAC;AACJ,CAAC"}
|
package/dist/recipe/agent.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type RecipeAgentModelConfig } from "./model.js";
|
|
2
2
|
import { type RecipeAgentSessionConfig } from "./session.js";
|
|
3
3
|
import { type PiPackageManifest, type RecipeMcpToolSelection } from "./package.js";
|
|
4
|
+
import { type PreprocessSpec } from "../prompts/spec.js";
|
|
4
5
|
export interface RecipeSystemInstructions {
|
|
5
6
|
mode: "append" | "replace";
|
|
6
7
|
content: string;
|
|
@@ -84,16 +85,25 @@ export interface RecipeAgentDefinition {
|
|
|
84
85
|
phases?: string[];
|
|
85
86
|
subagents: string[];
|
|
86
87
|
systemInstructions?: RecipeSystemInstructions;
|
|
88
|
+
/** The builder a batch turns a line's raw `input` into this agent's prompt with. */
|
|
89
|
+
preprocess?: PreprocessSpec;
|
|
90
|
+
/** What this agent's sandbox may use; absent, the platform's defaults apply. */
|
|
91
|
+
resources?: RecipeAgentResources;
|
|
87
92
|
/** Fields authored on this definition rather than inherited through `from`. */
|
|
88
93
|
declaredFields?: readonly RecipeAgentConfigField[];
|
|
89
94
|
}
|
|
90
|
-
export type RecipeAgentConfigField = "description" | "model" | "ai" | "session" | "tools" | "mcp" | "skills" | "phases" | "subagents" | "system_instructions";
|
|
95
|
+
export type RecipeAgentConfigField = "description" | "model" | "ai" | "session" | "tools" | "mcp" | "skills" | "phases" | "subagents" | "system_instructions" | "preprocess" | "resources";
|
|
91
96
|
export interface RecipeAgentValidationFinding {
|
|
92
97
|
agentName: string;
|
|
93
98
|
field: "name" | "from" | "file" | "mcp" | "tools" | "model.name";
|
|
94
99
|
code?: string;
|
|
95
100
|
message: string;
|
|
96
101
|
}
|
|
102
|
+
/** What an agent's sandbox may use. Today only memory; a batch sizes itself to it. */
|
|
103
|
+
interface RecipeAgentResources {
|
|
104
|
+
/** A memory quantity such as `512Mi`. */
|
|
105
|
+
memory?: string;
|
|
106
|
+
}
|
|
97
107
|
export interface ValidatedRecipeAgentDefinitions {
|
|
98
108
|
definitions: Map<string, RecipeAgentDefinition>;
|
|
99
109
|
findings: RecipeAgentValidationFinding[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/recipe/agent.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,KAAK,sBAAsB,EAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,cAAc,CAAC;AACtB,OAAO,EAOL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC5B,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/recipe/agent.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,KAAK,sBAAsB,EAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAIL,KAAK,wBAAwB,E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,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,qBAAqB,GACrB,YAAY,GACZ,WAAW,CAAC;AAWhB,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,YAAY,CAAC;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AA0BD,sFAAsF;AACtF,UAAU,oBAAoB;IAC5B,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA28BD,MAAM,WAAW,+BAA+B;IAC9C,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAChD,QAAQ,EAAE,4BAA4B,EAAE,CAAC;CAC1C;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CACjD,SAAS,EAAE,MAAM,GAChB,+BAA+B,CAoBjC;AAED,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,GAChB,4BAA4B,EAAE,CAEhC;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM5E"}
|
package/dist/recipe/agent.js
CHANGED
|
@@ -5,6 +5,7 @@ import { mergeRecipeAgentModelConfig, parseRecipeAgentAiConfig, parseRecipeAgent
|
|
|
5
5
|
import { mergeRecipeAgentSessionConfig, parseRecipeAgentSessionConfig, RecipeSessionConfigError, } from "./session.js";
|
|
6
6
|
import { assertRecipePathContained, isValidRecipeMcpToolSelection, packageResourcePaths, parseRecipeMcpToolSelection, readPiPackageManifest, RecipePackageError, } from "./package.js";
|
|
7
7
|
import { ISSUES_FALLBACK_PROVIDER } from "../issues/types.js";
|
|
8
|
+
import { parsePreprocess } from "../prompts/spec.js";
|
|
8
9
|
import { PRODUCTIVITY_TOOLS } from "../productivity/types.js";
|
|
9
10
|
import { mcpSelectionAllowsTool, normalizeMcpServerId } from "../mcp/policy.js";
|
|
10
11
|
const INVALID_AGENT_MCP = Symbol("invalidAgentMcp");
|
|
@@ -93,7 +94,11 @@ const AGENT_YAML_KEYS = new Set([
|
|
|
93
94
|
"phases",
|
|
94
95
|
"subagents",
|
|
95
96
|
"system_instructions",
|
|
97
|
+
"preprocess",
|
|
98
|
+
"resources",
|
|
96
99
|
]);
|
|
100
|
+
/** A Kubernetes memory quantity in binary or decimal units: `512Mi`, `1Gi`, `500M`. */
|
|
101
|
+
const MEMORY_QUANTITY = /^[1-9][0-9]*(Ki|Mi|Gi|K|M|G)$/;
|
|
97
102
|
const PORTABLE_AGENT_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
98
103
|
const MAX_INHERITANCE_DEPTH = 128;
|
|
99
104
|
function asRecord(value) {
|
|
@@ -116,6 +121,31 @@ function invalidAgentField(data) {
|
|
|
116
121
|
if (!Object.hasOwn(data, "name")) {
|
|
117
122
|
return "name is required";
|
|
118
123
|
}
|
|
124
|
+
if (Object.hasOwn(data, "resources")) {
|
|
125
|
+
const resources = data.resources;
|
|
126
|
+
if (!resources ||
|
|
127
|
+
typeof resources !== "object" ||
|
|
128
|
+
Array.isArray(resources)) {
|
|
129
|
+
return "resources must be a map";
|
|
130
|
+
}
|
|
131
|
+
const unknown = Object.keys(resources).filter((key) => key !== "memory");
|
|
132
|
+
if (unknown.length > 0) {
|
|
133
|
+
return `resources has unsupported key(s): ${unknown.join(", ")}`;
|
|
134
|
+
}
|
|
135
|
+
const memory = resources.memory;
|
|
136
|
+
if (memory !== undefined &&
|
|
137
|
+
(typeof memory !== "string" || !MEMORY_QUANTITY.test(memory))) {
|
|
138
|
+
return "resources.memory must be a quantity such as 512Mi or 1Gi";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (Object.hasOwn(data, "preprocess")) {
|
|
142
|
+
try {
|
|
143
|
+
parsePreprocess(data.preprocess);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
return error.message;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
119
149
|
for (const key of ["name", "from"]) {
|
|
120
150
|
if (Object.hasOwn(data, key) &&
|
|
121
151
|
(typeof data[key] !== "string" || !data[key].trim())) {
|
|
@@ -459,6 +489,7 @@ function readRecipeAgentSources(recipeDir, opts = {}) {
|
|
|
459
489
|
? parseRecipeAgentAiConfig(`Agent YAML at ${path}`, data.ai)
|
|
460
490
|
: parseRecipeAgentModelConfig(`Agent YAML at ${path}`, data.model);
|
|
461
491
|
sessionConfig = parseRecipeAgentSessionConfig(`Agent YAML at ${path}`, data.session);
|
|
492
|
+
({ modelConfig, sessionConfig } = cacheRetentionInSession(`Agent YAML at ${path}`, modelConfig, sessionConfig));
|
|
462
493
|
}
|
|
463
494
|
catch (err) {
|
|
464
495
|
if (!(err instanceof RecipeModelConfigError) &&
|
|
@@ -489,6 +520,12 @@ function readRecipeAgentSources(recipeDir, opts = {}) {
|
|
|
489
520
|
? stringArray(data.subagents)
|
|
490
521
|
: undefined,
|
|
491
522
|
systemInstructions: parseSystemInstructions(data),
|
|
523
|
+
...(Object.hasOwn(data, "resources")
|
|
524
|
+
? { resources: data.resources }
|
|
525
|
+
: {}),
|
|
526
|
+
...(Object.hasOwn(data, "preprocess")
|
|
527
|
+
? { preprocess: data.preprocess }
|
|
528
|
+
: {}),
|
|
492
529
|
declaredFields: [
|
|
493
530
|
"description",
|
|
494
531
|
"model",
|
|
@@ -500,12 +537,44 @@ function readRecipeAgentSources(recipeDir, opts = {}) {
|
|
|
500
537
|
"phases",
|
|
501
538
|
"subagents",
|
|
502
539
|
"system_instructions",
|
|
540
|
+
"preprocess",
|
|
541
|
+
"resources",
|
|
503
542
|
].filter((key) => Object.hasOwn(data, key)),
|
|
504
543
|
},
|
|
505
544
|
});
|
|
506
545
|
}
|
|
507
546
|
return sources;
|
|
508
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* Read the deprecated `ai.options.cache_retention` (or `model.cache_retention`)
|
|
550
|
+
* as `session.cache.retention`, so it inherits as `session` does.
|
|
551
|
+
*/
|
|
552
|
+
function cacheRetentionInSession(context, modelConfig, sessionConfig) {
|
|
553
|
+
const deprecated = modelConfig?.streamOptions?.cacheRetention;
|
|
554
|
+
if (deprecated === undefined)
|
|
555
|
+
return { modelConfig, sessionConfig };
|
|
556
|
+
if (sessionConfig?.cacheRetention !== undefined) {
|
|
557
|
+
throw new RecipeSessionConfigError(`${context} cannot declare both session.cache.retention and ai.options.cache_retention (or model.cache_retention)`);
|
|
558
|
+
}
|
|
559
|
+
const { cacheRetention: _moved, ...streamOptions } = modelConfig.streamOptions;
|
|
560
|
+
const { streamOptions: _old, ...rest } = modelConfig;
|
|
561
|
+
return {
|
|
562
|
+
modelConfig: {
|
|
563
|
+
...rest,
|
|
564
|
+
...(Object.keys(streamOptions).length > 0 ? { streamOptions } : {}),
|
|
565
|
+
},
|
|
566
|
+
sessionConfig: { ...sessionConfig, cacheRetention: deprecated },
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
/** Apply `session.cache.retention` as the `cacheRetention` request option. */
|
|
570
|
+
function withCacheRetention(modelConfig, cacheRetention) {
|
|
571
|
+
if (cacheRetention === undefined)
|
|
572
|
+
return modelConfig;
|
|
573
|
+
return {
|
|
574
|
+
...modelConfig,
|
|
575
|
+
streamOptions: { ...modelConfig?.streamOptions, cacheRetention },
|
|
576
|
+
};
|
|
577
|
+
}
|
|
509
578
|
function definitionsFromSources(sources) {
|
|
510
579
|
const rawDefinitions = new Map();
|
|
511
580
|
const resolvedDefinitions = new Map();
|
|
@@ -528,8 +597,8 @@ function definitionsFromSources(sources) {
|
|
|
528
597
|
: undefined;
|
|
529
598
|
if (raw.from && !base)
|
|
530
599
|
return undefined;
|
|
531
|
-
const modelConfig = mergeRecipeAgentModelConfig(base?.modelConfig, raw.modelConfig);
|
|
532
600
|
const sessionConfig = mergeRecipeAgentSessionConfig(base?.sessionConfig, raw.sessionConfig);
|
|
601
|
+
const modelConfig = withCacheRetention(mergeRecipeAgentModelConfig(base?.modelConfig, raw.modelConfig), sessionConfig?.cacheRetention);
|
|
533
602
|
const definition = {
|
|
534
603
|
name: raw.name,
|
|
535
604
|
...(raw.from ? { from: raw.from } : {}),
|
|
@@ -549,6 +618,12 @@ function definitionsFromSources(sources) {
|
|
|
549
618
|
: {}),
|
|
550
619
|
subagents: raw.subagents ?? base?.subagents ?? [],
|
|
551
620
|
systemInstructions: mergeSystemInstructions(base?.systemInstructions, raw.systemInstructions),
|
|
621
|
+
...((raw.resources ?? base?.resources)
|
|
622
|
+
? { resources: raw.resources ?? base?.resources }
|
|
623
|
+
: {}),
|
|
624
|
+
...((raw.preprocess ?? base?.preprocess)
|
|
625
|
+
? { preprocess: raw.preprocess ?? base?.preprocess }
|
|
626
|
+
: {}),
|
|
552
627
|
declaredFields: [...(raw.declaredFields ?? [])],
|
|
553
628
|
};
|
|
554
629
|
resolvedDefinitions.set(name, definition);
|