@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/dist/eval.cjs CHANGED
@@ -10230,11 +10230,28 @@ async function runToolWithLifecycle(inputs, resolved, call, callId) {
10230
10230
  conversationId: inputs.agentId,
10231
10231
  callId
10232
10232
  });
10233
+ await emitToolLifecycleDelta(inputs, {
10234
+ type: "tool-call-started",
10235
+ callId,
10236
+ toolCall: { callId, name: call.name, args: call.input },
10237
+ modelCallId: callId
10238
+ });
10233
10239
  const result = await raceToolExecution(executeTool(inputs, resolved, call), {
10234
10240
  signal: inputs.signal,
10235
10241
  timeoutMs: inputs.perToolTimeoutMs
10236
10242
  });
10237
10243
  const durationMs = Date.now() - startAt;
10244
+ await emitToolLifecycleDelta(inputs, {
10245
+ type: "tool-call-completed",
10246
+ callId,
10247
+ toolCall: {
10248
+ callId,
10249
+ name: call.name,
10250
+ args: call.input,
10251
+ result: result.content !== void 0 ? result.content : renderToolResult(result)
10252
+ },
10253
+ modelCallId: callId
10254
+ });
10238
10255
  inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.TOOL_CALL_DURATION_MS, durationMs, {
10239
10256
  "tool.name": call.name
10240
10257
  });
@@ -10300,6 +10317,17 @@ function finalizeSpanAndPostHook(inputs, call, callId, result, events, toolSpan)
10300
10317
  ...result.exitCode !== 0 && result.exitCode !== void 0 ? { isError: true } : {}
10301
10318
  };
10302
10319
  }
10320
+ async function emitToolLifecycleDelta(inputs, update) {
10321
+ if (inputs.onDelta === void 0) return;
10322
+ try {
10323
+ await inputs.onDelta({ update });
10324
+ } catch (err) {
10325
+ process.stderr.write(
10326
+ `[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
10327
+ `
10328
+ );
10329
+ }
10330
+ }
10303
10331
  async function safeEmitToolHook(callback, event) {
10304
10332
  if (callback === void 0) return;
10305
10333
  try {
@@ -13732,7 +13760,7 @@ function detectPrimaryProvider() {
13732
13760
 
13733
13761
  // src/a2a/subagent.ts
13734
13762
  init_agent_factory_registry();
13735
- var INHERIT_CREDENTIALS = /* @__PURE__ */ Symbol("theokit.subagent.inheritCredentials");
13763
+ var INHERIT_CREDENTIALS = /* @__PURE__ */ Symbol.for("theokit.subagent.inheritCredentials");
13736
13764
  function inheritSubAgentCredentials(tool, creds) {
13737
13765
  const sink = tool[INHERIT_CREDENTIALS];
13738
13766
  if (typeof sink === "function") sink(creds);
@@ -13795,6 +13823,13 @@ async function runChildAgent(spec, input, signal, maxSteps, inherited) {
13795
13823
  };
13796
13824
  const run = await agent.send(input, sendOptions);
13797
13825
  const result = await run.wait();
13826
+ if (result.status === "error") {
13827
+ const cause = result.error;
13828
+ throw new Error(
13829
+ `subagent "${spec.name}" run failed: ${cause?.message ?? "unknown error"}`,
13830
+ cause !== void 0 ? { cause } : void 0
13831
+ );
13832
+ }
13798
13833
  const text = result.result ?? "(no response)";
13799
13834
  return spec.includeToolResults === true ? text + await collectChildToolResults(run) : text;
13800
13835
  } finally {