@theokit/sdk 4.2.9 → 4.3.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.
- package/CHANGELOG.md +6 -0
- package/dist/a2a/index.cjs +8 -1
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +8 -1
- package/dist/a2a/index.js.map +1 -1
- package/dist/cron.cjs +36 -1
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.js +36 -1
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +36 -1
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +36 -1
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +36 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12817,11 +12817,28 @@ async function runToolWithLifecycle(inputs, resolved, call, callId) {
|
|
|
12817
12817
|
conversationId: inputs.agentId,
|
|
12818
12818
|
callId
|
|
12819
12819
|
});
|
|
12820
|
+
await emitToolLifecycleDelta(inputs, {
|
|
12821
|
+
type: "tool-call-started",
|
|
12822
|
+
callId,
|
|
12823
|
+
toolCall: { callId, name: call.name, args: call.input },
|
|
12824
|
+
modelCallId: callId
|
|
12825
|
+
});
|
|
12820
12826
|
const result = await raceToolExecution(executeTool(inputs, resolved, call), {
|
|
12821
12827
|
signal: inputs.signal,
|
|
12822
12828
|
timeoutMs: inputs.perToolTimeoutMs
|
|
12823
12829
|
});
|
|
12824
12830
|
const durationMs = Date.now() - startAt;
|
|
12831
|
+
await emitToolLifecycleDelta(inputs, {
|
|
12832
|
+
type: "tool-call-completed",
|
|
12833
|
+
callId,
|
|
12834
|
+
toolCall: {
|
|
12835
|
+
callId,
|
|
12836
|
+
name: call.name,
|
|
12837
|
+
args: call.input,
|
|
12838
|
+
result: result.content !== void 0 ? result.content : renderToolResult(result)
|
|
12839
|
+
},
|
|
12840
|
+
modelCallId: callId
|
|
12841
|
+
});
|
|
12825
12842
|
inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.TOOL_CALL_DURATION_MS, durationMs, {
|
|
12826
12843
|
"tool.name": call.name
|
|
12827
12844
|
});
|
|
@@ -12887,6 +12904,17 @@ function finalizeSpanAndPostHook(inputs, call, callId, result, events, toolSpan)
|
|
|
12887
12904
|
...result.exitCode !== 0 && result.exitCode !== void 0 ? { isError: true } : {}
|
|
12888
12905
|
};
|
|
12889
12906
|
}
|
|
12907
|
+
async function emitToolLifecycleDelta(inputs, update) {
|
|
12908
|
+
if (inputs.onDelta === void 0) return;
|
|
12909
|
+
try {
|
|
12910
|
+
await inputs.onDelta({ update });
|
|
12911
|
+
} catch (err) {
|
|
12912
|
+
process.stderr.write(
|
|
12913
|
+
`[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
|
|
12914
|
+
`
|
|
12915
|
+
);
|
|
12916
|
+
}
|
|
12917
|
+
}
|
|
12890
12918
|
async function safeEmitToolHook(callback, event) {
|
|
12891
12919
|
if (callback === void 0) return;
|
|
12892
12920
|
try {
|
|
@@ -16335,7 +16363,7 @@ function detectPrimaryProvider() {
|
|
|
16335
16363
|
|
|
16336
16364
|
// src/a2a/subagent.ts
|
|
16337
16365
|
init_agent_factory_registry();
|
|
16338
|
-
var INHERIT_CREDENTIALS = /* @__PURE__ */ Symbol("theokit.subagent.inheritCredentials");
|
|
16366
|
+
var INHERIT_CREDENTIALS = /* @__PURE__ */ Symbol.for("theokit.subagent.inheritCredentials");
|
|
16339
16367
|
function inheritSubAgentCredentials(tool, creds) {
|
|
16340
16368
|
const sink = tool[INHERIT_CREDENTIALS];
|
|
16341
16369
|
if (typeof sink === "function") sink(creds);
|
|
@@ -16398,6 +16426,13 @@ async function runChildAgent(spec, input, signal, maxSteps, inherited) {
|
|
|
16398
16426
|
};
|
|
16399
16427
|
const run = await agent.send(input, sendOptions);
|
|
16400
16428
|
const result = await run.wait();
|
|
16429
|
+
if (result.status === "error") {
|
|
16430
|
+
const cause = result.error;
|
|
16431
|
+
throw new Error(
|
|
16432
|
+
`subagent "${spec.name}" run failed: ${cause?.message ?? "unknown error"}`,
|
|
16433
|
+
cause !== void 0 ? { cause } : void 0
|
|
16434
|
+
);
|
|
16435
|
+
}
|
|
16401
16436
|
const text = result.result ?? "(no response)";
|
|
16402
16437
|
return spec.includeToolResults === true ? text + await collectChildToolResults(run) : text;
|
|
16403
16438
|
} finally {
|