@kashdao/cli 0.1.0 → 0.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 (80) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +13 -14
  3. package/dist/{account-AVFLEM5D.js → account-CVJZ3HVT.js} +9 -9
  4. package/dist/{auth-GUJCVKTD.js → auth-V5WVZBCO.js} +9 -9
  5. package/dist/auth-V5WVZBCO.js.map +1 -0
  6. package/dist/{chunk-LBIRQHX5.js → chunk-A3IH5HUV.js} +3 -3
  7. package/dist/{chunk-YHCG2SUC.js → chunk-BVFDUI73.js} +2 -2
  8. package/dist/{chunk-MIXOZU2S.js → chunk-KADB3OKE.js} +2 -2
  9. package/dist/chunk-KAM6KOFD.js +9 -0
  10. package/dist/{chunk-BN2CUM42.js.map → chunk-KAM6KOFD.js.map} +1 -1
  11. package/dist/{chunk-YJX3JJ4M.js → chunk-L4AFV2HK.js} +3 -3
  12. package/dist/{chunk-VIADBYFY.js → chunk-MQUJG224.js} +2 -2
  13. package/dist/{chunk-KMBMQIZ7.js → chunk-N26VGVGB.js} +3 -3
  14. package/dist/{chunk-KMBMQIZ7.js.map → chunk-N26VGVGB.js.map} +1 -1
  15. package/dist/{chunk-QJMF73M5.js → chunk-QALDZHTX.js} +5 -5
  16. package/dist/{chunk-BRK7KJ4O.js → chunk-R4NGUZKN.js} +2 -2
  17. package/dist/{chunk-UZNSYATZ.js → chunk-X2VM6VKM.js} +7 -7
  18. package/dist/chunk-X2VM6VKM.js.map +1 -0
  19. package/dist/client-75FVHGOH.js +14 -0
  20. package/dist/{completion-ZZGX5BQC.js → completion-PK74S3EZ.js} +4 -4
  21. package/dist/{config-XJL5TSYK.js → config-T5U6E6KU.js} +8 -8
  22. package/dist/{config-store-3ZSYGXMQ.js → config-store-UTFDUCKW.js} +4 -4
  23. package/dist/{docs-MDKKSJDC.js → docs-VA7CJ2ZF.js} +5 -5
  24. package/dist/{eoa-IQ72EIHR.js → eoa-RL3NLN3H.js} +9 -9
  25. package/dist/{errors-WMZIEGQI.js → errors-2NNXRNES.js} +2 -2
  26. package/dist/{explain-H4EH3KH3.js → explain-3SPMWDYX.js} +7 -7
  27. package/dist/{explain-H4EH3KH3.js.map → explain-3SPMWDYX.js.map} +1 -1
  28. package/dist/{global-options-XOLJUPTT.js → global-options-WFQ6CEFK.js} +4 -4
  29. package/dist/{health-VZEIII74.js → health-2KD6XUTJ.js} +10 -10
  30. package/dist/health-2KD6XUTJ.js.map +1 -0
  31. package/dist/index.js +27 -27
  32. package/dist/{markets-C37JZDPE.js → markets-H6EK2XDE.js} +10 -10
  33. package/dist/{output-VCBZ3FM7.js → output-FGTXXZEQ.js} +4 -4
  34. package/dist/{portfolio-2AEPIJIG.js → portfolio-R63D5QB2.js} +10 -10
  35. package/dist/{protocol-XEQXF2GW.js → protocol-ZB6R25IM.js} +9 -9
  36. package/dist/{quote-I4DVJ7ZB.js → quote-OF6BTAPQ.js} +10 -10
  37. package/dist/{schema-PIFQ65TS.js → schema-3HQN4RFL.js} +6 -6
  38. package/dist/{setup-USZ6IODD.js → setup-IIPQXLPL.js} +12 -12
  39. package/dist/setup-IIPQXLPL.js.map +1 -0
  40. package/dist/{trace-IZBYTUFO.js → trace-WMO3KDHS.js} +10 -10
  41. package/dist/{trade-IIZSEXEI.js → trade-YBCI6XD2.js} +10 -10
  42. package/dist/{version-JDK3PEP5.js → version-WB2ACHMU.js} +7 -7
  43. package/dist/{version-check-TDCION37.js → version-check-PRAVPFC6.js} +4 -4
  44. package/dist/{webhooks-PTVRKICZ.js → webhooks-DVS55O4T.js} +10 -10
  45. package/dist/{with-retry-4FIZG3A7.js → with-retry-2MD2CNK2.js} +5 -5
  46. package/package.json +3 -3
  47. package/dist/auth-GUJCVKTD.js.map +0 -1
  48. package/dist/chunk-BN2CUM42.js +0 -9
  49. package/dist/chunk-UZNSYATZ.js.map +0 -1
  50. package/dist/client-IOM55ZCS.js +0 -14
  51. package/dist/health-VZEIII74.js.map +0 -1
  52. package/dist/setup-USZ6IODD.js.map +0 -1
  53. /package/dist/{account-AVFLEM5D.js.map → account-CVJZ3HVT.js.map} +0 -0
  54. /package/dist/{chunk-LBIRQHX5.js.map → chunk-A3IH5HUV.js.map} +0 -0
  55. /package/dist/{chunk-YHCG2SUC.js.map → chunk-BVFDUI73.js.map} +0 -0
  56. /package/dist/{chunk-MIXOZU2S.js.map → chunk-KADB3OKE.js.map} +0 -0
  57. /package/dist/{chunk-YJX3JJ4M.js.map → chunk-L4AFV2HK.js.map} +0 -0
  58. /package/dist/{chunk-VIADBYFY.js.map → chunk-MQUJG224.js.map} +0 -0
  59. /package/dist/{chunk-QJMF73M5.js.map → chunk-QALDZHTX.js.map} +0 -0
  60. /package/dist/{chunk-BRK7KJ4O.js.map → chunk-R4NGUZKN.js.map} +0 -0
  61. /package/dist/{client-IOM55ZCS.js.map → client-75FVHGOH.js.map} +0 -0
  62. /package/dist/{completion-ZZGX5BQC.js.map → completion-PK74S3EZ.js.map} +0 -0
  63. /package/dist/{config-XJL5TSYK.js.map → config-T5U6E6KU.js.map} +0 -0
  64. /package/dist/{config-store-3ZSYGXMQ.js.map → config-store-UTFDUCKW.js.map} +0 -0
  65. /package/dist/{docs-MDKKSJDC.js.map → docs-VA7CJ2ZF.js.map} +0 -0
  66. /package/dist/{eoa-IQ72EIHR.js.map → eoa-RL3NLN3H.js.map} +0 -0
  67. /package/dist/{errors-WMZIEGQI.js.map → errors-2NNXRNES.js.map} +0 -0
  68. /package/dist/{global-options-XOLJUPTT.js.map → global-options-WFQ6CEFK.js.map} +0 -0
  69. /package/dist/{markets-C37JZDPE.js.map → markets-H6EK2XDE.js.map} +0 -0
  70. /package/dist/{output-VCBZ3FM7.js.map → output-FGTXXZEQ.js.map} +0 -0
  71. /package/dist/{portfolio-2AEPIJIG.js.map → portfolio-R63D5QB2.js.map} +0 -0
  72. /package/dist/{protocol-XEQXF2GW.js.map → protocol-ZB6R25IM.js.map} +0 -0
  73. /package/dist/{quote-I4DVJ7ZB.js.map → quote-OF6BTAPQ.js.map} +0 -0
  74. /package/dist/{schema-PIFQ65TS.js.map → schema-3HQN4RFL.js.map} +0 -0
  75. /package/dist/{trace-IZBYTUFO.js.map → trace-WMO3KDHS.js.map} +0 -0
  76. /package/dist/{trade-IIZSEXEI.js.map → trade-YBCI6XD2.js.map} +0 -0
  77. /package/dist/{version-JDK3PEP5.js.map → version-WB2ACHMU.js.map} +0 -0
  78. /package/dist/{version-check-TDCION37.js.map → version-check-PRAVPFC6.js.map} +0 -0
  79. /package/dist/{webhooks-PTVRKICZ.js.map → webhooks-DVS55O4T.js.map} +0 -0
  80. /package/dist/{with-retry-4FIZG3A7.js.map → with-retry-2MD2CNK2.js.map} +0 -0
@@ -43,8 +43,8 @@ var ERROR_CATALOG = [
43
43
  },
44
44
  {
45
45
  type: "open_url",
46
- url: "mailto:engineering@kash.bot?subject=Kash%20staging%20API%20key%20request",
47
- description: "Email `engineering@kash.bot` to request a `kash_test_*` staging key (self-service issuance ships with the production launch)."
46
+ url: "https://app.kash.bot",
47
+ description: "Create an API key under Settings \u2192 API Keys in the Kash app (`Live` for Base mainnet, `Test` for Base Sepolia)."
48
48
  }
49
49
  ]
50
50
  },
