@gaoding/cli 1.7.0 → 1.8.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/dist/src/bootstrap/create-cli.js +3 -1
- package/dist/src/bootstrap/create-runtime.js +24 -12
- package/dist/src/bootstrap/run-task-worker.js +2 -2
- package/dist/src/bootstrap/validators.js +1 -1
- package/dist/src/cli/action-binding.js +3 -0
- package/dist/src/cli/errors.js +77 -24
- package/dist/src/cli/model-commands.js +1 -1
- package/dist/src/cli/observed-errors.js +118 -0
- package/dist/src/cli/task-commands.js +1 -1
- package/dist/src/cli/tool-commands.js +1 -1
- package/dist/src/features/auth/sso-service.js +13 -4
- package/dist/src/features/dam/dam-api-adapter.js +1 -0
- package/dist/src/features/dam/file-downloader.js +23 -2
- package/dist/src/features/task/creation-refusal.js +14 -10
- package/dist/src/features/task/store.js +10 -4
- package/dist/src/features/task/use-cases.js +45 -16
- package/dist/src/features/tool/dynamic-schema.js +4 -1
- package/dist/src/features/tool/tool-api-adapter.js +42 -33
- package/dist/src/features/update/update-service.js +4 -2
- package/dist/src/platform/file-lock.js +12 -0
- package/dist/src/platform/local-json-file.js +19 -5
- package/dist/src/platform/remote-error-evidence.js +13 -1
- package/dist/src/platform/remote-protocol.js +1 -1
- package/dist/src/platform/safe-upload-file.js +18 -10
- package/dist/src/platform/schema-issues.js +47 -2
- package/dist/src/platform/signed-http-transport.js +1 -1
- package/dist/src/platform/text-output.js +17 -4
- package/dist/src/telemetry/failure-summary.js +18 -0
- package/package.json +4 -4
- package/skills/gd-cli/references/errors.md +3 -1
- package/skills/gd-cli/references/tool.md +1 -1
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { Writable } from "node:stream";
|
|
2
|
+
export class OutputStreamError extends Error {
|
|
3
|
+
outputStream;
|
|
4
|
+
constructor(outputStream, cause) {
|
|
5
|
+
super("结果未能完整返回。", { cause });
|
|
6
|
+
this.outputStream = outputStream;
|
|
7
|
+
this.name = "OutputStreamError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
2
10
|
/** Writes remain synchronous for command presenters; flush acknowledges delivery. */
|
|
3
|
-
export function createTextOutput(stream) {
|
|
11
|
+
export function createTextOutput(stream, outputStream = "stdout") {
|
|
4
12
|
if (!(stream instanceof Writable))
|
|
5
13
|
return {
|
|
6
|
-
write: text => {
|
|
14
|
+
write: text => { try {
|
|
15
|
+
stream.write(text);
|
|
16
|
+
}
|
|
17
|
+
catch (cause) {
|
|
18
|
+
throw new OutputStreamError(outputStream, cause);
|
|
19
|
+
} }, flush: async () => { }
|
|
7
20
|
};
|
|
8
21
|
const pending = new Set();
|
|
9
22
|
let failure;
|
|
@@ -11,7 +24,7 @@ export function createTextOutput(stream) {
|
|
|
11
24
|
return {
|
|
12
25
|
write(text) {
|
|
13
26
|
if (failure)
|
|
14
|
-
throw failure;
|
|
27
|
+
throw new OutputStreamError(outputStream, failure);
|
|
15
28
|
const writing = new Promise(resolve => {
|
|
16
29
|
try {
|
|
17
30
|
stream.write(text, error => { failure ??= error ?? undefined; resolve(); });
|
|
@@ -27,7 +40,7 @@ export function createTextOutput(stream) {
|
|
|
27
40
|
async flush() {
|
|
28
41
|
await Promise.all(pending);
|
|
29
42
|
if (failure)
|
|
30
|
-
throw failure;
|
|
43
|
+
throw new OutputStreamError(outputStream, failure);
|
|
31
44
|
}
|
|
32
45
|
};
|
|
33
46
|
}
|
|
@@ -2,6 +2,11 @@ const flags = new Set(["bodyUsedAtReceipt", "bodyLockedAtReceipt", "bodyUsedBefo
|
|
|
2
2
|
"bodyLockedBeforeRead", "reusedResponse", "contextIdPresent", "streamHadBytes"]);
|
|
3
3
|
const counts = new Set(["messageCount", "invalidMessageCount", "systemErrorCount", "publicPartCount",
|
|
4
4
|
"streamPayloadCount", "streamJsonValueCount"]);
|
|
5
|
+
const localFileSteps = new Set(["directory_create", "directory_permissions", "directory_read", "stat", "parse", "validate", "open", "file_permissions", "read", "write", "sync", "close", "rename", "unlink"]);
|
|
6
|
+
const inputReasons = new Set(["path_restricted", "not_regular_file", "format_missing", "media_type_mismatch", "file_read_failed",
|
|
7
|
+
"json_read", "json_parse", "schema_validation", "invalid_task_id", "command_arguments", "model_required", "model_not_found",
|
|
8
|
+
"model_tool_mismatch", "model_parameters", "tool_not_found", "invalid_asset_url", "commander.unknownOption",
|
|
9
|
+
"commander.unknownCommand", "commander.missingArgument", "commander.excessArguments", "commander.help"]);
|
|
5
10
|
/** Fixed diagnostic facts, never arbitrary response fields or error messages. */
|
|
6
11
|
export function safeFailureSummary(value) {
|
|
7
12
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
@@ -12,6 +17,19 @@ export function safeFailureSummary(value) {
|
|
|
12
17
|
result[key] = field;
|
|
13
18
|
if (counts.has(key) && typeof field === "number" && Number.isSafeInteger(field) && field >= 0 && field <= 100_000)
|
|
14
19
|
result[key] = field;
|
|
20
|
+
if (key === "inputReason" && typeof field === "string" && inputReasons.has(field))
|
|
21
|
+
result[key] = field;
|
|
22
|
+
if (key === "ssoPhase" && (field === "authorize" || field === "token"))
|
|
23
|
+
result[key] = field;
|
|
24
|
+
if (key === "outputStream" && (field === "stdout" || field === "stderr"))
|
|
25
|
+
result[key] = field;
|
|
26
|
+
if (key === "localFileOperation" && (field === "read" || field === "write" || field === "remove" || field === "list"))
|
|
27
|
+
result[key] = field;
|
|
28
|
+
if (key === "localFileStep" && typeof field === "string" && localFileSteps.has(field))
|
|
29
|
+
result[key] = field;
|
|
30
|
+
if (key === "ssoInvalidFields" && typeof field === "string"
|
|
31
|
+
&& /^(?:authorize_code|device_code|expires_in|interval|ak|sk|expires_at|scope)(?:,(?:authorize_code|device_code|expires_in|interval|ak|sk|expires_at|scope))*$/u.test(field))
|
|
32
|
+
result[key] = field;
|
|
15
33
|
if (key === "systemCode" && typeof field === "string"
|
|
16
34
|
&& /^(?:E[A-Z0-9_]{1,40}|UND_ERR_[A-Z0-9_]{1,40}|LOCAL_LOCK_TIMEOUT)$/u.test(field))
|
|
17
35
|
result[key] = field;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaoding/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Gaoding command-line interface for agents and people.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"vitest": "4.1.10"
|
|
57
57
|
},
|
|
58
58
|
"gaodingRelease": {
|
|
59
|
-
"sourceCommit": "
|
|
60
|
-
"pipelineId": "
|
|
61
|
-
"pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/
|
|
59
|
+
"sourceCommit": "d1722afac1b5acdc776ee3fbc2f2d69496e1a8af",
|
|
60
|
+
"pipelineId": "230438",
|
|
61
|
+
"pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/230438"
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
- 退出码 `1` 表示运行、服务或状态失败;只执行错误中 `error.details.next_steps` 明确给出的恢复步骤,缺失时停止并报告。
|
|
7
7
|
- 退出码 `2` 表示命令或参数错误;执行对应命令的 `--help` 后修正调用。
|
|
8
8
|
- 退出码 `130` 表示用户中断;立即停止,不自动重试。
|
|
9
|
-
- `INSUFFICIENT_CREDITS`
|
|
9
|
+
- `INSUFFICIENT_CREDITS` 只表示当前可用额度不足,不能据此区分账户余额、成员限额或其他扣费限制;不自动引导充值,不从余额查询或报价推断扣费一定成功。
|
|
10
10
|
|
|
11
11
|
## 千问办公桌面连接器
|
|
12
12
|
|
|
@@ -28,6 +28,8 @@ gd-cli task get <id>
|
|
|
28
28
|
- `unknown`:暂时无法确认终态;可复查同一 ID,仍未知就向用户说明。`partialResult` 是消息快照,不当成完整交付。
|
|
29
29
|
- `failed`:向用户说明 `note` 和原错误;不自动重提。
|
|
30
30
|
|
|
31
|
+
查询接口报错(包括未找到任务)不代表原生成失败;保留原任务 ID,不重新生成。
|
|
32
|
+
|
|
31
33
|
`task get` 退出码 0 只表示查询成功,原调用是否完成由 `state` 表示。重复读取同一 ID 的 usage 是同一份费用,不相加。用户主动中断后不自动继续等待或重提。
|
|
32
34
|
|
|
33
35
|
不要从未知错误中推断内部实现,也不要输出本地凭证、请求签名或带敏感查询参数的 URL。命令失败且没有安全恢复步骤时,保留原始 stderr 的公开错误码并向用户说明。
|
|
@@ -14,7 +14,7 @@ gd-cli task get <taskId>
|
|
|
14
14
|
|
|
15
15
|
`tool list` 给出可用 Tool;`model list` 和 `model get` 给出当前可用 Model、说明、费用、预估耗时和结构化参数。`model get` 的 `parameters` 是所选 Model 的实际调用元数据:遵循 `required`、`type`、`description`,SELECT 参数使用 `options[].value`,required 参数带 `default` 时在用户未指定时显式传入默认值。`usageDescription` 描述跨字段规则,例如视频 mode 对首尾帧或素材字段的要求;这类组合不能只从单个字段推断。不要把列表值固化在提示或脚本中。
|
|
16
16
|
|
|
17
|
-
按所选 Model detail 构造 JSON:提供全部 required 字段;SELECT 参数使用 `options[].value`;required 字段带 default 且用户未指定时,在输入中显式使用该 default。存在 width、height、resolution 等专用字段时,将用户要求写入对应结构化参数,不要只写在 prompt 中。`tool call <tool> --schema`
|
|
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`。
|
|
18
18
|
|
|
19
19
|
务必将 `model get <model>` 返回的 `model` 原样放在请求 JSON 的顶层 `model` 字段(即运行时的 `arguments.model`),与所选 Model 的参数字段并列;不要只复制 `parameters`。例如:
|
|
20
20
|
|