@linnlabs/linnkit 0.41.0 → 0.43.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 (78) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/cli.cjs +17 -202
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +17 -202
  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/contracts/agentSpec.d.cts +5 -5
  11. package/dist/contracts/agentSpec.d.ts +5 -5
  12. package/dist/contracts/audit.d.cts +10 -10
  13. package/dist/contracts/audit.d.ts +10 -10
  14. package/dist/contracts/contextPolicy.d.cts +14 -14
  15. package/dist/contracts/contextPolicy.d.ts +14 -14
  16. package/dist/contracts/events.d.cts +117 -117
  17. package/dist/contracts/events.d.ts +117 -117
  18. package/dist/contracts/execution.d.cts +2 -2
  19. package/dist/contracts/execution.d.ts +2 -2
  20. package/dist/contracts/llm-retry.d.cts +2 -2
  21. package/dist/contracts/llm-retry.d.ts +2 -2
  22. package/dist/contracts/messages.d.cts +32 -32
  23. package/dist/contracts/messages.d.ts +32 -32
  24. package/dist/contracts/sse.d.cts +97 -97
  25. package/dist/contracts/sse.d.ts +97 -97
  26. package/dist/contracts/sub-run-trace-payload.d.cts +8 -8
  27. package/dist/contracts/sub-run-trace-payload.d.ts +8 -8
  28. package/dist/contracts/token-accounting.d.cts +12 -12
  29. package/dist/contracts/token-accounting.d.ts +12 -12
  30. package/dist/index.cjs +18 -212
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.js +18 -212
  33. package/dist/index.js.map +1 -1
  34. package/dist/quickstart.cjs +17 -202
  35. package/dist/quickstart.cjs.map +1 -1
  36. package/dist/quickstart.js +17 -202
  37. package/dist/quickstart.js.map +1 -1
  38. package/dist/runtime-kernel/child-runs/childRunInvoker.d.cts +1 -3
  39. package/dist/runtime-kernel/child-runs/childRunInvoker.d.ts +1 -3
  40. package/dist/runtime-kernel/events/agentEvents.d.cts +2 -2
  41. package/dist/runtime-kernel/events/agentEvents.d.ts +2 -2
  42. package/dist/runtime-kernel/graph-engine/engine.d.cts +1 -0
  43. package/dist/runtime-kernel/graph-engine/engine.d.ts +1 -0
  44. package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.cts +1 -3
  45. package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.ts +1 -3
  46. package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.cts +1 -2
  47. package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.ts +1 -2
  48. package/dist/runtime-kernel/testkit/graphLoopHarness.d.cts +1 -2
  49. package/dist/runtime-kernel/testkit/graphLoopHarness.d.ts +1 -2
  50. package/dist/runtime-kernel/tools/index.d.cts +1 -2
  51. package/dist/runtime-kernel/tools/index.d.ts +1 -2
  52. package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.cts +4 -3
  53. package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.ts +4 -3
  54. package/dist/runtime-kernel/tools/ports.d.cts +1 -28
  55. package/dist/runtime-kernel/tools/ports.d.ts +1 -28
  56. package/dist/runtime-kernel/tools/toolContextRuntime.d.cts +1 -1
  57. package/dist/runtime-kernel/tools/toolContextRuntime.d.ts +1 -1
  58. package/dist/runtime-kernel/tools/toolContracts.d.cts +0 -6
  59. package/dist/runtime-kernel/tools/toolContracts.d.ts +0 -6
  60. package/dist/runtime-kernel/tools/toolExecutionContext.d.cts +0 -7
  61. package/dist/runtime-kernel/tools/toolExecutionContext.d.ts +0 -7
  62. package/dist/runtime-kernel.cjs +17 -207
  63. package/dist/runtime-kernel.cjs.map +1 -1
  64. package/dist/runtime-kernel.d.cts +1 -2
  65. package/dist/runtime-kernel.d.ts +1 -2
  66. package/dist/runtime-kernel.js +17 -207
  67. package/dist/runtime-kernel.js.map +1 -1
  68. package/dist/testkit/agent-harness/scriptedInferenceHarness.d.cts +1 -1
  69. package/dist/testkit/agent-harness/scriptedInferenceHarness.d.ts +1 -1
  70. package/dist/testkit.cjs +17 -207
  71. package/dist/testkit.cjs.map +1 -1
  72. package/dist/testkit.js +17 -207
  73. package/dist/testkit.js.map +1 -1
  74. package/docs/integration/tool-development-guide.md +8 -23
  75. package/docs/integration/tools.md +2 -5
  76. package/package.json +2 -2
  77. package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.cts +0 -17
  78. package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.ts +0 -17
