@insmind/cli 2.0.0 → 2.1.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.
Files changed (113) hide show
  1. package/README.md +5 -0
  2. package/contracts/operations/agent.send/input.schema.json +1 -77
  3. package/contracts/operations/credits.get/input.schema.json +8 -0
  4. package/contracts/operations/credits.get/output.schema.json +92 -0
  5. package/contracts/operations/credits.usage.get/input.schema.json +17 -0
  6. package/contracts/operations/credits.usage.get/output.schema.json +46 -0
  7. package/contracts/operations/credits.usage.list/input.schema.json +27 -0
  8. package/contracts/operations/credits.usage.list/output.schema.json +135 -0
  9. package/contracts/operations/dam.folder.list/input.schema.json +0 -1
  10. package/contracts/operations/dam.folder.list/output.schema.json +1 -2
  11. package/contracts/operations/dam.list/input.schema.json +3 -6
  12. package/contracts/operations/dam.list/output.schema.json +1 -2
  13. package/contracts/operations/dam.search/input.schema.json +3 -6
  14. package/contracts/operations/dam.search/output.schema.json +1 -2
  15. package/contracts/operations/tool.call/models/image-edit-smart.schema.json +1 -2
  16. package/contracts/operations/tool.call/models/image-expand-smart.schema.json +1 -2
  17. package/contracts/operations/tool.call/models/image-layers-smart.schema.json +1 -3
  18. package/contracts/operations/tool.call/models/video-edit-smart.schema.json +0 -3
  19. package/contracts/operations/tool.call/ocr-payload.schema.json +4 -5
  20. package/dist/bin/postinstall.js +22 -6
  21. package/dist/bin/task-worker.js +2 -2
  22. package/dist/src/bootstrap/create-cli.js +31 -15
  23. package/dist/src/bootstrap/create-runtime.js +103 -30
  24. package/dist/src/bootstrap/run-task-worker.js +6 -2
  25. package/dist/src/bootstrap/validators.js +4 -1
  26. package/dist/src/cli/action-binding.js +17 -50
  27. package/dist/src/cli/agent-commands.js +11 -11
  28. package/dist/src/cli/auth-commands.js +2 -1
  29. package/dist/src/cli/creation-help.js +9 -0
  30. package/dist/src/cli/credits-command.js +127 -16
  31. package/dist/src/cli/dam-commands.js +10 -14
  32. package/dist/src/cli/editor-commands.js +7 -5
  33. package/dist/src/cli/errors.js +81 -22
  34. package/dist/src/cli/host-input.js +64 -5
  35. package/dist/src/cli/model-commands.js +9 -3
  36. package/dist/src/cli/observed-errors.js +7 -3
  37. package/dist/src/cli/org-commands.js +3 -1
  38. package/dist/src/cli/presenter.js +4 -0
  39. package/dist/src/cli/task-commands.js +6 -2
  40. package/dist/src/cli/tool-commands.js +12 -11
  41. package/dist/src/cli/update-command.js +24 -1
  42. package/dist/src/features/agent/creative-agent-adapter.js +6 -2
  43. package/dist/src/features/agent/creative-protocol.js +8 -29
  44. package/dist/src/features/agent/resource-authorizer.js +25 -17
  45. package/dist/src/features/agent/result-reader.js +31 -14
  46. package/dist/src/features/agent/use-cases.js +6 -31
  47. package/dist/src/features/credits/amount.js +51 -0
  48. package/dist/src/features/credits/response.js +11 -0
  49. package/dist/src/features/credits/use-cases.js +200 -30
  50. package/dist/src/features/dam/asset-projection.js +3 -6
  51. package/dist/src/features/dam/dam-api-adapter.js +30 -15
  52. package/dist/src/features/dam/repository-catalog.js +30 -21
  53. package/dist/src/features/dam/use-cases.js +12 -7
  54. package/dist/src/features/editor/bridge-client.js +0 -2
  55. package/dist/src/features/editor/public-url.js +1 -36
  56. package/dist/src/features/editor/session.js +3 -2
  57. package/dist/src/features/editor/use-cases.js +27 -2
  58. package/dist/src/features/org/org-service.js +10 -1
  59. package/dist/src/features/org/use-cases.js +18 -4
  60. package/dist/src/features/task/process-owner.js +54 -0
  61. package/dist/src/features/task/store.js +37 -10
  62. package/dist/src/features/task/task-background.js +5 -2
  63. package/dist/src/features/task/use-cases.js +184 -84
  64. package/dist/src/features/tool/argument-paths.js +14 -0
  65. package/dist/src/features/tool/canvas-copy.js +28 -15
  66. package/dist/src/features/tool/canvas-matting.js +123 -0
  67. package/dist/src/features/tool/canvas-media.js +100 -52
  68. package/dist/src/features/tool/canvas-models.js +66 -33
  69. package/dist/src/features/tool/canvas-pricing.js +12 -0
  70. package/dist/src/features/tool/canvas-recovery.js +13 -30
  71. package/dist/src/features/tool/canvas-results.js +79 -87
  72. package/dist/src/features/tool/canvas-tool-adapter.js +134 -157
  73. package/dist/src/features/tool/canvas-video.js +44 -37
  74. package/dist/src/features/tool/dynamic-schema.js +39 -40
  75. package/dist/src/features/tool/ffprobe-executable.js +21 -0
  76. package/dist/src/features/tool/mns-catalog-adapter.js +61 -24
  77. package/dist/src/features/tool/resource-authorizer.js +11 -3
  78. package/dist/src/features/tool/tool-api-adapter.js +73 -82
  79. package/dist/src/features/tool/tool-errors.js +25 -0
  80. package/dist/src/features/tool/tool-output.js +15 -0
  81. package/dist/src/features/tool/use-cases.js +74 -98
  82. package/dist/src/features/update/check-schema.js +17 -0
  83. package/dist/src/features/update/host-receipt.js +30 -0
  84. package/dist/src/features/update/notice-output.js +30 -0
  85. package/dist/src/features/update/update-lock.js +80 -0
  86. package/dist/src/features/update/update-notification.js +129 -240
  87. package/dist/src/features/update/update-service.js +95 -21
  88. package/dist/src/platform/media-type.js +46 -0
  89. package/dist/src/platform/public-url.js +35 -0
  90. package/dist/src/platform/remote-error-evidence.js +33 -6
  91. package/dist/src/platform/resource-auth-key.js +35 -1
  92. package/dist/src/platform/safe-upload-file.js +36 -41
  93. package/dist/src/platform/signature.js +3 -1
  94. package/dist/src/platform/signed-http-transport.js +14 -6
  95. package/dist/src/platform/url-safety.js +6 -1
  96. package/dist/src/platform/webm-header.js +41 -0
  97. package/dist/src/telemetry/command-route.js +38 -0
  98. package/dist/src/telemetry/command-routes.json +1 -0
  99. package/dist/src/telemetry/failure-summary.js +1 -1
  100. package/dist/src/telemetry/invocation.js +1 -2
  101. package/dist/src/telemetry/process-errors.js +17 -33
  102. package/dist/src/telemetry/sanitize.js +19 -4
  103. package/dist/src/telemetry/sls-sink.js +8 -0
  104. package/package.json +4 -4
  105. package/skills/insmind-cli/SKILL.md +19 -5
  106. package/skills/insmind-cli/references/agent.md +9 -4
  107. package/skills/insmind-cli/references/creation.md +3 -1
  108. package/skills/insmind-cli/references/editor.md +7 -5
  109. package/skills/insmind-cli/references/errors.md +20 -9
  110. package/skills/insmind-cli/references/matting.md +3 -5
  111. package/skills/insmind-cli/references/media-tools.md +10 -4
  112. package/skills/insmind-cli/references/tool.md +9 -15
  113. package/skills/insmind-cli/references/update.md +2 -0
