@insmind/cli 2.1.7 → 3.0.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/README.md +6 -2
- package/contracts/operations/tool.call/canvas-input.schema.json +0 -3
- package/contracts/presentations/agent.send.schema.json +280 -0
- package/contracts/presentations/model.get.schema.json +217 -0
- package/contracts/presentations/model.list.schema.json +129 -0
- package/contracts/presentations/task.get.schema.json +135 -0
- package/contracts/presentations/tool.call.schema.json +185 -0
- package/dist/bin/insmind-cli.js +6 -1
- package/dist/src/bootstrap/create-cli.js +7 -4
- package/dist/src/bootstrap/create-runtime.js +7 -32
- package/dist/src/cli/action-binding.js +2 -2
- package/dist/src/cli/agent-commands.js +5 -4
- package/dist/src/cli/auth-commands.js +1 -1
- package/dist/src/cli/dam-commands.js +18 -10
- package/dist/src/cli/errors.js +1 -35
- package/dist/src/cli/host-input.js +0 -11
- package/dist/src/cli/model-commands.js +6 -5
- package/dist/src/cli/skill-output.js +13 -0
- package/dist/src/cli/tool-commands.js +9 -5
- package/dist/src/features/skill/catalog.js +152 -0
- package/dist/src/features/skill/manual.js +71 -0
- package/dist/src/features/tool/archived-ocr-result.js +74 -0
- package/dist/src/features/tool/canvas-copy.js +2 -3
- package/dist/src/features/tool/canvas-models.js +8 -5
- package/dist/src/features/tool/canvas-recovery.js +3 -2
- package/dist/src/features/tool/canvas-results.js +1 -55
- package/dist/src/features/tool/canvas-tool-adapter.js +7 -10
- package/dist/src/features/tool/mns-catalog-adapter.js +4 -4
- package/dist/src/features/tool/resource-authorizer.js +1 -1
- package/dist/src/features/tool/scene-catalog-adapter.js +20 -22
- package/dist/src/features/tool/tool-definitions.js +0 -1
- package/dist/src/product/config.js +0 -7
- package/dist/src/telemetry/command-routes.json +1 -1
- package/package.json +4 -4
- package/skills/insmind-cli/SKILL.md +9 -28
- package/contracts/operations/editor.apply/input.schema.json +0 -177
- package/contracts/operations/editor.apply/output.schema.json +0 -15
- package/contracts/operations/editor.connect/input.schema.json +0 -13
- package/contracts/operations/editor.connect/output.schema.json +0 -17
- package/contracts/operations/editor.disconnect/input.schema.json +0 -7
- package/contracts/operations/editor.disconnect/output.schema.json +0 -14
- package/contracts/operations/editor.save/input.schema.json +0 -7
- package/contracts/operations/editor.save/output.schema.json +0 -23
- package/contracts/operations/editor.screenshot/input.schema.json +0 -7
- package/contracts/operations/editor.screenshot/output.schema.json +0 -16
- package/contracts/operations/editor.snapshot/input.schema.json +0 -7
- package/contracts/operations/editor.snapshot/output.schema.json +0 -148
- package/contracts/operations/tool.call/models/image-ocr.schema.json +0 -20
- package/contracts/operations/tool.call/ocr-payload.schema.json +0 -64
- package/dist/src/cli/editor-commands.js +0 -136
- package/skills/insmind-cli/references/agent.md +0 -39
- package/skills/insmind-cli/references/auth.md +0 -8
- package/skills/insmind-cli/references/creation.md +0 -56
- package/skills/insmind-cli/references/dam.md +0 -52
- package/skills/insmind-cli/references/editor.md +0 -62
- package/skills/insmind-cli/references/errors.md +0 -42
- package/skills/insmind-cli/references/generation-constraints.md +0 -40
- package/skills/insmind-cli/references/matting.md +0 -27
- package/skills/insmind-cli/references/media-tools.md +0 -46
- package/skills/insmind-cli/references/tool.md +0 -24
- package/skills/insmind-cli/references/update.md +0 -18
package/dist/src/cli/errors.js
CHANGED
|
@@ -25,10 +25,8 @@ import { RemoteProtocolError } from "../platform/remote-protocol.js";
|
|
|
25
25
|
import { InputContractError, OutputContractError } from "../bootstrap/validators.js";
|
|
26
26
|
import { JsonInputError } from "../platform/json-input.js";
|
|
27
27
|
import { LocalFileInputError } from "../platform/safe-upload-file.js";
|
|
28
|
-
import { EditorBridgeError, EditorBridgeUnavailableError } from "../features/editor/bridge-client.js";
|
|
29
28
|
import { LocalFileError } from "../platform/local-json-file.js";
|
|
30
29
|
import { redactSensitiveText } from "../platform/redact.js";
|
|
31
|
-
import { EditorNotReadyError, EditorSessionNotFoundError, EditorTargetError } from "../features/editor/session.js";
|
|
32
30
|
import { UpdateError } from "../features/update/update-service.js";
|
|
33
31
|
import { WindAnalyticsError } from "../analytics/wind.js";
|
|
34
32
|
import { safeFailureSummary } from "../telemetry/failure-summary.js";
|
|
@@ -121,7 +119,7 @@ function mapBaseCliError(error, options) {
|
|
|
121
119
|
code: "INTERRUPTED", message: text("已停止本地等待;已派发的任务或写操作可能仍在继续。", "Local waiting stopped; dispatched tasks or writes may still be active."),
|
|
122
120
|
details: { ...(error instanceof DamOperationUnconfirmedError ? { operation: error.operation, ...error.context } : {}),
|
|
123
121
|
...(error instanceof DamDownloadError ? { phase: error.phase, remaining_paths: error.remainingPaths } : {}),
|
|
124
|
-
next_steps: [text(`创作用 ${command} task list 找到原任务,再用 task get <id>
|
|
122
|
+
next_steps: [text(`创作用 ${command} task list 找到原任务,再用 task get <id> 查询。不要直接重复提交。`, `For creation, find the original task with ${command} task list, then task get <id>. Do not resubmit directly.`)] }
|
|
125
123
|
} };
|
|
126
124
|
if (error instanceof TaskBackgroundError)
|
|
127
125
|
return { kind: "failure", failure: error.failure, exitCode: error.exitCode };
|
|
@@ -159,11 +157,6 @@ function mapBaseCliError(error, options) {
|
|
|
159
157
|
return failure("AUTH_STATE_INVALID", "The account context is unavailable. Sign out and sign in again.", 1, [`${command} auth logout`, `${command} auth login`]);
|
|
160
158
|
return failure("ORG_INVALID", "所选组织不可用,请重新选择组织。", 1, ["gd-cli org list", "gd-cli org switch --org <org-id>"]);
|
|
161
159
|
}
|
|
162
|
-
if (error instanceof EditorTargetError) {
|
|
163
|
-
if (insmind)
|
|
164
|
-
return failure(error.code, "Editor target must be a work ID or a complete trusted insMind Editor URL.", 2);
|
|
165
|
-
return failure(error.code, error.message, 2);
|
|
166
|
-
}
|
|
167
160
|
if (error instanceof JsonInputError)
|
|
168
161
|
return failure("USAGE_ERROR", error.reason === "read"
|
|
169
162
|
? text("无法读取 JSON 输入。", "Cannot read the JSON input.")
|
|
@@ -300,33 +293,6 @@ function mapBaseCliError(error, options) {
|
|
|
300
293
|
}
|
|
301
294
|
if (error instanceof LocalFileError)
|
|
302
295
|
return failure("LOCAL_STATE_ERROR", text("无法访问或解析本地文件,操作未完成。", "A local file could not be accessed or parsed; the operation did not complete."), 1, [text("先检查所列文件的权限、可用空间和内容;不要删除凭证来处理文件故障。", "Check the file's permissions, available space and contents; do not delete credentials to resolve a file failure.")], { reason: error.reason, file: error.file, system_code: systemErrorCode(error) });
|
|
303
|
-
if (error instanceof EditorBridgeUnavailableError || error instanceof EditorBridgeError
|
|
304
|
-
|| error instanceof EditorSessionNotFoundError || error instanceof EditorNotReadyError) {
|
|
305
|
-
const unavailable = error instanceof EditorBridgeUnavailableError;
|
|
306
|
-
const code = unavailable ? "EDITOR_NOT_READY" : error.code;
|
|
307
|
-
let message = redactSensitiveText(error.message).slice(0, 1024);
|
|
308
|
-
if (unavailable)
|
|
309
|
-
message = text("本地 Editor Bridge 连接不可用。", "The local Editor Bridge connection is unavailable.");
|
|
310
|
-
else if (insmind) {
|
|
311
|
-
if (error instanceof EditorSessionNotFoundError)
|
|
312
|
-
message = "No Editor session is available.";
|
|
313
|
-
else if (error instanceof EditorNotReadyError)
|
|
314
|
-
message = "The Editor page did not become ready in time.";
|
|
315
|
-
else
|
|
316
|
-
message = code === "EDITOR_BRIDGE_INVALID_RESPONSE" ? "The Editor Bridge returned an invalid response." : `Editor: ${message}`;
|
|
317
|
-
}
|
|
318
|
-
const connectionError = ["EDITOR_SESSION_NOT_FOUND", "EDITOR_NOT_CONNECTED", "EDITOR_DISCONNECTED", "EDITOR_NOT_READY", "EDITOR_RPC_TIMEOUT"].includes(code);
|
|
319
|
-
let nextStep = text(`按 ${command} editor --help 中该错误的说明处理。`, `Follow the instructions for this error in ${command} editor --help.`);
|
|
320
|
-
if (connectionError && (options.operation === "editor.snapshot" || options.operation === "editor.screenshot")) {
|
|
321
|
-
const read = options.operation === "editor.snapshot" ? "snapshot" : "screenshot";
|
|
322
|
-
nextStep = text(`要继续原作品,若还没有作品链接或 ID,先向用户索取。省略目标会新建线上 Board。拿到原作品的链接或 ID 后,用 ${command} editor connect <target> 连接,再执行 ${command} editor ${read}。`, `To continue the original work, ask the user for its link or ID if you don't have it. Omitting the target creates a new production Board. With the link or ID, run ${command} editor connect <target>, then ${command} editor ${read}.`);
|
|
323
|
-
}
|
|
324
|
-
else if ((options.operation === "editor.apply" || options.operation === "editor.save")
|
|
325
|
-
&& (connectionError || ["EDITOR_ROLLBACK_FAILED", "APPLY_FAILED", "SAVE_FAILED", "EDITOR_BRIDGE_INVALID_RESPONSE"].includes(code))) {
|
|
326
|
-
nextStep = text("先检查原作品的实际状态,再决定后续操作。无法确认状态时停止写入,不重复 apply 或 save。", "Inspect the original work before taking further action. If the state is uncertain, stop writing without repeating apply or save.");
|
|
327
|
-
}
|
|
328
|
-
return failure(code, message, 1, [nextStep], unavailable ? { phase: "editor_connection" } : undefined);
|
|
329
|
-
}
|
|
330
296
|
if (systemErrorCode(error) === "ECONNRESET")
|
|
331
297
|
return failure("REMOTE_REQUEST_FAILED", text("连接中断,未能完整收到结果。", "The connection closed before the full result was received."), 1);
|
|
332
298
|
return failure("INTERNAL_ERROR", insmind ? "The CLI encountered an internal error." : "CLI 发生内部错误。", 1);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { lazySchemaCompiler } from "../platform/schema-compiler.js";
|
|
2
|
-
import { InputContractError } from "../bootstrap/validators.js";
|
|
3
2
|
import { productText } from "../product/text.js";
|
|
4
3
|
function object(value) {
|
|
5
4
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
@@ -79,13 +78,3 @@ export function hostSchema(runtime, schema, tool) {
|
|
|
79
78
|
}
|
|
80
79
|
return result;
|
|
81
80
|
}
|
|
82
|
-
export function editorActions(raw) {
|
|
83
|
-
if (!object(raw) || !Array.isArray(raw.actions))
|
|
84
|
-
throw new InputContractError([
|
|
85
|
-
{ field: "/actions", rule: "type", message: "expected an array of editor actions" }
|
|
86
|
-
]);
|
|
87
|
-
const extra = Object.keys(raw).find(key => key !== "actions");
|
|
88
|
-
if (extra)
|
|
89
|
-
throw new InputContractError([{ field: "/" + extra, rule: "additionalProperties", message: "editor action fields belong inside actions" }]);
|
|
90
|
-
return raw.actions;
|
|
91
|
-
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { skillOutput, writeSkillResult } from "./skill-output.js";
|
|
1
2
|
import { hostSchema } from "./host-input.js";
|
|
2
|
-
import {
|
|
3
|
+
import { bindAction } from "./action-binding.js";
|
|
3
4
|
import { CliUsageError } from "./errors.js";
|
|
4
5
|
import { productText as text } from "../product/text.js";
|
|
5
6
|
export function registerModelCommands(program, runtime) {
|
|
@@ -11,7 +12,7 @@ export function registerModelCommands(program, runtime) {
|
|
|
11
12
|
.option("--tool <tool>", text(runtime.product, "按工具筛选", "filter by tool"))
|
|
12
13
|
.allowExcessArguments(false);
|
|
13
14
|
list.addHelpText("after", text(runtime.product, "\n列表只提供模型摘要。选择后用 model get <model> --tool <tool> 读取完整输入、用途与保留范围,再判断是否符合需求;不能仅凭摘要推断整个工具不支持。\n", "\nThis list is a summary. Read model get <model> --tool <tool> for full inputs, purpose and preservation scope before deciding whether it meets the request; the summary alone cannot establish that the whole Tool is unsupported.\n"));
|
|
14
|
-
|
|
15
|
+
skillOutput(list, runtime);
|
|
15
16
|
bindAction(list, "organization", async (context, signal) => {
|
|
16
17
|
const selectedTool = list.opts().tool;
|
|
17
18
|
if (selectedTool !== undefined)
|
|
@@ -30,7 +31,7 @@ export function registerModelCommands(program, runtime) {
|
|
|
30
31
|
});
|
|
31
32
|
await runtime.telemetry.stage("output", async () => {
|
|
32
33
|
runtime.validators.modelListOutput(result);
|
|
33
|
-
runtime
|
|
34
|
+
await writeSkillResult(runtime, list, result, selectedTool);
|
|
34
35
|
});
|
|
35
36
|
}, { operation: "model.list" });
|
|
36
37
|
const get = model.command("get")
|
|
@@ -50,7 +51,7 @@ export function registerModelCommands(program, runtime) {
|
|
|
50
51
|
text(runtime.product, "公开 Schema 指导构参;CLI 仅检查自身读取、转换、授权和交付所必需的条件。服务端决定业务参数是否可接受,返回明确错误时按实际原因处理,不能静默替换用户值。", "The public Schema guides input construction. The CLI checks only what it needs for reading, conversion, authorization and delivery. The service decides business validity; handle its stated error without silently replacing user values."),
|
|
51
52
|
""
|
|
52
53
|
].join("\n"));
|
|
53
|
-
|
|
54
|
+
skillOutput(get, runtime);
|
|
54
55
|
bindAction(get, "organization", async (context, signal) => {
|
|
55
56
|
const modelName = get.processedArgs[0];
|
|
56
57
|
if (typeof modelName !== "string" || modelName.trim() === "")
|
|
@@ -74,7 +75,7 @@ export function registerModelCommands(program, runtime) {
|
|
|
74
75
|
const projected = result.inputSchema ? hostSchema(runtime, result.inputSchema, result.tool) : undefined;
|
|
75
76
|
const output = { ...result, ...(projected ? { inputSchema: projected } : {}) };
|
|
76
77
|
runtime.validators.modelGetOutput(output);
|
|
77
|
-
runtime
|
|
78
|
+
await writeSkillResult(runtime, get, output, result.tool);
|
|
78
79
|
});
|
|
79
80
|
}, {
|
|
80
81
|
operation: "model.get"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsonOutput } from "./action-binding.js";
|
|
2
|
+
import { productText } from "../product/text.js";
|
|
3
|
+
export function skillOutput(command, runtime) {
|
|
4
|
+
jsonOutput(command, productText(runtime.product, "仅输出原业务 JSON,供按原 Schema 校验的脚本使用", "output only the business JSON for scripts that validate its original schema"));
|
|
5
|
+
command.option("--with-skills", productText(runtime.product, "在 JSON 的 relatedSkills 中附上匹配指引(默认),也可与 --json 合用", "include matching guides in relatedSkills (default), including when used with --json"));
|
|
6
|
+
}
|
|
7
|
+
export async function writeSkillResult(runtime, command, result, operation) {
|
|
8
|
+
const { withSkills, json } = command.opts();
|
|
9
|
+
const relatedSkills = operation && (!json || withSkills)
|
|
10
|
+
? await runtime.skillCatalog?.recommendations(operation)
|
|
11
|
+
: undefined;
|
|
12
|
+
runtime.io.writeOut(JSON.stringify(relatedSkills?.length ? { ...result, relatedSkills } : result) + "\n");
|
|
13
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ToolInputError } from "../features/tool/catalog.js";
|
|
2
|
+
import { skillOutput, writeSkillResult } from "./skill-output.js";
|
|
1
3
|
import { creationTaskHelp } from "./creation-help.js";
|
|
2
4
|
import { hostSchema, readHostInput } from "./host-input.js";
|
|
3
5
|
import { jsonOutput, bindAction, bindPreparedAction } from "./action-binding.js";
|
|
@@ -7,7 +9,7 @@ export function registerToolCommands(program, runtime) {
|
|
|
7
9
|
const tool = program.command("tool")
|
|
8
10
|
.description(text(runtime.product, "生成及附件图片/视频处理:改字、抠图、分层等", "Generate and process attached images/videos: text, cutouts, layers and more"))
|
|
9
11
|
.helpCommand(false);
|
|
10
|
-
tool.addHelpText("after", text(runtime.product, "\n附件、素材链接或导出图片的处理从 tool list 发现,再用 model list --tool <tool> 和 model get <model> --tool <tool>
|
|
12
|
+
tool.addHelpText("after", text(runtime.product, "\n附件、素材链接或导出图片的处理从 tool list 发现,再用 model list --tool <tool> 和 model get <model> --tool <tool> 选择实现。模型选择和参数不决定 Agent/Tool 路线;业务策划或持续多轮创作用 agent send。\n", "\nDiscover processing for attachments, asset links and exported images with tool list, then model list --tool <tool> and model get <model> --tool <tool>. Model choices and controls do not determine Agent/Tool routing; use agent send for planning or multi-turn creation.\n"));
|
|
11
13
|
const list = tool.command("list")
|
|
12
14
|
.description(text(runtime.product, "列出可用工具", "List available tools"))
|
|
13
15
|
.allowExcessArguments(false);
|
|
@@ -40,12 +42,12 @@ export function registerToolCommands(program, runtime) {
|
|
|
40
42
|
text(runtime.product, "最终错误为 stderr 中的 JSON error 对象;stderr 也可能有进度和警告。中断退出码 130 只表示本地停止等待。", "The final error is a JSON error object on stderr, which may also contain progress and warnings. Exit code 130 means local waiting stopped."),
|
|
41
43
|
...creationTaskHelp(runtime.product),
|
|
42
44
|
text(runtime.product, "媒体 URI 字段支持 HTTP(S) 与本地 file URI;本地路径用 Python Path(path).resolve().as_uri() 或 Node.js pathToFileURL(path).href 生成,正确转义中文、空格和 #。CLI 按调用上传素材;原图、参考和选区分别放入对应字段,数组保留顺序和重复项。", "Media URI fields accept HTTP(S) and local file URIs. Generate local URIs with Python Path(path).resolve().as_uri() or Node.js pathToFileURL(path).href to escape Unicode, spaces and #. The CLI uploads them for the call; keep sources, references and masks in their own fields and preserve array order and duplicates."),
|
|
43
|
-
text(runtime.product, "完整结果为 {content,usage}。content 项为 text、resource_link(uri/name/mimeType)或 resource(resource.uri/mimeType/text
|
|
45
|
+
text(runtime.product, "完整结果为 {content,usage}。content 项为 text、resource_link(uri/name/mimeType)或 resource(resource.uri/mimeType/text)。分层返回原生模板 JSON 链接,不是 PSD。交付资源链接时原样保留完整 URI 及查询参数,不截断、拼接或去掉授权参数。", "Complete results are {content,usage}. Content items are text, resource_link (uri/name/mimeType), or resource (resource.uri/mimeType/text). Layer decomposition returns a native template JSON link, not PSD. Preserve each complete delivery URI and its query parameters without truncating, splicing or stripping authorization parameters."),
|
|
44
46
|
text(runtime.product, "Tool usage.cost 的 minimum/maximum 是目录估价,即使相等也不是实际扣费;缺失表示未提供估价,不是免费。实扣须查询可对应的 credits usage 账本;同一 taskId 重复读取不累计费用。", "Tool usage.cost minimum/maximum are catalog estimates even when equal; missing cost means no estimate, not free. Actual charges require matching credits usage ledger records. Repeated reads of one taskId do not add usage."),
|
|
45
47
|
text(runtime.product, "先交付服务返回的已有结果。效果与用户预期有差异时如实说明,后续新创作按用户要求执行;CLI 不按效果阈值判失败或自动重做。本地插值、描图等替代文件不能报告为本工具的服务结果。", "Deliver the existing service result first. Describe any difference from the user's goal and follow the user's instructions for further creation; the CLI does not fail or regenerate based on aesthetic thresholds. Files produced by local interpolation or tracing are not this Tool's service results."),
|
|
46
48
|
""
|
|
47
49
|
].join("\n"));
|
|
48
|
-
|
|
50
|
+
skillOutput(call, runtime);
|
|
49
51
|
bindPreparedAction(call, "organization", async (signal) => {
|
|
50
52
|
signal.throwIfAborted();
|
|
51
53
|
const name = call.processedArgs[0];
|
|
@@ -55,6 +57,8 @@ export function registerToolCommands(program, runtime) {
|
|
|
55
57
|
const modes = Number(options.schema === true) + Number(options.input !== undefined);
|
|
56
58
|
if (modes !== 1 || (options.schema && options.async))
|
|
57
59
|
throw new CliUsageError();
|
|
60
|
+
if (!runtime.product.tools.some(tool => tool.name === name))
|
|
61
|
+
throw new ToolInputError("tool_not_found", "/tool");
|
|
58
62
|
if (options.schema === true) {
|
|
59
63
|
return { handled: false, input: { mode: "schema", name } };
|
|
60
64
|
}
|
|
@@ -89,7 +93,7 @@ export function registerToolCommands(program, runtime) {
|
|
|
89
93
|
const result = await runtime.startBackgroundTask({ ...task, input: prepared.input }, signal);
|
|
90
94
|
await runtime.telemetry.stage("output", async () => {
|
|
91
95
|
runtime.validators.taskResult(result);
|
|
92
|
-
runtime.
|
|
96
|
+
await writeSkillResult(runtime, call, result, prepared.input.name);
|
|
93
97
|
});
|
|
94
98
|
return;
|
|
95
99
|
}
|
|
@@ -97,7 +101,7 @@ export function registerToolCommands(program, runtime) {
|
|
|
97
101
|
...(observe ? { observe } : {}) });
|
|
98
102
|
const result = await runtime.tasks.track({ ...task, run, signal });
|
|
99
103
|
await runtime.telemetry.stage("output", async () => {
|
|
100
|
-
runtime.
|
|
104
|
+
await writeSkillResult(runtime, call, result, prepared.input.name);
|
|
101
105
|
});
|
|
102
106
|
}, {
|
|
103
107
|
operation: "tool.call",
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
const edition = "cli-3.0-v1";
|
|
6
|
+
const validId = /^[a-z][a-z0-9-]{0,63}$/u;
|
|
7
|
+
const maxBytes = 256 * 1024;
|
|
8
|
+
const maxAge = 60 * 60 * 1000;
|
|
9
|
+
function parseCatalog(body) {
|
|
10
|
+
const value = JSON.parse(body);
|
|
11
|
+
if (value?.edition !== edition || !Array.isArray(value.skills) || value.skills.length > 512)
|
|
12
|
+
throw Error("Invalid skill catalog");
|
|
13
|
+
const ids = new Set();
|
|
14
|
+
for (const item of value.skills) {
|
|
15
|
+
if (!item || typeof item.id !== "string" || !validId.test(item.id) || ids.has(item.id) ||
|
|
16
|
+
typeof item.title !== "string" || !item.title.trim() || typeof item.description !== "string" || !item.description.trim() ||
|
|
17
|
+
!Array.isArray(item.operations) || !item.operations.every((op) => typeof op === "string"))
|
|
18
|
+
throw Error("Invalid skill entry");
|
|
19
|
+
ids.add(item.id);
|
|
20
|
+
}
|
|
21
|
+
return value.skills;
|
|
22
|
+
}
|
|
23
|
+
async function readCache(path) {
|
|
24
|
+
try {
|
|
25
|
+
const cached = JSON.parse(await readFile(path, "utf8"));
|
|
26
|
+
if (Number.isFinite(cached.checked) && (cached.etag === null || typeof cached.etag === "string")
|
|
27
|
+
&& typeof cached.body === "string" && Buffer.byteLength(cached.body) <= maxBytes)
|
|
28
|
+
return cached;
|
|
29
|
+
}
|
|
30
|
+
catch { /* A missing or incomplete cache can be fetched again. */ }
|
|
31
|
+
}
|
|
32
|
+
async function bodyText(response) {
|
|
33
|
+
if (!response.body || Number(response.headers.get("content-length")) > maxBytes)
|
|
34
|
+
throw Error("Invalid guide size");
|
|
35
|
+
const chunks = [];
|
|
36
|
+
let total = 0;
|
|
37
|
+
const reader = response.body.getReader();
|
|
38
|
+
try {
|
|
39
|
+
for (;;) {
|
|
40
|
+
const { done, value } = await reader.read();
|
|
41
|
+
if (done)
|
|
42
|
+
break;
|
|
43
|
+
total += value.length;
|
|
44
|
+
if (total > maxBytes) {
|
|
45
|
+
await reader.cancel();
|
|
46
|
+
throw Error("Invalid guide size");
|
|
47
|
+
}
|
|
48
|
+
chunks.push(value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
reader.releaseLock();
|
|
53
|
+
}
|
|
54
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
55
|
+
}
|
|
56
|
+
export function createSkillCatalog(client, options = {}) {
|
|
57
|
+
const now = options.now ?? Date.now;
|
|
58
|
+
const dir = join(options.home ?? homedir(), client === "gd-cli" ? ".gd" : ".insmind", "skill-cache", edition);
|
|
59
|
+
async function load(chapter, parse, timeout) {
|
|
60
|
+
// Both language editions come from the public documentation service. No business payload or credentials are sent.
|
|
61
|
+
const url = new URL(options.endpoint ?? process.env[client === "gd-cli" ? "GD_CLI_SKILL_URL" : "INSMIND_CLI_SKILL_URL"] ?? "https://www.gaoding.com/mcp");
|
|
62
|
+
if (url.username || url.password || url.search || url.hash ||
|
|
63
|
+
!(url.protocol === "https:" || (url.protocol === "http:" && ["127.0.0.1", "[::1]", "localhost"].includes(url.hostname))))
|
|
64
|
+
throw Error("Invalid skill endpoint");
|
|
65
|
+
url.searchParams.set("handbook", edition);
|
|
66
|
+
url.searchParams.set("client", client);
|
|
67
|
+
if (chapter !== undefined)
|
|
68
|
+
url.searchParams.set("chapter", chapter);
|
|
69
|
+
const path = join(dir, createHash("sha256").update(url.href).digest("hex") + ".json");
|
|
70
|
+
let cached = await readCache(path);
|
|
71
|
+
let previous;
|
|
72
|
+
if (cached) {
|
|
73
|
+
try {
|
|
74
|
+
previous = parse(cached.body);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
cached = undefined;
|
|
78
|
+
}
|
|
79
|
+
if (cached && previous !== undefined && cached.checked <= now() && now() - cached.checked < maxAge)
|
|
80
|
+
return previous;
|
|
81
|
+
}
|
|
82
|
+
let response;
|
|
83
|
+
try {
|
|
84
|
+
response = await (options.fetch ?? globalThis.fetch)(url, {
|
|
85
|
+
headers: cached?.etag ? { "If-None-Match": cached.etag } : {},
|
|
86
|
+
credentials: "omit", redirect: "error", signal: AbortSignal.timeout(timeout),
|
|
87
|
+
});
|
|
88
|
+
let record;
|
|
89
|
+
if (response.status === 304 && cached)
|
|
90
|
+
record = { ...cached, checked: now() };
|
|
91
|
+
else {
|
|
92
|
+
if (response.status === 404 && chapter !== undefined) {
|
|
93
|
+
await rm(path, { force: true }).catch(() => undefined);
|
|
94
|
+
throw new MissingSkill();
|
|
95
|
+
}
|
|
96
|
+
if (response.status !== 200)
|
|
97
|
+
throw Error("Handbook HTTP " + response.status);
|
|
98
|
+
const mime = response.headers.get("content-type")?.split(";")[0]?.trim();
|
|
99
|
+
if (mime !== (chapter ? "text/markdown" : "application/json"))
|
|
100
|
+
throw Error("Invalid guide format");
|
|
101
|
+
record = { checked: now(), etag: response.headers.get("etag"), body: await bodyText(response) };
|
|
102
|
+
}
|
|
103
|
+
const value = parse(record.body);
|
|
104
|
+
const temporary = path + "." + randomUUID() + ".tmp";
|
|
105
|
+
try {
|
|
106
|
+
await mkdir(dir, { recursive: true });
|
|
107
|
+
await writeFile(temporary, JSON.stringify(record), { flag: "wx", mode: 0o600 });
|
|
108
|
+
await rename(temporary, path);
|
|
109
|
+
}
|
|
110
|
+
catch { /* A read-only filesystem still permits online documentation. */ }
|
|
111
|
+
finally {
|
|
112
|
+
await rm(temporary, { force: true }).catch(() => undefined);
|
|
113
|
+
}
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (error instanceof MissingSkill)
|
|
118
|
+
throw error;
|
|
119
|
+
if (previous !== undefined)
|
|
120
|
+
return previous;
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
if (response?.body && !response.bodyUsed)
|
|
125
|
+
await response.body.cancel().catch(() => undefined);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
list: () => load(undefined, parseCatalog, 3500),
|
|
130
|
+
read(id) {
|
|
131
|
+
if (!validId.test(id))
|
|
132
|
+
throw new MissingSkill();
|
|
133
|
+
return load(id, body => {
|
|
134
|
+
if (!/^#\s+\S/mu.test(body))
|
|
135
|
+
throw Error("Invalid guide document");
|
|
136
|
+
return body;
|
|
137
|
+
}, 3500);
|
|
138
|
+
},
|
|
139
|
+
async recommendations(operation) {
|
|
140
|
+
try {
|
|
141
|
+
const items = await load(undefined, parseCatalog, 650);
|
|
142
|
+
return items.filter(item => item.operations.some(op => op.endsWith(".*") ? operation.startsWith(op.slice(0, -1)) : op === operation))
|
|
143
|
+
.map(({ id, title, description }) => ({ id, title, description, command: client + " --skill " + id }));
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
export class MissingSkill extends Error {
|
|
152
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { createSkillCatalog, MissingSkill } from "./catalog.js";
|
|
5
|
+
/** Return undefined for normal commands. Documentation also works with lifecycle scripts disabled. */
|
|
6
|
+
export async function runSkillManual(argv, name, jsonErrors) {
|
|
7
|
+
if (!argv.includes("--skill"))
|
|
8
|
+
return;
|
|
9
|
+
const end = argv.indexOf("--");
|
|
10
|
+
const options = end < 0 ? argv : argv.slice(0, end);
|
|
11
|
+
const words = [];
|
|
12
|
+
for (let index = 0; index < options.length; index++) {
|
|
13
|
+
const argument = options[index];
|
|
14
|
+
if (argument === "--json-errors")
|
|
15
|
+
continue;
|
|
16
|
+
if (name === "insmind-cli") {
|
|
17
|
+
if (argument === "--locale") {
|
|
18
|
+
index++;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (argument.startsWith("--locale="))
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
words.push(argument);
|
|
25
|
+
}
|
|
26
|
+
if (words.shift() !== "--skill")
|
|
27
|
+
return;
|
|
28
|
+
if (end >= 0)
|
|
29
|
+
words.push(...argv.slice(end + 1));
|
|
30
|
+
const english = name === "insmind-cli";
|
|
31
|
+
const usage = english ? "Usage: insmind-cli --skill [chapter]" : "用法:gd-cli --skill [章节]";
|
|
32
|
+
const [chapter] = words;
|
|
33
|
+
const help = chapter === "--help" || chapter === "-h";
|
|
34
|
+
if (words.length > 1 || (chapter && !help && !/^[a-z][a-z0-9-]{0,63}$/u.test(chapter))) {
|
|
35
|
+
writeError("USAGE_ERROR", usage, jsonErrors);
|
|
36
|
+
return 2;
|
|
37
|
+
}
|
|
38
|
+
const catalog = createSkillCatalog(name);
|
|
39
|
+
try {
|
|
40
|
+
if (chapter !== undefined && !help) {
|
|
41
|
+
process.stdout.write(await catalog.read(chapter));
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
if (!help) {
|
|
45
|
+
const { loadBundledSkills } = await import("./bundled-skills.js");
|
|
46
|
+
const skill = loadBundledSkills(fileURLToPath(import.meta.url)).find(entry => entry.skill === name);
|
|
47
|
+
if (!skill)
|
|
48
|
+
throw Error("Missing entry Skill");
|
|
49
|
+
const entry = await readFile(join(skill.sourceDirectory, "SKILL.md"), "utf8");
|
|
50
|
+
process.stdout.write(entry.replace(/^---\n[\s\S]*?\n---\n/u, "") + "\n");
|
|
51
|
+
}
|
|
52
|
+
process.stdout.write(usage + "\n");
|
|
53
|
+
const skills = await catalog.list();
|
|
54
|
+
for (const item of skills)
|
|
55
|
+
process.stdout.write(name + " --skill " + item.id + " " + item.title + " — " + item.description + "\n");
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error instanceof MissingSkill) {
|
|
60
|
+
writeError("USAGE_ERROR", (english ? "Unknown chapter. " : "未找到该章节。") + usage, jsonErrors);
|
|
61
|
+
return 2;
|
|
62
|
+
}
|
|
63
|
+
const message = english ? "The guide is unavailable. Use command --help for basic usage."
|
|
64
|
+
: "当前无法取得指引,可用命令的 --help 查看基础用法。";
|
|
65
|
+
writeError("SKILL_UNAVAILABLE", message, jsonErrors);
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function writeError(code, message, json) {
|
|
70
|
+
process.stderr.write((json ? JSON.stringify({ error: { code, message } }) : message) + "\n");
|
|
71
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Read-only compatibility for saved tasks created before OCR was retired.
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { lazySchemaCompiler } from "../../platform/schema-compiler.js";
|
|
4
|
+
import { RemoteProtocolError } from "../../platform/remote-protocol.js";
|
|
5
|
+
const schema = {
|
|
6
|
+
type: "object",
|
|
7
|
+
required: ["image", "blocks"],
|
|
8
|
+
properties: {
|
|
9
|
+
image: {
|
|
10
|
+
type: "object",
|
|
11
|
+
required: ["uri", "width", "height"],
|
|
12
|
+
properties: {
|
|
13
|
+
uri: { type: "string", format: "uri" },
|
|
14
|
+
width: { type: "integer", minimum: 1 },
|
|
15
|
+
height: { type: "integer", minimum: 1 },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
blocks: {
|
|
19
|
+
type: "array",
|
|
20
|
+
items: {
|
|
21
|
+
type: "object",
|
|
22
|
+
required: ["bbox", "category"],
|
|
23
|
+
properties: {
|
|
24
|
+
bbox: { type: "array", minItems: 4, maxItems: 4, items: { type: "number" } },
|
|
25
|
+
category: { type: "string", minLength: 1, pattern: ".*\\S.*" },
|
|
26
|
+
text: { type: "string" },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const compiler = lazySchemaCompiler({ strict: true, allErrors: true });
|
|
33
|
+
let validator;
|
|
34
|
+
function validateOcr(value) {
|
|
35
|
+
validator ??= compiler().compile(schema);
|
|
36
|
+
return validator(value);
|
|
37
|
+
}
|
|
38
|
+
export function readOcrPayload(text) {
|
|
39
|
+
let payload;
|
|
40
|
+
try {
|
|
41
|
+
payload = JSON.parse(text);
|
|
42
|
+
}
|
|
43
|
+
catch (cause) {
|
|
44
|
+
throw new RemoteProtocolError({}, cause, "OCR_JSON_INVALID");
|
|
45
|
+
}
|
|
46
|
+
if (!validateOcr(payload))
|
|
47
|
+
throw new RemoteProtocolError({}, undefined, "OCR_PAYLOAD_INVALID");
|
|
48
|
+
return payload;
|
|
49
|
+
}
|
|
50
|
+
export function ocrResult(content, image, id = randomUUID()) {
|
|
51
|
+
const result = [];
|
|
52
|
+
for (const part of content) {
|
|
53
|
+
if (part.type === "resource_link") {
|
|
54
|
+
result.push(part);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
let blocks;
|
|
58
|
+
try {
|
|
59
|
+
blocks = JSON.parse(part.type === "text" ? part.text : part.resource.text);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
result.push(part);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const payload = { image, blocks };
|
|
66
|
+
if (!Array.isArray(blocks) || !validateOcr(payload)) {
|
|
67
|
+
result.push(part);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
result.push({ type: "resource", resource: { uri: part.type === "resource" ? part.resource.uri : `urn:uuid:${result.some(item => item.type === "resource") ? randomUUID() : id}`,
|
|
71
|
+
mimeType: "application/json", text: JSON.stringify(payload) } });
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
@@ -11,9 +11,8 @@ const copy = {
|
|
|
11
11
|
"image-expand-standard": ["Standard image expansion", "canvas and placement use auto-oriented source pixels. Origin is top-left; x goes right and y down. The original must fit without scaling. The target canvas dimensions are requested from the service."],
|
|
12
12
|
"image-expand-smart": ["Smart image expansion", "Place the source at natural size and expand its surroundings. Output uses the target aspect ratio; pixel dimensions follow the live resolution setting. Source details can change."],
|
|
13
13
|
"image-text-edit": ["Image text replacement", "replacements match complete original text. An empty to deletes it. Repeated text cannot be targeted by occurrence; actual text and layout are determined by the returned image."],
|
|
14
|
-
"image-
|
|
15
|
-
"image-layers-
|
|
16
|
-
"image-layers-smart": ["Smart layer decomposition", "For separating objects in a photo from each other and the background, such as a product and surrounding props. Fits the source within 3000×3000 pixels without enlargement; the service requires width × height of at least 262144 total pixels (512×512), not a 512-pixel minimum for each edge. Returns native template JSON and any accompanying service notes, not PSD or word-by-word OCR. maxLayers is an upper bound. Pricing uses current remote metered components."],
|
|
14
|
+
"image-layers-layout": ["Layout decomposition", "For separating layout elements such as poster headlines, body text and background. Fits the source within 3000×3000 pixels without enlargement. Returns native template JSON and any accompanying service notes, not PSD. Editability depends on the returned layers; fonts may be substituted."],
|
|
15
|
+
"image-layers-smart": ["Smart layer decomposition", "For separating objects in a photo from each other and the background, such as a product and surrounding props. Fits the source within 3000×3000 pixels without enlargement; the service requires width × height of at least 262144 total pixels (512×512), not a 512-pixel minimum for each edge. Returns native template JSON and any accompanying service notes, not PSD. maxLayers is an upper bound. Pricing uses current remote metered components."],
|
|
17
16
|
"image-vectorize": ["Image to SVG", "Returns an SVG resource. Shapes, colors and details may be reconstructed; actual vector contents are determined by the returned file."],
|
|
18
17
|
"video-edit-smart": ["Smart video edit", "Duration and ratio come from the actual source. Reference videos including the source total at most 15 seconds. audioEnabled controls audio presence, not preservation of the original sound."],
|
|
19
18
|
"video-enhance-standard": ["Standard video upscale", "Uses ceil(actual seconds) for billing and requests preservation of the source video. Actual duration, visuals and soundtrack are determined by the returned video."],
|
|
@@ -16,7 +16,6 @@ export const canvasModelBindings = [
|
|
|
16
16
|
["image.expand", "image-expand-standard", "outpainting-pro", "canvas-image-expand", "标准扩图", "dify"],
|
|
17
17
|
["image.expand", "image-expand-smart", "canvas-image-expand-sunburst", "canvas-image-expand", "智能扩图", "dify"],
|
|
18
18
|
["image.text_edit", "image-text-edit", "TextEdit", "TextEdit", "图片改字", "dify"],
|
|
19
|
-
["image.ocr", "image-ocr", "new-image-ocr", "new-image-ocr", "文字识别", "dify"],
|
|
20
19
|
["image.layers", "image-layers-layout", "codia", "special-agent-tools", "图文分层", "toolkit"],
|
|
21
20
|
["image.layers", "image-layers-smart", "seedream-layer-decomposition", "special-agent-tools", "智能分层", "toolkit"],
|
|
22
21
|
["image.vectorize", "image-vectorize", "eval-recraft-vectorize", "canvas-image-vectorize", "图片转矢量", "dify"],
|
|
@@ -24,7 +23,12 @@ export const canvasModelBindings = [
|
|
|
24
23
|
["video.enhance", "video-enhance-standard", "canvas-video-enhance-fast", "canvas-video-enhance", "标准视频超分", "dify"],
|
|
25
24
|
["video.enhance", "video-enhance-smart", "canvas-video-enhance-smart", "canvas-video-enhance", "智能视频修复", "dify"]
|
|
26
25
|
];
|
|
27
|
-
|
|
26
|
+
// MNS uses both associations for layers: production uses AI-image-tool, FAT uses special-agent-tools.
|
|
27
|
+
export const canvasSceneTools = new Map([
|
|
28
|
+
...canvasModelBindings.map(([tool, , , scene]) => [scene, tool]),
|
|
29
|
+
["AI-image-tool", "image.layers"]
|
|
30
|
+
]);
|
|
31
|
+
export const canvasSceneCodes = [...canvasSceneTools.keys()];
|
|
28
32
|
export function canvasProtocol(model) {
|
|
29
33
|
const binding = canvasModelBindings.find(([, id]) => id === model);
|
|
30
34
|
if (!binding)
|
|
@@ -143,9 +147,8 @@ export function canvasModel(raw, binding, configuration, english = false) {
|
|
|
143
147
|
"image-expand-standard": "canvas/placement 以自动转正后的原图自然像素计。画布左上角为原点,x向右、y向下;原图不得缩放或超出画布,向服务请求目标画布尺寸。",
|
|
144
148
|
"image-expand-smart": "按自然尺寸和像素坐标放置原图、补绘外围;智能输出采用目标比例,像素尺寸由当前分辨率选项决定,可能改变原图细节。",
|
|
145
149
|
"image-text-edit": "replacements 用完整原文匹配;空 to 表示删除。重复原文无法指定某一次出现;实际文字与版式以返回图片为准。",
|
|
146
|
-
"image-
|
|
147
|
-
"image-layers-
|
|
148
|
-
"image-layers-smart": "用于分开照片中的物件和背景,例如商品与周围的摆件。输入按比例缩小到3000×3000范围内,不放大小图;服务要求处理后宽×高至少262144总像素(512×512),不是每条边都至少512。把图片拆为独立物件图层,返回原生模板 JSON 和服务附带的说明;maxLayers 是图层数量上限,按当前远端计费组件计价。不是逐字OCR或PSD。",
|
|
150
|
+
"image-layers-layout": "用于拆分版式元素,例如海报的标题、正文和底图。输入按比例缩小到3000×3000范围内,不放大小图。返回原生模板 JSON 资源和服务附带的说明;文字/图片/矢量的实际可编辑程度以模板图层为准,字体可能替换。不是PSD。",
|
|
151
|
+
"image-layers-smart": "用于分开照片中的物件和背景,例如商品与周围的摆件。输入按比例缩小到3000×3000范围内,不放大小图;服务要求处理后宽×高至少262144总像素(512×512),不是每条边都至少512。把图片拆为独立物件图层,返回原生模板 JSON 和服务附带的说明;maxLayers 是图层数量上限,按当前远端计费组件计价。不提供 PSD。",
|
|
149
152
|
"image-vectorize": "返回 SVG 资源;形状、颜色和细节可能重建,实际矢量内容以返回文件为准。",
|
|
150
153
|
"video-edit-smart": "从原视频推导时长与比例;原片与全部参考视频的合计时长不超过15秒。audioEnabled 控制输出是否有音轨,不承诺原音轨内容不变。智能处理可能改动画面与声音。",
|
|
151
154
|
"video-enhance-standard": "标准视频超分,从实际输入时长计费(向上取整秒),请求保持原视频;实际时长、画面及原声以返回视频为准。",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { canvasModelBindings } from "./canvas-models.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ocrResult } from "./archived-ocr-result.js";
|
|
3
|
+
import { canvasContent, templateResult } from "./canvas-results.js";
|
|
3
4
|
import { presentToolContent } from "./tool-output.js";
|
|
4
5
|
import { queryToolkitResult } from "./canvas-tool-adapter.js";
|
|
5
6
|
import { queryToolResult } from "./tool-api-adapter.js";
|
|
@@ -8,7 +9,7 @@ import { RemoteProtocolError } from "../../platform/remote-protocol.js";
|
|
|
8
9
|
/** Read-only recovery. This module deliberately has no uploader or generation port. */
|
|
9
10
|
export async function recoverCanvasTool(progress, context, dependencies) {
|
|
10
11
|
const pipeline = progress.toolPipeline;
|
|
11
|
-
if (!canvasModelBindings.some(binding => binding[1] === pipeline.model))
|
|
12
|
+
if (pipeline.model !== "image-ocr" && !canvasModelBindings.some(binding => binding[1] === pipeline.model))
|
|
12
13
|
throw new RemoteProtocolError();
|
|
13
14
|
const saved = pipeline.partialContent ? { content: pipeline.partialContent, fromCheckpoint: true } : {};
|
|
14
15
|
const unknown = () => ({ state: "unknown", ...saved });
|