@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/testkit.js
CHANGED
|
@@ -3197,6 +3197,16 @@ function mergeResumeSessionLocal(persistedLocal, localPatch) {
|
|
|
3197
3197
|
}
|
|
3198
3198
|
};
|
|
3199
3199
|
}
|
|
3200
|
+
function resolveResumeNodeId(local, requested) {
|
|
3201
|
+
const pending = local?.pendingToolCalls;
|
|
3202
|
+
if (!Array.isArray(pending) || pending.length === 0) return requested ?? "llm";
|
|
3203
|
+
if (requested !== void 0 && requested !== "tool") {
|
|
3204
|
+
throw new Error(
|
|
3205
|
+
`Graph resume must first run ${pending.length} pending tool call(s) from the interrupted batch: requested node=${requested}`
|
|
3206
|
+
);
|
|
3207
|
+
}
|
|
3208
|
+
return "tool";
|
|
3209
|
+
}
|
|
3200
3210
|
var GraphExecutor = class {
|
|
3201
3211
|
constructor(checkpointer, config = {}) {
|
|
3202
3212
|
this.checkpointer = checkpointer;
|
|
@@ -3309,13 +3319,14 @@ var GraphExecutor = class {
|
|
|
3309
3319
|
);
|
|
3310
3320
|
}
|
|
3311
3321
|
const resumedLocal = mergeResumeSessionLocal(current.local, input.localPatch);
|
|
3322
|
+
const nodeId = resolveResumeNodeId(resumedLocal, input.nodeId);
|
|
3312
3323
|
if (this.executionCheckpointPort && current.local?.executorLocal) {
|
|
3313
3324
|
resumedLocal.executorLocal = { ...current.local.executorLocal };
|
|
3314
3325
|
}
|
|
3315
3326
|
this.ephemeralLocals.set(checkpointKey, resumedLocal);
|
|
3316
3327
|
await this.commitCheckpoint(checkpointKey, {
|
|
3317
3328
|
...current,
|
|
3318
|
-
nodeId
|
|
3329
|
+
nodeId,
|
|
3319
3330
|
...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
|
|
3320
3331
|
revision: currentRevision + 1,
|
|
3321
3332
|
local: sanitizeCheckpointLocal(resumedLocal)
|
|
@@ -4196,7 +4207,6 @@ var tickPipelineContextKeys = [
|
|
|
4196
4207
|
"runtimeEventCommitPort",
|
|
4197
4208
|
"modelId",
|
|
4198
4209
|
"toolSchemas",
|
|
4199
|
-
"toolModelInputRequirement",
|
|
4200
4210
|
"toolCallStreamingPolicies",
|
|
4201
4211
|
"llmOptions",
|
|
4202
4212
|
"toolDefinitionTokens",
|
|
@@ -5317,7 +5327,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5317
5327
|
"outputProcessor",
|
|
5318
5328
|
"modelId",
|
|
5319
5329
|
"llmMessages",
|
|
5320
|
-
"toolModelInputRequirement",
|
|
5321
5330
|
"toolCallStreamingPolicies",
|
|
5322
5331
|
"imageInputAdmissionEvidence",
|
|
5323
5332
|
"llmOptions",
|
|
@@ -5376,7 +5385,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5376
5385
|
},
|
|
5377
5386
|
{
|
|
5378
5387
|
imageInputAdmissionEvidence: ctx.imageInputAdmissionEvidence,
|
|
5379
|
-
additionalModelInputRequirement: ctx.toolModelInputRequirement,
|
|
5380
5388
|
toolCallStreamingPolicies: ctx.toolCallStreamingPolicies,
|
|
5381
5389
|
...promptBudget && promptUsageMeasurementPolicy ? {
|
|
5382
5390
|
measurePromptUsage: async (activeModelId, messages) => {
|
|
@@ -6361,29 +6369,6 @@ function createCommitContextCompactionStage() {
|
|
|
6361
6369
|
});
|
|
6362
6370
|
}
|
|
6363
6371
|
|
|
6364
|
-
// src/runtime-kernel/graph-engine/functions/prepareModelCompatibleTools.ts
|
|
6365
|
-
function prepareModelCompatibleTools(input) {
|
|
6366
|
-
const schemas = [];
|
|
6367
|
-
const requirements = [];
|
|
6368
|
-
for (const schema of input.schemas) {
|
|
6369
|
-
const definition = input.getToolDefinition(schema.function.name);
|
|
6370
|
-
const requirement = definition?.modelInputRequirement;
|
|
6371
|
-
const delivery = definition?.modelInputDelivery ?? "required";
|
|
6372
|
-
const isRequired = delivery === "required";
|
|
6373
|
-
if (requirement && isRequired && !evaluateModelInputCompatibility(input.model, requirement).compatible) {
|
|
6374
|
-
continue;
|
|
6375
|
-
}
|
|
6376
|
-
schemas.push(schema);
|
|
6377
|
-
if (requirement && isRequired) {
|
|
6378
|
-
requirements.push(requirement);
|
|
6379
|
-
}
|
|
6380
|
-
}
|
|
6381
|
-
return {
|
|
6382
|
-
schemas: Object.freeze(schemas),
|
|
6383
|
-
requirement: requirements.length > 0 ? mergeModelInputRequirements(...requirements) : EMPTY_MODEL_INPUT_REQUIREMENT
|
|
6384
|
-
};
|
|
6385
|
-
}
|
|
6386
|
-
|
|
6387
6372
|
// src/runtime-kernel/graph-engine/tick-pipeline/stages/prepareCallStage.ts
|
|
6388
6373
|
function createPrepareCallStage(dependencies) {
|
|
6389
6374
|
return defineTickStage({
|
|
@@ -6401,7 +6386,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6401
6386
|
writes: [
|
|
6402
6387
|
"modelId",
|
|
6403
6388
|
"toolSchemas",
|
|
6404
|
-
"toolModelInputRequirement",
|
|
6405
6389
|
"toolCallStreamingPolicies",
|
|
6406
6390
|
"llmOptions",
|
|
6407
6391
|
"toolDefinitionTokens"
|
|
@@ -6441,12 +6425,7 @@ function createPrepareCallStage(dependencies) {
|
|
|
6441
6425
|
invocation: ctx.request
|
|
6442
6426
|
});
|
|
6443
6427
|
const modelConfig = dependencies.modelCatalog.getModelById(modelId);
|
|
6444
|
-
const
|
|
6445
|
-
schemas: candidateToolSchemas,
|
|
6446
|
-
model: modelConfig,
|
|
6447
|
-
getToolDefinition: (toolName) => dependencies.toolCatalog.getToolDefinition(toolName)
|
|
6448
|
-
});
|
|
6449
|
-
const toolSchemas = [...toolPreparation.schemas];
|
|
6428
|
+
const toolSchemas = [...candidateToolSchemas];
|
|
6450
6429
|
const toolCallStreamingPolicies = deriveToolCallStreamingPolicies(
|
|
6451
6430
|
toolSchemas,
|
|
6452
6431
|
dependencies.toolCatalog
|
|
@@ -6490,7 +6469,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6490
6469
|
return {
|
|
6491
6470
|
modelId,
|
|
6492
6471
|
toolSchemas,
|
|
6493
|
-
toolModelInputRequirement: toolPreparation.requirement,
|
|
6494
6472
|
toolCallStreamingPolicies,
|
|
6495
6473
|
llmOptions,
|
|
6496
6474
|
toolDefinitionTokens
|
|
@@ -6664,7 +6642,6 @@ var GraphAgentExecutor = class {
|
|
|
6664
6642
|
modelId: "",
|
|
6665
6643
|
toolSchemas: [],
|
|
6666
6644
|
toolCallStreamingPolicies: {},
|
|
6667
|
-
toolModelInputRequirement: void 0,
|
|
6668
6645
|
llmOptions: {},
|
|
6669
6646
|
toolDefinitionTokens: 0,
|
|
6670
6647
|
llmMessages: [],
|
|
@@ -7916,10 +7893,6 @@ function parseToolModelInputDeclaration(value) {
|
|
|
7916
7893
|
}
|
|
7917
7894
|
|
|
7918
7895
|
// src/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.ts
|
|
7919
|
-
var TOOL_RESULT_IMAGE_REQUIREMENT = {
|
|
7920
|
-
requires_image_input: true,
|
|
7921
|
-
placements: ["tool_result_image"]
|
|
7922
|
-
};
|
|
7923
7896
|
async function resolveToolModelInput(input) {
|
|
7924
7897
|
if (!input.selections) {
|
|
7925
7898
|
return void 0;
|
|
@@ -7940,16 +7913,6 @@ async function resolveToolModelInput(input) {
|
|
|
7940
7913
|
if (parsed.data.some((reference, index) => reference.id !== input.selections?.[index]?.id)) {
|
|
7941
7914
|
throw new ToolModelInputResolutionError("Tool model input resolver changed attachment identity or order.");
|
|
7942
7915
|
}
|
|
7943
|
-
if (!input.activeModelId) {
|
|
7944
|
-
throw new ToolModelInputResolutionError("Missing successful LLM model for tool input validation.");
|
|
7945
|
-
}
|
|
7946
|
-
if (!input.capabilityValidator) {
|
|
7947
|
-
throw new ToolModelInputResolutionError("Tool model input validator is not configured.");
|
|
7948
|
-
}
|
|
7949
|
-
input.capabilityValidator.assertCompatible({
|
|
7950
|
-
activeModelId: input.activeModelId,
|
|
7951
|
-
requirement: TOOL_RESULT_IMAGE_REQUIREMENT
|
|
7952
|
-
});
|
|
7953
7916
|
return Object.freeze(parsed.data.map((reference) => Object.freeze(reference)));
|
|
7954
7917
|
}
|
|
7955
7918
|
|
|
@@ -8414,8 +8377,7 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
|
|
|
8414
8377
|
"parentRunId",
|
|
8415
8378
|
"childRunDepth",
|
|
8416
8379
|
"childRunContextInjections",
|
|
8417
|
-
"parentToolCallId"
|
|
8418
|
-
"modelInputAdmission"
|
|
8380
|
+
"parentToolCallId"
|
|
8419
8381
|
];
|
|
8420
8382
|
var TOOL_CONTEXT_RUNTIME_BINDINGS_KEY = /* @__PURE__ */ Symbol.for(
|
|
8421
8383
|
"@linnlabs/linnkit/tool-context-runtime-bindings/v1"
|
|
@@ -8716,7 +8678,6 @@ var ToolNodeEventBridge = class {
|
|
|
8716
8678
|
|
|
8717
8679
|
// src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
|
|
8718
8680
|
var logger10 = new Logger("ToolNode");
|
|
8719
|
-
var MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR = "tool.model_input.requirement_resolution_failed: Tool model input requirement could not be resolved";
|
|
8720
8681
|
function parseToolArgs(call) {
|
|
8721
8682
|
const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
|
|
8722
8683
|
if (!rawArguments.trim()) {
|
|
@@ -8820,12 +8781,6 @@ function prepareToolExecution(params) {
|
|
|
8820
8781
|
toolArgs,
|
|
8821
8782
|
idempotencyKey
|
|
8822
8783
|
});
|
|
8823
|
-
const modelInputRequirement = resolveModelInputRequirement({
|
|
8824
|
-
toolDefinition,
|
|
8825
|
-
toolArgs,
|
|
8826
|
-
hasProtocolError: protocolError !== void 0,
|
|
8827
|
-
toolName
|
|
8828
|
-
});
|
|
8829
8784
|
return {
|
|
8830
8785
|
call: params.call,
|
|
8831
8786
|
toolName,
|
|
@@ -8834,30 +8789,9 @@ function prepareToolExecution(params) {
|
|
|
8834
8789
|
toolArgs,
|
|
8835
8790
|
protocolError,
|
|
8836
8791
|
idempotencyKey,
|
|
8837
|
-
...modelInputRequirement.requirement ? { modelInputRequirement: modelInputRequirement.requirement } : {},
|
|
8838
|
-
modelInputDelivery: toolDefinition?.modelInputDelivery ?? "required",
|
|
8839
|
-
...modelInputRequirement.error ? { modelInputRequirementError: modelInputRequirement.error } : {},
|
|
8840
8792
|
bridge
|
|
8841
8793
|
};
|
|
8842
8794
|
}
|
|
8843
|
-
function resolveModelInputRequirement(params) {
|
|
8844
|
-
if (params.hasProtocolError) {
|
|
8845
|
-
return {};
|
|
8846
|
-
}
|
|
8847
|
-
if (!params.toolDefinition?.resolveModelInputRequirement) {
|
|
8848
|
-
return params.toolDefinition?.modelInputRequirement ? { requirement: params.toolDefinition.modelInputRequirement } : {};
|
|
8849
|
-
}
|
|
8850
|
-
try {
|
|
8851
|
-
const requirement = params.toolDefinition.resolveModelInputRequirement(params.toolArgs);
|
|
8852
|
-
return requirement ? { requirement } : {};
|
|
8853
|
-
} catch (error) {
|
|
8854
|
-
logger10.warn("dynamic model input requirement resolution failed", {
|
|
8855
|
-
toolName: params.toolName,
|
|
8856
|
-
errorName: error instanceof Error ? error.name : "UnknownError"
|
|
8857
|
-
});
|
|
8858
|
-
return { error: MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR };
|
|
8859
|
-
}
|
|
8860
|
-
}
|
|
8861
8795
|
function attachWorkingHistoryView(params) {
|
|
8862
8796
|
const historyEvents = parseRuntimeEvents(
|
|
8863
8797
|
params.state.local?.history ?? []
|
|
@@ -9089,14 +9023,6 @@ function readToolObservationPolicy(local) {
|
|
|
9089
9023
|
function readHistoryEvents(local) {
|
|
9090
9024
|
return parseRuntimeEvents(local.history ?? []);
|
|
9091
9025
|
}
|
|
9092
|
-
function readLastSuccessfulLlmModelId(local) {
|
|
9093
|
-
const executorLocal = local.executorLocal;
|
|
9094
|
-
if (!isRecord9(executorLocal)) {
|
|
9095
|
-
return void 0;
|
|
9096
|
-
}
|
|
9097
|
-
const value = executorLocal.lastSuccessfulLlmModelId;
|
|
9098
|
-
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
9099
|
-
}
|
|
9100
9026
|
function formatCapabilityError(error) {
|
|
9101
9027
|
if (isRecord9(error)) {
|
|
9102
9028
|
const codeValue = error.errorCode ?? error.code;
|
|
@@ -9108,29 +9034,12 @@ function formatCapabilityError(error) {
|
|
|
9108
9034
|
}
|
|
9109
9035
|
return error instanceof Error ? error.message : String(error);
|
|
9110
9036
|
}
|
|
9111
|
-
function bindModelInputAdmission(input) {
|
|
9112
|
-
input.context.modelInputAdmission = Object.freeze({
|
|
9113
|
-
requirement: Object.freeze({
|
|
9114
|
-
...input.requirement,
|
|
9115
|
-
placements: Object.freeze([...input.requirement.placements])
|
|
9116
|
-
}),
|
|
9117
|
-
delivery: input.delivery,
|
|
9118
|
-
admitted: input.admitted
|
|
9119
|
-
});
|
|
9120
|
-
}
|
|
9121
|
-
function isOptionalImageInputIncompatibility(reason) {
|
|
9122
|
-
return reason === "image_input_unsupported" || reason === "placement_unsupported";
|
|
9123
|
-
}
|
|
9124
|
-
function shouldDeliverToolModelInput(input) {
|
|
9125
|
-
return input.delivery === "required" || input.context.modelInputAdmission?.admitted === true;
|
|
9126
|
-
}
|
|
9127
9037
|
var ToolNode = class {
|
|
9128
9038
|
id = "tool";
|
|
9129
9039
|
toolRuntime;
|
|
9130
9040
|
observationPreview;
|
|
9131
9041
|
telemetryPort;
|
|
9132
9042
|
auditPort;
|
|
9133
|
-
modelInputCapabilityValidator;
|
|
9134
9043
|
modelInputResolver;
|
|
9135
9044
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
9136
9045
|
constructor(dependencies) {
|
|
@@ -9138,7 +9047,6 @@ var ToolNode = class {
|
|
|
9138
9047
|
this.observationPreview = dependencies.observationPreview;
|
|
9139
9048
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
9140
9049
|
this.auditPort = dependencies.auditPort ?? noopAudit;
|
|
9141
|
-
this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
|
|
9142
9050
|
this.modelInputResolver = dependencies.modelInputResolver;
|
|
9143
9051
|
}
|
|
9144
9052
|
/**
|
|
@@ -9304,7 +9212,6 @@ var ToolNode = class {
|
|
|
9304
9212
|
logger11.warn("no tool name found in call");
|
|
9305
9213
|
return { kind: "yield", events: [] };
|
|
9306
9214
|
}
|
|
9307
|
-
delete prepared.toolContext.modelInputAdmission;
|
|
9308
9215
|
if (typeof execution.protocolError === "string") {
|
|
9309
9216
|
return this.handleError({
|
|
9310
9217
|
...prepared,
|
|
@@ -9322,88 +9229,6 @@ var ToolNode = class {
|
|
|
9322
9229
|
bridge: execution.bridge
|
|
9323
9230
|
});
|
|
9324
9231
|
}
|
|
9325
|
-
if (typeof execution.modelInputRequirementError === "string") {
|
|
9326
|
-
return this.handleError({
|
|
9327
|
-
...prepared,
|
|
9328
|
-
calls,
|
|
9329
|
-
call,
|
|
9330
|
-
toolName: execution.toolName,
|
|
9331
|
-
toolCallId: execution.toolCallId,
|
|
9332
|
-
toolArgs: execution.toolArgs,
|
|
9333
|
-
exec: {
|
|
9334
|
-
success: false,
|
|
9335
|
-
error: execution.modelInputRequirementError,
|
|
9336
|
-
errorKind: "capability",
|
|
9337
|
-
durationMs: 0
|
|
9338
|
-
},
|
|
9339
|
-
bridge: execution.bridge
|
|
9340
|
-
});
|
|
9341
|
-
}
|
|
9342
|
-
if (execution.modelInputRequirement?.requires_image_input === true) {
|
|
9343
|
-
const activeModelId = readLastSuccessfulLlmModelId(prepared.local);
|
|
9344
|
-
let capabilityError;
|
|
9345
|
-
let admitted = true;
|
|
9346
|
-
if (!activeModelId) {
|
|
9347
|
-
capabilityError = "llm.unsupported_capability: missing successful LLM model for tool input validation";
|
|
9348
|
-
} else if (!this.modelInputCapabilityValidator) {
|
|
9349
|
-
capabilityError = "llm.unsupported_capability: tool model input validator is not configured";
|
|
9350
|
-
} else {
|
|
9351
|
-
const validationInput = {
|
|
9352
|
-
activeModelId,
|
|
9353
|
-
requirement: execution.modelInputRequirement
|
|
9354
|
-
};
|
|
9355
|
-
if (execution.modelInputDelivery === "when_supported") {
|
|
9356
|
-
try {
|
|
9357
|
-
const compatibility = this.modelInputCapabilityValidator.evaluate(validationInput);
|
|
9358
|
-
if (!compatibility.compatible) {
|
|
9359
|
-
if (isOptionalImageInputIncompatibility(compatibility.reason)) {
|
|
9360
|
-
admitted = false;
|
|
9361
|
-
logger11.debug("optional tool model input omitted for incompatible active model", {
|
|
9362
|
-
toolName: execution.toolName,
|
|
9363
|
-
activeModelId,
|
|
9364
|
-
reason: compatibility.reason,
|
|
9365
|
-
placements: execution.modelInputRequirement.placements
|
|
9366
|
-
});
|
|
9367
|
-
} else {
|
|
9368
|
-
this.modelInputCapabilityValidator.assertCompatible(validationInput);
|
|
9369
|
-
capabilityError = "llm.unsupported_capability: active model is not eligible";
|
|
9370
|
-
}
|
|
9371
|
-
}
|
|
9372
|
-
} catch (error) {
|
|
9373
|
-
capabilityError = formatCapabilityError(error);
|
|
9374
|
-
}
|
|
9375
|
-
} else {
|
|
9376
|
-
try {
|
|
9377
|
-
this.modelInputCapabilityValidator.assertCompatible(validationInput);
|
|
9378
|
-
} catch (error) {
|
|
9379
|
-
capabilityError = formatCapabilityError(error);
|
|
9380
|
-
}
|
|
9381
|
-
}
|
|
9382
|
-
}
|
|
9383
|
-
if (capabilityError) {
|
|
9384
|
-
return this.handleError({
|
|
9385
|
-
...prepared,
|
|
9386
|
-
calls,
|
|
9387
|
-
call,
|
|
9388
|
-
toolName: execution.toolName,
|
|
9389
|
-
toolCallId: execution.toolCallId,
|
|
9390
|
-
toolArgs: execution.toolArgs,
|
|
9391
|
-
exec: {
|
|
9392
|
-
success: false,
|
|
9393
|
-
error: capabilityError,
|
|
9394
|
-
errorKind: "capability",
|
|
9395
|
-
durationMs: 0
|
|
9396
|
-
},
|
|
9397
|
-
bridge: execution.bridge
|
|
9398
|
-
});
|
|
9399
|
-
}
|
|
9400
|
-
bindModelInputAdmission({
|
|
9401
|
-
context: prepared.toolContext,
|
|
9402
|
-
requirement: execution.modelInputRequirement,
|
|
9403
|
-
delivery: execution.modelInputDelivery,
|
|
9404
|
-
admitted
|
|
9405
|
-
});
|
|
9406
|
-
}
|
|
9407
9232
|
await this.emitToolDecisionAudit({
|
|
9408
9233
|
action: "tool.allow",
|
|
9409
9234
|
toolName: execution.toolName,
|
|
@@ -9455,21 +9280,15 @@ var ToolNode = class {
|
|
|
9455
9280
|
bridge: execution.bridge
|
|
9456
9281
|
});
|
|
9457
9282
|
}
|
|
9458
|
-
|
|
9459
|
-
context: prepared.toolContext,
|
|
9460
|
-
delivery: execution.modelInputDelivery
|
|
9461
|
-
});
|
|
9462
|
-
let attachments = deliverModelInput ? exec.cachedAttachments : void 0;
|
|
9283
|
+
let attachments = exec.cachedAttachments;
|
|
9463
9284
|
try {
|
|
9464
|
-
if (
|
|
9285
|
+
if (!attachments) {
|
|
9465
9286
|
attachments = await resolveToolModelInput({
|
|
9466
|
-
activeModelId: readLastSuccessfulLlmModelId(prepared.local),
|
|
9467
9287
|
toolName: execution.toolName,
|
|
9468
9288
|
toolCallId: execution.toolCallId,
|
|
9469
9289
|
selections: contract.modelInputAttachments,
|
|
9470
9290
|
context: prepared.toolContext,
|
|
9471
|
-
resolver: this.modelInputResolver
|
|
9472
|
-
capabilityValidator: this.modelInputCapabilityValidator
|
|
9291
|
+
resolver: this.modelInputResolver
|
|
9473
9292
|
});
|
|
9474
9293
|
}
|
|
9475
9294
|
} catch (error) {
|
|
@@ -10178,10 +9997,6 @@ function formatUnknownToolArguments(fields, allowedFields) {
|
|
|
10178
9997
|
// src/runtime-kernel/tools/toolContracts.ts
|
|
10179
9998
|
var BaseTool = class {
|
|
10180
9999
|
idempotency;
|
|
10181
|
-
modelInputRequirement;
|
|
10182
|
-
/** 模型输入是工具成功的必要结果,还是仅在当前模型支持时提供的增强反馈。 */
|
|
10183
|
-
modelInputDelivery;
|
|
10184
|
-
resolveModelInputRequirement;
|
|
10185
10000
|
streaming;
|
|
10186
10001
|
getExecutionSummary(output) {
|
|
10187
10002
|
const FULL_CONTENT_THRESHOLD = 200;
|
|
@@ -12459,7 +12274,6 @@ var ChildRunInvoker = class {
|
|
|
12459
12274
|
createLlmNode;
|
|
12460
12275
|
toolRuntime;
|
|
12461
12276
|
observationPreview;
|
|
12462
|
-
modelInputCapabilityValidator;
|
|
12463
12277
|
modelInputResolver;
|
|
12464
12278
|
eventToMessageConverter;
|
|
12465
12279
|
defaultJudgeToolName;
|
|
@@ -12470,7 +12284,6 @@ var ChildRunInvoker = class {
|
|
|
12470
12284
|
this.createLlmNode = dependencies.createLlmNode;
|
|
12471
12285
|
this.toolRuntime = dependencies.toolRuntime;
|
|
12472
12286
|
this.observationPreview = dependencies.observationPreview;
|
|
12473
|
-
this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
|
|
12474
12287
|
this.modelInputResolver = dependencies.modelInputResolver;
|
|
12475
12288
|
this.eventToMessageConverter = dependencies.eventToMessageConverter;
|
|
12476
12289
|
this.defaultJudgeToolName = dependencies.defaultJudgeToolName;
|
|
@@ -12733,7 +12546,6 @@ var ChildRunInvoker = class {
|
|
|
12733
12546
|
observationPreview: this.observationPreview,
|
|
12734
12547
|
telemetryPort: this.telemetryPort,
|
|
12735
12548
|
auditPort: this.auditPort,
|
|
12736
|
-
modelInputCapabilityValidator: this.modelInputCapabilityValidator,
|
|
12737
12549
|
modelInputResolver: this.modelInputResolver
|
|
12738
12550
|
}));
|
|
12739
12551
|
graph.registerNode(new WaitUserNode({ auditPort: this.auditPort }));
|
|
@@ -14843,7 +14655,6 @@ function createDefaultGraphExecutor(options) {
|
|
|
14843
14655
|
observationPreview: options.observationPreview,
|
|
14844
14656
|
auditPort: options.auditPort,
|
|
14845
14657
|
telemetryPort: options.telemetryPort,
|
|
14846
|
-
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
14847
14658
|
modelInputResolver: options.modelInputResolver
|
|
14848
14659
|
}));
|
|
14849
14660
|
executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
|
|
@@ -14882,7 +14693,6 @@ function createGraphLoopHarness(options) {
|
|
|
14882
14693
|
maxSteps,
|
|
14883
14694
|
auditPort: options.auditPort,
|
|
14884
14695
|
telemetryPort: options.telemetryPort,
|
|
14885
|
-
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
14886
14696
|
modelInputResolver: options.modelInputResolver
|
|
14887
14697
|
});
|
|
14888
14698
|
const local = {
|