@@ -68,7 +68,7 @@ export { MemoryEventStore } from './runtime-kernel/graph-engine/event-store/memo
68
68
  export { ModelCatalogEntry, ModelCatalogLike, createFixedChatModelCatalog } from './runtime-kernel/llm/modelCatalog.cjs';
69
69
  export { ModelReasoningConfig, REASONING_EFFORTS, ReasoningEffort, isValidReasoningEffort, resolveEffectiveEffort } from './contracts/reasoning.cjs';
70
70
  export { ModelResolver } from './runtime-kernel/llm/modelResolver.cjs';
71
- export { ObservationPreviewContext, ObservationPreviewMeta, ObservationPreviewPort, ObservationPreviewResult, ToolCatalogPort, ToolExecutionPort, ToolExecutionResult, ToolModelInputCapabilityValidatorPort, ToolRuntimeDefinition, ToolRuntimePort, ToolSchemaBuildRequest } from './runtime-kernel/tools/ports.cjs';
71
+ export { ObservationPreviewContext, ObservationPreviewMeta, ObservationPreviewPort, ObservationPreviewResult, ToolCatalogPort, ToolExecutionPort, ToolExecutionResult, ToolRuntimeDefinition, ToolRuntimePort, ToolSchemaBuildRequest } from './runtime-kernel/tools/ports.cjs';
72
72
  export { PRIMARY_PROMPT_CAPACITY_ERROR_CODE, PrimaryPromptCapacityError, PrimaryPromptCapacityErrorMetadata } from './runtime-kernel/graph-engine/definitions/primaryPromptCapacityError.cjs';
73
73
  export { PrimaryPromptCapacityAdmission, evaluatePrimaryPromptCapacity } from './runtime-kernel/graph-engine/functions/evaluatePrimaryPromptCapacity.cjs';
74
74
  export { ProviderContinuation } from './contracts/provider-continuation.cjs';
