@gaoding/cli 1.9.1 → 2.1.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 +5 -0
- package/contracts/operations/credits.get/input.schema.json +9 -0
- package/contracts/operations/credits.get/output.schema.json +107 -0
- package/contracts/operations/credits.usage.get/input.schema.json +18 -0
- package/contracts/operations/credits.usage.get/output.schema.json +53 -0
- package/contracts/operations/credits.usage.list/input.schema.json +32 -0
- package/contracts/operations/credits.usage.list/output.schema.json +144 -0
- package/dist/bin/gd-cli.js +2 -2
- package/dist/bin/insmind-cli.js +2 -2
- package/dist/src/bootstrap/create-cli.js +28 -24
- package/dist/src/bootstrap/create-runtime.js +31 -18
- package/dist/src/bootstrap/run-task-worker.js +2 -1
- package/dist/src/bootstrap/validators.js +7 -2
- package/dist/src/cli/action-binding.js +42 -13
- package/dist/src/cli/agent-commands.js +8 -12
- package/dist/src/cli/credits-command.js +127 -16
- package/dist/src/cli/dam-commands.js +3 -2
- package/dist/src/cli/editor-commands.js +10 -5
- package/dist/src/cli/host-input.js +34 -0
- package/dist/src/cli/model-commands.js +4 -3
- package/dist/src/cli/presenter.js +4 -0
- package/dist/src/cli/tool-commands.js +7 -9
- package/dist/src/cli/update-command.js +24 -1
- package/dist/src/contracts/creation-input.js +20 -0
- package/dist/src/features/agent/creative-protocol.js +12 -14
- package/dist/src/features/agent/use-cases.js +6 -31
- package/dist/src/features/auth/access-policy.js +1 -3
- package/dist/src/features/auth/sso-service.js +6 -4
- package/dist/src/features/auth/use-cases.js +2 -1
- package/dist/src/features/credits/amount.js +51 -0
- package/dist/src/features/credits/response.js +11 -0
- package/dist/src/features/credits/use-cases.js +174 -31
- package/dist/src/features/dam/file-downloader.js +2 -1
- package/dist/src/features/dam/use-cases.js +7 -7
- package/dist/src/features/editor/bridge-client.js +1 -1
- package/dist/src/features/editor/use-cases.js +6 -8
- package/dist/src/features/org/use-cases.js +3 -3
- package/dist/src/features/skill/installer.js +24 -22
- package/dist/src/features/task/store.js +26 -12
- package/dist/src/features/task/use-cases.js +97 -82
- package/dist/src/features/tool/canvas-models.js +21 -4
- package/dist/src/features/tool/canvas-tool-adapter.js +29 -20
- package/dist/src/features/tool/canvas-video.js +2 -4
- package/dist/src/features/tool/dynamic-schema.js +29 -64
- package/dist/src/features/tool/mns-catalog-adapter.js +9 -2
- package/dist/src/features/tool/scene-catalog-adapter.js +0 -1
- package/dist/src/features/tool/tool-api-adapter.js +2 -2
- package/dist/src/features/tool/use-cases.js +24 -35
- package/dist/src/features/update/check-schema.js +17 -0
- package/dist/src/features/update/host-receipt.js +30 -0
- package/dist/src/features/update/notice-output.js +30 -0
- package/dist/src/features/update/update-lock.js +80 -0
- package/dist/src/features/update/update-notification.js +129 -240
- package/dist/src/platform/json-input.js +1 -1
- package/dist/src/platform/safe-upload-file.js +6 -0
- package/dist/src/platform/signature.js +3 -1
- package/dist/src/platform/signed-http-transport.js +34 -32
- package/dist/src/telemetry/host-diagnostics.js +2 -2
- package/dist/src/telemetry/invocation.js +87 -24
- package/dist/src/telemetry/process-errors.js +36 -3
- package/dist/src/telemetry/sls-sink.js +7 -10
- package/package.json +4 -4
- package/skills/gd-cli/SKILL.md +2 -0
- package/skills/gd-cli/references/editor.md +1 -1
- package/skills/gd-cli/references/generation-constraints.md +3 -1
- package/skills/gd-cli/references/tool.md +2 -3
- package/skills/gd-cli/references/update.md +6 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { cleanDiagnostic, errorEvidence } from "./sanitize.js";
|
|
2
2
|
import { isInterruption } from "../platform/interruption.js";
|
|
3
3
|
import { safeFailureSummary } from "./failure-summary.js";
|
|
4
|
-
|
|
4
|
+
export function hostName(value) {
|
|
5
|
+
return typeof value === "string" && value.trim() ? value.trim().slice(0, 128) : undefined;
|
|
6
|
+
}
|
|
5
7
|
export function hostTelemetryContext(env) {
|
|
6
8
|
return {
|
|
7
|
-
|
|
8
|
-
? { host_application: env.CLI_HOST_APPLICATION } : {}),
|
|
9
|
+
host_application: hostName(env.CLI_HOST_APPLICATION) ?? "unknown",
|
|
9
10
|
...(["auth_status", "version_check"].includes(env.CLI_INVOCATION_PURPOSE ?? "")
|
|
10
11
|
? { invocation_purpose: env.CLI_INVOCATION_PURPOSE } : {}),
|
|
11
12
|
...(/^[a-f0-9]{32}$/u.test(env.CLI_HOST_INVOCATION_ID ?? "") ? { host_invocation_id: env.CLI_HOST_INVOCATION_ID } : {}),
|
|
@@ -25,22 +26,30 @@ export function createTelemetryInvocation(options) {
|
|
|
25
26
|
const traceId = options.traceIdFactory();
|
|
26
27
|
const startedAt = options.startedAt ?? options.now();
|
|
27
28
|
let definition;
|
|
29
|
+
let issued = false;
|
|
30
|
+
let nextStep = "request_sent";
|
|
28
31
|
let finished = false;
|
|
29
32
|
let signal;
|
|
30
33
|
let sequence = 0;
|
|
31
34
|
const context = {};
|
|
32
35
|
const events = [];
|
|
36
|
+
const steps = new Map();
|
|
33
37
|
const published = new Set();
|
|
34
38
|
const failures = [];
|
|
35
|
-
function
|
|
39
|
+
function identity() {
|
|
36
40
|
const mode = definition?.mode?.();
|
|
37
|
-
|
|
41
|
+
const creation = mode === "execute" && (definition?.operation === "agent.send" || definition?.operation === "tool.call");
|
|
42
|
+
return { host_application: context.host_application ?? "unknown", schema_version: "6", started_at_ms: startedAt, command_kind: creation ? "creation" : "technical", cli_name: options.cliName ?? "gd-cli",
|
|
38
43
|
env: options.env ?? "production", process_role: options.processRole ?? "cli",
|
|
39
|
-
trace_id: traceId,
|
|
44
|
+
trace_id: traceId,
|
|
40
45
|
operation: definition?.operation ?? "unknown", ...(mode ? { mode } : {}),
|
|
41
46
|
cli_version: options.cliVersion, os: options.runtime.os, arch: options.runtime.arch,
|
|
42
47
|
node_major: options.runtime.nodeMajor };
|
|
43
48
|
}
|
|
49
|
+
function base() {
|
|
50
|
+
const { parameters: _input, ...diagnostics } = context;
|
|
51
|
+
return { ...diagnostics, ...identity(), record_seq: ++sequence, occurred_at_ms: options.now() };
|
|
52
|
+
}
|
|
44
53
|
function classify(error) {
|
|
45
54
|
return isInterruption(error, signal) ? { outcome: "interrupted" } : options.classifyError(error);
|
|
46
55
|
}
|
|
@@ -66,17 +75,35 @@ export function createTelemetryInvocation(options) {
|
|
|
66
75
|
}
|
|
67
76
|
function remember(event) {
|
|
68
77
|
const safe = cleanDiagnostic(event);
|
|
78
|
+
if (safe.event_name === "command_step") {
|
|
79
|
+
const key = `${safe.trace_id}/${safe.step}`;
|
|
80
|
+
const first = steps.get(key);
|
|
81
|
+
if (first)
|
|
82
|
+
return first;
|
|
83
|
+
steps.set(key, safe);
|
|
84
|
+
}
|
|
69
85
|
events.push(safe);
|
|
70
86
|
return safe;
|
|
71
87
|
}
|
|
88
|
+
function observeStep(step) {
|
|
89
|
+
if (step === "request_sent")
|
|
90
|
+
nextStep = "result_received";
|
|
91
|
+
if (step === "result_received")
|
|
92
|
+
nextStep = "delivered";
|
|
93
|
+
if (step === "delivered")
|
|
94
|
+
nextStep = undefined;
|
|
95
|
+
}
|
|
72
96
|
async function publish(event) {
|
|
73
97
|
if (!options.onEvent)
|
|
74
|
-
return;
|
|
98
|
+
return false;
|
|
75
99
|
try {
|
|
76
|
-
if (await options.onEvent(event) !== false)
|
|
100
|
+
if (await options.onEvent(event) !== false) {
|
|
77
101
|
published.add(event);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
78
104
|
}
|
|
79
105
|
catch { /* Logging cannot fail the operation. */ }
|
|
106
|
+
return false;
|
|
80
107
|
}
|
|
81
108
|
return {
|
|
82
109
|
traceId,
|
|
@@ -86,7 +113,19 @@ export function createTelemetryInvocation(options) {
|
|
|
86
113
|
&& definition.mode?.() === "execute";
|
|
87
114
|
return `00-${traceId}-${options.spanIdFactory()}-${paid ? "01" : "00"}`;
|
|
88
115
|
},
|
|
89
|
-
select(next) {
|
|
116
|
+
select(next) { if (!issued)
|
|
117
|
+
definition = next; },
|
|
118
|
+
async issue(next) {
|
|
119
|
+
if (issued)
|
|
120
|
+
return;
|
|
121
|
+
issued = true;
|
|
122
|
+
definition = next;
|
|
123
|
+
await publish(remember({ ...base(), occurred_at_ms: startedAt, event_name: "command_step", step: "issued", outcome: "success" }));
|
|
124
|
+
},
|
|
125
|
+
observeHost(value) {
|
|
126
|
+
if (!context.host_application || context.host_application === "unknown")
|
|
127
|
+
context.host_application = hostName(value) ?? "unknown";
|
|
128
|
+
},
|
|
90
129
|
useSignal(next) { signal = next; },
|
|
91
130
|
annotate(annotation) {
|
|
92
131
|
for (const [key, value] of Object.entries(annotation)) {
|
|
@@ -105,10 +144,23 @@ export function createTelemetryInvocation(options) {
|
|
|
105
144
|
}
|
|
106
145
|
},
|
|
107
146
|
creationContext() {
|
|
108
|
-
|
|
109
|
-
|
|
147
|
+
// Background work and later queries retain the originating invocation's dimensions.
|
|
148
|
+
const snapshot = identity();
|
|
149
|
+
const keys = ["host_invocation_id", "host_connector_version", "installation_owner", "invocation_purpose",
|
|
150
|
+
"account_id", "organization_id", "tool_name", "model_id", "content_id", "task_id", "dify_task_id",
|
|
151
|
+
"cli_task_id", "execution_mode", "parameters"];
|
|
152
|
+
for (const key of keys) {
|
|
153
|
+
if (context[key] !== undefined)
|
|
154
|
+
Object.assign(snapshot, { [key]: context[key] });
|
|
155
|
+
}
|
|
156
|
+
return cleanDiagnostic(snapshot);
|
|
157
|
+
},
|
|
158
|
+
observeStep,
|
|
159
|
+
async emit(event) {
|
|
160
|
+
if (event.trace_id === traceId || event.trace_id === context.creation_trace_id)
|
|
161
|
+
observeStep(event.step);
|
|
162
|
+
return publish(remember(event));
|
|
110
163
|
},
|
|
111
|
-
async emit(event) { await publish(remember(event)); },
|
|
112
164
|
taskFailure(error) {
|
|
113
165
|
const c = classify(error);
|
|
114
166
|
const summary = { ...context.diagnostic_summary, ...c.diagnosticSummary };
|
|
@@ -145,18 +197,29 @@ export function createTelemetryInvocation(options) {
|
|
|
145
197
|
if (finished || !definition)
|
|
146
198
|
return [];
|
|
147
199
|
finished = true;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
...(completion.
|
|
158
|
-
...(
|
|
159
|
-
|
|
200
|
+
const last = base();
|
|
201
|
+
if (completion.outcome === "success" && issued && last.command_kind === "technical") {
|
|
202
|
+
remember({ ...last, event_name: "command_step", step: "delivered", outcome: "success",
|
|
203
|
+
...(context.parameters ? { parameters: context.parameters } : {}) });
|
|
204
|
+
}
|
|
205
|
+
else if (completion.outcome !== "success" || !issued) {
|
|
206
|
+
const failedStep = last.command_kind === "technical" ? "delivered" : nextStep;
|
|
207
|
+
const stage = completion.outcome === "success" ? "process" : classify(completion.error).failureStage ?? failureStage(completion.error) ?? "command";
|
|
208
|
+
remember({ ...last, event_name: "stage_finished", stage, outcome: completion.outcome,
|
|
209
|
+
...(completion.outcome !== "success" && failedStep ? { failed_step: failedStep } : {}),
|
|
210
|
+
...(context.parameters && (!issued || last.command_kind === "technical") ? { parameters: context.parameters } : {}),
|
|
211
|
+
duration_ms: Math.max(0, options.now() - startedAt),
|
|
212
|
+
...(completion.outcome === "success" ? {} : {
|
|
213
|
+
failure_stage: classify(completion.error).failureStage ?? failureStage(completion.error) ?? "unknown"
|
|
214
|
+
}),
|
|
215
|
+
...(completion.outcome === "failure" ? errorFields(completion.error) : completion.outcome === "interrupted" && completion.error !== undefined ? errorEvidence(completion.error) : {}),
|
|
216
|
+
...(completion.outcome === "failure" ? {
|
|
217
|
+
error_code: completion.errorCode, error_message: completion.errorMessage,
|
|
218
|
+
...(completion.httpStatus === undefined ? {} : { http_status: completion.httpStatus }),
|
|
219
|
+
...(completion.remoteErrorCode === undefined ? {} : { remote_error_code: completion.remoteErrorCode }),
|
|
220
|
+
...(completion.remoteErrorBody === undefined ? {} : { remote_error_body: completion.remoteErrorBody })
|
|
221
|
+
} : {}) });
|
|
222
|
+
}
|
|
160
223
|
return events.filter(event => !published.has(event));
|
|
161
224
|
}
|
|
162
225
|
};
|
|
@@ -1,13 +1,43 @@
|
|
|
1
1
|
import { classifyTelemetryError, mapCliError } from "../cli/errors.js";
|
|
2
2
|
import { isInterruption } from "../platform/interruption.js";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
|
-
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { gaodingProduct, insmindProduct } from "../product/config.js";
|
|
9
9
|
import { createTelemetryInvocation, hostTelemetryContext } from "./invocation.js";
|
|
10
10
|
import { createSlsTelemetrySink } from "./sls-sink.js";
|
|
11
|
+
// The CLI module graph may not be loadable. Use packaged operation names only,
|
|
12
|
+
// so a user-supplied positional argument can never become an SLS operation name.
|
|
13
|
+
async function bootstrapDefinition(argv) {
|
|
14
|
+
const names = new Set(["agent.send", "tool.call", "editor.apply", "auth.login", "auth.logout", "org.switch", "credits", "update"]);
|
|
15
|
+
const contracts = new URL("../../../contracts/operations/", import.meta.url);
|
|
16
|
+
for (const name of await readdir(contracts).catch(() => []))
|
|
17
|
+
names.add(name);
|
|
18
|
+
const path = [];
|
|
19
|
+
let mode = "execute";
|
|
20
|
+
for (let i = 0; i < argv.length; i++) {
|
|
21
|
+
const token = argv[i];
|
|
22
|
+
if (token === "--")
|
|
23
|
+
break;
|
|
24
|
+
if (token === "--input" || token === "--locale") {
|
|
25
|
+
i++;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (token === "--help" || token === "-h")
|
|
29
|
+
mode = "help";
|
|
30
|
+
else if (token === "--version" || token === "-V")
|
|
31
|
+
mode = "version";
|
|
32
|
+
else if (token === "--schema" && mode === "execute")
|
|
33
|
+
mode = "schema";
|
|
34
|
+
else if (!token.startsWith("-") && !names.has(path.join(".")) && path.length < 3)
|
|
35
|
+
path.push(token);
|
|
36
|
+
}
|
|
37
|
+
const name = path.join(".");
|
|
38
|
+
const operation = mode === "version" ? "version" : names.has(name) ? name : !name && mode === "help" ? "help" : "bootstrap";
|
|
39
|
+
return { operation, mode: () => mode };
|
|
40
|
+
}
|
|
11
41
|
/** Independent fallback for entrypoints which cannot construct the full runtime. */
|
|
12
42
|
export async function reportProcessError(error, options) {
|
|
13
43
|
try {
|
|
@@ -34,8 +64,11 @@ export async function reportProcessError(error, options) {
|
|
|
34
64
|
traceIdFactory: () => options.traceId ?? randomBytes(16).toString("hex"), spanIdFactory: () => randomBytes(8).toString("hex"),
|
|
35
65
|
runtime: { os: process.platform, arch: process.arch, nodeMajor: Number(process.versions.node.split(".")[0]) },
|
|
36
66
|
classifyError: () => classification });
|
|
37
|
-
|
|
67
|
+
const definition = options.argv ? await bootstrapDefinition(options.argv) : { operation: options.operation };
|
|
68
|
+
telemetry.select(definition);
|
|
38
69
|
telemetry.annotate(hostTelemetryContext(process.env));
|
|
70
|
+
if ((options.processRole ?? "cli") === "cli")
|
|
71
|
+
await telemetry.issue(definition);
|
|
39
72
|
const events = telemetry.finish(mapped.kind === "interrupted" ? { outcome: "interrupted", error } : {
|
|
40
73
|
outcome: "failure", error, errorCode: mapped.failure.code, errorMessage: mapped.failure.message,
|
|
41
74
|
...(classification.httpStatus === undefined ? {} : { httpStatus: classification.httpStatus }),
|
|
@@ -43,7 +76,7 @@ export async function reportProcessError(error, options) {
|
|
|
43
76
|
...(classification.remoteErrorBody === undefined ? {} : { remoteErrorBody: classification.remoteErrorBody })
|
|
44
77
|
});
|
|
45
78
|
const sink = createSlsTelemetrySink({ fetch: globalThis.fetch, trackingUrl: options.trackingUrl ?? product.telemetryUrl,
|
|
46
|
-
directory: join(options.homeDirectory ?? homedir(), product.stateDirectory, "telemetry") });
|
|
79
|
+
directory: join(options.homeDirectory ?? homedir(), product.stateDirectory, "telemetry", "v6") });
|
|
47
80
|
// Automated process tests persist to their temporary home, without external traffic.
|
|
48
81
|
if (process.env.NODE_ENV === "test" || process.env.VITEST)
|
|
49
82
|
await sink.enqueue?.(events);
|
|
@@ -9,11 +9,9 @@ const TTL = 7 * 86_400_000;
|
|
|
9
9
|
const CAPACITY = 10 * 1024 * 1024;
|
|
10
10
|
const BUDGET = 2_000;
|
|
11
11
|
export function eventKey(event) {
|
|
12
|
-
const key = event.event_name === "
|
|
13
|
-
? [event.cli_name, event.env, event.
|
|
14
|
-
: event.
|
|
15
|
-
? [event.cli_name, event.env, event.cli_task_id, event.event_name]
|
|
16
|
-
: [event.cli_name, event.env, event.trace_id, event.process_role, Number(event.record_seq)];
|
|
12
|
+
const key = event.event_name === "command_step"
|
|
13
|
+
? [event.cli_name, event.env, event.trace_id, event.step]
|
|
14
|
+
: [event.cli_name, event.env, event.trace_id, event.process_role, Number(event.record_seq)];
|
|
17
15
|
return createHash("sha256").update(JSON.stringify(key)).digest("hex");
|
|
18
16
|
}
|
|
19
17
|
export function wireEvent(event) {
|
|
@@ -25,7 +23,7 @@ export function wireEvent(event) {
|
|
|
25
23
|
else
|
|
26
24
|
delete safe.diagnostic_summary;
|
|
27
25
|
}
|
|
28
|
-
const wire = {};
|
|
26
|
+
const wire = { event_id: eventKey(safe) };
|
|
29
27
|
for (const [key, value] of Object.entries(safe)) {
|
|
30
28
|
if (value !== undefined)
|
|
31
29
|
wire[key] = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
@@ -100,8 +98,7 @@ export function createSlsTelemetrySink(options) {
|
|
|
100
98
|
const value = rawStatus;
|
|
101
99
|
const count = (key) => typeof value[key] === "number" && Number.isSafeInteger(value[key]) && value[key] >= 0 ? value[key] : 0;
|
|
102
100
|
status = { count: count("count"), delivery_failures: count("delivery_failures"),
|
|
103
|
-
...(["interrupted_write", "corrupt", "expired", "capacity", "http_rejected"].includes(String(value.reason)) ? { reason: value.reason }
|
|
104
|
-
: /^http_4\d\d$/u.test(String(value.reason)) ? { reason: "http_rejected" } : {}),
|
|
101
|
+
...(["interrupted_write", "corrupt", "expired", "capacity", "http_rejected"].includes(String(value.reason)) ? { reason: value.reason } : {}),
|
|
105
102
|
...(["accepted", "http_rejected", "http_retryable", "network_error"].includes(String(value.result)) ? { result: value.result } : {}),
|
|
106
103
|
...(typeof value.http_status === "number" && value.http_status >= 100 && value.http_status <= 599 ? { http_status: value.http_status } : {}),
|
|
107
104
|
...(count("first_at_ms") ? { first_at_ms: count("first_at_ms") } : {}),
|
|
@@ -121,7 +118,7 @@ export function createSlsTelemetrySink(options) {
|
|
|
121
118
|
const raw = await readFile(join(options.directory, name), "utf8");
|
|
122
119
|
try {
|
|
123
120
|
const entry = JSON.parse(raw);
|
|
124
|
-
if (!Number.isFinite(entry.queuedAt) || !entry.event || eventKey(entry.event) !== name.slice(0, -5))
|
|
121
|
+
if (entry.event?.schema_version !== "6" || !Number.isFinite(entry.queuedAt) || !entry.event || eventKey(entry.event) !== name.slice(0, -5))
|
|
125
122
|
throw new Error();
|
|
126
123
|
entries.set(name.slice(0, -5), entry);
|
|
127
124
|
}
|
|
@@ -160,7 +157,7 @@ export function createSlsTelemetrySink(options) {
|
|
|
160
157
|
}
|
|
161
158
|
}
|
|
162
159
|
let size = [...entries.values()].reduce((sum, e) => sum + Buffer.byteLength(JSON.stringify(e)), 0);
|
|
163
|
-
const priority = (e) => e.event.event_name === "
|
|
160
|
+
const priority = (e) => e.event.event_name === "command_step" ? 2
|
|
164
161
|
: e.event.event_name === "host_diagnostic" || "outcome" in e.event && e.event.outcome !== "success" ? 1 : 0;
|
|
165
162
|
for (const [id, entry] of [...entries].sort((a, b) => priority(a[1]) - priority(b[1]) || a[1].queuedAt - b[1].queuedAt)) {
|
|
166
163
|
checkBudget(deadline);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaoding/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Gaoding command-line interface for agents and people.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"vitest": "4.1.10"
|
|
58
58
|
},
|
|
59
59
|
"gaodingRelease": {
|
|
60
|
-
"sourceCommit": "
|
|
61
|
-
"pipelineId": "
|
|
62
|
-
"pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/
|
|
60
|
+
"sourceCommit": "5a8acfd84d3ce5ed311d5442c66ebc6b62c9f680",
|
|
61
|
+
"pipelineId": "241803",
|
|
62
|
+
"pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/241803"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/skills/gd-cli/SKILL.md
CHANGED
|
@@ -7,7 +7,9 @@ description: Use when creating images, videos or text with GD CLI, operating the
|
|
|
7
7
|
|
|
8
8
|
## 按需发现当前能力
|
|
9
9
|
|
|
10
|
+
- 调用 `agent send`、`tool call`、`editor apply` 时,在输入 JSON 顶层填写 `host_application`。值为发起命令的实际应用名,例如 `workbuddy`、`qwenwork`、`trae`;用户直接在终端运行时填 `terminal`。
|
|
10
11
|
- 首次使用时确认 `gd-cli --version`;不确定入口时读 `gd-cli --help`,沿相关命令组选择命令,执行前读其 `--help`。本 Skill 的示例不代表完整能力清单。
|
|
12
|
+
- 用户前台使用时,把可用升级提醒随本次结果转述给用户,一小时最多一次。只读取标准输出的宿主见下方「更新」。
|
|
11
13
|
- 结构化输入先读取命令公开支持的 `--schema`;模型、参数选项、价格与资源 ID 由对应目录或详情查询取得,不从旧示例猜值。发现不支持或查询失败时说明缺口,不静默替换用户明确约束。
|
|
12
14
|
- 同一会话可复用同一路径/版本的 help 和静态 Schema;CLI 变化后重查。动态信息在本次任务选能力或报价时查询,身份/组织变化或明确不匹配时刷新相关结果,不全量扫描无关目录。
|
|
13
15
|
- 发现只说明当前实装 CLI 的能力,不等于升级,也不授予生成、写入或安装权限;未知结果的恢复按错误处理指引执行。
|
|
@@ -20,7 +20,7 @@ gd-cli editor apply --schema
|
|
|
20
20
|
|
|
21
21
|
1. 查询 `gd-cli editor connect --help`,按用户目标选择 `gd-cli editor connect [target]`。不为恢复已有作品而省略目标新建 Board。只有浏览器登录、加载、编辑/保存权限和内容检查通过后才成功;连接失败时停止作图。
|
|
22
22
|
2. 读取 `gd-cli editor snapshot`。以最新 Snapshot 中的完整元素为基础,只改变目标字段;Update 提交完整元素,不能提交 patch。
|
|
23
|
-
3. 根据 Schema 和 Snapshot
|
|
23
|
+
3. 根据 Schema 和 Snapshot 构造包含 `host_application` 和有序 `actions` 数组的对象,执行 `gd-cli editor apply --input actions.json`,或用 `--input -` 从 stdin 读取。使用简短语义 ID;Connector 的方向和目标必须符合业务关系。
|
|
24
24
|
4. 每次 Apply 后重新读取 Snapshot。涉及布局、文字或 Connector 时,执行 `gd-cli editor screenshot --json` 并打开返回的绝对 `path` 对应的实际 PNG。文件存在或 Action 已提交都不代表渲染正确。
|
|
25
25
|
5. 结构和视觉复查均通过后,执行 `gd-cli editor save --json`,继续等待原命令完成,不因短暂无输出而中断或并发操作。只有保存成功才可声明作品已保存;把返回的 `workId` 和公开 `url` 交给用户,并保留 URL 中的环境参数。等待时限查 `editor save --help`。
|
|
26
26
|
6. 保存成功后执行 `gd-cli editor disconnect`;断开连接不代替保存。
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
```json
|
|
8
8
|
{
|
|
9
|
+
"host_application": "<invoking application>",
|
|
9
10
|
"message": {
|
|
10
11
|
"parts": [
|
|
11
12
|
{ "text": "<用户要求>" },
|
|
@@ -22,10 +23,11 @@
|
|
|
22
23
|
}
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
`arguments` 可以在不指定 `model` 时单独提交,由服务端 Agent 选择 Model。指定 `model` 时,CLI
|
|
26
|
+
`arguments` 可以在不指定 `model` 时单独提交,由服务端 Agent 选择 Model。指定 `model` 时,CLI 转发显式控制参数,将已知编辑模型别名映射成服务字段。Prompt 使用 Text Part,素材使用独立 URL Part,不放入 `arguments`。素材保持消息 Part 的输入顺序;`metadata.role` 可标记 `reference`、`first_frame` 或 `last_frame`,不注入“首帧”或“尾帧”文本。例如:
|
|
26
27
|
|
|
27
28
|
```json
|
|
28
29
|
{
|
|
30
|
+
"host_application": "<invoking application>",
|
|
29
31
|
"message": {
|
|
30
32
|
"parts": [
|
|
31
33
|
{ "text": "生成一段转场视频" },
|
|
@@ -12,14 +12,13 @@ gd-cli tool call <tool> --input request.json --async
|
|
|
12
12
|
gd-cli task get <taskId>
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
`tool
|
|
16
|
-
|
|
17
|
-
按所选 Model detail 构造 JSON:提供全部 required 字段;SELECT 参数使用 `options[].value`;required 字段带 default 且用户未指定时,在输入中显式使用该 default。存在 width、height、resolution 等专用字段时,将用户要求写入对应结构化参数,不要只写在 prompt 中。`tool call <tool> --schema` 按 model 选择对应的必填字段、参数和范围;`model get` 补充 step、参数默认值及 `usageDescription` 中的组合要求。固定 JSON 命令可显式添加 `--json`。
|
|
15
|
+
用 `gd-cli tool call <tool> --schema` 查工具输入,用 `model get` 看选定模型的价格和预计耗时。`required` 标出模型所需输入,`default` 标出服务默认值;用户未指定有默认值的字段时可以省略。选择目录列出的选项时用 `options[].value`。尺寸和分辨率写进 `width`、`height`、`resolution` 等字段,用户显式指定的值原样发送。`usageDescription` 描述跨字段规则,例如视频 mode 对首尾帧或素材字段的要求。
|
|
18
16
|
|
|
19
17
|
务必将 `model get <model> --tool <tool>` 返回的 `model` 原样放在请求 JSON 的顶层 `model` 字段(即运行时的 `arguments.model`),与所选 Model 的参数字段并列;不要只复制 `parameters`。例如:
|
|
20
18
|
|
|
21
19
|
```json
|
|
22
20
|
{
|
|
21
|
+
"host_application": "<invoking application>",
|
|
23
22
|
"model": "<model>",
|
|
24
23
|
"prompt": "<required prompt>",
|
|
25
24
|
"<parameter>": "<value>"
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# 更新
|
|
2
2
|
|
|
3
|
+
用户在会话中运行任何命令,都可能收到升级提示。把这句话附在本次业务结果后。后台状态或版本探测不负责提醒。
|
|
4
|
+
|
|
5
|
+
- 如果连接器帮助提供 `--with-notices`,在前台业务命令前加这个选项,从返回对象的 `result` 提取业务结果,逐条向用户转述 `notices`。探测、Schema 和需要原始 JSON 的脚本使用原入口。
|
|
6
|
+
- 只能读取业务 stdout 时,首次前台使用或上次检查满一小时后的下一次使用,先从 `gd-cli update --help` 发现 `check`。若支持,按实际宿主设置环境变量 `CLI_HOST_APPLICATION`(如 `workbuddy`),执行 `gd-cli update check --json --for-display`,只转述返回的 `notice`。普通 `update check --json` 只查看版本,不占展示次数。
|
|
7
|
+
- 旧 CLI 没有 `check` 时,仅在明确复用了用户的 npm 全局安装、能读到真实 CLI 版本时,可用 `npm view @gaoding/cli dist-tags.latest` 只读比对 SemVer。千问的 `--version` 是连接器版本,底层 CLI 版本见其帮助。无法确认安装归属就跳过手动升级提醒。查询失败继续用户任务。
|
|
8
|
+
|
|
3
9
|
用户要求升级或同意处理兼容性问题时,先查询当前安装渠道的更新语义,再执行更新:
|
|
4
10
|
|
|
5
11
|
```bash
|