@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.
- package/CHANGELOG.md +45 -0
- package/dist/cli.cjs +17 -202
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +17 -202
- 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/contracts/agentSpec.d.cts +5 -5
- package/dist/contracts/agentSpec.d.ts +5 -5
- package/dist/contracts/audit.d.cts +10 -10
- package/dist/contracts/audit.d.ts +10 -10
- package/dist/contracts/contextPolicy.d.cts +14 -14
- package/dist/contracts/contextPolicy.d.ts +14 -14
- package/dist/contracts/events.d.cts +117 -117
- package/dist/contracts/events.d.ts +117 -117
- package/dist/contracts/execution.d.cts +2 -2
- package/dist/contracts/execution.d.ts +2 -2
- package/dist/contracts/llm-retry.d.cts +2 -2
- package/dist/contracts/llm-retry.d.ts +2 -2
- package/dist/contracts/messages.d.cts +32 -32
- package/dist/contracts/messages.d.ts +32 -32
- package/dist/contracts/sse.d.cts +97 -97
- package/dist/contracts/sse.d.ts +97 -97
- package/dist/contracts/sub-run-trace-payload.d.cts +8 -8
- package/dist/contracts/sub-run-trace-payload.d.ts +8 -8
- package/dist/contracts/token-accounting.d.cts +12 -12
- package/dist/contracts/token-accounting.d.ts +12 -12
- package/dist/index.cjs +18 -212
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -212
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +17 -202
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +17 -202
- 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/events/agentEvents.d.cts +2 -2
- package/dist/runtime-kernel/events/agentEvents.d.ts +2 -2
- package/dist/runtime-kernel/graph-engine/engine.d.cts +1 -0
- package/dist/runtime-kernel/graph-engine/engine.d.ts +1 -0
- 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 +17 -207
- 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 +17 -207
- 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 +17 -207
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +17 -207
- package/dist/testkit.js.map +1 -1
- package/docs/integration/tool-development-guide.md +8 -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
package/dist/index.js
CHANGED
|
@@ -4022,6 +4022,16 @@ function mergeResumeSessionLocal(persistedLocal, localPatch) {
|
|
|
4022
4022
|
}
|
|
4023
4023
|
};
|
|
4024
4024
|
}
|
|
4025
|
+
function resolveResumeNodeId(local, requested) {
|
|
4026
|
+
const pending = local?.pendingToolCalls;
|
|
4027
|
+
if (!Array.isArray(pending) || pending.length === 0) return requested ?? "llm";
|
|
4028
|
+
if (requested !== void 0 && requested !== "tool") {
|
|
4029
|
+
throw new Error(
|
|
4030
|
+
`Graph resume must first run ${pending.length} pending tool call(s) from the interrupted batch: requested node=${requested}`
|
|
4031
|
+
);
|
|
4032
|
+
}
|
|
4033
|
+
return "tool";
|
|
4034
|
+
}
|
|
4025
4035
|
var GraphExecutor = class {
|
|
4026
4036
|
constructor(checkpointer, config = {}) {
|
|
4027
4037
|
this.checkpointer = checkpointer;
|
|
@@ -4134,13 +4144,14 @@ var GraphExecutor = class {
|
|
|
4134
4144
|
);
|
|
4135
4145
|
}
|
|
4136
4146
|
const resumedLocal = mergeResumeSessionLocal(current.local, input.localPatch);
|
|
4147
|
+
const nodeId = resolveResumeNodeId(resumedLocal, input.nodeId);
|
|
4137
4148
|
if (this.executionCheckpointPort && current.local?.executorLocal) {
|
|
4138
4149
|
resumedLocal.executorLocal = { ...current.local.executorLocal };
|
|
4139
4150
|
}
|
|
4140
4151
|
this.ephemeralLocals.set(checkpointKey, resumedLocal);
|
|
4141
4152
|
await this.commitCheckpoint(checkpointKey, {
|
|
4142
4153
|
...current,
|
|
4143
|
-
nodeId
|
|
4154
|
+
nodeId,
|
|
4144
4155
|
...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
|
|
4145
4156
|
revision: currentRevision + 1,
|
|
4146
4157
|
local: sanitizeCheckpointLocal(resumedLocal)
|
|
@@ -5031,7 +5042,6 @@ var tickPipelineContextKeys = [
|
|
|
5031
5042
|
"runtimeEventCommitPort",
|
|
5032
5043
|
"modelId",
|
|
5033
5044
|
"toolSchemas",
|
|
5034
|
-
"toolModelInputRequirement",
|
|
5035
5045
|
"toolCallStreamingPolicies",
|
|
5036
5046
|
"llmOptions",
|
|
5037
5047
|
"toolDefinitionTokens",
|
|
@@ -6152,7 +6162,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
6152
6162
|
"outputProcessor",
|
|
6153
6163
|
"modelId",
|
|
6154
6164
|
"llmMessages",
|
|
6155
|
-
"toolModelInputRequirement",
|
|
6156
6165
|
"toolCallStreamingPolicies",
|
|
6157
6166
|
"imageInputAdmissionEvidence",
|
|
6158
6167
|
"llmOptions",
|
|
@@ -6211,7 +6220,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
6211
6220
|
},
|
|
6212
6221
|
{
|
|
6213
6222
|
imageInputAdmissionEvidence: ctx.imageInputAdmissionEvidence,
|
|
6214
|
-
additionalModelInputRequirement: ctx.toolModelInputRequirement,
|
|
6215
6223
|
toolCallStreamingPolicies: ctx.toolCallStreamingPolicies,
|
|
6216
6224
|
...promptBudget && promptUsageMeasurementPolicy ? {
|
|
6217
6225
|
measurePromptUsage: async (activeModelId, messages) => {
|
|
@@ -7196,29 +7204,6 @@ function createCommitContextCompactionStage() {
|
|
|
7196
7204
|
});
|
|
7197
7205
|
}
|
|
7198
7206
|
|
|
7199
|
-
// src/runtime-kernel/graph-engine/functions/prepareModelCompatibleTools.ts
|
|
7200
|
-
function prepareModelCompatibleTools(input) {
|
|
7201
|
-
const schemas = [];
|
|
7202
|
-
const requirements = [];
|
|
7203
|
-
for (const schema of input.schemas) {
|
|
7204
|
-
const definition = input.getToolDefinition(schema.function.name);
|
|
7205
|
-
const requirement = definition?.modelInputRequirement;
|
|
7206
|
-
const delivery = definition?.modelInputDelivery ?? "required";
|
|
7207
|
-
const isRequired = delivery === "required";
|
|
7208
|
-
if (requirement && isRequired && !evaluateModelInputCompatibility(input.model, requirement).compatible) {
|
|
7209
|
-
continue;
|
|
7210
|
-
}
|
|
7211
|
-
schemas.push(schema);
|
|
7212
|
-
if (requirement && isRequired) {
|
|
7213
|
-
requirements.push(requirement);
|
|
7214
|
-
}
|
|
7215
|
-
}
|
|
7216
|
-
return {
|
|
7217
|
-
schemas: Object.freeze(schemas),
|
|
7218
|
-
requirement: requirements.length > 0 ? mergeModelInputRequirements(...requirements) : EMPTY_MODEL_INPUT_REQUIREMENT
|
|
7219
|
-
};
|
|
7220
|
-
}
|
|
7221
|
-
|
|
7222
7207
|
// src/runtime-kernel/graph-engine/tick-pipeline/stages/prepareCallStage.ts
|
|
7223
7208
|
function createPrepareCallStage(dependencies) {
|
|
7224
7209
|
return defineTickStage({
|
|
@@ -7236,7 +7221,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
7236
7221
|
writes: [
|
|
7237
7222
|
"modelId",
|
|
7238
7223
|
"toolSchemas",
|
|
7239
|
-
"toolModelInputRequirement",
|
|
7240
7224
|
"toolCallStreamingPolicies",
|
|
7241
7225
|
"llmOptions",
|
|
7242
7226
|
"toolDefinitionTokens"
|
|
@@ -7276,12 +7260,7 @@ function createPrepareCallStage(dependencies) {
|
|
|
7276
7260
|
invocation: ctx.request
|
|
7277
7261
|
});
|
|
7278
7262
|
const modelConfig = dependencies.modelCatalog.getModelById(modelId);
|
|
7279
|
-
const
|
|
7280
|
-
schemas: candidateToolSchemas,
|
|
7281
|
-
model: modelConfig,
|
|
7282
|
-
getToolDefinition: (toolName) => dependencies.toolCatalog.getToolDefinition(toolName)
|
|
7283
|
-
});
|
|
7284
|
-
const toolSchemas = [...toolPreparation.schemas];
|
|
7263
|
+
const toolSchemas = [...candidateToolSchemas];
|
|
7285
7264
|
const toolCallStreamingPolicies = deriveToolCallStreamingPolicies(
|
|
7286
7265
|
toolSchemas,
|
|
7287
7266
|
dependencies.toolCatalog
|
|
@@ -7325,7 +7304,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
7325
7304
|
return {
|
|
7326
7305
|
modelId,
|
|
7327
7306
|
toolSchemas,
|
|
7328
|
-
toolModelInputRequirement: toolPreparation.requirement,
|
|
7329
7307
|
toolCallStreamingPolicies,
|
|
7330
7308
|
llmOptions,
|
|
7331
7309
|
toolDefinitionTokens
|
|
@@ -7499,7 +7477,6 @@ var GraphAgentExecutor = class {
|
|
|
7499
7477
|
modelId: "",
|
|
7500
7478
|
toolSchemas: [],
|
|
7501
7479
|
toolCallStreamingPolicies: {},
|
|
7502
|
-
toolModelInputRequirement: void 0,
|
|
7503
7480
|
llmOptions: {},
|
|
7504
7481
|
toolDefinitionTokens: 0,
|
|
7505
7482
|
llmMessages: [],
|
|
@@ -8751,10 +8728,6 @@ function parseToolModelInputDeclaration(value) {
|
|
|
8751
8728
|
}
|
|
8752
8729
|
|
|
8753
8730
|
// src/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.ts
|
|
8754
|
-
var TOOL_RESULT_IMAGE_REQUIREMENT = {
|
|
8755
|
-
requires_image_input: true,
|
|
8756
|
-
placements: ["tool_result_image"]
|
|
8757
|
-
};
|
|
8758
8731
|
async function resolveToolModelInput(input) {
|
|
8759
8732
|
if (!input.selections) {
|
|
8760
8733
|
return void 0;
|
|
@@ -8775,16 +8748,6 @@ async function resolveToolModelInput(input) {
|
|
|
8775
8748
|
if (parsed.data.some((reference, index) => reference.id !== input.selections?.[index]?.id)) {
|
|
8776
8749
|
throw new ToolModelInputResolutionError("Tool model input resolver changed attachment identity or order.");
|
|
8777
8750
|
}
|
|
8778
|
-
if (!input.activeModelId) {
|
|
8779
|
-
throw new ToolModelInputResolutionError("Missing successful LLM model for tool input validation.");
|
|
8780
|
-
}
|
|
8781
|
-
if (!input.capabilityValidator) {
|
|
8782
|
-
throw new ToolModelInputResolutionError("Tool model input validator is not configured.");
|
|
8783
|
-
}
|
|
8784
|
-
input.capabilityValidator.assertCompatible({
|
|
8785
|
-
activeModelId: input.activeModelId,
|
|
8786
|
-
requirement: TOOL_RESULT_IMAGE_REQUIREMENT
|
|
8787
|
-
});
|
|
8788
8751
|
return Object.freeze(parsed.data.map((reference) => Object.freeze(reference)));
|
|
8789
8752
|
}
|
|
8790
8753
|
|
|
@@ -9249,8 +9212,7 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
|
|
|
9249
9212
|
"parentRunId",
|
|
9250
9213
|
"childRunDepth",
|
|
9251
9214
|
"childRunContextInjections",
|
|
9252
|
-
"parentToolCallId"
|
|
9253
|
-
"modelInputAdmission"
|
|
9215
|
+
"parentToolCallId"
|
|
9254
9216
|
];
|
|
9255
9217
|
var TOOL_CONTEXT_RUNTIME_BINDINGS_KEY = /* @__PURE__ */ Symbol.for(
|
|
9256
9218
|
"@linnlabs/linnkit/tool-context-runtime-bindings/v1"
|
|
@@ -9551,7 +9513,6 @@ var ToolNodeEventBridge = class {
|
|
|
9551
9513
|
|
|
9552
9514
|
// src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
|
|
9553
9515
|
var logger10 = new Logger("ToolNode");
|
|
9554
|
-
var MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR = "tool.model_input.requirement_resolution_failed: Tool model input requirement could not be resolved";
|
|
9555
9516
|
function parseToolArgs(call) {
|
|
9556
9517
|
const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
|
|
9557
9518
|
if (!rawArguments.trim()) {
|
|
@@ -9655,12 +9616,6 @@ function prepareToolExecution(params) {
|
|
|
9655
9616
|
toolArgs,
|
|
9656
9617
|
idempotencyKey
|
|
9657
9618
|
});
|
|
9658
|
-
const modelInputRequirement = resolveModelInputRequirement({
|
|
9659
|
-
toolDefinition,
|
|
9660
|
-
toolArgs,
|
|
9661
|
-
hasProtocolError: protocolError !== void 0,
|
|
9662
|
-
toolName
|
|
9663
|
-
});
|
|
9664
9619
|
return {
|
|
9665
9620
|
call: params.call,
|
|
9666
9621
|
toolName,
|
|
@@ -9669,30 +9624,9 @@ function prepareToolExecution(params) {
|
|
|
9669
9624
|
toolArgs,
|
|
9670
9625
|
protocolError,
|
|
9671
9626
|
idempotencyKey,
|
|
9672
|
-
...modelInputRequirement.requirement ? { modelInputRequirement: modelInputRequirement.requirement } : {},
|
|
9673
|
-
modelInputDelivery: toolDefinition?.modelInputDelivery ?? "required",
|
|
9674
|
-
...modelInputRequirement.error ? { modelInputRequirementError: modelInputRequirement.error } : {},
|
|
9675
9627
|
bridge
|
|
9676
9628
|
};
|
|
9677
9629
|
}
|
|
9678
|
-
function resolveModelInputRequirement(params) {
|
|
9679
|
-
if (params.hasProtocolError) {
|
|
9680
|
-
return {};
|
|
9681
|
-
}
|
|
9682
|
-
if (!params.toolDefinition?.resolveModelInputRequirement) {
|
|
9683
|
-
return params.toolDefinition?.modelInputRequirement ? { requirement: params.toolDefinition.modelInputRequirement } : {};
|
|
9684
|
-
}
|
|
9685
|
-
try {
|
|
9686
|
-
const requirement = params.toolDefinition.resolveModelInputRequirement(params.toolArgs);
|
|
9687
|
-
return requirement ? { requirement } : {};
|
|
9688
|
-
} catch (error) {
|
|
9689
|
-
logger10.warn("dynamic model input requirement resolution failed", {
|
|
9690
|
-
toolName: params.toolName,
|
|
9691
|
-
errorName: error instanceof Error ? error.name : "UnknownError"
|
|
9692
|
-
});
|
|
9693
|
-
return { error: MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR };
|
|
9694
|
-
}
|
|
9695
|
-
}
|
|
9696
9630
|
function attachWorkingHistoryView(params) {
|
|
9697
9631
|
const historyEvents = parseRuntimeEvents(
|
|
9698
9632
|
params.state.local?.history ?? []
|
|
@@ -9931,14 +9865,6 @@ function readToolObservationPolicy(local) {
|
|
|
9931
9865
|
function readHistoryEvents(local) {
|
|
9932
9866
|
return parseRuntimeEvents(local.history ?? []);
|
|
9933
9867
|
}
|
|
9934
|
-
function readLastSuccessfulLlmModelId(local) {
|
|
9935
|
-
const executorLocal = local.executorLocal;
|
|
9936
|
-
if (!isRecord9(executorLocal)) {
|
|
9937
|
-
return void 0;
|
|
9938
|
-
}
|
|
9939
|
-
const value = executorLocal.lastSuccessfulLlmModelId;
|
|
9940
|
-
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
9941
|
-
}
|
|
9942
9868
|
function formatCapabilityError(error) {
|
|
9943
9869
|
if (isRecord9(error)) {
|
|
9944
9870
|
const codeValue = error.errorCode ?? error.code;
|
|
@@ -9950,29 +9876,12 @@ function formatCapabilityError(error) {
|
|
|
9950
9876
|
}
|
|
9951
9877
|
return error instanceof Error ? error.message : String(error);
|
|
9952
9878
|
}
|
|
9953
|
-
function bindModelInputAdmission(input) {
|
|
9954
|
-
input.context.modelInputAdmission = Object.freeze({
|
|
9955
|
-
requirement: Object.freeze({
|
|
9956
|
-
...input.requirement,
|
|
9957
|
-
placements: Object.freeze([...input.requirement.placements])
|
|
9958
|
-
}),
|
|
9959
|
-
delivery: input.delivery,
|
|
9960
|
-
admitted: input.admitted
|
|
9961
|
-
});
|
|
9962
|
-
}
|
|
9963
|
-
function isOptionalImageInputIncompatibility(reason) {
|
|
9964
|
-
return reason === "image_input_unsupported" || reason === "placement_unsupported";
|
|
9965
|
-
}
|
|
9966
|
-
function shouldDeliverToolModelInput(input) {
|
|
9967
|
-
return input.delivery === "required" || input.context.modelInputAdmission?.admitted === true;
|
|
9968
|
-
}
|
|
9969
9879
|
var ToolNode = class {
|
|
9970
9880
|
id = "tool";
|
|
9971
9881
|
toolRuntime;
|
|
9972
9882
|
observationPreview;
|
|
9973
9883
|
telemetryPort;
|
|
9974
9884
|
auditPort;
|
|
9975
|
-
modelInputCapabilityValidator;
|
|
9976
9885
|
modelInputResolver;
|
|
9977
9886
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
9978
9887
|
constructor(dependencies) {
|
|
@@ -9980,7 +9889,6 @@ var ToolNode = class {
|
|
|
9980
9889
|
this.observationPreview = dependencies.observationPreview;
|
|
9981
9890
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
9982
9891
|
this.auditPort = dependencies.auditPort ?? noopAudit;
|
|
9983
|
-
this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
|
|
9984
9892
|
this.modelInputResolver = dependencies.modelInputResolver;
|
|
9985
9893
|
}
|
|
9986
9894
|
/**
|
|
@@ -10146,7 +10054,6 @@ var ToolNode = class {
|
|
|
10146
10054
|
logger11.warn("no tool name found in call");
|
|
10147
10055
|
return { kind: "yield", events: [] };
|
|
10148
10056
|
}
|
|
10149
|
-
delete prepared.toolContext.modelInputAdmission;
|
|
10150
10057
|
if (typeof execution.protocolError === "string") {
|
|
10151
10058
|
return this.handleError({
|
|
10152
10059
|
...prepared,
|
|
@@ -10164,88 +10071,6 @@ var ToolNode = class {
|
|
|
10164
10071
|
bridge: execution.bridge
|
|
10165
10072
|
});
|
|
10166
10073
|
}
|
|
10167
|
-
if (typeof execution.modelInputRequirementError === "string") {
|
|
10168
|
-
return this.handleError({
|
|
10169
|
-
...prepared,
|
|
10170
|
-
calls,
|
|
10171
|
-
call,
|
|
10172
|
-
toolName: execution.toolName,
|
|
10173
|
-
toolCallId: execution.toolCallId,
|
|
10174
|
-
toolArgs: execution.toolArgs,
|
|
10175
|
-
exec: {
|
|
10176
|
-
success: false,
|
|
10177
|
-
error: execution.modelInputRequirementError,
|
|
10178
|
-
errorKind: "capability",
|
|
10179
|
-
durationMs: 0
|
|
10180
|
-
},
|
|
10181
|
-
bridge: execution.bridge
|
|
10182
|
-
});
|
|
10183
|
-
}
|
|
10184
|
-
if (execution.modelInputRequirement?.requires_image_input === true) {
|
|
10185
|
-
const activeModelId = readLastSuccessfulLlmModelId(prepared.local);
|
|
10186
|
-
let capabilityError;
|
|
10187
|
-
let admitted = true;
|
|
10188
|
-
if (!activeModelId) {
|
|
10189
|
-
capabilityError = "llm.unsupported_capability: missing successful LLM model for tool input validation";
|
|
10190
|
-
} else if (!this.modelInputCapabilityValidator) {
|
|
10191
|
-
capabilityError = "llm.unsupported_capability: tool model input validator is not configured";
|
|
10192
|
-
} else {
|
|
10193
|
-
const validationInput = {
|
|
10194
|
-
activeModelId,
|
|
10195
|
-
requirement: execution.modelInputRequirement
|
|
10196
|
-
};
|
|
10197
|
-
if (execution.modelInputDelivery === "when_supported") {
|
|
10198
|
-
try {
|
|
10199
|
-
const compatibility = this.modelInputCapabilityValidator.evaluate(validationInput);
|
|
10200
|
-
if (!compatibility.compatible) {
|
|
10201
|
-
if (isOptionalImageInputIncompatibility(compatibility.reason)) {
|
|
10202
|
-
admitted = false;
|
|
10203
|
-
logger11.debug("optional tool model input omitted for incompatible active model", {
|
|
10204
|
-
toolName: execution.toolName,
|
|
10205
|
-
activeModelId,
|
|
10206
|
-
reason: compatibility.reason,
|
|
10207
|
-
placements: execution.modelInputRequirement.placements
|
|
10208
|
-
});
|
|
10209
|
-
} else {
|
|
10210
|
-
this.modelInputCapabilityValidator.assertCompatible(validationInput);
|
|
10211
|
-
capabilityError = "llm.unsupported_capability: active model is not eligible";
|
|
10212
|
-
}
|
|
10213
|
-
}
|
|
10214
|
-
} catch (error) {
|
|
10215
|
-
capabilityError = formatCapabilityError(error);
|
|
10216
|
-
}
|
|
10217
|
-
} else {
|
|
10218
|
-
try {
|
|
10219
|
-
this.modelInputCapabilityValidator.assertCompatible(validationInput);
|
|
10220
|
-
} catch (error) {
|
|
10221
|
-
capabilityError = formatCapabilityError(error);
|
|
10222
|
-
}
|
|
10223
|
-
}
|
|
10224
|
-
}
|
|
10225
|
-
if (capabilityError) {
|
|
10226
|
-
return this.handleError({
|
|
10227
|
-
...prepared,
|
|
10228
|
-
calls,
|
|
10229
|
-
call,
|
|
10230
|
-
toolName: execution.toolName,
|
|
10231
|
-
toolCallId: execution.toolCallId,
|
|
10232
|
-
toolArgs: execution.toolArgs,
|
|
10233
|
-
exec: {
|
|
10234
|
-
success: false,
|
|
10235
|
-
error: capabilityError,
|
|
10236
|
-
errorKind: "capability",
|
|
10237
|
-
durationMs: 0
|
|
10238
|
-
},
|
|
10239
|
-
bridge: execution.bridge
|
|
10240
|
-
});
|
|
10241
|
-
}
|
|
10242
|
-
bindModelInputAdmission({
|
|
10243
|
-
context: prepared.toolContext,
|
|
10244
|
-
requirement: execution.modelInputRequirement,
|
|
10245
|
-
delivery: execution.modelInputDelivery,
|
|
10246
|
-
admitted
|
|
10247
|
-
});
|
|
10248
|
-
}
|
|
10249
10074
|
await this.emitToolDecisionAudit({
|
|
10250
10075
|
action: "tool.allow",
|
|
10251
10076
|
toolName: execution.toolName,
|
|
@@ -10297,21 +10122,15 @@ var ToolNode = class {
|
|
|
10297
10122
|
bridge: execution.bridge
|
|
10298
10123
|
});
|
|
10299
10124
|
}
|
|
10300
|
-
|
|
10301
|
-
context: prepared.toolContext,
|
|
10302
|
-
delivery: execution.modelInputDelivery
|
|
10303
|
-
});
|
|
10304
|
-
let attachments = deliverModelInput ? exec.cachedAttachments : void 0;
|
|
10125
|
+
let attachments = exec.cachedAttachments;
|
|
10305
10126
|
try {
|
|
10306
|
-
if (
|
|
10127
|
+
if (!attachments) {
|
|
10307
10128
|
attachments = await resolveToolModelInput({
|
|
10308
|
-
activeModelId: readLastSuccessfulLlmModelId(prepared.local),
|
|
10309
10129
|
toolName: execution.toolName,
|
|
10310
10130
|
toolCallId: execution.toolCallId,
|
|
10311
10131
|
selections: contract.modelInputAttachments,
|
|
10312
10132
|
context: prepared.toolContext,
|
|
10313
|
-
resolver: this.modelInputResolver
|
|
10314
|
-
capabilityValidator: this.modelInputCapabilityValidator
|
|
10133
|
+
resolver: this.modelInputResolver
|
|
10315
10134
|
});
|
|
10316
10135
|
}
|
|
10317
10136
|
} catch (error) {
|
|
@@ -11020,10 +10839,6 @@ function formatUnknownToolArguments(fields, allowedFields) {
|
|
|
11020
10839
|
// src/runtime-kernel/tools/toolContracts.ts
|
|
11021
10840
|
var BaseTool = class {
|
|
11022
10841
|
idempotency;
|
|
11023
|
-
modelInputRequirement;
|
|
11024
|
-
/** 模型输入是工具成功的必要结果,还是仅在当前模型支持时提供的增强反馈。 */
|
|
11025
|
-
modelInputDelivery;
|
|
11026
|
-
resolveModelInputRequirement;
|
|
11027
10842
|
streaming;
|
|
11028
10843
|
getExecutionSummary(output) {
|
|
11029
10844
|
const FULL_CONTENT_THRESHOLD = 200;
|
|
@@ -13301,7 +13116,6 @@ var ChildRunInvoker = class {
|
|
|
13301
13116
|
createLlmNode;
|
|
13302
13117
|
toolRuntime;
|
|
13303
13118
|
observationPreview;
|
|
13304
|
-
modelInputCapabilityValidator;
|
|
13305
13119
|
modelInputResolver;
|
|
13306
13120
|
eventToMessageConverter;
|
|
13307
13121
|
defaultJudgeToolName;
|
|
@@ -13312,7 +13126,6 @@ var ChildRunInvoker = class {
|
|
|
13312
13126
|
this.createLlmNode = dependencies.createLlmNode;
|
|
13313
13127
|
this.toolRuntime = dependencies.toolRuntime;
|
|
13314
13128
|
this.observationPreview = dependencies.observationPreview;
|
|
13315
|
-
this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
|
|
13316
13129
|
this.modelInputResolver = dependencies.modelInputResolver;
|
|
13317
13130
|
this.eventToMessageConverter = dependencies.eventToMessageConverter;
|
|
13318
13131
|
this.defaultJudgeToolName = dependencies.defaultJudgeToolName;
|
|
@@ -13575,7 +13388,6 @@ var ChildRunInvoker = class {
|
|
|
13575
13388
|
observationPreview: this.observationPreview,
|
|
13576
13389
|
telemetryPort: this.telemetryPort,
|
|
13577
13390
|
auditPort: this.auditPort,
|
|
13578
|
-
modelInputCapabilityValidator: this.modelInputCapabilityValidator,
|
|
13579
13391
|
modelInputResolver: this.modelInputResolver
|
|
13580
13392
|
}));
|
|
13581
13393
|
graph.registerNode(new WaitUserNode({ auditPort: this.auditPort }));
|
|
@@ -15685,7 +15497,6 @@ function createDefaultGraphExecutor(options) {
|
|
|
15685
15497
|
observationPreview: options.observationPreview,
|
|
15686
15498
|
auditPort: options.auditPort,
|
|
15687
15499
|
telemetryPort: options.telemetryPort,
|
|
15688
|
-
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
15689
15500
|
modelInputResolver: options.modelInputResolver
|
|
15690
15501
|
}));
|
|
15691
15502
|
executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
|
|
@@ -15724,7 +15535,6 @@ function createGraphLoopHarness(options) {
|
|
|
15724
15535
|
maxSteps,
|
|
15725
15536
|
auditPort: options.auditPort,
|
|
15726
15537
|
telemetryPort: options.telemetryPort,
|
|
15727
|
-
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
15728
15538
|
modelInputResolver: options.modelInputResolver
|
|
15729
15539
|
});
|
|
15730
15540
|
const local = {
|
|
@@ -15998,11 +15808,7 @@ var QuickstartMemoryToolRuntime = class {
|
|
|
15998
15808
|
return {
|
|
15999
15809
|
parameters: tool.parameters,
|
|
16000
15810
|
validateArguments: (args) => tool["validateArguments"](args),
|
|
16001
|
-
idempotency: tool.idempotency
|
|
16002
|
-
modelInputRequirement: tool.modelInputRequirement,
|
|
16003
|
-
...tool.resolveModelInputRequirement ? {
|
|
16004
|
-
resolveModelInputRequirement: (args) => tool.resolveModelInputRequirement?.(args)
|
|
16005
|
-
} : {}
|
|
15811
|
+
idempotency: tool.idempotency
|
|
16006
15812
|
};
|
|
16007
15813
|
}
|
|
16008
15814
|
async executeTool(toolName, args, context) {
|