@standardagents/builder 0.12.1 → 0.12.3
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/built-in-routes.js +42 -49
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +27 -27
- package/dist/index.d.ts +17 -0
- package/dist/index.js +47 -54
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +4 -3
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -83,6 +83,17 @@ declare global {
|
|
|
83
83
|
* @deprecated Use StandardAgentSpec.Callables instead
|
|
84
84
|
*/
|
|
85
85
|
type Callables = StandardAgentSpec.Callables;
|
|
86
|
+
/**
|
|
87
|
+
* Interface for hook ID registration.
|
|
88
|
+
* @deprecated Use StandardAgentSpec.HookIdRegistry instead
|
|
89
|
+
*/
|
|
90
|
+
interface HookIdRegistry extends StandardAgentSpec.HookIdRegistry {
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Union type of all hook IDs defined in agents/hooks/.
|
|
94
|
+
* @deprecated Use StandardAgentSpec.HookIds instead
|
|
95
|
+
*/
|
|
96
|
+
type Hooks = StandardAgentSpec.HookIds;
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
99
|
|
|
@@ -1400,6 +1411,8 @@ interface PromptDefinition<N extends string = string, S extends ToolArgs = ToolA
|
|
|
1400
1411
|
reasoning?: ReasoningConfig;
|
|
1401
1412
|
/** Number of recent messages to keep actual images for. @default 10 */
|
|
1402
1413
|
recentImageThreshold?: number;
|
|
1414
|
+
/** Hook IDs to run when this prompt is active. Falls back to agent-level hooks if not set. */
|
|
1415
|
+
hooks?: AgentBuilder.Hooks[];
|
|
1403
1416
|
}
|
|
1404
1417
|
|
|
1405
1418
|
/**
|
|
@@ -1628,6 +1641,10 @@ interface PromptFileData {
|
|
|
1628
1641
|
* Will be converted to Zod code.
|
|
1629
1642
|
*/
|
|
1630
1643
|
requiredSchema?: JSONSchema;
|
|
1644
|
+
/**
|
|
1645
|
+
* Hook IDs to associate with this prompt.
|
|
1646
|
+
*/
|
|
1647
|
+
hooks?: string[];
|
|
1631
1648
|
}
|
|
1632
1649
|
/**
|
|
1633
1650
|
* Generate a TypeScript file for a prompt definition.
|
package/dist/index.js
CHANGED
|
@@ -4808,7 +4808,7 @@ var init_FlowEngine = __esm({
|
|
|
4808
4808
|
init_ToolExecutor();
|
|
4809
4809
|
init_context();
|
|
4810
4810
|
init_ThreadStateImpl();
|
|
4811
|
-
FlowEngine = class {
|
|
4811
|
+
FlowEngine = class _FlowEngine {
|
|
4812
4812
|
/**
|
|
4813
4813
|
* Main execution entry point
|
|
4814
4814
|
* Executes an agent conversation until stopped or max steps reached
|
|
@@ -4943,6 +4943,30 @@ var init_FlowEngine = __esm({
|
|
|
4943
4943
|
}
|
|
4944
4944
|
await state.stream.close();
|
|
4945
4945
|
}
|
|
4946
|
+
/**
|
|
4947
|
+
* Convert a PromptDefinition (from definePrompt) to PromptData (runtime format).
|
|
4948
|
+
*/
|
|
4949
|
+
static convertPromptDefinition(id, def) {
|
|
4950
|
+
return {
|
|
4951
|
+
id,
|
|
4952
|
+
name: def.name,
|
|
4953
|
+
tool_description: def.toolDescription,
|
|
4954
|
+
prompt: def.prompt,
|
|
4955
|
+
model: def.model,
|
|
4956
|
+
include_chat: def.includeChat ?? false,
|
|
4957
|
+
include_past_tools: def.includePastTools ?? false,
|
|
4958
|
+
parallel_tool_calls: def.parallelToolCalls ?? false,
|
|
4959
|
+
tool_choice: def.toolChoice ?? "auto",
|
|
4960
|
+
reasoning_effort: def.reasoning?.effort ?? null,
|
|
4961
|
+
reasoning_max_tokens: def.reasoning?.maxTokens ?? null,
|
|
4962
|
+
reasoning_exclude: def.reasoning?.exclude ?? false,
|
|
4963
|
+
include_reasoning: def.reasoning?.include ?? false,
|
|
4964
|
+
recentImageThreshold: def.recentImageThreshold ?? null,
|
|
4965
|
+
_tools: def.tools ?? [],
|
|
4966
|
+
_requiredSchema: def.requiredSchema ?? null,
|
|
4967
|
+
_hooks: def.hooks ?? []
|
|
4968
|
+
};
|
|
4969
|
+
}
|
|
4946
4970
|
/**
|
|
4947
4971
|
* Load prompts from TypeScript configs via virtual modules.
|
|
4948
4972
|
*
|
|
@@ -4960,23 +4984,7 @@ var init_FlowEngine = __esm({
|
|
|
4960
4984
|
if (sideAPromptDef.tools?.length) {
|
|
4961
4985
|
console.log(`[FlowEngine] Prompt tools: [${sideAPromptDef.tools.map((t) => typeof t === "string" ? t : t.name).join(", ")}]`);
|
|
4962
4986
|
}
|
|
4963
|
-
const sideAPrompt =
|
|
4964
|
-
id: sideAPromptName,
|
|
4965
|
-
name: sideAPromptDef.name,
|
|
4966
|
-
tool_description: sideAPromptDef.toolDescription,
|
|
4967
|
-
prompt: sideAPromptDef.prompt,
|
|
4968
|
-
model: sideAPromptDef.model,
|
|
4969
|
-
include_chat: sideAPromptDef.includeChat ?? false,
|
|
4970
|
-
include_past_tools: sideAPromptDef.includePastTools ?? false,
|
|
4971
|
-
parallel_tool_calls: sideAPromptDef.parallelToolCalls ?? false,
|
|
4972
|
-
tool_choice: sideAPromptDef.toolChoice ?? "auto",
|
|
4973
|
-
reasoning_effort: sideAPromptDef.reasoning?.effort ?? null,
|
|
4974
|
-
reasoning_max_tokens: sideAPromptDef.reasoning?.maxTokens ?? null,
|
|
4975
|
-
reasoning_exclude: sideAPromptDef.reasoning?.exclude ?? false,
|
|
4976
|
-
include_reasoning: sideAPromptDef.reasoning?.include ?? false,
|
|
4977
|
-
_tools: sideAPromptDef.tools ?? [],
|
|
4978
|
-
_requiredSchema: sideAPromptDef.requiredSchema ?? null
|
|
4979
|
-
};
|
|
4987
|
+
const sideAPrompt = _FlowEngine.convertPromptDefinition(sideAPromptName, sideAPromptDef);
|
|
4980
4988
|
let sideBPrompt = null;
|
|
4981
4989
|
const sideBPromptName = agentConfig.side_b_agent_prompt;
|
|
4982
4990
|
if (sideBPromptName) {
|
|
@@ -4986,23 +4994,7 @@ var init_FlowEngine = __esm({
|
|
|
4986
4994
|
if (sideBPromptDef.tools?.length) {
|
|
4987
4995
|
console.log(`[FlowEngine] Prompt tools: [${sideBPromptDef.tools.map((t) => typeof t === "string" ? t : t.name).join(", ")}]`);
|
|
4988
4996
|
}
|
|
4989
|
-
sideBPrompt =
|
|
4990
|
-
id: sideBPromptName,
|
|
4991
|
-
name: sideBPromptDef.name,
|
|
4992
|
-
tool_description: sideBPromptDef.toolDescription,
|
|
4993
|
-
prompt: sideBPromptDef.prompt,
|
|
4994
|
-
model: sideBPromptDef.model,
|
|
4995
|
-
include_chat: sideBPromptDef.includeChat ?? false,
|
|
4996
|
-
include_past_tools: sideBPromptDef.includePastTools ?? false,
|
|
4997
|
-
parallel_tool_calls: sideBPromptDef.parallelToolCalls ?? false,
|
|
4998
|
-
tool_choice: sideBPromptDef.toolChoice ?? "auto",
|
|
4999
|
-
reasoning_effort: sideBPromptDef.reasoning?.effort ?? null,
|
|
5000
|
-
reasoning_max_tokens: sideBPromptDef.reasoning?.maxTokens ?? null,
|
|
5001
|
-
reasoning_exclude: sideBPromptDef.reasoning?.exclude ?? false,
|
|
5002
|
-
include_reasoning: sideBPromptDef.reasoning?.include ?? false,
|
|
5003
|
-
_tools: sideBPromptDef.tools ?? [],
|
|
5004
|
-
_requiredSchema: sideBPromptDef.requiredSchema ?? null
|
|
5005
|
-
};
|
|
4997
|
+
sideBPrompt = _FlowEngine.convertPromptDefinition(sideBPromptName, sideBPromptDef);
|
|
5006
4998
|
}
|
|
5007
4999
|
return { agentConfig, sideAPrompt, sideBPrompt };
|
|
5008
5000
|
}
|
|
@@ -9021,6 +9013,10 @@ function generatePromptFile(data) {
|
|
|
9021
9013
|
const reasoningCode = formatReasoningConfig(data.reasoning);
|
|
9022
9014
|
lines.push(` reasoning: ${reasoningCode},`);
|
|
9023
9015
|
}
|
|
9016
|
+
if (data.hooks && data.hooks.length > 0) {
|
|
9017
|
+
const hooksCode = data.hooks.map((h) => `'${escapeString2(h)}'`).join(", ");
|
|
9018
|
+
lines.push(` hooks: [${hooksCode}],`);
|
|
9019
|
+
}
|
|
9024
9020
|
if (hasSchema) {
|
|
9025
9021
|
const zodCode = jsonSchemaToZod(data.requiredSchema, 1);
|
|
9026
9022
|
lines.push(` requiredSchema: ${zodCode},`);
|
|
@@ -9352,9 +9348,6 @@ function validateModelData(data) {
|
|
|
9352
9348
|
if (!data.name || typeof data.name !== "string") {
|
|
9353
9349
|
return "Model name is required and must be a string";
|
|
9354
9350
|
}
|
|
9355
|
-
if (data.name.includes("/")) {
|
|
9356
|
-
return "Model name cannot contain '/'. Reserved for namespace qualification.";
|
|
9357
|
-
}
|
|
9358
9351
|
if (!data.provider || typeof data.provider !== "string") {
|
|
9359
9352
|
return "Model provider is required and must be a string";
|
|
9360
9353
|
}
|
|
@@ -16178,27 +16171,27 @@ var DurableThread = class extends DurableObject {
|
|
|
16178
16171
|
if (isQualifiedName(name)) {
|
|
16179
16172
|
const [packageId, modelName] = parseQualifiedName(name);
|
|
16180
16173
|
const reg = this.registry();
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
|
|
16186
|
-
|
|
16187
|
-
|
|
16188
|
-
|
|
16189
|
-
|
|
16190
|
-
|
|
16191
|
-
|
|
16192
|
-
|
|
16193
|
-
|
|
16174
|
+
if (reg?.packages && packageId) {
|
|
16175
|
+
const pkg = reg.packages[packageId];
|
|
16176
|
+
if (pkg) {
|
|
16177
|
+
if (pkg.models?.[modelName]) {
|
|
16178
|
+
return await pkg.models[modelName]();
|
|
16179
|
+
}
|
|
16180
|
+
const globalRegistry2 = this.models();
|
|
16181
|
+
const globalLoader2 = globalRegistry2[modelName];
|
|
16182
|
+
if (globalLoader2) {
|
|
16183
|
+
console.log(`[loadModel] Packed model "${modelName}" not in package, using global fallback`);
|
|
16184
|
+
return await globalLoader2();
|
|
16185
|
+
}
|
|
16186
|
+
throw new Error(`Model not found: ${name}. Model "${modelName}" not found in package "${packageId}" or global namespace.`);
|
|
16187
|
+
}
|
|
16194
16188
|
}
|
|
16195
16189
|
const globalRegistry = this.models();
|
|
16196
|
-
const globalLoader = globalRegistry[
|
|
16190
|
+
const globalLoader = globalRegistry[name];
|
|
16197
16191
|
if (globalLoader) {
|
|
16198
|
-
console.log(`[loadModel] Packed model "${modelName}" not in package, using global fallback`);
|
|
16199
16192
|
return await globalLoader();
|
|
16200
16193
|
}
|
|
16201
|
-
throw new Error(`Model not found: ${name}
|
|
16194
|
+
throw new Error(`Model not found: ${name}`);
|
|
16202
16195
|
}
|
|
16203
16196
|
const registry = this.models();
|
|
16204
16197
|
const loader = registry[name];
|