@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/runtime-kernel.cjs
CHANGED
|
@@ -3011,6 +3011,16 @@ function mergeResumeSessionLocal(persistedLocal, localPatch) {
|
|
|
3011
3011
|
}
|
|
3012
3012
|
};
|
|
3013
3013
|
}
|
|
3014
|
+
function resolveResumeNodeId(local, requested) {
|
|
3015
|
+
const pending = local?.pendingToolCalls;
|
|
3016
|
+
if (!Array.isArray(pending) || pending.length === 0) return requested ?? "llm";
|
|
3017
|
+
if (requested !== void 0 && requested !== "tool") {
|
|
3018
|
+
throw new Error(
|
|
3019
|
+
`Graph resume must first run ${pending.length} pending tool call(s) from the interrupted batch: requested node=${requested}`
|
|
3020
|
+
);
|
|
3021
|
+
}
|
|
3022
|
+
return "tool";
|
|
3023
|
+
}
|
|
3014
3024
|
var GraphExecutor = class {
|
|
3015
3025
|
constructor(checkpointer, config = {}) {
|
|
3016
3026
|
this.checkpointer = checkpointer;
|
|
@@ -3123,13 +3133,14 @@ var GraphExecutor = class {
|
|
|
3123
3133
|
);
|
|
3124
3134
|
}
|
|
3125
3135
|
const resumedLocal = mergeResumeSessionLocal(current.local, input.localPatch);
|
|
3136
|
+
const nodeId = resolveResumeNodeId(resumedLocal, input.nodeId);
|
|
3126
3137
|
if (this.executionCheckpointPort && current.local?.executorLocal) {
|
|
3127
3138
|
resumedLocal.executorLocal = { ...current.local.executorLocal };
|
|
3128
3139
|
}
|
|
3129
3140
|
this.ephemeralLocals.set(checkpointKey, resumedLocal);
|
|
3130
3141
|
await this.commitCheckpoint(checkpointKey, {
|
|
3131
3142
|
...current,
|
|
3132
|
-
nodeId
|
|
3143
|
+
nodeId,
|
|
3133
3144
|
...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
|
|
3134
3145
|
revision: currentRevision + 1,
|
|
3135
3146
|
local: sanitizeCheckpointLocal(resumedLocal)
|
|
@@ -4010,7 +4021,6 @@ var tickPipelineContextKeys = [
|
|
|
4010
4021
|
"runtimeEventCommitPort",
|
|
4011
4022
|
"modelId",
|
|
4012
4023
|
"toolSchemas",
|
|
4013
|
-
"toolModelInputRequirement",
|
|
4014
4024
|
"toolCallStreamingPolicies",
|
|
4015
4025
|
"llmOptions",
|
|
4016
4026
|
"toolDefinitionTokens",
|
|
@@ -5131,7 +5141,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5131
5141
|
"outputProcessor",
|
|
5132
5142
|
"modelId",
|
|
5133
5143
|
"llmMessages",
|
|
5134
|
-
"toolModelInputRequirement",
|
|
5135
5144
|
"toolCallStreamingPolicies",
|
|
5136
5145
|
"imageInputAdmissionEvidence",
|
|
5137
5146
|
"llmOptions",
|
|
@@ -5190,7 +5199,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5190
5199
|
},
|
|
5191
5200
|
{
|
|
5192
5201
|
imageInputAdmissionEvidence: ctx.imageInputAdmissionEvidence,
|
|
5193
|
-
additionalModelInputRequirement: ctx.toolModelInputRequirement,
|
|
5194
5202
|
toolCallStreamingPolicies: ctx.toolCallStreamingPolicies,
|
|
5195
5203
|
...promptBudget && promptUsageMeasurementPolicy ? {
|
|
5196
5204
|
measurePromptUsage: async (activeModelId, messages) => {
|
|
@@ -6175,29 +6183,6 @@ function createCommitContextCompactionStage() {
|
|
|
6175
6183
|
});
|
|
6176
6184
|
}
|
|
6177
6185
|
|
|
6178
|
-
// src/runtime-kernel/graph-engine/functions/prepareModelCompatibleTools.ts
|
|
6179
|
-
function prepareModelCompatibleTools(input) {
|
|
6180
|
-
const schemas = [];
|
|
6181
|
-
const requirements = [];
|
|
6182
|
-
for (const schema of input.schemas) {
|
|
6183
|
-
const definition = input.getToolDefinition(schema.function.name);
|
|
6184
|
-
const requirement = definition?.modelInputRequirement;
|
|
6185
|
-
const delivery = definition?.modelInputDelivery ?? "required";
|
|
6186
|
-
const isRequired = delivery === "required";
|
|
6187
|
-
if (requirement && isRequired && !evaluateModelInputCompatibility(input.model, requirement).compatible) {
|
|
6188
|
-
continue;
|
|
6189
|
-
}
|
|
6190
|
-
schemas.push(schema);
|
|
6191
|
-
if (requirement && isRequired) {
|
|
6192
|
-
requirements.push(requirement);
|
|
6193
|
-
}
|
|
6194
|
-
}
|
|
6195
|
-
return {
|
|
6196
|
-
schemas: Object.freeze(schemas),
|
|
6197
|
-
requirement: requirements.length > 0 ? mergeModelInputRequirements(...requirements) : EMPTY_MODEL_INPUT_REQUIREMENT
|
|
6198
|
-
};
|
|
6199
|
-
}
|
|
6200
|
-
|
|
6201
6186
|
// src/runtime-kernel/graph-engine/tick-pipeline/stages/prepareCallStage.ts
|
|
6202
6187
|
function createPrepareCallStage(dependencies) {
|
|
6203
6188
|
return defineTickStage({
|
|
@@ -6215,7 +6200,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6215
6200
|
writes: [
|
|
6216
6201
|
"modelId",
|
|
6217
6202
|
"toolSchemas",
|
|
6218
|
-
"toolModelInputRequirement",
|
|
6219
6203
|
"toolCallStreamingPolicies",
|
|
6220
6204
|
"llmOptions",
|
|
6221
6205
|
"toolDefinitionTokens"
|
|
@@ -6255,12 +6239,7 @@ function createPrepareCallStage(dependencies) {
|
|
|
6255
6239
|
invocation: ctx.request
|
|
6256
6240
|
});
|
|
6257
6241
|
const modelConfig = dependencies.modelCatalog.getModelById(modelId);
|
|
6258
|
-
const
|
|
6259
|
-
schemas: candidateToolSchemas,
|
|
6260
|
-
model: modelConfig,
|
|
6261
|
-
getToolDefinition: (toolName) => dependencies.toolCatalog.getToolDefinition(toolName)
|
|
6262
|
-
});
|
|
6263
|
-
const toolSchemas = [...toolPreparation.schemas];
|
|
6242
|
+
const toolSchemas = [...candidateToolSchemas];
|
|
6264
6243
|
const toolCallStreamingPolicies = deriveToolCallStreamingPolicies(
|
|
6265
6244
|
toolSchemas,
|
|
6266
6245
|
dependencies.toolCatalog
|
|
@@ -6304,7 +6283,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6304
6283
|
return {
|
|
6305
6284
|
modelId,
|
|
6306
6285
|
toolSchemas,
|
|
6307
|
-
toolModelInputRequirement: toolPreparation.requirement,
|
|
6308
6286
|
toolCallStreamingPolicies,
|
|
6309
6287
|
llmOptions,
|
|
6310
6288
|
toolDefinitionTokens
|
|
@@ -6478,7 +6456,6 @@ var GraphAgentExecutor = class {
|
|
|
6478
6456
|
modelId: "",
|
|
6479
6457
|
toolSchemas: [],
|
|
6480
6458
|
toolCallStreamingPolicies: {},
|
|
6481
|
-
toolModelInputRequirement: void 0,
|
|
6482
6459
|
llmOptions: {},
|
|
6483
6460
|
toolDefinitionTokens: 0,
|
|
6484
6461
|
llmMessages: [],
|
|
@@ -7730,10 +7707,6 @@ function parseToolModelInputDeclaration(value) {
|
|
|
7730
7707
|
}
|
|
7731
7708
|
|
|
7732
7709
|
// src/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.ts
|
|
7733
|
-
var TOOL_RESULT_IMAGE_REQUIREMENT = {
|
|
7734
|
-
requires_image_input: true,
|
|
7735
|
-
placements: ["tool_result_image"]
|
|
7736
|
-
};
|
|
7737
7710
|
async function resolveToolModelInput(input) {
|
|
7738
7711
|
if (!input.selections) {
|
|
7739
7712
|
return void 0;
|
|
@@ -7754,16 +7727,6 @@ async function resolveToolModelInput(input) {
|
|
|
7754
7727
|
if (parsed.data.some((reference, index) => reference.id !== input.selections?.[index]?.id)) {
|
|
7755
7728
|
throw new ToolModelInputResolutionError("Tool model input resolver changed attachment identity or order.");
|
|
7756
7729
|
}
|
|
7757
|
-
if (!input.activeModelId) {
|
|
7758
|
-
throw new ToolModelInputResolutionError("Missing successful LLM model for tool input validation.");
|
|
7759
|
-
}
|
|
7760
|
-
if (!input.capabilityValidator) {
|
|
7761
|
-
throw new ToolModelInputResolutionError("Tool model input validator is not configured.");
|
|
7762
|
-
}
|
|
7763
|
-
input.capabilityValidator.assertCompatible({
|
|
7764
|
-
activeModelId: input.activeModelId,
|
|
7765
|
-
requirement: TOOL_RESULT_IMAGE_REQUIREMENT
|
|
7766
|
-
});
|
|
7767
7730
|
return Object.freeze(parsed.data.map((reference) => Object.freeze(reference)));
|
|
7768
7731
|
}
|
|
7769
7732
|
|
|
@@ -8228,8 +8191,7 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
|
|
|
8228
8191
|
"parentRunId",
|
|
8229
8192
|
"childRunDepth",
|
|
8230
8193
|
"childRunContextInjections",
|
|
8231
|
-
"parentToolCallId"
|
|
8232
|
-
"modelInputAdmission"
|
|
8194
|
+
"parentToolCallId"
|
|
8233
8195
|
];
|
|
8234
8196
|
var TOOL_CONTEXT_RUNTIME_BINDINGS_KEY = /* @__PURE__ */ Symbol.for(
|
|
8235
8197
|
"@linnlabs/linnkit/tool-context-runtime-bindings/v1"
|
|
@@ -8530,7 +8492,6 @@ var ToolNodeEventBridge = class {
|
|
|
8530
8492
|
|
|
8531
8493
|
// src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
|
|
8532
8494
|
var logger10 = new Logger("ToolNode");
|
|
8533
|
-
var MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR = "tool.model_input.requirement_resolution_failed: Tool model input requirement could not be resolved";
|
|
8534
8495
|
function parseToolArgs(call) {
|
|
8535
8496
|
const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
|
|
8536
8497
|
if (!rawArguments.trim()) {
|
|
@@ -8634,12 +8595,6 @@ function prepareToolExecution(params) {
|
|
|
8634
8595
|
toolArgs,
|
|
8635
8596
|
idempotencyKey
|
|
8636
8597
|
});
|
|
8637
|
-
const modelInputRequirement = resolveModelInputRequirement({
|
|
8638
|
-
toolDefinition,
|
|
8639
|
-
toolArgs,
|
|
8640
|
-
hasProtocolError: protocolError !== void 0,
|
|
8641
|
-
toolName
|
|
8642
|
-
});
|
|
8643
8598
|
return {
|
|
8644
8599
|
call: params.call,
|
|
8645
8600
|
toolName,
|
|
@@ -8648,30 +8603,9 @@ function prepareToolExecution(params) {
|
|
|
8648
8603
|
toolArgs,
|
|
8649
8604
|
protocolError,
|
|
8650
8605
|
idempotencyKey,
|
|
8651
|
-
...modelInputRequirement.requirement ? { modelInputRequirement: modelInputRequirement.requirement } : {},
|
|
8652
|
-
modelInputDelivery: toolDefinition?.modelInputDelivery ?? "required",
|
|
8653
|
-
...modelInputRequirement.error ? { modelInputRequirementError: modelInputRequirement.error } : {},
|
|
8654
8606
|
bridge
|
|
8655
8607
|
};
|
|
8656
8608
|
}
|
|
8657
|
-
function resolveModelInputRequirement(params) {
|
|
8658
|
-
if (params.hasProtocolError) {
|
|
8659
|
-
return {};
|
|
8660
|
-
}
|
|
8661
|
-
if (!params.toolDefinition?.resolveModelInputRequirement) {
|
|
8662
|
-
return params.toolDefinition?.modelInputRequirement ? { requirement: params.toolDefinition.modelInputRequirement } : {};
|
|
8663
|
-
}
|
|
8664
|
-
try {
|
|
8665
|
-
const requirement = params.toolDefinition.resolveModelInputRequirement(params.toolArgs);
|
|
8666
|
-
return requirement ? { requirement } : {};
|
|
8667
|
-
} catch (error) {
|
|
8668
|
-
logger10.warn("dynamic model input requirement resolution failed", {
|
|
8669
|
-
toolName: params.toolName,
|
|
8670
|
-
errorName: error instanceof Error ? error.name : "UnknownError"
|
|
8671
|
-
});
|
|
8672
|
-
return { error: MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR };
|
|
8673
|
-
}
|
|
8674
|
-
}
|
|
8675
8609
|
function attachWorkingHistoryView(params) {
|
|
8676
8610
|
const historyEvents = parseRuntimeEvents(
|
|
8677
8611
|
params.state.local?.history ?? []
|
|
@@ -8903,14 +8837,6 @@ function readToolObservationPolicy(local) {
|
|
|
8903
8837
|
function readHistoryEvents(local) {
|
|
8904
8838
|
return parseRuntimeEvents(local.history ?? []);
|
|
8905
8839
|
}
|
|
8906
|
-
function readLastSuccessfulLlmModelId(local) {
|
|
8907
|
-
const executorLocal = local.executorLocal;
|
|
8908
|
-
if (!isRecord9(executorLocal)) {
|
|
8909
|
-
return void 0;
|
|
8910
|
-
}
|
|
8911
|
-
const value = executorLocal.lastSuccessfulLlmModelId;
|
|
8912
|
-
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
8913
|
-
}
|
|
8914
8840
|
function formatCapabilityError(error) {
|
|
8915
8841
|
if (isRecord9(error)) {
|
|
8916
8842
|
const codeValue = error.errorCode ?? error.code;
|
|
@@ -8922,29 +8848,12 @@ function formatCapabilityError(error) {
|
|
|
8922
8848
|
}
|
|
8923
8849
|
return error instanceof Error ? error.message : String(error);
|
|
8924
8850
|
}
|
|
8925
|
-
function bindModelInputAdmission(input) {
|
|
8926
|
-
input.context.modelInputAdmission = Object.freeze({
|
|
8927
|
-
requirement: Object.freeze({
|
|
8928
|
-
...input.requirement,
|
|
8929
|
-
placements: Object.freeze([...input.requirement.placements])
|
|
8930
|
-
}),
|
|
8931
|
-
delivery: input.delivery,
|
|
8932
|
-
admitted: input.admitted
|
|
8933
|
-
});
|
|
8934
|
-
}
|
|
8935
|
-
function isOptionalImageInputIncompatibility(reason) {
|
|
8936
|
-
return reason === "image_input_unsupported" || reason === "placement_unsupported";
|
|
8937
|
-
}
|
|
8938
|
-
function shouldDeliverToolModelInput(input) {
|
|
8939
|
-
return input.delivery === "required" || input.context.modelInputAdmission?.admitted === true;
|
|
8940
|
-
}
|
|
8941
8851
|
var ToolNode = class {
|
|
8942
8852
|
id = "tool";
|
|
8943
8853
|
toolRuntime;
|
|
8944
8854
|
observationPreview;
|
|
8945
8855
|
telemetryPort;
|
|
8946
8856
|
auditPort;
|
|
8947
|
-
modelInputCapabilityValidator;
|
|
8948
8857
|
modelInputResolver;
|
|
8949
8858
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
8950
8859
|
constructor(dependencies) {
|
|
@@ -8952,7 +8861,6 @@ var ToolNode = class {
|
|
|
8952
8861
|
this.observationPreview = dependencies.observationPreview;
|
|
8953
8862
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
8954
8863
|
this.auditPort = dependencies.auditPort ?? noopAudit;
|
|
8955
|
-
this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
|
|
8956
8864
|
this.modelInputResolver = dependencies.modelInputResolver;
|
|
8957
8865
|
}
|
|
8958
8866
|
/**
|
|
@@ -9118,7 +9026,6 @@ var ToolNode = class {
|
|
|
9118
9026
|
logger11.warn("no tool name found in call");
|
|
9119
9027
|
return { kind: "yield", events: [] };
|
|
9120
9028
|
}
|
|
9121
|
-
delete prepared.toolContext.modelInputAdmission;
|
|
9122
9029
|
if (typeof execution.protocolError === "string") {
|
|
9123
9030
|
return this.handleError({
|
|
9124
9031
|
...prepared,
|
|
@@ -9136,88 +9043,6 @@ var ToolNode = class {
|
|
|
9136
9043
|
bridge: execution.bridge
|
|
9137
9044
|
});
|
|
9138
9045
|
}
|
|
9139
|
-
if (typeof execution.modelInputRequirementError === "string") {
|
|
9140
|
-
return this.handleError({
|
|
9141
|
-
...prepared,
|
|
9142
|
-
calls,
|
|
9143
|
-
call,
|
|
9144
|
-
toolName: execution.toolName,
|
|
9145
|
-
toolCallId: execution.toolCallId,
|
|
9146
|
-
toolArgs: execution.toolArgs,
|
|
9147
|
-
exec: {
|
|
9148
|
-
success: false,
|
|
9149
|
-
error: execution.modelInputRequirementError,
|
|
9150
|
-
errorKind: "capability",
|
|
9151
|
-
durationMs: 0
|
|
9152
|
-
},
|
|
9153
|
-
bridge: execution.bridge
|
|
9154
|
-
});
|
|
9155
|
-
}
|
|
9156
|
-
if (execution.modelInputRequirement?.requires_image_input === true) {
|
|
9157
|
-
const activeModelId = readLastSuccessfulLlmModelId(prepared.local);
|
|
9158
|
-
let capabilityError;
|
|
9159
|
-
let admitted = true;
|
|
9160
|
-
if (!activeModelId) {
|
|
9161
|
-
capabilityError = "llm.unsupported_capability: missing successful LLM model for tool input validation";
|
|
9162
|
-
} else if (!this.modelInputCapabilityValidator) {
|
|
9163
|
-
capabilityError = "llm.unsupported_capability: tool model input validator is not configured";
|
|
9164
|
-
} else {
|
|
9165
|
-
const validationInput = {
|
|
9166
|
-
activeModelId,
|
|
9167
|
-
requirement: execution.modelInputRequirement
|
|
9168
|
-
};
|
|
9169
|
-
if (execution.modelInputDelivery === "when_supported") {
|
|
9170
|
-
try {
|
|
9171
|
-
const compatibility = this.modelInputCapabilityValidator.evaluate(validationInput);
|
|
9172
|
-
if (!compatibility.compatible) {
|
|
9173
|
-
if (isOptionalImageInputIncompatibility(compatibility.reason)) {
|
|
9174
|
-
admitted = false;
|
|
9175
|
-
logger11.debug("optional tool model input omitted for incompatible active model", {
|
|
9176
|
-
toolName: execution.toolName,
|
|
9177
|
-
activeModelId,
|
|
9178
|
-
reason: compatibility.reason,
|
|
9179
|
-
placements: execution.modelInputRequirement.placements
|
|
9180
|
-
});
|
|
9181
|
-
} else {
|
|
9182
|
-
this.modelInputCapabilityValidator.assertCompatible(validationInput);
|
|
9183
|
-
capabilityError = "llm.unsupported_capability: active model is not eligible";
|
|
9184
|
-
}
|
|
9185
|
-
}
|
|
9186
|
-
} catch (error) {
|
|
9187
|
-
capabilityError = formatCapabilityError(error);
|
|
9188
|
-
}
|
|
9189
|
-
} else {
|
|
9190
|
-
try {
|
|
9191
|
-
this.modelInputCapabilityValidator.assertCompatible(validationInput);
|
|
9192
|
-
} catch (error) {
|
|
9193
|
-
capabilityError = formatCapabilityError(error);
|
|
9194
|
-
}
|
|
9195
|
-
}
|
|
9196
|
-
}
|
|
9197
|
-
if (capabilityError) {
|
|
9198
|
-
return this.handleError({
|
|
9199
|
-
...prepared,
|
|
9200
|
-
calls,
|
|
9201
|
-
call,
|
|
9202
|
-
toolName: execution.toolName,
|
|
9203
|
-
toolCallId: execution.toolCallId,
|
|
9204
|
-
toolArgs: execution.toolArgs,
|
|
9205
|
-
exec: {
|
|
9206
|
-
success: false,
|
|
9207
|
-
error: capabilityError,
|
|
9208
|
-
errorKind: "capability",
|
|
9209
|
-
durationMs: 0
|
|
9210
|
-
},
|
|
9211
|
-
bridge: execution.bridge
|
|
9212
|
-
});
|
|
9213
|
-
}
|
|
9214
|
-
bindModelInputAdmission({
|
|
9215
|
-
context: prepared.toolContext,
|
|
9216
|
-
requirement: execution.modelInputRequirement,
|
|
9217
|
-
delivery: execution.modelInputDelivery,
|
|
9218
|
-
admitted
|
|
9219
|
-
});
|
|
9220
|
-
}
|
|
9221
9046
|
await this.emitToolDecisionAudit({
|
|
9222
9047
|
action: "tool.allow",
|
|
9223
9048
|
toolName: execution.toolName,
|
|
@@ -9269,21 +9094,15 @@ var ToolNode = class {
|
|
|
9269
9094
|
bridge: execution.bridge
|
|
9270
9095
|
});
|
|
9271
9096
|
}
|
|
9272
|
-
|
|
9273
|
-
context: prepared.toolContext,
|
|
9274
|
-
delivery: execution.modelInputDelivery
|
|
9275
|
-
});
|
|
9276
|
-
let attachments = deliverModelInput ? exec.cachedAttachments : void 0;
|
|
9097
|
+
let attachments = exec.cachedAttachments;
|
|
9277
9098
|
try {
|
|
9278
|
-
if (
|
|
9099
|
+
if (!attachments) {
|
|
9279
9100
|
attachments = await resolveToolModelInput({
|
|
9280
|
-
activeModelId: readLastSuccessfulLlmModelId(prepared.local),
|
|
9281
9101
|
toolName: execution.toolName,
|
|
9282
9102
|
toolCallId: execution.toolCallId,
|
|
9283
9103
|
selections: contract.modelInputAttachments,
|
|
9284
9104
|
context: prepared.toolContext,
|
|
9285
|
-
resolver: this.modelInputResolver
|
|
9286
|
-
capabilityValidator: this.modelInputCapabilityValidator
|
|
9105
|
+
resolver: this.modelInputResolver
|
|
9287
9106
|
});
|
|
9288
9107
|
}
|
|
9289
9108
|
} catch (error) {
|
|
@@ -9992,10 +9811,6 @@ function formatUnknownToolArguments(fields, allowedFields) {
|
|
|
9992
9811
|
// src/runtime-kernel/tools/toolContracts.ts
|
|
9993
9812
|
var BaseTool = class {
|
|
9994
9813
|
idempotency;
|
|
9995
|
-
modelInputRequirement;
|
|
9996
|
-
/** 模型输入是工具成功的必要结果,还是仅在当前模型支持时提供的增强反馈。 */
|
|
9997
|
-
modelInputDelivery;
|
|
9998
|
-
resolveModelInputRequirement;
|
|
9999
9814
|
streaming;
|
|
10000
9815
|
getExecutionSummary(output) {
|
|
10001
9816
|
const FULL_CONTENT_THRESHOLD = 200;
|
|
@@ -12273,7 +12088,6 @@ var ChildRunInvoker = class {
|
|
|
12273
12088
|
createLlmNode;
|
|
12274
12089
|
toolRuntime;
|
|
12275
12090
|
observationPreview;
|
|
12276
|
-
modelInputCapabilityValidator;
|
|
12277
12091
|
modelInputResolver;
|
|
12278
12092
|
eventToMessageConverter;
|
|
12279
12093
|
defaultJudgeToolName;
|
|
@@ -12284,7 +12098,6 @@ var ChildRunInvoker = class {
|
|
|
12284
12098
|
this.createLlmNode = dependencies.createLlmNode;
|
|
12285
12099
|
this.toolRuntime = dependencies.toolRuntime;
|
|
12286
12100
|
this.observationPreview = dependencies.observationPreview;
|
|
12287
|
-
this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
|
|
12288
12101
|
this.modelInputResolver = dependencies.modelInputResolver;
|
|
12289
12102
|
this.eventToMessageConverter = dependencies.eventToMessageConverter;
|
|
12290
12103
|
this.defaultJudgeToolName = dependencies.defaultJudgeToolName;
|
|
@@ -12547,7 +12360,6 @@ var ChildRunInvoker = class {
|
|
|
12547
12360
|
observationPreview: this.observationPreview,
|
|
12548
12361
|
telemetryPort: this.telemetryPort,
|
|
12549
12362
|
auditPort: this.auditPort,
|
|
12550
|
-
modelInputCapabilityValidator: this.modelInputCapabilityValidator,
|
|
12551
12363
|
modelInputResolver: this.modelInputResolver
|
|
12552
12364
|
}));
|
|
12553
12365
|
graph.registerNode(new WaitUserNode({ auditPort: this.auditPort }));
|
|
@@ -14657,7 +14469,6 @@ function createDefaultGraphExecutor(options) {
|
|
|
14657
14469
|
observationPreview: options.observationPreview,
|
|
14658
14470
|
auditPort: options.auditPort,
|
|
14659
14471
|
telemetryPort: options.telemetryPort,
|
|
14660
|
-
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
14661
14472
|
modelInputResolver: options.modelInputResolver
|
|
14662
14473
|
}));
|
|
14663
14474
|
executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
|
|
@@ -14696,7 +14507,6 @@ function createGraphLoopHarness(options) {
|
|
|
14696
14507
|
maxSteps,
|
|
14697
14508
|
auditPort: options.auditPort,
|
|
14698
14509
|
telemetryPort: options.telemetryPort,
|
|
14699
|
-
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
14700
14510
|
modelInputResolver: options.modelInputResolver
|
|
14701
14511
|
});
|
|
14702
14512
|
const local = {
|