@theokit/sdk 4.2.10 → 4.4.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 {