@standardagents/builder 0.11.5 → 0.11.6
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 +63 -24
- package/dist/built-in-routes.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +67 -26
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +4 -2
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -439,6 +439,8 @@ interface FlowState {
|
|
|
439
439
|
currentLogId?: string | null;
|
|
440
440
|
parentMessageId?: string;
|
|
441
441
|
depth: number;
|
|
442
|
+
/** Path from root prompt to current prompt (e.g., ['basic_prompt', 'generate_image']) */
|
|
443
|
+
promptPath: string[];
|
|
442
444
|
pendingMessageId?: string;
|
|
443
445
|
allowedTools?: ToolDefinition[];
|
|
444
446
|
pendingMetadataPromises?: Promise<void>[];
|
package/dist/index.js
CHANGED
|
@@ -2739,6 +2739,8 @@ var init_ToolExecutor = __esm({
|
|
|
2739
2739
|
parentMessageId: toolMessageId,
|
|
2740
2740
|
// Set depth one level deeper than parent
|
|
2741
2741
|
depth: state.depth + 1,
|
|
2742
|
+
// Extend promptPath with the sub-prompt name
|
|
2743
|
+
promptPath: [...state.promptPath, promptDef.name],
|
|
2742
2744
|
// Additional messages to inject
|
|
2743
2745
|
extraMessages
|
|
2744
2746
|
}, true);
|
|
@@ -2767,7 +2769,7 @@ var init_ToolExecutor = __esm({
|
|
|
2767
2769
|
reader.releaseLock();
|
|
2768
2770
|
}
|
|
2769
2771
|
const childToolMessagesResult = await state.storage.sql.exec(
|
|
2770
|
-
`SELECT id, content, tool_status, tool_call_id FROM messages WHERE parent_id = ? AND role = 'tool'`,
|
|
2772
|
+
`SELECT id, content, tool_status, tool_call_id, name FROM messages WHERE parent_id = ? AND role = 'tool'`,
|
|
2771
2773
|
toolMessageId
|
|
2772
2774
|
);
|
|
2773
2775
|
const childToolRows = childToolMessagesResult.toArray();
|
|
@@ -2799,33 +2801,64 @@ var init_ToolExecutor = __esm({
|
|
|
2799
2801
|
if (toolResponseOptions.include_text_response && textContent) {
|
|
2800
2802
|
responseParts.push(textContent);
|
|
2801
2803
|
}
|
|
2802
|
-
if (
|
|
2803
|
-
const
|
|
2804
|
-
|
|
2805
|
-
toolMessageId
|
|
2806
|
-
);
|
|
2807
|
-
const childAssistantRows = childAssistantMessagesResult.toArray();
|
|
2808
|
-
const toolCallsSummary = [];
|
|
2809
|
-
if (toolResponseOptions.include_tool_calls && childAssistantRows.length > 0) {
|
|
2810
|
-
for (const row of childAssistantRows) {
|
|
2811
|
-
const toolCalls = JSON.parse(row.tool_calls);
|
|
2812
|
-
for (const tc of toolCalls) {
|
|
2813
|
-
toolCallsSummary.push(
|
|
2814
|
-
`Tool Call: ${tc.function.name}(${tc.function.arguments})`
|
|
2815
|
-
);
|
|
2816
|
-
}
|
|
2817
|
-
}
|
|
2818
|
-
}
|
|
2804
|
+
if (overallStatus === "error") {
|
|
2805
|
+
const failedTools = [];
|
|
2806
|
+
const successfulToolNames = [];
|
|
2819
2807
|
for (const row of childToolRows) {
|
|
2820
|
-
const
|
|
2821
|
-
|
|
2822
|
-
|
|
2808
|
+
const toolName = row.name || "unknown_tool";
|
|
2809
|
+
const isError = row.tool_status === "error";
|
|
2810
|
+
if (isError) {
|
|
2811
|
+
failedTools.push({
|
|
2812
|
+
name: toolName,
|
|
2813
|
+
content: row.content
|
|
2814
|
+
});
|
|
2815
|
+
} else {
|
|
2816
|
+
successfulToolNames.push(toolName);
|
|
2823
2817
|
}
|
|
2824
2818
|
}
|
|
2825
|
-
if (
|
|
2826
|
-
|
|
2827
|
-
|
|
2819
|
+
if (toolResponseOptions.include_errors && failedTools.length > 0) {
|
|
2820
|
+
const errorLines = failedTools.map((tool) => {
|
|
2821
|
+
let errorMsg = tool.content;
|
|
2822
|
+
if (errorMsg.startsWith("Failed to execute tool: ")) {
|
|
2823
|
+
errorMsg = errorMsg.substring("Failed to execute tool: ".length);
|
|
2824
|
+
}
|
|
2825
|
+
return ` ${tool.name}: ${errorMsg}`;
|
|
2826
|
+
});
|
|
2827
|
+
responseParts.push(`Sub-prompt failed with ${failedTools.length} error(s):
|
|
2828
|
+
${errorLines.join("\n")}`);
|
|
2829
|
+
}
|
|
2830
|
+
if (toolResponseOptions.include_tool_calls && successfulToolNames.length > 0) {
|
|
2831
|
+
responseParts.push(`Completed successfully: ${successfulToolNames.join(", ")}`);
|
|
2832
|
+
}
|
|
2833
|
+
} else {
|
|
2834
|
+
if (toolResponseOptions.include_tool_calls || toolResponseOptions.include_errors) {
|
|
2835
|
+
const childAssistantMessagesResult = await state.storage.sql.exec(
|
|
2836
|
+
`SELECT id, tool_calls FROM messages WHERE parent_id = ? AND role = 'assistant' AND tool_calls IS NOT NULL`,
|
|
2837
|
+
toolMessageId
|
|
2828
2838
|
);
|
|
2839
|
+
const childAssistantRows = childAssistantMessagesResult.toArray();
|
|
2840
|
+
const toolCallsSummary = [];
|
|
2841
|
+
if (toolResponseOptions.include_tool_calls && childAssistantRows.length > 0) {
|
|
2842
|
+
for (const row of childAssistantRows) {
|
|
2843
|
+
const toolCalls = JSON.parse(row.tool_calls);
|
|
2844
|
+
for (const tc of toolCalls) {
|
|
2845
|
+
toolCallsSummary.push(
|
|
2846
|
+
`Tool Call: ${tc.function.name}(${tc.function.arguments})`
|
|
2847
|
+
);
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
for (const row of childToolRows) {
|
|
2852
|
+
const isError = row.content?.startsWith("Error: ");
|
|
2853
|
+
if (isError && toolResponseOptions.include_errors || !isError && toolResponseOptions.include_tool_calls) {
|
|
2854
|
+
toolCallsSummary.push(`Tool Response: ${row.content}`);
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
if (toolCallsSummary.length > 0) {
|
|
2858
|
+
responseParts.push(
|
|
2859
|
+
"Tool Executions:\n" + toolCallsSummary.join("\n")
|
|
2860
|
+
);
|
|
2861
|
+
}
|
|
2829
2862
|
}
|
|
2830
2863
|
}
|
|
2831
2864
|
const finalResponse = responseParts.length > 0 ? responseParts.join("\n\n") : "Prompt executed successfully";
|
|
@@ -4878,6 +4911,8 @@ var init_FlowEngine = __esm({
|
|
|
4878
4911
|
parentMessageId: stateInput.parentMessageId,
|
|
4879
4912
|
depth: stateInput.depth ?? 0,
|
|
4880
4913
|
// Default to 0 for top-level prompts
|
|
4914
|
+
// Initialize promptPath from input or create new path with current prompt name
|
|
4915
|
+
promptPath: stateInput.promptPath ?? [sideAPrompt.name],
|
|
4881
4916
|
pendingMessageId: stateInput.pendingMessageId,
|
|
4882
4917
|
abortController: stateInput.abortController,
|
|
4883
4918
|
allowedTools: stateInput.allowedTools,
|
|
@@ -5081,6 +5116,7 @@ var init_FlowEngine = __esm({
|
|
|
5081
5116
|
state.extraMessages = [];
|
|
5082
5117
|
state.currentSide = "a";
|
|
5083
5118
|
state.prompt = state.prompts.sideA;
|
|
5119
|
+
state.promptPath = [sideAPrompt.name];
|
|
5084
5120
|
state.pendingHandoff = void 0;
|
|
5085
5121
|
state.emitTelemetry?.({
|
|
5086
5122
|
type: "agent_handoff",
|
|
@@ -7548,6 +7584,9 @@ var init_ThreadStateImpl = __esm({
|
|
|
7548
7584
|
metadata: void 0
|
|
7549
7585
|
}));
|
|
7550
7586
|
}
|
|
7587
|
+
get promptPath() {
|
|
7588
|
+
return this._flowState.promptPath;
|
|
7589
|
+
}
|
|
7551
7590
|
forceTurn(side) {
|
|
7552
7591
|
this._flowState.forcedNextSide = side === "a" ? "side_a" : "side_b";
|
|
7553
7592
|
}
|
|
@@ -9822,7 +9861,8 @@ function agentbuilder(options = {}) {
|
|
|
9822
9861
|
];
|
|
9823
9862
|
const depsToInclude = [
|
|
9824
9863
|
"zod",
|
|
9825
|
-
"openai"
|
|
9864
|
+
"openai",
|
|
9865
|
+
"@standardagents/spec"
|
|
9826
9866
|
];
|
|
9827
9867
|
const currentDir = path3.dirname(fileURLToPath(import.meta.url));
|
|
9828
9868
|
const isInDist = currentDir.endsWith("dist");
|
|
@@ -9871,7 +9911,8 @@ function agentbuilder(options = {}) {
|
|
|
9871
9911
|
"zod/v3",
|
|
9872
9912
|
"zod/v4",
|
|
9873
9913
|
"zod/v4/core",
|
|
9874
|
-
"openai"
|
|
9914
|
+
"openai",
|
|
9915
|
+
"@standardagents/spec"
|
|
9875
9916
|
];
|
|
9876
9917
|
config.optimizeDeps = config.optimizeDeps || {};
|
|
9877
9918
|
config.optimizeDeps.exclude = [
|