@sema-agent/core 1.437.0 → 1.438.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.
|
@@ -3405,15 +3405,16 @@ export class Runner {
|
|
|
3405
3405
|
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
3406
3406
|
return;
|
|
3407
3407
|
}
|
|
3408
|
-
|
|
3409
|
-
|
|
3408
|
+
const executedIsError = res.isError === true;
|
|
3409
|
+
emitEnd(executedIsError);
|
|
3410
|
+
onResolvedToolSuccess?.(canonicalToolName(pendingAction.toolName), executedIsError ? undefined : res.details);
|
|
3410
3411
|
const eid = await prepared.session.appendMessage({
|
|
3411
3412
|
role: "toolResult",
|
|
3412
3413
|
toolCallId: pendingAction.toolCallId,
|
|
3413
3414
|
toolName: pendingAction.toolName,
|
|
3414
3415
|
content: res.content,
|
|
3415
3416
|
details: res.details,
|
|
3416
|
-
isError:
|
|
3417
|
+
isError: executedIsError,
|
|
3417
3418
|
timestamp: Date.now(),
|
|
3418
3419
|
});
|
|
3419
3420
|
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
@@ -59,8 +59,10 @@ export function makePlaceholderTool(info) {
|
|
|
59
59
|
description: `${info.hint} — deferred: call ${TOOL_SEARCH_NAME}({"query":"select:${sn}"}) to load its parameters before use.`,
|
|
60
60
|
parameters: EMPTY_PARAMS,
|
|
61
61
|
effect: "read",
|
|
62
|
-
execute: () =>
|
|
63
|
-
|
|
62
|
+
execute: () => {
|
|
63
|
+
throw new Error(`Tool "${sn}" is not active yet. Call ${TOOL_SEARCH_NAME} with {"query":"select:${sn}"} ` +
|
|
64
|
+
`(or a keyword \`query\`) to load its full schema, then call ${sn} with the proper arguments.`);
|
|
65
|
+
},
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
68
|
export function scoreToolMatch(query, info) {
|
package/dist/core/tools.js
CHANGED
|
@@ -3,11 +3,11 @@ import { formatToolError, formatZodValidationError } from "./tool-errors.js";
|
|
|
3
3
|
import { attachToolContract } from "../prompt-assembly/tool-catalog.js";
|
|
4
4
|
function normalizeContent(ret) {
|
|
5
5
|
if (typeof ret === "string") {
|
|
6
|
-
return { content: [{ type: "text", text: ret }], details: undefined, terminate: false };
|
|
6
|
+
return { content: [{ type: "text", text: ret }], details: undefined, terminate: false, isError: false };
|
|
7
7
|
}
|
|
8
8
|
const raw = ret.content;
|
|
9
9
|
const content = typeof raw === "string" ? [{ type: "text", text: raw }] : raw;
|
|
10
|
-
return { content, details: ret.details, terminate: ret.terminate ?? false };
|
|
10
|
+
return { content, details: ret.details, terminate: ret.terminate ?? false, isError: ret.isError === true };
|
|
11
11
|
}
|
|
12
12
|
function isEmptyToolContent(content) {
|
|
13
13
|
if (content.length === 0)
|
|
@@ -45,11 +45,11 @@ export function defineTool(spec) {
|
|
|
45
45
|
catch (err) {
|
|
46
46
|
throw new Error(formatToolError(err));
|
|
47
47
|
}
|
|
48
|
-
const { content, details, terminate } = normalizeContent(ret);
|
|
48
|
+
const { content, details, terminate, isError } = normalizeContent(ret);
|
|
49
49
|
const guarded = isEmptyToolContent(content)
|
|
50
|
-
? [{ type: "text", text: `(${spec.name} completed with no output)` }]
|
|
50
|
+
? [{ type: "text", text: isError ? `(${spec.name} reported an error with no further output)` : `(${spec.name} completed with no output)` }]
|
|
51
51
|
: content;
|
|
52
|
-
return { content: guarded, details, terminate };
|
|
52
|
+
return { content: guarded, details, terminate, ...(isError ? { isError: true } : {}) };
|
|
53
53
|
},
|
|
54
54
|
};
|
|
55
55
|
if (spec.contract) {
|
package/dist/core/types.d.ts
CHANGED