@linnlabs/linnkit 0.37.0 → 0.37.2

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.
@@ -5021,10 +5021,7 @@ function createExecuteLlmStage(dependencies) {
5021
5021
  const promptBudget = ctx.promptBudget;
5022
5022
  const promptUsageMeasurementPolicy = ctx.promptUsageMeasurementPolicy;
5023
5023
  const streamEventHandler = ctx.input.stream && ctx.eventHandler ? (event) => {
5024
- const processedEvent = processStreamEvent(event, ctx.outputProcessor);
5025
- if (processedEvent) {
5026
- ctx.eventHandler?.(processedEvent);
5027
- }
5024
+ ctx.eventHandler?.(processStreamEvent(event, ctx.outputProcessor));
5028
5025
  } : void 0;
5029
5026
  const llmCallStartedAt = Date.now();
5030
5027
  let llmResp;
@@ -5180,9 +5177,6 @@ function processStreamEvent(event, outputProcessor) {
5180
5177
  return event;
5181
5178
  }
5182
5179
  const processedContent = outputProcessor.processStreamChunk(event.content);
5183
- if (processedContent.length === 0) {
5184
- return null;
5185
- }
5186
5180
  return {
5187
5181
  ...event,
5188
5182
  content: processedContent
@@ -6753,9 +6747,7 @@ function mapToolProgressToRuntime(toolEvent, context, options, id, timestamp) {
6753
6747
  return event;
6754
6748
  }
6755
6749
  function mapStreamChunkToRuntime(streamEvent, context, id, timestamp) {
6756
- const text = streamEvent.content ?? "";
6757
- if (!text) return null;
6758
- const chunkEvent = createFinalAnswerChunkEvent(id, context.conversationId, context.turnId, streamEvent.answer_id, streamEvent.seq, text, {
6750
+ const chunkEvent = createFinalAnswerChunkEvent(id, context.conversationId, context.turnId, streamEvent.answer_id, streamEvent.seq, streamEvent.content, {
6759
6751
  timestamp,
6760
6752
  is_last: streamEvent.is_last === true
6761
6753
  });
@@ -8651,6 +8643,14 @@ var ToolNode = class {
8651
8643
  error.name = "AbortError";
8652
8644
  throw error;
8653
8645
  }
8646
+ if (result.kind === "interrupted") {
8647
+ await commitToolBoundary(state, {
8648
+ kind: "route",
8649
+ nextNodeId: "llm",
8650
+ events: result.events
8651
+ });
8652
+ throw result.error;
8653
+ }
8654
8654
  await commitToolBoundary(state, result);
8655
8655
  if (Array.isArray(result.events) && result.events.length > 0) {
8656
8656
  events.push(...result.events);
@@ -9091,7 +9091,11 @@ var ToolNode = class {
9091
9091
  nextProtocolErrorCount: fuse.nextCount
9092
9092
  });
9093
9093
  if (fuse.shouldFuse && remainingCalls.length === 0) {
9094
- throw createToolProtocolFuseError(fuse.nextCount, context.exec.error);
9094
+ return {
9095
+ kind: "interrupted",
9096
+ error: createToolProtocolFuseError(fuse.nextCount, context.exec.error),
9097
+ events: context.bridge.getRuntimeEvents()
9098
+ };
9095
9099
  }
9096
9100
  if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
9097
9101
  return { kind: "yield", events: context.bridge.getRuntimeEvents() };