@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/built-in-routes.js
CHANGED
|
@@ -2721,6 +2721,8 @@ var init_ToolExecutor = __esm({
|
|
|
2721
2721
|
parentMessageId: toolMessageId,
|
|
2722
2722
|
// Set depth one level deeper than parent
|
|
2723
2723
|
depth: state.depth + 1,
|
|
2724
|
+
// Extend promptPath with the sub-prompt name
|
|
2725
|
+
promptPath: [...state.promptPath, promptDef.name],
|
|
2724
2726
|
// Additional messages to inject
|
|
2725
2727
|
extraMessages
|
|
2726
2728
|
}, true);
|
|
@@ -2749,7 +2751,7 @@ var init_ToolExecutor = __esm({
|
|
|
2749
2751
|
reader.releaseLock();
|
|
2750
2752
|
}
|
|
2751
2753
|
const childToolMessagesResult = await state.storage.sql.exec(
|
|
2752
|
-
`SELECT id, content, tool_status, tool_call_id FROM messages WHERE parent_id = ? AND role = 'tool'`,
|
|
2754
|
+
`SELECT id, content, tool_status, tool_call_id, name FROM messages WHERE parent_id = ? AND role = 'tool'`,
|
|
2753
2755
|
toolMessageId
|
|
2754
2756
|
);
|
|
2755
2757
|
const childToolRows = childToolMessagesResult.toArray();
|
|
@@ -2781,33 +2783,64 @@ var init_ToolExecutor = __esm({
|
|
|
2781
2783
|
if (toolResponseOptions.include_text_response && textContent) {
|
|
2782
2784
|
responseParts.push(textContent);
|
|
2783
2785
|
}
|
|
2784
|
-
if (
|
|
2785
|
-
const
|
|
2786
|
-
|
|
2787
|
-
toolMessageId
|
|
2788
|
-
);
|
|
2789
|
-
const childAssistantRows = childAssistantMessagesResult.toArray();
|
|
2790
|
-
const toolCallsSummary = [];
|
|
2791
|
-
if (toolResponseOptions.include_tool_calls && childAssistantRows.length > 0) {
|
|
2792
|
-
for (const row of childAssistantRows) {
|
|
2793
|
-
const toolCalls = JSON.parse(row.tool_calls);
|
|
2794
|
-
for (const tc of toolCalls) {
|
|
2795
|
-
toolCallsSummary.push(
|
|
2796
|
-
`Tool Call: ${tc.function.name}(${tc.function.arguments})`
|
|
2797
|
-
);
|
|
2798
|
-
}
|
|
2799
|
-
}
|
|
2800
|
-
}
|
|
2786
|
+
if (overallStatus === "error") {
|
|
2787
|
+
const failedTools = [];
|
|
2788
|
+
const successfulToolNames = [];
|
|
2801
2789
|
for (const row of childToolRows) {
|
|
2802
|
-
const
|
|
2803
|
-
|
|
2804
|
-
|
|
2790
|
+
const toolName = row.name || "unknown_tool";
|
|
2791
|
+
const isError = row.tool_status === "error";
|
|
2792
|
+
if (isError) {
|
|
2793
|
+
failedTools.push({
|
|
2794
|
+
name: toolName,
|
|
2795
|
+
content: row.content
|
|
2796
|
+
});
|
|
2797
|
+
} else {
|
|
2798
|
+
successfulToolNames.push(toolName);
|
|
2805
2799
|
}
|
|
2806
2800
|
}
|
|
2807
|
-
if (
|
|
2808
|
-
|
|
2809
|
-
|
|
2801
|
+
if (toolResponseOptions.include_errors && failedTools.length > 0) {
|
|
2802
|
+
const errorLines = failedTools.map((tool2) => {
|
|
2803
|
+
let errorMsg = tool2.content;
|
|
2804
|
+
if (errorMsg.startsWith("Failed to execute tool: ")) {
|
|
2805
|
+
errorMsg = errorMsg.substring("Failed to execute tool: ".length);
|
|
2806
|
+
}
|
|
2807
|
+
return ` ${tool2.name}: ${errorMsg}`;
|
|
2808
|
+
});
|
|
2809
|
+
responseParts.push(`Sub-prompt failed with ${failedTools.length} error(s):
|
|
2810
|
+
${errorLines.join("\n")}`);
|
|
2811
|
+
}
|
|
2812
|
+
if (toolResponseOptions.include_tool_calls && successfulToolNames.length > 0) {
|
|
2813
|
+
responseParts.push(`Completed successfully: ${successfulToolNames.join(", ")}`);
|
|
2814
|
+
}
|
|
2815
|
+
} else {
|
|
2816
|
+
if (toolResponseOptions.include_tool_calls || toolResponseOptions.include_errors) {
|
|
2817
|
+
const childAssistantMessagesResult = await state.storage.sql.exec(
|
|
2818
|
+
`SELECT id, tool_calls FROM messages WHERE parent_id = ? AND role = 'assistant' AND tool_calls IS NOT NULL`,
|
|
2819
|
+
toolMessageId
|
|
2810
2820
|
);
|
|
2821
|
+
const childAssistantRows = childAssistantMessagesResult.toArray();
|
|
2822
|
+
const toolCallsSummary = [];
|
|
2823
|
+
if (toolResponseOptions.include_tool_calls && childAssistantRows.length > 0) {
|
|
2824
|
+
for (const row of childAssistantRows) {
|
|
2825
|
+
const toolCalls = JSON.parse(row.tool_calls);
|
|
2826
|
+
for (const tc of toolCalls) {
|
|
2827
|
+
toolCallsSummary.push(
|
|
2828
|
+
`Tool Call: ${tc.function.name}(${tc.function.arguments})`
|
|
2829
|
+
);
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
for (const row of childToolRows) {
|
|
2834
|
+
const isError = row.content?.startsWith("Error: ");
|
|
2835
|
+
if (isError && toolResponseOptions.include_errors || !isError && toolResponseOptions.include_tool_calls) {
|
|
2836
|
+
toolCallsSummary.push(`Tool Response: ${row.content}`);
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
if (toolCallsSummary.length > 0) {
|
|
2840
|
+
responseParts.push(
|
|
2841
|
+
"Tool Executions:\n" + toolCallsSummary.join("\n")
|
|
2842
|
+
);
|
|
2843
|
+
}
|
|
2811
2844
|
}
|
|
2812
2845
|
}
|
|
2813
2846
|
const finalResponse = responseParts.length > 0 ? responseParts.join("\n\n") : "Prompt executed successfully";
|
|
@@ -4767,6 +4800,8 @@ var init_FlowEngine = __esm({
|
|
|
4767
4800
|
parentMessageId: stateInput.parentMessageId,
|
|
4768
4801
|
depth: stateInput.depth ?? 0,
|
|
4769
4802
|
// Default to 0 for top-level prompts
|
|
4803
|
+
// Initialize promptPath from input or create new path with current prompt name
|
|
4804
|
+
promptPath: stateInput.promptPath ?? [sideAPrompt.name],
|
|
4770
4805
|
pendingMessageId: stateInput.pendingMessageId,
|
|
4771
4806
|
abortController: stateInput.abortController,
|
|
4772
4807
|
allowedTools: stateInput.allowedTools,
|
|
@@ -4970,6 +5005,7 @@ var init_FlowEngine = __esm({
|
|
|
4970
5005
|
state.extraMessages = [];
|
|
4971
5006
|
state.currentSide = "a";
|
|
4972
5007
|
state.prompt = state.prompts.sideA;
|
|
5008
|
+
state.promptPath = [sideAPrompt.name];
|
|
4973
5009
|
state.pendingHandoff = void 0;
|
|
4974
5010
|
state.emitTelemetry?.({
|
|
4975
5011
|
type: "agent_handoff",
|
|
@@ -7215,6 +7251,9 @@ var init_ThreadStateImpl = __esm({
|
|
|
7215
7251
|
metadata: void 0
|
|
7216
7252
|
}));
|
|
7217
7253
|
}
|
|
7254
|
+
get promptPath() {
|
|
7255
|
+
return this._flowState.promptPath;
|
|
7256
|
+
}
|
|
7218
7257
|
forceTurn(side) {
|
|
7219
7258
|
this._flowState.forcedNextSide = side === "a" ? "side_a" : "side_b";
|
|
7220
7259
|
}
|