@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
package/README.md
CHANGED
|
@@ -30,6 +30,9 @@ gd-cli tool list
|
|
|
30
30
|
gd-cli model list --tool <tool>
|
|
31
31
|
gd-cli model get <model>
|
|
32
32
|
gd-cli editor apply --schema
|
|
33
|
+
gd-cli credits --json
|
|
34
|
+
gd-cli credits usage list --help
|
|
35
|
+
gd-cli credits usage get --schema
|
|
33
36
|
```
|
|
34
37
|
|
|
35
38
|
选定 Model 后,以 `model get` 返回的 `parameters` 与 `usageDescription` 构造实际输入;其中 `cost` 是当前上架 SKU 的稿豆价格区间,不表示某次调用的实际扣费。`tool call <tool> --schema` 只给出整个 Tool 的参数并集。运行 `gd-cli --help` 查看当前命令;运行任一命令的 `--help` 查看参数。`editor apply --schema` 无需登录或连接编辑器,输出当前版本的 Action 输入契约;与执行模式 `--input` 互斥。
|
|
@@ -38,6 +41,8 @@ CLI 最多每小时检查一次 npm `latest`,发现新版本后每天最多在
|
|
|
38
41
|
|
|
39
42
|
发布只由仓库受保护 `main` 的 CI 执行:先发布并验证 `candidate` 与精确版本安装,再提升 `latest` 并验证默认安装。版本与 dist-tag 不由本地手工修改。
|
|
40
43
|
|
|
44
|
+
`credits` 读取当前身份和组织的余额;`credits usage list` 查询一页消费、归还、回收与过期记录,`credits usage get <record-id>` 读取来源拆分。三个命令的 `--schema` 无需登录,输出本地输入与输出 Schema。流水默认当前 UTC 月份;翻页沿用返回区间和 `nextCursor`,不把本页数量当作完整消费合计。
|
|
45
|
+
|
|
41
46
|
## License
|
|
42
47
|
|
|
43
48
|
MIT
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.gaoding.com/operations/credits.get/input.schema.json",
|
|
4
|
+
"title": "CreditsGetInput",
|
|
5
|
+
"description": "查询当前身份及组织上下文的余额,无业务参数。",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {}
|
|
9
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.gaoding.com/operations/credits.get/output.schema.json",
|
|
4
|
+
"title": "CreditsResult",
|
|
5
|
+
"description": "当前身份及组织上下文的权益概览;保留池余额与成员周期限额的区别。",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"credits"
|
|
10
|
+
],
|
|
11
|
+
"properties": {
|
|
12
|
+
"credits": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"additionalProperties": false,
|
|
15
|
+
"required": [
|
|
16
|
+
"unit",
|
|
17
|
+
"total",
|
|
18
|
+
"used",
|
|
19
|
+
"pending",
|
|
20
|
+
"available"
|
|
21
|
+
],
|
|
22
|
+
"properties": {
|
|
23
|
+
"unit": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"enum": [
|
|
26
|
+
"gaodou",
|
|
27
|
+
"credit"
|
|
28
|
+
],
|
|
29
|
+
"description": "产品配置决定的计量单位;稿豆或 insMind credit,不代表货币。"
|
|
30
|
+
},
|
|
31
|
+
"total": {
|
|
32
|
+
"type": "number",
|
|
33
|
+
"minimum": 0,
|
|
34
|
+
"maximum": 9007199254740991,
|
|
35
|
+
"description": "该权益行的 total;不等同于终身累计充值。"
|
|
36
|
+
},
|
|
37
|
+
"used": {
|
|
38
|
+
"type": "number",
|
|
39
|
+
"minimum": 0,
|
|
40
|
+
"maximum": 9007199254740991,
|
|
41
|
+
"description": "与该权益行总量配对的已用量;不等同于所选日期消费合计。"
|
|
42
|
+
},
|
|
43
|
+
"pending": {
|
|
44
|
+
"type": "number",
|
|
45
|
+
"minimum": 0,
|
|
46
|
+
"maximum": 9007199254740991,
|
|
47
|
+
"description": "服务端 wait 的数值;含义由服务端定义,不承诺待生效或冻结。"
|
|
48
|
+
},
|
|
49
|
+
"available": {
|
|
50
|
+
"type": "number",
|
|
51
|
+
"minimum": 0,
|
|
52
|
+
"maximum": 9007199254740991,
|
|
53
|
+
"description": "max(0,total-used);不扣除 wait,不代表成员限额内可用量。"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"balances": {
|
|
58
|
+
"type": "array",
|
|
59
|
+
"description": "多行概览或存在成员限额时返回完整权益行;不按 identifier 去重。",
|
|
60
|
+
"items": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"additionalProperties": false,
|
|
63
|
+
"required": [
|
|
64
|
+
"total",
|
|
65
|
+
"used",
|
|
66
|
+
"pending",
|
|
67
|
+
"available"
|
|
68
|
+
],
|
|
69
|
+
"properties": {
|
|
70
|
+
"identifier": {
|
|
71
|
+
"type": "string"
|
|
72
|
+
},
|
|
73
|
+
"total": {
|
|
74
|
+
"type": "number",
|
|
75
|
+
"minimum": 0,
|
|
76
|
+
"maximum": 9007199254740991,
|
|
77
|
+
"description": "该权益行的 total;不等同于终身累计充值。"
|
|
78
|
+
},
|
|
79
|
+
"used": {
|
|
80
|
+
"type": "number",
|
|
81
|
+
"minimum": 0,
|
|
82
|
+
"maximum": 9007199254740991,
|
|
83
|
+
"description": "与该权益行总量配对的已用量;不等同于所选日期消费合计。"
|
|
84
|
+
},
|
|
85
|
+
"pending": {
|
|
86
|
+
"type": "number",
|
|
87
|
+
"minimum": 0,
|
|
88
|
+
"maximum": 9007199254740991,
|
|
89
|
+
"description": "服务端 wait 的数值;含义由服务端定义,不承诺待生效或冻结。"
|
|
90
|
+
},
|
|
91
|
+
"available": {
|
|
92
|
+
"type": "number",
|
|
93
|
+
"minimum": 0,
|
|
94
|
+
"maximum": 9007199254740991,
|
|
95
|
+
"description": "max(0,total-used);不扣除 wait,不代表成员限额内可用量。"
|
|
96
|
+
},
|
|
97
|
+
"memberPeriodLimit": {
|
|
98
|
+
"type": "number",
|
|
99
|
+
"minimum": 0,
|
|
100
|
+
"maximum": 9007199254740991,
|
|
101
|
+
"description": "服务端成员周期限额,0 是有效限额;不以它覆盖权益池余额。"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.gaoding.com/operations/credits.usage.get/input.schema.json",
|
|
4
|
+
"title": "CreditsUsageGetInput",
|
|
5
|
+
"description": "按列表返回的记录 ID 查询来源拆分。",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"id"
|
|
10
|
+
],
|
|
11
|
+
"properties": {
|
|
12
|
+
"id": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"minLength": 1,
|
|
15
|
+
"pattern": ".*\\S.*"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.gaoding.com/operations/credits.usage.get/output.schema.json",
|
|
4
|
+
"title": "CreditsUsageGetResult",
|
|
5
|
+
"description": "服务端提供的单条记录来源拆分;空数组不表示该记录数量为零。",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"id",
|
|
10
|
+
"unit",
|
|
11
|
+
"breakdown"
|
|
12
|
+
],
|
|
13
|
+
"properties": {
|
|
14
|
+
"id": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"minLength": 1,
|
|
17
|
+
"pattern": ".*\\S.*"
|
|
18
|
+
},
|
|
19
|
+
"unit": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"enum": [
|
|
22
|
+
"gaodou",
|
|
23
|
+
"credit"
|
|
24
|
+
],
|
|
25
|
+
"description": "产品配置决定的计量单位;稿豆或 insMind credit,不代表货币。"
|
|
26
|
+
},
|
|
27
|
+
"breakdown": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"additionalProperties": false,
|
|
32
|
+
"required": [
|
|
33
|
+
"amount"
|
|
34
|
+
],
|
|
35
|
+
"properties": {
|
|
36
|
+
"amount": {
|
|
37
|
+
"type": "number",
|
|
38
|
+
"minimum": 0,
|
|
39
|
+
"maximum": 9007199254740991
|
|
40
|
+
},
|
|
41
|
+
"usageType": {
|
|
42
|
+
"type": "number",
|
|
43
|
+
"description": "服务端 usage_type;1 为消费、2 为归还,其他值保留不推断方向。"
|
|
44
|
+
},
|
|
45
|
+
"sourceType": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "服务端权益来源类型;保留未知值。"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.gaoding.com/operations/credits.usage.list/input.schema.json",
|
|
4
|
+
"title": "CreditsUsageListInput",
|
|
5
|
+
"description": "按含端点的时间区间读取一页服务端变动流水;默认 UTC 本月,20 条。",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"from": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"format": "date-time",
|
|
12
|
+
"description": "含起始时刻;ISO 8601 时间戳,必须含 Z 或时区偏移。省略为当前 UTC 月首。"
|
|
13
|
+
},
|
|
14
|
+
"to": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"format": "date-time",
|
|
17
|
+
"description": "含结束时刻;ISO 8601 时间戳,必须含 Z 或时区偏移。省略为当前 UTC 月末。"
|
|
18
|
+
},
|
|
19
|
+
"limit": {
|
|
20
|
+
"type": "integer",
|
|
21
|
+
"minimum": 1,
|
|
22
|
+
"default": 20,
|
|
23
|
+
"description": "每页条数;不在 CLI 声明未经确认的服务端最大值。"
|
|
24
|
+
},
|
|
25
|
+
"cursor": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"minLength": 1,
|
|
28
|
+
"pattern": ".*\\S.*",
|
|
29
|
+
"description": "上一页 nextCursor,原样传递;翻页时保持相同时间区间。"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.gaoding.com/operations/credits.usage.list/output.schema.json",
|
|
4
|
+
"title": "CreditsUsageListResult",
|
|
5
|
+
"description": "带实际 UTC 区间和继续游标的一页变动流水。",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"unit",
|
|
10
|
+
"range",
|
|
11
|
+
"items",
|
|
12
|
+
"hasMore",
|
|
13
|
+
"nextCursor"
|
|
14
|
+
],
|
|
15
|
+
"properties": {
|
|
16
|
+
"unit": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"enum": [
|
|
19
|
+
"gaodou",
|
|
20
|
+
"credit"
|
|
21
|
+
],
|
|
22
|
+
"description": "产品配置决定的计量单位;稿豆或 insMind credit,不代表货币。"
|
|
23
|
+
},
|
|
24
|
+
"range": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"additionalProperties": false,
|
|
27
|
+
"required": [
|
|
28
|
+
"from",
|
|
29
|
+
"to"
|
|
30
|
+
],
|
|
31
|
+
"properties": {
|
|
32
|
+
"from": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"format": "date-time"
|
|
35
|
+
},
|
|
36
|
+
"to": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"format": "date-time"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"items": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"items": {
|
|
45
|
+
"type": "object",
|
|
46
|
+
"additionalProperties": false,
|
|
47
|
+
"required": [
|
|
48
|
+
"id",
|
|
49
|
+
"changeType",
|
|
50
|
+
"amount",
|
|
51
|
+
"recordedAt"
|
|
52
|
+
],
|
|
53
|
+
"properties": {
|
|
54
|
+
"id": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"minLength": 1,
|
|
57
|
+
"pattern": ".*\\S.*"
|
|
58
|
+
},
|
|
59
|
+
"changeType": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"minLength": 1,
|
|
62
|
+
"pattern": ".*\\S.*",
|
|
63
|
+
"description": "服务端变动类型。CONSUME 消费、RESTORE 归还、RECYCLE 回收、EXPIRE 过期;其他值保留,不假设方向。"
|
|
64
|
+
},
|
|
65
|
+
"amount": {
|
|
66
|
+
"type": "number",
|
|
67
|
+
"minimum": 0,
|
|
68
|
+
"maximum": 9007199254740991,
|
|
69
|
+
"description": "该条变动的无符号数量,不是所有类型均属于消费。"
|
|
70
|
+
},
|
|
71
|
+
"recordedAt": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"format": "date-time"
|
|
74
|
+
},
|
|
75
|
+
"recordMode": {
|
|
76
|
+
"type": "string"
|
|
77
|
+
},
|
|
78
|
+
"description": {
|
|
79
|
+
"type": "string"
|
|
80
|
+
},
|
|
81
|
+
"scene": {
|
|
82
|
+
"type": "number"
|
|
83
|
+
},
|
|
84
|
+
"referenceId": {
|
|
85
|
+
"type": "string"
|
|
86
|
+
},
|
|
87
|
+
"user": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"additionalProperties": false,
|
|
90
|
+
"properties": {
|
|
91
|
+
"id": {
|
|
92
|
+
"type": "string"
|
|
93
|
+
},
|
|
94
|
+
"name": {
|
|
95
|
+
"type": "string"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"description": "本页记录,不代表区间完整账本,不提供推测的总数或总消费。"
|
|
102
|
+
},
|
|
103
|
+
"hasMore": {
|
|
104
|
+
"type": "boolean"
|
|
105
|
+
},
|
|
106
|
+
"nextCursor": {
|
|
107
|
+
"type": [
|
|
108
|
+
"string",
|
|
109
|
+
"null"
|
|
110
|
+
],
|
|
111
|
+
"description": "后续页的 opaque cursor;无后续页时为 null。"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"allOf": [
|
|
115
|
+
{
|
|
116
|
+
"if": {
|
|
117
|
+
"properties": {
|
|
118
|
+
"hasMore": {
|
|
119
|
+
"const": true
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"required": [
|
|
123
|
+
"hasMore"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
"then": {
|
|
127
|
+
"properties": {
|
|
128
|
+
"nextCursor": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"minLength": 1,
|
|
131
|
+
"pattern": ".*\\S.*"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"else": {
|
|
136
|
+
"properties": {
|
|
137
|
+
"nextCursor": {
|
|
138
|
+
"type": "null"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
package/dist/bin/gd-cli.js
CHANGED
|
@@ -31,7 +31,7 @@ try {
|
|
|
31
31
|
const { createProductionRuntime } = runtimeModule;
|
|
32
32
|
mapCliError = errorsModule.mapCliError;
|
|
33
33
|
redact = redactModule.redact;
|
|
34
|
-
runtime = createProductionRuntime();
|
|
34
|
+
runtime = createProductionRuntime({ invocationStartedAt: startedAt, invocationTraceId: bootstrapTraceId });
|
|
35
35
|
const program = createCli(runtime, { signal: controller.signal });
|
|
36
36
|
process.exitCode = await executeCli({
|
|
37
37
|
program,
|
|
@@ -49,7 +49,7 @@ catch (error) {
|
|
|
49
49
|
const traceId = runtime?.telemetry.traceId ?? bootstrapTraceId;
|
|
50
50
|
try {
|
|
51
51
|
const { reportProcessError } = await import("../src/telemetry/process-errors.js");
|
|
52
|
-
await reportProcessError(error, { operation: "bootstrap", startedAt, traceId, signal: controller.signal, stateDirectory: ".gd" });
|
|
52
|
+
await reportProcessError(error, { operation: "bootstrap", argv: process.argv.slice(2), startedAt, traceId, signal: controller.signal, stateDirectory: ".gd" });
|
|
53
53
|
}
|
|
54
54
|
catch { /* Retain startup error output even if diagnostic modules cannot load. */ }
|
|
55
55
|
// Dynamic module loading can fail before the error mapper is available.
|
package/dist/bin/insmind-cli.js
CHANGED
|
@@ -31,7 +31,7 @@ try {
|
|
|
31
31
|
redact = redactModule.redact;
|
|
32
32
|
const selectedLocale = localeOption(process.argv.slice(2));
|
|
33
33
|
runtime = runtimeModule.createProductionRuntime({
|
|
34
|
-
product: insmindProduct,
|
|
34
|
+
product: insmindProduct, invocationStartedAt: startedAt, invocationTraceId: bootstrapTraceId,
|
|
35
35
|
...(selectedLocale === undefined ? {} : { locale: selectedLocale })
|
|
36
36
|
});
|
|
37
37
|
const program = cliModule.createCli(runtime, { signal: controller.signal });
|
|
@@ -51,7 +51,7 @@ catch (error) {
|
|
|
51
51
|
const traceId = runtime?.telemetry.traceId ?? bootstrapTraceId;
|
|
52
52
|
try {
|
|
53
53
|
const { reportProcessError } = await import("../src/telemetry/process-errors.js");
|
|
54
|
-
await reportProcessError(error, { operation: "bootstrap", startedAt, traceId, signal: controller.signal, stateDirectory: ".insmind" });
|
|
54
|
+
await reportProcessError(error, { operation: "bootstrap", argv: process.argv.slice(2), startedAt, traceId, signal: controller.signal, stateDirectory: ".insmind" });
|
|
55
55
|
}
|
|
56
56
|
catch { /* Retain startup error output even if diagnostic modules cannot load. */ }
|
|
57
57
|
if (mapCliError === undefined || redact === undefined) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isInterruption } from "../platform/interruption.js";
|
|
2
2
|
import { registerTaskCommands } from "../cli/task-commands.js";
|
|
3
3
|
import { Command, CommanderError } from "commander";
|
|
4
|
-
import { assertAllLeafCommandsBound, errorUsesJson, configureActionEnvironment } from "../cli/action-binding.js";
|
|
4
|
+
import { assertAllLeafCommandsBound, errorUsesJson, invocationDefinition, configureActionEnvironment } from "../cli/action-binding.js";
|
|
5
5
|
import { registerAgentCommands } from "../cli/agent-commands.js";
|
|
6
6
|
import { registerAuthCommands } from "../cli/auth-commands.js";
|
|
7
7
|
import { classifyTelemetryError, isHelpOutcome, mapCliError } from "../cli/errors.js";
|
|
@@ -35,22 +35,19 @@ export function createCli(runtime, options) {
|
|
|
35
35
|
writeErr: () => undefined
|
|
36
36
|
});
|
|
37
37
|
program.addHelpText("after", runtime.product.id === "insmind"
|
|
38
|
-
? "\nstdout contains command results; stderr contains progress, warnings and errors. Fixed JSON commands, --json and --json-errors use {error:{code,message,details?,trace_id?}} for final errors. stderr may contain multiple messages.\nExit codes: 0 success, 1 execution failure, 2 invalid input, 130 local interruption; dispatched work may still be active.\n"
|
|
39
|
-
: "\nstdout
|
|
38
|
+
? "\nstdout contains command results; human-readable views can include an update notice. stderr contains progress, warnings and errors. Fixed JSON commands, --json and --json-errors use {error:{code,message,details?,trace_id?}} for final errors. stderr may contain multiple messages.\nExit codes: 0 success, 1 execution failure, 2 invalid input, 130 local interruption; dispatched work may still be active.\n"
|
|
39
|
+
: "\nstdout 输出命令结果,人类可读视图可以附带升级提醒;stderr 输出进度、警告和错误。固定 JSON 命令、--json 和 --json-errors 的最终错误使用 {error:{code,message,details?,trace_id?}},stderr 可能包含多条信息。\n退出码:0 成功,1 执行失败,2 输入无效,130 本地中断;已派发的工作可能仍在继续。\n");
|
|
40
40
|
if (runtime.product.id === "insmind") {
|
|
41
41
|
program.option("--locale <locale>", "locale for service-owned business descriptions");
|
|
42
42
|
}
|
|
43
43
|
configureActionEnvironment(program, {
|
|
44
44
|
policies: runtime.accessPolicies,
|
|
45
45
|
signal: options.signal,
|
|
46
|
-
telemetry: runtime.telemetry
|
|
47
|
-
updateNotification: runtime.updateNotification
|
|
46
|
+
telemetry: runtime.telemetry
|
|
48
47
|
});
|
|
49
48
|
registerAuthCommands(program, runtime);
|
|
50
49
|
if (runtime.product.exposesOrganizations)
|
|
51
50
|
registerOrgCommands(program, runtime);
|
|
52
|
-
else
|
|
53
|
-
registerCreditsCommand(program, runtime);
|
|
54
51
|
registerAgentCommands(program, runtime);
|
|
55
52
|
registerToolCommands(program, runtime);
|
|
56
53
|
registerModelCommands(program, runtime);
|
|
@@ -58,6 +55,7 @@ export function createCli(runtime, options) {
|
|
|
58
55
|
registerDamCommands(program, runtime);
|
|
59
56
|
registerUpdateCommand(program, runtime);
|
|
60
57
|
registerTaskCommands(program, runtime);
|
|
58
|
+
registerCreditsCommand(program, runtime);
|
|
61
59
|
assertAllLeafCommandsBound(program);
|
|
62
60
|
outputs.set(program, runtime);
|
|
63
61
|
if (runtime.analytics)
|
|
@@ -65,13 +63,11 @@ export function createCli(runtime, options) {
|
|
|
65
63
|
return program;
|
|
66
64
|
}
|
|
67
65
|
export async function executeCli(options) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
options.telemetry.select({ operation: "version" });
|
|
74
|
-
}
|
|
66
|
+
const definition = invocationDefinition(options.program, options.argv);
|
|
67
|
+
await options.telemetry.issue(definition);
|
|
68
|
+
const automaticNotice = definition.operation !== "update" && !definition.operation.startsWith("update.");
|
|
69
|
+
let informational = false;
|
|
70
|
+
let help = false;
|
|
75
71
|
try {
|
|
76
72
|
try {
|
|
77
73
|
await options.program.parseAsync(options.argv, { from: "user" });
|
|
@@ -79,15 +75,17 @@ export async function executeCli(options) {
|
|
|
79
75
|
catch (error) {
|
|
80
76
|
if (!isHelpOutcome(error))
|
|
81
77
|
throw error;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
await checkUpdateNotification(options.updateNotification, options.signal);
|
|
78
|
+
informational = true;
|
|
79
|
+
help = error instanceof CommanderError && error.code === "commander.helpDisplayed";
|
|
85
80
|
options.signal.throwIfAborted();
|
|
86
81
|
}
|
|
87
82
|
await options.telemetry.stage("output", async () => { await outputs.get(options.program)?.io.flush?.(); });
|
|
88
83
|
await outputs.get(options.program)?.tasks.outputCompleted();
|
|
89
|
-
if (
|
|
90
|
-
await
|
|
84
|
+
if (automaticNotice)
|
|
85
|
+
await checkUpdateNotification(options.updateNotification, options.signal, help || options.presenter.humanResult ? "text" : "machine");
|
|
86
|
+
if (informational)
|
|
87
|
+
options.signal.throwIfAborted();
|
|
88
|
+
await sendFinished(options, { outcome: "success" });
|
|
91
89
|
return 0;
|
|
92
90
|
}
|
|
93
91
|
catch (error) {
|
|
@@ -123,16 +121,23 @@ export async function executeCli(options) {
|
|
|
123
121
|
const traceId = options.telemetry.selected
|
|
124
122
|
? options.telemetry.traceId
|
|
125
123
|
: undefined;
|
|
124
|
+
let errorDelivered = false;
|
|
126
125
|
try {
|
|
127
126
|
options.presenter.error(outcome, {
|
|
128
127
|
json: errorUsesJson(options.program, options.argv),
|
|
129
128
|
...(traceId ? { traceId } : {})
|
|
130
129
|
});
|
|
130
|
+
await outputs.get(options.program)?.io.flush?.();
|
|
131
|
+
errorDelivered = true;
|
|
131
132
|
}
|
|
132
133
|
catch (presenterError) {
|
|
133
134
|
await options.telemetry.stage("output", () => { throw presenterError; }).catch(() => undefined);
|
|
134
135
|
}
|
|
135
|
-
|
|
136
|
+
if (errorDelivered)
|
|
137
|
+
await outputs.get(options.program)?.tasks.outputCompleted(error);
|
|
138
|
+
if (errorDelivered && automaticNotice && outcome.exitCode === 1 && definition.operation !== "unknown") {
|
|
139
|
+
await checkUpdateNotification(options.updateNotification, options.signal, "machine");
|
|
140
|
+
}
|
|
136
141
|
await sendFinished(options, outcome.kind === "interrupted"
|
|
137
142
|
? { outcome: "interrupted", error }
|
|
138
143
|
: {
|
|
@@ -153,9 +158,9 @@ export async function executeCli(options) {
|
|
|
153
158
|
return outcome.exitCode;
|
|
154
159
|
}
|
|
155
160
|
}
|
|
156
|
-
async function checkUpdateNotification(updateNotification, signal) {
|
|
161
|
+
async function checkUpdateNotification(updateNotification, signal, output) {
|
|
157
162
|
try {
|
|
158
|
-
await updateNotification.check(signal);
|
|
163
|
+
await updateNotification.check(signal, output);
|
|
159
164
|
}
|
|
160
165
|
catch {
|
|
161
166
|
// Version availability must never change the requested command outcome.
|
|
@@ -166,6 +171,5 @@ async function sendFinished(options, completion) {
|
|
|
166
171
|
await options.telemetrySink.refreshDiagnostics?.().catch(() => undefined);
|
|
167
172
|
options.telemetry.annotate(options.telemetrySink.diagnostics?.() ?? {});
|
|
168
173
|
const events = options.telemetry.finish(completion);
|
|
169
|
-
|
|
170
|
-
await options.telemetrySink.send(events).catch(() => undefined);
|
|
174
|
+
await options.telemetrySink.send(events).catch(() => undefined);
|
|
171
175
|
}
|