@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
@@ -1 +0,0 @@
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. Email `engineering@kash.bot` to request a key with broader scope.',\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. The most common\n // failure mode pre-mainnet-launch is \"configured for production\n // but production isn't deployed yet\" — point them at staging via\n // their test key rather than 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 'For staging, use a `kash_test_*` key — the CLI auto-routes to ' +\n '`https://api-staging.kash.bot/v1`. ' +\n 'For a custom host, pass `--base-url <url>` or set `KASH_BASE_URL`. ' +\n 'Production (`https://api.kash.bot/v1`) is not yet live; track launch ' +\n 'status at https://docs.kash.bot.'\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: 'mailto:engineering@kash.bot?subject=Kash%20staging%20API%20key%20request',\n description:\n 'Email `engineering@kash.bot` to request a `kash_test_*` staging key (self-service issuance ships with the production launch).',\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: 'mailto:engineering@kash.bot?subject=Kash%20API%20key%20scope%20request',\n description: 'Email `engineering@kash.bot` for a key with broader scope.',\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;A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AAO,EAAE,QAAQ,QAAQ,EAAE;AAC7B;AAeA,SAAS,iBAAiB,KAAoC;AAC5D,MAAI,EAAE,eAAe,OAAQ,QAAO;AACpC,UAAQ,IAAI,MAAM;AAAA,IAChB,KAAK,mBAAmB;AACtB,YAAM,SAAS,IAAI,SAAS,IAAI,SAAS;AAAA,QACvC,MAAM;AAAA,QACN,YACE;AAAA,QACF,OAAO;AAAA,MACT,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,KAAK;AACH,aAAO,IAAI,SAAS,IAAI,SAAS;AAAA,QAC/B,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,OAAO;AAAA,MACT,CAAC;AAAA,IACH,KAAK;AACH,aAAO,IAAI,SAAS,IAAI,SAAS;AAAA,QAC/B,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,OAAO;AAAA,MACT,CAAC;AAAA,IACH,KAAK;AACH,aAAO,IAAI,SAAS,IAAI,SAAS;AAAA,QAC/B,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,OAAO;AAAA,MACT,CAAC;AAAA,IACH,KAAK;AACH,aAAO,IAAI,SAAS,IAAI,SAAS;AAAA,QAC/B,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,OAAO;AAAA,MACT,CAAC;AAAA,IACH,KAAK;AAGH,aAAO,IAAI,SAAS,IAAI,SAAS;AAAA,QAC/B,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- buildClient
4
- } from "./chunk-QJMF73M5.js";
5
- import "./chunk-KMBMQIZ7.js";
6
- import "./chunk-YHCG2SUC.js";
7
- import "./chunk-BN2CUM42.js";
8
- import "./chunk-VIADBYFY.js";
9
- import "./chunk-MIXOZU2S.js";
10
- import "./chunk-UZNSYATZ.js";
11
- export {
12
- buildClient
13
- };
14
- //# sourceMappingURL=client-IOM55ZCS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/health.ts"],"sourcesContent":["/**\n * `kash health` — verify connectivity + key validity.\n *\n * Wraps the SDK's `KashClient.healthCheck`, which calls `GET /v1/health`\n * with a tight timeout and a single attempt (no retries — health\n * failures should be surfaced fast). The result is non-throwing: a\n * down server produces `ok: false`, not an exception, so scripts can\n * branch on the boolean without try/catch.\n *\n * Designed for two flows:\n *\n * 1. **Operator preflight** — run before a deploy or batch job to\n * confirm reachability and tag agreement.\n * 2. **AI-agent startup** — call once at boot, fail fast if Kash\n * is unreachable instead of mid-request.\n *\n * Exit code is `0` on `ok: true` and `1` on `ok: false`, so\n * `kash health || exit 1` is a valid one-liner gate.\n */\n\nimport { Command } from 'commander';\n\nimport { CliError, EXIT_CODES, toCliError } from '../errors.js';\nimport { buildClient } from '../utils/client.js';\nimport { readConfig } from '../utils/config-store.js';\nimport { readGlobals } from '../utils/global-options.js';\nimport { log, print, printJson, style } from '../utils/output.js';\n\n/**\n * Build a recovery suggestion for a failed health check based on the\n * resolved base URL. The two common failure modes pre-mainnet-launch:\n *\n * 1. User has no API key set → CLI defaults to `api.kash.bot/v1`,\n * which doesn't resolve until production deploys. Steer them at\n * a test key (which auto-routes to staging via\n * `inferBaseUrlFromApiKey`).\n * 2. User has a key but the host is genuinely unreachable (transient\n * network issue, corporate proxy, DNS hiccup) → generic retry.\n */\nfunction buildHealthFailureSuggestion(baseUrl: string): string {\n if (baseUrl.includes('api.kash.bot') && !baseUrl.includes('api-staging.kash.bot')) {\n return (\n 'Production (`https://api.kash.bot/v1`) is not yet live. ' +\n 'For staging, get a test key at https://app.kash.bot and run `kash setup ' +\n '--api-key kash_test_…` — the CLI auto-routes test keys to ' +\n '`https://api-staging.kash.bot/v1`. ' +\n 'To pin a different host, pass `--base-url <url>` or set `KASH_BASE_URL`.'\n );\n }\n return `The configured API host (${baseUrl}) was not reachable. Check connectivity and retry.`;\n}\n\nexport const healthCommand = new Command('health')\n .description(\n 'Check connectivity to the Kash API. Exits 1 when not ok. Honors --timeout-ms (default 5000).'\n )\n .addHelpText(\n 'after',\n `\nExamples:\n $ kash health\n $ kash health --json --quiet | jq -r '.ok'\n $ kash --timeout-ms 2000 health\n $ kash health || exit 1 # gate a script on reachability\n`\n )\n .action(async (_opts, cmd: Command) => {\n const globals = readGlobals(cmd);\n // Health-check default is tighter than the SDK's general 30s\n // default — failures should surface fast. The global\n // --timeout-ms still wins when set explicitly.\n const timeoutMs = globals.timeoutMs ?? 5000;\n\n let result;\n try {\n const { client } = await buildClient({ globals });\n result = await client.healthCheck({ timeoutMs });\n } catch (cause) {\n // The SDK's healthCheck only throws on caller-driven aborts\n // (KashAbortedError). Anything else is data, not an exception.\n throw toCliError(cause);\n }\n\n // **JSON-mode contract.** Always emit exactly ONE JSON object on\n // stdout — the previous code path emitted both the success-shape\n // `result` AND the error envelope on the !ok path, which broke\n // `jq` consumers. On the !ok path we throw a CliError with the\n // diagnostic data folded into `actions[]` so a single envelope\n // carries both the failure code and the latency / requestId\n // diagnostics.\n if (!result.ok) {\n // Resolve the config so the suggestion can reference the host the\n // CLI actually tried. Tolerate resolution failures (e.g. missing\n // config file) — fall back to a generic suggestion rather than\n // erroring inside an error handler.\n let suggestion = 'The Kash API was not reachable. Check connectivity and retry.';\n try {\n const cfg = await readConfig({\n ...(globals.profile === undefined ? {} : { profile: globals.profile }),\n ...(globals.configPath === undefined ? {} : { configPath: globals.configPath }),\n });\n suggestion = buildHealthFailureSuggestion(cfg.baseUrl);\n } catch {\n // ignore — keep generic suggestion\n }\n\n if (globals.json) {\n // Throw a CliError that carries the diagnostic data in its\n // envelope. The top-level emitError handler will print\n // exactly one JSON object on stdout. We pre-load the\n // recoverable + suggestion fields here rather than in the\n // catalog so the runtime data (latencyMs, requestId) is\n // visible to the agent reading the envelope.\n throw new CliError(\n `Health check failed (${String(result.latencyMs)}ms elapsed${result.requestId === undefined ? '' : `, request ${result.requestId}`}).`,\n {\n code: 'NETWORK',\n recoverable: true,\n suggestion,\n exitCode: EXIT_CODES.GENERIC,\n ...(result.requestId === undefined ? {} : { requestId: result.requestId }),\n }\n );\n }\n // Human mode: emit the error line + diagnostics on stderr,\n // then throw to drive the exit code through the top-level\n // emitError. The top-level handler prints the human error\n // footer on stderr too, so no stdout pollution.\n log.error(`Kash API not reachable. (${String(result.latencyMs)}ms elapsed)`);\n if (result.requestId !== undefined) {\n log.detail('Request ID', result.requestId);\n }\n throw new CliError('Health check failed.', {\n code: 'NETWORK',\n recoverable: true,\n suggestion,\n exitCode: EXIT_CODES.GENERIC,\n });\n }\n\n // ok path\n if (globals.json) {\n printJson(result);\n return;\n }\n const versionTag = result.version === undefined ? '' : ` (server ${result.version})`;\n print(`${style.success('✓')} Kash API reachable in ${String(result.latencyMs)}ms${versionTag}`);\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,eAAe;AAmBxB,SAAS,6BAA6B,SAAyB;AAC7D,MAAI,QAAQ,SAAS,cAAc,KAAK,CAAC,QAAQ,SAAS,sBAAsB,GAAG;AACjF,WACE;AAAA,EAMJ;AACA,SAAO,4BAA4B,OAAO;AAC5C;AAEO,IAAM,gBAAgB,IAAI,QAAQ,QAAQ,EAC9C;AAAA,EACC;AACF,EACC;AAAA,EACC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOF,EACC,OAAO,OAAO,OAAO,QAAiB;AACrC,QAAM,UAAU,YAAY,GAAG;AAI/B,QAAM,YAAY,QAAQ,aAAa;AAEvC,MAAI;AACJ,MAAI;AACF,UAAM,EAAE,OAAO,IAAI,MAAM,YAAY,EAAE,QAAQ,CAAC;AAChD,aAAS,MAAM,OAAO,YAAY,EAAE,UAAU,CAAC;AAAA,EACjD,SAAS,OAAO;AAGd,UAAM,WAAW,KAAK;AAAA,EACxB;AASA,MAAI,CAAC,OAAO,IAAI;AAKd,QAAI,aAAa;AACjB,QAAI;AACF,YAAM,MAAM,MAAM,WAAW;AAAA,QAC3B,GAAI,QAAQ,YAAY,SAAY,CAAC,IAAI,EAAE,SAAS,QAAQ,QAAQ;AAAA,QACpE,GAAI,QAAQ,eAAe,SAAY,CAAC,IAAI,EAAE,YAAY,QAAQ,WAAW;AAAA,MAC/E,CAAC;AACD,mBAAa,6BAA6B,IAAI,OAAO;AAAA,IACvD,QAAQ;AAAA,IAER;AAEA,QAAI,QAAQ,MAAM;AAOhB,YAAM,IAAI;AAAA,QACR,wBAAwB,OAAO,OAAO,SAAS,CAAC,aAAa,OAAO,cAAc,SAAY,KAAK,aAAa,OAAO,SAAS,EAAE;AAAA,QAClI;AAAA,UACE,MAAM;AAAA,UACN,aAAa;AAAA,UACb;AAAA,UACA,UAAU,WAAW;AAAA,UACrB,GAAI,OAAO,cAAc,SAAY,CAAC,IAAI,EAAE,WAAW,OAAO,UAAU;AAAA,QAC1E;AAAA,MACF;AAAA,IACF;AAKA,QAAI,MAAM,4BAA4B,OAAO,OAAO,SAAS,CAAC,aAAa;AAC3E,QAAI,OAAO,cAAc,QAAW;AAClC,UAAI,OAAO,cAAc,OAAO,SAAS;AAAA,IAC3C;AACA,UAAM,IAAI,SAAS,wBAAwB;AAAA,MACzC,MAAM;AAAA,MACN,aAAa;AAAA,MACb;AAAA,MACA,UAAU,WAAW;AAAA,IACvB,CAAC;AAAA,EACH;AAGA,MAAI,QAAQ,MAAM;AAChB,cAAU,MAAM;AAChB;AAAA,EACF;AACA,QAAM,aAAa,OAAO,YAAY,SAAY,KAAK,YAAY,OAAO,OAAO;AACjF,QAAM,GAAG,MAAM,QAAQ,QAAG,CAAC,0BAA0B,OAAO,OAAO,SAAS,CAAC,KAAK,UAAU,EAAE;AAChG,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/setup.ts"],"sourcesContent":["/**\n * `kash setup` — first-run interactive wizard.\n *\n * Collapses what's normally a four-step onboarding into a single\n * guided flow:\n * 1. Open the dashboard URL so the user can issue an API key.\n * 2. Paste the key (validated for the `kash_` prefix).\n * 3. Pick a profile name (defaults to `default`).\n * 4. Verify connectivity via `kash health`.\n * 5. Optionally install shell completion.\n *\n * **Lazy-loaded.** `@inquirer/prompts` is heavy — the dynamic import\n * keeps it out of the cold path for `kash --version` and other\n * non-interactive invocations. The KashClient + completion modules\n * are also lazy.\n *\n * **Skippable.** Every prompt has a sensible default and `--yes`\n * accepts all defaults non-interactively (CI / automation). `--json`\n * emits a structured summary at the end so post-setup scripts can\n * verify state without re-reading the config file.\n */\n\nimport { Command } from 'commander';\n\nimport { CliError, toCliError } from '../errors.js';\nimport { readGlobals } from '../utils/global-options.js';\nimport { log, print, printJson, style } from '../utils/output.js';\n\nimport type { GlobalOptions } from '../utils/global-options.js';\n\n// Staging release: production endpoints aren't deployed yet and the\n// self-service key-issuance dashboard isn't live. For now, customers\n// request a `kash_test_*` key by email; the SDK + CLI auto-route test\n// keys to the staging environment so the developer experience is\n// otherwise unchanged.\nconst KEY_REQUEST_EMAIL = 'engineering@kash.bot';\nconst KEY_REQUEST_INSTRUCTIONS = `Email ${KEY_REQUEST_EMAIL} with your intended use case to request a \\`kash_test_*\\` staging key. Self-service issuance is coming with the production launch.`;\n\ntype SetupOptions = {\n yes?: boolean;\n apiKey?: string;\n};\n\n/**\n * Per-scope probe result. `'ok'` means the canary call succeeded;\n * `'denied'` means the API returned 403 / INSUFFICIENT_SCOPE for that\n * scope (the key is valid but doesn't carry the scope); `'unknown'`\n * means the probe failed for a non-scope reason (network, server\n * error) — we don't pretend to know.\n */\ntype ScopeProbeStatus = 'ok' | 'denied' | 'unknown';\n\n/**\n * Output envelope when `--json` is set. Stable contract — agents and\n * provisioning scripts pin to it.\n */\ntype SetupResult = {\n ok: true;\n profile: string;\n authenticated: boolean;\n health: { ok: boolean; latencyMs?: number; status?: string; version?: string };\n /**\n * Best-effort scope detection from canary read calls. Each entry is\n * a granted/denied/unknown verdict for a named scope. Does NOT probe\n * write scopes (that'd require a real trade).\n */\n scopes: Record<string, ScopeProbeStatus>;\n completionInstalled: boolean;\n};\n\nexport const setupCommand = new Command('setup')\n .description('Interactive first-run wizard: configure an API key, verify, install completion.')\n .option('-y, --yes', 'accept all defaults and skip optional prompts (non-interactive)')\n .option('--api-key <key>', 'pass the API key non-interactively (skips the prompt)')\n .addHelpText(\n 'after',\n `\nExamples:\n $ kash setup\n $ kash setup --api-key kash_live_… --yes --json\n $ kash --profile staging setup --yes # write to a named profile\n $ KASH_API_KEY=kash_live_… kash setup --yes # picks up the env var\n\nNotes:\n - Re-runnable. Existing profiles are updated, not duplicated.\n - --yes accepts every default and skips optional prompts (no shell\n completion install). Combine with --api-key for full automation.\n - Use the top-level --profile flag (\\`kash --profile <name> setup\\`)\n to write to a named profile non-interactively.\n`\n )\n .action(async (options: SetupOptions, cmd: Command) => {\n const globals = readGlobals(cmd);\n\n try {\n const result = await runSetup(options, globals);\n if (globals.json) {\n printJson(result);\n }\n } catch (cause) {\n throw toCliError(cause);\n }\n });\n\nasync function runSetup(options: SetupOptions, globals: GlobalOptions): Promise<SetupResult> {\n const jsonMode = globals.json;\n // Lazy imports — see file header.\n const [{ confirm, input, password }, { updateConfig, setCurrentProfile }, { buildClient }] =\n await Promise.all([\n import('@inquirer/prompts'),\n import('../utils/config-store.js'),\n import('../utils/client.js'),\n ]);\n\n if (!jsonMode) {\n print('');\n print(style.bold('Kash CLI setup'));\n print(style.dim('Configure an API key, verify connectivity, install shell completion.'));\n print('');\n }\n\n // Resolve the API key. Precedence: --api-key flag → env → prompt.\n const envKey = process.env['KASH_API_KEY'];\n let apiKey: string;\n if (options.apiKey) {\n apiKey = options.apiKey;\n if (!jsonMode) log.info('Using --api-key from the command line.');\n } else if (envKey) {\n apiKey = envKey;\n if (!jsonMode) log.info('Using KASH_API_KEY from the environment.');\n } else if (options.yes) {\n throw new CliError('Cannot run --yes without an API key.', {\n code: 'INVALID_INPUT',\n recoverable: true,\n suggestion: `Pass --api-key <kash_…>, set KASH_API_KEY, or run \\`kash setup\\` without --yes. ${KEY_REQUEST_INSTRUCTIONS}`,\n });\n } else {\n if (!jsonMode) {\n print(`${style.dim('🧪 Staging release.')} ${KEY_REQUEST_INSTRUCTIONS} (Ctrl-C to abort.)`);\n }\n // Use the masked-input prompt — `input()` would echo every\n // keystroke to the terminal, defeating the protection that\n // `kash setup` should provide for fresh API keys (shoulder-\n // surfing, screen recording, scroll-back capture). The validation\n // shape is identical to the previous `input` call.\n apiKey = await password({\n message: 'Paste your API key:',\n mask: '*',\n validate: (value: string) => {\n const trimmed = value.trim();\n if (trimmed.length < 16) return 'API key looks too short.';\n if (!trimmed.startsWith('kash_')) return 'API keys start with \"kash_\".';\n return true;\n },\n });\n apiKey = apiKey.trim();\n }\n\n // Resolve the profile name. Precedence: top-level --profile flag →\n // interactive prompt → 'default'. We deliberately reuse the global\n // flag rather than declaring our own to avoid two profile flags\n // with subtly different semantics.\n let profile = globals.profile;\n if (profile === undefined && !options.yes) {\n profile = await input({\n message: 'Profile name:',\n default: 'default',\n });\n }\n profile = (profile ?? 'default').trim();\n\n // Persist. `updateConfig` handles the file IO, mode 0600, and Zod\n // validation. We only update apiKey — baseUrl/chain are inferred\n // from the key prefix on first request. Both calls thread the\n // global `--config <path>` override so `kash setup --config\n // /tmp/test.json` writes to the user-specified file rather than\n // silently falling back to ~/.kash/config.json.\n const writeOpts = {\n profile,\n ...(globals.configPath === undefined ? {} : { configPath: globals.configPath }),\n };\n const written = await updateConfig({ apiKey }, writeOpts);\n await setCurrentProfile(\n written.profile,\n globals.configPath === undefined ? undefined : { configPath: globals.configPath }\n );\n\n if (!jsonMode) {\n log.success(`Saved API key to profile \"${written.profile}\".`);\n }\n\n // Verify connectivity. We pass the just-resolved profile so the\n // health check reads the key we just wrote (not whatever was the\n // active profile before).\n let healthOk = false;\n let healthLatency: number | undefined;\n let healthStatus: string | undefined;\n let healthVersion: string | undefined;\n try {\n const { client } = await buildClient({\n requireAuth: true,\n // Reuse the resolved globals but pin the profile to the one we\n // just wrote — otherwise a stale flag could cause us to verify\n // a different profile than the one we configured.\n globals: { ...globals, profile: written.profile },\n });\n const result = await client.healthCheck();\n healthOk = result.ok;\n healthLatency = result.latencyMs;\n healthStatus = result.status;\n healthVersion = result.version;\n if (!jsonMode) {\n if (healthOk) {\n log.success(\n `Health check OK in ${String(healthLatency)}ms${\n healthVersion ? ` (server ${healthVersion})` : ''\n }.`\n );\n } else {\n log.warn('Health check returned not-ok. Verify your network or rerun later.');\n }\n }\n } catch (cause) {\n // Don't fail setup on a flaky health check — the key may still be\n // good and the user just has temporary connectivity issues.\n if (!jsonMode) {\n log.warn(`Health check failed: ${cause instanceof Error ? cause.message : String(cause)}`);\n log.info('Setup completed; verify later with `kash health`.');\n }\n }\n\n // Probe a handful of read scopes via canary calls. We don't probe\n // write scopes (that'd require a real trade or webhook rotation),\n // and we don't fail setup on probe errors — the key still works,\n // we just couldn't tell which scopes it carries.\n const scopes = await probeReadScopes({ globals, profile: written.profile });\n if (!jsonMode) {\n renderScopesHuman(scopes);\n }\n\n // Optional: shell completion. Skip in --yes mode (no good default\n // for an action that mutates the user's shell rc files).\n let completionInstalled = false;\n if (!options.yes && !jsonMode) {\n const detectedShell = process.env['SHELL'] ?? '(unknown)';\n const wantCompletion = await confirm({\n message: `Install shell completion for ${detectedShell}?`,\n default: true,\n });\n if (wantCompletion) {\n try {\n const { default: omelette } = await import('omelette');\n const completion = omelette('kash');\n completion.setupShellInitFile();\n completionInstalled = true;\n log.success('Shell completions installed.');\n log.info('Restart your shell or source your shell config to activate.');\n } catch (cause) {\n log.warn(\n `Could not install completion: ${cause instanceof Error ? cause.message : String(cause)}`\n );\n }\n }\n }\n\n if (!jsonMode) {\n print('');\n print(style.bold(\"You're all set.\"));\n // Pick a \"Try:\" suggestion the user's key actually has scope for.\n // Pre-fix this was hardcoded to `markets list --status ACTIVE`,\n // which fails immediately for keys that only carry webhooks-read\n // / trades-read scope. Probe results drive the suggestion now.\n for (const line of pickNextStepHints(scopes)) {\n print(` ${style.dim('Try:')} ${line}`);\n }\n print(` ${style.dim(' :')} kash docs --json --quiet | jq '.subcommands[].name'`);\n print('');\n }\n\n return {\n ok: true,\n profile: written.profile,\n authenticated: true,\n health: {\n ok: healthOk,\n ...(healthLatency === undefined ? {} : { latencyMs: healthLatency }),\n ...(healthStatus === undefined ? {} : { status: healthStatus }),\n ...(healthVersion === undefined ? {} : { version: healthVersion }),\n },\n scopes,\n completionInstalled,\n };\n}\n\n/**\n * Probe-derived scope detection.\n *\n * Each named scope is mapped to a canary SDK call. We invoke the call\n * with a minimal pageSize and inspect the failure mode to classify:\n *\n * - call resolves → `'ok'` (scope present)\n * - throws KashAuthorizationError(INSUFFICIENT_SCOPE) → `'denied'`\n * - throws anything else → `'unknown'` (probe inconclusive,\n * don't claim the scope is missing)\n *\n * Read-only by design — write scopes (`trades:create`, `auth:manage`)\n * would require either a real mutation or a sentinel \"what scopes do\n * I have?\" endpoint, which the API doesn't currently expose.\n */\nasync function probeReadScopes(opts: {\n globals: GlobalOptions;\n profile: string;\n}): Promise<Record<string, ScopeProbeStatus>> {\n const { buildClient } = await import('../utils/client.js');\n const { client } = await buildClient({\n requireAuth: true,\n globals: { ...opts.globals, profile: opts.profile },\n });\n\n // Each canary is a (scope-name, call) pair. Call uses limit:1 to\n // minimise server load. Order is stable so the JSON envelope is\n // pinnable.\n const probes: ReadonlyArray<readonly [string, () => Promise<unknown>]> = [\n ['markets:read', async () => client.markets.list({ limit: 1 })],\n ['trades:read', async () => client.trades.list({ limit: 1 })],\n ['webhooks:read', async () => client.webhooks.list({ limit: 1 })],\n ];\n\n const result: Record<string, ScopeProbeStatus> = {};\n for (const [scope, call] of probes) {\n result[scope] = await classifyProbe(call);\n }\n return result;\n}\n\nasync function classifyProbe(call: () => Promise<unknown>): Promise<ScopeProbeStatus> {\n try {\n await call();\n return 'ok';\n } catch (cause) {\n // The SDK's KashAuthorizationError carries `code: 'INSUFFICIENT_SCOPE'`.\n // We duck-type rather than import the class to avoid a dependency\n // on the SDK's class identity (an instanceof check would couple\n // to the exact module-graph copy of @kashdao/sdk).\n if (cause !== null && typeof cause === 'object') {\n const code = (cause as { code?: unknown }).code;\n if (code === 'INSUFFICIENT_SCOPE') return 'denied';\n }\n return 'unknown';\n }\n}\n\nfunction renderScopesHuman(scopes: Record<string, ScopeProbeStatus>): void {\n const entries = Object.entries(scopes);\n if (entries.length === 0) return;\n const allOk = entries.every(([, v]) => v === 'ok');\n if (allOk) {\n log.success('Scope check OK — key carries every probed read scope.');\n return;\n }\n log.info('Scope detection (probed via canary read calls):');\n for (const [scope, status] of entries) {\n const label =\n status === 'ok'\n ? style.success('granted')\n : status === 'denied'\n ? style.warn('not granted')\n : style.dim('inconclusive');\n print(` ${style.dim(scope.padEnd(16))} ${label}`);\n }\n const denied = entries.filter(([, v]) => v === 'denied').map(([k]) => k);\n if (denied.length > 0) {\n log.info(\n `Request a key with broader scope by emailing ${KEY_REQUEST_EMAIL} if you need: ${denied.join(', ')}.`\n );\n }\n}\n\n/**\n * Pick `kash <…>` suggestions to surface in the post-setup banner,\n * gated on the scopes the probe confirmed. Order from most-common\n * to least-common; emit at most 2 lines so the banner stays terse.\n *\n * Falls back to a generic \"see `kash --help`\" when no probed scope\n * looks usable (rare — the probe already errored loudly in that\n * case, but we keep the wizard's last line useful regardless).\n */\nfunction pickNextStepHints(scopes: Record<string, ScopeProbeStatus>): readonly string[] {\n const hints: string[] = [];\n if (scopes['markets:read'] === 'ok') {\n hints.push('kash markets list --status ACTIVE');\n }\n if (scopes['trades:read'] === 'ok') {\n hints.push('kash trade list --json --quiet | jq -r \".data[].id\"');\n }\n if (scopes['webhooks:read'] === 'ok' && hints.length < 2) {\n hints.push('kash webhooks list --status failed,retrying');\n }\n if (hints.length === 0) {\n // Probe results were inconclusive or every read scope was denied.\n // The earlier `renderScopesHuman` already surfaced the per-scope\n // verdict; keep the banner non-actionable instead of pointing at\n // a command that 403s.\n hints.push('kash --help');\n }\n return hints.slice(0, 2);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA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