@@ -81,7 +81,6 @@ export { SystemReminderRegistry, createDefaultSystemReminderRegistry, defaultSys
81
81
  export { ToolContextConversationView } from './runtime-kernel/tools/conversationView.cjs';
82
82
  export { ToolContextPatch } from './runtime-kernel/tools/toolContextPatch.cjs';
83
83
  export { ToolExecutionContext } from './runtime-kernel/tools/toolExecutionContext.cjs';
84
- export { ToolModelInputAdmission, ToolModelInputDelivery } from './runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.cjs';
85
84
  export { ToolModelInputDeclarationValidation, parseToolModelInputDeclaration } from './runtime-kernel/tools/model-input/functions/parseToolModelInputDeclaration.cjs';
86
85
  export { ToolNode } from './runtime-kernel/graph-engine/nodes/toolNode.cjs';
87
86
  export { ToolParameterSchemaError, assertToolParameterSchema } from './runtime-kernel/tools/schema/functions/assertToolParameterSchema.cjs';
@@ -68,7 +68,7 @@ export { MemoryEventStore } from './runtime-kernel/graph-engine/event-store/memo
68
68
  export { ModelCatalogEntry, ModelCatalogLike, createFixedChatModelCatalog } from './runtime-kernel/llm/modelCatalog.js';
69
69
  export { ModelReasoningConfig, REASONING_EFFORTS, ReasoningEffort, isValidReasoningEffort, resolveEffectiveEffort } from './contracts/reasoning.js';
70
70
  export { ModelResolver } from './runtime-kernel/llm/modelResolver.js';
71
- export { ObservationPreviewContext, ObservationPreviewMeta, ObservationPreviewPort, ObservationPreviewResult, ToolCatalogPort, ToolExecutionPort, ToolExecutionResult, ToolModelInputCapabilityValidatorPort, ToolRuntimeDefinition, ToolRuntimePort, ToolSchemaBuildRequest } from './runtime-kernel/tools/ports.js';
71
+ export { ObservationPreviewContext, ObservationPreviewMeta, ObservationPreviewPort, ObservationPreviewResult, ToolCatalogPort, ToolExecutionPort, ToolExecutionResult, ToolRuntimeDefinition, ToolRuntimePort, ToolSchemaBuildRequest } from './runtime-kernel/tools/ports.js';
72
72
  export { PRIMARY_PROMPT_CAPACITY_ERROR_CODE, PrimaryPromptCapacityError, PrimaryPromptCapacityErrorMetadata } from './runtime-kernel/graph-engine/definitions/primaryPromptCapacityError.js';
73
73
  export { PrimaryPromptCapacityAdmission, evaluatePrimaryPromptCapacity } from './runtime-kernel/graph-engine/functions/evaluatePrimaryPromptCapacity.js';
74
74
  export { ProviderContinuation } from './contracts/provider-continuation.js';
@@ -81,7 +81,6 @@ export { SystemReminderRegistry, createDefaultSystemReminderRegistry, defaultSys
81
81
  export { ToolContextConversationView } from './runtime-kernel/tools/conversationView.js';
82
82
  export { ToolContextPatch } from './runtime-kernel/tools/toolContextPatch.js';
83
83
  export { ToolExecutionContext } from './runtime-kernel/tools/toolExecutionContext.js';
84
- export { ToolModelInputAdmission, ToolModelInputDelivery } from './runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.js';
85
84
  export { ToolModelInputDeclarationValidation, parseToolModelInputDeclaration } from './runtime-kernel/tools/model-input/functions/parseToolModelInputDeclaration.js';
86
85
  export { ToolNode } from './runtime-kernel/graph-engine/nodes/toolNode.js';
87
86
  export { ToolParameterSchemaError, assertToolParameterSchema } from './runtime-kernel/tools/schema/functions/assertToolParameterSchema.js';
@@ -3009,6 +3009,16 @@ function mergeResumeSessionLocal(persistedLocal, localPatch) {
3009
3009
  }
3010
3010
  };
3011
3011
  }
