@linnlabs/linnkit 0.41.0 → 0.42.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 (54) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cli.cjs +5 -201
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +5 -201
  5. package/dist/cli.js.map +1 -1
  6. package/dist/context-manager.cjs +0 -1
  7. package/dist/context-manager.cjs.map +1 -1
  8. package/dist/context-manager.js +0 -1
  9. package/dist/context-manager.js.map +1 -1
  10. package/dist/index.cjs +6 -211
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.js +6 -211
  13. package/dist/index.js.map +1 -1
  14. package/dist/quickstart.cjs +5 -201
  15. package/dist/quickstart.cjs.map +1 -1
  16. package/dist/quickstart.js +5 -201
  17. package/dist/quickstart.js.map +1 -1
  18. package/dist/runtime-kernel/child-runs/childRunInvoker.d.cts +1 -3
  19. package/dist/runtime-kernel/child-runs/childRunInvoker.d.ts +1 -3
  20. package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.cts +1 -3
  21. package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.ts +1 -3
  22. package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.cts +1 -2
  23. package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.ts +1 -2
  24. package/dist/runtime-kernel/testkit/graphLoopHarness.d.cts +1 -2
  25. package/dist/runtime-kernel/testkit/graphLoopHarness.d.ts +1 -2
  26. package/dist/runtime-kernel/tools/index.d.cts +1 -2
  27. package/dist/runtime-kernel/tools/index.d.ts +1 -2
  28. package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.cts +4 -3
  29. package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.ts +4 -3
  30. package/dist/runtime-kernel/tools/ports.d.cts +1 -28
  31. package/dist/runtime-kernel/tools/ports.d.ts +1 -28
  32. package/dist/runtime-kernel/tools/toolContextRuntime.d.cts +1 -1
  33. package/dist/runtime-kernel/tools/toolContextRuntime.d.ts +1 -1
  34. package/dist/runtime-kernel/tools/toolContracts.d.cts +0 -6
  35. package/dist/runtime-kernel/tools/toolContracts.d.ts +0 -6
  36. package/dist/runtime-kernel/tools/toolExecutionContext.d.cts +0 -7
  37. package/dist/runtime-kernel/tools/toolExecutionContext.d.ts +0 -7
  38. package/dist/runtime-kernel.cjs +5 -206
  39. package/dist/runtime-kernel.cjs.map +1 -1
  40. package/dist/runtime-kernel.d.cts +1 -2
  41. package/dist/runtime-kernel.d.ts +1 -2
  42. package/dist/runtime-kernel.js +5 -206
  43. package/dist/runtime-kernel.js.map +1 -1
  44. package/dist/testkit/agent-harness/scriptedInferenceHarness.d.cts +1 -1
  45. package/dist/testkit/agent-harness/scriptedInferenceHarness.d.ts +1 -1
  46. package/dist/testkit.cjs +5 -206
  47. package/dist/testkit.cjs.map +1 -1
  48. package/dist/testkit.js +5 -206
  49. package/dist/testkit.js.map +1 -1
  50. package/docs/integration/tool-development-guide.md +7 -23
  51. package/docs/integration/tools.md +2 -5
  52. package/package.json +2 -2
  53. package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.cts +0 -17
  54. package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.ts +0 -17
package/CHANGELOG.md CHANGED
@@ -12,6 +12,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
12
 
13
13
  ---
14
14
 
15
+ ## [0.42.0] - 2026-11-11
16
+
17
+ ### Breaking
18
+
19
+ - Remove the tool model-input requirement protocol. `ToolRuntimeDefinition`
20
+ and `BaseTool` no longer accept `modelInputRequirement`,
21
+ `modelInputDelivery` or `resolveModelInputRequirement`;
22
+ `ToolExecutionContext.modelInputAdmission`, `ToolModelInputAdmission`,
23
+ `ToolModelInputDelivery` and `ToolModelInputCapabilityValidatorPort` are
24
+ gone, and `ToolNode`, `ChildRunInvoker` and the testkit no longer take a
25
+ `modelInputCapabilityValidator`. Whether a tool returns images is the
26
+ Host's decision: the caller may be a model or a Host-originated call with no
27
+ model, and only the Host knows which.
28
+
29
+ ### Changed
30
+
31
+ - `ToolNode` no longer checks the last successful model before running a tool
32
+ and no longer rejects Host-originated calls that have no model. Attachments a
33
+ tool declares are always passed to `ToolModelInputResolverPort`; cache hits
34
+ reuse the attachments resolved at the time.
35
+ - The LLM prepare stage exposes the tool schemas the Host provides without
36
+ filtering them by model image support or adding tool image requirements to
37
+ the request. The input preflight still validates images actually present in
38
+ the request against the active route.
39
+
15
40
  ## [0.41.0] - 2026-10-30
