@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/index.js CHANGED
@@ -12814,11 +12814,28 @@ async function runToolWithLifecycle(inputs, resolved, call, callId) {
12814
12814
  conversationId: inputs.agentId,
12815
12815
  callId
12816
12816
  });
12817
+ await emitToolLifecycleDelta(inputs, {
12818
+ type: "tool-call-started",
12819
+ callId,
12820
+ toolCall: { callId, name: call.name, args: call.input },
12821
+ modelCallId: callId
12822
+ });
12817
12823
  const result = await raceToolExecution(executeTool(inputs, resolved, call), {
12818
12824
  signal: inputs.signal,
12819
12825
  timeoutMs: inputs.perToolTimeoutMs
12820
12826
  });
12821
12827
  const durationMs = Date.now() - startAt;
12828
+ await emitToolLifecycleDelta(inputs, {
12829
+ type: "tool-call-completed",
12830
+ callId,
12831
+ toolCall: {
12832
+ callId,
12833
+ name: call.name,
12834
+ args: call.input,
12835
+ result: result.content !== void 0 ? result.content : renderToolResult(result)
12836
+ },
12837
+ modelCallId: callId
12838
+ });
12822
12839
  inputs.telemetry?.recordHistogram(HISTOGRAM_NAMES.TOOL_CALL_DURATION_MS, durationMs, {
12823
12840
  "tool.name": call.name
12824
12841
  });
@@ -12884,6 +12901,17 @@ function finalizeSpanAndPostHook(inputs, call, callId, result, events, toolSpan)
12884
12901
  ...result.exitCode !== 0 && result.exitCode !== void 0 ? { isError: true } : {}
12885
12902
  };
12886
12903
  }
12904
+ async function emitToolLifecycleDelta(inputs, update) {
12905
+ if (inputs.onDelta === void 0) return;
12906
+ try {
12907
+ await inputs.onDelta({ update });
12908
+ } catch (err) {
12909
+ process.stderr.write(
12910
+ `[theokit-sdk] onDelta tool-lifecycle emit error (swallowed): ${err instanceof Error ? err.message : String(err)}
12911
+ `
12912
+ );
12913
+ }
12914
+ }
12887
12915
  async function safeEmitToolHook(callback, event) {
12888
12916
  if (callback === void 0) return;
12889
12917
  try {
@@ -16332,7 +16360,7 @@ function detectPrimaryProvider() {
16332
16360
 
16333
16361
  // src/a2a/subagent.ts
16334
16362
  init_agent_factory_registry();
16335
- var INHERIT_CREDENTIALS = /* @__PURE__ */ Symbol("theokit.subagent.inheritCredentials");
16363
+ var INHERIT_CREDENTIALS = /* @__PURE__ */ Symbol.for("theokit.subagent.inheritCredentials");
16336
16364
  function inheritSubAgentCredentials(tool, creds) {
16337
16365
  const sink = tool[INHERIT_CREDENTIALS];
16338
16366
  if (typeof sink === "function") sink(creds);
@@ -16395,6 +16423,13 @@ async function runChildAgent(spec, input, signal, maxSteps, inherited) {
16395
16423
  };
16396
16424
  const run = await agent.send(input, sendOptions);
16397
16425
  const result = await run.wait();
16426
+ if (result.status === "error") {
16427
+ const cause = result.error;
16428
+ throw new Error(
16429
+ `subagent "${spec.name}" run failed: ${cause?.message ?? "unknown error"}`,
16430
+ cause !== void 0 ? { cause } : void 0
16431
+ );
16432
+ }
16398
16433
  const text = result.result ?? "(no response)";
16399
16434
  return spec.includeToolResults === true ? text + await collectChildToolResults(run) : text;
16400
16435
  } finally {