@gaoding/cli 1.8.0 → 1.9.1
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/contracts/operations/agent.send/input.schema.json +1 -1
- package/contracts/operations/agent.send/output.schema.json +1 -1
- package/contracts/operations/model.get/input.schema.json +6 -0
- package/contracts/operations/model.get/output.schema.json +10 -1
- package/contracts/operations/tool.call/canvas-input.schema.json +60 -0
- package/contracts/operations/tool.call/models/image-edit-smart.schema.json +42 -0
- package/contracts/operations/tool.call/models/image-edit-standard.schema.json +33 -0
- package/contracts/operations/tool.call/models/image-enhance-smart.schema.json +27 -0
- package/contracts/operations/tool.call/models/image-enhance-standard.schema.json +27 -0
- package/contracts/operations/tool.call/models/image-expand-smart.schema.json +76 -0
- package/contracts/operations/tool.call/models/image-expand-standard.schema.json +61 -0
- package/contracts/operations/tool.call/models/image-layers-layout.schema.json +21 -0
- package/contracts/operations/tool.call/models/image-layers-smart.schema.json +28 -0
- package/contracts/operations/tool.call/models/image-matting-smart.schema.json +37 -0
- package/contracts/operations/tool.call/models/image-matting-standard.schema.json +26 -0
- package/contracts/operations/tool.call/models/image-ocr.schema.json +21 -0
- package/contracts/operations/tool.call/models/image-remove-smart.schema.json +32 -0
- package/contracts/operations/tool.call/models/image-remove-standard.schema.json +27 -0
- package/contracts/operations/tool.call/models/image-text-edit.schema.json +46 -0
- package/contracts/operations/tool.call/models/image-vectorize.schema.json +21 -0
- package/contracts/operations/tool.call/models/video-edit-smart.schema.json +76 -0
- package/contracts/operations/tool.call/models/video-enhance-smart.schema.json +33 -0
- package/contracts/operations/tool.call/models/video-enhance-standard.schema.json +27 -0
- package/contracts/operations/tool.call/ocr-payload.schema.json +66 -0
- package/contracts/operations/tool.call/output.schema.json +38 -0
- package/contracts/operations/tool.call/template-payload.schema.json +96 -0
- package/dist/bin/gd-cli.js +31 -24
- package/dist/bin/insmind-cli.js +31 -24
- package/dist/bin/task-worker.js +4 -1
- package/dist/src/analytics/device.js +2 -2
- package/dist/src/bootstrap/create-cli.js +7 -0
- package/dist/src/bootstrap/create-runtime.js +53 -30
- package/dist/src/bootstrap/run-task-worker.js +5 -1
- package/dist/src/bootstrap/validators.js +11 -4
- package/dist/src/cli/agent-commands.js +1 -0
- package/dist/src/cli/dam-commands.js +3 -3
- package/dist/src/cli/errors.js +63 -15
- package/dist/src/cli/model-commands.js +6 -3
- package/dist/src/cli/observed-errors.js +3 -1
- package/dist/src/cli/tool-commands.js +2 -0
- package/dist/src/contracts/schema.js +4 -1
- package/dist/src/features/agent/creative-agent-adapter.js +37 -11
- package/dist/src/features/agent/creative-protocol.js +31 -10
- package/dist/src/features/agent/creative-stream.js +54 -6
- package/dist/src/features/agent/resource-authorizer.js +1 -0
- package/dist/src/features/agent/result-reader.js +3 -1
- package/dist/src/features/agent/use-cases.js +15 -5
- package/dist/src/features/auth/credential-store.js +6 -10
- package/dist/src/features/auth/sso-service.js +22 -6
- package/dist/src/features/auth/state.js +6 -0
- package/dist/src/features/auth/use-cases.js +90 -32
- package/dist/src/features/dam/asset-projection.js +10 -1
- package/dist/src/features/dam/dam-api-adapter.js +30 -15
- package/dist/src/features/dam/input.js +23 -0
- package/dist/src/features/dam/use-cases.js +32 -22
- package/dist/src/features/task/store.js +5 -5
- package/dist/src/features/task/task-background.js +67 -19
- package/dist/src/features/task/use-cases.js +38 -9
- package/dist/src/features/tool/canvas-copy.js +61 -0
- package/dist/src/features/tool/canvas-media.js +248 -0
- package/dist/src/features/tool/canvas-models.js +109 -0
- package/dist/src/features/tool/canvas-pricing.js +81 -0
- package/dist/src/features/tool/canvas-recovery.js +68 -0
- package/dist/src/features/tool/canvas-results.js +144 -0
- package/dist/src/features/tool/canvas-tool-adapter.js +366 -0
- package/dist/src/features/tool/canvas-video.js +84 -0
- package/dist/src/features/tool/catalog.js +35 -13
- package/dist/src/features/tool/dynamic-schema.js +55 -25
- package/dist/src/features/tool/matting-billing.js +115 -0
- package/dist/src/features/tool/mns-catalog-adapter.js +66 -19
- package/dist/src/features/tool/resource-authorizer.js +34 -0
- package/dist/src/features/tool/scene-catalog-adapter.js +35 -0
- package/dist/src/features/tool/tool-api-adapter.js +29 -17
- package/dist/src/features/tool/use-cases.js +28 -3
- package/dist/src/platform/file-lock.js +58 -15
- package/dist/src/platform/input-uri.js +105 -0
- package/dist/src/platform/local-json-file.js +7 -4
- package/dist/src/platform/remote-error-evidence.js +23 -1
- package/dist/src/platform/safe-upload-file.js +18 -4
- package/dist/src/platform/schema-issues.js +18 -0
- package/dist/src/platform/signed-http-transport.js +77 -16
- package/dist/src/platform/text-output.js +55 -13
- package/dist/src/product/config.js +12 -1
- package/dist/src/telemetry/failure-summary.js +53 -2
- package/dist/src/telemetry/host-diagnostics.js +95 -0
- package/dist/src/telemetry/invocation.js +24 -3
- package/dist/src/telemetry/process-errors.js +2 -1
- package/dist/src/telemetry/sls-sink.js +66 -18
- package/package.json +5 -4
- package/skills/gd-cli/SKILL.md +2 -0
- package/skills/gd-cli/references/creation.md +2 -0
- package/skills/gd-cli/references/generation-constraints.md +3 -1
- package/skills/gd-cli/references/matting.md +29 -0
- package/skills/gd-cli/references/media-tools.md +40 -0
- package/skills/gd-cli/references/tool.md +4 -4
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "VideoEditSmartInput",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": [
|
|
7
|
+
"model",
|
|
8
|
+
"video",
|
|
9
|
+
"prompt",
|
|
10
|
+
"resolution",
|
|
11
|
+
"audioEnabled"
|
|
12
|
+
],
|
|
13
|
+
"properties": {
|
|
14
|
+
"model": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"const": "video-edit-smart"
|
|
17
|
+
},
|
|
18
|
+
"video": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"format": "uri",
|
|
21
|
+
"description": "待编辑原视频,对应提示词中的视频1。支持 HTTP(S) 或 CLI file:// 素材 URI。"
|
|
22
|
+
},
|
|
23
|
+
"prompt": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"minLength": 1,
|
|
26
|
+
"pattern": ".*\\S.*",
|
|
27
|
+
"description": "用户 prompt 原文逐字保留,CLI 仅在前面补充素材对应关系。原片为视频1,referenceVideos 从视频2起,referenceImages 从图1起,referenceAudios 从音频1起;各类按数组顺序编号。映射包含原文件名,上传后仍可识别素材角色。"
|
|
28
|
+
},
|
|
29
|
+
"resolution": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"minLength": 1,
|
|
32
|
+
"pattern": ".*\\S.*"
|
|
33
|
+
},
|
|
34
|
+
"audioEnabled": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"minLength": 1,
|
|
37
|
+
"pattern": ".*\\S.*"
|
|
38
|
+
},
|
|
39
|
+
"referenceImages": {
|
|
40
|
+
"type": "array",
|
|
41
|
+
"items": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"format": "uri",
|
|
44
|
+
"description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
|
|
45
|
+
},
|
|
46
|
+
"minItems": 1,
|
|
47
|
+
"uniqueItems": true,
|
|
48
|
+
"maxItems": 10,
|
|
49
|
+
"description": "额外参考图片,按顺序对应图1、图2等。"
|
|
50
|
+
},
|
|
51
|
+
"referenceVideos": {
|
|
52
|
+
"type": "array",
|
|
53
|
+
"items": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"format": "uri",
|
|
56
|
+
"description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
|
|
57
|
+
},
|
|
58
|
+
"minItems": 1,
|
|
59
|
+
"uniqueItems": true,
|
|
60
|
+
"maxItems": 4,
|
|
61
|
+
"description": "额外参考视频,按顺序对应视频2、视频3等;视频1固定为原片。原片与全部参考视频的合计时长不超过15秒。"
|
|
62
|
+
},
|
|
63
|
+
"referenceAudios": {
|
|
64
|
+
"type": "array",
|
|
65
|
+
"items": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"format": "uri",
|
|
68
|
+
"description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
|
|
69
|
+
},
|
|
70
|
+
"minItems": 1,
|
|
71
|
+
"uniqueItems": true,
|
|
72
|
+
"maxItems": 5,
|
|
73
|
+
"description": "额外参考音频,按顺序对应音频1、音频2等。"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "VideoEnhanceSmartInput",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": [
|
|
7
|
+
"model",
|
|
8
|
+
"video",
|
|
9
|
+
"prompt",
|
|
10
|
+
"resolution"
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"model": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"const": "video-enhance-smart"
|
|
16
|
+
},
|
|
17
|
+
"video": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"format": "uri",
|
|
20
|
+
"description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
|
|
21
|
+
},
|
|
22
|
+
"prompt": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"minLength": 1,
|
|
25
|
+
"pattern": ".*\\S.*"
|
|
26
|
+
},
|
|
27
|
+
"resolution": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"minLength": 1,
|
|
30
|
+
"pattern": ".*\\S.*"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "VideoEnhanceStandardInput",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": [
|
|
7
|
+
"model",
|
|
8
|
+
"video",
|
|
9
|
+
"resolution"
|
|
10
|
+
],
|
|
11
|
+
"properties": {
|
|
12
|
+
"model": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"const": "video-enhance-standard"
|
|
15
|
+
},
|
|
16
|
+
"video": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"format": "uri",
|
|
19
|
+
"description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
|
|
20
|
+
},
|
|
21
|
+
"resolution": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"minLength": 1,
|
|
24
|
+
"pattern": ".*\\S.*"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "OcrPayload",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": [
|
|
7
|
+
"image",
|
|
8
|
+
"blocks"
|
|
9
|
+
],
|
|
10
|
+
"properties": {
|
|
11
|
+
"image": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"required": [
|
|
15
|
+
"uri",
|
|
16
|
+
"width",
|
|
17
|
+
"height"
|
|
18
|
+
],
|
|
19
|
+
"properties": {
|
|
20
|
+
"uri": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"format": "uri",
|
|
23
|
+
"description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
|
|
24
|
+
},
|
|
25
|
+
"width": {
|
|
26
|
+
"type": "integer",
|
|
27
|
+
"minimum": 1
|
|
28
|
+
},
|
|
29
|
+
"height": {
|
|
30
|
+
"type": "integer",
|
|
31
|
+
"minimum": 1
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"blocks": {
|
|
36
|
+
"type": "array",
|
|
37
|
+
"items": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"additionalProperties": false,
|
|
40
|
+
"required": [
|
|
41
|
+
"bbox",
|
|
42
|
+
"category"
|
|
43
|
+
],
|
|
44
|
+
"properties": {
|
|
45
|
+
"bbox": {
|
|
46
|
+
"type": "array",
|
|
47
|
+
"minItems": 4,
|
|
48
|
+
"maxItems": 4,
|
|
49
|
+
"items": {
|
|
50
|
+
"type": "number",
|
|
51
|
+
"minimum": 0
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"category": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"minLength": 1,
|
|
57
|
+
"pattern": ".*\\S.*"
|
|
58
|
+
},
|
|
59
|
+
"text": {
|
|
60
|
+
"type": "string"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"$ref": "#/$defs/ResourceLink"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"$ref": "#/$defs/EmbeddedJsonResource"
|
|
22
25
|
}
|
|
23
26
|
]
|
|
24
27
|
}
|
|
@@ -124,6 +127,41 @@
|
|
|
124
127
|
"description": "资源的 MIME type。"
|
|
125
128
|
}
|
|
126
129
|
}
|
|
130
|
+
},
|
|
131
|
+
"EmbeddedJsonResource": {
|
|
132
|
+
"type": "object",
|
|
133
|
+
"additionalProperties": false,
|
|
134
|
+
"required": [
|
|
135
|
+
"type",
|
|
136
|
+
"resource"
|
|
137
|
+
],
|
|
138
|
+
"properties": {
|
|
139
|
+
"type": {
|
|
140
|
+
"const": "resource"
|
|
141
|
+
},
|
|
142
|
+
"resource": {
|
|
143
|
+
"type": "object",
|
|
144
|
+
"additionalProperties": false,
|
|
145
|
+
"required": [
|
|
146
|
+
"uri",
|
|
147
|
+
"mimeType",
|
|
148
|
+
"text"
|
|
149
|
+
],
|
|
150
|
+
"properties": {
|
|
151
|
+
"uri": {
|
|
152
|
+
"type": "string",
|
|
153
|
+
"format": "uri"
|
|
154
|
+
},
|
|
155
|
+
"mimeType": {
|
|
156
|
+
"const": "application/json"
|
|
157
|
+
},
|
|
158
|
+
"text": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"minLength": 1
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
127
165
|
}
|
|
128
166
|
}
|
|
129
167
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "NativeLayerTemplate",
|
|
4
|
+
"description": "分层服务返回的原生模板最低结构;保留扩展字段,不转换为扁平格式。",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"pages"
|
|
8
|
+
],
|
|
9
|
+
"properties": {
|
|
10
|
+
"pages": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"minItems": 1,
|
|
13
|
+
"items": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"required": [
|
|
16
|
+
"elements"
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"elements": {
|
|
20
|
+
"type": "array",
|
|
21
|
+
"minItems": 1,
|
|
22
|
+
"items": {
|
|
23
|
+
"$ref": "#/$defs/layout"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"$defs": {
|
|
31
|
+
"element": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"required": [
|
|
34
|
+
"type"
|
|
35
|
+
],
|
|
36
|
+
"properties": {
|
|
37
|
+
"type": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"minLength": 1
|
|
40
|
+
},
|
|
41
|
+
"elements": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": {
|
|
44
|
+
"$ref": "#/$defs/element"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"url": {
|
|
48
|
+
"type": "string"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"layout": {
|
|
53
|
+
"allOf": [
|
|
54
|
+
{
|
|
55
|
+
"$ref": "#/$defs/element"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "object",
|
|
59
|
+
"required": [
|
|
60
|
+
"width",
|
|
61
|
+
"height",
|
|
62
|
+
"background",
|
|
63
|
+
"elements"
|
|
64
|
+
],
|
|
65
|
+
"properties": {
|
|
66
|
+
"width": {
|
|
67
|
+
"type": "number",
|
|
68
|
+
"exclusiveMinimum": 0
|
|
69
|
+
},
|
|
70
|
+
"height": {
|
|
71
|
+
"type": "number",
|
|
72
|
+
"exclusiveMinimum": 0
|
|
73
|
+
},
|
|
74
|
+
"background": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"required": [
|
|
77
|
+
"image"
|
|
78
|
+
],
|
|
79
|
+
"properties": {
|
|
80
|
+
"image": {
|
|
81
|
+
"type": "object"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"elements": {
|
|
86
|
+
"type": "array",
|
|
87
|
+
"items": {
|
|
88
|
+
"$ref": "#/$defs/element"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
package/dist/bin/gd-cli.js
CHANGED
|
@@ -13,30 +13,37 @@ let runtime;
|
|
|
13
13
|
let mapCliError;
|
|
14
14
|
let redact;
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
16
|
+
if (process.env.CLI_INTERNAL_HOST_DIAGNOSTIC === "1" && process.argv.length === 3 && process.argv[2] === "--version") {
|
|
17
|
+
await Promise.all([import("../src/telemetry/host-diagnostics.js"), import("../src/product/config.js")])
|
|
18
|
+
.then(([{ runHostDiagnosticReporter }, { gaodingProduct }]) => runHostDiagnosticReporter({ product: gaodingProduct }))
|
|
19
|
+
.catch(() => undefined);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// Register SIGINT before loading the CLI graph so a cold-start interrupt is
|
|
23
|
+
// converted into the same abort path as an interrupt during stdin reading.
|
|
24
|
+
const [cliModule, runtimeModule, errorsModule, redactModule] = await Promise.all([
|
|
25
|
+
import("../src/bootstrap/create-cli.js"),
|
|
26
|
+
import("../src/bootstrap/create-runtime.js"),
|
|
27
|
+
import("../src/cli/errors.js"),
|
|
28
|
+
import("../src/platform/redact.js")
|
|
29
|
+
]);
|
|
30
|
+
const { createCli, executeCli } = cliModule;
|
|
31
|
+
const { createProductionRuntime } = runtimeModule;
|
|
32
|
+
mapCliError = errorsModule.mapCliError;
|
|
33
|
+
redact = redactModule.redact;
|
|
34
|
+
runtime = createProductionRuntime();
|
|
35
|
+
const program = createCli(runtime, { signal: controller.signal });
|
|
36
|
+
process.exitCode = await executeCli({
|
|
37
|
+
program,
|
|
38
|
+
argv: process.argv.slice(2),
|
|
39
|
+
presenter: runtime.presenter,
|
|
40
|
+
signal: controller.signal,
|
|
41
|
+
telemetry: runtime.telemetry,
|
|
42
|
+
telemetrySink: runtime.telemetrySink,
|
|
43
|
+
updateNotification: runtime.updateNotification,
|
|
44
|
+
product: runtime.product
|
|
45
|
+
});
|
|
46
|
+
}
|
|
40
47
|
}
|
|
41
48
|
catch (error) {
|
|
42
49
|
const traceId = runtime?.telemetry.traceId ?? bootstrapTraceId;
|
package/dist/bin/insmind-cli.js
CHANGED
|
@@ -15,30 +15,37 @@ let runtime;
|
|
|
15
15
|
let mapCliError;
|
|
16
16
|
let redact;
|
|
17
17
|
try {
|
|
18
|
-
|
|
19
|
-
import("../src/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
if (process.env.CLI_INTERNAL_HOST_DIAGNOSTIC === "1" && process.argv.length === 3 && process.argv[2] === "--version") {
|
|
19
|
+
await import("../src/telemetry/host-diagnostics.js")
|
|
20
|
+
.then(({ runHostDiagnosticReporter }) => runHostDiagnosticReporter({ product: insmindProduct }))
|
|
21
|
+
.catch(() => undefined);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const [cliModule, runtimeModule, errorsModule, redactModule] = await Promise.all([
|
|
25
|
+
import("../src/bootstrap/create-cli.js"),
|
|
26
|
+
import("../src/bootstrap/create-runtime.js"),
|
|
27
|
+
import("../src/cli/errors.js"),
|
|
28
|
+
import("../src/platform/redact.js")
|
|
29
|
+
]);
|
|
30
|
+
mapCliError = errorsModule.mapCliError;
|
|
31
|
+
redact = redactModule.redact;
|
|
32
|
+
const selectedLocale = localeOption(process.argv.slice(2));
|
|
33
|
+
runtime = runtimeModule.createProductionRuntime({
|
|
34
|
+
product: insmindProduct,
|
|
35
|
+
...(selectedLocale === undefined ? {} : { locale: selectedLocale })
|
|
36
|
+
});
|
|
37
|
+
const program = cliModule.createCli(runtime, { signal: controller.signal });
|
|
38
|
+
process.exitCode = await cliModule.executeCli({
|
|
39
|
+
program,
|
|
40
|
+
argv: process.argv.slice(2),
|
|
41
|
+
presenter: runtime.presenter,
|
|
42
|
+
signal: controller.signal,
|
|
43
|
+
telemetry: runtime.telemetry,
|
|
44
|
+
telemetrySink: runtime.telemetrySink,
|
|
45
|
+
updateNotification: runtime.updateNotification,
|
|
46
|
+
product: runtime.product
|
|
47
|
+
});
|
|
48
|
+
}
|
|
42
49
|
}
|
|
43
50
|
catch (error) {
|
|
44
51
|
const traceId = runtime?.telemetry.traceId ?? bootstrapTraceId;
|
package/dist/bin/task-worker.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { reportProcessError } from "../src/telemetry/process-errors.js";
|
|
3
3
|
import { once } from "node:events";
|
|
4
4
|
import { Readable } from "node:stream";
|
|
5
|
+
import { taskWorkerUnavailableError } from "../src/features/task/task-background.js";
|
|
5
6
|
import { gaodingProduct, insmindProduct } from "../src/product/config.js";
|
|
6
7
|
import { createProductionRuntime } from "../src/bootstrap/create-runtime.js";
|
|
7
8
|
import { runTaskWorker } from "../src/bootstrap/run-task-worker.js";
|
|
@@ -42,7 +43,9 @@ else {
|
|
|
42
43
|
...(currentJob?.telemetryTrackingUrl ? { trackingUrl: new URL(currentJob.telemetryTrackingUrl) } : {}),
|
|
43
44
|
...(currentJob?.telemetryEnvironment ? { environment: currentJob.telemetryEnvironment } : {}),
|
|
44
45
|
...(currentJob?.homeDirectory ? { homeDirectory: currentJob.homeDirectory } : {}) });
|
|
45
|
-
|
|
46
|
+
const unavailable = taskWorkerUnavailableError({ product: currentJob?.product === "insmind" ? "insmind" : "gaoding",
|
|
47
|
+
phase: "bootstrap", cause: error, pid: process.pid });
|
|
48
|
+
send({ type: "error", failure: unavailable.failure, ...(unavailable.diagnostics ? { diagnostics: unavailable.diagnostics } : {}), exitCode: 1 });
|
|
46
49
|
process.exitCode = 1;
|
|
47
50
|
}
|
|
48
51
|
finally {
|
|
@@ -3,7 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { withFileLock } from "../platform/file-lock.js";
|
|
4
4
|
import { createLocalJsonFile } from "../platform/local-json-file.js";
|
|
5
5
|
export async function loadAnalyticsDevice(directory, now) {
|
|
6
|
-
const file = createLocalJsonFile({ directory, filename: "analytics-device.json" });
|
|
6
|
+
const file = createLocalJsonFile({ directory, filename: "analytics-device.json", role: "analytics_device" });
|
|
7
7
|
async function read() {
|
|
8
8
|
const text = await file.readText();
|
|
9
9
|
if (text !== null) {
|
|
@@ -26,7 +26,7 @@ export async function loadAnalyticsDevice(directory, now) {
|
|
|
26
26
|
const device = { id: randomUUID(), createdAt: now() };
|
|
27
27
|
await file.writeTextAtomically(`${JSON.stringify(device)}\n`);
|
|
28
28
|
return device;
|
|
29
|
-
});
|
|
29
|
+
}, { action: "analytics_device" });
|
|
30
30
|
}
|
|
31
31
|
export function isFirstDay(createdAt, now) {
|
|
32
32
|
return new Date(createdAt).setHours(23, 59, 59, 999) >= now ? 1 : 0;
|
|
@@ -66,6 +66,12 @@ export function createCli(runtime, options) {
|
|
|
66
66
|
}
|
|
67
67
|
export async function executeCli(options) {
|
|
68
68
|
let helpOnly = false;
|
|
69
|
+
// Commander handles version before action selection. Preserve the real
|
|
70
|
+
// operation if writing that version to a closed host pipe fails.
|
|
71
|
+
if (options.argv.some(argument => argument === "--version" || argument === "-V")
|
|
72
|
+
&& options.argv.every(argument => ["--version", "-V", "--json-errors"].includes(argument))) {
|
|
73
|
+
options.telemetry.select({ operation: "version" });
|
|
74
|
+
}
|
|
69
75
|
try {
|
|
70
76
|
try {
|
|
71
77
|
await options.program.parseAsync(options.argv, { from: "user" });
|
|
@@ -157,6 +163,7 @@ async function checkUpdateNotification(updateNotification, signal) {
|
|
|
157
163
|
}
|
|
158
164
|
async function sendFinished(options, completion) {
|
|
159
165
|
await analyticsShutdown.get(options.program)?.().catch(() => undefined);
|
|
166
|
+
await options.telemetrySink.refreshDiagnostics?.().catch(() => undefined);
|
|
160
167
|
options.telemetry.annotate(options.telemetrySink.diagnostics?.() ?? {});
|
|
161
168
|
const events = options.telemetry.finish(completion);
|
|
162
169
|
if (events.length > 0)
|