agent.libx.js 0.89.4 → 0.89.5
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/cli.d.ts +20 -0
- package/dist/cli.js +54 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2801,7 +2801,7 @@ var Agent = class _Agent {
|
|
|
2801
2801
|
} catch (err) {
|
|
2802
2802
|
if (err?.code === "budget") return kill("budget");
|
|
2803
2803
|
if (o.signal?.aborted) return kill("aborted");
|
|
2804
|
-
log3.error(
|
|
2804
|
+
log3.error(`chat() failed: ${err?.message ?? err}`, err);
|
|
2805
2805
|
return { text: "", steps, finishReason: "error", messages: this.transcript, usage, usageEstimated, error: err };
|
|
2806
2806
|
}
|
|
2807
2807
|
if (o.signal?.aborted) return kill("aborted");
|
|
@@ -2865,12 +2865,14 @@ var Agent = class _Agent {
|
|
|
2865
2865
|
}
|
|
2866
2866
|
async dispatch(tc) {
|
|
2867
2867
|
const tool = this.activeTools.find((t) => t.name === tc.function.name);
|
|
2868
|
-
if (!tool) return `Error: unknown tool '${tc.function.name}'`;
|
|
2869
2868
|
let args = {};
|
|
2869
|
+
let earlyError;
|
|
2870
|
+
if (!tool) earlyError = `Error: unknown tool '${tc.function.name}'`;
|
|
2870
2871
|
try {
|
|
2871
2872
|
args = tc.function.arguments ? JSON.parse(tc.function.arguments) : {};
|
|
2872
2873
|
} catch (e) {
|
|
2873
|
-
|
|
2874
|
+
args = tc.function.arguments;
|
|
2875
|
+
earlyError ??= `Error: invalid JSON arguments for ${tc.function.name}: ${String(e)}`;
|
|
2874
2876
|
}
|
|
2875
2877
|
const hooks = this.activeHooks;
|
|
2876
2878
|
const call = { name: tc.function.name, args };
|
|
@@ -2883,6 +2885,12 @@ var Agent = class _Agent {
|
|
|
2883
2885
|
return blocked;
|
|
2884
2886
|
}
|
|
2885
2887
|
this.options.host?.notify?.({ kind: "tool_use", id: tc.id ?? "", name: tc.function.name, input: args });
|
|
2888
|
+
if (earlyError) {
|
|
2889
|
+
log3.debug(`${tc.function.name} -> ${earlyError}`);
|
|
2890
|
+
await hooks?.postToolUse?.(call, earlyError, meta);
|
|
2891
|
+
this.options.host?.notify?.({ kind: "tool_result", id: tc.id ?? "", output: earlyError, isError: true });
|
|
2892
|
+
return earlyError;
|
|
2893
|
+
}
|
|
2886
2894
|
let result;
|
|
2887
2895
|
let threw = false;
|
|
2888
2896
|
try {
|