@insmind/cli 2.1.0 → 2.1.2
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/README.md +30 -0
- package/contracts/operations/agent.send/input.schema.json +1 -77
- package/contracts/operations/dam.folder.list/input.schema.json +0 -1
- package/contracts/operations/dam.folder.list/output.schema.json +1 -2
- package/contracts/operations/dam.list/input.schema.json +3 -6
- package/contracts/operations/dam.list/output.schema.json +1 -2
- package/contracts/operations/dam.search/input.schema.json +3 -6
- package/contracts/operations/dam.search/output.schema.json +1 -2
- package/contracts/operations/tool.call/models/image-edit-smart.schema.json +1 -2
- package/contracts/operations/tool.call/models/image-expand-smart.schema.json +1 -2
- package/contracts/operations/tool.call/models/image-layers-smart.schema.json +1 -3
- package/contracts/operations/tool.call/models/video-edit-smart.schema.json +0 -3
- package/contracts/operations/tool.call/ocr-payload.schema.json +4 -5
- package/dist/bin/postinstall.js +22 -6
- package/dist/bin/sync-skill.js +33 -0
- package/dist/bin/task-worker.js +2 -2
- package/dist/src/bootstrap/create-cli.js +13 -6
- package/dist/src/bootstrap/create-runtime.js +103 -29
- package/dist/src/bootstrap/run-task-worker.js +6 -2
- package/dist/src/bootstrap/validators.js +87 -151
- package/dist/src/cli/action-binding.js +14 -37
- package/dist/src/cli/agent-commands.js +13 -13
- package/dist/src/cli/auth-commands.js +2 -1
- package/dist/src/cli/creation-help.js +9 -0
- package/dist/src/cli/dam-commands.js +10 -14
- package/dist/src/cli/editor-commands.js +16 -12
- package/dist/src/cli/errors.js +84 -26
- package/dist/src/cli/host-input.js +62 -5
- package/dist/src/cli/model-commands.js +9 -3
- package/dist/src/cli/observed-errors.js +7 -3
- package/dist/src/cli/org-commands.js +3 -1
- package/dist/src/cli/presenter.js +4 -5
- package/dist/src/cli/task-commands.js +6 -2
- package/dist/src/cli/tool-commands.js +12 -11
- package/dist/src/contracts/creation-input.js +20 -17
- package/dist/src/features/agent/creative-agent-adapter.js +6 -2
- package/dist/src/features/agent/creative-protocol.js +8 -29
- package/dist/src/features/agent/resource-authorizer.js +25 -17
- package/dist/src/features/agent/result-reader.js +31 -14
- package/dist/src/features/agent/use-cases.js +6 -31
- package/dist/src/features/auth/credential-store.js +1 -0
- package/dist/src/features/credits/use-cases.js +55 -28
- package/dist/src/features/dam/asset-projection.js +3 -6
- package/dist/src/features/dam/dam-api-adapter.js +30 -15
- package/dist/src/features/dam/object-storage.js +2 -1
- package/dist/src/features/dam/repository-catalog.js +30 -21
- package/dist/src/features/dam/use-cases.js +14 -9
- package/dist/src/features/editor/bridge-client.js +0 -2
- package/dist/src/features/editor/bridge-process.js +3 -2
- package/dist/src/features/editor/public-url.js +1 -36
- package/dist/src/features/editor/session-state.js +1 -0
- package/dist/src/features/editor/session.js +3 -2
- package/dist/src/features/editor/use-cases.js +27 -2
- package/dist/src/features/org/org-service.js +10 -1
- package/dist/src/features/org/use-cases.js +18 -4
- package/dist/src/features/task/process-owner.js +54 -0
- package/dist/src/features/task/store.js +102 -32
- package/dist/src/features/task/task-background.js +8 -4
- package/dist/src/features/task/use-cases.js +184 -84
- package/dist/src/features/tool/argument-paths.js +14 -0
- package/dist/src/features/tool/canvas-copy.js +28 -15
- package/dist/src/features/tool/canvas-matting.js +123 -0
- package/dist/src/features/tool/canvas-media.js +102 -55
- package/dist/src/features/tool/canvas-models.js +66 -33
- package/dist/src/features/tool/canvas-pricing.js +12 -0
- package/dist/src/features/tool/canvas-recovery.js +13 -30
- package/dist/src/features/tool/canvas-results.js +92 -93
- package/dist/src/features/tool/canvas-tool-adapter.js +134 -157
- package/dist/src/features/tool/canvas-video.js +44 -37
- package/dist/src/features/tool/catalog.js +2 -23
- package/dist/src/features/tool/dynamic-schema.js +42 -46
- package/dist/src/features/tool/ffprobe-executable.js +21 -0
- package/dist/src/features/tool/mns-catalog-adapter.js +61 -24
- package/dist/src/features/tool/resource-authorizer.js +11 -3
- package/dist/src/features/tool/tool-api-adapter.js +73 -82
- package/dist/src/features/tool/tool-definitions.js +23 -0
- package/dist/src/features/tool/tool-errors.js +25 -0
- package/dist/src/features/tool/tool-output.js +15 -0
- package/dist/src/features/tool/use-cases.js +74 -98
- package/dist/src/features/update/package-manager.js +124 -0
- package/dist/src/features/update/update-service.js +195 -55
- package/dist/src/platform/detached-spawn.js +9 -0
- package/dist/src/platform/file-lock.js +12 -4
- package/dist/src/platform/input-uri.js +23 -1
- package/dist/src/platform/local-json-file.js +97 -15
- package/dist/src/platform/media-type.js +46 -0
- package/dist/src/platform/open-browser.js +5 -2
- package/dist/src/platform/public-url.js +35 -0
- package/dist/src/platform/remote-error-evidence.js +33 -6
- package/dist/src/platform/resource-auth-key.js +35 -1
- package/dist/src/platform/safe-upload-file.js +38 -44
- package/dist/src/platform/schema-compiler.js +16 -0
- package/dist/src/platform/signature.js +2 -2
- package/dist/src/platform/signed-http-transport.js +4 -1
- package/dist/src/platform/url-safety.js +6 -1
- package/dist/src/platform/webm-header.js +41 -0
- package/dist/src/platform/windows-acl/LICENSE-mingw-w64 +43 -0
- package/dist/src/platform/windows-acl/arm64.node +0 -0
- package/dist/src/platform/windows-acl/ia32.node +0 -0
- package/dist/src/platform/windows-acl/x64.node +0 -0
- package/dist/src/platform/windows-host-job/arm64.exe +0 -0
- package/dist/src/platform/windows-host-job/ia32.exe +0 -0
- package/dist/src/platform/windows-host-job/sha256.json +7 -0
- package/dist/src/platform/windows-host-job/x64.exe +0 -0
- package/dist/src/platform/windows-private-state.js +72 -0
- package/dist/src/product/config.js +1 -1
- package/dist/src/telemetry/command-route.js +38 -0
- package/dist/src/telemetry/command-routes.json +1 -0
- package/dist/src/telemetry/failure-summary.js +3 -3
- package/dist/src/telemetry/invocation.js +1 -2
- package/dist/src/telemetry/process-errors.js +17 -33
- package/dist/src/telemetry/sanitize.js +19 -4
- package/dist/src/telemetry/sls-sink.js +45 -20
- package/package.json +4 -4
- package/skills/insmind-cli/SKILL.md +18 -5
- package/skills/insmind-cli/references/agent.md +9 -4
- package/skills/insmind-cli/references/creation.md +3 -1
- package/skills/insmind-cli/references/editor.md +7 -5
- package/skills/insmind-cli/references/errors.md +20 -9
- package/skills/insmind-cli/references/matting.md +3 -5
- package/skills/insmind-cli/references/media-tools.md +10 -4
- package/skills/insmind-cli/references/tool.md +9 -15
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { canvasModelBindings } from "../features/tool/canvas-models.js";
|
|
1
2
|
import { createWindAnalytics } from "../analytics/wind.js";
|
|
2
3
|
import { taskScope } from "../features/task/store.js";
|
|
3
4
|
import { noticeWriter, sameTerminal } from "../features/update/notice-output.js";
|
|
@@ -6,8 +7,10 @@ import { TaskNotFoundError } from "../features/task/use-cases.js";
|
|
|
6
7
|
import { homedir } from "node:os";
|
|
7
8
|
import { createTaskBackgroundLauncher, TaskBackgroundError } from "../features/task/task-background.js";
|
|
8
9
|
import { createTaskStore } from "../features/task/store.js";
|
|
9
|
-
import { createTaskUseCases } from "../features/task/use-cases.js";
|
|
10
|
+
import { createTaskUseCases, taskStartedNotice } from "../features/task/use-cases.js";
|
|
10
11
|
import { readAgentResult } from "../features/agent/result-reader.js";
|
|
12
|
+
import { createToolOutputVerifier, presentToolContent } from "../features/tool/tool-output.js";
|
|
13
|
+
import { RemoteProtocolError } from "../platform/remote-protocol.js";
|
|
11
14
|
import { queryToolResult, ToolTaskFailedError, ToolTaskCanceledError } from "../features/tool/tool-api-adapter.js";
|
|
12
15
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
13
16
|
import { dirname, join } from "node:path";
|
|
@@ -91,9 +94,13 @@ export function createProductionRuntime(options = {}) {
|
|
|
91
94
|
} : undefined;
|
|
92
95
|
const now = options.now ?? (() => new Date());
|
|
93
96
|
const telemetryEnvironment = options.telemetryEnvironment ?? (env.CLI_TELEMETRY_ENV === "test" ? "test" : "production");
|
|
97
|
+
const host = hostTelemetryContext(env);
|
|
98
|
+
const reporterFlushes = env.CLI_INTERNAL_HOST_REPORTER_FLUSH === "1" && host.host_application === "workbuddy"
|
|
99
|
+
&& !!host.host_invocation_id && (host.invocation_purpose === "auth_status" || host.invocation_purpose === "version_check");
|
|
94
100
|
const telemetrySink = options.telemetrySink ?? createSlsTelemetrySink({
|
|
95
101
|
fetch, trackingUrl: options.telemetryTrackingUrl ?? product.telemetryUrl,
|
|
96
102
|
background: options.telemetryBackground ?? true,
|
|
103
|
+
reporterFlushes,
|
|
97
104
|
directory: join(options.homeDirectory ?? homedir(), product.stateDirectory, "telemetry", "v6"),
|
|
98
105
|
now: () => now().getTime()
|
|
99
106
|
});
|
|
@@ -108,7 +115,7 @@ export function createProductionRuntime(options = {}) {
|
|
|
108
115
|
classifyError: error => classifyTelemetryError(error, { product, operation: telemetry.creationContext().operation, failureStage: telemetry.failureStage(error) }),
|
|
109
116
|
...(telemetrySink.enqueue ? { onEvent: (event) => telemetrySink.enqueue([event]) } : {})
|
|
110
117
|
});
|
|
111
|
-
telemetry.annotate({ installation_owner: installationOwner, ...
|
|
118
|
+
telemetry.annotate({ installation_owner: installationOwner, ...host });
|
|
112
119
|
// Explicit test transport enables SDK tests; test-mode child processes never emit real analytics.
|
|
113
120
|
const analytics = options.analytics ?? (telemetryEnvironment === "production" || options.windFetch
|
|
114
121
|
? createWindAnalytics({ product: product.id, version: options.telemetryVersion ?? primarySkill.version,
|
|
@@ -189,7 +196,7 @@ export function createProductionRuntime(options = {}) {
|
|
|
189
196
|
});
|
|
190
197
|
const org = createOrgUseCases({
|
|
191
198
|
store,
|
|
192
|
-
org: createOrgService({ transport: orgTransport }),
|
|
199
|
+
org: createOrgService({ transport: orgTransport, onPartial: count => partialWarning("ORG_LIST_PARTIAL", `有 ${count} 条组织记录无法读取,已返回可确认的组织。`, `${count} organization record(s) could not be read.`) }),
|
|
193
200
|
sso,
|
|
194
201
|
telemetry,
|
|
195
202
|
...(product.exposesOrganizations
|
|
@@ -214,6 +221,7 @@ export function createProductionRuntime(options = {}) {
|
|
|
214
221
|
});
|
|
215
222
|
const credits = createCreditsUseCases({
|
|
216
223
|
transport: creditsTransport,
|
|
224
|
+
onPartial: () => partialWarning("CREDITS_RECORDS_PARTIAL", "部分账单记录或可选字段无法表示,已返回可确认的流水;不要据此推算完整账单。", "Some billing records or optional fields could not be represented. Known records are included; do not infer a complete bill."),
|
|
217
225
|
billingUnit: product.billingUnit,
|
|
218
226
|
now
|
|
219
227
|
});
|
|
@@ -227,6 +235,10 @@ export function createProductionRuntime(options = {}) {
|
|
|
227
235
|
writeError: io.writeError,
|
|
228
236
|
product
|
|
229
237
|
});
|
|
238
|
+
function partialWarning(code, zh, en) {
|
|
239
|
+
telemetry.annotate({ warning_codes: [code] });
|
|
240
|
+
presenter.warning(text(zh, en));
|
|
241
|
+
}
|
|
230
242
|
const browser = createBrowserOpener();
|
|
231
243
|
const validators = createContractValidators({
|
|
232
244
|
organizations: product.exposesOrganizations
|
|
@@ -238,8 +250,15 @@ export function createProductionRuntime(options = {}) {
|
|
|
238
250
|
? { invalidModelWarning: (count) => `Ignored ${count} invalid model configuration${count === 1 ? "" : "s"}.` }
|
|
239
251
|
: {})
|
|
240
252
|
}) });
|
|
241
|
-
const damApi = createDamApiAdapter({
|
|
242
|
-
|
|
253
|
+
const damApi = createDamApiAdapter({
|
|
254
|
+
transport: damTransport,
|
|
255
|
+
onPartial: count => partialWarning("DAM_LIST_PARTIAL", `有 ${count} 条素材库记录无法表示,已返回其余记录。`, `${count} unreadable record(s); the other records are included.`),
|
|
256
|
+
onPaginationFallback: () => partialWarning("DAM_PAGINATION_INCOMPLETE", "服务未提供完整分页信息;缺失的总数或结束标记按本页结果推导。", "The service omitted pagination information; a missing total or end marker was inferred from this page.")
|
|
257
|
+
});
|
|
258
|
+
const damRepositories = createDamRepositoryCatalog({ transport: damTransport, onPartial: source => {
|
|
259
|
+
const label = source === "team" ? "团队" : source === "personal" ? "个人" : "企业";
|
|
260
|
+
partialWarning("DAM_REPOSITORIES_PARTIAL", `${label}库来源或其中部分记录无法读取,已列出可确认的资源库。`, `The ${source} repository source was unavailable or incomplete. Known repositories are included.`);
|
|
261
|
+
} });
|
|
243
262
|
const damOperations = createDamOperationExecutor({
|
|
244
263
|
now: () => now().getTime(),
|
|
245
264
|
sleep: async (milliseconds, signal) => {
|
|
@@ -292,7 +311,14 @@ export function createProductionRuntime(options = {}) {
|
|
|
292
311
|
traceparent: () => telemetry.traceparent(),
|
|
293
312
|
...(businessHeaders ? { businessHeaders } : {})
|
|
294
313
|
}) });
|
|
295
|
-
const
|
|
314
|
+
const onPartialResourceFailure = (error) => {
|
|
315
|
+
if (!(error instanceof RemoteRequestError || error instanceof RemoteProtocolError)
|
|
316
|
+
|| !["RESOURCE_AUTH_REQUEST_FAILED", "RESOURCE_AUTH_INVALID_RESPONSE"].includes(error.diagnosticReason ?? ""))
|
|
317
|
+
return false;
|
|
318
|
+
partialWarning("RESOURCE_AUTH_PARTIAL", "部分私有资源链接尚未取得访问授权;已保留原链接及其他可用内容,请使用原任务再次取件,不要重做。", "Some private links could not be authorized. The original links and other content are included. Query the same task; do not resubmit.");
|
|
319
|
+
return true;
|
|
320
|
+
};
|
|
321
|
+
const resourceAuthorizer = createAgentResourceAuthorizer({ authKeys: resourceAuthKeys, onPartialResourceFailure });
|
|
296
322
|
const accessPolicies = createAccessPolicies({ store, now, refreshCurrentOrganization: org.refreshCurrentOrganization });
|
|
297
323
|
const authorizeTaskAccess = async (state, signal) => {
|
|
298
324
|
await telemetry.stage("access", async () => {
|
|
@@ -304,24 +330,59 @@ export function createProductionRuntime(options = {}) {
|
|
|
304
330
|
}
|
|
305
331
|
});
|
|
306
332
|
};
|
|
307
|
-
const authorizeTaskResult = async (result, state, signal,
|
|
333
|
+
const authorizeTaskResult = async (result, state, signal, source = "stored") => {
|
|
308
334
|
if ("message" in result)
|
|
309
335
|
validators.agentSendOutput(result);
|
|
310
336
|
else
|
|
311
337
|
validators.toolCallOutput(result);
|
|
312
338
|
// Bind only if this result actually needs a fresh resource token.
|
|
313
|
-
const taskAuthorizer = createAgentResourceAuthorizer({
|
|
339
|
+
const taskAuthorizer = createAgentResourceAuthorizer({
|
|
340
|
+
onPartialResourceFailure,
|
|
341
|
+
// Re-reading an existing result can repair an expired official link without probing anyone's URLs.
|
|
342
|
+
...(source !== "upstream" ? { onSignedRefreshFailure(error) {
|
|
343
|
+
if (!(error instanceof RemoteRequestError || error instanceof RemoteProtocolError)
|
|
344
|
+
|| !["RESOURCE_AUTH_REQUEST_FAILED", "RESOURCE_AUTH_INVALID_RESPONSE"].includes(error.diagnosticReason ?? ""))
|
|
345
|
+
return false;
|
|
346
|
+
telemetry.annotate({ warning_codes: ["TASK_RESOURCE_REFRESH_UNAVAILABLE"] });
|
|
347
|
+
presenter.warning(text("资源授权暂未更新,已返回原签名链接;如仍无法打开,请稍后用原任务 ID 查询。", "The resource key could not be refreshed. The original signed URL is included; if it cannot be opened, query the same task ID later."));
|
|
348
|
+
return true;
|
|
349
|
+
} } : {}),
|
|
350
|
+
authKeys: {
|
|
314
351
|
async getAuthKey(access, tokenSignal) {
|
|
315
|
-
if (
|
|
352
|
+
if (source === "stored")
|
|
316
353
|
await authorizeTaskAccess(state, tokenSignal);
|
|
317
354
|
return resourceAuthKeys.getAuthKey(access, tokenSignal);
|
|
318
355
|
}
|
|
319
|
-
}
|
|
356
|
+
}
|
|
357
|
+
});
|
|
320
358
|
const access = { credential: state.credential, organizationId: state.organization.id };
|
|
321
359
|
if ("message" in result)
|
|
322
360
|
return taskAuthorizer.authorize(result, access, signal);
|
|
323
361
|
return authorizeToolResources(result, taskAuthorizer, access, signal);
|
|
324
362
|
};
|
|
363
|
+
const canvasMedia = (access) => createCanvasMedia({ fetch, uploader: transientUploader,
|
|
364
|
+
...(access ? { filems: { access, authKeys: resourceAuthKeys } } : {}) });
|
|
365
|
+
const onMissingMedia = (kind) => {
|
|
366
|
+
telemetry.annotate({ warning_codes: ["TOOL_EXPECTED_MEDIA_UNIDENTIFIED"] });
|
|
367
|
+
presenter.warning(text(`已交付服务返回的内容,未发现明确标记为${kind === "video" ? "视频" : "图片"}的资源;请按实际内容交付,勿重新提交。`, `The returned content is included. No resource was identified as ${kind}; report what was received and do not resubmit.`));
|
|
368
|
+
};
|
|
369
|
+
const onUnrepresented = () => {
|
|
370
|
+
telemetry.annotate({ warning_codes: ["TOOL_PART_UNREPRESENTABLE"] });
|
|
371
|
+
presenter.warning(text("已返回可表示的内容,另有无法读取的附件。", "The representable content is included; another attachment could not be read."));
|
|
372
|
+
};
|
|
373
|
+
const verifyToolOutput = createToolOutputVerifier(resourceAuthorizer, onMissingMedia);
|
|
374
|
+
const canvasTools = createCanvasToolAdapter({
|
|
375
|
+
transport: toolTransport, recordTransport: damTransport, resourceAuthorizer, telemetry, media: canvasMedia, onMissingMedia, onUnrepresented, english: product.id === "insmind",
|
|
376
|
+
fallback: createToolApiAdapter({ transport: toolTransport, telemetry, onUnrepresented, verifyOutput: verifyToolOutput }),
|
|
377
|
+
standardMatting: createStandardMatting({ transport: toolTransport, recordTransport: damTransport, media: canvasMedia() })
|
|
378
|
+
});
|
|
379
|
+
const taskFailureNote = (error, operation = telemetry.creationContext().operation) => {
|
|
380
|
+
const outcome = mapCliError(error, { aborted: false, product, operation, failureStage: telemetry.failureStage(error) });
|
|
381
|
+
if (outcome.kind !== "failure")
|
|
382
|
+
return "";
|
|
383
|
+
const details = outcome.failure.details;
|
|
384
|
+
return [outcome.failure.message, details?.remote_code, details?.remote_message].filter(Boolean).join(" ");
|
|
385
|
+
};
|
|
325
386
|
const tasks = createTaskUseCases({
|
|
326
387
|
telemetry,
|
|
327
388
|
...(analytics ? { analytics } : {}),
|
|
@@ -335,6 +396,7 @@ export function createProductionRuntime(options = {}) {
|
|
|
335
396
|
store: createTaskStore({
|
|
336
397
|
...(options.homeDirectory ? { homeDirectory: options.homeDirectory } : {}),
|
|
337
398
|
stateDirectory: product.stateDirectory,
|
|
399
|
+
onUnreadableRecords: count => partialWarning("TASK_LIST_PARTIAL", `有 ${count} 条本地任务记录无法读取,已列出可读取的记录。`, `${count} local task record(s) could not be read. Readable records are included.`),
|
|
338
400
|
validateSummary: task => validators.taskListResult({ tasks: [task] }),
|
|
339
401
|
validate: validators.taskResult
|
|
340
402
|
}),
|
|
@@ -344,12 +406,19 @@ export function createProductionRuntime(options = {}) {
|
|
|
344
406
|
warning: message => presenter.warning(message),
|
|
345
407
|
commandName: product.commandName,
|
|
346
408
|
text,
|
|
347
|
-
failureNote:
|
|
348
|
-
const outcome = mapCliError(error, { aborted: false, product, operation: telemetry.creationContext().operation, failureStage: telemetry.failureStage(error) });
|
|
349
|
-
return outcome.kind === "failure" ? outcome.failure.message : "";
|
|
350
|
-
},
|
|
409
|
+
failureNote: taskFailureNote,
|
|
351
410
|
recovery: {
|
|
352
|
-
authorize
|
|
411
|
+
async authorize(result, state, signal, progress) {
|
|
412
|
+
const authorized = await authorizeTaskResult(result, state, signal);
|
|
413
|
+
const tool = progress?.generation?.tool ?? canvasModelBindings.find(binding => binding[1] === progress?.toolPipeline?.model)?.[0];
|
|
414
|
+
if ("content" in authorized && tool && tool !== "image.ocr" && tool !== "image.layers") {
|
|
415
|
+
if (tool.startsWith("video."))
|
|
416
|
+
presentToolContent(authorized.content, "video", onMissingMedia);
|
|
417
|
+
else if (tool.startsWith("image."))
|
|
418
|
+
presentToolContent(authorized.content, "image", onMissingMedia);
|
|
419
|
+
}
|
|
420
|
+
return authorized;
|
|
421
|
+
},
|
|
353
422
|
async agent(progress, state, signal) {
|
|
354
423
|
if (!progress.contextId || !progress.localMessageId)
|
|
355
424
|
return {
|
|
@@ -361,14 +430,18 @@ export function createProductionRuntime(options = {}) {
|
|
|
361
430
|
credential: state.credential, organizationId: state.organization.id, signal
|
|
362
431
|
});
|
|
363
432
|
return { state: "unknown",
|
|
433
|
+
...(snapshot.usageAmountMissing ? { usageAmountMissing: true } : {}),
|
|
364
434
|
...(snapshot.usageModelMissing ? { usageModelMissing: true } : {}),
|
|
365
435
|
note: snapshot.partialResult
|
|
366
436
|
? text("已找到部分内容,尚未取得完整结果。", "Some content was found, but the complete result has not been received.")
|
|
367
437
|
: text("尚未取得任务结果。", "The task result has not been received."),
|
|
368
|
-
...(snapshot.partialResult ? { partialResult: await authorizeTaskResult(agentOutputWithBillingUnit(snapshot.partialResult, product.billingUnit), state, signal,
|
|
438
|
+
...(snapshot.partialResult ? { partialResult: await authorizeTaskResult(agentOutputWithBillingUnit(snapshot.partialResult, product.billingUnit), state, signal, "upstream") } : {})
|
|
369
439
|
};
|
|
370
440
|
},
|
|
371
441
|
async tool(progress, state, signal) {
|
|
442
|
+
// Never interpret an unpublished candidate's Run receipt as a Dify task.
|
|
443
|
+
if (Object.hasOwn(progress, "toolRun"))
|
|
444
|
+
return { state: "unknown", note: text("该实验版本任务不支持继续远端查询。请保留原任务记录用于排查,不要重复提交。", "Remote recovery is unavailable for this experimental task. Keep its original record for diagnosis; do not resubmit.") };
|
|
372
445
|
if (progress.toolPipeline) {
|
|
373
446
|
const pipeline = progress.toolPipeline;
|
|
374
447
|
await authorizeTaskAccess(state, signal);
|
|
@@ -376,7 +449,7 @@ export function createProductionRuntime(options = {}) {
|
|
|
376
449
|
try {
|
|
377
450
|
recovered = await telemetry.stage("task.query", () => recoverCanvasTool(progress, {
|
|
378
451
|
access: { credential: state.credential, organizationId: state.organization.id }, signal
|
|
379
|
-
}, { transport: toolTransport, media: canvasMedia, english: product.id === "insmind" }));
|
|
452
|
+
}, { transport: toolTransport, onMissingMedia, onUnrepresented, media: canvasMedia({ credential: state.credential, organizationId: state.organization.id }), english: product.id === "insmind" }));
|
|
380
453
|
}
|
|
381
454
|
catch (error) {
|
|
382
455
|
if (!(error instanceof ToolTaskFailedError) && !(error instanceof ToolTaskCanceledError))
|
|
@@ -384,17 +457,18 @@ export function createProductionRuntime(options = {}) {
|
|
|
384
457
|
const outcome = mapCliError(error, { aborted: false, product, operation: "task.get", failureStage: "task.query" });
|
|
385
458
|
return { state: "failed", note: outcome.failure?.message ?? text("本次处理未能完成。", "This processing could not be completed."), failure: error };
|
|
386
459
|
}
|
|
460
|
+
const source = "fromCheckpoint" in recovered && recovered.fromCheckpoint ? "checkpoint" : "upstream";
|
|
387
461
|
if (recovered.state === "complete" && progress.toolUsage)
|
|
388
462
|
return { state: "completed", result: await authorizeTaskResult(toolOutputWithBillingUnit({
|
|
389
463
|
content: recovered.content, usage: progress.toolUsage
|
|
390
|
-
}, product.billingUnit), state, signal,
|
|
464
|
+
}, product.billingUnit), state, signal, source) };
|
|
391
465
|
if (recovered.state === "pending")
|
|
392
466
|
return { state: "running", note: text("任务仍在处理中。", "The task is still processing.") };
|
|
393
467
|
const partialContent = recovered.state === "unknown" ? recovered.content : undefined;
|
|
394
468
|
return { state: "unknown", note: text(`处理停留在 ${pipeline.stage} 阶段,尚未交付完整结果。查询不会重新处理、上传或结算;请保留任务 ID 排查,勿重复提交。`, `Processing reached ${pipeline.stage}; no complete result was delivered. Querying does not process, upload, or settle again. Keep the task ID for diagnosis; do not resubmit.`),
|
|
395
469
|
...(partialContent && progress.toolUsage ? { partialResult: await authorizeTaskResult(toolOutputWithBillingUnit({
|
|
396
470
|
content: partialContent, usage: progress.toolUsage
|
|
397
|
-
}, product.billingUnit), state, signal,
|
|
471
|
+
}, product.billingUnit), state, signal, source) } : {}) };
|
|
398
472
|
}
|
|
399
473
|
if (!progress.remoteTaskId || !progress.toolUsage)
|
|
400
474
|
return {
|
|
@@ -406,7 +480,7 @@ export function createProductionRuntime(options = {}) {
|
|
|
406
480
|
try {
|
|
407
481
|
response = await telemetry.stage("task.query", async () => {
|
|
408
482
|
const result = await queryToolResult(toolTransport, {
|
|
409
|
-
taskId, credential: state.credential, organizationId: state.organization.id, signal,
|
|
483
|
+
taskId, credential: state.credential, organizationId: state.organization.id, signal, onUnrepresented,
|
|
410
484
|
onDifyTaskId: id => telemetry.annotate({ dify_task_id: id })
|
|
411
485
|
});
|
|
412
486
|
if (result.difyTaskId)
|
|
@@ -425,8 +499,8 @@ export function createProductionRuntime(options = {}) {
|
|
|
425
499
|
if (response.state === "pending")
|
|
426
500
|
return { state: "running", note: text("任务仍在处理中。", "The task is still processing.") };
|
|
427
501
|
return { state: "completed", result: await authorizeTaskResult(toolOutputWithBillingUnit({
|
|
428
|
-
content: response.content, usage: progress.toolUsage
|
|
429
|
-
}, product.billingUnit), state, signal,
|
|
502
|
+
content: await verifyToolOutput(response.content, progress.generation?.tool === "video.generate" ? "video" : "image", { access: { credential: state.credential, organizationId: state.organization.id }, signal }), usage: progress.toolUsage
|
|
503
|
+
}, product.billingUnit), state, signal, "upstream") };
|
|
430
504
|
}
|
|
431
505
|
}
|
|
432
506
|
});
|
|
@@ -440,19 +514,17 @@ export function createProductionRuntime(options = {}) {
|
|
|
440
514
|
}),
|
|
441
515
|
telemetry
|
|
442
516
|
}), product.billingUnit);
|
|
443
|
-
const canvasMedia = createCanvasMedia({ fetch, uploader: transientUploader });
|
|
444
517
|
const tool = withToolBillingUnit(createToolUseCases({
|
|
445
518
|
catalog: modelCatalog,
|
|
446
519
|
tools: product.tools,
|
|
447
520
|
...(product.id === "insmind" ? { modelDescription: "Model machine identifier from model list." } : {}),
|
|
448
|
-
execution:
|
|
449
|
-
fallback: createToolApiAdapter({ transport: toolTransport, telemetry }),
|
|
450
|
-
standardMatting: createStandardMatting({ transport: toolTransport, recordTransport: damTransport, media: canvasMedia }) }),
|
|
521
|
+
execution: canvasTools,
|
|
451
522
|
uploader: transientUploader,
|
|
452
523
|
warn: (message) => { presenter.warning(message); },
|
|
453
524
|
telemetry
|
|
454
525
|
}), product.billingUnit);
|
|
455
526
|
const editor = createEditorUseCases({
|
|
527
|
+
onPartial: count => partialWarning("EDITOR_SNAPSHOT_PARTIAL", `有 ${count} 个元素无法表示,已返回其余元素。`, `${count} unsupported element(s); the other elements are included.`),
|
|
456
528
|
session: createEditorSession({
|
|
457
529
|
store: createEditorSessionStateStore({
|
|
458
530
|
...(options.homeDirectory === undefined
|
|
@@ -533,11 +605,13 @@ export function createProductionRuntime(options = {}) {
|
|
|
533
605
|
telemetryEnvironment, telemetryVersion: options.telemetryVersion ?? primarySkill.version, origin: telemetry.creationContext(),
|
|
534
606
|
telemetryTrackingUrl: String(options.telemetryTrackingUrl ?? product.telemetryUrl),
|
|
535
607
|
locale: locale.locale, endpoints: Object.fromEntries(Object.entries(endpoints).map(([key, value]) => [key, String(value)]))
|
|
536
|
-
}, signal, task => {
|
|
608
|
+
}, signal, (task, creationTraceId) => {
|
|
537
609
|
startedId = task.taskId;
|
|
610
|
+
if (creationTraceId)
|
|
611
|
+
telemetry.annotate({ creation_trace_id: creationTraceId });
|
|
538
612
|
telemetry.annotate({ cli_task_id: task.taskId, execution_mode: "async", result_state: task.state });
|
|
539
|
-
presenter.notice(
|
|
540
|
-
});
|
|
613
|
+
presenter.notice(taskStartedNotice(task.taskId, product.commandName, "async", text));
|
|
614
|
+
}, facts => telemetry.annotate(facts));
|
|
541
615
|
}
|
|
542
616
|
catch (error) {
|
|
543
617
|
if (startedId)
|
|
@@ -8,7 +8,9 @@ export async function runTaskWorker(options) {
|
|
|
8
8
|
const { job, signal, send } = options;
|
|
9
9
|
runtime.telemetry.useSignal(signal);
|
|
10
10
|
runtime.telemetry.select({ operation: job.operation, mode: () => "execute" });
|
|
11
|
-
runtime.telemetry.annotate({ ...(job.origin ? {
|
|
11
|
+
runtime.telemetry.annotate({ ...(job.origin ? { host_application: job.origin.host_application ?? "unknown" } : {}),
|
|
12
|
+
...(job.origin ? { creation_trace_id: job.origin.trace_id } : {}),
|
|
13
|
+
account_id: job.state.account?.id, organization_id: job.state.organization.id,
|
|
12
14
|
parameters: { ...job.input }, execution_mode: "async" });
|
|
13
15
|
let completion = { outcome: "success" };
|
|
14
16
|
let started = false;
|
|
@@ -21,6 +23,7 @@ export async function runTaskWorker(options) {
|
|
|
21
23
|
runtime.validators.toolCallInput(job.input);
|
|
22
24
|
await runtime.tasks.track({
|
|
23
25
|
state: job.state,
|
|
26
|
+
signal,
|
|
24
27
|
operation: job.operation,
|
|
25
28
|
label: job.label,
|
|
26
29
|
executionMode: "async",
|
|
@@ -32,7 +35,8 @@ export async function runTaskWorker(options) {
|
|
|
32
35
|
}
|
|
33
36
|
if ((progress.accepted || progress.remoteTaskId) && !accepted) {
|
|
34
37
|
accepted = true;
|
|
35
|
-
send({ type: "accepted", task
|
|
38
|
+
send({ type: "accepted", task,
|
|
39
|
+
...(job.operation === "tool.call" ? { execution_protocol: progress.toolPipeline?.protocol ?? "dify" } : {}) });
|
|
36
40
|
}
|
|
37
41
|
},
|
|
38
42
|
run: async (observe) => {
|
|
@@ -1,51 +1,8 @@
|
|
|
1
1
|
import { inputValidationSummary, validationIssues } from "../platform/schema-issues.js";
|
|
2
2
|
import { canonicalizeInputFileUris } from "../platform/input-uri.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { agentInputSchema } from "../contracts/creation-input.js";
|
|
3
|
+
import { lazySchemaCompiler } from "../platform/schema-compiler.js";
|
|
4
|
+
import { readAgentInputSchema } from "../contracts/creation-input.js";
|
|
6
5
|
import { contractSchema } from "../contracts/schema.js";
|
|
7
|
-
const agentSendOutputSchema = contractSchema("agent.send", "output");
|
|
8
|
-
const authStatusSchema = contractSchema("auth.status", "output");
|
|
9
|
-
const damDeleteInputSchema = contractSchema("dam.delete", "input");
|
|
10
|
-
const damDeleteOutputSchema = contractSchema("dam.delete", "output");
|
|
11
|
-
const damCopyInputSchema = contractSchema("dam.copy", "input");
|
|
12
|
-
const damCopyOutputSchema = contractSchema("dam.copy", "output");
|
|
13
|
-
const damDownloadInputSchema = contractSchema("dam.download", "input");
|
|
14
|
-
const damDownloadOutputSchema = contractSchema("dam.download", "output");
|
|
15
|
-
const damFolderListInputSchema = contractSchema("dam.folder.list", "input");
|
|
16
|
-
const damFolderListOutputSchema = contractSchema("dam.folder.list", "output");
|
|
17
|
-
const damGetInputSchema = contractSchema("dam.get", "input");
|
|
18
|
-
const damGetOutputSchema = contractSchema("dam.get", "output");
|
|
19
|
-
const damListInputSchema = contractSchema("dam.list", "input");
|
|
20
|
-
const damListOutputSchema = contractSchema("dam.list", "output");
|
|
21
|
-
const damMoveInputSchema = contractSchema("dam.move", "input");
|
|
22
|
-
const damMoveOutputSchema = contractSchema("dam.move", "output");
|
|
23
|
-
const damRepositoryListOutputSchema = contractSchema("dam.repository.list", "output");
|
|
24
|
-
const damRenameInputSchema = contractSchema("dam.rename", "input");
|
|
25
|
-
// The service owns the character limit. The CLI only needs a title to send.
|
|
26
|
-
delete (damRenameInputSchema.properties.title).maxLength;
|
|
27
|
-
const damRenameOutputSchema = contractSchema("dam.rename", "output");
|
|
28
|
-
const damSearchInputSchema = contractSchema("dam.search", "input");
|
|
29
|
-
const damSearchOutputSchema = contractSchema("dam.search", "output");
|
|
30
|
-
const damTagListInputSchema = contractSchema("dam.tag.list", "input");
|
|
31
|
-
const damTagListOutputSchema = contractSchema("dam.tag.list", "output");
|
|
32
|
-
const damUploadInputSchema = contractSchema("dam.upload", "input");
|
|
33
|
-
const damUploadOutputSchema = contractSchema("dam.upload", "output");
|
|
34
|
-
const editorApplyInputSchema = contractSchema("editor.apply", "input");
|
|
35
|
-
const editorApplyOutputSchema = contractSchema("editor.apply", "output");
|
|
36
|
-
const editorConnectInputSchema = contractSchema("editor.connect", "input");
|
|
37
|
-
const editorConnectOutputSchema = contractSchema("editor.connect", "output");
|
|
38
|
-
const editorDisconnectOutputSchema = contractSchema("editor.disconnect", "output");
|
|
39
|
-
const editorSaveOutputSchema = contractSchema("editor.save", "output");
|
|
40
|
-
const editorScreenshotOutputSchema = contractSchema("editor.screenshot", "output");
|
|
41
|
-
const editorSnapshotOutputSchema = contractSchema("editor.snapshot", "output");
|
|
42
|
-
const modelGetInputSchema = contractSchema("model.get", "input");
|
|
43
|
-
const modelGetOutputSchema = contractSchema("model.get", "output");
|
|
44
|
-
const modelListInputSchema = contractSchema("model.list", "input");
|
|
45
|
-
const modelListOutputSchema = contractSchema("model.list", "output");
|
|
46
|
-
const toolCallInputSchema = contractSchema("tool.call", "input");
|
|
47
|
-
const toolCallOutputSchema = contractSchema("tool.call", "output");
|
|
48
|
-
const toolListOutputSchema = contractSchema("tool.list", "output");
|
|
49
6
|
export class InputContractError extends Error {
|
|
50
7
|
issues;
|
|
51
8
|
diagnosticSummary;
|
|
@@ -65,117 +22,96 @@ export class OutputContractError extends Error {
|
|
|
65
22
|
}
|
|
66
23
|
}
|
|
67
24
|
export function createContractValidators(options = {}) {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
const editorApplyOutput = ajv.compile(editorApplyOutputSchema);
|
|
103
|
-
const editorScreenshotOutput = ajv.compile(editorScreenshotOutputSchema);
|
|
104
|
-
const editorSaveOutput = ajv.compile(editorSaveOutputSchema);
|
|
105
|
-
const organizations = options.organizations !== false;
|
|
106
|
-
const orgList = organizations
|
|
107
|
-
? ajv.compile(contractSchema("org.list", "output"))
|
|
108
|
-
: unavailableValidator;
|
|
109
|
-
const orgCurrent = organizations
|
|
110
|
-
? ajv.compile(contractSchema("org.current", "output"))
|
|
111
|
-
: unavailableValidator;
|
|
112
|
-
const toolListOutput = ajv.compile(toolListOutputSchema);
|
|
113
|
-
const modelListInput = ajv.compile(modelListInputSchema);
|
|
114
|
-
const modelListOutput = ajv.compile(modelListOutputSchema);
|
|
115
|
-
const modelGetInput = ajv.compile(modelGetInputSchema);
|
|
116
|
-
const modelGetOutput = ajv.compile(modelGetOutputSchema);
|
|
117
|
-
const toolCallInput = ajv.compile(toolCallInputSchema);
|
|
118
|
-
const toolCallOutput = ajv.compile(toolCallOutputSchema);
|
|
119
|
-
const runOutputSchema = contractSchema("task.get", "output");
|
|
120
|
-
const runSchemaId = runOutputSchema.$id;
|
|
121
|
-
ajv.addSchema(agentSendOutputSchema, new URL("../agent.send/output.schema.json", runSchemaId).href);
|
|
122
|
-
ajv.addSchema(toolCallOutputSchema, new URL("../tool.call/output.schema.json", runSchemaId).href);
|
|
123
|
-
const taskResult = ajv.compile(runOutputSchema);
|
|
124
|
-
const taskListResult = ajv.compile(contractSchema("task.list", "output"));
|
|
25
|
+
const compiler = lazySchemaCompiler({ allErrors: true, strict: true });
|
|
26
|
+
// Only the task contracts reference both producer outputs. Reading them for
|
|
27
|
+
// auth.status or --version adds filesystem work to every cold Windows probe.
|
|
28
|
+
let taskSchemas;
|
|
29
|
+
function taskOutput(operation) {
|
|
30
|
+
return assertion(() => {
|
|
31
|
+
const engine = compiler();
|
|
32
|
+
if (!taskSchemas) {
|
|
33
|
+
const task = contractSchema("task.get", "output");
|
|
34
|
+
const agent = contractSchema("agent.send", "output");
|
|
35
|
+
const tool = contractSchema("tool.call", "output");
|
|
36
|
+
const id = String(task.$id);
|
|
37
|
+
engine.addSchema(agent, new URL("../agent.send/output.schema.json", id).href);
|
|
38
|
+
engine.addSchema(tool, new URL("../tool.call/output.schema.json", id).href);
|
|
39
|
+
engine.addSchema(task);
|
|
40
|
+
taskSchemas = { "task.get": task, "agent.send": agent, "tool.call": tool };
|
|
41
|
+
}
|
|
42
|
+
return engine.compile(operation === "task.list" ? contractSchema(operation, "output") : taskSchemas[operation]);
|
|
43
|
+
}, OutputContractError);
|
|
44
|
+
}
|
|
45
|
+
function output(operation) {
|
|
46
|
+
return assertion(() => compiler().compile(contractSchema(operation, "output")), OutputContractError);
|
|
47
|
+
}
|
|
48
|
+
function input(operation) {
|
|
49
|
+
return assertion(() => {
|
|
50
|
+
const schema = contractSchema(operation, "input");
|
|
51
|
+
if (operation === "dam.rename") {
|
|
52
|
+
// The service owns the character limit. The CLI only needs a title to send.
|
|
53
|
+
delete (schema.properties.title).maxLength;
|
|
54
|
+
}
|
|
55
|
+
return compiler().compile(schema);
|
|
56
|
+
}, InputContractError);
|
|
57
|
+
}
|
|
58
|
+
const unavailable = assertion(() => unavailableValidator, OutputContractError);
|
|
125
59
|
return {
|
|
126
|
-
creditsOutput:
|
|
127
|
-
creditsUsageListOutput:
|
|
128
|
-
creditsUsageGetOutput:
|
|
129
|
-
taskResult:
|
|
130
|
-
taskListResult:
|
|
131
|
-
agentSendInput: assertion(
|
|
132
|
-
agentSendOutput:
|
|
133
|
-
authStatus:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
toolListOutput:
|
|
168
|
-
modelListInput:
|
|
169
|
-
modelListOutput:
|
|
170
|
-
modelGetInput:
|
|
171
|
-
modelGetOutput:
|
|
172
|
-
toolCallInput:
|
|
173
|
-
toolCallOutput:
|
|
60
|
+
creditsOutput: output("credits.get"),
|
|
61
|
+
creditsUsageListOutput: output("credits.usage.list"),
|
|
62
|
+
creditsUsageGetOutput: output("credits.usage.get"),
|
|
63
|
+
taskResult: taskOutput("task.get"),
|
|
64
|
+
taskListResult: taskOutput("task.list"),
|
|
65
|
+
agentSendInput: assertion(() => compiler().compile(readAgentInputSchema()), InputContractError),
|
|
66
|
+
agentSendOutput: taskOutput("agent.send"),
|
|
67
|
+
authStatus: output("auth.status"),
|
|
68
|
+
orgList: options.organizations === false ? unavailable : output("org.list"),
|
|
69
|
+
orgCurrent: options.organizations === false ? unavailable : output("org.current"),
|
|
70
|
+
damRepositoryListOutput: output("dam.repository.list"),
|
|
71
|
+
damListInput: input("dam.list"),
|
|
72
|
+
damListOutput: output("dam.list"),
|
|
73
|
+
damSearchInput: input("dam.search"),
|
|
74
|
+
damSearchOutput: output("dam.search"),
|
|
75
|
+
damFolderListInput: input("dam.folder.list"),
|
|
76
|
+
damFolderListOutput: output("dam.folder.list"),
|
|
77
|
+
damTagListInput: input("dam.tag.list"),
|
|
78
|
+
damTagListOutput: output("dam.tag.list"),
|
|
79
|
+
damGetInput: input("dam.get"),
|
|
80
|
+
damGetOutput: output("dam.get"),
|
|
81
|
+
damUploadInput: input("dam.upload"),
|
|
82
|
+
damUploadOutput: output("dam.upload"),
|
|
83
|
+
damDeleteInput: input("dam.delete"),
|
|
84
|
+
damDeleteOutput: output("dam.delete"),
|
|
85
|
+
damDownloadInput: input("dam.download"),
|
|
86
|
+
damDownloadOutput: output("dam.download"),
|
|
87
|
+
damRenameInput: input("dam.rename"),
|
|
88
|
+
damRenameOutput: output("dam.rename"),
|
|
89
|
+
damMoveInput: input("dam.move"),
|
|
90
|
+
damMoveOutput: output("dam.move"),
|
|
91
|
+
damCopyInput: input("dam.copy"),
|
|
92
|
+
damCopyOutput: output("dam.copy"),
|
|
93
|
+
editorConnectInput: input("editor.connect"),
|
|
94
|
+
editorConnectOutput: output("editor.connect"),
|
|
95
|
+
editorDisconnectOutput: output("editor.disconnect"),
|
|
96
|
+
editorSnapshotOutput: output("editor.snapshot"),
|
|
97
|
+
editorApplyInput: input("editor.apply"),
|
|
98
|
+
editorApplyOutput: output("editor.apply"),
|
|
99
|
+
editorScreenshotOutput: output("editor.screenshot"),
|
|
100
|
+
editorSaveOutput: output("editor.save"),
|
|
101
|
+
toolListOutput: output("tool.list"),
|
|
102
|
+
modelListInput: input("model.list"),
|
|
103
|
+
modelListOutput: output("model.list"),
|
|
104
|
+
modelGetInput: input("model.get"),
|
|
105
|
+
modelGetOutput: output("model.get"),
|
|
106
|
+
toolCallInput: input("tool.call"),
|
|
107
|
+
toolCallOutput: taskOutput("tool.call"),
|
|
174
108
|
};
|
|
175
109
|
}
|
|
176
110
|
const unavailableValidator = Object.assign(() => false, { errors: null, schema: false, schemaEnv: undefined });
|
|
177
|
-
function assertion(
|
|
111
|
+
function assertion(compile, ErrorType) {
|
|
112
|
+
let validate;
|
|
178
113
|
return (value) => {
|
|
114
|
+
validate ??= compile();
|
|
179
115
|
if (ErrorType === InputContractError)
|
|
180
116
|
canonicalizeInputFileUris(value, validate.schema);
|
|
181
117
|
if (!validate(value)) {
|