@insmind/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.
Files changed (31) hide show
  1. package/dist/src/bootstrap/create-cli.js +3 -1
  2. package/dist/src/bootstrap/create-runtime.js +24 -12
  3. package/dist/src/bootstrap/run-task-worker.js +2 -2
  4. package/dist/src/bootstrap/validators.js +1 -1
  5. package/dist/src/cli/action-binding.js +3 -0
  6. package/dist/src/cli/errors.js +77 -24
  7. package/dist/src/cli/model-commands.js +1 -1
  8. package/dist/src/cli/observed-errors.js +118 -0
  9. package/dist/src/cli/task-commands.js +1 -1
  10. package/dist/src/cli/tool-commands.js +1 -1
  11. package/dist/src/features/auth/sso-service.js +13 -4
  12. package/dist/src/features/dam/dam-api-adapter.js +1 -0
  13. package/dist/src/features/dam/file-downloader.js +23 -2
  14. package/dist/src/features/task/creation-refusal.js +14 -10
  15. package/dist/src/features/task/store.js +10 -4
  16. package/dist/src/features/task/use-cases.js +45 -16
  17. package/dist/src/features/tool/dynamic-schema.js +4 -1
  18. package/dist/src/features/tool/tool-api-adapter.js +42 -33
  19. package/dist/src/features/update/update-service.js +4 -2
  20. package/dist/src/platform/file-lock.js +12 -0
  21. package/dist/src/platform/local-json-file.js +19 -5
  22. package/dist/src/platform/remote-error-evidence.js +13 -1
  23. package/dist/src/platform/remote-protocol.js +1 -1
  24. package/dist/src/platform/safe-upload-file.js +18 -10
  25. package/dist/src/platform/schema-issues.js +47 -2
  26. package/dist/src/platform/signed-http-transport.js +1 -1
  27. package/dist/src/platform/text-output.js +17 -4
  28. package/dist/src/telemetry/failure-summary.js +18 -0
  29. package/package.json +4 -4
  30. package/skills/insmind-cli/references/errors.md +3 -1
  31. package/skills/insmind-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 => { stream.write(text); }, flush: async () => { }
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": "@insmind/cli",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "insMind command-line interface for agents and people.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,8 +46,8 @@
46
46
  "@gaoding/cli": "workspace:*"
47
47
  },
48
48
  "gaodingRelease": {
49
- "sourceCommit": "c1f9db85d5bf4c74b6b808bad8119c9c50b50970",
50
- "pipelineId": "226274",
51
- "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/226274"
49
+ "sourceCommit": "d1722afac1b5acdc776ee3fbc2f2d69496e1a8af",
50
+ "pipelineId": "230438",
51
+ "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/230438"
52
52
  }
53
53
  }
@@ -6,7 +6,7 @@
6
6
  - Exit `1`: runtime, service or state failure. Follow explicit `error.details.next_steps`; if none are provided, stop and report.
7
7
  - Exit `2`: command or argument error. Read the command's `--help` and correct the invocation.
8
8
  - Exit `130`: user interruption. Stop immediately; do not retry automatically.
9
- - `INSUFFICIENT_CREDITS`: follow `error.details.next_steps`, direct the user to https://www.insmind.com/pricing, and submit again only after credits are available. Use `insmind-cli credits` to inspect the balance.
9
+ - `INSUFFICIENT_CREDITS` only means available credits were insufficient for this operation. It does not distinguish account balance, member limits or other charging restrictions. Do not automatically recommend a purchase or treat a balance check or price quote as a guarantee that charging will succeed.
10
10
 
11
11
  ## Missing creation output
12
12
 
@@ -24,6 +24,8 @@ Use a known ID directly. Otherwise locate the task by time, operation and input
24
24
  - `unknown`: completion is unconfirmed. Recheck the same ID; explain if it remains unknown. `partialResult` is a message snapshot, not a complete deliverable.
25
25
  - `failed`: report `note` and the original error; do not resubmit automatically.
26
26
 
27
+ A query error, including a task-not-found response, does not mean the original creation failed. Keep the original task ID; do not generate again.
28
+
27
29
  Exit `0` from `task get` means the query succeeded; `state` determines whether the creation completed. Repeated reads of one ID return the same usage, which must not be added again. Do not resume waiting or resubmit after a user interruption.
28
30
 
29
31
  Do not infer internal causes from unknown errors or disclose local credentials, request signatures or sensitive URL query values. If safe recovery steps are absent, preserve the public error code from stderr and explain the failure.
@@ -14,7 +14,7 @@ insmind-cli task get <taskId>
14
14
 
15
15
  `tool list` lists available Tools. Model discovery provides current descriptions, prices, estimated duration and structured parameters. Follow each parameter's `required`, `type` and `description`; for SELECT parameters use `options[].value`. Explicitly supply a required parameter's `default` when the user did not specify it. Read `usageDescription` for combinations such as video mode and frame/media requirements; individual fields cannot establish these rules. Do not freeze catalog values in prompts or scripts.
16
16
 
17
- Provide all required fields. Put width, height, resolution and similar requirements in dedicated structured parameters when available, rather than only in prompt text. `tool call <tool> --schema` is the parameter union of all models in the Tool; after selecting a model, use its `model get` parameters and `usageDescription`.
17
+ Provide all required fields. Put width, height, resolution and similar requirements in dedicated structured parameters when available, rather than only in prompt text. `tool call <tool> --schema` selects required fields, allowed parameters and ranges by model. Use `model get` for step, defaults and cross-field rules in `usageDescription`. Fixed JSON commands also accept `--json`.
18
18
 
19
19
  Copy the returned `model` identifier into the top-level `model` field of request JSON (runtime `arguments.model`), alongside its parameters:
20
20