@@ -57,8 +57,8 @@ var ERROR_CATALOG = [
57
57
  actions: [
58
58
  {
59
59
  type: "open_url",
60
- url: "mailto:engineering@kash.bot?subject=Kash%20API%20key%20scope%20request",
61
- description: "Email `engineering@kash.bot` for a key with broader scope."
60
+ url: "https://app.kash.bot",
61
+ description: "Issue a key with broader scope under Settings \u2192 API Keys in the Kash app."
62
62
  }
63
63
  ]
64
64
  },
@@ -420,7 +420,7 @@ function toCliError(err) {
420
420
  return new CliError(err.message, {
421
421
  code: "INSUFFICIENT_SCOPE",
422
422
  exitCode: EXIT_CODES.AUTH,
423
- suggestion: "The API key is valid but is missing the scope this command needs. Email `engineering@kash.bot` to request a key with broader scope.",
423
+ suggestion: "The API key is valid but is missing the scope this command needs. Issue a key with broader scope under Settings \u2192 API Keys at https://app.kash.bot.",
424
424
  ...err.requestId === void 0 ? {} : { requestId: err.requestId },
425
425
  cause: err
426
426
  });
@@ -501,7 +501,7 @@ function toCliError(err) {
501
501
  if (err instanceof KashNetworkError) {
502
502
  const causeStr = `${String(err.message ?? "")} ${String(err.cause?.message ?? "")}`;
503
503
  const isDnsError = causeStr.includes("ENOTFOUND") || causeStr.includes("getaddrinfo") || causeStr.includes("EAI_AGAIN") || causeStr.includes("Could not resolve");
504
- const suggestion = isDnsError ? "The configured API host did not resolve in DNS. For staging, use a `kash_test_*` key \u2014 the CLI auto-routes to `https://api-staging.kash.bot/v1`. For a custom host, pass `--base-url <url>` or set `KASH_BASE_URL`. Production (`https://api.kash.bot/v1`) is not yet live; track launch status at https://docs.kash.bot." : "The request did not reach the API. Check network connectivity and retry.";
504
+ const suggestion = isDnsError ? "The configured API host did not resolve in DNS. A `kash_live_*` key auto-routes to production (`https://api.kash.bot/v1`); a `kash_test_*` key auto-routes to staging (`https://api-staging.kash.bot/v1`). For a custom host, pass `--base-url <url>` or set `KASH_BASE_URL`. Check your network/DNS and retry." : "The request did not reach the API. Check network connectivity and retry.";
505
505
  return new CliError(err.message, {
506
506
  code: "NETWORK",
507
507
  suggestion,
@@ -677,4 +677,4 @@ export {
677
677
  toCliError,
678
678
  isCommanderError
679
679
  };
680
- //# sourceMappingURL=chunk-UZNSYATZ.js.map
680
+ //# sourceMappingURL=chunk-X2VM6VKM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/error-catalog.ts"],"sourcesContent":["/**\n * CLI error hierarchy + SDK-error mapper.\n *\n * The CliError shape is **the contract** between this CLI and any\n * agent or script that consumes it. The fields below are SemVer-stable\n * — additions are minor bumps, removals/renames are major bumps.\n *\n * Exit code convention:\n * 0 — success\n * 1 — generic error (validation, server, network, etc.)\n * 2 — auth failure (missing/invalid API key, missing scope)\n *\n * Mapping a `KashRateLimitError` to exit 1 is deliberate: a rate-limit\n * is recoverable, but the CLI should still fail loudly so scripts\n * don't silently move on. The `recoverable` boolean and `retryAfterMs`\n * field tell agents how to handle it.\n *\n * The `actions` array is the agent-friendly recovery path. Each entry\n * is one of a small, well-defined set of variants — agents can branch\n * on `actions[0].type` without parsing prose.\n *\n * **Catalog as source of truth.** Static fields (`recoverable`,\n * `docsUrl`, base `actions`) are read from\n * `error-catalog.ts#ERROR_CATALOG` based on the error's `code`, so\n * `kash explain RATE_LIMITED` always shows the same metadata as the\n * envelope on a real `RATE_LIMITED` failure. The `toCliError` mapper\n * adds runtime-only data (`retryAfterMs` from the server's\n * `Retry-After`, an extra `wait_and_retry` action derived from it).\n * Callers can override any field explicitly, but the default path\n * pulls from the catalog so drift is structurally impossible.\n */\n\nimport {\n KashAbortedError,\n KashAuthenticationError,\n KashAuthorizationError,\n KashConfigurationError as SdkKashConfigurationError,\n KashConflictError,\n KashError,\n KashMaintenanceError,\n KashNetworkError,\n KashNotFoundError,\n KashRateLimitError,\n KashServerError,\n KashTimeoutError,\n KashValidationError,\n} from '@kashdao/sdk';\n\nimport { lookupErrorCodeWithFallback } from './error-catalog.js';\n\n/** Exit codes used by the CLI. */\nexport const EXIT_CODES = {\n OK: 0,\n GENERIC: 1,\n AUTH: 2,\n} as const;\n\nexport type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];\n\n/**\n * Machine-readable next-step hint. Agents inspect `type` and act\n * without parsing the human-prose `suggestion`. Adding new variants\n * is a minor bump (agents that don't recognise them ignore them);\n * removing or renaming is a major bump.\n *\n * **Templates.** A `run_command` action MAY carry `template: true` to\n * signal that `command` contains `<placeholder>` substrings that the\n * agent must substitute (or skip) before executing. Templates exist\n * because the static error catalog can't always know the concrete\n * command id / trade id / market id at the point the catalog is\n * authored — they're carved at runtime when the SDK error is mapped.\n * Agents that auto-execute `run_command` actions MUST honour the\n * `template` flag: substitute, prompt, or skip. Treating templated\n * commands as concrete will literally shell `kash trade status <id>`\n * (with the angle brackets) and fail.\n */\nexport type CliErrorAction =\n | {\n readonly type: 'run_command';\n readonly command: string;\n readonly description: string;\n /**\n * `true` when `command` contains `<placeholder>` tokens the\n * caller must substitute. Absent or `false` means the command\n * is concrete and safe to auto-execute. Agents that lack\n * substitution support should skip templated commands and fall\n * back to the catalog's `description` / `suggestion`.\n */\n readonly template?: boolean;\n }\n | { readonly type: 'set_env'; readonly variable: string; readonly description: string }\n | { readonly type: 'wait_and_retry'; readonly delayMs: number; readonly description: string }\n | { readonly type: 'open_url'; readonly url: string; readonly description: string }\n | { readonly type: 'check_input'; readonly field: string; readonly description: string };\n\nexport type CliErrorOptions = {\n readonly code: string;\n readonly suggestion?: string | undefined;\n readonly exitCode?: ExitCode;\n readonly requestId?: string | undefined;\n /**\n * Override the catalog's `recoverable`. If omitted the catalog's\n * value is used; if the code isn't in the catalog, defaults to\n * `false` via the UNEXPECTED fallback.\n */\n readonly recoverable?: boolean;\n /** Suggested delay before retrying. No catalog default. */\n readonly retryAfterMs?: number | undefined;\n /** Override the catalog's `docsUrl`. */\n readonly docsUrl?: string | undefined;\n /**\n * Additional `actions` to append to the catalog's static set. Use\n * this for runtime-derived hints (e.g. a `wait_and_retry` with the\n * server's exact Retry-After). Pass `actionsOverride` to replace\n * the catalog set entirely.\n */\n readonly actions?: readonly CliErrorAction[];\n /**\n * Replace the catalog's `actions` entirely (instead of appending\n * via `actions`). Use sparingly — the catalog is the source of\n * truth for static actions.\n */\n readonly actionsOverride?: readonly CliErrorAction[];\n readonly cause?: unknown;\n};\n\nexport class CliError extends Error {\n readonly code: string;\n readonly suggestion: string | undefined;\n readonly exitCode: ExitCode;\n readonly requestId: string | undefined;\n /** True iff a sensible retry/recovery path exists. */\n readonly recoverable: boolean;\n /** Suggested delay before retrying (rate limit, server error). */\n readonly retryAfterMs: number | undefined;\n /** Stable docs URL agents can fetch for richer context. */\n readonly docsUrl: string | undefined;\n /** Machine-readable next-step hints. Empty array if none. */\n readonly actions: readonly CliErrorAction[];\n override readonly cause: unknown;\n\n constructor(message: string, options: CliErrorOptions) {\n super(message);\n this.name = 'CliError';\n const catalogEntry = lookupErrorCodeWithFallback(options.code);\n this.code = options.code;\n this.suggestion = options.suggestion;\n this.exitCode = options.exitCode ?? EXIT_CODES.GENERIC;\n this.requestId = options.requestId;\n this.recoverable = options.recoverable ?? catalogEntry.recoverable;\n this.retryAfterMs = options.retryAfterMs;\n this.docsUrl = options.docsUrl ?? catalogEntry.docsUrl;\n if (options.actionsOverride !== undefined) {\n this.actions = options.actionsOverride;\n } else {\n // Caller-provided actions first (they're contextually specific:\n // a `wait_and_retry` derived from the server's actual\n // Retry-After, or a `check_input` naming a concrete bad field),\n // catalog actions second (generic fallbacks). Agents act on the\n // first applicable hint, so the more specific one needs to win.\n this.actions = [...(options.actions ?? []), ...catalogEntry.actions];\n }\n this.cause = options.cause;\n Error.captureStackTrace?.(this, this.constructor);\n }\n\n /**\n * Render the error as the stable JSON envelope agents pin to. Kept\n * as a method so the index.ts emitError can serialise consistently\n * regardless of caller.\n */\n toEnvelope(): Record<string, unknown> {\n return {\n ok: false,\n error: {\n code: this.code,\n message: this.message,\n recoverable: this.recoverable,\n ...(this.suggestion === undefined ? {} : { suggestion: this.suggestion }),\n ...(this.retryAfterMs === undefined ? {} : { retryAfterMs: this.retryAfterMs }),\n ...(this.docsUrl === undefined ? {} : { docsUrl: this.docsUrl }),\n ...(this.requestId === undefined ? {} : { requestId: this.requestId }),\n actions: this.actions,\n },\n };\n }\n}\n\nexport class CliValidationError extends CliError {\n constructor(message: string, suggestion?: string, field?: string) {\n super(message, {\n code: 'INVALID_INPUT',\n ...(suggestion === undefined ? {} : { suggestion }),\n ...(field === undefined\n ? {}\n : {\n actions: [\n {\n type: 'check_input' as const,\n field,\n description: `Verify the value of \"${field}\".`,\n },\n ],\n }),\n });\n this.name = 'CliValidationError';\n }\n}\n\nexport class CliConfigurationError extends CliError {\n constructor(message: string, suggestion?: string) {\n super(message, {\n code: 'CONFIGURATION',\n ...(suggestion === undefined ? {} : { suggestion }),\n });\n this.name = 'CliConfigurationError';\n }\n}\n\n/**\n * Translate any `unknown` error coming out of the SDK or the CLI\n * itself into a `CliError`. Pass-through for existing `CliError`\n * instances so callers can re-throw without re-wrapping.\n *\n * Each branch only sets runtime fields (suggestion, requestId,\n * retryAfterMs, runtime-derived actions). Static fields like\n * `recoverable`, `docsUrl`, and base `actions` come from the catalog\n * via the CliError constructor.\n */\nexport function toCliError(err: unknown): CliError {\n if (err instanceof CliError) {\n return err;\n }\n // Commander-thrown errors (we call `program.exitOverride()` so\n // unknown commands / unknown options surface here instead of\n // exiting via process.exit). Help and version short-circuits also\n // come through — they're not errors and exit cleanly.\n const commander = mapCommanderError(err);\n if (commander) return commander;\n if (err instanceof KashAuthenticationError) {\n return new CliError(err.message, {\n code: 'AUTH_REQUIRED',\n exitCode: EXIT_CODES.AUTH,\n suggestion:\n \"First-time setup: run 'kash setup' (interactive wizard). Otherwise: 'kash auth set-key' or set KASH_API_KEY.\",\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof KashAuthorizationError) {\n return new CliError(err.message, {\n code: 'INSUFFICIENT_SCOPE',\n exitCode: EXIT_CODES.AUTH,\n suggestion:\n 'The API key is valid but is missing the scope this command needs. Issue a key with broader scope under Settings → API Keys at https://app.kash.bot.',\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof KashRateLimitError) {\n const retrySec = err.retryAfterSeconds;\n const retryAfterMs = retrySec === undefined ? undefined : retrySec * 1000;\n const suggestion =\n retrySec !== undefined\n ? `Retry in ${String(retrySec)}s. Upgrade for higher limits: https://kash.bot/pricing`\n : 'Slow down request rate. Upgrade for higher limits: https://kash.bot/pricing';\n return new CliError(err.message, {\n code: 'RATE_LIMITED',\n suggestion,\n ...(retryAfterMs === undefined ? {} : { retryAfterMs }),\n ...(retryAfterMs === undefined\n ? {}\n : {\n actions: [\n {\n type: 'wait_and_retry' as const,\n delayMs: retryAfterMs,\n description: `Wait ${String(retrySec)}s then re-run the same command.`,\n },\n ],\n }),\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof KashNotFoundError) {\n return new CliError(err.message, {\n code: 'NOT_FOUND',\n suggestion: 'Double-check the resource id (markets and trades use UUIDs).',\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof KashConflictError) {\n return new CliError(err.message, {\n code: 'CONFLICT',\n suggestion:\n 'A conflicting request is already in flight or the resource state changed underneath you. Inspect the trade with `kash trade status <id>` before retrying.',\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof KashValidationError) {\n return new CliError(err.message, {\n code: 'INVALID_INPUT',\n suggestion: 'Verify the request shape matches `kash <command> --help`.',\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof KashMaintenanceError) {\n const retrySec = err.retryAfterSeconds;\n const retryAfterMs = retrySec === undefined ? undefined : retrySec * 1000;\n return new CliError(err.message, {\n code: 'MAINTENANCE',\n suggestion:\n 'The Kash trade pipeline is temporarily disabled (incident response or planned maintenance). Honor `retryAfterMs` and retry once the window closes.',\n ...(retryAfterMs === undefined ? {} : { retryAfterMs }),\n ...(retryAfterMs === undefined\n ? {}\n : {\n actions: [\n {\n type: 'wait_and_retry' as const,\n delayMs: retryAfterMs,\n description: `Wait ${String(retrySec)}s before retrying.`,\n },\n ],\n }),\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof KashTimeoutError) {\n return new CliError(err.message, {\n code: 'TIMEOUT',\n suggestion:\n 'The request exceeded the configured timeout. Retry, or pass --timeout-ms to raise the cap.',\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof KashNetworkError) {\n // Inspect the underlying cause for DNS-resolution failures so we\n // can route the user to the right recovery action — remind them that\n // the key prefix picks the host (live → production, test → staging)\n // rather than emitting a generic \"check connectivity\" line.\n const causeStr = `${String(err.message ?? '')} ${String((err.cause as Error)?.message ?? '')}`;\n const isDnsError =\n causeStr.includes('ENOTFOUND') ||\n causeStr.includes('getaddrinfo') ||\n causeStr.includes('EAI_AGAIN') ||\n causeStr.includes('Could not resolve');\n const suggestion = isDnsError\n ? 'The configured API host did not resolve in DNS. ' +\n 'A `kash_live_*` key auto-routes to production ' +\n '(`https://api.kash.bot/v1`); a `kash_test_*` key auto-routes to ' +\n 'staging (`https://api-staging.kash.bot/v1`). ' +\n 'For a custom host, pass `--base-url <url>` or set `KASH_BASE_URL`. ' +\n 'Check your network/DNS and retry.'\n : 'The request did not reach the API. Check network connectivity and retry.';\n return new CliError(err.message, {\n code: 'NETWORK',\n suggestion,\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof KashAbortedError) {\n return new CliError(err.message, {\n code: 'ABORTED',\n suggestion:\n 'The request was cancelled before it completed. If the command is idempotent, you can safely retry with the same Idempotency-Key.',\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof KashServerError) {\n return new CliError(err.message, {\n code: 'SERVER_ERROR',\n suggestion:\n 'The API returned a 5xx after retries. The request is safe to retry; if the failure persists, file a bug at https://github.com/KashDAO/cli/issues with the requestId.',\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof SdkKashConfigurationError) {\n // Surface the first Zod issue's path as a check_input action so\n // an agent can localise the broken field without parsing prose.\n const firstIssue = err.issues[0];\n const fieldPath = firstIssue?.path.join('.') ?? '';\n return new CliError(err.message, {\n code: 'CONFIGURATION',\n suggestion:\n firstIssue !== undefined\n ? `SDK rejected ${fieldPath || '(root)'}: ${firstIssue.message}`\n : 'The SDK rejected the configuration provided to the client.',\n ...(fieldPath\n ? {\n actions: [\n {\n type: 'check_input' as const,\n field: fieldPath,\n description: `Fix the value of \"${fieldPath}\" and re-run.`,\n },\n ],\n }\n : {}),\n cause: err,\n });\n }\n // ── Protocol-SDK (`@kashdao/protocol-sdk`) errors ───────────────\n // We don't eager-import the protocol-sdk just to use `instanceof`\n // checks (it pulls in viem). Duck-type on `err.name` instead — the\n // protocol-sdk's error classes set their `name` field deterministically\n // in the base constructor.\n const protocolErrorMapping = mapProtocolError(err);\n if (protocolErrorMapping !== undefined) {\n return protocolErrorMapping;\n }\n if (err instanceof KashError) {\n // Any KashError subclass we haven't enumerated above. Falls back\n // to the catalog's UNEXPECTED entry for `recoverable`/`docsUrl`\n // (so `kash explain` always returns *something*) but preserves\n // the SDK's `isRetryable` value.\n return new CliError(err.message, {\n code: 'UNEXPECTED',\n recoverable: err.isRetryable,\n ...(err.requestId === undefined ? {} : { requestId: err.requestId }),\n cause: err,\n });\n }\n if (err instanceof Error) {\n return new CliError(err.message, { code: 'UNEXPECTED', cause: err });\n }\n return new CliError(String(err), { code: 'UNEXPECTED', cause: err });\n}\n\n/**\n * Structural shape of Commander's `CommanderError`. Commander documents\n * `code` and `message` as stable public API and namespaces every code\n * with the `commander.` prefix (`commander.unknownCommand`,\n * `commander.help`, etc.).\n *\n * We type-guard against this shape rather than `instanceof CommanderError`\n * because importing the constructor here would force the Commander\n * module to load on the cold path even for invocations that never\n * touch it. Going through a structural check keeps the import lazy\n * AND keeps TypeScript safety at every use site.\n */\nexport type CommanderErrorLike = {\n readonly code: string;\n readonly message: string;\n};\n\n/**\n * Type guard — true iff `err` looks like a Commander-thrown error.\n * Commander always sets `code` to a string starting with `commander.`,\n * so the prefix check is the load-bearing test (filters out other\n * errors that happen to have a `code` field, e.g. `EACCES`).\n */\nexport function isCommanderError(err: unknown): err is CommanderErrorLike {\n if (!(err instanceof Error)) return false;\n const candidate = err as { code?: unknown; message?: unknown };\n return (\n typeof candidate.code === 'string' &&\n candidate.code.startsWith('commander.') &&\n typeof candidate.message === 'string'\n );\n}\n\n/**\n * Map a Commander-thrown error to either a clean exit (help/version)\n * or a structured `CliError` (unknown command, unknown option, missing\n * argument, etc.). Returns undefined for non-Commander errors so the\n * outer mapper can keep walking its switch.\n */\nfunction mapCommanderError(err: unknown): CliError | undefined {\n if (!isCommanderError(err)) return undefined;\n const { code, message } = err;\n\n // `commander.help`, `commander.helpDisplayed`, `commander.version` —\n // user asked for `--help` or `--version`. Commander already wrote\n // the output; surfacing this as a real error would be wrong. Use\n // `EXIT_CODES.OK` and code `'NOOP'` so the top-level boundary in\n // `index.ts` exits cleanly and prints nothing extra.\n if (\n code === 'commander.help' ||\n code === 'commander.helpDisplayed' ||\n code === 'commander.version'\n ) {\n return new CliError('', {\n code: 'NOOP',\n exitCode: EXIT_CODES.OK,\n recoverable: false,\n cause: err,\n });\n }\n\n // Unknown command — the most common typo case. Commander appends\n // a \"Did you mean X?\" suggestion to the message; we extract it so\n // the structured envelope carries a `run_command` recovery action\n // an agent can execute directly.\n if (code === 'commander.unknownCommand') {\n const match = /Did you mean (\\S+?)\\??\\)?$/m.exec(message);\n const suggested = match?.[1];\n const suggestion = suggested\n ? `Did you mean \\`kash ${suggested}\\`? Run \\`kash --help\\` for the full command tree.`\n : 'Run `kash --help` for the full command tree.';\n return new CliError(stripTrailingNewlines(message), {\n code: 'INVALID_INPUT',\n recoverable: true,\n suggestion,\n ...(suggested === undefined\n ? {}\n : {\n actions: [\n {\n type: 'run_command' as const,\n command: `kash ${suggested}`,\n description: 'Run the suggested command instead.',\n },\n ],\n }),\n cause: err,\n });\n }\n\n // Unknown option — adjacent typo case. Commander doesn't always\n // include a suggestion for options; fall back to a generic check.\n if (code === 'commander.unknownOption') {\n return new CliError(stripTrailingNewlines(message), {\n code: 'INVALID_INPUT',\n recoverable: true,\n suggestion:\n 'Run `kash <command> --help` for the supported flags, or `kash docs --json` for the full surface.',\n cause: err,\n });\n }\n\n // Missing required argument / option — Commander surfaces these\n // before the action runs. Keep the original message (it names the\n // flag) and add a generic check_input action.\n if (\n code === 'commander.missingArgument' ||\n code === 'commander.missingMandatoryOptionValue' ||\n code === 'commander.optionMissingArgument'\n ) {\n return new CliError(stripTrailingNewlines(message), {\n code: 'INVALID_INPUT',\n recoverable: true,\n suggestion: 'Run the command with `--help` to see required arguments.',\n cause: err,\n });\n }\n\n // Anything else from Commander (excess arguments, invalid choice,\n // etc.) — generic mapping with the original message preserved.\n return new CliError(stripTrailingNewlines(message), {\n code: 'INVALID_INPUT',\n recoverable: true,\n cause: err,\n });\n}\n\n/** Trim trailing newlines so error messages don't render double-spaced. */\nfunction stripTrailingNewlines(s: string): string {\n return s.replace(/\\n+$/, '');\n}\n\n/**\n * Map an `@kashdao/protocol-sdk` error to the corresponding CLI code,\n * by class name. Returns `undefined` if the error is not a recognised\n * protocol-sdk error.\n *\n * **Why duck-typing instead of `instanceof`?** Importing the\n * protocol-sdk eagerly here would defeat the cold-start optimisation\n * that lazy-loads `@kashdao/protocol-sdk` only when `kash protocol …`\n * commands run. Kash-orchestrated-only invocations (markets/trade/portfolio)\n * keep their fast path. The protocol-sdk's error base class sets\n * `name` to the constructor name in its constructor, so a name check\n * is reliable across module-instance boundaries.\n */\nfunction mapProtocolError(err: unknown): CliError | undefined {\n if (!(err instanceof Error)) return undefined;\n switch (err.name) {\n case 'KashConfigError': {\n const cliErr = new CliError(err.message, {\n code: 'DIRECT_CONFIG_MISSING',\n suggestion:\n 'Set the missing field via `kash config set <field> <value>` (rpcUrl, smartAccount, signerKeyRef, defaultChainId).',\n cause: err,\n });\n return cliErr;\n }\n case 'KashSignerError':\n return new CliError(err.message, {\n code: 'SIGNER_FAILED',\n suggestion: 'Verify the signerKeyRef target is readable (file:<path>) or set (env:<NAME>).',\n cause: err,\n });\n case 'KashChainError':\n return new CliError(err.message, {\n code: 'CHAIN_ERROR',\n suggestion: 'On-chain read or contract interaction failed unexpectedly.',\n cause: err,\n });\n case 'KashBundlerError':\n return new CliError(err.message, {\n code: 'BUNDLER_REJECTED',\n suggestion: 'Inspect the bundler-specific reason in the message and adjust.',\n cause: err,\n });\n case 'KashSimulationRevertedError':\n return new CliError(err.message, {\n code: 'TRANSACTION_REVERTED',\n suggestion: 'Re-run with `kash protocol simulate` to see the decoded revert reason.',\n cause: err,\n });\n case 'KashProtocolError':\n // Base class — ChainError is the closest fallback for any\n // protocol-sdk error not covered above.\n return new CliError(err.message, {\n code: 'CHAIN_ERROR',\n suggestion: 'Unrecognised protocol-sdk error. File an issue with `kash version --json`.',\n cause: err,\n });\n default:\n return undefined;\n }\n}\n","/**\n * Single source of truth for every error `code` the CLI emits.\n *\n * Both `toCliError` (the SDK-error mapper) and `kash explain <code>`\n * read from this catalog so an AI agent that hits a `RATE_LIMITED`\n * error and asks `kash explain RATE_LIMITED --json` gets the same\n * `recoverable`, `docsUrl`, and `actions` it would have seen on the\n * error envelope.\n *\n * Adding a new code: append an entry. Removing one: major bump.\n * Renaming a field: major bump.\n *\n * Runtime-only data (the server's `retryAfterMs`, the specific\n * `requestId`, an extra `wait_and_retry` action computed from the\n * Retry-After header) is layered on top by `toCliError` — the\n * catalog is for static metadata only.\n */\n\nimport type { CliErrorAction } from './errors.js';\n\nexport type ErrorCatalogEntry = {\n /** Stable machine-readable code. */\n readonly code: string;\n /** One-sentence summary in plain English. */\n readonly summary: string;\n /** Longer explanation suitable for human troubleshooting. */\n readonly description: string;\n /** Whether retrying the original request might succeed. */\n readonly recoverable: boolean;\n /** Stable docs URL, when one exists. */\n readonly docsUrl?: string;\n /**\n * Concrete recovery steps the agent can take. These are the\n * *static* actions for this code; runtime-only actions (e.g. a\n * `wait_and_retry` derived from the server's Retry-After header)\n * are appended by `toCliError`.\n */\n readonly actions: readonly CliErrorAction[];\n};\n\nexport const ERROR_CATALOG: readonly ErrorCatalogEntry[] = [\n {\n code: 'AUTH_REQUIRED',\n summary: 'No API key was provided, or the key is invalid / expired / revoked.',\n description:\n 'The Kash public API requires a kash_live_… or kash_test_… key on every authenticated route. First-time users should run `kash setup` (interactive wizard). Existing users can `kash auth set-key`, set KASH_API_KEY, or pass --profile to switch to a stored profile.',\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/cli/authentication',\n actions: [\n {\n type: 'run_command',\n command: 'kash setup',\n description: 'First-run wizard — issues a key, configures profile, validates it.',\n },\n {\n type: 'run_command',\n command: 'kash auth set-key',\n description:\n 'Store an API key for the active profile (paste interactively or pipe via stdin).',\n },\n {\n type: 'set_env',\n variable: 'KASH_API_KEY',\n description: 'Provide the key via environment variable.',\n },\n {\n type: 'open_url',\n url: 'https://app.kash.bot',\n description:\n 'Create an API key under Settings → API Keys in the Kash app (`Live` for Base mainnet, `Test` for Base Sepolia).',\n },\n ],\n },\n {\n code: 'INSUFFICIENT_SCOPE',\n summary: 'The API key is valid but lacks the scope this command requires.',\n description:\n \"Authentication succeeded but the key's scope (read-only / trade / admin) doesn't cover the route. Request a key with broader scope, or move to a tier that includes it.\",\n recoverable: true,\n docsUrl: 'https://docs.kash.bot/developer-docs/rest-api/authentication',\n actions: [\n {\n type: 'open_url',\n url: 'https://app.kash.bot',\n description: 'Issue a key with broader scope under Settings → API Keys in the Kash app.',\n },\n ],\n },\n {\n code: 'RATE_LIMITED',\n summary: 'You have exceeded the per-key rate limit for this tier.',\n description:\n 'Slow down or upgrade for higher limits. The error envelope carries `retryAfterMs`; honor it via `kash --max-retries` or back off in your application.',\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/api/rate-limits',\n actions: [\n {\n type: 'open_url',\n url: 'https://kash.bot/pricing',\n description: 'Upgrade tier for higher rate limits.',\n },\n ],\n },\n {\n code: 'NOT_FOUND',\n summary: 'The requested resource (market, trade, position) does not exist.',\n description:\n 'Markets and trades are identified by UUID. Confirm the id is correct (especially after copy-paste truncation) and that the resource is visible to the active key.',\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/api/errors',\n actions: [],\n },\n {\n code: 'CONFLICT',\n summary: 'A conflicting request is already in flight or the resource state changed.',\n description:\n 'Common cases: you sent a duplicate Idempotency-Key, the trade is awaiting high-value confirmation, or the market closed between fetch and trade. Inspect the resource before retrying.',\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/api/errors',\n actions: [\n {\n type: 'run_command',\n command: 'kash trade status <id>',\n description: 'Inspect the conflicting trade resource. Substitute <id> with the trade UUID.',\n template: true,\n },\n ],\n },\n {\n code: 'INVALID_INPUT',\n summary: 'The request body or arguments failed validation.',\n description:\n 'Check the field names and types against `kash <command> --help` or `kash schema <command>`. USDC amounts are decimal strings with up to 6 fractional digits.',\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/cli/commands',\n actions: [\n {\n type: 'run_command',\n command: 'kash <command> --help',\n description:\n 'Inspect the command signature. Substitute <command> with the failing path (e.g. `trade buy`, `markets list`).',\n template: true,\n },\n {\n type: 'run_command',\n command: 'kash schema <command>',\n description:\n 'Get the JSON Schema for the command inputs. Substitute <command> with the failing path.',\n template: true,\n },\n ],\n },\n {\n code: 'MAINTENANCE',\n summary: 'The Kash trade pipeline is temporarily disabled (kill switch).',\n description:\n 'API trade processing is halted, typically during incident response or planned maintenance. Read state is unaffected. Honor the `retryAfterMs` and retry once the window closes.',\n recoverable: true,\n docsUrl: 'https://docs.kash.bot/developer-docs/api-errors/API_TRADE_PROCESSING_HALTED',\n actions: [\n {\n type: 'wait_and_retry',\n delayMs: 30_000,\n description: 'Wait 30s then retry. Surface the requestId if the failure persists.',\n },\n ],\n },\n {\n code: 'TIMEOUT',\n summary: 'The request exceeded the SDK timeout (default 30s).',\n description:\n 'Either the server is slow or the network path is degraded. Retry, or pass --timeout-ms to raise the cap. Repeated timeouts are worth investigating against the status page.',\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/cli/troubleshooting',\n actions: [\n {\n type: 'run_command',\n command: 'kash --timeout-ms 60000 <same command>',\n description:\n 'Re-run with a longer timeout. Substitute <same command> with the original invocation tail.',\n template: true,\n },\n ],\n },\n {\n code: 'NETWORK',\n summary: 'A transport-layer failure (DNS, TLS, connection refused) before any HTTP response.',\n description:\n 'The SDK never received a response. Check connectivity to api.kash.bot. The CLI retries network errors automatically; this means retries were exhausted.',\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/cli/troubleshooting',\n actions: [],\n },\n {\n code: 'ABORTED',\n summary: 'The request was cancelled by the caller before it completed.',\n description:\n 'An AbortSignal you passed (or the spinner you cancelled) fired while the request was in flight. The server may or may not have processed the request — if it did, the side effect already landed. Idempotent requests can be safely retried with the same Idempotency-Key.',\n recoverable: false,\n docsUrl: 'https://kash.bot/docs/cli/troubleshooting',\n actions: [],\n },\n {\n code: 'SERVER_ERROR',\n summary: 'The API returned a 5xx response after retries.',\n description:\n 'The request is safe to retry. If the issue persists, file a bug at https://github.com/KashDAO/cli/issues with the requestId on the error envelope.',\n recoverable: true,\n docsUrl: 'https://docs.kash.bot/developer-docs/api-errors/DEPENDENCY_UNAVAILABLE',\n actions: [\n {\n type: 'wait_and_retry',\n delayMs: 5_000,\n description: 'Wait 5s and retry. The CLI may have already exhausted its retry budget.',\n },\n ],\n },\n {\n code: 'CONFIGURATION',\n summary: 'The CLI configuration file or environment is invalid.',\n description:\n \"The on-disk ~/.kash/config.json failed to parse, an env var (KASH_CHAIN_ID) doesn't match its expected shape, or a per-invocation flag (--max-retries, --timeout-ms, --base-url) was rejected by the SDK. Run `kash config show` to inspect what loaded.\",\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/cli/configuration',\n actions: [\n {\n type: 'run_command',\n command: 'kash config show',\n description: 'Inspect the loaded configuration and its sources.',\n },\n ],\n },\n // ─── Direct-mode (kash protocol ...) ─────────────────────────────\n {\n code: 'DIRECT_CONFIG_MISSING',\n summary: 'Direct-mode configuration is incomplete.',\n description:\n \"Direct-mode commands (`kash protocol ...`) require RPC URL, smart account address, signer key reference, and chain ID. One or more of these is missing from the active profile and the environment. Run `kash config show` to see what's loaded; set the missing fields with `kash config set rpcUrl …`, `kash config set smartAccount 0x…`, etc.\",\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/cli/direct-mode',\n actions: [\n {\n type: 'run_command',\n command: 'kash config show',\n description: 'Inspect the loaded configuration and source attribution.',\n },\n {\n type: 'run_command',\n command: 'kash config set rpcUrl https://your-rpc.example.com',\n description: 'Set the RPC URL for direct-mode operations.',\n },\n ],\n },\n {\n code: 'SIGNER_FAILED',\n summary: 'The configured signer (file/env/KMS) failed to load or sign.',\n description:\n \"The signer adapter referenced by `signerKeyRef` couldn't load the private key, or signing the UserOp hash failed. Common causes: missing/unreadable file, missing env var, malformed hex, or a KMS permission denial.\",\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/cli/direct-mode',\n actions: [\n {\n type: 'check_input',\n field: 'signerKeyRef',\n description: 'Verify the signer reference (file:<path> or env:<VAR>) and its target.',\n },\n ],\n },\n {\n code: 'RPC_FAILED',\n summary: 'The RPC endpoint refused the request or timed out.',\n description:\n 'Network call to the configured `rpcUrl` failed. Could be a rate-limit at the RPC provider, a transient network issue, or a misconfigured URL. The protocol-sdk does NOT retry RPC calls — fail fast so the operator sees the issue.',\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/cli/troubleshooting',\n actions: [\n {\n type: 'check_input',\n field: 'rpcUrl',\n description: 'Verify the RPC URL is reachable and the API key (if any) is valid.',\n },\n ],\n },\n {\n code: 'BUNDLER_REJECTED',\n summary: 'The bundler refused to relay the UserOp.',\n description:\n 'Common rejection reasons: replacement-underpriced, sender-mempool-full, gas estimation drift, or a UserOp that the bundler suspects will revert. The error message carries the bundler-specific reason verbatim.',\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/cli/direct-mode',\n actions: [],\n },\n {\n code: 'TRANSACTION_REVERTED',\n summary: 'The UserOp executed but the on-chain call reverted.',\n description:\n 'The transaction landed on-chain but the contract call reverted. The error message carries the decoded revert reason when the protocol-sdk recognises it (e.g. `MarketFrozen`, `InsufficientReserve`). Re-running with `kash protocol simulate` first will catch most reverts before they cost gas.',\n recoverable: false,\n docsUrl: 'https://kash.bot/docs/cli/direct-mode',\n actions: [\n {\n type: 'run_command',\n command:\n 'kash protocol simulate <market-address> --action <buy|sell> --outcome <i> --amount <n>',\n description:\n 'Dry-run the trade against current chain state before re-submitting. Substitute every <placeholder>.',\n template: true,\n },\n ],\n },\n {\n code: 'CHAIN_ERROR',\n summary: 'A protocol-level chain interaction failed.',\n description:\n \"An on-chain read or simulation returned an unexpected shape, decoded to an unknown revert, or the contract addresses don't match the configured chain ID. Verify the chain ID and that the protocol contracts are deployed at the expected addresses for that chain.\",\n recoverable: false,\n docsUrl: 'https://kash.bot/docs/cli/direct-mode',\n actions: [\n {\n type: 'check_input',\n field: 'chainId',\n description: 'Confirm chainId matches the network your RPC and bundler target.',\n },\n ],\n },\n {\n code: 'UNEXPECTED',\n summary: 'An unrecognised error escaped the SDK or the CLI.',\n description:\n \"This means the CLI's error mapper didn't recognise the underlying failure — the most likely cause is an SDK or runtime issue. File an issue with the message, the command, and the runtime info from `kash version --json`.\",\n recoverable: false,\n docsUrl: 'https://github.com/KashDAO/cli/issues',\n actions: [\n {\n type: 'run_command',\n command: 'kash version --json',\n description: 'Capture runtime info to attach to the bug report.',\n },\n ],\n },\n {\n code: 'NOOP',\n summary: 'No-op exit (Commander emitted output and asked us to stop).',\n description:\n \"Commander's help/version paths don't represent a failure — it printed `--help` or `--version` output and signalled the CLI to exit cleanly. This code surfaces in JSON-output contexts so consumers know the run completed without doing real work; the human path exits 0 with no error envelope.\",\n recoverable: true,\n docsUrl: 'https://kash.bot/docs/cli/exit-codes',\n actions: [],\n },\n];\n\nconst CATALOG_BY_CODE = new Map<string, ErrorCatalogEntry>(\n ERROR_CATALOG.map((entry) => [entry.code, entry])\n);\n\nexport function lookupErrorCode(code: string): ErrorCatalogEntry | undefined {\n return CATALOG_BY_CODE.get(code);\n}\n\n/**\n * Resolve the catalog entry for a code, falling back to the\n * `UNEXPECTED` entry when the code isn't recognised.\n *\n * The fallback exists so opaque SDK codes (e.g. a new `KashError`\n * subclass that hasn't been mapped CLI-side yet) still produce a\n * usable `kash explain <code>` response — the agent learns \"we don't\n * recognise this code, file an issue\" instead of \"Unknown error\n * code\", which would be a dead end.\n */\nexport function lookupErrorCodeWithFallback(code: string): ErrorCatalogEntry {\n const entry = CATALOG_BY_CODE.get(code);\n if (entry) return entry;\n // The UNEXPECTED entry is always present; safe to assert.\n return CATALOG_BY_CODE.get('UNEXPECTED')!;\n}\n\n/** Set of every catalog code, exposed for invariant tests. */\nexport const ERROR_CODES: ReadonlySet<string> = new Set(ERROR_CATALOG.map((e) => e.code));\n"],"mappings":";;;AAgCA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,0BAA0B;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACNA,IAAM,gBAA8C;AAAA,EACzD;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACE;AAAA,IACF,aAAa;AAAA,IACb,SAAS;AAAA,IACT,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,MACf;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aACE;AAAA,MACJ;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,UAAU;AAAA,QACV,aAAa;AAAA,MACf;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,KAAK;AAAA,QACL,aACE;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACE;AAAA,IACF,aAAa;AAAA,IACb,SAAS;AAAA,IACT,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,KAAK;AAAA,QACL,aAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACE;AAAA,IACF,aAAa;AAAA,IACb,SAAS;AAAA,IACT,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,Q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N,YAAY;AAAA,QACZ,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ buildClient
4
+ } from "./chunk-QALDZHTX.js";
5
+ import "./chunk-N26VGVGB.js";
6
+ import "./chunk-BVFDUI73.js";
7
+ import "./chunk-KAM6KOFD.js";
8
+ import "./chunk-MQUJG224.js";
9
+ import "./chunk-KADB3OKE.js";
10
+ import "./chunk-X2VM6VKM.js";
11
+ export {
12
+ buildClient
13
+ };
14
+ //# sourceMappingURL=client-75FVHGOH.js.map
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  log
4
- } from "./chunk-VIADBYFY.js";
5
- import "./chunk-MIXOZU2S.js";
4
+ } from "./chunk-MQUJG224.js";
5
+ import "./chunk-KADB3OKE.js";
6
6
  import {
7
7
  CliError
8
- } from "./chunk-UZNSYATZ.js";
8
+ } from "./chunk-X2VM6VKM.js";
9
9
 
10
10
  // src/completion.ts
11
11
  import { Command } from "commander";
@@ -97,4 +97,4 @@ export {
97
97
  createCompletionCommand,
98
98
  initCompletion
99
99
  };
100
- //# sourceMappingURL=completion-ZZGX5BQC.js.map
100
+ //# sourceMappingURL=completion-PK74S3EZ.js.map
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createTable,
4
4
  redact
5
- } from "./chunk-BRK7KJ4O.js";
5
+ } from "./chunk-R4NGUZKN.js";
6
6
  import {
7
7
  cliConfigSchema,
8
8
  cliFileSchema,
@@ -15,23 +15,23 @@ import {
15
15
  setCurrentProfile,
16
16
  updateConfig,
17
17
  writeWholeFile
18
- } from "./chunk-KMBMQIZ7.js";
19
- import "./chunk-YHCG2SUC.js";
18
+ } from "./chunk-N26VGVGB.js";
19
+ import "./chunk-BVFDUI73.js";
20
20
  import {
21
21
  readGlobals
22
- } from "./chunk-LBIRQHX5.js";
22
+ } from "./chunk-A3IH5HUV.js";
23
23
  import {
24
24
  log,
25
25
  print,
26
26
  printJson,
27
27
  style
28
- } from "./chunk-VIADBYFY.js";
29
- import "./chunk-MIXOZU2S.js";
28
+ } from "./chunk-MQUJG224.js";
29
+ import "./chunk-KADB3OKE.js";
30
30
  import {
31
31
  CliError,
32
32
  CliValidationError,
33
33
  toCliError
34
- } from "./chunk-UZNSYATZ.js";
34
+ } from "./chunk-X2VM6VKM.js";
35
35
 
