@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
package/CHANGELOG.md CHANGED
@@ -14,6 +14,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
 
15
15
  ## [Unreleased]
16
16
 
17
+ ## [0.32.0] - 2026-09-04
18
+
19
+ ### Added
20
+
21
+ - Added the host-controlled `yield_after_batch` tool completion mode. Host-originated
22
+ runs can now return a fully settled tool batch without invoking the LLM or changing
23
+ the reusable tool's own `terminateRun` semantics.
24
+
25
+ ## [0.31.1] - 2026-09-03
26
+
27
+ ### Fixed
28
+
29
+ - Fixed `ToolContext` runtime capability identity across the package root, `runtime-kernel`, and `testkit` bundles. ESM and CommonJS consumers can now admit a context through one public entry and read or derive it through another without creating isolated hidden-binding registries.
30
+
17
31
  ## [0.31.0] - 2026-09-03
18
32
 
19
33
  ### Added
package/dist/cli.cjs CHANGED
@@ -7634,7 +7634,33 @@ function findCachedToolOutputByIdempotencyKey(params) {
7634
7634
  }
7635
7635
 
7636
7636
  // src/runtime-kernel/tools/toolContextRuntime.ts
7637
- var runtimeBindings = /* @__PURE__ */ new WeakMap();
7637
+ var TOOL_CONTEXT_RUNTIME_BINDINGS_KEY = /* @__PURE__ */ Symbol.for(
7638
+ "@linnlabs/linnkit/tool-context-runtime-bindings/v1"
7639
+ );
7640
+ function isRuntimeBindingRegistry(value) {
7641
+ return value instanceof WeakMap;
7642
+ }
7643
+ function resolveRuntimeBindingRegistry() {
7644
+ const existing = Reflect.get(globalThis, TOOL_CONTEXT_RUNTIME_BINDINGS_KEY);
7645
+ if (existing !== void 0) {
7646
+ if (!isRuntimeBindingRegistry(existing)) {
7647
+ throw new Error("Linnkit ToolContext runtime binding registry has an incompatible owner.");
7648
+ }
7649
+ return existing;
7650
+ }
7651
+ const registry = /* @__PURE__ */ new WeakMap();
7652
+ const installed = Reflect.defineProperty(globalThis, TOOL_CONTEXT_RUNTIME_BINDINGS_KEY, {
7653
+ value: registry,
7654
+ configurable: false,
7655
+ enumerable: false,
7656
+ writable: false
7657
+ });
7658
+ if (!installed) {
7659
+ throw new Error("Cannot install Linnkit ToolContext runtime binding registry.");
7660
+ }
7661
+ return registry;
7662
+ }
7663
+ var runtimeBindings = resolveRuntimeBindingRegistry();
7638
7664
  function toEventSource(source) {
7639
7665
  if (typeof source === "function") {
7640
7666
  return source;
@@ -8678,6 +8704,15 @@ var ToolNode = class {
8678
8704
  });
8679
8705
  return { kind: "yield", events: context.bridge.getRuntimeEvents() };
8680
8706
  }
8707
+ if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
8708
+ logger11.info("[ToolNode] \u5DE5\u5177\u6279\u6B21\u5DF2\u7ED3\u7B97\uFF0C\u6309 Host \u7B56\u7565\u76F4\u63A5 yield", {
8709
+ toolName: context.toolName,
8710
+ toolCallId: context.toolCallId,
8711
+ conversationId: context.conversationId,
8712
+ turnId: context.turnId
8713
+ });
8714
+ return { kind: "yield", events: context.bridge.getRuntimeEvents() };
8715
+ }
8681
8716
  return {
8682
8717
  kind: "route",
8683
8718
  nextNodeId: remainingCalls.length > 0 ? "tool" : "llm",
@@ -8760,6 +8795,9 @@ var ToolNode = class {
8760
8795
  if (fuse.shouldFuse && remainingCalls.length === 0) {
8761
8796
  throw createToolProtocolFuseError(fuse.nextCount, context.exec.error);
8762
8797
  }
8798
+ if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
8799
+ return { kind: "yield", events: context.bridge.getRuntimeEvents() };
8800
+ }
8763
8801
  return {
8764
8802
  kind: "route",
8765
8803
  // 同一个 assistant.tool_calls batch 必须为每个 call 产出 tool_output。
@@ -9284,7 +9322,8 @@ function createHostToolCallBootstrap(input) {
9284
9322
  conversationId,
9285
9323
  turnId,
9286
9324
  history: [...input.history ?? [], decisionEvent],
9287
- pendingToolCalls: [toolCall]
9325
+ pendingToolCalls: [toolCall],
9326
+ ...input.completionMode === void 0 ? {} : { toolBatchCompletionMode: input.completionMode }
9288
9327
  }
9289
9328
  };
9290
9329
  }