3012
+ function resolveResumeNodeId(local, requested) {
3013
+ const pending = local?.pendingToolCalls;
3014
+ if (!Array.isArray(pending) || pending.length === 0) return requested ?? "llm";
3015
+ if (requested !== void 0 && requested !== "tool") {
3016
+ throw new Error(
3017
+ `Graph resume must first run ${pending.length} pending tool call(s) from the interrupted batch: requested node=${requested}`
3018
+ );
3019
+ }
3020
+ return "tool";
3021
+ }
3012
3022
  var GraphExecutor = class {
3013
3023
  constructor(checkpointer, config = {}) {
3014
3024
  this.checkpointer = checkpointer;
@@ -3121,13 +3131,14 @@ var GraphExecutor = class {
3121
3131
  );
3122
3132
  }
3123
3133
  const resumedLocal = mergeResumeSessionLocal(current.local, input.localPatch);
3134
+ const nodeId = resolveResumeNodeId(resumedLocal, input.nodeId);
3124
3135
  if (this.executionCheckpointPort && current.local?.executorLocal) {
3125
3136
  resumedLocal.executorLocal = { ...current.local.executorLocal };
3126
3137
  }
3127
3138
  this.ephemeralLocals.set(checkpointKey, resumedLocal);
3128
3139
  await this.commitCheckpoint(checkpointKey, {
3129
3140
  ...current,
3130
- nodeId: input.nodeId ?? "llm",
3141
+ nodeId,
3131
3142
  ...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
3132
3143
  revision: currentRevision + 1,
3133
3144
  local: sanitizeCheckpointLocal(resumedLocal)
@@ -4008,7 +4019,6 @@ var tickPipelineContextKeys = [
4008
4019
  "runtimeEventCommitPort",
4009
4020
  "modelId",
4010
4021
  "toolSchemas",
4011
- "toolModelInputRequirement",
4012
4022
  "toolCallStreamingPolicies",
4013
4023
  "llmOptions",
4014
4024
  "toolDefinitionTokens",
@@ -5129,7 +5139,6 @@ function createExecuteLlmStage(dependencies) {
5129
5139
  "outputProcessor",
5130
5140
  "modelId",
5131
5141
  "llmMessages",
5132
- "toolModelInputRequirement",
5133
5142
  "toolCallStreamingPolicies",
5134
5143
  "imageInputAdmissionEvidence",
5135
5144
  "llmOptions",
@@ -5188,7 +5197,6 @@ function createExecuteLlmStage(dependencies) {
5188
5197
  },
5189
5198
  {
5190
5199
  imageInputAdmissionEvidence: ctx.imageInputAdmissionEvidence,
5191
- additionalModelInputRequirement: ctx.toolModelInputRequirement,
5192
5200
  toolCallStreamingPolicies: ctx.toolCallStreamingPolicies,
5193
5201
  ...promptBudget && promptUsageMeasurementPolicy ? {
5194
5202
  measurePromptUsage: async (activeModelId, messages) => {
@@ -6173,29 +6181,6 @@ function createCommitContextCompactionStage() {
6173
6181
  });
6174
6182
  }
6175
6183
 
6176
- // src/runtime-kernel/graph-engine/functions/prepareModelCompatibleTools.ts
6177
- function prepareModelCompatibleTools(input) {
6178
- const schemas = [];
6179
- const requirements = [];
6180
- for (const schema of input.schemas) {
6181
- const definition = input.getToolDefinition(schema.function.name);
6182
- const requirement = definition?.modelInputRequirement;
6183
- const delivery = definition?.modelInputDelivery ?? "required";
6184
- const isRequired = delivery === "required";
6185
- if (requirement && isRequired && !evaluateModelInputCompatibility(input.model, requirement).compatible) {
6186
- continue;
6187
- }
6188
- schemas.push(schema);
6189
- if (requirement && isRequired) {
6190
- requirements.push(requirement);
6191
- }
6192
- }
6193
- return {
6194
- schemas: Object.freeze(schemas),
6195
- requirement: requirements.length > 0 ? mergeModelInputRequirements(...requirements) : EMPTY_MODEL_INPUT_REQUIREMENT
6196
- };
6197
- }
6198
-
6199
6184
  // src/runtime-kernel/graph-engine/tick-pipeline/stages/prepareCallStage.ts
6200
6185
  function createPrepareCallStage(dependencies) {
6201
6186
  return defineTickStage({
@@ -6213,7 +6198,6 @@ function createPrepareCallStage(dependencies) {
6213
6198
  writes: [
6214
6199
  "modelId",
6215
6200
  "toolSchemas",
6216
- "toolModelInputRequirement",
6217
6201
  "toolCallStreamingPolicies",
6218
6202
  "llmOptions",
6219
6203
  "toolDefinitionTokens"
@@ -6253,12 +6237,7 @@ function createPrepareCallStage(dependencies) {
6253
6237
  invocation: ctx.request
6254
6238
  });
6255
6239
  const modelConfig = dependencies.modelCatalog.getModelById(modelId);
6256
- const toolPreparation = prepareModelCompatibleTools({
6257
- schemas: candidateToolSchemas,
6258
- model: modelConfig,
6259
- getToolDefinition: (toolName) => dependencies.toolCatalog.getToolDefinition(toolName)
6260
- });
6261
- const toolSchemas = [...toolPreparation.schemas];
6240
+ const toolSchemas = [...candidateToolSchemas];
6262
6241
  const toolCallStreamingPolicies = deriveToolCallStreamingPolicies(
6263
6242
  toolSchemas,
6264
6243
  dependencies.toolCatalog
@@ -6302,7 +6281,6 @@ function createPrepareCallStage(dependencies) {
6302
6281
  return {
6303
6282
  modelId,
6304
6283
  toolSchemas,
6305
- toolModelInputRequirement: toolPreparation.requirement,
6306
6284
  toolCallStreamingPolicies,
6307
6285
  llmOptions,
6308
6286
  toolDefinitionTokens
@@ -6476,7 +6454,6 @@ var GraphAgentExecutor = class {
6476
6454
  modelId: "",
6477
6455
  toolSchemas: [],
6478
6456
  toolCallStreamingPolicies: {},
6479
- toolModelInputRequirement: void 0,
6480
6457
  llmOptions: {},
6481
6458
  toolDefinitionTokens: 0,
6482
6459
  llmMessages: [],
@@ -7728,10 +7705,6 @@ function parseToolModelInputDeclaration(value) {
7728
7705
  }
7729
7706
 
7730
7707
  // src/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.ts
7731
- var TOOL_RESULT_IMAGE_REQUIREMENT = {
7732
- requires_image_input: true,
7733
- placements: ["tool_result_image"]
7734
- };
7735
7708
  async function resolveToolModelInput(input) {
7736
7709
  if (!input.selections) {
7737
7710
  return void 0;
@@ -7752,16 +7725,6 @@ async function resolveToolModelInput(input) {
7752
7725
  if (parsed.data.some((reference, index) => reference.id !== input.selections?.[index]?.id)) {
7753
7726
  throw new ToolModelInputResolutionError("Tool model input resolver changed attachment identity or order.");
7754
7727
  }
7755
- if (!input.activeModelId) {
7756
- throw new ToolModelInputResolutionError("Missing successful LLM model for tool input validation.");
7757
- }
7758
- if (!input.capabilityValidator) {
7759
- throw new ToolModelInputResolutionError("Tool model input validator is not configured.");
7760
- }
7761
- input.capabilityValidator.assertCompatible({
7762
- activeModelId: input.activeModelId,
7763
- requirement: TOOL_RESULT_IMAGE_REQUIREMENT
7764
- });
7765
7728
  return Object.freeze(parsed.data.map((reference) => Object.freeze(reference)));
7766
7729
  }
7767
7730
 
@@ -8226,8 +8189,7 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
8226
8189
  "parentRunId",
8227
8190
  "childRunDepth",
8228
8191
  "childRunContextInjections",
8229
- "parentToolCallId",
8230
- "modelInputAdmission"
8192
+ "parentToolCallId"
8231
8193
  ];
8232
8194
  var TOOL_CONTEXT_RUNTIME_BINDINGS_KEY = /* @__PURE__ */ Symbol.for(
8233
8195
  "@linnlabs/linnkit/tool-context-runtime-bindings/v1"
@@ -8528,7 +8490,6 @@ var ToolNodeEventBridge = class {
8528
8490
 
8529
8491
  // src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
8530
8492
  var logger10 = new Logger("ToolNode");
8531
- var MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR = "tool.model_input.requirement_resolution_failed: Tool model input requirement could not be resolved";
8532
8493
  function parseToolArgs(call) {
8533
8494
  const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
8534
8495
  if (!rawArguments.trim()) {
@@ -8632,12 +8593,6 @@ function prepareToolExecution(params) {
8632
8593
  toolArgs,
8633
8594
  idempotencyKey
8634
8595
  });
8635
- const modelInputRequirement = resolveModelInputRequirement({
8636
- toolDefinition,
8637
- toolArgs,
8638
- hasProtocolError: protocolError !== void 0,
8639
- toolName
8640
- });
8641
8596
  return {
8642
8597
  call: params.call,
8643
8598
  toolName,
@@ -8646,30 +8601,9 @@ function prepareToolExecution(params) {
8646
8601
  toolArgs,
8647
8602
  protocolError,
8648
8603
  idempotencyKey,
8649
- ...modelInputRequirement.requirement ? { modelInputRequirement: modelInputRequirement.requirement } : {},
8650
- modelInputDelivery: toolDefinition?.modelInputDelivery ?? "required",
8651
- ...modelInputRequirement.error ? { modelInputRequirementError: modelInputRequirement.error } : {},
8652
8604
  bridge
8653
8605
  };
8654
8606
  }
8655
- function resolveModelInputRequirement(params) {
8656
- if (params.hasProtocolError) {
8657
- return {};
8658
- }
8659
- if (!params.toolDefinition?.resolveModelInputRequirement) {
8660
- return params.toolDefinition?.modelInputRequirement ? { requirement: params.toolDefinition.modelInputRequirement } : {};
8661
- }
8662
- try {
8663
- const requirement = params.toolDefinition.resolveModelInputRequirement(params.toolArgs);
8664
- return requirement ? { requirement } : {};
8665
- } catch (error) {
8666
- logger10.warn("dynamic model input requirement resolution failed", {
8667
- toolName: params.toolName,
8668
- errorName: error instanceof Error ? error.name : "UnknownError"
8669
- });
8670
- return { error: MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR };
8671
- }
8672
- }
8673
8607
  function attachWorkingHistoryView(params) {
8674
8608
  const historyEvents = parseRuntimeEvents(
8675
8609
  params.state.local?.history ?? []
@@ -8901,14 +8835,6 @@ function readToolObservationPolicy(local) {
8901
8835
  function readHistoryEvents(local) {
8902
8836
  return parseRuntimeEvents(local.history ?? []);
8903
8837
  }
8904
- function readLastSuccessfulLlmModelId(local) {
8905
- const executorLocal = local.executorLocal;
8906
- if (!isRecord9(executorLocal)) {
8907
- return void 0;
8908
- }
8909
- const value = executorLocal.lastSuccessfulLlmModelId;
8910
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
8911
- }
8912
8838
  function formatCapabilityError(error) {
8913
8839
  if (isRecord9(error)) {
8914
8840
  const codeValue = error.errorCode ?? error.code;
@@ -8920,29 +8846,12 @@ function formatCapabilityError(error) {
8920
8846
  }
8921
8847
  return error instanceof Error ? error.message : String(error);
8922
8848
  }
8923
- function bindModelInputAdmission(input) {
8924
- input.context.modelInputAdmission = Object.freeze({
8925
- requirement: Object.freeze({
8926
- ...input.requirement,
8927
- placements: Object.freeze([...input.requirement.placements])
8928
- }),
8929
- delivery: input.delivery,
8930
- admitted: input.admitted
8931
- });
8932
- }
8933
- function isOptionalImageInputIncompatibility(reason) {
8934
- return reason === "image_input_unsupported" || reason === "placement_unsupported";
8935
- }
8936
- function shouldDeliverToolModelInput(input) {
8937
- return input.delivery === "required" || input.context.modelInputAdmission?.admitted === true;
8938
- }
8939
8849
  var ToolNode = class {
8940
8850
  id = "tool";
8941
8851
  toolRuntime;
8942
8852
  observationPreview;
8943
8853
  telemetryPort;
8944
8854
  auditPort;
8945
- modelInputCapabilityValidator;
8946
8855
  modelInputResolver;
8947
8856
  idempotencyInFlight = /* @__PURE__ */ new Map();
8948
8857
  constructor(dependencies) {
@@ -8950,7 +8859,6 @@ var ToolNode = class {
8950
8859
  this.observationPreview = dependencies.observationPreview;
8951
8860
  this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
8952
8861
  this.auditPort = dependencies.auditPort ?? noopAudit;
8953
- this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
8954
8862
  this.modelInputResolver = dependencies.modelInputResolver;
8955
8863
  }
8956
8864
  /**
@@ -9116,7 +9024,6 @@ var ToolNode = class {
9116
9024
  logger11.warn("no tool name found in call");
9117
9025
  return { kind: "yield", events: [] };
9118
9026
  }
9119
- delete prepared.toolContext.modelInputAdmission;
9120
9027
  if (typeof execution.protocolError === "string") {
9121
9028
  return this.handleError({
9122
9029
  ...prepared,
@@ -9134,88 +9041,6 @@ var ToolNode = class {
9134
9041
  bridge: execution.bridge
9135
9042
  });
9136
9043
  }
9137
- if (typeof execution.modelInputRequirementError === "string") {
9138
- return this.handleError({
9139
- ...prepared,
9140
- calls,
9141
- call,
9142
- toolName: execution.toolName,
9143
- toolCallId: execution.toolCallId,
9144
- toolArgs: execution.toolArgs,
9145
- exec: {
9146
- success: false,
9147
- error: execution.modelInputRequirementError,
9148
- errorKind: "capability",
9149
- durationMs: 0
9150
- },
9151
- bridge: execution.bridge
9152
- });
9153
- }
9154
- if (execution.modelInputRequirement?.requires_image_input === true) {
9155
- const activeModelId = readLastSuccessfulLlmModelId(prepared.local);
9156
- let capabilityError;
9157
- let admitted = true;
9158
- if (!activeModelId) {
9159
- capabilityError = "llm.unsupported_capability: missing successful LLM model for tool input validation";
9160
- } else if (!this.modelInputCapabilityValidator) {
9161
- capabilityError = "llm.unsupported_capability: tool model input validator is not configured";
9162
- } else {
9163
- const validationInput = {
9164
- activeModelId,
9165
- requirement: execution.modelInputRequirement
9166
- };
9167
- if (execution.modelInputDelivery === "when_supported") {
9168
- try {
9169
- const compatibility = this.modelInputCapabilityValidator.evaluate(validationInput);
9170
- if (!compatibility.compatible) {
9171
- if (isOptionalImageInputIncompatibility(compatibility.reason)) {
9172
- admitted = false;
9173
- logger11.debug("optional tool model input omitted for incompatible active model", {
9174
- toolName: execution.toolName,
9175
- activeModelId,
9176
- reason: compatibility.reason,
9177
- placements: execution.modelInputRequirement.placements
9178
- });
9179
- } else {
9180
- this.modelInputCapabilityValidator.assertCompatible(validationInput);
9181
- capabilityError = "llm.unsupported_capability: active model is not eligible";
9182
- }
9183
- }
9184
- } catch (error) {
9185
- capabilityError = formatCapabilityError(error);
9186
- }
9187
- } else {
9188
- try {
9189
- this.modelInputCapabilityValidator.assertCompatible(validationInput);
9190
- } catch (error) {
9191
- capabilityError = formatCapabilityError(error);
9192
- }
9193
- }
9194
- }
9195
- if (capabilityError) {
9196
- return this.handleError({
9197
- ...prepared,
9198
- calls,
9199
- call,
9200
- toolName: execution.toolName,
9201
- toolCallId: execution.toolCallId,
9202
- toolArgs: execution.toolArgs,
9203
- exec: {
9204
- success: false,
9205
- error: capabilityError,
9206
- errorKind: "capability",
9207
- durationMs: 0
9208
- },
9209
- bridge: execution.bridge
9210
- });
9211
- }
9212
- bindModelInputAdmission({
9213
- context: prepared.toolContext,
9214
- requirement: execution.modelInputRequirement,
9215
- delivery: execution.modelInputDelivery,
9216
- admitted
9217
- });
9218
- }
9219
9044
  await this.emitToolDecisionAudit({
9220
9045
  action: "tool.allow",
9221
9046
  toolName: execution.toolName,
@@ -9267,21 +9092,15 @@ var ToolNode = class {
9267
9092
  bridge: execution.bridge
9268
9093
  });
9269
9094
  }
9270
- const deliverModelInput = shouldDeliverToolModelInput({
9271
- context: prepared.toolContext,
9272
- delivery: execution.modelInputDelivery
9273
- });
9274
- let attachments = deliverModelInput ? exec.cachedAttachments : void 0;
9095
+ let attachments = exec.cachedAttachments;
9275
9096
  try {
9276
- if (deliverModelInput && !attachments) {
9097
+ if (!attachments) {
9277
9098
  attachments = await resolveToolModelInput({
9278
- activeModelId: readLastSuccessfulLlmModelId(prepared.local),
9279
9099
  toolName: execution.toolName,
9280
9100
  toolCallId: execution.toolCallId,
9281
9101
  selections: contract.modelInputAttachments,
9282
9102
  context: prepared.toolContext,
9283
- resolver: this.modelInputResolver,
9284
- capabilityValidator: this.modelInputCapabilityValidator
9103
+ resolver: this.modelInputResolver
9285
9104
  });
9286
9105
  }
9287
9106
  } catch (error) {
@@ -9990,10 +9809,6 @@ function formatUnknownToolArguments(fields, allowedFields) {
9990
9809
  // src/runtime-kernel/tools/toolContracts.ts
9991
9810
  var BaseTool = class {
9992
9811
  idempotency;
9993
- modelInputRequirement;
9994
- /** 模型输入是工具成功的必要结果,还是仅在当前模型支持时提供的增强反馈。 */
9995
- modelInputDelivery;
9996
- resolveModelInputRequirement;
9997
9812
  streaming;
9998
9813
  getExecutionSummary(output) {
9999
9814
  const FULL_CONTENT_THRESHOLD = 200;
@@ -12271,7 +12086,6 @@ var ChildRunInvoker = class {
12271
12086
  createLlmNode;
12272
12087
  toolRuntime;
12273
12088
  observationPreview;
12274
- modelInputCapabilityValidator;
12275
12089
  modelInputResolver;
12276
12090
  eventToMessageConverter;
12277
12091
  defaultJudgeToolName;
@@ -12282,7 +12096,6 @@ var ChildRunInvoker = class {
12282
12096
  this.createLlmNode = dependencies.createLlmNode;
12283
12097
  this.toolRuntime = dependencies.toolRuntime;
12284
12098
  this.observationPreview = dependencies.observationPreview;
12285
- this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
12286
12099
  this.modelInputResolver = dependencies.modelInputResolver;
12287
12100
  this.eventToMessageConverter = dependencies.eventToMessageConverter;
12288
12101
  this.defaultJudgeToolName = dependencies.defaultJudgeToolName;
@@ -12545,7 +12358,6 @@ var ChildRunInvoker = class {
12545
12358
  observationPreview: this.observationPreview,
12546
12359
  telemetryPort: this.telemetryPort,
12547
12360
  auditPort: this.auditPort,
12548
- modelInputCapabilityValidator: this.modelInputCapabilityValidator,
12549
12361
  modelInputResolver: this.modelInputResolver
12550
12362
  }));
12551
12363
  graph.registerNode(new WaitUserNode({ auditPort: this.auditPort }));
@@ -14655,7 +14467,6 @@ function createDefaultGraphExecutor(options) {
14655
14467
  observationPreview: options.observationPreview,
14656
14468
  auditPort: options.auditPort,
14657
14469
  telemetryPort: options.telemetryPort,
14658
- modelInputCapabilityValidator: options.modelInputCapabilityValidator,
14659
14470
  modelInputResolver: options.modelInputResolver
14660
14471
  }));
14661
14472
  executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
@@ -14694,7 +14505,6 @@ function createGraphLoopHarness(options) {
14694
14505
  maxSteps,
14695
14506
  auditPort: options.auditPort,
14696
14507
  telemetryPort: options.telemetryPort,
14697
- modelInputCapabilityValidator: options.modelInputCapabilityValidator,
14698
14508
  modelInputResolver: options.modelInputResolver
14699
14509
  });
14700
14510
  const local = {