@gaoding/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 +8 -84
- package/contracts/operations/agent.send/output.schema.json +6 -6
- package/contracts/operations/dam.folder.list/input.schema.json +1 -1
- package/contracts/operations/dam.folder.list/output.schema.json +1 -1
- package/contracts/operations/dam.list/input.schema.json +2 -5
- package/contracts/operations/dam.list/output.schema.json +1 -1
- package/contracts/operations/dam.search/input.schema.json +2 -5
- package/contracts/operations/dam.search/output.schema.json +1 -1
- package/contracts/operations/model.get/output.schema.json +6 -5
- package/contracts/operations/model.list/output.schema.json +5 -4
- package/contracts/operations/task.get/output.schema.json +22 -11
- package/contracts/operations/tool.call/models/image-edit-smart.schema.json +7 -5
- package/contracts/operations/tool.call/models/image-edit-standard.schema.json +6 -4
- package/contracts/operations/tool.call/models/image-enhance-smart.schema.json +5 -3
- package/contracts/operations/tool.call/models/image-enhance-standard.schema.json +3 -2
- package/contracts/operations/tool.call/models/image-expand-smart.schema.json +16 -10
- package/contracts/operations/tool.call/models/image-expand-standard.schema.json +13 -8
- package/contracts/operations/tool.call/models/image-layers-layout.schema.json +3 -2
- package/contracts/operations/tool.call/models/image-layers-smart.schema.json +3 -4
- package/contracts/operations/tool.call/models/image-matting-smart.schema.json +6 -4
- package/contracts/operations/tool.call/models/image-matting-standard.schema.json +3 -2
- package/contracts/operations/tool.call/models/image-ocr.schema.json +3 -2
- package/contracts/operations/tool.call/models/image-remove-smart.schema.json +6 -4
- package/contracts/operations/tool.call/models/image-remove-standard.schema.json +4 -3
- package/contracts/operations/tool.call/models/image-text-edit.schema.json +5 -3
- package/contracts/operations/tool.call/models/image-vectorize.schema.json +3 -2
- package/contracts/operations/tool.call/models/video-edit-smart.schema.json +6 -6
- package/contracts/operations/tool.call/models/video-enhance-smart.schema.json +7 -4
- package/contracts/operations/tool.call/models/video-enhance-standard.schema.json +5 -3
- package/contracts/operations/tool.call/ocr-payload.schema.json +4 -5
- package/contracts/operations/tool.call/output.schema.json +9 -8
- 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/gd-cli/SKILL.md +18 -5
- package/skills/gd-cli/references/agent.md +9 -4
- package/skills/gd-cli/references/creation.md +3 -1
- package/skills/gd-cli/references/editor.md +7 -5
- package/skills/gd-cli/references/errors.md +19 -8
- package/skills/gd-cli/references/matting.md +3 -5
- package/skills/gd-cli/references/media-tools.md +10 -4
- package/skills/gd-cli/references/tool.md +9 -15
|
@@ -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)) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { identifyInvocation } from "../telemetry/command-route.js";
|
|
1
2
|
import { jsonErrorsRequested } from "../platform/error-output-mode.js";
|
|
2
3
|
const environments = new WeakMap();
|
|
3
4
|
const boundPolicies = new WeakMap();
|
|
@@ -106,44 +107,20 @@ function annotateAccessContext(telemetry, context) {
|
|
|
106
107
|
organization_id: context.state.organization?.id
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
let command = program;
|
|
112
|
-
let unknown = false;
|
|
113
|
-
let mode = "execute";
|
|
114
|
-
for (let i = 0; i < argv.length; i++) {
|
|
115
|
-
const token = argv[i];
|
|
116
|
-
if (token === "--")
|
|
117
|
-
break;
|
|
118
|
-
if (token === "-h" || token === "--help") {
|
|
119
|
-
mode = "help";
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (token === "-V" || token === "--version") {
|
|
123
|
-
mode = "version";
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (token.startsWith("-")) {
|
|
127
|
-
const flag = token.split("=")[0];
|
|
128
|
-
const option = [...command.options, ...program.options].find(item => item.long === flag || item.short === flag);
|
|
129
|
-
if (option?.long === "--schema" && mode === "execute")
|
|
130
|
-
mode = "schema";
|
|
131
|
-
if (option?.required && !token.includes("="))
|
|
132
|
-
i++;
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (command.commands.length) {
|
|
136
|
-
const child = command.commands.find(item => item.name() === token || item.aliases().includes(token));
|
|
137
|
-
if (!child) {
|
|
138
|
-
unknown = true;
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
command = child;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
110
|
+
export function commandRoute(command) {
|
|
111
|
+
const definition = commandDefinitions.get(command);
|
|
144
112
|
const path = commandPath(command).split(" ").slice(1).join(".");
|
|
145
|
-
const
|
|
146
|
-
|
|
113
|
+
const children = Object.create(null);
|
|
114
|
+
for (const child of command.commands) {
|
|
115
|
+
const route = commandRoute(child);
|
|
116
|
+
for (const name of [child.name(), ...child.aliases()])
|
|
117
|
+
children[name] = route;
|
|
118
|
+
}
|
|
119
|
+
return { operation: definition?.operation ?? (path || "unknown"), action: !!definition,
|
|
120
|
+
options: command.options.map(option => option.flags), children };
|
|
121
|
+
}
|
|
122
|
+
export function invocationDefinition(program, argv) {
|
|
123
|
+
return identifyInvocation(commandRoute(program), argv);
|
|
147
124
|
}
|
|
148
125
|
function commandPath(command) {
|
|
149
126
|
const names = [];
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
+
import { creationTaskHelp } from "./creation-help.js";
|
|
1
2
|
import { hostSchema, readHostInput } from "./host-input.js";
|
|
2
|
-
import {
|
|
3
|
+
import { readAgentInputSchema } from "../contracts/creation-input.js";
|
|
3
4
|
import { jsonOutput, bindPreparedAction } from "./action-binding.js";
|
|
4
5
|
import { CliUsageError } from "./errors.js";
|
|
5
6
|
import { productText as text } from "../product/text.js";
|
|
6
7
|
export function registerAgentCommands(program, runtime) {
|
|
7
8
|
const agent = program.command("agent")
|
|
8
|
-
.description(text(runtime.product, "
|
|
9
|
+
.description(text(runtime.product, "业务策划与持续多轮创作", "Business planning and multi-turn creation"))
|
|
9
10
|
.helpCommand(false);
|
|
10
11
|
const send = agent.command("send")
|
|
11
|
-
.description(text(runtime.product, "
|
|
12
|
+
.description(text(runtime.product, "发送创作消息,等待本轮回复、成品或补充问题", "Send a creation message and wait for this turn's reply, assets or questions"))
|
|
12
13
|
.option("--schema", text(runtime.product, "输出输入 Schema", "output the input Schema"))
|
|
13
14
|
.option("--input <file|->", text(runtime.product, "从文件或标准输入读取 JSON", "read JSON from a file or stdin"))
|
|
14
15
|
.option("--async", text(runtime.product, "提交后返回 taskId,通过 task get 查询结果", "return taskId after submission; retrieve results with task get"))
|
|
15
16
|
.allowExcessArguments(false);
|
|
16
17
|
send.addHelpText("after", [
|
|
17
18
|
"",
|
|
19
|
+
text(runtime.product, "用于业务策划、多步骤或持续创作;明确的单次媒体处理也可从 tool list 发现。先保存完整 JSON 再用 --input request.json 执行;--input - 必须在同一条 shell 命令中经管道或重定向提供完整 JSON,不交互填参。", "Use for planning, multiple steps or continuing creation; discover atomic media processing with tool list. Save complete JSON before using --input request.json. With --input -, pipe or redirect complete JSON in the same shell command; input is not an interactive form."),
|
|
18
20
|
text(runtime.product, "完整结果已校验但最终本地记录保存失败时仍返回结果和退出码 0;stderr 警告 task get 可能无法恢复,请保留输出。", "A validated complete result is delivered with exit code 0 even if its final local record cannot be saved; stderr warns that task get may not recover it. Keep the output."),
|
|
19
21
|
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."),
|
|
20
|
-
|
|
21
|
-
text(runtime.product, "
|
|
22
|
-
text(runtime.product, "Agent 异步由本机后台进程继续执行;进程终止或关机可能使状态变为 unknown。", "Agent async continues in a local background process; termination or shutdown may leave its state unknown."),
|
|
23
|
-
text(runtime.product, "中断前台等待不会取消已交接的后台任务;仍用原 taskId 查询。", "Interrupting the foreground wait does not cancel a handed-off task; query the same taskId."),
|
|
24
|
-
text(runtime.product, "默认在当前进程等待最终结果,成功后一次输出 JSON。", "By default, the command waits in the current process and returns the final result as one JSON object."),
|
|
25
|
-
text(runtime.product, "运行中请继续等待原进程;已提交但结果未知时,不要重复提交。", "Wait for the original process. Do not resubmit a creation whose outcome is unknown."),
|
|
26
|
-
text(runtime.product, "默认模式在 stderr 提示任务 ID,stdout 保持原结果 JSON。", "In default mode the Task ID is written to stderr; stdout contains only the original result JSON."),
|
|
27
|
-
text(runtime.product, `结果未收到时执行 ${runtime.product.commandName} task list 找到原调用,再执行 ${runtime.product.commandName} task get <id> 查询。`, `If output is missing, find the original run with ${runtime.product.commandName} task list, then query ${runtime.product.commandName} task get <id>.`),
|
|
22
|
+
...creationTaskHelp(runtime.product),
|
|
23
|
+
text(runtime.product, "本机后台进程终止或关机可能使 Agent 任务变为 unknown。", "If the local background process stops or the machine shuts down, an Agent task may become unknown."),
|
|
28
24
|
text(runtime.product, "首次创作省略 JSON 中的 message.contextId;续聊时传入上次结果的 message.contextId。", "Omit message.contextId for the first creation. Continue a conversation using message.contextId from the previous result."),
|
|
25
|
+
text(runtime.product, "completed 表示本轮 Agent 已完整回复,可能是文本、资源或补充/确认问题,并不保证已生成成品。转述实际回复;需要用户回答时询问用户,收到回答后沿用 contextId 发送下一轮。", "completed means the Agent's turn has fully replied with text, assets or clarification/confirmation questions; it does not guarantee a finished asset. Relay the actual reply, ask the user when an answer is needed, then continue with the same contextId."),
|
|
26
|
+
text(runtime.product, "把本轮实际回复或资源连同 usage.cost.amount 的实际消耗一并交付。同步从输出读取,异步从 completed 的 result 读取。返回 0 就报 0,缺失则说明未取得。汇总按不同 taskId,同一任务重复读取只计一次。Tool minimum/maximum 是目录估价。", "Deliver this turn's reply or assets together with the actual charge in usage.cost.amount. Read it from the synchronous output or the completed task's result. Report 0 when present, and unknown when absent. Count each distinct taskId once. Tool minimum/maximum are catalog estimates."),
|
|
27
|
+
text(runtime.product, "结构化问题位于 message.parts[].data.questions;回答时将 message.messageId 写入 data.questionMessageId,answers 保留 question 原文及用户 values,该 data Part 是本轮 parts 唯一一项。普通文本续聊使用 text Part。", "Structured questions are in message.parts[].data.questions. Reply with message.messageId as data.questionMessageId and answers containing the original question and the user's values; this data Part must be the sole Part. Use a text Part for ordinary follow-up conversation."),
|
|
29
28
|
text(runtime.product, "可用 model 和参数示例见 model list / model get。显式 model 和 arguments 会传给 Agent,编辑模型的已知别名转换为服务字段。文本和素材用独立 Part。", "Discover models and example controls with model list and model get. Explicit model and arguments are sent to the Agent, with known editing aliases mapped to service fields. Supply text and assets as separate Parts."),
|
|
30
|
-
text(runtime.product, "
|
|
29
|
+
text(runtime.product, "交付服务返回的资源时,原样使用完整 URL 及查询参数;不凭记忆重写、拼接或去掉授权参数。诊断凭证脱敏不改变可交付资源链接。", "Deliver service resources using the complete returned URL and query parameters. Do not reconstruct, splice or strip authorization parameters. Diagnostic credential redaction does not alter delivery links."),
|
|
30
|
+
text(runtime.product, "素材用独立 URL Part;本地文件用 Path(path).resolve().as_uri() 或 pathToFileURL(path).href 生成标准 URI,保留顺序和 metadata.role。--input 的 JSON 文件参数仍使用路径。", "Supply assets as separate URL Parts, preserving order and metadata.role. Generate local URIs with Path(path).resolve().as_uri() or pathToFileURL(path).href. The --input JSON file argument remains a path."),
|
|
31
31
|
""
|
|
32
32
|
].join("\n"));
|
|
33
33
|
jsonOutput(send);
|
|
@@ -39,7 +39,7 @@ export function registerAgentCommands(program, runtime) {
|
|
|
39
39
|
throw new CliUsageError();
|
|
40
40
|
if (options.schema === true) {
|
|
41
41
|
await runtime.telemetry.stage("output", async () => {
|
|
42
|
-
runtime.io.writeOut(`${JSON.stringify(hostSchema(runtime,
|
|
42
|
+
runtime.io.writeOut(`${JSON.stringify(hostSchema(runtime, readAgentInputSchema()))}\n`);
|
|
43
43
|
});
|
|
44
44
|
return { handled: true };
|
|
45
45
|
}
|
|
@@ -6,6 +6,7 @@ export function registerAuthCommands(program, runtime) {
|
|
|
6
6
|
const auth = program.command("auth")
|
|
7
7
|
.description(text(runtime.product, "登录与本机凭证", "Authentication and local credentials"))
|
|
8
8
|
.helpCommand(false);
|
|
9
|
+
auth.addHelpText("after", text(runtime.product, "\n管理本机 CLI 登录;不替代 Editor 浏览器登录。status 只读状态,login 等待浏览器授权完成,logout 清除本机共享登录。授权链接不等于登录成功;无需提供或读取 AK/SK、Cookie 等凭证。\n", "\nManages the local CLI identity, separately from Editor browser login. status reads state, login waits for browser authorization, and logout clears the shared local sign-in. An authorization URL is not successful login; do not provide or read credential values.\n"));
|
|
9
10
|
const login = leaf(auth.command("login"))
|
|
10
11
|
.description(text(runtime.product, "登录稿定", "Sign in to insMind"))
|
|
11
12
|
.option("--no-browser", text(runtime.product, "不自动打开浏览器", "do not open a browser automatically"))
|
|
@@ -51,7 +52,7 @@ export function registerAuthCommands(program, runtime) {
|
|
|
51
52
|
});
|
|
52
53
|
});
|
|
53
54
|
}, { operation: "auth.status" });
|
|
54
|
-
const logout = leaf(auth.command("logout")).description(text(runtime.product, "退出登录", "Sign out"));
|
|
55
|
+
const logout = leaf(auth.command("logout")).description(text(runtime.product, "退出登录", "Sign out")).addHelpText("after", text(runtime.product, "\n清除本机 CLI 凭证及当前组织选择,会影响复用这份登录的其他入口;不删除云端素材或作品。\n", "\nClears local CLI credentials and the current identity context, affecting other entry points sharing this sign-in. It does not delete cloud assets or works.\n"));
|
|
55
56
|
bindAction(logout, "none", async () => {
|
|
56
57
|
await runtime.auth.logout();
|
|
57
58
|
await runtime.telemetry.stage("output", async () => {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { productText } from "../product/text.js";
|
|
2
|
+
export function creationTaskHelp(product) {
|
|
3
|
+
return [
|
|
4
|
+
productText(product, "现在要结果时默认同步。保留宿主返回的退出状态和进程句柄,进程仍在运行就继续等待原进程,直到 stdout 给出完整结果或命令报错。", "For a result now, use the default synchronous command. Keep the host's exit status and process handle. While it is running, wait on that process for the complete stdout result or an error."),
|
|
5
|
+
productText(product, "失去进程句柄时,用 stderr 提示的 taskId 执行 task get <taskId>。没有 ID 时用 task list 定位原调用。现在要交付且 state=running 时隔数秒继续查原 ID。", "If the process handle is lost, use task get <taskId> with the ID from stderr, or locate the call with task list. For delivery now, keep checking the same ID every few seconds while state is running."),
|
|
6
|
+
productText(product, "用户明确稍后取回时用 --async。受理后立即向用户返回 taskId 和当前 state,本轮到此结束。用户回来时用同一 ID 取结果。退出码 0 在此表示已受理。", "For later pickup, use --async. As soon as it is accepted, return the taskId and current state to the user and end this turn. When they return, retrieve the result with that ID. Exit 0 here means accepted."),
|
|
7
|
+
productText(product, "异步由本机后台进程继续执行。退出前台不会取消已交接的任务。unknown 或查询超时只能说明结果待确认,请查原任务,勿另发创作。", "Async work continues in a local background process. Leaving the foreground does not cancel accepted work. On unknown or a query timeout, check the original task without resubmitting.")
|
|
8
|
+
];
|
|
9
|
+
}
|
|
@@ -11,6 +11,7 @@ export function registerDamCommands(program, runtime) {
|
|
|
11
11
|
"",
|
|
12
12
|
text(runtime.product, "先通过 repository list、folder list、tag list 或资源查询取得真实 ID,再操作;名称、前端 URL 和旧缓存不能代替 ID。", "Discover real IDs with repository list, folder list, tag list or asset queries before acting; names, frontend URLs and old caches are not IDs."),
|
|
13
13
|
text(runtime.product, "支持的命令以本 help 为准;读取所选子命令的 --help 获取参数、作用范围和输出形式。", "Available commands are listed here; read the selected subcommand's --help for parameters, scope and output mode."),
|
|
14
|
+
text(runtime.product, "资源库 ID 与组织 ID 不同。团队/企业资料显式传查询到的 repository_id;list/search/upload 省略资源库时默认个人库。素材处理使用详情中的资源链接或下载后的本地文件,再从 tool list 发现处理能力。", "Repository IDs differ from organization IDs. Pass a discovered repository_id for team/enterprise assets; list/search/upload default to the personal repository when omitted. To process an asset, use its resource link or downloaded file and discover processing with tool list."),
|
|
14
15
|
text(runtime.product, "写入结果未确认时先查询实际状态,不重复提交。跨资源库查询、受保护路径上传和永久删除须有用户明确授权。", "Inspect actual state before retrying an unconfirmed write. Cross-repository queries, protected-path uploads and permanent deletion require explicit user authorization."),
|
|
15
16
|
""
|
|
16
17
|
].join("\n"));
|
|
@@ -41,7 +42,7 @@ export function registerDamCommands(program, runtime) {
|
|
|
41
42
|
.option("--parent-id <id>", text(runtime.product, "父文件夹 ID", "parent folder ID"))
|
|
42
43
|
.option("--query <text>", text(runtime.product, "按名称筛选", "filter by name"))
|
|
43
44
|
.option("--page <n>", text(runtime.product, "页码", "page number"), positiveInteger)
|
|
44
|
-
.option("--page-size <
|
|
45
|
+
.option("--page-size <number>", text(runtime.product, "分页大小", "page size"), positiveInteger)
|
|
45
46
|
.option("--json", text(runtime.product, "输出 JSON", "output JSON"));
|
|
46
47
|
bindPreparedAction(folderList, "organization", async (signal) => {
|
|
47
48
|
signal.throwIfAborted();
|
|
@@ -294,6 +295,7 @@ export function registerDamCommands(program, runtime) {
|
|
|
294
295
|
.option("--allow-sensitive-path", text(runtime.product, "明确允许受保护路径", "allow a protected local path"))
|
|
295
296
|
.option("--wait-analysis", text(runtime.product, "等待素材分析结束", "wait for asset analysis"))
|
|
296
297
|
.option("--json", text(runtime.product, "输出 JSON", "output JSON"));
|
|
298
|
+
upload.addHelpText("after", text(runtime.product, "\n<file> 是本地文件路径(不是 file URI);路径含空格时按 shell 规则引用。默认上传个人库根目录 0,标题默认取不含扩展名的文件名;团队位置显式传资源库和文件夹 ID。返回素材详情表示已创建;--wait-analysis 额外等待分析,未知写入先查目标位置,不重复上传。\n", "\n<file> is a local path, not a file URI; quote spaces for the shell. Defaults to personal repository root 0 and a title from the filename without its extension. Specify repository/folder IDs for team destinations. Returned asset details confirm creation; --wait-analysis also waits for analysis. Inspect the destination before repeating an unconfirmed upload.\n"));
|
|
297
299
|
bindPreparedAction(upload, "organization", async (signal) => {
|
|
298
300
|
signal.throwIfAborted();
|
|
299
301
|
const options = upload.opts();
|
|
@@ -364,9 +366,10 @@ function browseCommand(command, runtime) {
|
|
|
364
366
|
.option("--type <type>", text(runtime.product, "素材类型", "asset type"))
|
|
365
367
|
.option("--asset-format <csv>", text(runtime.product, "文件格式,逗号分隔", "comma-separated file formats"))
|
|
366
368
|
.option("--tag-ids <csv>", text(runtime.product, "标签 ID,逗号分隔", "comma-separated tag IDs"))
|
|
367
|
-
.option("--page-size <
|
|
368
|
-
.option("--cursor <id>", text(runtime.product, "
|
|
369
|
-
.option("--json", text(runtime.product, "输出 JSON", "output JSON"))
|
|
369
|
+
.option("--page-size <number>", text(runtime.product, "请求分页大小", "request page size"), positiveInteger)
|
|
370
|
+
.option("--cursor <id>", text(runtime.product, "原样使用上一页 next_cursor,并保持相同筛选", "reuse the previous next_cursor unchanged with the same filters"))
|
|
371
|
+
.option("--json", text(runtime.product, "输出 JSON", "output JSON"))
|
|
372
|
+
.addHelpText("after", text(runtime.product, "\n默认个人资源库,每页 20 条,包含子文件夹;finish=false 时用 next_cursor 继续同范围查询,本页不代表全部结果。空结果不证明其他资源库不存在该素材;按用户指定范围核对资源库和筛选。\n", "\nDefaults to the personal repository, 20 items and inclusion of child folders. When finish=false, continue with next_cursor and unchanged scope; one page is not the entire result. An empty page says nothing about other repositories; check the user's intended repository and filters.\n"));
|
|
370
373
|
}
|
|
371
374
|
function browseInput(command) {
|
|
372
375
|
const options = command.opts();
|
|
@@ -388,15 +391,7 @@ function defined(key, value) {
|
|
|
388
391
|
return value === undefined ? {} : { [key]: value };
|
|
389
392
|
}
|
|
390
393
|
function csv(value) {
|
|
391
|
-
return value?.split(",").map((item) => item.trim())
|
|
392
|
-
}
|
|
393
|
-
function pageSize(value) {
|
|
394
|
-
if (!/^\d+$/u.test(value))
|
|
395
|
-
throw new CliUsageError();
|
|
396
|
-
const parsed = Number(value);
|
|
397
|
-
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 100)
|
|
398
|
-
throw new CliUsageError();
|
|
399
|
-
return parsed;
|
|
394
|
+
return value?.split(",").map((item) => item.trim());
|
|
400
395
|
}
|
|
401
396
|
function positiveInteger(value) {
|
|
402
397
|
if (!/^\d+$/u.test(value))
|
|
@@ -424,7 +419,8 @@ function assetListView(value, product) {
|
|
|
424
419
|
`${text(product, "资源库", "Repositories")}: ${result.repository_ids.join(", ")}`,
|
|
425
420
|
`${text(product, "本批 / 总数", "This batch / total")}: ${result.assets.length} / ${result.total}`,
|
|
426
421
|
result.finish ? text(product, "已到最后一页。", "Last page.")
|
|
427
|
-
: text(product,
|
|
422
|
+
: !result.next_cursor ? text(product, "服务提示还有结果,但未返回可用游标,无法续页。", "More results are indicated, but the service supplied no cursor.")
|
|
423
|
+
: text(product, `还有下一页;保留筛选条件,使用 --cursor ${result.next_cursor ?? "<cursor>"} 查询。`, `More results; keep the same filters and query with --cursor ${result.next_cursor ?? "<cursor>"}.`),
|
|
428
424
|
...(result.assets.length ? [text(product, "ID\t标题\t类型\t格式", "ID\tTitle\tType\tFormat"), ...result.assets.map(assetRow)]
|
|
429
425
|
: [text(product, "暂无素材。", "No assets.")])
|
|
430
426
|
].join("\n");
|
|
@@ -3,31 +3,34 @@ import { jsonOutput, bindAction, bindPreparedAction } from "./action-binding.js"
|
|
|
3
3
|
import { contractSchema } from "../contracts/schema.js";
|
|
4
4
|
import { CliUsageError } from "./errors.js";
|
|
5
5
|
import { productText as text } from "../product/text.js";
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.
|
|
11
|
-
}
|
|
6
|
+
function editorApplyInputSchema() {
|
|
7
|
+
const { $defs, ...actionArray } = contractSchema("editor.apply", "input");
|
|
8
|
+
return {
|
|
9
|
+
type: "object", additionalProperties: false, required: ["actions"], properties: { actions: actionArray },
|
|
10
|
+
$defs: Object.fromEntries(Object.entries($defs)
|
|
11
|
+
.map(([name, definition]) => [name, { ...definition, additionalProperties: true }]))
|
|
12
|
+
};
|
|
13
|
+
}
|
|
12
14
|
export function registerEditorCommands(program, runtime) {
|
|
13
15
|
const editor = program.command("editor")
|
|
14
16
|
.description(text(runtime.product, "连接并操作 AI+ Editor", "Connect to and operate insMind Editor"))
|
|
15
17
|
.helpCommand(false);
|
|
16
18
|
editor.addHelpText("after", [
|
|
17
19
|
"",
|
|
20
|
+
text(runtime.product, "对象是已连接作品中的元素。用户提供附件图片/媒体链接并要求改字、分层、矢量化或其他图片处理时,先从 tool list 发现能力;无需为了这些操作新建 Board。", "This group operates elements in a connected work. For attached images or media links needing text replacement, decomposition, vectorization or other processing, discover tool list first; these operations do not require a new Board."),
|
|
18
21
|
text(runtime.product, "操作一个当前 Session、当前 Page 的直属 Shape 和绑定 Connector;单操作者串行执行。", "Operate one current Session and its Page's direct Shapes and bound Connectors, serially with one operator."),
|
|
19
22
|
text(runtime.product, "元素类型与字段以 editor apply --schema 为准;Schema 查询无需登录或连接 Editor。", "Discover element types and fields with editor apply --schema; no login or Editor connection is required."),
|
|
20
23
|
text(runtime.product, "当前不支持嵌套元素、自由/半绑定 Connector、页面或选择修改;UNSUPPORTED_PAGE_CONTENT 时保留原作品并换用空白或专用 Page。", "Nested elements, free/half-bound Connectors, page and selection changes are unsupported. On UNSUPPORTED_PAGE_CONTENT, preserve the work and use a blank or dedicated Page."),
|
|
21
|
-
text(runtime.product, "流程:connect → snapshot → apply → snapshot/screenshot 复查 → save → disconnect。apply 不代替 save
|
|
24
|
+
text(runtime.product, "流程:connect → snapshot → apply → snapshot/screenshot 复查 → 按用户授权 save → disconnect。apply 不代替 save。只预览/暂不保存时停在预览;用户要求断开就执行 disconnect,断开不隐含保存。", "Workflow: connect → snapshot → apply → review snapshot/screenshot → save as authorized → disconnect. Apply does not replace Save. For preview-only requests stop at preview; on a request to disconnect, execute disconnect without implicitly saving."),
|
|
22
25
|
text(runtime.product, "EDITOR_BUSY 时等待原命令结束;写入超时、取消或断连时,先重新连接同一作品并检查真实状态,不直接重试写入。", "On EDITOR_BUSY, wait for the original command. After a write times out, is cancelled or disconnects, reconnect to the same work and inspect its state before deciding what to do."),
|
|
23
26
|
""
|
|
24
27
|
].join("\n"));
|
|
25
28
|
const connect = leaf(editor.command("connect"))
|
|
26
29
|
.description(text(runtime.product, "打开并连接一个 AI+ Editor 作品", "Open and connect to an Editor work"))
|
|
27
|
-
.argument("[target]", text(runtime.product, "
|
|
30
|
+
.argument("[target]", text(runtime.product, "已有作品的 ID 或完整 URL;留空会新建线上 Board", "existing work ID or full URL; omitting it creates a new production Board"));
|
|
28
31
|
connect.addHelpText("after", [
|
|
29
32
|
"",
|
|
30
|
-
text(runtime.product, "
|
|
33
|
+
text(runtime.product, "继续已有作品时,传数字作品 ID 或完整 HTTP(S) URL。还没有目标就先向用户索取作品链接或 ID。用户要求新建时才省略 target。", "To continue an existing work, pass its numeric ID or supported insMind production Editor URL. If the target is missing, ask the user for the link or ID. Omit target only when the user requests a new Board."),
|
|
31
34
|
text(runtime.product, "会打开浏览器并替换旧 Session;浏览器登录、加载、Board 类型、编辑/保存权限与页面内容检查通过后才成功。CLI 登录不能替代浏览器登录。", "Opens the browser and replaces the old Session. Browser login, loading, Board type, edit/save permission and page-content checks must pass. CLI credentials do not replace browser login."),
|
|
32
35
|
text(runtime.product, "输出 JSON {target},不含连接凭证。连接失败时停止写入,让用户在页面处理登录或权限,再重新连接。", "Returns JSON {target} without connection credentials. On failure, stop writing and let the user resolve browser login or permissions before reconnecting."),
|
|
33
36
|
text(runtime.product, "页面切换作品会断开 Session;EDITOR_NOT_READY、EDITOR_SESSION_NOT_FOUND 或 EDITOR_NOT_CONNECTED 时确认目标后重连,不轮询旧 Session。", "Switching works disconnects the Session. On EDITOR_NOT_READY, EDITOR_SESSION_NOT_FOUND or EDITOR_NOT_CONNECTED, verify the target and reconnect instead of polling the old Session."),
|
|
@@ -46,7 +49,7 @@ export function registerEditorCommands(program, runtime) {
|
|
|
46
49
|
});
|
|
47
50
|
const disconnect = leaf(editor.command("disconnect"))
|
|
48
51
|
.description(text(runtime.product, "断开当前 Editor 连接", "Disconnect the current Editor"));
|
|
49
|
-
disconnect.addHelpText("after", `\n${text(runtime.product, "输出 JSON {disconnected}
|
|
52
|
+
disconnect.addHelpText("after", `\n${text(runtime.product, "输出 JSON {disconnected},解除当前 CLI 会话连接,不保存作品、不关闭浏览器页面。需要保留修改且已获保存授权时先 save;用户只要求断开或明确不保存时直接断开,并说明未保存状态。", "Returns JSON {disconnected}, ending the CLI session without saving the work or closing its browser page. Save first only when persistence is intended and authorized; if the user requests only disconnection or no save, disconnect and state what remains unsaved.")}\n`);
|
|
50
53
|
jsonOutput(disconnect);
|
|
51
54
|
bindAction(disconnect, "none", async (_context, signal) => {
|
|
52
55
|
writeJson(runtime, await runtime.telemetry.stage("editor.disconnect", () => runtime.editor.disconnect({ signal })));
|
|
@@ -70,11 +73,12 @@ export function registerEditorCommands(program, runtime) {
|
|
|
70
73
|
apply.addHelpText("after", [
|
|
71
74
|
"",
|
|
72
75
|
text(runtime.product, "--schema 与 --input 必须且只能选择一个。Schema 为本地契约,不连接 Editor;执行成功输出 JSON {appliedCount}。", "Choose exactly one of --schema and --input. Schema reads the local contract without connecting to Editor; successful execution returns JSON {appliedCount}."),
|
|
76
|
+
text(runtime.product, "先保存完整 JSON,再用 --input request.json 执行;--input - 必须在同一条 shell 命令中经管道或重定向提供完整 JSON,不交互填参。", "Save complete JSON before using --input request.json. With --input -, pipe or redirect complete JSON in the same shell command; input is not an interactive form."),
|
|
73
77
|
text(runtime.product, "输入对象包含 host_application 和按序执行的 actions 数组;类型、必填字段与可选值见 --schema。使用简短语义 ID;create ID 必须唯一,Connector 可引用本批次更早创建的 Shape。", "Input is an object with host_application and an ordered actions array; discover types, required fields and choices with --schema. Use short semantic IDs. Create IDs must be unique; a Connector may reference a Shape created earlier in the batch."),
|
|
74
78
|
text(runtime.product, "update 提交完整元素而非 patch,不改变 id 或 _type。delete 要求 ID 存在;删除 Shape 同时删除绑定的 Connector。", "Update requires the full element, not a patch, without changing id or _type. Delete requires an existing ID; deleting a Shape also deletes its bound Connectors."),
|
|
75
79
|
text(runtime.product, "Shape 的 x/y 为 Page 左上角坐标,w/h 大于 0;数值必须有限。颜色用 #RRGGBB 或 #RRGGBBAA,仅 stroke 可为 null。Connector 用 fromId/toId 表达有方向的 Shape 关系。", "Shape x/y locate its top-left corner in Page coordinates; w/h must exceed zero and numbers must be finite. Colors use #RRGGBB or #RRGGBBAA; only stroke accepts null. Connector fromId/toId express a directed Shape relationship."),
|
|
76
80
|
text(runtime.product, "整批先预检,再在可回滚事务中应用;INVALID_ACTIONS 时修正输入,APPLY_FAILED 时读 Snapshot 确认回滚。EDITOR_ROLLBACK_FAILED 时停止 apply/save,只读检查并报告。", "The batch is checked before one rollback-capable transaction. Correct INVALID_ACTIONS; on APPLY_FAILED read a Snapshot to confirm rollback. On EDITOR_ROLLBACK_FAILED, stop apply/save, inspect read-only and report."),
|
|
77
|
-
text(runtime.product, "成功不表示已保存或视觉正确;读取新 Snapshot
|
|
81
|
+
text(runtime.product, "成功不表示已保存或视觉正确;读取新 Snapshot,涉及布局/文字/连线时查看截图。只预览时交付截图且不 save;需要持久化并已获授权时再显式 save。超时、取消或断连后先检查真实状态,不重复提交。", "Success proves neither persistence nor correct rendering. Read a new Snapshot and view a screenshot for layout/text/connectors. Deliver preview-only requests without save; explicitly save when persistence is intended and authorized. Inspect real state after timeout, cancellation or disconnection instead of resubmitting."),
|
|
78
82
|
""
|
|
79
83
|
].join("\n"));
|
|
80
84
|
jsonOutput(apply);
|
|
@@ -84,7 +88,7 @@ export function registerEditorCommands(program, runtime) {
|
|
|
84
88
|
if (Number(options.schema === true) + Number(options.input !== undefined) !== 1)
|
|
85
89
|
throw new CliUsageError();
|
|
86
90
|
if (options.schema === true) {
|
|
87
|
-
await runtime.telemetry.stage("output", () => { writeJson(runtime, hostSchema(runtime, editorApplyInputSchema)); });
|
|
91
|
+
await runtime.telemetry.stage("output", () => { writeJson(runtime, hostSchema(runtime, editorApplyInputSchema())); });
|
|
88
92
|
return { handled: true };
|
|
89
93
|
}
|
|
90
94
|
const input = editorActions(readHostInput(runtime, await runtime.jsonInput.read(options.input, signal)));
|