36
36
  // src/commands/config/index.ts
37
37
  import { Command as Command9 } from "commander";
@@ -687,4 +687,4 @@ var configCommand = new Command9("config").description("Inspect and edit ~/.kash
687
687
  export {
688
688
  configCommand
689
689
  };
690
- //# sourceMappingURL=config-XJL5TSYK.js.map
690
+ //# sourceMappingURL=config-T5U6E6KU.js.map
@@ -18,9 +18,9 @@ import {
18
18
  setCurrentProfile,
19
19
  updateConfig,
20
20
  writeWholeFile
21
- } from "./chunk-KMBMQIZ7.js";
22
- import "./chunk-YHCG2SUC.js";
23
- import "./chunk-UZNSYATZ.js";
21
+ } from "./chunk-N26VGVGB.js";
22
+ import "./chunk-BVFDUI73.js";
23
+ import "./chunk-X2VM6VKM.js";
24
24
  export {
25
25
  DEFAULTS,
26
26
  DEFAULT_PROFILE,
@@ -41,4 +41,4 @@ export {
41
41
  updateConfig,
42
42
  writeWholeFile
43
43
  };
44
- //# sourceMappingURL=config-store-3ZSYGXMQ.js.map
44
+ //# sourceMappingURL=config-store-UTFDUCKW.js.map
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readGlobals
4
- } from "./chunk-LBIRQHX5.js";
4
+ } from "./chunk-A3IH5HUV.js";
5
5
  import {
6
6
  print,
7
7
  printJson,
8
8
  style
9
- } from "./chunk-VIADBYFY.js";
10
- import "./chunk-MIXOZU2S.js";
11
- import "./chunk-UZNSYATZ.js";
9
+ } from "./chunk-MQUJG224.js";
10
+ import "./chunk-KADB3OKE.js";
11
+ import "./chunk-X2VM6VKM.js";
12
12
 
