@linnlabs/linnkit 0.31.0 → 0.32.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cli.cjs +41 -2
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +41 -2
  5. package/dist/cli.js.map +1 -1
  6. package/dist/context-manager.cjs +29 -0
  7. package/dist/context-manager.cjs.map +1 -1
  8. package/dist/context-manager.js +29 -0
  9. package/dist/context-manager.js.map +1 -1
  10. package/dist/{defaultGraphExecutor-CO3ztZdG.d.cts → defaultGraphExecutor-Chr16eYO.d.cts} +10 -1
  11. package/dist/{defaultGraphExecutor-B2kGX0iA.d.ts → defaultGraphExecutor-hT7dchpC.d.ts} +10 -1
  12. package/dist/{index-CZtZq3T1.d.cts → index-C2PSqU1I.d.cts} +8 -3
  13. package/dist/{index-CMUnmxhM.d.ts → index-CZMXtw4h.d.ts} +8 -3
  14. package/dist/index.cjs +41 -2
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +2 -2
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.js +41 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/quickstart.cjs +41 -2
  21. package/dist/quickstart.cjs.map +1 -1
  22. package/dist/quickstart.js +41 -2
  23. package/dist/quickstart.js.map +1 -1
  24. package/dist/runtime-kernel.cjs +41 -2
  25. package/dist/runtime-kernel.cjs.map +1 -1
  26. package/dist/runtime-kernel.d.cts +2 -2
  27. package/dist/runtime-kernel.d.ts +2 -2
  28. package/dist/runtime-kernel.js +41 -2
  29. package/dist/runtime-kernel.js.map +1 -1
  30. package/dist/testkit.cjs +41 -2
  31. package/dist/testkit.cjs.map +1 -1
  32. package/dist/testkit.d.cts +2 -2
  33. package/dist/testkit.d.ts +2 -2
  34. package/dist/testkit.js +41 -2
  35. package/dist/testkit.js.map +1 -1
  36. package/docs/integration/host-originated-tools.md +9 -0
  37. package/package.json +2 -2
@@ -1,8 +1,8 @@
1
1
  import { C as CanonicalLlmUsage } from './reasoning-bffu9R2B.cjs';
2
2
  import { P as ProviderContinuation, A as AiMessage } from './provider-continuation-CTZdCB--.cjs';
3
3
  import { m as CanonicalInferenceRequest, r as LlmCallOptions, v as LlmInputMaterializerPort, i as CanonicalInferenceFinishReason, w as LlmRequestMessage } from './llm-input-materialization-r-V3n9U-.cjs';
4
- import { d as LlmCaller, a as ModelCatalogLike, aa as TelemetryEvent$2, P as DefaultRunSupervisor, W as MemoryRunRegistryStore, n as MemoryEventStore, Y as RunExecutorPort$1, Z as RunOutcome$1, q as ToolContextPatch$1 } from './defaultGraphExecutor-CO3ztZdG.cjs';
5
- export { ac as DefaultGraphExecutorOptions, ad as GraphLoopHarness, ae as GraphLoopHarnessOptions, af as GraphLoopHarnessRunResult, ag as GraphLoopLlmNodeFactoryParams, ah as createDefaultGraphExecutor, ai as createGraphLoopHarness } from './defaultGraphExecutor-CO3ztZdG.cjs';
4
+ import { d as LlmCaller, a as ModelCatalogLike, ab as TelemetryEvent$2, Q as DefaultRunSupervisor, X as MemoryRunRegistryStore, o as MemoryEventStore, Z as RunExecutorPort$1, _ as RunOutcome$1, r as ToolContextPatch$1 } from './defaultGraphExecutor-Chr16eYO.cjs';
5
+ export { ad as DefaultGraphExecutorOptions, ae as GraphLoopHarness, af as GraphLoopHarnessOptions, ag as GraphLoopHarnessRunResult, ah as GraphLoopLlmNodeFactoryParams, ai as createDefaultGraphExecutor, aj as createGraphLoopHarness } from './defaultGraphExecutor-Chr16eYO.cjs';
6
6
  import { R as RuntimeEvent, f as RoutedRuntimeEvent } from './final-answer-B0_kx5_U.cjs';
7
7
  import { b as ContextTrace } from './base-DRRrRhxS.cjs';
8
8
  import { d as AgentSpecContextPolicy, c as AgentSpec } from './token-accounting-19cXG7hM.cjs';
package/dist/testkit.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { C as CanonicalLlmUsage } from './reasoning-bffu9R2B.js';
2
2
  import { P as ProviderContinuation, A as AiMessage } from './provider-continuation-CTZdCB--.js';
3
3
  import { m as CanonicalInferenceRequest, r as LlmCallOptions, v as LlmInputMaterializerPort, i as CanonicalInferenceFinishReason, w as LlmRequestMessage } from './llm-input-materialization-Vce5Swvc.js';
