gaoding-cli 1.0.0-alpha.20 → 1.0.0-alpha.21
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.
|
@@ -40,7 +40,7 @@ const productionEndpoints = {
|
|
|
40
40
|
toolApi: new URL("https://gdcli.gaoding.com/api"),
|
|
41
41
|
damApi: new URL("https://gdcli.gaoding.com/api"),
|
|
42
42
|
ssoApi: new URL("https://www.gaoding.com/api/sso"),
|
|
43
|
-
authPageOrigin: new URL("https://www.gaoding.
|
|
43
|
+
authPageOrigin: new URL("https://www.gaoding.art")
|
|
44
44
|
};
|
|
45
45
|
export function createProductionRuntime(options = {}) {
|
|
46
46
|
const bundledSkills = loadBundledSkills(fileURLToPath(import.meta.url));
|
package/dist/src/cli/errors.js
CHANGED
|
@@ -25,6 +25,12 @@ export class CliUsageError extends Error {
|
|
|
25
25
|
this.name = "CliUsageError";
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
+
const INSUFFICIENT_CREDITS_REMOTE_CODE = "12020770";
|
|
29
|
+
const INSUFFICIENT_CREDITS_NEXT_STEPS = [
|
|
30
|
+
"前往 https://www.gaoding.art/pricing 购买稿豆",
|
|
31
|
+
"也可以执行 gd-cli org switch 切换到有可用稿豆的组织",
|
|
32
|
+
"处理后重新发起本次创作"
|
|
33
|
+
];
|
|
28
34
|
export function isHelpOutcome(error) {
|
|
29
35
|
return error instanceof CommanderError
|
|
30
36
|
&& error.exitCode === 0
|
|
@@ -62,6 +68,9 @@ export function mapCliError(error, options) {
|
|
|
62
68
|
|| error instanceof CommanderError) {
|
|
63
69
|
return failure("USAGE_ERROR", "命令或参数无效,请查看 --help。", 2);
|
|
64
70
|
}
|
|
71
|
+
if (isInsufficientCreditsError(error)) {
|
|
72
|
+
return failure("INSUFFICIENT_CREDITS", "当前组织稿豆不足,无法完成本次创作。", 1, INSUFFICIENT_CREDITS_NEXT_STEPS);
|
|
73
|
+
}
|
|
65
74
|
if (error instanceof RemoteProtocolError) {
|
|
66
75
|
return failure("REMOTE_PROTOCOL_INCOMPATIBLE", "稿定服务返回了当前 CLI 无法安全处理的结果;为避免重复创作,已停止处理。", 1);
|
|
67
76
|
}
|
|
@@ -89,6 +98,11 @@ export function mapCliError(error, options) {
|
|
|
89
98
|
}
|
|
90
99
|
return failure("INTERNAL_ERROR", "CLI 发生内部错误。", 1);
|
|
91
100
|
}
|
|
101
|
+
function isInsufficientCreditsError(error) {
|
|
102
|
+
return (error instanceof RemoteRequestError
|
|
103
|
+
|| error instanceof RemoteProtocolError
|
|
104
|
+
|| error instanceof ToolTaskFailedError) && error.remoteCode === INSUFFICIENT_CREDITS_REMOTE_CODE;
|
|
105
|
+
}
|
|
92
106
|
export function classifyTelemetryError(error) {
|
|
93
107
|
const outcome = mapCliError(error, { aborted: false });
|
|
94
108
|
const remoteError = error instanceof RemoteRequestError
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
- 退出码 `1` 表示运行、服务或状态失败;只执行错误中 `error.details.next_steps` 明确给出的恢复步骤,缺失时停止并报告。
|
|
7
7
|
- 退出码 `2` 表示命令或参数错误;执行对应命令的 `--help` 后修正调用。
|
|
8
8
|
- 退出码 `130` 表示用户中断;立即停止,不自动重试。
|
|
9
|
+
- `INSUFFICIENT_CREDITS` 表示当前组织稿豆不足;按 `error.details.next_steps` 引导用户前往 https://www.gaoding.art/pricing 购买稿豆,或执行 `gd-cli org switch` 切换到有可用稿豆的组织,处理后再重新发起创作。
|
|
9
10
|
|
|
10
11
|
Agent 或 Tool 等可能消耗稿豆的请求如果可能已经提交、但完成状态未知,停止并报告,不自动重试原调用。
|
|
11
12
|
|