13
13
  // src/commands/docs.ts
14
14
  import { Command } from "commander";
@@ -99,4 +99,4 @@ export {
99
99
  buildDocsCommand,
100
100
  describeCommand
101
101
  };
102
- //# sourceMappingURL=docs-MDKKSJDC.js.map
102
+ //# sourceMappingURL=docs-VA7CJ2ZF.js.map
@@ -2,15 +2,15 @@
2
2
  import {
3
3
  loadRawPrivateKey,
4
4
  resolveCliCustomChain
5
- } from "./chunk-YJX3JJ4M.js";
5
+ } from "./chunk-L4AFV2HK.js";
6
6
  import {
7
7
  formatAddress,
8
8
  formatGwei,
9
9
  formatUsdcAtomic
10
- } from "./chunk-BRK7KJ4O.js";
10
+ } from "./chunk-R4NGUZKN.js";
11
11
  import {
12
12
  readConfig
13
- } from "./chunk-KMBMQIZ7.js";
13
+ } from "./chunk-N26VGVGB.js";
14
14
  import {
15
15
  DEFAULT_SLIPPAGE_BPS,
16
16
  MAX_UINT256,
@@ -23,26 +23,26 @@ import {
23
23
  parseUppercaseSide,
24
24
  validateAddress,
25
25
  validateAddressOptional
26
- } from "./chunk-YHCG2SUC.js";
26
+ } from "./chunk-BVFDUI73.js";
27
27
  import {
28
28
  parseOptionalPositiveFloat,
29
29
  parseOptionalPositiveInt,
30
30
  parsePositiveInt,
31
31
  readGlobals
32
- } from "./chunk-LBIRQHX5.js";
32
+ } from "./chunk-A3IH5HUV.js";
33
33
  import {
34
34
  log,
35
35
  print,
36
36
  printJson,
37
37
  style
38
- } from "./chunk-VIADBYFY.js";
39
- import "./chunk-MIXOZU2S.js";
38
+ } from "./chunk-MQUJG224.js";
39
+ import "./chunk-KADB3OKE.js";
40
40
  import {
41
41
  CliError,
42
42
  CliValidationError,
43
43
  EXIT_CODES,
44
44
  toCliError
45
- } from "./chunk-UZNSYATZ.js";
45
+ } from "./chunk-X2VM6VKM.js";
46
46
 