package/README.md CHANGED
@@ -7,8 +7,13 @@ npm install --global --allow-scripts=@insmind/cli @insmind/cli
7
7
  insmind-cli auth login
8
8
  insmind-cli --help
9
9
  insmind-cli editor apply --schema
10
+ insmind-cli credits --json
11
+ insmind-cli credits usage list --help
12
+ insmind-cli credits usage get --schema
10
13
  ```
11
14
 
12
15
  Requires Node.js 20 or newer. Credentials and local runtime state are stored separately from GaoDing CLI under `~/.insmind`.
13
16
 
17
+ `credits` reads the current balance; `credits usage list` returns one page of consumption, restoration, recycling and expiry records. `credits usage get <record-id>` reads source breakdown. Each supports offline `--schema` discovery without login. Records default to the current UTC month. Continue using the returned range and `nextCursor`; a page is not a complete spending total. Member period limits are shown separately from the overview balance.
18
+
14
19
  Discover command behavior with `--help`, structured input through supported `--schema` modes, and live model parameters through `model list` and `model get`. `editor apply --schema` reads the installed Action contract without login or an Editor connection; it cannot be combined with execution via `--input`.
@@ -75,30 +75,6 @@
75
75
  }
76
76
  }
77
77
  },
78
- {
79
- "properties": {
80
- "parts": {
81
- "type": "array",
82
- "contains": {
83
- "$ref": "#/$defs/FirstFramePart"
84
- },
85
- "minContains": 0,
86
- "maxContains": 1
87
- }
88
- }
89
- },
90
- {
91
- "properties": {
92
- "parts": {
93
- "type": "array",
94
- "contains": {
95
- "$ref": "#/$defs/LastFramePart"
96
- },
97
- "minContains": 0,
98
- "maxContains": 1
99
- }
100
- }
101
- },
102
78
  {
103
79
  "if": {
104
80
  "properties": {
@@ -191,7 +167,7 @@
191
167
  "properties": {
192
168
  "role": {
193
169
  "type": "string",
194
- "enum": [
170
+ "examples": [
195
171
  "reference",
196
172
  "first_frame",
197
173
  "last_frame"
@@ -278,58 +254,6 @@
278
254
  }
279
255
  }
280
256
  }
281
- },
282
- "FirstFramePart": {
283
- "allOf": [
284
- {
285
- "$ref": "#/$defs/InputAssetPart"
286
- },
287
- {
288
- "type": "object",
289
- "properties": {
290
- "metadata": {
291
- "type": "object",
292
- "properties": {
293
- "role": {
294
- "const": "first_frame"
295
- }
296
- },
297
- "required": [
298
- "role"
299
- ]
300
- }
301
- },
302
- "required": [
303
- "metadata"
304
- ]
305
- }
306
- ]
307
- },
308
- "LastFramePart": {
309
- "allOf": [
310
- {
311
- "$ref": "#/$defs/InputAssetPart"
312
- },
313
- {
314
- "type": "object",
315
- "properties": {
316
- "metadata": {
317
- "type": "object",
318
- "properties": {
319
- "role": {
320
- "const": "last_frame"
321
- }
322
- },
323
- "required": [
324
- "role"
325
- ]
326
- }
327
- },
328
- "required": [
329
- "metadata"
330
- ]
331
- }
332
- ]
333
257
  }
334
258
  }
335
259
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.insmind.com/operations/credits.get/input.schema.json",
4
+ "title": "CreditsGetInput",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "properties": {}
8
+ }
@@ -0,0 +1,92 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.insmind.com/operations/credits.get/output.schema.json",
4
+ "title": "CreditsResult",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "credits"
9
+ ],
10
+ "properties": {
11
+ "credits": {
12
+ "type": "object",
13
+ "additionalProperties": false,
14
+ "required": [
15
+ "unit",
16
+ "total",
17
+ "used",
18
+ "pending",
19
+ "available"
20
+ ],
21
+ "properties": {
22
+ "unit": {
23
+ "type": "string",
24
+ "const": "credit"
25
+ },
26
+ "total": {
27
+ "type": "number",
28
+ "minimum": 0,
29
+ "maximum": 9007199254740991
30
+ },
31
+ "used": {
32
+ "type": "number",
33
+ "minimum": 0,
34
+ "maximum": 9007199254740991
35
+ },
36
+ "pending": {
37
+ "type": "number",
38
+ "minimum": 0,
39
+ "maximum": 9007199254740991
40
+ },
41
+ "available": {
42
+ "type": "number",
43
+ "minimum": 0,
44
+ "maximum": 9007199254740991
45
+ }
46
+ }
47
+ },
48
+ "balances": {
49
+ "type": "array",
50
+ "items": {
51
+ "type": "object",
52
+ "additionalProperties": false,
53
+ "required": [
54
+ "total",
55
+ "used",
56
+ "pending",
57
+ "available"
58
+ ],
59
+ "properties": {
60
+ "identifier": {
61
+ "type": "string"
62
+ },
63
+ "total": {
64
+ "type": "number",
65
+ "minimum": 0,
66
+ "maximum": 9007199254740991
67
+ },
68
+ "used": {
69
+ "type": "number",
70
+ "minimum": 0,
71
+ "maximum": 9007199254740991
72
+ },
73
+ "pending": {
74
+ "type": "number",
75
+ "minimum": 0,
76
+ "maximum": 9007199254740991
77
+ },
78
+ "available": {
79
+ "type": "number",
80
+ "minimum": 0,
81
+ "maximum": 9007199254740991
82
+ },
83
+ "memberPeriodLimit": {
84
+ "type": "number",
85
+ "minimum": 0,
86
+ "maximum": 9007199254740991
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.insmind.com/operations/credits.usage.get/input.schema.json",
4
+ "title": "CreditsUsageGetInput",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "id"
9
+ ],
10
+ "properties": {
11
+ "id": {
12
+ "type": "string",
13
+ "minLength": 1,
14
+ "pattern": ".*\\S.*"
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.insmind.com/operations/credits.usage.get/output.schema.json",
4
+ "title": "CreditsUsageGetResult",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "id",
9
+ "unit",
10
+ "breakdown"
11
+ ],
12
+ "properties": {
13
+ "id": {
14
+ "type": "string",
15
+ "minLength": 1,
16
+ "pattern": ".*\\S.*"
17
+ },
18
+ "unit": {
19
+ "type": "string",
20
+ "const": "credit"
21
+ },
22
+ "breakdown": {
23
+ "type": "array",
24
+ "items": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "required": [
28
+ "amount"
29
+ ],
30
+ "properties": {
31
+ "amount": {
32
+ "type": "number",
33
+ "minimum": 0,
34
+ "maximum": 9007199254740991
35
+ },
36
+ "usageType": {
37
+ "type": "number"
38
+ },
39
+ "sourceType": {
40
+ "type": "string"
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.insmind.com/operations/credits.usage.list/input.schema.json",
4
+ "title": "CreditsUsageListInput",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "from": {
9
+ "type": "string",
10
+ "format": "date-time"
11
+ },
12
+ "to": {
13
+ "type": "string",
14
+ "format": "date-time"
15
+ },
16
+ "limit": {
17
+ "type": "integer",
18
+ "minimum": 1,
19
+ "default": 20
20
+ },
21
+ "cursor": {
22
+ "type": "string",
23
+ "minLength": 1,
24
+ "pattern": ".*\\S.*"
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,135 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.insmind.com/operations/credits.usage.list/output.schema.json",
4
+ "title": "CreditsUsageListResult",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "unit",
9
+ "range",
10
+ "items",
11
+ "hasMore",
12
+ "nextCursor"
13
+ ],
14
+ "properties": {
15
+ "unit": {
16
+ "type": "string",
17
+ "const": "credit"
18
+ },
19
+ "range": {
20
+ "type": "object",
21
+ "additionalProperties": false,
22
+ "required": [
23
+ "from",
24
+ "to"
25
+ ],
26
+ "properties": {
27
+ "from": {
28
+ "type": "string",
29
+ "format": "date-time"
30
+ },
31
+ "to": {
32
+ "type": "string",
33
+ "format": "date-time"
34
+ }
35
+ }
36
+ },
37
+ "items": {
38
+ "type": "array",
39
+ "items": {
40
+ "type": "object",
41
+ "additionalProperties": false,
42
+ "required": [
43
+ "id",
44
+ "changeType",
45
+ "amount",
46
+ "recordedAt"
47
+ ],
48
+ "properties": {
49
+ "id": {
50
+ "type": "string",
51
+ "minLength": 1,
52
+ "pattern": ".*\\S.*"
53
+ },
54
+ "changeType": {
55
+ "type": "string",
56
+ "minLength": 1,
57
+ "pattern": ".*\\S.*"
58
+ },
59
+ "amount": {
60
+ "type": "number",
61
+ "minimum": 0,
62
+ "maximum": 9007199254740991
63
+ },
64
+ "recordedAt": {
65
+ "type": "string",
66
+ "format": "date-time"
67
+ },
68
+ "recordMode": {
69
+ "type": "string"
70
+ },
71
+ "description": {
72
+ "type": "string"
73
+ },
74
+ "scene": {
75
+ "type": "number"
76
+ },
77
+ "referenceId": {
78
+ "type": "string"
79
+ },
80
+ "user": {
81
+ "type": "object",
82
+ "additionalProperties": false,
83
+ "properties": {
84
+ "id": {
85
+ "type": "string"
86
+ },
87
+ "name": {
88
+ "type": "string"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ },
95
+ "hasMore": {
96
+ "type": "boolean"
97
+ },
98
+ "nextCursor": {
99
+ "type": [
100
+ "string",
101
+ "null"
102
+ ]
103
+ }
104
+ },
105
+ "allOf": [
106
+ {
107
+ "if": {
108
+ "properties": {
109
+ "hasMore": {
110
+ "const": true
111
+ }
112
+ },
113
+ "required": [
114
+ "hasMore"
115
+ ]
116
+ },
117
+ "then": {
118
+ "properties": {
119
+ "nextCursor": {
120
+ "type": "string",
121
+ "minLength": 1,
122
+ "pattern": ".*\\S.*"
123
+ }
124
+ }
125
+ },
126
+ "else": {
127
+ "properties": {
128
+ "nextCursor": {
129
+ "type": "null"
130
+ }
131
+ }
132
+ }
133
+ }
134
+ ]
135
+ }
@@ -22,7 +22,6 @@
22
22
  "pageSize": {
23
23
  "type": "integer",
24
24
  "minimum": 1,
25
- "maximum": 100,
26
25
  "default": 20
27
26
  }
28
27
  },
@@ -24,8 +24,7 @@
24
24
  },
25
25
  "page_size": {
26
26
  "type": "integer",
27
- "minimum": 1,
28
- "maximum": 100
27
+ "minimum": 1
29
28
  },
30
29
  "total": {
31
30
  "type": "integer",
@@ -31,22 +31,19 @@
31
31
  },
32
32
  "assetFormats": {
33
33
  "type": "array",
34
- "minItems": 1,
35
34
  "items": {
36
- "$ref": "#/$defs/nonblank"
35
+ "type": "string"
37
36
  }
38
37
  },
39
38
  "tagIds": {
40
39
  "type": "array",
41
- "minItems": 1,
42
40
  "items": {
43
- "$ref": "#/$defs/nonblank"
41
+ "type": "string"
44
42
  }
45
43
  },
46
44
  "pageSize": {
47
45
  "type": "integer",
48
- "minimum": 1,
49
- "maximum": 100
46
+ "minimum": 1
50
47
  },
51
48
  "cursor": {
52
49
  "$ref": "#/$defs/nonblank"
@@ -20,8 +20,7 @@
20
20
  },
21
21
  "page_size": {
22
22
  "type": "integer",
23
- "minimum": 1,
24
- "maximum": 100
23
+ "minimum": 1
25
24
  },
26
25
  "total": {
27
26
  "type": "integer",
@@ -37,22 +37,19 @@
37
37
  },
38
38
  "assetFormats": {
39
39
  "type": "array",
40
- "minItems": 1,
41
40
  "items": {
42
- "$ref": "#/$defs/nonblank"
41
+ "type": "string"
43
42
  }
44
43
  },
45
44
  "tagIds": {
46
45
  "type": "array",
47
- "minItems": 1,
48
46
  "items": {
49
- "$ref": "#/$defs/nonblank"
47
+ "type": "string"
50
48
  }
51
49
  },
52
50
  "pageSize": {
53
51
  "type": "integer",
54
- "minimum": 1,
55
- "maximum": 100
52
+ "minimum": 1
56
53
  },
57
54
  "cursor": {
58
55
  "$ref": "#/$defs/nonblank"
@@ -20,8 +20,7 @@
20
20
  },
21
21
  "page_size": {
22
22
  "type": "integer",
23
- "minimum": 1,
24
- "maximum": 100
23
+ "minimum": 1
25
24
  },
26
25
  "total": {
27
26
  "type": "integer",
@@ -32,8 +32,7 @@
32
32
  "type": "string",
33
33
  "format": "uri"
34
34
  },
35
- "minItems": 1,
36
- "uniqueItems": true
35
+ "minItems": 1
37
36
  }
38
37
  }
39
38
  }
@@ -65,8 +65,7 @@
65
65
  "type": "string",
66
66
  "format": "uri"
67
67
  },
68
- "minItems": 1,
69
- "uniqueItems": true
68
+ "minItems": 1
70
69
  }
71
70
  }
72
71
  }
@@ -18,9 +18,7 @@
18
18
  "format": "uri"
19
19
  },
20
20
  "maxLayers": {
21
- "type": "integer",
22
- "minimum": 1,
23
- "maximum": 17
21
+ "type": "integer"
24
22
  }
25
23
  }
26
24
  }
@@ -41,7 +41,6 @@
41
41
  "format": "uri"
42
42
  },
43
43
  "minItems": 1,
44
- "uniqueItems": true,
45
44
  "maxItems": 10
46
45
  },
47
46
  "referenceVideos": {
@@ -51,7 +50,6 @@
51
50
  "format": "uri"
52
51
  },
53
52
  "minItems": 1,
54
- "uniqueItems": true,
55
53
  "maxItems": 4
56
54
  },
57
55
  "referenceAudios": {
@@ -61,7 +59,6 @@
61
59
  "format": "uri"
62
60
  },
63
61
  "minItems": 1,
64
- "uniqueItems": true,
65
62
  "maxItems": 5
66
63
  }
67
64
  }
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "title": "OcrPayload",
4
4
  "type": "object",
5
- "additionalProperties": false,
5
+ "additionalProperties": true,
6
6
  "required": [
7
7
  "image",
8
8
  "blocks"
@@ -10,7 +10,7 @@
10
10
  "properties": {
11
11
  "image": {
12
12
  "type": "object",
13
- "additionalProperties": false,
13
+ "additionalProperties": true,
14
14
  "required": [
15
15
  "uri",
16
16
  "width",
@@ -35,7 +35,7 @@
35
35
  "type": "array",
36
36
  "items": {
37
37
  "type": "object",
38
- "additionalProperties": false,
38
+ "additionalProperties": true,
39
39
  "required": [
40
40
  "bbox",
41
41
  "category"
@@ -46,8 +46,7 @@
46
46
  "minItems": 4,
47
47
  "maxItems": 4,
48
48
  "items": {
49
- "type": "number",
50
- "minimum": 0
49
+ "type": "number"
51
50
  }
52
51
  },
53
52
  "category": {
@@ -1,7 +1,8 @@
1
1
  import { reportProcessError } from "../src/telemetry/process-errors.js";
2
2
  import { cleanText } from "../src/telemetry/sanitize.js";
3
3
  import { fileURLToPath } from "node:url";
4
- import { dirname, resolve } from "node:path";
4
+ import { existsSync, realpathSync, statSync } from "node:fs";
5
+ import { dirname, join, resolve } from "node:path";
5
6
  import { loadBundledSkills } from "../src/features/skill/bundled-skills.js";
6
7
  import { syncBundledSkills } from "../src/features/skill/installer.js";
7
8
  import { markWorkBuddyInstallation, readInstallationOwner } from "../src/platform/installation-owner.js";
@@ -12,11 +13,26 @@ export function isSupportedGlobalLifecycle(env) {
12
13
  return /^(?:npm|pnpm)\//u.test(userAgent);
13
14
  }
14
15
  const initialDirectory = (env.INIT_CWD ?? "").replace(/\\/gu, "/");
15
- return userAgent.startsWith("pnpm/")
16
- && env.npm_command === "add"
17
- && env.npm_lifecycle_event === "postinstall"
18
- && (env.npm_package_name === "@gaoding/cli" || env.npm_package_name === "@insmind/cli")
19
- && /\/v\d+\/[0-9a-f]+-[0-9a-f]+-[0-9a-f]{16}$/u.test(initialDirectory);
16
+ const name = env.npm_package_name;
17
+ if (!userAgent.startsWith("pnpm/") || env.npm_command !== "add" || env.npm_lifecycle_event !== "postinstall"
18
+ || (name !== "@gaoding/cli" && name !== "@insmind/cli"))
19
+ return false;
20
+ if (/\/v\d+\/[0-9a-f]+-[0-9a-f]+-[0-9a-f]{16}$/u.test(initialDirectory))
21
+ return true;
22
+ // pnpm 12 runs postinstall before publishing its global launcher. Its staging
23
+ // directory has no consumer manifest and links directly to the package being built.
24
+ if (!/\/v\d+\/[0-9a-f]+-[0-9a-f]{16}-\d+$/u.test(initialDirectory)
25
+ || !env.npm_package_json || !env.PNPM_SCRIPT_SRC_DIR)
26
+ return false;
27
+ try {
28
+ return !existsSync(join(initialDirectory, "package.json"))
29
+ && statSync(join(dirname(initialDirectory), "pnpm-workspace.yaml")).isFile()
30
+ && realpathSync(join(initialDirectory, "node_modules", name, "package.json")) === realpathSync(env.npm_package_json)
31
+ && realpathSync(join(env.PNPM_SCRIPT_SRC_DIR, "package.json")) === realpathSync(env.npm_package_json);
32
+ }
33
+ catch {
34
+ return false;
35
+ }
20
36
  }
21
37
  export async function runPostinstall(options = {}) {
22
38
  const startedAt = Date.now();