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