47
47
  // src/commands/eoa/index.ts
48
48
  import { Command } from "commander";
@@ -548,4 +548,4 @@ function emitSendResult(side, target, result, json) {
548
548
  export {
549
549
  eoaCommand
550
550
  };
551
- //# sourceMappingURL=eoa-IQ72EIHR.js.map
551
+ //# sourceMappingURL=eoa-RL3NLN3H.js.map
@@ -6,7 +6,7 @@ import {
6
6
  EXIT_CODES,
7
7
  isCommanderError,
8
8
  toCliError
9
- } from "./chunk-UZNSYATZ.js";
9
+ } from "./chunk-X2VM6VKM.js";
10
10
  export {
11
11
  CliConfigurationError,
12
12
  CliError,
@@ -15,4 +15,4 @@ export {
15
15
  isCommanderError,
16
16
  toCliError
17
17
  };
18
- //# sourceMappingURL=errors-WMZIEGQI.js.map
18
+ //# sourceMappingURL=errors-2NNXRNES.js.map
@@ -2,21 +2,21 @@
2
2
  import {
3
3
  createTable,
4
4
  truncate
5
- } from "./chunk-BRK7KJ4O.js";
5
+ } from "./chunk-R4NGUZKN.js";
6
6
  import {
7
7
  readGlobals
8
- } from "./chunk-LBIRQHX5.js";
8
+ } from "./chunk-A3IH5HUV.js";
9
9
  import {
10
10
  print,
11
11
  printJson,
12
12
  style
13
- } from "./chunk-VIADBYFY.js";
14
- import "./chunk-MIXOZU2S.js";
13
+ } from "./chunk-MQUJG224.js";
14
+ import "./chunk-KADB3OKE.js";
15
15
  import {
16
16
  CliError,
17
17
  ERROR_CATALOG,
18
18
  lookupErrorCode
19
- } from "./chunk-UZNSYATZ.js";
19
+ } from "./chunk-X2VM6VKM.js";
20
20
 
