@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.
@@ -15,6 +15,7 @@ interface GraphExecutorOutputProcessor {
15
15
  * runtime-kernel 调用时必须保留对象接收者,不要拆成裸函数传递。
16
16
  */
17
17
  processResponse?(this: GraphExecutorOutputProcessor, rawResponse: string): string;
18
+ /** 返回空串只隐藏当前正文;已经分配的 chunk identity/seq 仍原样进入 Graph 与实时通道。 */
18
19
  processStreamChunk?(this: GraphExecutorOutputProcessor, chunk: string): string;
19
20
  }
20
21
  interface GraphExecutorContextBuildInput {
@@ -15,6 +15,7 @@ interface GraphExecutorOutputProcessor {
15
15
  * runtime-kernel 调用时必须保留对象接收者,不要拆成裸函数传递。
16
16
  */
17
17
  processResponse?(this: GraphExecutorOutputProcessor, rawResponse: string): string;
18
+ /** 返回空串只隐藏当前正文;已经分配的 chunk identity/seq 仍原样进入 Graph 与实时通道。 */
18
19
  processStreamChunk?(this: GraphExecutorOutputProcessor, chunk: string): string;
19
20
  }
20
21
  interface GraphExecutorContextBuildInput {
@@ -5032,10 +5032,7 @@ function createExecuteLlmStage(dependencies) {
5032
5032
  const promptBudget = ctx.promptBudget;
5033
5033
  const promptUsageMeasurementPolicy = ctx.promptUsageMeasurementPolicy;
5034
5034
  const streamEventHandler = ctx.input.stream && ctx.eventHandler ? (event) => {
5035
- const processedEvent = processStreamEvent(event, ctx.outputProcessor);
5036
- if (processedEvent) {
5037
- ctx.eventHandler?.(processedEvent);
5038
- }
5035
+ ctx.eventHandler?.(processStreamEvent(event, ctx.outputProcessor));
5039
5036
  } : void 0;
5040
5037
  const llmCallStartedAt = Date.now();
5041
5038
  let llmResp;
@@ -5191,9 +5188,6 @@ function processStreamEvent(event, outputProcessor) {
5191
5188
  return event;
5192
5189
  }
5193
5190
  const processedContent = outputProcessor.processStreamChunk(event.content);
5194
- if (processedContent.length === 0) {
5195
- return null;
5196
- }
5197
5191
  return {
5198
5192
  ...event,
5199
5193
  content: processedContent
@@ -6764,9 +6758,7 @@ function mapToolProgressToRuntime(toolEvent, context, options, id, timestamp) {
6764
6758
  return event;
6765
6759
  }
6766
6760
  function mapStreamChunkToRuntime(streamEvent, context, id, timestamp) {
6767
- const text = streamEvent.content ?? "";
6768
- if (!text) return null;
6769
- const chunkEvent = createFinalAnswerChunkEvent(id, context.conversationId, context.turnId, streamEvent.answer_id, streamEvent.seq, text, {
6761
+ const chunkEvent = createFinalAnswerChunkEvent(id, context.conversationId, context.turnId, streamEvent.answer_id, streamEvent.seq, streamEvent.content, {
6770
6762
  timestamp,
6771
6763
  is_last: streamEvent.is_last === true
6772
6764
  });
@@ -8723,6 +8715,14 @@ var ToolNode = class {
8723
8715
  error.name = "AbortError";
8724
8716
  throw error;
8725
8717
  }
8718
+ if (result.kind === "interrupted") {
8719
+ await commitToolBoundary(state, {
8720
+ kind: "route",
8721
+ nextNodeId: "llm",
8722
+ events: result.events
8723
+ });
8724
+ throw result.error;
8725
+ }
8726
8726
  await commitToolBoundary(state, result);
8727
8727
  if (Array.isArray(result.events) && result.events.length > 0) {
8728
8728
  events.push(...result.events);
@@ -9163,7 +9163,11 @@ var ToolNode = class {
9163
9163
  nextProtocolErrorCount: fuse.nextCount
9164
9164
  });
9165
9165
  if (fuse.shouldFuse && remainingCalls.length === 0) {
9166
- throw createToolProtocolFuseError(fuse.nextCount, context.exec.error);
9166
+ return {
9167
+ kind: "interrupted",
9168
+ error: createToolProtocolFuseError(fuse.nextCount, context.exec.error),
9169
+ events: context.bridge.getRuntimeEvents()
9170
+ };
9167
9171
  }
9168
9172
  if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
9169
9173
  return { kind: "yield", events: context.bridge.getRuntimeEvents() };