@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.
- package/CHANGELOG.md +25 -0
- package/dist/cli.cjs +5 -201
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +5 -201
- package/dist/cli.js.map +1 -1
- package/dist/context-manager.cjs +0 -1
- package/dist/context-manager.cjs.map +1 -1
- package/dist/context-manager.js +0 -1
- package/dist/context-manager.js.map +1 -1
- package/dist/index.cjs +6 -211
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -211
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +5 -201
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +5 -201
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/child-runs/childRunInvoker.d.cts +1 -3
- package/dist/runtime-kernel/child-runs/childRunInvoker.d.ts +1 -3
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.cts +1 -3
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.ts +1 -3
- package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.cts +1 -2
- package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.ts +1 -2
- package/dist/runtime-kernel/testkit/graphLoopHarness.d.cts +1 -2
- package/dist/runtime-kernel/testkit/graphLoopHarness.d.ts +1 -2
- package/dist/runtime-kernel/tools/index.d.cts +1 -2
- package/dist/runtime-kernel/tools/index.d.ts +1 -2
- package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.cts +4 -3
- package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.ts +4 -3
- package/dist/runtime-kernel/tools/ports.d.cts +1 -28
- package/dist/runtime-kernel/tools/ports.d.ts +1 -28
- package/dist/runtime-kernel/tools/toolContextRuntime.d.cts +1 -1
- package/dist/runtime-kernel/tools/toolContextRuntime.d.ts +1 -1
- package/dist/runtime-kernel/tools/toolContracts.d.cts +0 -6
- package/dist/runtime-kernel/tools/toolContracts.d.ts +0 -6
- package/dist/runtime-kernel/tools/toolExecutionContext.d.cts +0 -7
- package/dist/runtime-kernel/tools/toolExecutionContext.d.ts +0 -7
- package/dist/runtime-kernel.cjs +5 -206
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.d.cts +1 -2
- package/dist/runtime-kernel.d.ts +1 -2
- package/dist/runtime-kernel.js +5 -206
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit/agent-harness/scriptedInferenceHarness.d.cts +1 -1
- package/dist/testkit/agent-harness/scriptedInferenceHarness.d.ts +1 -1
- package/dist/testkit.cjs +5 -206
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +5 -206
- package/dist/testkit.js.map +1 -1
- package/docs/integration/tool-development-guide.md +7 -23
- package/docs/integration/tools.md +2 -5
- package/package.json +2 -2
- package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.cts +0 -17
- 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,
|
|
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';
|
package/dist/runtime-kernel.d.ts
CHANGED
|
@@ -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,
|
|
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';
|
package/dist/runtime-kernel.js
CHANGED
|
@@ -4008,7 +4008,6 @@ var tickPipelineContextKeys = [
|
|
|
4008
4008
|
"runtimeEventCommitPort",
|
|
4009
4009
|
"modelId",
|
|
4010
4010
|
"toolSchemas",
|
|
4011
|
-
"toolModelInputRequirement",
|
|
4012
4011
|
"toolCallStreamingPolicies",
|
|
4013
4012
|
"llmOptions",
|
|
4014
4013
|
"toolDefinitionTokens",
|
|
@@ -5129,7 +5128,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5129
5128
|
"outputProcessor",
|
|
5130
5129
|
"modelId",
|
|
5131
5130
|
"llmMessages",
|
|
5132
|
-
"toolModelInputRequirement",
|
|
5133
5131
|
"toolCallStreamingPolicies",
|
|
5134
5132
|
"imageInputAdmissionEvidence",
|
|
5135
5133
|
"llmOptions",
|
|
@@ -5188,7 +5186,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5188
5186
|
},
|
|
5189
5187
|
{
|
|
5190
5188
|
imageInputAdmissionEvidence: ctx.imageInputAdmissionEvidence,
|
|
5191
|
-
additionalModelInputRequirement: ctx.toolModelInputRequirement,
|
|
5192
5189
|
toolCallStreamingPolicies: ctx.toolCallStreamingPolicies,
|
|
5193
5190
|
...promptBudget && promptUsageMeasurementPolicy ? {
|
|
5194
5191
|
measurePromptUsage: async (activeModelId, messages) => {
|
|
@@ -6173,29 +6170,6 @@ function createCommitContextCompactionStage() {
|
|
|
6173
6170
|
});
|
|
6174
6171
|
}
|
|
6175
6172
|
|
|
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
6173
|
// src/runtime-kernel/graph-engine/tick-pipeline/stages/prepareCallStage.ts
|
|
6200
6174
|
function createPrepareCallStage(dependencies) {
|
|
6201
6175
|
return defineTickStage({
|
|
@@ -6213,7 +6187,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6213
6187
|
writes: [
|
|
6214
6188
|
"modelId",
|
|
6215
6189
|
"toolSchemas",
|
|
6216
|
-
"toolModelInputRequirement",
|
|
6217
6190
|
"toolCallStreamingPolicies",
|
|
6218
6191
|
"llmOptions",
|
|
6219
6192
|
"toolDefinitionTokens"
|
|
@@ -6253,12 +6226,7 @@ function createPrepareCallStage(dependencies) {
|
|
|
6253
6226
|
invocation: ctx.request
|
|
6254
6227
|
});
|
|
6255
6228
|
const modelConfig = dependencies.modelCatalog.getModelById(modelId);
|
|
6256
|
-
const
|
|
6257
|
-
schemas: candidateToolSchemas,
|
|
6258
|
-
model: modelConfig,
|
|
6259
|
-
getToolDefinition: (toolName) => dependencies.toolCatalog.getToolDefinition(toolName)
|
|
6260
|
-
});
|
|
6261
|
-
const toolSchemas = [...toolPreparation.schemas];
|
|
6229
|
+
const toolSchemas = [...candidateToolSchemas];
|
|
6262
6230
|
const toolCallStreamingPolicies = deriveToolCallStreamingPolicies(
|
|
6263
6231
|
toolSchemas,
|
|
6264
6232
|
dependencies.toolCatalog
|
|
@@ -6302,7 +6270,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6302
6270
|
return {
|
|
6303
6271
|
modelId,
|
|
6304
6272
|
toolSchemas,
|
|
6305
|
-
toolModelInputRequirement: toolPreparation.requirement,
|
|
6306
6273
|
toolCallStreamingPolicies,
|
|
6307
6274
|
llmOptions,
|
|
6308
6275
|
toolDefinitionTokens
|
|
@@ -6476,7 +6443,6 @@ var GraphAgentExecutor = class {
|
|
|
6476
6443
|
modelId: "",
|
|
6477
6444
|
toolSchemas: [],
|
|
6478
6445
|
toolCallStreamingPolicies: {},
|
|
6479
|
-
toolModelInputRequirement: void 0,
|
|
6480
6446
|
llmOptions: {},
|
|
6481
6447
|
toolDefinitionTokens: 0,
|
|
6482
6448
|
llmMessages: [],
|
|
@@ -7728,10 +7694,6 @@ function parseToolModelInputDeclaration(value) {
|
|
|
7728
7694
|
}
|
|
7729
7695
|
|
|
7730
7696
|
// 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
7697
|
async function resolveToolModelInput(input) {
|
|
7736
7698
|
if (!input.selections) {
|
|
7737
7699
|
return void 0;
|
|
@@ -7752,16 +7714,6 @@ async function resolveToolModelInput(input) {
|
|
|
7752
7714
|
if (parsed.data.some((reference, index) => reference.id !== input.selections?.[index]?.id)) {
|
|
7753
7715
|
throw new ToolModelInputResolutionError("Tool model input resolver changed attachment identity or order.");
|
|
7754
7716
|
}
|
|
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
7717
|
return Object.freeze(parsed.data.map((reference) => Object.freeze(reference)));
|
|
7766
7718
|
}
|
|
7767
7719
|
|
|
@@ -8226,8 +8178,7 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
|
|
|
8226
8178
|
"parentRunId",
|
|
8227
8179
|
"childRunDepth",
|
|
8228
8180
|
"childRunContextInjections",
|
|
8229
|
-
"parentToolCallId"
|
|
8230
|
-
"modelInputAdmission"
|
|
8181
|
+
"parentToolCallId"
|
|
8231
8182
|
];
|
|
8232
8183
|
var TOOL_CONTEXT_RUNTIME_BINDINGS_KEY = /* @__PURE__ */ Symbol.for(
|
|
8233
8184
|
"@linnlabs/linnkit/tool-context-runtime-bindings/v1"
|
|
@@ -8528,7 +8479,6 @@ var ToolNodeEventBridge = class {
|
|
|
8528
8479
|
|
|
8529
8480
|
// src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
|
|
8530
8481
|
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
8482
|
function parseToolArgs(call) {
|
|
8533
8483
|
const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
|
|
8534
8484
|
if (!rawArguments.trim()) {
|
|
@@ -8632,12 +8582,6 @@ function prepareToolExecution(params) {
|
|
|
8632
8582
|
toolArgs,
|
|
8633
8583
|
idempotencyKey
|
|
8634
8584
|
});
|
|
8635
|
-
const modelInputRequirement = resolveModelInputRequirement({
|
|
8636
|
-
toolDefinition,
|
|
8637
|
-
toolArgs,
|
|
8638
|
-
hasProtocolError: protocolError !== void 0,
|
|
8639
|
-
toolName
|
|
8640
|
-
});
|
|
8641
8585
|
return {
|
|
8642
8586
|
call: params.call,
|
|
8643
8587
|
toolName,
|
|
@@ -8646,30 +8590,9 @@ function prepareToolExecution(params) {
|
|
|
8646
8590
|
toolArgs,
|
|
8647
8591
|
protocolError,
|
|
8648
8592
|
idempotencyKey,
|
|
8649
|
-
...modelInputRequirement.requirement ? { modelInputRequirement: modelInputRequirement.requirement } : {},
|
|
8650
|
-
modelInputDelivery: toolDefinition?.modelInputDelivery ?? "required",
|
|
8651
|
-
...modelInputRequirement.error ? { modelInputRequirementError: modelInputRequirement.error } : {},
|
|
8652
8593
|
bridge
|
|
8653
8594
|
};
|
|
8654
8595
|
}
|
|
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
8596
|
function attachWorkingHistoryView(params) {
|
|
8674
8597
|
const historyEvents = parseRuntimeEvents(
|
|
8675
8598
|
params.state.local?.history ?? []
|
|
@@ -8901,14 +8824,6 @@ function readToolObservationPolicy(local) {
|
|
|
8901
8824
|
function readHistoryEvents(local) {
|
|
8902
8825
|
return parseRuntimeEvents(local.history ?? []);
|
|
8903
8826
|
}
|
|
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
8827
|
function formatCapabilityError(error) {
|
|
8913
8828
|
if (isRecord9(error)) {
|
|
8914
8829
|
const codeValue = error.errorCode ?? error.code;
|
|
@@ -8920,29 +8835,12 @@ function formatCapabilityError(error) {
|
|
|
8920
8835
|
}
|
|
8921
8836
|
return error instanceof Error ? error.message : String(error);
|
|
8922
8837
|
}
|
|
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
8838
|
var ToolNode = class {
|
|
8940
8839
|
id = "tool";
|
|
8941
8840
|
toolRuntime;
|
|
8942
8841
|
observationPreview;
|
|
8943
8842
|
telemetryPort;
|
|
8944
8843
|
auditPort;
|
|
8945
|
-
modelInputCapabilityValidator;
|
|
8946
8844
|
modelInputResolver;
|
|
8947
8845
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
8948
8846
|
constructor(dependencies) {
|
|
@@ -8950,7 +8848,6 @@ var ToolNode = class {
|
|
|
8950
8848
|
this.observationPreview = dependencies.observationPreview;
|
|
8951
8849
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
8952
8850
|
this.auditPort = dependencies.auditPort ?? noopAudit;
|
|
8953
|
-
this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
|
|
8954
8851
|
this.modelInputResolver = dependencies.modelInputResolver;
|
|
8955
8852
|
}
|
|
8956
8853
|
/**
|
|
@@ -9116,7 +9013,6 @@ var ToolNode = class {
|
|
|
9116
9013
|
logger11.warn("no tool name found in call");
|
|
9117
9014
|
return { kind: "yield", events: [] };
|
|
9118
9015
|
}
|
|
9119
|
-
delete prepared.toolContext.modelInputAdmission;
|
|
9120
9016
|
if (typeof execution.protocolError === "string") {
|
|
9121
9017
|
return this.handleError({
|
|
9122
9018
|
...prepared,
|
|
@@ -9134,88 +9030,6 @@ var ToolNode = class {
|
|
|
9134
9030
|
bridge: execution.bridge
|
|
9135
9031
|
});
|
|
9136
9032
|
}
|
|
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
9033
|
await this.emitToolDecisionAudit({
|
|
9220
9034
|
action: "tool.allow",
|
|
9221
9035
|
toolName: execution.toolName,
|
|
@@ -9267,21 +9081,15 @@ var ToolNode = class {
|
|
|
9267
9081
|
bridge: execution.bridge
|
|
9268
9082
|
});
|
|
9269
9083
|
}
|
|
9270
|
-
|
|
9271
|
-
context: prepared.toolContext,
|
|
9272
|
-
delivery: execution.modelInputDelivery
|
|
9273
|
-
});
|
|
9274
|
-
let attachments = deliverModelInput ? exec.cachedAttachments : void 0;
|
|
9084
|
+
let attachments = exec.cachedAttachments;
|
|
9275
9085
|
try {
|
|
9276
|
-
if (
|
|
9086
|
+
if (!attachments) {
|
|
9277
9087
|
attachments = await resolveToolModelInput({
|
|
9278
|
-
activeModelId: readLastSuccessfulLlmModelId(prepared.local),
|
|
9279
9088
|
toolName: execution.toolName,
|
|
9280
9089
|
toolCallId: execution.toolCallId,
|
|
9281
9090
|
selections: contract.modelInputAttachments,
|
|
9282
9091
|
context: prepared.toolContext,
|
|
9283
|
-
resolver: this.modelInputResolver
|
|
9284
|
-
capabilityValidator: this.modelInputCapabilityValidator
|
|
9092
|
+
resolver: this.modelInputResolver
|
|
9285
9093
|
});
|
|
9286
9094
|
}
|
|
9287
9095
|
} catch (error) {
|
|
@@ -9990,10 +9798,6 @@ function formatUnknownToolArguments(fields, allowedFields) {
|
|
|
9990
9798
|
// src/runtime-kernel/tools/toolContracts.ts
|
|
9991
9799
|
var BaseTool = class {
|
|
9992
9800
|
idempotency;
|
|
9993
|
-
modelInputRequirement;
|
|
9994
|
-
/** 模型输入是工具成功的必要结果,还是仅在当前模型支持时提供的增强反馈。 */
|
|
9995
|
-
modelInputDelivery;
|
|
9996
|
-
resolveModelInputRequirement;
|
|
9997
9801
|
streaming;
|
|
9998
9802
|
getExecutionSummary(output) {
|
|
9999
9803
|
const FULL_CONTENT_THRESHOLD = 200;
|
|
@@ -12271,7 +12075,6 @@ var ChildRunInvoker = class {
|
|
|
12271
12075
|
createLlmNode;
|
|
12272
12076
|
toolRuntime;
|
|
12273
12077
|
observationPreview;
|
|
12274
|
-
modelInputCapabilityValidator;
|
|
12275
12078
|
modelInputResolver;
|
|
12276
12079
|
eventToMessageConverter;
|
|
12277
12080
|
defaultJudgeToolName;
|
|
@@ -12282,7 +12085,6 @@ var ChildRunInvoker = class {
|
|
|
12282
12085
|
this.createLlmNode = dependencies.createLlmNode;
|
|
12283
12086
|
this.toolRuntime = dependencies.toolRuntime;
|
|
12284
12087
|
this.observationPreview = dependencies.observationPreview;
|
|
12285
|
-
this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
|
|
12286
12088
|
this.modelInputResolver = dependencies.modelInputResolver;
|
|
12287
12089
|
this.eventToMessageConverter = dependencies.eventToMessageConverter;
|
|
12288
12090
|
this.defaultJudgeToolName = dependencies.defaultJudgeToolName;
|
|
@@ -12545,7 +12347,6 @@ var ChildRunInvoker = class {
|
|
|
12545
12347
|
observationPreview: this.observationPreview,
|
|
12546
12348
|
telemetryPort: this.telemetryPort,
|
|
12547
12349
|
auditPort: this.auditPort,
|
|
12548
|
-
modelInputCapabilityValidator: this.modelInputCapabilityValidator,
|
|
12549
12350
|
modelInputResolver: this.modelInputResolver
|
|
12550
12351
|
}));
|
|
12551
12352
|
graph.registerNode(new WaitUserNode({ auditPort: this.auditPort }));
|
|
@@ -14655,7 +14456,6 @@ function createDefaultGraphExecutor(options) {
|
|
|
14655
14456
|
observationPreview: options.observationPreview,
|
|
14656
14457
|
auditPort: options.auditPort,
|
|
14657
14458
|
telemetryPort: options.telemetryPort,
|
|
14658
|
-
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
14659
14459
|
modelInputResolver: options.modelInputResolver
|
|
14660
14460
|
}));
|
|
14661
14461
|
executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
|
|
@@ -14694,7 +14494,6 @@ function createGraphLoopHarness(options) {
|
|
|
14694
14494
|
maxSteps,
|
|
14695
14495
|
auditPort: options.auditPort,
|
|
14696
14496
|
telemetryPort: options.telemetryPort,
|
|
14697
|
-
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
14698
14497
|
modelInputResolver: options.modelInputResolver
|
|
14699
14498
|
});
|
|
14700
14499
|
const local = {
|