21
21
  // src/commands/explain.ts
22
22
  import { Command } from "commander";
@@ -55,7 +55,7 @@ var API_ERROR_DOCS = Object.freeze({
55
55
  "RESOURCE_NOT_FOUND": "# `RESOURCE_NOT_FOUND`\n\n**HTTP status:** 404 \xB7 **Title:** \"Not Found\"\n\n## When it fires\n\nA request for a specific resource (trade, key, webhook event, etc.) didn't find a matching row that the caller is authorised to see.\n\nThis is the generic catch-all 404. Specific resource types may have their own dedicated codes (e.g., [`MARKET_NOT_FOUND`](./MARKET_NOT_FOUND.md)) where there's value in distinguishing the resource type to the caller.\n\n## Why it happens\n\n- The id is wrong (typo, cross-environment confusion).\n- The resource exists but belongs to a different user \u2014 we return 404 (not 403) deliberately, so attackers can't probe for the existence of resources they don't own.\n- The resource was deleted.\n\n## How to fix\n\n- Re-check the id (capitalisation, hyphens, environment).\n- If the resource should exist but you can't see it, confirm you're authenticated as the owner.\n- For webhook events: events are retained for 90 days; older events return 404.\n\n## Related codes\n\n- [`MARKET_NOT_FOUND`](./MARKET_NOT_FOUND.md) \u2014 specific case for markets\n",
56
56
  "ROUTE_DISABLED": '# `ROUTE_DISABLED`\n\n**HTTP status:** 503 \xB7 **Title:** "Route disabled" \xB7 **Retry-After:** 60s\n\n## When it fires\n\nA single route is disabled by ops via a per-route kill switch. Distinct from the coarse [`API_TRADE_PROCESSING_HALTED`](./API_TRADE_PROCESSING_HALTED.md) so SDK consumers can branch on "my entire trading capability is offline" vs "just one endpoint."\n\nThe Problem detail\'s `extensions.flag` field carries the kill-switch name (e.g., `"api-quotes-read"`) so you can tell exactly which route is gated.\n\n## Why it happens\n\n- Targeted rollback after a route-specific bug shipped.\n- Pre-deploy lockdown of one endpoint while the rest of the API stays live.\n- Capacity-driven shedding (rare \u2014 usually we\'d raise rate limits first).\n\n## How to fix\n\n- Honour `Retry-After`. The flag is binary; polling won\'t help.\n- Read the `extensions.flag` field \u2014 if it\'s an endpoint you don\'t actually need, ignore it; other endpoints are fine.\n- For mission-critical endpoints, contact support to understand the ETA.\n\n## Related codes\n\n- [`API_TRADE_PROCESSING_HALTED`](./API_TRADE_PROCESSING_HALTED.md) \u2014 coarser kill switch covering all trade writes\n- [`DEPENDENCY_UNAVAILABLE`](./DEPENDENCY_UNAVAILABLE.md) \u2014 distinct: this is "ops chose to disable", that\'s "infra is broken"\n',
57
57
  "SMART_ACCOUNT_NOT_PROVISIONED": "# `SMART_ACCOUNT_NOT_PROVISIONED`\n\n**HTTP status:** 409 \xB7 **Title:** \"Smart account not provisioned\"\n\n## When it fires\n\nThe actor (user or organization) doesn't have a smart account row yet, so trades can't execute on-chain.\n\n## Why it happens\n\n- New account that hasn't completed the wallet-creation step in the webapp.\n- An organization that's enabled the API but hasn't provisioned its own org-level smart account.\n- The smart-account worker is backlogged \u2014 provisioning is async.\n\n## How to fix\n\n- For users: complete the wallet setup flow in the webapp (Settings \u2192 Wallet). Smart account provisioning is async \u2014 typically a few seconds.\n- For orgs: an admin needs to provision the org smart account via the org settings page.\n- If you provisioned recently and still see this error, retry after 30 s. If it persists past a minute, contact support with your `requestId`.\n\n## Related codes\n\n- [`WALLET_DELEGATION_NOT_ENABLED`](./WALLET_DELEGATION_NOT_ENABLED.md) \u2014 smart account exists but Privy delegation is off\n- [`INSUFFICIENT_BALANCE`](./INSUFFICIENT_BALANCE.md) \u2014 smart account provisioned but no USDC\n",
58
- "SPENDING_LIMIT_EXCEEDED": "# `SPENDING_LIMIT_EXCEEDED`\n\n**HTTP status:** 409 \xB7 **Title:** \"Spending limit exceeded\"\n\n## When it fires\n\nThe trade would exceed one of the API key's spending caps:\n\n- `per_trade_limit_usdc` \u2014 single-trade maximum\n- `daily_spend_limit_usdc` \u2014 rolling 24-hour cumulative maximum across all trades\n\nThe `detail` field specifies which cap fired and by how much.\n\n## Why it happens\n\n- A bot iteration that computed a larger order than expected (e.g., signal scaling factor was off).\n- Cumulative drift over a busy day finally pushed a moderate trade over the daily cap.\n- The cap was lowered (by you or an admin) since you last designed your sizing logic.\n\n## How to fix\n\n- Inspect your key's caps in Settings \u2192 API Keys \u2192 Edit.\n- For per-trade overruns: split the trade into smaller chunks under the cap.\n- For daily overruns: wait for the rolling window to clear, or upgrade your tier (see \"How to raise the cap\" below).\n- Programmatically: every key's caps are returned in the issuance response \u2014 cache them so your client knows the headroom.\n\n## How to raise the cap\n\nThe cap is set by your API key's tier. See [`docs/api-tiers.md`](../api-tiers.md) for the full tier matrix and rationale, then:\n\n- **`free` \u2192 `developer`** (10\xD7 headroom \u2014 $1k \u2192 $10k daily, $500 \u2192 $2.5k per-trade): email [support@kash.bot](mailto:support@kash.bot) for early access. Self-serve via Stripe is planned ([`docs/todo/public-surface/PUBLIC_API_TIER_BILLING.md`](../todo/PUBLIC_API_TIER_BILLING.md)).\n- **`developer` \u2192 `enterprise`** ($100k daily, $25k per-trade, custom rate limit): [contact sales](mailto:sales@kash.bot) \u2014 pricing is contractual.\n- **MM-tier counterparty terms** ($1M daily, $50k per-trade): [contact partnerships](mailto:partnerships@kash.bot) \u2014 KYB and ToS attestation required; this is a relationship, not a price tier.\n\nThe caps are not punitive \u2014 they exist for blast-radius and AMM-stability reasons documented in [`docs/api-tiers.md`](../api-tiers.md). When you outgrow your tier, the cap is the signal to upgrade, not a problem to work around.\n\n## Related codes\n\n- [`AMOUNT_TOO_LARGE`](./AMOUNT_TOO_LARGE.md) \u2014 platform-wide cap, separate from your key's caps\n- [`INSUFFICIENT_BALANCE`](./INSUFFICIENT_BALANCE.md) \u2014 wallet balance too low (different failure surface)\n",
58
+ "SPENDING_LIMIT_EXCEEDED": "# `SPENDING_LIMIT_EXCEEDED`\n\n**HTTP status:** 409 \xB7 **Title:** \"Spending limit exceeded\"\n\n## When it fires\n\nThe trade would exceed one of the API key's spending caps:\n\n- `per_trade_limit_usdc` \u2014 single-trade maximum\n- `daily_spend_limit_usdc` \u2014 rolling 24-hour cumulative maximum across all trades\n\nThe `detail` field specifies which cap fired and by how much.\n\n## Why it happens\n\n- A bot iteration that computed a larger order than expected (e.g., signal scaling factor was off).\n- Cumulative drift over a busy day finally pushed a moderate trade over the daily cap.\n- The cap was lowered (by you or an admin) since you last designed your sizing logic.\n\n## How to fix\n\n- Inspect your key's caps in Settings \u2192 API Keys \u2192 Edit.\n- For per-trade overruns: split the trade into smaller chunks under the cap.\n- For daily overruns: wait for the rolling window to clear, or upgrade your tier (see \"How to raise the cap\" below).\n- Programmatically: every key's caps are returned in the issuance response \u2014 cache them so your client knows the headroom.\n\n## How to raise the cap\n\nThe cap is set by your API key's tier. See [`docs/api-tiers.md`](../api-tiers.md) for the full tier matrix and rationale, then:\n\n- **`free` \u2192 `developer`** (10\xD7 headroom \u2014 $1k \u2192 $10k daily, $500 \u2192 $2.5k per-trade): email [support@kash.bot](mailto:support@kash.bot) for early access. Self-serve via Stripe is planned ([`docs/todo/public-surface/PUBLIC_API_TIER_BILLING.md`](../todo/public-surface/PUBLIC_API_TIER_BILLING.md)).\n- **`developer` \u2192 `enterprise`** ($100k daily, $25k per-trade, custom rate limit): [contact sales](mailto:sales@kash.bot) \u2014 pricing is contractual.\n- **MM-tier counterparty terms** ($1M daily, $50k per-trade): [contact partnerships](mailto:partnerships@kash.bot) \u2014 KYB and ToS attestation required; this is a relationship, not a price tier.\n\nThe caps are not punitive \u2014 they exist for blast-radius and AMM-stability reasons documented in [`docs/api-tiers.md`](../api-tiers.md). When you outgrow your tier, the cap is the signal to upgrade, not a problem to work around.\n\n## Related codes\n\n- [`AMOUNT_TOO_LARGE`](./AMOUNT_TOO_LARGE.md) \u2014 platform-wide cap, separate from your key's caps\n- [`INSUFFICIENT_BALANCE`](./INSUFFICIENT_BALANCE.md) \u2014 wallet balance too low (different failure surface)\n",
59
59
  "TRADE_NOT_AWAITING_CONFIRMATION": "# `TRADE_NOT_AWAITING_CONFIRMATION`\n\n**HTTP status:** 409 \xB7 **Title:** \"Trade not awaiting confirmation\"\n\n## When it fires\n\n`POST /v1/trades/:id/confirm` was called for a trade that's not in `pending_confirmation` status.\n\n## Why it happens\n\n- The trade was already confirmed (you'll see this if you accidentally call confirm twice) \u2014 see also [`CONFIRMATION_TOKEN_USED`](./CONFIRMATION_TOKEN_USED.md).\n- The trade was below your tier's high-value threshold and never required confirmation in the first place.\n- The trade has progressed past confirmation into `pending` / `executing` / a terminal state.\n- The confirmation window expired and the trade was auto-cancelled \u2014 see [`CONFIRMATION_EXPIRED`](./CONFIRMATION_EXPIRED.md).\n\n## How to fix\n\n- Check the trade's current `status` via `GET /v1/trades/:id`. The lifecycle is: `pending_confirmation` \u2192 `pending` \u2192 `executing` \u2192 `completed`/`failed`.\n- If the trade is `completed`, there's nothing more to do.\n- If the trade is `cancelled`, re-create it and confirm within the new window.\n\n## Related codes\n\n- [`CONFIRMATION_EXPIRED`](./CONFIRMATION_EXPIRED.md), [`CONFIRMATION_TOKEN_INVALID`](./CONFIRMATION_TOKEN_INVALID.md), [`CONFIRMATION_TOKEN_USED`](./CONFIRMATION_TOKEN_USED.md)\n",
60
60
  "VALIDATION_FAILED": '# `VALIDATION_FAILED`\n\n**HTTP status:** 400 \xB7 **Title:** "Validation failed"\n\n## When it fires\n\nThe request body failed Zod schema parse. One or more fields are missing, malformed, or out of range.\n\n## Why it happens\n\n- Required field is missing or `null`.\n- Field has the wrong type (e.g., `amount` sent as a number instead of a string \u2014 we use string for arbitrary-precision USDC amounts).\n- Field violates a constraint (UUID format, enum value, min/max length).\n- An unknown extra field was sent \u2014 we accept extras (`.passthrough()`) so this is rarely the cause; if it is, you\'ll see it called out in `detail`.\n\n## How to fix\n\n- The `detail` field carries the path of the first offending field (e.g., `body.outcomeIndex must be a non-negative integer`).\n- Cross-reference with the OpenAPI spec at `https://api.kash.bot/v1/openapi.json` \u2014 every endpoint\'s request body is fully typed there.\n- If you\'re using the TS SDK, you\'d have caught this client-side via `KashValidationError` before the request went out.\n\n## Example\n\n```json\n{\n "type": "https://docs.kash.bot/developer-docs/api-errors/VALIDATION_FAILED",\n "title": "Validation failed",\n "status": 400,\n "code": "VALIDATION_FAILED",\n "detail": "body.amount must be a string matching ^[0-9]+(\\\\.[0-9]+)?$",\n "instance": "/v1/trades",\n "requestId": "01HX-..."\n}\n```\n\n## Related codes\n\n- [`AMOUNT_TOO_LARGE`](./AMOUNT_TOO_LARGE.md) \u2014 specific case for `amount` exceeding the per-trade cap\n- [`OUTCOME_INDEX_INVALID`](./OUTCOME_INDEX_INVALID.md) \u2014 specific case for invalid `outcomeIndex`\n',
61
61
  "WALLET_DELEGATION_NOT_ENABLED": "# `WALLET_DELEGATION_NOT_ENABLED`\n\n**HTTP status:** 409 \xB7 **Title:** \"Wallet delegation not enabled\"\n\n## When it fires\n\nA smart account exists for the actor, but Privy server-side delegation is disabled. The platform can't sign user-operations on behalf of the user, so trades can't execute.\n\nWe surface this at the API layer as a preflight check rather than failing at execution \u2014 better UX for the consumer.\n\n## Why it happens\n\n- The user revoked delegation in Privy after onboarding.\n- A Privy app config change disabled delegation for a class of users.\n- An incomplete onboarding flow that skipped the delegation grant step.\n\n## How to fix\n\n- The user must re-grant delegation via the webapp (Settings \u2192 Wallet \u2192 Re-enable). One-click; uses the existing Privy session.\n- For orgs, the org admin re-grants on behalf of the org wallet.\n- If the issue is platform-wide (multiple users), check the Privy app config or the status page.\n\n## Related codes\n\n- [`SMART_ACCOUNT_NOT_PROVISIONED`](./SMART_ACCOUNT_NOT_PROVISIONED.md) \u2014 earlier failure point\n",
@@ -162,4 +162,4 @@ function formatAction(action) {
162
162
  export {
163
163
  explainCommand
164
164
  };
165
- //# sourceMappingURL=explain-H4EH3KH3.js.map
165
+ //# sourceMappingURL=explain-3SPMWDYX.js.map