16
41
 
17
42
  ### Breaking
package/dist/cli.cjs CHANGED
@@ -4104,7 +4104,6 @@ var tickPipelineContextKeys = [
4104
4104
  "runtimeEventCommitPort",
4105
4105
  "modelId",
4106
4106
  "toolSchemas",
4107
- "toolModelInputRequirement",
4108
4107
  "toolCallStreamingPolicies",
4109
4108
  "llmOptions",
4110
4109
  "toolDefinitionTokens",
@@ -5007,7 +5006,6 @@ function createExecuteLlmStage(dependencies) {
5007
5006
  "outputProcessor",
5008
5007
  "modelId",
5009
5008
  "llmMessages",
5010
- "toolModelInputRequirement",
5011
5009
  "toolCallStreamingPolicies",
5012
5010
  "imageInputAdmissionEvidence",
5013
5011
  "llmOptions",
@@ -5066,7 +5064,6 @@ function createExecuteLlmStage(dependencies) {
5066
5064
  },
5067
5065
  {
5068
5066
  imageInputAdmissionEvidence: ctx.imageInputAdmissionEvidence,
5069
- additionalModelInputRequirement: ctx.toolModelInputRequirement,
5070
5067
  toolCallStreamingPolicies: ctx.toolCallStreamingPolicies,
5071
5068
  ...promptBudget && promptUsageMeasurementPolicy ? {
5072
5069
  measurePromptUsage: async (activeModelId, messages) => {
@@ -6051,29 +6048,6 @@ function createCommitContextCompactionStage() {
6051
6048
  });
6052
6049
  }
6053
6050
 
6054
- // src/runtime-kernel/graph-engine/functions/prepareModelCompatibleTools.ts
6055
- function prepareModelCompatibleTools(input) {
6056
- const schemas = [];
6057
- const requirements = [];
6058
- for (const schema of input.schemas) {
6059
- const definition = input.getToolDefinition(schema.function.name);
6060
- const requirement = definition?.modelInputRequirement;
6061
- const delivery = definition?.modelInputDelivery ?? "required";
6062
- const isRequired = delivery === "required";
6063
- if (requirement && isRequired && !evaluateModelInputCompatibility(input.model, requirement).compatible) {
6064
- continue;
6065
- }
6066
- schemas.push(schema);
6067
- if (requirement && isRequired) {
6068
- requirements.push(requirement);
6069
- }
6070
- }
6071
- return {
6072
- schemas: Object.freeze(schemas),
6073
- requirement: requirements.length > 0 ? mergeModelInputRequirements(...requirements) : EMPTY_MODEL_INPUT_REQUIREMENT
6074
- };
6075
- }
6076
-
6077
6051
  // src/runtime-kernel/graph-engine/tick-pipeline/stages/prepareCallStage.ts
6078
6052
  function createPrepareCallStage(dependencies) {
6079
6053
  return defineTickStage({
@@ -6091,7 +6065,6 @@ function createPrepareCallStage(dependencies) {
6091
6065
  writes: [
6092
6066
  "modelId",
6093
6067
  "toolSchemas",
6094
- "toolModelInputRequirement",
6095
6068
  "toolCallStreamingPolicies",
6096
6069
  "llmOptions",
6097
6070
  "toolDefinitionTokens"
@@ -6131,12 +6104,7 @@ function createPrepareCallStage(dependencies) {
6131
6104
  invocation: ctx.request
6132
6105
  });
6133
6106
  const modelConfig = dependencies.modelCatalog.getModelById(modelId);
6134
- const toolPreparation = prepareModelCompatibleTools({
6135
- schemas: candidateToolSchemas,
6136
- model: modelConfig,
6137
- getToolDefinition: (toolName) => dependencies.toolCatalog.getToolDefinition(toolName)
6138
- });
6139
- const toolSchemas = [...toolPreparation.schemas];
6107
+ const toolSchemas = [...candidateToolSchemas];
6140
6108
  const toolCallStreamingPolicies = deriveToolCallStreamingPolicies(
6141
6109
  toolSchemas,
6142
6110
  dependencies.toolCatalog
@@ -6180,7 +6148,6 @@ function createPrepareCallStage(dependencies) {
6180
6148
  return {
6181
6149
  modelId,
6182
6150
  toolSchemas,
6183
- toolModelInputRequirement: toolPreparation.requirement,
6184
6151
  toolCallStreamingPolicies,
6185
6152
  llmOptions,
6186
6153
  toolDefinitionTokens
@@ -6354,7 +6321,6 @@ var GraphAgentExecutor = class {
6354
6321
  modelId: "",
6355
6322
  toolSchemas: [],
6356
6323
  toolCallStreamingPolicies: {},
6357
- toolModelInputRequirement: void 0,
6358
6324
  llmOptions: {},
6359
6325
  toolDefinitionTokens: 0,
6360
6326
  llmMessages: [],
@@ -7606,10 +7572,6 @@ function parseToolModelInputDeclaration(value) {
7606
7572
  }
7607
7573
 
7608
7574
  // src/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.ts
7609
- var TOOL_RESULT_IMAGE_REQUIREMENT = {
7610
- requires_image_input: true,
7611
- placements: ["tool_result_image"]
7612
- };
7613
7575
  async function resolveToolModelInput(input) {
7614
7576
  if (!input.selections) {
7615
7577
  return void 0;
@@ -7630,16 +7592,6 @@ async function resolveToolModelInput(input) {
7630
7592
  if (parsed.data.some((reference, index) => reference.id !== input.selections?.[index]?.id)) {
7631
7593
  throw new ToolModelInputResolutionError("Tool model input resolver changed attachment identity or order.");
7632
7594
  }
7633
- if (!input.activeModelId) {
7634
- throw new ToolModelInputResolutionError("Missing successful LLM model for tool input validation.");
7635
- }
7636
- if (!input.capabilityValidator) {
7637
- throw new ToolModelInputResolutionError("Tool model input validator is not configured.");
7638
- }
7639
- input.capabilityValidator.assertCompatible({
7640
- activeModelId: input.activeModelId,
7641
- requirement: TOOL_RESULT_IMAGE_REQUIREMENT
7642
- });
7643
7595
  return Object.freeze(parsed.data.map((reference) => Object.freeze(reference)));
7644
7596
  }
7645
7597
 
@@ -8345,7 +8297,6 @@ var ToolNodeEventBridge = class {
8345
8297
 
8346
8298
  // src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
8347
8299
  var logger10 = new Logger("ToolNode");
8348
- var MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR = "tool.model_input.requirement_resolution_failed: Tool model input requirement could not be resolved";
8349
8300
  function parseToolArgs(call) {
8350
8301
  const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
8351
8302
  if (!rawArguments.trim()) {
@@ -8449,12 +8400,6 @@ function prepareToolExecution(params) {
8449
8400
  toolArgs,
8450
8401
  idempotencyKey
8451
8402
  });
8452
- const modelInputRequirement = resolveModelInputRequirement({
8453
- toolDefinition,
8454
- toolArgs,
8455
- hasProtocolError: protocolError !== void 0,
8456
- toolName
8457
- });
8458
8403
  return {
8459
8404
  call: params.call,
8460
8405
  toolName,
@@ -8463,30 +8408,9 @@ function prepareToolExecution(params) {
8463
8408
  toolArgs,
8464
8409
  protocolError,
8465
8410
  idempotencyKey,
8466
- ...modelInputRequirement.requirement ? { modelInputRequirement: modelInputRequirement.requirement } : {},
8467
- modelInputDelivery: toolDefinition?.modelInputDelivery ?? "required",
8468
- ...modelInputRequirement.error ? { modelInputRequirementError: modelInputRequirement.error } : {},
8469
8411
  bridge
8470
8412
  };
8471
8413
  }
8472
- function resolveModelInputRequirement(params) {
8473
- if (params.hasProtocolError) {
8474
- return {};
8475
- }
8476
- if (!params.toolDefinition?.resolveModelInputRequirement) {
8477
- return params.toolDefinition?.modelInputRequirement ? { requirement: params.toolDefinition.modelInputRequirement } : {};
8478
- }
8479
- try {
8480
- const requirement = params.toolDefinition.resolveModelInputRequirement(params.toolArgs);
8481
- return requirement ? { requirement } : {};
8482
- } catch (error) {
8483
- logger10.warn("dynamic model input requirement resolution failed", {
8484
- toolName: params.toolName,
8485
- errorName: error instanceof Error ? error.name : "UnknownError"
8486
- });
8487
- return { error: MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR };
8488
- }
8489
- }
8490
8414
  function attachWorkingHistoryView(params) {
8491
8415
  const historyEvents = parseRuntimeEvents(
8492
8416
  params.state.local?.history ?? []
@@ -8718,14 +8642,6 @@ function readToolObservationPolicy(local) {
8718
8642
  function readHistoryEvents(local) {
8719
8643
  return parseRuntimeEvents(local.history ?? []);
8720
8644
  }
8721
- function readLastSuccessfulLlmModelId(local) {
8722
- const executorLocal = local.executorLocal;
8723
- if (!isRecord9(executorLocal)) {
8724
- return void 0;
8725
- }
8726
- const value = executorLocal.lastSuccessfulLlmModelId;
8727
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
8728
- }
8729
8645
  function formatCapabilityError(error) {
8730
8646
  if (isRecord9(error)) {
8731
8647
  const codeValue = error.errorCode ?? error.code;
@@ -8737,29 +8653,12 @@ function formatCapabilityError(error) {
8737
8653
  }
8738
8654
  return error instanceof Error ? error.message : String(error);
8739
8655
  }
8740
- function bindModelInputAdmission(input) {
8741
- input.context.modelInputAdmission = Object.freeze({
8742
- requirement: Object.freeze({
8743
- ...input.requirement,
8744
- placements: Object.freeze([...input.requirement.placements])
8745
- }),
8746
- delivery: input.delivery,
8747
- admitted: input.admitted
8748
- });
8749
- }
8750
- function isOptionalImageInputIncompatibility(reason) {
8751
- return reason === "image_input_unsupported" || reason === "placement_unsupported";
8752
- }
8753
- function shouldDeliverToolModelInput(input) {
8754
- return input.delivery === "required" || input.context.modelInputAdmission?.admitted === true;
8755
- }
8756
8656
  var ToolNode = class {
8757
8657
  id = "tool";
8758
8658
  toolRuntime;
8759
8659
  observationPreview;
8760
8660
  telemetryPort;
8761
8661
  auditPort;
8762
- modelInputCapabilityValidator;
8763
8662
  modelInputResolver;
8764
8663
  idempotencyInFlight = /* @__PURE__ */ new Map();
8765
8664
  constructor(dependencies) {
@@ -8767,7 +8666,6 @@ var ToolNode = class {
8767
8666
  this.observationPreview = dependencies.observationPreview;
8768
8667
  this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
8769
8668
  this.auditPort = dependencies.auditPort ?? noopAudit;
8770
- this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
8771
8669
  this.modelInputResolver = dependencies.modelInputResolver;
8772
8670
  }
8773
8671
  /**
@@ -8933,7 +8831,6 @@ var ToolNode = class {
8933
8831
  logger11.warn("no tool name found in call");
8934
8832
  return { kind: "yield", events: [] };
8935
8833
  }
8936
- delete prepared.toolContext.modelInputAdmission;
8937
8834
  if (typeof execution.protocolError === "string") {
8938
8835
  return this.handleError({
8939
8836
  ...prepared,
@@ -8951,88 +8848,6 @@ var ToolNode = class {
8951
8848
  bridge: execution.bridge
8952
8849
  });
8953
8850
  }
8954
- if (typeof execution.modelInputRequirementError === "string") {
8955
- return this.handleError({
8956
- ...prepared,
8957
- calls,
8958
- call,
8959
- toolName: execution.toolName,
8960
- toolCallId: execution.toolCallId,
8961
- toolArgs: execution.toolArgs,
8962
- exec: {
8963
- success: false,
8964
- error: execution.modelInputRequirementError,
8965
- errorKind: "capability",
8966
- durationMs: 0
8967
- },
8968
- bridge: execution.bridge
8969
- });
8970
- }
8971
- if (execution.modelInputRequirement?.requires_image_input === true) {
8972
- const activeModelId = readLastSuccessfulLlmModelId(prepared.local);
8973
- let capabilityError;
8974
- let admitted = true;
8975
- if (!activeModelId) {
8976
- capabilityError = "llm.unsupported_capability: missing successful LLM model for tool input validation";
8977
- } else if (!this.modelInputCapabilityValidator) {
8978
- capabilityError = "llm.unsupported_capability: tool model input validator is not configured";
8979
- } else {
8980
- const validationInput = {
8981
- activeModelId,
8982
- requirement: execution.modelInputRequirement
8983
- };
8984
- if (execution.modelInputDelivery === "when_supported") {
8985
- try {
8986
- const compatibility = this.modelInputCapabilityValidator.evaluate(validationInput);
8987
- if (!compatibility.compatible) {
8988
- if (isOptionalImageInputIncompatibility(compatibility.reason)) {
8989
- admitted = false;
8990
- logger11.debug("optional tool model input omitted for incompatible active model", {
8991
- toolName: execution.toolName,
8992
- activeModelId,
8993
- reason: compatibility.reason,
8994
- placements: execution.modelInputRequirement.placements
8995
- });
8996
- } else {
8997
- this.modelInputCapabilityValidator.assertCompatible(validationInput);
8998
- capabilityError = "llm.unsupported_capability: active model is not eligible";
8999
- }
9000
- }
9001
- } catch (error) {
9002
- capabilityError = formatCapabilityError(error);
9003
- }
9004
- } else {
9005
- try {
9006
- this.modelInputCapabilityValidator.assertCompatible(validationInput);
9007
- } catch (error) {
9008
- capabilityError = formatCapabilityError(error);
9009
- }
9010
- }
9011
- }
9012
- if (capabilityError) {
9013
- return this.handleError({
9014
- ...prepared,
9015
- calls,
9016
- call,
9017
- toolName: execution.toolName,
9018
- toolCallId: execution.toolCallId,
9019
- toolArgs: execution.toolArgs,
9020
- exec: {
9021
- success: false,
9022
- error: capabilityError,
9023
- errorKind: "capability",
9024
- durationMs: 0
9025
- },
9026
- bridge: execution.bridge
9027
- });
9028
- }
9029
- bindModelInputAdmission({
9030
- context: prepared.toolContext,
9031
- requirement: execution.modelInputRequirement,
9032
- delivery: execution.modelInputDelivery,
9033
- admitted
9034
- });
9035
- }
9036
8851
  await this.emitToolDecisionAudit({
9037
8852
  action: "tool.allow",
9038
8853
  toolName: execution.toolName,
@@ -9084,21 +8899,15 @@ var ToolNode = class {
9084
8899
  bridge: execution.bridge
9085
8900
  });
9086
8901
  }
9087
- const deliverModelInput = shouldDeliverToolModelInput({
9088
- context: prepared.toolContext,
9089
- delivery: execution.modelInputDelivery
9090
- });
9091
- let attachments = deliverModelInput ? exec.cachedAttachments : void 0;
8902
+ let attachments = exec.cachedAttachments;
9092
8903
  try {
9093
- if (deliverModelInput && !attachments) {
8904
+ if (!attachments) {
9094
8905
  attachments = await resolveToolModelInput({
9095
- activeModelId: readLastSuccessfulLlmModelId(prepared.local),
9096
8906
  toolName: execution.toolName,
9097
8907
  toolCallId: execution.toolCallId,
9098
8908
  selections: contract.modelInputAttachments,
9099
8909
  context: prepared.toolContext,
9100
- resolver: this.modelInputResolver,
9101
- capabilityValidator: this.modelInputCapabilityValidator
8910
+ resolver: this.modelInputResolver
9102
8911
  });
9103
8912
  }
9104
8913
  } catch (error) {
@@ -13123,7 +12932,6 @@ function createDefaultGraphExecutor(options) {
13123
12932
  observationPreview: options.observationPreview,
13124
12933
  auditPort: options.auditPort,
13125
12934
  telemetryPort: options.telemetryPort,
13126
- modelInputCapabilityValidator: options.modelInputCapabilityValidator,
13127
12935
  modelInputResolver: options.modelInputResolver
13128
12936
  }));
13129
12937
  executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
@@ -13247,11 +13055,7 @@ var QuickstartMemoryToolRuntime = class {
13247
13055
  return {
13248
13056
  parameters: tool.parameters,
13249
13057
  validateArguments: (args) => tool["validateArguments"](args),
13250
- idempotency: tool.idempotency,
13251
- modelInputRequirement: tool.modelInputRequirement,
13252
- ...tool.resolveModelInputRequirement ? {
13253
- resolveModelInputRequirement: (args) => tool.resolveModelInputRequirement?.(args)
13254
- } : {}
13058
+ idempotency: tool.idempotency
13255
13059
  };
13256
13060
  }
13257
13061
  async executeTool(toolName, args, context) {