4
- import { d as LlmCaller, a as ModelCatalogLike, aa as TelemetryEvent$2, P as DefaultRunSupervisor, W as MemoryRunRegistryStore, n as MemoryEventStore, Y as RunExecutorPort$1, Z as RunOutcome$1, q as ToolContextPatch$1 } from './defaultGraphExecutor-B2kGX0iA.js';
5
- export { ac as DefaultGraphExecutorOptions, ad as GraphLoopHarness, ae as GraphLoopHarnessOptions, af as GraphLoopHarnessRunResult, ag as GraphLoopLlmNodeFactoryParams, ah as createDefaultGraphExecutor, ai as createGraphLoopHarness } from './defaultGraphExecutor-B2kGX0iA.js';
4
+ import { d as LlmCaller, a as ModelCatalogLike, ab as TelemetryEvent$2, Q as DefaultRunSupervisor, X as MemoryRunRegistryStore, o as MemoryEventStore, Z as RunExecutorPort$1, _ as RunOutcome$1, r as ToolContextPatch$1 } from './defaultGraphExecutor-hT7dchpC.js';
5
+ export { ad as DefaultGraphExecutorOptions, ae as GraphLoopHarness, af as GraphLoopHarnessOptions, ag as GraphLoopHarnessRunResult, ah as GraphLoopLlmNodeFactoryParams, ai as createDefaultGraphExecutor, aj as createGraphLoopHarness } from './defaultGraphExecutor-hT7dchpC.js';
6
6
  import { R as RuntimeEvent, f as RoutedRuntimeEvent } from './final-answer-oOQ_7nPt.js';
7
7
  import { b as ContextTrace } from './base-DVyQIl_d.js';
8
8
  import { d as AgentSpecContextPolicy, c as AgentSpec } from './token-accounting-CVW37Uri.js';
package/dist/testkit.js CHANGED
@@ -7951,7 +7951,33 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
7951
7951
  "parentToolCallId",
7952
7952
  "modelInputAdmission"
7953
7953
  ];
7954
- var runtimeBindings = /* @__PURE__ */ new WeakMap();
7954
+ var TOOL_CONTEXT_RUNTIME_BINDINGS_KEY = /* @__PURE__ */ Symbol.for(
7955
+ "@linnlabs/linnkit/tool-context-runtime-bindings/v1"
7956
+ );
7957
+ function isRuntimeBindingRegistry(value) {
7958
+ return value instanceof WeakMap;
7959
+ }
7960
+ function resolveRuntimeBindingRegistry() {
7961
+ const existing = Reflect.get(globalThis, TOOL_CONTEXT_RUNTIME_BINDINGS_KEY);
7962
+ if (existing !== void 0) {
7963
+ if (!isRuntimeBindingRegistry(existing)) {
7964
+ throw new Error("Linnkit ToolContext runtime binding registry has an incompatible owner.");
7965
+ }
7966
+ return existing;
7967
+ }
7968
+ const registry = /* @__PURE__ */ new WeakMap();
7969
+ const installed = Reflect.defineProperty(globalThis, TOOL_CONTEXT_RUNTIME_BINDINGS_KEY, {
7970
+ value: registry,
7971
+ configurable: false,
7972
+ enumerable: false,
7973
+ writable: false
7974
+ });
7975
+ if (!installed) {
7976
+ throw new Error("Cannot install Linnkit ToolContext runtime binding registry.");
7977
+ }
7978
+ return registry;
7979
+ }
7980
+ var runtimeBindings = resolveRuntimeBindingRegistry();
7955
7981
  function toEventSource(source) {
7956
7982
  if (typeof source === "function") {
7957
7983
  return source;
@@ -9043,6 +9069,15 @@ var ToolNode = class {
9043
9069
  });
9044
9070
  return { kind: "yield", events: context.bridge.getRuntimeEvents() };
9045
9071
  }
9072
+ if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
9073
+ logger11.info("[ToolNode] \u5DE5\u5177\u6279\u6B21\u5DF2\u7ED3\u7B97\uFF0C\u6309 Host \u7B56\u7565\u76F4\u63A5 yield", {
9074
+ toolName: context.toolName,
9075
+ toolCallId: context.toolCallId,
9076
+ conversationId: context.conversationId,
9077
+ turnId: context.turnId
9078
+ });
9079
+ return { kind: "yield", events: context.bridge.getRuntimeEvents() };
9080
+ }
9046
9081
  return {
9047
9082
  kind: "route",
9048
9083
  nextNodeId: remainingCalls.length > 0 ? "tool" : "llm",
@@ -9125,6 +9160,9 @@ var ToolNode = class {
9125
9160
  if (fuse.shouldFuse && remainingCalls.length === 0) {
9126
9161
  throw createToolProtocolFuseError(fuse.nextCount, context.exec.error);
9127
9162
  }
9163
+ if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
9164
+ return { kind: "yield", events: context.bridge.getRuntimeEvents() };
9165
+ }
9128
9166
  return {
9129
9167
  kind: "route",
9130
9168
  // 同一个 assistant.tool_calls batch 必须为每个 call 产出 tool_output。
@@ -9649,7 +9687,8 @@ function createHostToolCallBootstrap(input) {
9649
9687
  conversationId,
9650
9688
  turnId,
9651
9689
  history: [...input.history ?? [], decisionEvent],
9652
- pendingToolCalls: [toolCall]
9690
+ pendingToolCalls: [toolCall],
9691
+ ...input.completionMode === void 0 ? {} : { toolBatchCompletionMode: input.completionMode }
9653
9692
  }
9654
9693
  };
9655
9694
  }