@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
|
@@ -3,8 +3,8 @@ import { ProviderContinuation } from '../../contracts/provider-continuation.cjs'
|
|
|
3
3
|
import { CanonicalInferenceRequest, CanonicalInferenceFinishReason } from '../../ports/canonical-inference.cjs';
|
|
4
4
|
import { LlmCallOptions } from '../../ports/llm-call.cjs';
|
|
5
5
|
import { LlmInputMaterializerPort } from '../../ports/llm-input-materialization.cjs';
|
|
6
|
-
import { ModelCatalogLike } from '../../runtime-kernel/llm/modelCatalog.cjs';
|
|
7
6
|
import { LlmCaller } from '../../runtime-kernel/llm/caller.cjs';
|
|
7
|
+
import { ModelCatalogLike } from '../../runtime-kernel/llm/modelCatalog.cjs';
|
|
8
8
|
|
|
9
9
|
type ScriptedLlmCaller = LlmCaller;
|
|
10
10
|
interface ScriptedLlmCall {
|
|
@@ -3,8 +3,8 @@ import { ProviderContinuation } from '../../contracts/provider-continuation.js';
|
|
|
3
3
|
import { CanonicalInferenceRequest, CanonicalInferenceFinishReason } from '../../ports/canonical-inference.js';
|
|
4
4
|
import { LlmCallOptions } from '../../ports/llm-call.js';
|
|
5
5
|
import { LlmInputMaterializerPort } from '../../ports/llm-input-materialization.js';
|
|
6
|
-
import { ModelCatalogLike } from '../../runtime-kernel/llm/modelCatalog.js';
|
|
7
6
|
import { LlmCaller } from '../../runtime-kernel/llm/caller.js';
|
|
7
|
+
import { ModelCatalogLike } from '../../runtime-kernel/llm/modelCatalog.js';
|
|
8
8
|
|
|
9
9
|
type ScriptedLlmCaller = LlmCaller;
|
|
10
10
|
interface ScriptedLlmCall {
|
package/dist/testkit.cjs
CHANGED
|
@@ -3199,6 +3199,16 @@ function mergeResumeSessionLocal(persistedLocal, localPatch) {
|
|
|
3199
3199
|
}
|
|
3200
3200
|
};
|
|
3201
3201
|
}
|
|
3202
|
+
function resolveResumeNodeId(local, requested) {
|
|
3203
|
+
const pending = local?.pendingToolCalls;
|
|
3204
|
+
if (!Array.isArray(pending) || pending.length === 0) return requested ?? "llm";
|
|
3205
|
+
if (requested !== void 0 && requested !== "tool") {
|
|
3206
|
+
throw new Error(
|
|
3207
|
+
`Graph resume must first run ${pending.length} pending tool call(s) from the interrupted batch: requested node=${requested}`
|
|
3208
|
+
);
|
|
3209
|
+
}
|
|
3210
|
+
return "tool";
|
|
3211
|
+
}
|
|
3202
3212
|
var GraphExecutor = class {
|
|
3203
3213
|
constructor(checkpointer, config = {}) {
|
|
3204
3214
|
this.checkpointer = checkpointer;
|
|
@@ -3311,13 +3321,14 @@ var GraphExecutor = class {
|
|
|
3311
3321
|
);
|
|
3312
3322
|
}
|
|
3313
3323
|
const resumedLocal = mergeResumeSessionLocal(current.local, input.localPatch);
|
|
3324
|
+
const nodeId = resolveResumeNodeId(resumedLocal, input.nodeId);
|
|
3314
3325
|
if (this.executionCheckpointPort && current.local?.executorLocal) {
|
|
3315
3326
|
resumedLocal.executorLocal = { ...current.local.executorLocal };
|
|
3316
3327
|
}
|
|
3317
3328
|
this.ephemeralLocals.set(checkpointKey, resumedLocal);
|
|
3318
3329
|
await this.commitCheckpoint(checkpointKey, {
|
|
3319
3330
|
...current,
|
|
3320
|
-
nodeId
|
|
3331
|
+
nodeId,
|
|
3321
3332
|
...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
|
|
3322
3333
|
revision: currentRevision + 1,
|
|
3323
3334
|
local: sanitizeCheckpointLocal(resumedLocal)
|
|
@@ -4198,7 +4209,6 @@ var tickPipelineContextKeys = [
|
|
|
4198
4209
|
"runtimeEventCommitPort",
|
|
4199
4210
|
"modelId",
|
|
4200
4211
|
"toolSchemas",
|
|
4201
|
-
"toolModelInputRequirement",
|
|
4202
4212
|
"toolCallStreamingPolicies",
|
|
4203
4213
|
"llmOptions",
|
|
4204
4214
|
"toolDefinitionTokens",
|
|
@@ -5319,7 +5329,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5319
5329
|
"outputProcessor",
|
|
5320
5330
|
"modelId",
|
|
5321
5331
|
"llmMessages",
|
|
5322
|
-
"toolModelInputRequirement",
|
|
5323
5332
|
"toolCallStreamingPolicies",
|
|
5324
5333
|
"imageInputAdmissionEvidence",
|
|
5325
5334
|
"llmOptions",
|
|
@@ -5378,7 +5387,6 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5378
5387
|
},
|
|
5379
5388
|
{
|
|
5380
5389
|
imageInputAdmissionEvidence: ctx.imageInputAdmissionEvidence,
|
|
5381
|
-
additionalModelInputRequirement: ctx.toolModelInputRequirement,
|
|
5382
5390
|
toolCallStreamingPolicies: ctx.toolCallStreamingPolicies,
|
|
5383
5391
|
...promptBudget && promptUsageMeasurementPolicy ? {
|
|
5384
5392
|
measurePromptUsage: async (activeModelId, messages) => {
|
|
@@ -6363,29 +6371,6 @@ function createCommitContextCompactionStage() {
|
|
|
6363
6371
|
});
|
|
6364
6372
|
}
|
|
6365
6373
|
|
|
6366
|
-
// src/runtime-kernel/graph-engine/functions/prepareModelCompatibleTools.ts
|
|
6367
|
-
function prepareModelCompatibleTools(input) {
|
|
6368
|
-
const schemas = [];
|
|
6369
|
-
const requirements = [];
|
|
6370
|
-
for (const schema of input.schemas) {
|
|
6371
|
-
const definition = input.getToolDefinition(schema.function.name);
|
|
6372
|
-
const requirement = definition?.modelInputRequirement;
|
|
6373
|
-
const delivery = definition?.modelInputDelivery ?? "required";
|
|
6374
|
-
const isRequired = delivery === "required";
|
|
6375
|
-
if (requirement && isRequired && !evaluateModelInputCompatibility(input.model, requirement).compatible) {
|
|
6376
|
-
continue;
|
|
6377
|
-
}
|
|
6378
|
-
schemas.push(schema);
|
|
6379
|
-
if (requirement && isRequired) {
|
|
6380
|
-
requirements.push(requirement);
|
|
6381
|
-
}
|
|
6382
|
-
}
|
|
6383
|
-
return {
|
|
6384
|
-
schemas: Object.freeze(schemas),
|
|
6385
|
-
requirement: requirements.length > 0 ? mergeModelInputRequirements(...requirements) : EMPTY_MODEL_INPUT_REQUIREMENT
|
|
6386
|
-
};
|
|
6387
|
-
}
|
|
6388
|
-
|
|
6389
6374
|
// src/runtime-kernel/graph-engine/tick-pipeline/stages/prepareCallStage.ts
|
|
6390
6375
|
function createPrepareCallStage(dependencies) {
|
|
6391
6376
|
return defineTickStage({
|
|
@@ -6403,7 +6388,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6403
6388
|
writes: [
|
|
6404
6389
|
"modelId",
|
|
6405
6390
|
"toolSchemas",
|
|
6406
|
-
"toolModelInputRequirement",
|
|
6407
6391
|
"toolCallStreamingPolicies",
|
|
6408
6392
|
"llmOptions",
|
|
6409
6393
|
"toolDefinitionTokens"
|
|
@@ -6443,12 +6427,7 @@ function createPrepareCallStage(dependencies) {
|
|
|
6443
6427
|
invocation: ctx.request
|
|
6444
6428
|
});
|
|
6445
6429
|
const modelConfig = dependencies.modelCatalog.getModelById(modelId);
|
|
6446
|
-
const
|
|
6447
|
-
schemas: candidateToolSchemas,
|
|
6448
|
-
model: modelConfig,
|
|
6449
|
-
getToolDefinition: (toolName) => dependencies.toolCatalog.getToolDefinition(toolName)
|
|
6450
|
-
});
|
|
6451
|
-
const toolSchemas = [...toolPreparation.schemas];
|
|
6430
|
+
const toolSchemas = [...candidateToolSchemas];
|
|
6452
6431
|
const toolCallStreamingPolicies = deriveToolCallStreamingPolicies(
|
|
6453
6432
|
toolSchemas,
|
|
6454
6433
|
dependencies.toolCatalog
|
|
@@ -6492,7 +6471,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6492
6471
|
return {
|
|
6493
6472
|
modelId,
|
|
6494
6473
|
toolSchemas,
|
|
6495
|
-
toolModelInputRequirement: toolPreparation.requirement,
|
|
6496
6474
|
toolCallStreamingPolicies,
|
|
6497
6475
|
llmOptions,
|
|
6498
6476
|
toolDefinitionTokens
|
|
@@ -6666,7 +6644,6 @@ var GraphAgentExecutor = class {
|
|
|
6666
6644
|
modelId: "",
|
|
6667
6645
|
toolSchemas: [],
|
|
6668
6646
|
toolCallStreamingPolicies: {},
|
|
6669
|
-
toolModelInputRequirement: void 0,
|
|
6670
6647
|
llmOptions: {},
|
|
6671
6648
|
toolDefinitionTokens: 0,
|
|
6672
6649
|
llmMessages: [],
|
|
@@ -7918,10 +7895,6 @@ function parseToolModelInputDeclaration(value) {
|
|
|
7918
7895
|
}
|
|
7919
7896
|
|
|
7920
7897
|
// src/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.ts
|
|
7921
|
-
var TOOL_RESULT_IMAGE_REQUIREMENT = {
|
|
7922
|
-
requires_image_input: true,
|
|
7923
|
-
placements: ["tool_result_image"]
|
|
7924
|
-
};
|
|
7925
7898
|
async function resolveToolModelInput(input) {
|
|
7926
7899
|
if (!input.selections) {
|
|
7927
7900
|
return void 0;
|
|
@@ -7942,16 +7915,6 @@ async function resolveToolModelInput(input) {
|
|
|
7942
7915
|
if (parsed.data.some((reference, index) => reference.id !== input.selections?.[index]?.id)) {
|
|
7943
7916
|
throw new ToolModelInputResolutionError("Tool model input resolver changed attachment identity or order.");
|
|
7944
7917
|
}
|
|
7945
|
-
if (!input.activeModelId) {
|
|
7946
|
-
throw new ToolModelInputResolutionError("Missing successful LLM model for tool input validation.");
|
|
7947
|
-
}
|
|
7948
|
-
if (!input.capabilityValidator) {
|
|
7949
|
-
throw new ToolModelInputResolutionError("Tool model input validator is not configured.");
|
|
7950
|
-
}
|
|
7951
|
-
input.capabilityValidator.assertCompatible({
|
|
7952
|
-
activeModelId: input.activeModelId,
|
|
7953
|
-
requirement: TOOL_RESULT_IMAGE_REQUIREMENT
|
|
7954
|
-
});
|
|
7955
7918
|
return Object.freeze(parsed.data.map((reference) => Object.freeze(reference)));
|
|
7956
7919
|
}
|
|
7957
7920
|
|
|
@@ -8416,8 +8379,7 @@ var TOOL_CONTEXT_RUNTIME_RESERVED_KEYS = [
|
|
|
8416
8379
|
"parentRunId",
|
|
8417
8380
|
"childRunDepth",
|
|
8418
8381
|
"childRunContextInjections",
|
|
8419
|
-
"parentToolCallId"
|
|
8420
|
-
"modelInputAdmission"
|
|
8382
|
+
"parentToolCallId"
|
|
8421
8383
|
];
|
|
8422
8384
|
var TOOL_CONTEXT_RUNTIME_BINDINGS_KEY = /* @__PURE__ */ Symbol.for(
|
|
8423
8385
|
"@linnlabs/linnkit/tool-context-runtime-bindings/v1"
|
|
@@ -8718,7 +8680,6 @@ var ToolNodeEventBridge = class {
|
|
|
8718
8680
|
|
|
8719
8681
|
// src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
|
|
8720
8682
|
var logger10 = new Logger("ToolNode");
|
|
8721
|
-
var MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR = "tool.model_input.requirement_resolution_failed: Tool model input requirement could not be resolved";
|
|
8722
8683
|
function parseToolArgs(call) {
|
|
8723
8684
|
const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
|
|
8724
8685
|
if (!rawArguments.trim()) {
|
|
@@ -8822,12 +8783,6 @@ function prepareToolExecution(params) {
|
|
|
8822
8783
|
toolArgs,
|
|
8823
8784
|
idempotencyKey
|
|
8824
8785
|
});
|
|
8825
|
-
const modelInputRequirement = resolveModelInputRequirement({
|
|
8826
|
-
toolDefinition,
|
|
8827
|
-
toolArgs,
|
|
8828
|
-
hasProtocolError: protocolError !== void 0,
|
|
8829
|
-
toolName
|
|
8830
|
-
});
|
|
8831
8786
|
return {
|
|
8832
8787
|
call: params.call,
|
|
8833
8788
|
toolName,
|
|
@@ -8836,30 +8791,9 @@ function prepareToolExecution(params) {
|
|
|
8836
8791
|
toolArgs,
|
|
8837
8792
|
protocolError,
|
|
8838
8793
|
idempotencyKey,
|
|
8839
|
-
...modelInputRequirement.requirement ? { modelInputRequirement: modelInputRequirement.requirement } : {},
|
|
8840
|
-
modelInputDelivery: toolDefinition?.modelInputDelivery ?? "required",
|
|
8841
|
-
...modelInputRequirement.error ? { modelInputRequirementError: modelInputRequirement.error } : {},
|
|
8842
8794
|
bridge
|
|
8843
8795
|
};
|
|
8844
8796
|
}
|
|
8845
|
-
function resolveModelInputRequirement(params) {
|
|
8846
|
-
if (params.hasProtocolError) {
|
|
8847
|
-
return {};
|
|
8848
|
-
}
|
|
8849
|
-
if (!params.toolDefinition?.resolveModelInputRequirement) {
|
|
8850
|
-
return params.toolDefinition?.modelInputRequirement ? { requirement: params.toolDefinition.modelInputRequirement } : {};
|
|
8851
|
-
}
|
|
8852
|
-
try {
|
|
8853
|
-
const requirement = params.toolDefinition.resolveModelInputRequirement(params.toolArgs);
|
|
8854
|
-
return requirement ? { requirement } : {};
|
|
8855
|
-
} catch (error) {
|
|
8856
|
-
logger10.warn("dynamic model input requirement resolution failed", {
|
|
8857
|
-
toolName: params.toolName,
|
|
8858
|
-
errorName: error instanceof Error ? error.name : "UnknownError"
|
|
8859
|
-
});
|
|
8860
|
-
return { error: MODEL_INPUT_REQUIREMENT_RESOLUTION_ERROR };
|
|
8861
|
-
}
|
|
8862
|
-
}
|
|
8863
8797
|
function attachWorkingHistoryView(params) {
|
|
8864
8798
|
const historyEvents = parseRuntimeEvents(
|
|
8865
8799
|
params.state.local?.history ?? []
|
|
@@ -9091,14 +9025,6 @@ function readToolObservationPolicy(local) {
|
|
|
9091
9025
|
function readHistoryEvents(local) {
|
|
9092
9026
|
return parseRuntimeEvents(local.history ?? []);
|
|
9093
9027
|
}
|
|
9094
|
-
function readLastSuccessfulLlmModelId(local) {
|
|
9095
|
-
const executorLocal = local.executorLocal;
|
|
9096
|
-
if (!isRecord9(executorLocal)) {
|
|
9097
|
-
return void 0;
|
|
9098
|
-
}
|
|
9099
|
-
const value = executorLocal.lastSuccessfulLlmModelId;
|
|
9100
|
-
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
9101
|
-
}
|
|
9102
9028
|
function formatCapabilityError(error) {
|
|
9103
9029
|
if (isRecord9(error)) {
|
|
9104
9030
|
const codeValue = error.errorCode ?? error.code;
|
|
@@ -9110,29 +9036,12 @@ function formatCapabilityError(error) {
|
|
|
9110
9036
|
}
|
|
9111
9037
|
return error instanceof Error ? error.message : String(error);
|
|
9112
9038
|
}
|
|
9113
|
-
function bindModelInputAdmission(input) {
|
|
9114
|
-
input.context.modelInputAdmission = Object.freeze({
|
|
9115
|
-
requirement: Object.freeze({
|
|
9116
|
-
...input.requirement,
|
|
9117
|
-
placements: Object.freeze([...input.requirement.placements])
|
|
9118
|
-
}),
|
|
9119
|
-
delivery: input.delivery,
|
|
9120
|
-
admitted: input.admitted
|
|
9121
|
-
});
|
|
9122
|
-
}
|
|
9123
|
-
function isOptionalImageInputIncompatibility(reason) {
|
|
9124
|
-
return reason === "image_input_unsupported" || reason === "placement_unsupported";
|
|
9125
|
-
}
|
|
9126
|
-
function shouldDeliverToolModelInput(input) {
|
|
9127
|
-
return input.delivery === "required" || input.context.modelInputAdmission?.admitted === true;
|
|
9128
|
-
}
|
|
9129
9039
|
var ToolNode = class {
|
|
9130
9040
|
id = "tool";
|
|
9131
9041
|
toolRuntime;
|
|
9132
9042
|
observationPreview;
|
|
9133
9043
|
telemetryPort;
|
|
9134
9044
|
auditPort;
|
|
9135
|
-
modelInputCapabilityValidator;
|
|
9136
9045
|
modelInputResolver;
|
|
9137
9046
|
idempotencyInFlight = /* @__PURE__ */ new Map();
|
|
9138
9047
|
constructor(dependencies) {
|
|
@@ -9140,7 +9049,6 @@ var ToolNode = class {
|
|
|
9140
9049
|
this.observationPreview = dependencies.observationPreview;
|
|
9141
9050
|
this.telemetryPort = dependencies.telemetryPort ?? noopTelemetry;
|
|
9142
9051
|
this.auditPort = dependencies.auditPort ?? noopAudit;
|
|
9143
|
-
this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
|
|
9144
9052
|
this.modelInputResolver = dependencies.modelInputResolver;
|
|
9145
9053
|
}
|
|
9146
9054
|
/**
|
|
@@ -9306,7 +9214,6 @@ var ToolNode = class {
|
|
|
9306
9214
|
logger11.warn("no tool name found in call");
|
|
9307
9215
|
return { kind: "yield", events: [] };
|
|
9308
9216
|
}
|
|
9309
|
-
delete prepared.toolContext.modelInputAdmission;
|
|
9310
9217
|
if (typeof execution.protocolError === "string") {
|
|
9311
9218
|
return this.handleError({
|
|
9312
9219
|
...prepared,
|
|
@@ -9324,88 +9231,6 @@ var ToolNode = class {
|
|
|
9324
9231
|
bridge: execution.bridge
|
|
9325
9232
|
});
|
|
9326
9233
|
}
|
|
9327
|
-
if (typeof execution.modelInputRequirementError === "string") {
|
|
9328
|
-
return this.handleError({
|
|
9329
|
-
...prepared,
|
|
9330
|
-
calls,
|
|
9331
|
-
call,
|
|
9332
|
-
toolName: execution.toolName,
|
|
9333
|
-
toolCallId: execution.toolCallId,
|
|
9334
|
-
toolArgs: execution.toolArgs,
|
|
9335
|
-
exec: {
|
|
9336
|
-
success: false,
|
|
9337
|
-
error: execution.modelInputRequirementError,
|
|
9338
|
-
errorKind: "capability",
|
|
9339
|
-
durationMs: 0
|
|
9340
|
-
},
|
|
9341
|
-
bridge: execution.bridge
|
|
9342
|
-
});
|
|
9343
|
-
}
|
|
9344
|
-
if (execution.modelInputRequirement?.requires_image_input === true) {
|
|
9345
|
-
const activeModelId = readLastSuccessfulLlmModelId(prepared.local);
|
|
9346
|
-
let capabilityError;
|
|
9347
|
-
let admitted = true;
|
|
9348
|
-
if (!activeModelId) {
|
|
9349
|
-
capabilityError = "llm.unsupported_capability: missing successful LLM model for tool input validation";
|
|
9350
|
-
} else if (!this.modelInputCapabilityValidator) {
|
|
9351
|
-
capabilityError = "llm.unsupported_capability: tool model input validator is not configured";
|
|
9352
|
-
} else {
|
|
9353
|
-
const validationInput = {
|
|
9354
|
-
activeModelId,
|
|
9355
|
-
requirement: execution.modelInputRequirement
|
|
9356
|
-
};
|
|
9357
|
-
if (execution.modelInputDelivery === "when_supported") {
|
|
9358
|
-
try {
|
|
9359
|
-
const compatibility = this.modelInputCapabilityValidator.evaluate(validationInput);
|
|
9360
|
-
if (!compatibility.compatible) {
|
|
9361
|
-
if (isOptionalImageInputIncompatibility(compatibility.reason)) {
|
|
9362
|
-
admitted = false;
|
|
9363
|
-
logger11.debug("optional tool model input omitted for incompatible active model", {
|
|
9364
|
-
toolName: execution.toolName,
|
|
9365
|
-
activeModelId,
|
|
9366
|
-
reason: compatibility.reason,
|
|
9367
|
-
placements: execution.modelInputRequirement.placements
|
|
9368
|
-
});
|
|
9369
|
-
} else {
|
|
9370
|
-
this.modelInputCapabilityValidator.assertCompatible(validationInput);
|
|
9371
|
-
capabilityError = "llm.unsupported_capability: active model is not eligible";
|
|
9372
|
-
}
|
|
9373
|
-
}
|
|
9374
|
-
} catch (error) {
|
|
9375
|
-
capabilityError = formatCapabilityError(error);
|
|
9376
|
-
}
|
|
9377
|
-
} else {
|
|
9378
|
-
try {
|
|
9379
|
-
this.modelInputCapabilityValidator.assertCompatible(validationInput);
|
|
9380
|
-
} catch (error) {
|
|
9381
|
-
capabilityError = formatCapabilityError(error);
|
|
9382
|
-
}
|
|
9383
|
-
}
|
|
9384
|
-
}
|
|
9385
|
-
if (capabilityError) {
|
|
9386
|
-
return this.handleError({
|
|
9387
|
-
...prepared,
|
|
9388
|
-
calls,
|
|
9389
|
-
call,
|
|
9390
|
-
toolName: execution.toolName,
|
|
9391
|
-
toolCallId: execution.toolCallId,
|
|
9392
|
-
toolArgs: execution.toolArgs,
|
|
9393
|
-
exec: {
|
|
9394
|
-
success: false,
|
|
9395
|
-
error: capabilityError,
|
|
9396
|
-
errorKind: "capability",
|
|
9397
|
-
durationMs: 0
|
|
9398
|
-
},
|
|
9399
|
-
bridge: execution.bridge
|
|
9400
|
-
});
|
|
9401
|
-
}
|
|
9402
|
-
bindModelInputAdmission({
|
|
9403
|
-
context: prepared.toolContext,
|
|
9404
|
-
requirement: execution.modelInputRequirement,
|
|
9405
|
-
delivery: execution.modelInputDelivery,
|
|
9406
|
-
admitted
|
|
9407
|
-
});
|
|
9408
|
-
}
|
|
9409
9234
|
await this.emitToolDecisionAudit({
|
|
9410
9235
|
action: "tool.allow",
|
|
9411
9236
|
toolName: execution.toolName,
|
|
@@ -9457,21 +9282,15 @@ var ToolNode = class {
|
|
|
9457
9282
|
bridge: execution.bridge
|
|
9458
9283
|
});
|
|
9459
9284
|
}
|
|
9460
|
-
|
|
9461
|
-
context: prepared.toolContext,
|
|
9462
|
-
delivery: execution.modelInputDelivery
|
|
9463
|
-
});
|
|
9464
|
-
let attachments = deliverModelInput ? exec.cachedAttachments : void 0;
|
|
9285
|
+
let attachments = exec.cachedAttachments;
|
|
9465
9286
|
try {
|
|
9466
|
-
if (
|
|
9287
|
+
if (!attachments) {
|
|
9467
9288
|
attachments = await resolveToolModelInput({
|
|
9468
|
-
activeModelId: readLastSuccessfulLlmModelId(prepared.local),
|
|
9469
9289
|
toolName: execution.toolName,
|
|
9470
9290
|
toolCallId: execution.toolCallId,
|
|
9471
9291
|
selections: contract.modelInputAttachments,
|
|
9472
9292
|
context: prepared.toolContext,
|
|
9473
|
-
resolver: this.modelInputResolver
|
|
9474
|
-
capabilityValidator: this.modelInputCapabilityValidator
|
|
9293
|
+
resolver: this.modelInputResolver
|
|
9475
9294
|
});
|
|
9476
9295
|
}
|
|
9477
9296
|
} catch (error) {
|
|
@@ -10180,10 +9999,6 @@ function formatUnknownToolArguments(fields, allowedFields) {
|
|
|
10180
9999
|
// src/runtime-kernel/tools/toolContracts.ts
|
|
10181
10000
|
var BaseTool = class {
|
|
10182
10001
|
idempotency;
|
|
10183
|
-
modelInputRequirement;
|
|
10184
|
-
/** 模型输入是工具成功的必要结果,还是仅在当前模型支持时提供的增强反馈。 */
|
|
10185
|
-
modelInputDelivery;
|
|
10186
|
-
resolveModelInputRequirement;
|
|
10187
10002
|
streaming;
|
|
10188
10003
|
getExecutionSummary(output) {
|
|
10189
10004
|
const FULL_CONTENT_THRESHOLD = 200;
|
|
@@ -12461,7 +12276,6 @@ var ChildRunInvoker = class {
|
|
|
12461
12276
|
createLlmNode;
|
|
12462
12277
|
toolRuntime;
|
|
12463
12278
|
observationPreview;
|
|
12464
|
-
modelInputCapabilityValidator;
|
|
12465
12279
|
modelInputResolver;
|
|
12466
12280
|
eventToMessageConverter;
|
|
12467
12281
|
defaultJudgeToolName;
|
|
@@ -12472,7 +12286,6 @@ var ChildRunInvoker = class {
|
|
|
12472
12286
|
this.createLlmNode = dependencies.createLlmNode;
|
|
12473
12287
|
this.toolRuntime = dependencies.toolRuntime;
|
|
12474
12288
|
this.observationPreview = dependencies.observationPreview;
|
|
12475
|
-
this.modelInputCapabilityValidator = dependencies.modelInputCapabilityValidator;
|
|
12476
12289
|
this.modelInputResolver = dependencies.modelInputResolver;
|
|
12477
12290
|
this.eventToMessageConverter = dependencies.eventToMessageConverter;
|
|
12478
12291
|
this.defaultJudgeToolName = dependencies.defaultJudgeToolName;
|
|
@@ -12735,7 +12548,6 @@ var ChildRunInvoker = class {
|
|
|
12735
12548
|
observationPreview: this.observationPreview,
|
|
12736
12549
|
telemetryPort: this.telemetryPort,
|
|
12737
12550
|
auditPort: this.auditPort,
|
|
12738
|
-
modelInputCapabilityValidator: this.modelInputCapabilityValidator,
|
|
12739
12551
|
modelInputResolver: this.modelInputResolver
|
|
12740
12552
|
}));
|
|
12741
12553
|
graph.registerNode(new WaitUserNode({ auditPort: this.auditPort }));
|
|
@@ -14845,7 +14657,6 @@ function createDefaultGraphExecutor(options) {
|
|
|
14845
14657
|
observationPreview: options.observationPreview,
|
|
14846
14658
|
auditPort: options.auditPort,
|
|
14847
14659
|
telemetryPort: options.telemetryPort,
|
|
14848
|
-
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
14849
14660
|
modelInputResolver: options.modelInputResolver
|
|
14850
14661
|
}));
|
|
14851
14662
|
executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
|
|
@@ -14884,7 +14695,6 @@ function createGraphLoopHarness(options) {
|
|
|
14884
14695
|
maxSteps,
|
|
14885
14696
|
auditPort: options.auditPort,
|
|
14886
14697
|
telemetryPort: options.telemetryPort,
|
|
14887
|
-
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
14888
14698
|
modelInputResolver: options.modelInputResolver
|
|
14889
14699
|
});
|
|
14890
14700
|
const local = {
|