@agenzo/admin-cli 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.
- package/LICENSE +21 -0
- package/README.md +285 -0
- package/dist/chunk-AZALPHQR.js +126 -0
- package/dist/chunk-AZALPHQR.js.map +1 -0
- package/dist/chunk-UIGWXIDT.js +41 -0
- package/dist/chunk-UIGWXIDT.js.map +1 -0
- package/dist/formatter-3JVOJXN6.js +10 -0
- package/dist/formatter-3JVOJXN6.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1862 -0
- package/dist/index.js.map +1 -0
- package/dist/output-VMJKMMKS.js +13 -0
- package/dist/output-VMJKMMKS.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/errors.ts","../src/utils/version.ts","../src/api/client.ts","../src/config/config-manager.ts","../src/config/credential-store.ts","../src/config/key-store.ts","../src/utils/prompt-engine.ts","../src/auth/auth-service.ts","../src/utils/exit.ts","../src/auth/login.ts","../src/auth/logout.ts","../src/config/set.ts","../src/orgs/get.ts","../src/orgs/update.ts","../src/orgs/list.ts","../src/orgs/switch.ts","../src/developers/billing-mode.ts","../src/developers/create.ts","../src/developers/list.ts","../src/developers/get.ts","../src/developers/update.ts","../src/keys/scope.ts","../src/keys/create.ts","../src/keys/list.ts","../src/keys/get.ts","../src/keys/rotate.ts","../src/keys/disable.ts","../src/accounts/get.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { ApiClient } from './api/client.js';\nimport { ConfigManager } from './config/config-manager.js';\nimport { CredentialStore } from './config/credential-store.js';\nimport { KeyStore } from './config/key-store.js';\nimport { AuthService } from './auth/auth-service.js';\nimport { Formatter } from './utils/formatter.js';\nimport {\n CliError,\n AuthError,\n UserCancelError,\n toErrorEnvelope,\n} from './utils/errors.js';\nimport { resolveFormat, type OutputFormat } from './utils/output.js';\nimport { exitCodeFor } from './utils/exit.js';\nimport { getCurrentVersion } from './utils/version.js';\n\n// Auth commands\nimport { registerLoginCommand } from './auth/login.js';\nimport { registerLogoutCommand } from './auth/logout.js';\n\n// Config commands\nimport { registerConfigCommand } from './config/set.js';\n\n// Orgs commands\nimport { registerMeCommand } from './orgs/get.js';\nimport { registerUpdateCommand as registerOrgUpdateCommand } from './orgs/update.js';\nimport { registerListCommand as registerOrgListCommand } from './orgs/list.js';\nimport { registerSwitchCommand } from './orgs/switch.js';\n\n// Developers commands\nimport { registerCreateCommand as registerDevCreateCommand } from './developers/create.js';\nimport { registerListCommand as registerDevListCommand } from './developers/list.js';\nimport { registerGetCommand as registerDevGetCommand } from './developers/get.js';\nimport { registerUpdateCommand as registerDevUpdateCommand } from './developers/update.js';\n\n// Keys commands\nimport { registerCreateCommand as registerKeyCreateCommand } from './keys/create.js';\nimport { registerListCommand as registerKeyListCommand } from './keys/list.js';\nimport { registerGetCommand as registerKeyGetCommand } from './keys/get.js';\nimport { registerRotateCommand } from './keys/rotate.js';\nimport { registerDisableCommand as registerKeyDisableCommand } from './keys/disable.js';\n\n// Accounts commands\nimport { registerGetCommand as registerAccountGetCommand } from './accounts/get.js';\n\n// Holds the parsed program so the top-level error handler can read the\n// resolved `--format` global flag. Assigned inside `main()` once the program\n// is constructed; may be undefined if an error is thrown before then.\nlet programRef: Command | undefined;\n\nasync function main() {\n // Instantiate shared infrastructure\n const configManager = new ConfigManager();\n await configManager.ensureDirectories();\n\n const credentialStore = new CredentialStore();\n const keyStore = new KeyStore();\n\n const apiBaseUrl = await configManager.getApiBaseUrl();\n const apiClient = new ApiClient({ baseUrl: apiBaseUrl });\n\n const authService = new AuthService(apiClient, credentialStore, configManager);\n\n // Shared deps objects\n const controlPlaneDeps = { apiClient, authService, credentialStore, configManager };\n const keysDeps = { apiClient, authService, keyStore, configManager };\n const orgsDeps = { credentialStore, configManager };\n\n // Create program\n const program = new Command();\n programRef = program;\n program\n .name('agenzo-admin-cli')\n .version(getCurrentVersion())\n .description(\n 'Agenzo control plane: login, organizations, developers, API keys, settlement accounts, and config',\n )\n .option('--verbose', 'Show verbose logs')\n .option('--yes', 'Skip confirmation prompts (for automation/AI Agents)')\n .option(\n '--format <format>',\n 'Output format: json | table (default: table; or set AGENZO_FORMAT)',\n );\n\n // Mirror the resolved global --format into AGENZO_FORMAT before any action\n // runs, so code paths without direct format access (e.g. AuthService's\n // auto re-login deep inside executeWithAuth) can resolve the active format\n // and stay silent in json mode. resolveFormat already honors the flag; this\n // just makes the flag value visible to env-based readers.\n program.hook('preAction', (thisCommand) => {\n const flag = thisCommand.opts().format as string | undefined;\n process.env.AGENZO_FORMAT = resolveFormat(flag);\n });\n\n // Auth command group\n const authCmd = program.command('auth').description('Authentication');\n registerLoginCommand(authCmd, { authService });\n registerLogoutCommand(authCmd, { authService });\n\n // Config command\n registerConfigCommand(program, { configManager, credentialStore });\n\n // Orgs command group\n const orgsCmd = program.command('orgs').description('Organization management');\n registerMeCommand(orgsCmd, controlPlaneDeps);\n registerOrgUpdateCommand(orgsCmd, controlPlaneDeps);\n registerOrgListCommand(orgsCmd, orgsDeps);\n registerSwitchCommand(orgsCmd, orgsDeps);\n\n // Developers command group\n const devsCmd = program.command('developers').description('Developer management');\n registerDevCreateCommand(devsCmd, controlPlaneDeps);\n registerDevListCommand(devsCmd, controlPlaneDeps);\n registerDevGetCommand(devsCmd, controlPlaneDeps);\n registerDevUpdateCommand(devsCmd, controlPlaneDeps);\n\n // Keys command group\n const keysCmd = program.command('keys').description('API Key management');\n registerKeyCreateCommand(keysCmd, keysDeps);\n registerKeyListCommand(keysCmd, controlPlaneDeps);\n registerKeyGetCommand(keysCmd, controlPlaneDeps);\n registerRotateCommand(keysCmd, keysDeps);\n registerKeyDisableCommand(keysCmd, controlPlaneDeps);\n\n // Accounts command group\n const accountsCmd = program.command('accounts').description('Settlement account management');\n registerAccountGetCommand(accountsCmd, controlPlaneDeps);\n\n // Parse and execute\n await program.parseAsync(process.argv);\n}\n\n/**\n * Resolve the active output format for error reporting. Prefers the parsed\n * global `--format` flag (available on `programRef` once the program is\n * constructed); if an error was thrown before parsing, falls back to\n * `resolveFormat(undefined)` (which consults `AGENZO_FORMAT`, else `table`).\n */\nfunction resolveActiveFormat(): OutputFormat {\n const flag = programRef?.opts().format as string | undefined;\n return resolveFormat(flag);\n}\n\n/**\n * Top-level failure path. Writes the error envelope to stderr in the resolved\n * format and exits with the mapped code (1–5). stdout is left untouched so a\n * partial machine payload is never emitted on failure.\n *\n * - `json`: a single `{ error: { code, message, http? } }` envelope.\n * - `table`: `✗ <message>` plus, for `AuthError`, the suggestion line.\n */\nfunction reportError(error: unknown): never {\n const envelope = toErrorEnvelope(error);\n const format = resolveActiveFormat();\n\n if (format === 'json') {\n console.error(JSON.stringify(envelope));\n } else {\n console.error(Formatter.status('error', envelope.error.message));\n if (error instanceof AuthError) {\n console.error(Formatter.status('info', error.suggestion));\n }\n // Unknown (non-CliError) failures keep the --verbose raw-dump affordance.\n if (!(error instanceof CliError) && process.argv.includes('--verbose')) {\n console.error(error);\n }\n }\n\n // exitCodeFor owns the error-class → exit-code matrix, including\n // UpgradeRequiredError → 2 and UserCancelError → 5.\n process.exit(exitCodeFor(error));\n}\n\n// Ctrl+C / SIGINT maps to a user-cancel (exit 5) via the same envelope path.\nprocess.on('SIGINT', () => {\n reportError(new UserCancelError());\n});\n\n// Global error handler. Normal completion exits 0 naturally (the mapper is\n// never consulted on success).\nmain().catch(reportError);\n","/** Base class for all CLI errors */\nexport abstract class CliError extends Error {\n abstract readonly code: string;\n}\n\n/** API business error (backend error code) */\nexport class ApiBusinessError extends CliError {\n readonly code = 'API_BUSINESS_ERROR';\n constructor(\n public readonly errorCode: number,\n public readonly errorMessage: string,\n public readonly statusCode: number,\n ) {\n super(`[${errorCode}] ${errorMessage}`);\n }\n}\n\n/** Network error (timeout, connection failure) */\nexport class NetworkError extends CliError {\n readonly code = 'NETWORK_ERROR';\n constructor(\n public readonly url: string,\n public readonly timeout?: number,\n public readonly cause?: Error,\n ) {\n const detail = cause?.message;\n let msg: string;\n if (timeout) {\n msg = `Request timed out (${timeout}ms): ${url}`;\n } else if (detail) {\n msg = `Connection failed: ${url} (${detail})`;\n } else {\n msg = `Connection failed: ${url}`;\n }\n super(msg);\n }\n}\n\n/** Authentication error (not logged in, token expired) */\nexport class AuthError extends CliError {\n readonly code = 'AUTH_ERROR';\n constructor(\n message: string,\n public readonly suggestion: string,\n ) {\n super(message);\n }\n}\n\n/** Configuration error (corrupted file, unwritable directory) */\nexport class ConfigError extends CliError {\n readonly code = 'CONFIG_ERROR';\n constructor(\n message: string,\n public readonly filePath: string,\n ) {\n super(message);\n }\n}\n\n/** Input validation error */\nexport class ValidationError extends CliError {\n readonly code = 'VALIDATION_ERROR';\n constructor(message: string) {\n super(message);\n }\n}\n\n/**\n * A server-write command was invoked without the mandatory `--idempotency-key`.\n * Every command that issues a backend write requires the caller to supply an\n * idempotency key (the CLI never auto-generates one), so its absence is a local\n * input error surfaced as `PARAM_IDEMPOTENCY_KEY_REQUIRED` (exit code 1).\n */\nexport class IdempotencyKeyRequiredError extends CliError {\n readonly code = 'IDEMPOTENCY_KEY_REQUIRED_ERROR';\n constructor(commandPath: string) {\n super(\n `\\`${commandPath}\\` requires --idempotency-key <key>. ` +\n 'Supply a unique key so the write can be safely retried.',\n );\n }\n}\n\n/**\n * CLI version is below the server-advertised minimum. Thrown from the API\n * client before the response body is parsed; handled by the top-level error\n * handler which exits with a non-zero code so CI/automation can detect it.\n */\nexport class UpgradeRequiredError extends CliError {\n readonly code = 'UPGRADE_REQUIRED';\n constructor(\n public readonly currentVersion: string,\n public readonly minVersion: string,\n public readonly upgradeCommand: string,\n ) {\n super(\n `agenzo-admin-cli ${currentVersion} is out of date — the server requires ` +\n `${minVersion} or newer. To upgrade, run: ${upgradeCommand}`,\n );\n }\n}\n\n/**\n * User cancelled the operation — SIGINT / Ctrl+C, or answering `n` at a\n * confirmation prompt. Maps to the public `USER_CANCELLED` catalog code and\n * exit code 5.\n *\n * NOTE: `code` here is the *class identifier* ('USER_CANCEL_ERROR'), matching\n * the structural check in `utils/exit.ts`. It is intentionally distinct from\n * the outward-facing `ErrorCode` catalog value ('USER_CANCELLED') below.\n */\nexport class UserCancelError extends CliError {\n readonly code = 'USER_CANCEL_ERROR';\n constructor(message = 'Operation cancelled by user') {\n super(message);\n // Subclasses do not inherit a useful `name` automatically; set it so\n // structural detectors (e.g. exit.ts) can recognise the class by name.\n this.name = 'UserCancelError';\n }\n}\n\n/**\n * Public, machine-readable error code emitted in the error envelope\n * (cli-standard §5.3/§10; cli-design §7.7.3 BACK-020). SCREAMING_SNAKE, drawn\n * from the domain prefixes AUTH_* / ORG_* / KEY_* / PARAM_* / RATE_* /\n * UPSTREAM_*, plus the standalone UPGRADE_REQUIRED / USER_CANCELLED /\n * INTERNAL_ERROR.\n *\n * IMPORTANT: This outward-facing catalog code is distinct from each\n * `CliError` subclass's `readonly code` (a class identifier such as\n * 'AUTH_ERROR' or 'USER_CANCEL_ERROR'). Do not conflate the two — `code` on\n * the class identifies the thrown class; `ErrorCode` is the public catalog\n * surfaced to Agents/CI in the error envelope.\n */\nexport type ErrorCode =\n | 'AUTH_FAILED'\n | 'AUTH_INVALID_API_KEY'\n | 'AUTH_NOT_SIGNED_IN'\n | 'AUTH_SESSION_EXPIRED'\n | 'AUTH_TIMEOUT'\n | 'ORG_NOT_FOUND'\n | 'ORG_CONFLICT'\n | 'KEY_NOT_FOUND'\n | 'KEY_SCOPE_DENIED'\n | 'PARAM_INVALID'\n | 'PARAM_MISSING'\n | 'PARAM_IDEMPOTENCY_KEY_REQUIRED'\n | 'PARAM_IDEMPOTENCY_KEY_CONFLICT'\n | 'RATE_LIMITED'\n | 'UPSTREAM_UNAVAILABLE'\n | 'UPGRADE_REQUIRED'\n | 'USER_CANCELLED'\n | 'INTERNAL_ERROR';\n\n/**\n * Pick the AUTH_* sub-code for an `AuthError`. The reused `AuthError` class\n * carries no structured discriminator (the split keeps AuthService logic\n * verbatim), so the trigger is inferred from the human message/suggestion:\n * magic-link timeout -> AUTH_TIMEOUT, expired/refresh failure ->\n * AUTH_SESSION_EXPIRED, otherwise the default \"not signed in\".\n */\nfunction authErrorCode(error: AuthError): ErrorCode {\n const haystack = `${error.message} ${error.suggestion}`.toLowerCase();\n if (haystack.includes('timed out') || haystack.includes('timeout')) {\n return 'AUTH_TIMEOUT';\n }\n if (\n haystack.includes('expired') ||\n haystack.includes('session') ||\n haystack.includes('refresh')\n ) {\n return 'AUTH_SESSION_EXPIRED';\n }\n return 'AUTH_NOT_SIGNED_IN';\n}\n\n/**\n * Derive the public `ErrorCode` for any thrown value (cli-standard §5.3).\n *\n * Keys off `instanceof` first, then subdivides `ApiBusinessError` by HTTP\n * `statusCode`. Anything unrecognised maps to `INTERNAL_ERROR`, so the return\n * value is always a member of the `ErrorCode` union.\n *\n * Per the design's \"Error class -> code -> exit-code matrix\".\n */\nexport function errorCodeFor(error: unknown): ErrorCode {\n // instanceof checks take priority over status-code subdivision.\n if (error instanceof UpgradeRequiredError) {\n return 'UPGRADE_REQUIRED';\n }\n if (error instanceof UserCancelError) {\n return 'USER_CANCELLED';\n }\n if (error instanceof AuthError) {\n return authErrorCode(error);\n }\n if (error instanceof ValidationError) {\n return 'PARAM_INVALID';\n }\n if (error instanceof IdempotencyKeyRequiredError) {\n return 'PARAM_IDEMPOTENCY_KEY_REQUIRED';\n }\n if (error instanceof ConfigError) {\n return 'INTERNAL_ERROR';\n }\n if (error instanceof NetworkError) {\n return 'UPSTREAM_UNAVAILABLE';\n }\n\n // ApiBusinessError — subdivide by backend HTTP status.\n if (error instanceof ApiBusinessError) {\n const status = error.statusCode;\n if (status === 401) {\n return 'AUTH_FAILED';\n }\n if (status === 403) {\n return 'KEY_SCOPE_DENIED';\n }\n if (status === 404) {\n // Resource-specific: ORG_NOT_FOUND vs KEY_NOT_FOUND. `errorCodeFor` sees\n // only the error, not the command noun, so it defaults to ORG_NOT_FOUND;\n // a calling command may refine this when it constructs the error.\n // (design: \"Resource-specific 404 is chosen by the calling command's noun.\")\n return 'ORG_NOT_FOUND';\n }\n if (status === 409) {\n return 'ORG_CONFLICT';\n }\n if (status === 429) {\n return 'RATE_LIMITED';\n }\n if (status >= 500) {\n return 'UPSTREAM_UNAVAILABLE';\n }\n // Any other 4xx is a business / parameter error.\n return 'PARAM_INVALID';\n }\n\n // Unrecognised throwable.\n return 'INTERNAL_ERROR';\n}\n\n/**\n * Shape written to stderr on failure (cli-design §7.7.3 BACK-021).\n * `http` is the backend HTTP status, present only when the failure came from\n * an HTTP call.\n */\nexport interface ErrorEnvelope {\n error: { code: ErrorCode; message: string; http?: number };\n}\n\n/**\n * Build the stderr error envelope for any thrown value. `code` is always a\n * known `ErrorCode`; `message` is always non-empty. `http` is included only\n * when the failure originated from an HTTP call — `ApiBusinessError` carries\n * the backend status, whereas `NetworkError` never received a response and so\n * reports no status.\n */\nexport function toErrorEnvelope(error: unknown): ErrorEnvelope {\n const code = errorCodeFor(error);\n\n let message: string;\n if (error instanceof Error && error.message) {\n message = error.message;\n } else if (typeof error === 'string' && error.length > 0) {\n message = error;\n } else {\n message = 'Unexpected error';\n }\n\n const http = error instanceof ApiBusinessError ? error.statusCode : undefined;\n if (http === undefined) {\n return { error: { code, message } };\n }\n return { error: { code, message, http } };\n}\n","/**\n * CLI version + min-version comparator.\n *\n * The CLI's current version is read from `package.json` at runtime. This is\n * the single source of truth — bumping `package.json` automatically updates\n * what the CLI reports and what it compares against the server-advertised\n * minimum (`X-CLI-Min-Version` response header, driven by\n * `AGENT_PAY_CLI_MIN_VERSION` on the server).\n *\n * Only numeric major.minor.patch segments are compared; pre-release and build\n * metadata suffixes are stripped. This matches our versioning scheme and\n * avoids pulling in `semver` for a single `<` check.\n */\n\nimport { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/** Command the user should run to pick up the latest CLI. */\nexport const UPGRADE_COMMAND = 'npm install -g agenzo-admin-cli@latest';\n\n/**\n * Hard-coded fallback used only when `package.json` cannot be read at runtime\n * (unusual packaging/bundling edge cases). Keep this in sync with\n * `package.json`'s `version` on every release so the reported version and\n * the User-Agent stay accurate even in the degraded path.\n */\nexport const FALLBACK_VERSION = '0.1.1';\n\nlet cachedVersion: string | null = null;\n\nexport function getCurrentVersion(): string {\n if (cachedVersion !== null) return cachedVersion;\n // Walk up from the compiled file (dist/index.js) or source layout to find\n // package.json. Both `dist/..` and `src/utils/../..` resolve to the project\n // root, which is where package.json lives in a published npm install.\n const here = dirname(fileURLToPath(import.meta.url));\n const candidates = [\n join(here, '..', 'package.json'), // dist/ → project root\n join(here, '..', '..', 'package.json'), // src/utils/ → project root\n ];\n for (const p of candidates) {\n try {\n const pkg = JSON.parse(readFileSync(p, 'utf-8')) as { version?: string };\n if (typeof pkg.version === 'string') {\n cachedVersion = pkg.version;\n return cachedVersion;\n }\n } catch {\n // try next candidate\n }\n }\n // Degrade gracefully instead of crashing the CLI: if we can't locate\n // package.json at runtime, report the hard-coded fallback. The User-Agent\n // and any min-version comparison will still behave sensibly. We write a\n // one-line warning to stderr so packaging regressions remain visible.\n cachedVersion = FALLBACK_VERSION;\n // eslint-disable-next-line no-console\n console.warn(\n `[agenzo-admin-cli] package.json not found; using fallback version ${FALLBACK_VERSION}`,\n );\n return cachedVersion;\n}\n\n/**\n * Returns negative / zero / positive like `Array.sort`, comparing `a` against `b`.\n * Non-numeric segments and suffixes are treated as zero.\n */\nexport function compareVersions(a: string, b: string): number {\n const parse = (v: string): [number, number, number] => {\n const clean = v.trim().replace(/^v/, '').split(/[-+]/)[0];\n const parts = clean.split('.');\n return [\n parseInt(parts[0] ?? '0', 10) || 0,\n parseInt(parts[1] ?? '0', 10) || 0,\n parseInt(parts[2] ?? '0', 10) || 0,\n ];\n };\n const [a1, a2, a3] = parse(a);\n const [b1, b2, b3] = parse(b);\n if (a1 !== b1) return a1 - b1;\n if (a2 !== b2) return a2 - b2;\n return a3 - b3;\n}\n\nexport function isBelow(current: string, minimum: string): boolean {\n return compareVersions(current, minimum) < 0;\n}\n","import { NetworkError, UpgradeRequiredError } from '../utils/errors.js';\nimport { getCurrentVersion, isBelow, UPGRADE_COMMAND } from '../utils/version.js';\n\nexport interface ApiClientConfig {\n baseUrl: string;\n timeout?: number; // Default 30000ms\n}\n\nexport interface ApiResponse<T> {\n success: true;\n data: T;\n /** Server-provided message from the unified response envelope. */\n message?: string;\n}\n\nexport interface ApiError {\n success: false;\n errorCode: number;\n errorMessage: string;\n statusCode: number;\n}\n\nexport type ApiResult<T> = ApiResponse<T> | ApiError;\n\nexport type AuthMode =\n | { type: 'bearer'; token: string }\n | { type: 'api-key'; key: string }\n | { type: 'none' };\n\nexport class ApiClient {\n private readonly baseUrl: string;\n private readonly timeout: number;\n\n constructor(config: ApiClientConfig) {\n this.baseUrl = config.baseUrl.replace(/\\/+$/, '');\n this.timeout = config.timeout ?? 60000;\n }\n\n private buildHeaders(auth: AuthMode): Record<string, string> {\n const headers: Record<string, string> = {\n 'User-Agent': `agenzo-admin-cli/${getCurrentVersion()}`,\n };\n if (auth.type === 'bearer') {\n headers['Authorization'] = `Bearer ${auth.token}`;\n } else if (auth.type === 'api-key') {\n headers['X-Api-Key'] = auth.key;\n }\n return headers;\n }\n\n async get<T>(\n path: string,\n auth: AuthMode,\n params?: Record<string, string>,\n ): Promise<ApiResult<T>> {\n let url = `${this.baseUrl}${path}`;\n if (params && Object.keys(params).length > 0) {\n const searchParams = new URLSearchParams(params);\n url += `?${searchParams.toString()}`;\n }\n return this.request<T>(url, {\n method: 'GET',\n headers: this.buildHeaders(auth),\n });\n }\n\n async post<T>(\n path: string,\n auth: AuthMode,\n body?: Record<string, unknown>,\n extraHeaders?: Record<string, string>,\n ): Promise<ApiResult<T>> {\n const url = `${this.baseUrl}${path}`;\n const headers = this.buildHeaders(auth);\n headers['Content-Type'] = 'application/json';\n if (extraHeaders) {\n Object.assign(headers, extraHeaders);\n }\n return this.request<T>(url, {\n method: 'POST',\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n }\n\n private async request<T>(url: string, init: RequestInit): Promise<ApiResult<T>> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const response = await fetch(url, {\n ...init,\n signal: controller.signal,\n });\n\n // Enforce server-advertised CLI version floor before doing any work\n // on the response. Throws UpgradeRequiredError which is rendered and\n // exits at the top level (src/index.ts).\n this.enforceMinVersion(response.headers.get('x-cli-min-version'));\n\n // Handle non-JSON responses (e.g. 500 Internal Server Error returns plain text)\n const contentType = response.headers.get('content-type') ?? '';\n let responseBody: Record<string, unknown>;\n if (contentType.includes('application/json')) {\n responseBody = await response.json() as Record<string, unknown>;\n } else {\n const text = await response.text();\n if (!response.ok) {\n const statusMsg = this.friendlyStatusMessage(response.status);\n return {\n success: false,\n errorCode: 0,\n errorMessage: statusMsg,\n statusCode: response.status,\n };\n }\n // Try parsing as JSON anyway (some servers don't set content-type)\n try {\n responseBody = JSON.parse(text) as Record<string, unknown>;\n } catch {\n return {\n success: false,\n errorCode: 0,\n errorMessage: `Unexpected response from server (${response.status})`,\n statusCode: response.status,\n };\n }\n }\n\n // Server uses unified format: { code: \"0000\", message: \"...\", data: {...} }\n const code = responseBody.code as string | undefined;\n const message = responseBody.message as string | undefined;\n const data = responseBody.data as Record<string, unknown> | undefined;\n\n // Success: HTTP 2xx AND code is \"0000\" (or no code field for raw responses)\n if (response.ok && (!code || code === '0000')) {\n // If server wraps data in a \"data\" field, unwrap it\n const payload = data ?? responseBody;\n return { success: true, data: payload as T, message };\n }\n\n // Error: either HTTP non-2xx or code !== \"0000\"\n const errorCode = code ? parseInt(code, 10) : 0;\n // Handle FastAPI 422 validation errors where detail is an array\n let errorMsg = message ?? response.statusText;\n if (!errorMsg || errorMsg === response.statusText) {\n const detail = responseBody.detail;\n if (Array.isArray(detail)) {\n errorMsg = detail.map((d: Record<string, unknown>) => {\n const loc = (d.loc as string[])?.slice(1).join('.') ?? '';\n return loc ? `${loc}: ${d.msg}` : String(d.msg);\n }).join('; ');\n } else if (typeof detail === 'string') {\n errorMsg = detail;\n }\n }\n return {\n success: false,\n errorCode: isNaN(errorCode) ? 0 : errorCode,\n errorMessage: errorMsg,\n statusCode: response.status,\n };\n } catch (error) {\n // UpgradeRequiredError is a CliError and must propagate untouched to the\n // top-level handler; don't rewrap it as a NetworkError.\n if (error instanceof UpgradeRequiredError) {\n throw error;\n }\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw new NetworkError(url, this.timeout);\n }\n throw new NetworkError(url, undefined, error instanceof Error ? error : undefined);\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Validate that the running CLI meets the server-advertised minimum.\n * Missing or empty header → skip (backward compat with servers that don't\n * advertise yet, and clients hitting legacy proxies).\n */\n private enforceMinVersion(headerValue: string | null): void {\n const minVersion = headerValue?.trim();\n if (!minVersion) return;\n const current = getCurrentVersion();\n if (isBelow(current, minVersion)) {\n throw new UpgradeRequiredError(current, minVersion, UPGRADE_COMMAND);\n }\n }\n\n private friendlyStatusMessage(status: number): string {\n const messages: Record<number, string> = {\n 400: 'Invalid request. Please check your input.',\n 401: 'Authentication failed. Please check your API key or login again.',\n 403: 'Access denied. You do not have permission for this operation.',\n 404: 'Resource not found. Please check the ID.',\n 409: 'Conflict. This resource may already exist.',\n 422: 'Invalid input. Please check the request parameters.',\n 429: 'Too many requests. Please wait and try again.',\n 500: 'Something went wrong on the server. Please try again later.',\n 502: 'Service is temporarily unavailable. Please try again in a moment.',\n 503: 'Service is temporarily unavailable. Please try again in a moment.',\n 504: 'The request took too long. Please try again.',\n };\n return messages[status] ?? `Something went wrong (${status}). Please try again later.`;\n }\n}\n","import { readFile, writeFile, mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { homedir } from 'node:os';\nimport { AppConfig } from '../types/config.js';\nimport { ConfigError } from '../utils/errors.js';\n\nconst DEFAULT_CONFIG: AppConfig = {\n active_org: null,\n active_developer_id: null,\n api_host: 'https://agent.everonet.com',\n api_path: '/api/v3/agent-pay',\n};\n\nexport class ConfigManager {\n private readonly basePath: string;\n private readonly configPath: string;\n\n constructor(basePath?: string) {\n this.basePath = basePath ?? join(homedir(), '.agenzo-admin-cli');\n this.configPath = join(this.basePath, 'config.json');\n }\n\n async ensureDirectories(): Promise<void> {\n await mkdir(this.basePath, { recursive: true });\n await mkdir(join(this.basePath, 'credentials'), { recursive: true });\n }\n\n async load(): Promise<AppConfig> {\n try {\n const content = await readFile(this.configPath, 'utf-8');\n try {\n const raw = JSON.parse(content) as Record<string, unknown>;\n // Migrate old api_base_url format\n if (raw.api_base_url && !raw.api_host) {\n const url = String(raw.api_base_url);\n const pathIndex = url.indexOf('/api/');\n raw.api_host = pathIndex > 0 ? url.slice(0, pathIndex) : url;\n raw.api_path = pathIndex > 0 ? url.slice(pathIndex) : DEFAULT_CONFIG.api_path;\n delete raw.api_base_url;\n }\n return {\n active_org: (raw.active_org as string) ?? null,\n active_developer_id: (raw.active_developer_id as string) ?? null,\n api_host: (raw.api_host as string) ?? DEFAULT_CONFIG.api_host,\n api_path: (raw.api_path as string) ?? DEFAULT_CONFIG.api_path,\n };\n } catch {\n throw new ConfigError(\n `Invalid config file: ${this.configPath}`,\n this.configPath,\n );\n }\n } catch (error) {\n if (error instanceof ConfigError) throw error;\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return { ...DEFAULT_CONFIG };\n }\n throw error;\n }\n }\n\n async save(config: AppConfig): Promise<void> {\n await this.ensureDirectories();\n await writeFile(this.configPath, JSON.stringify(config, null, 2), 'utf-8');\n }\n\n async getActiveOrg(): Promise<string | null> {\n const config = await this.load();\n return config.active_org;\n }\n\n async setActiveOrg(orgId: string): Promise<void> {\n const config = await this.load();\n config.active_org = orgId;\n await this.save(config);\n }\n\n async getApiBaseUrl(): Promise<string> {\n const config = await this.load();\n const host = config.api_host.replace(/\\/+$/, '');\n const path = config.api_path.startsWith('/') ? config.api_path : `/${config.api_path}`;\n return `${host}${path}`;\n }\n\n async setApiHost(host: string): Promise<void> {\n const config = await this.load();\n config.api_host = host;\n await this.save(config);\n }\n\n async getApiHost(): Promise<string> {\n const config = await this.load();\n return config.api_host;\n }\n}\n","import { readFile, writeFile, readdir, unlink, access, mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { homedir } from 'node:os';\nimport { OrgCredential } from '../types/config.js';\n\nexport class CredentialStore {\n private readonly basePath: string;\n\n constructor(basePath?: string) {\n this.basePath = basePath ?? join(homedir(), '.agenzo-admin-cli', 'credentials');\n }\n\n private filePath(orgId: string): string {\n return join(this.basePath, `${orgId}.json`);\n }\n\n private async ensureDir(): Promise<void> {\n await mkdir(this.basePath, { recursive: true });\n }\n\n async get(orgId: string): Promise<OrgCredential | null> {\n try {\n const content = await readFile(this.filePath(orgId), 'utf-8');\n return JSON.parse(content) as OrgCredential;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return null;\n }\n throw error;\n }\n }\n\n async save(credential: OrgCredential): Promise<void> {\n await this.ensureDir();\n await writeFile(\n this.filePath(credential.org_id),\n JSON.stringify(credential, null, 2),\n 'utf-8',\n );\n }\n\n async delete(orgId: string): Promise<void> {\n try {\n await unlink(this.filePath(orgId));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return;\n }\n throw error;\n }\n }\n\n async listAll(): Promise<OrgCredential[]> {\n try {\n const files = await readdir(this.basePath);\n const jsonFiles = files.filter((f) => f.endsWith('.json'));\n const credentials: OrgCredential[] = [];\n for (const file of jsonFiles) {\n try {\n const content = await readFile(join(this.basePath, file), 'utf-8');\n credentials.push(JSON.parse(content) as OrgCredential);\n } catch {\n // Skip corrupted files\n }\n }\n return credentials;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw error;\n }\n }\n\n async exists(orgId: string): Promise<boolean> {\n try {\n await access(this.filePath(orgId));\n return true;\n } catch {\n return false;\n }\n }\n}\n","import { readFile, writeFile, mkdir } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { homedir } from 'node:os';\nimport { StoredApiKey, KeyStoreData } from '../types/config.js';\n\nexport class KeyStore {\n private readonly filePath: string;\n\n constructor(filePath?: string) {\n this.filePath = filePath ?? join(homedir(), '.agenzo-admin-cli', 'keys.json');\n }\n\n private async loadData(): Promise<KeyStoreData> {\n try {\n const content = await readFile(this.filePath, 'utf-8');\n return JSON.parse(content) as KeyStoreData;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return {};\n }\n throw error;\n }\n }\n\n private async saveData(data: KeyStoreData): Promise<void> {\n await mkdir(dirname(this.filePath), { recursive: true });\n await writeFile(this.filePath, JSON.stringify(data, null, 2), 'utf-8');\n }\n\n async add(orgId: string, key: StoredApiKey): Promise<void> {\n const data = await this.loadData();\n if (!data[orgId]) {\n data[orgId] = [];\n }\n data[orgId].push(key);\n await this.saveData(data);\n }\n\n async update(orgId: string, keyId: string, newKeyValue: string): Promise<void> {\n const data = await this.loadData();\n const keys = data[orgId];\n if (!keys) return;\n const key = keys.find((k) => k.key_id === keyId);\n if (key) {\n key.key_value = newKeyValue;\n await this.saveData(data);\n }\n }\n\n async list(orgId: string): Promise<StoredApiKey[]> {\n const data = await this.loadData();\n return data[orgId] ?? [];\n }\n\n async get(orgId: string, keyId: string): Promise<StoredApiKey | null> {\n const data = await this.loadData();\n const keys = data[orgId];\n if (!keys) return null;\n return keys.find((k) => k.key_id === keyId) ?? null;\n }\n}\n","import { input, password, select } from '@inquirer/prompts';\n\ninterface PromptConfig {\n message: string;\n type?: 'input' | 'password' | 'select';\n choices?: { name: string; value: string }[];\n validate?: (input: string) => boolean | string;\n}\n\nexport class PromptEngine {\n /** Return flagValue directly if provided, otherwise prompt interactively */\n static async resolveInput(\n flagValue: string | undefined,\n config: PromptConfig,\n ): Promise<string> {\n if (flagValue !== undefined) {\n return flagValue;\n }\n\n if (config.type === 'password') {\n return password({ message: config.message, mask: '*' });\n }\n\n if (config.type === 'select' && config.choices) {\n return select({\n message: config.message,\n choices: config.choices,\n });\n }\n\n return input({\n message: config.message,\n validate: config.validate,\n });\n }\n\n /** Always collect CVV interactively with masked display */\n static async collectCvv(): Promise<string> {\n return password({\n message: 'CVV:',\n mask: '*',\n });\n }\n\n /** Collect payment method params based on type */\n static async collectPaymentMethodParams(\n type: string,\n flags: Record<string, string | undefined>,\n ): Promise<Record<string, string>> {\n const params: Record<string, string> = { type };\n\n const email = await PromptEngine.resolveInput(flags.cardEmail ?? flags.email, {\n message: 'Email (for 3DS verification):',\n });\n params.email = email;\n\n if (type === 'card') {\n params.card_number = await PromptEngine.resolveInput(flags.cardNumber, {\n message: 'Card number:',\n });\n params.expiry_date = await PromptEngine.resolveInput(flags.expiry, {\n message: 'Expiry (MMYY):',\n });\n // CVV: use flag if provided, otherwise collect interactively\n if (flags.cvv) {\n params.cvv = flags.cvv;\n } else {\n params.cvv = await PromptEngine.collectCvv();\n }\n }\n\n return params;\n }\n}\n","import { ApiClient, ApiResult, AuthMode } from '../api/client.js';\nimport { CredentialStore } from '../config/credential-store.js';\nimport { ConfigManager } from '../config/config-manager.js';\nimport { OrgCredential } from '../types/config.js';\nimport {\n MagicLinkStatusResponse,\n RefreshResponse,\n} from '../types/api.js';\nimport { AuthError } from '../utils/errors.js';\nimport { PromptEngine } from '../utils/prompt-engine.js';\nimport { createSpinner, Spinner } from '../utils/formatter.js';\n\nexport interface LoginResult {\n credential: OrgCredential;\n isNewRegistration: boolean;\n}\n\nexport interface LoginOptions {\n /**\n * Value supplied via `--idempotency-key`, forwarded verbatim as the\n * `Idempotency-Key` header on `POST /auth/login` (and `/auth/register` for\n * new registrations). Never auto-generated.\n */\n idempotencyKey?: string;\n /**\n * Suppress human-facing status lines (e.g. \"Magic link sent\") on stderr.\n * Set in `--format json` mode so agent consumers get clean output — only\n * interactive prompts (org name / invitation code) and errors remain.\n */\n quiet?: boolean;\n}\n\nconst POLL_INTERVAL_MS = 3000;\nconst POLL_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes\nconst TOKEN_REFRESH_THRESHOLD_S = 300; // 5 minutes\n\nexport class AuthService {\n constructor(\n private readonly apiClient: ApiClient,\n private readonly credentialStore: CredentialStore,\n private readonly configManager: ConfigManager,\n ) {}\n\n async login(email: string, options: LoginOptions = {}): Promise<LoginResult> {\n const { Formatter } = await import('../utils/formatter.js');\n let isNewRegistration = false;\n const noAuth: AuthMode = { type: 'none' };\n\n // Forward `--idempotency-key` verbatim as the Idempotency-Key header on the\n // server writes (login / register). Omitted entirely when not supplied —\n // never auto-generated (Requirement 4.3).\n const idempotencyHeaders = options.idempotencyKey\n ? { 'Idempotency-Key': options.idempotencyKey }\n : undefined;\n\n // Step 1: Probe whether this email is already registered.\n // No user-facing status here — we haven't sent anything yet, and we may\n // still need to collect organization / invitation details.\n const loginResult = await this.apiClient.post<{ magic_link_token: string }>(\n '/auth/login',\n noAuth,\n { email },\n idempotencyHeaders,\n );\n\n let magicLinkToken: string;\n\n if (!loginResult.success && loginResult.errorCode === 1007) {\n // Email not registered — collect org name (and optionally invitation code) and register\n isNewRegistration = true;\n const orgName = await PromptEngine.resolveInput(undefined, {\n message: 'Organization name:',\n });\n\n const registerBody: Record<string, string> = {\n email,\n organization_name: orgName,\n };\n\n // Attempt registration; if backend requires an invitation code (1103),\n // prompt for it and retry. Still silent — the email isn't sent until\n // we have all required fields.\n let registerResult = await this.apiClient.post<{ magic_link_token: string }>(\n '/auth/register',\n noAuth,\n registerBody,\n idempotencyHeaders,\n );\n\n if (!registerResult.success && registerResult.errorCode === 1103) {\n const invitationCode = await PromptEngine.resolveInput(undefined, {\n message: 'Invitation code:',\n });\n registerBody.invitation_code = invitationCode;\n registerResult = await this.apiClient.post<{ magic_link_token: string }>(\n '/auth/register',\n noAuth,\n registerBody,\n idempotencyHeaders,\n );\n }\n\n if (!registerResult.success) {\n throw new AuthError(\n `Registration failed: ${registerResult.errorMessage}`,\n 'Please check your input and try again',\n );\n }\n magicLinkToken = registerResult.data.magic_link_token;\n } else if (!loginResult.success) {\n throw new AuthError(\n `Login failed: ${loginResult.errorMessage}`,\n 'Please check your email and try again',\n );\n } else {\n magicLinkToken = loginResult.data.magic_link_token;\n }\n\n // Magic link token in hand means the backend has dispatched the email.\n // This is the only place the \"Sending magic link\" status is truthful.\n // Status/progress lines are logs — stderr only, and suppressed in quiet\n // (json) mode so agent consumers get clean output (Requirement 4.4).\n if (!options.quiet) {\n console.error(Formatter.status('success', 'Magic link sent. Please check your inbox.'));\n }\n\n // Step 2: Poll magic link status\n const credential = await this.pollMagicLinkStatus(\n magicLinkToken,\n email,\n options.quiet,\n );\n\n // Step 3: Save credential and update active org\n await this.credentialStore.save(credential);\n await this.configManager.setActiveOrg(credential.org_id);\n\n return { credential, isNewRegistration };\n }\n\n private async pollMagicLinkStatus(\n magicLinkToken: string,\n email: string,\n quiet = false,\n ): Promise<OrgCredential> {\n const startTime = Date.now();\n const noAuth: AuthMode = { type: 'none' };\n // The spinner draws to stdout; in quiet (json) mode skip it entirely so\n // the stdout payload stays clean for agent consumers.\n const spinner: Spinner | null = quiet\n ? null\n : createSpinner('Waiting for email verification');\n\n while (Date.now() - startTime < POLL_TIMEOUT_MS) {\n const result = await this.apiClient.get<MagicLinkStatusResponse>(\n '/auth/magic-links/status',\n noAuth,\n { token: magicLinkToken },\n );\n\n if (!result.success) {\n spinner?.stop();\n if (result.errorCode === 1101) {\n throw new AuthError('Magic link expired', 'Please run agenzo-admin-cli auth login again');\n }\n throw new AuthError(\n `Polling failed: [${result.errorCode}] ${result.errorMessage}`,\n 'Please run agenzo-admin-cli auth login again',\n );\n }\n\n const data = result.data;\n\n if (data.status === 'CONSUMED') {\n spinner?.stop();\n const raw = data as unknown as Record<string, unknown>;\n const org = raw.organization as Record<string, unknown> | undefined;\n\n const orgId = String(raw.organization_id ?? org?.id ?? '');\n const orgName = String(org?.name ?? '');\n\n // Handle expires_at: could be ISO string or unix timestamp\n let accessExpiresAt: number;\n const rawExpires = raw.expires_at ?? data.access_token_expires_at;\n if (typeof rawExpires === 'string') {\n accessExpiresAt = Math.floor(new Date(rawExpires).getTime() / 1000);\n } else {\n accessExpiresAt = (rawExpires as number) ?? 0;\n }\n\n const refreshExpiresAt = data.refresh_token_expires_at\n ?? accessExpiresAt + 30 * 24 * 60 * 60;\n\n return {\n org_id: orgId,\n org_name: orgName,\n email,\n access_token: data.access_token!,\n refresh_token: data.refresh_token!,\n access_token_expires_at: accessExpiresAt,\n refresh_token_expires_at: refreshExpiresAt,\n api_host: (await this.configManager.getApiHost()),\n };\n }\n\n if (data.status === 'EXPIRED') {\n spinner?.stop();\n throw new AuthError('Magic link expired', 'Please run agenzo-admin-cli auth login again');\n }\n\n await this.sleep(POLL_INTERVAL_MS);\n }\n\n spinner?.stop();\n throw new AuthError('Login timed out (10 minutes)', 'Please run agenzo-admin-cli auth login again');\n }\n\n async logout(): Promise<void> {\n const orgId = await this.configManager.getActiveOrg();\n if (!orgId) {\n throw new AuthError('Not signed in', 'Please run agenzo-admin-cli auth login first');\n }\n\n const credential = await this.credentialStore.get(orgId);\n if (credential) {\n // Best-effort server logout\n try {\n await this.apiClient.post(\n '/auth/logout',\n { type: 'bearer', token: credential.access_token },\n );\n } catch {\n // Ignore network errors during logout\n }\n }\n\n await this.credentialStore.delete(orgId);\n }\n\n async getValidAccessToken(): Promise<string> {\n const orgId = await this.configManager.getActiveOrg();\n if (!orgId) {\n throw new AuthError('Not signed in', 'Please run agenzo-admin-cli auth login first');\n }\n\n const credential = await this.credentialStore.get(orgId);\n if (!credential) {\n throw new AuthError('Not signed in', 'Please run agenzo-admin-cli auth login first');\n }\n\n const now = Math.floor(Date.now() / 1000);\n if (credential.access_token_expires_at - now < TOKEN_REFRESH_THRESHOLD_S) {\n try {\n await this.refreshToken(orgId);\n const refreshed = await this.credentialStore.get(orgId);\n return refreshed!.access_token;\n } catch {\n // Refresh failed (token expired, revoked, etc.) — auto re-login\n return this.autoReLogin(credential);\n }\n }\n\n return credential.access_token;\n }\n\n /**\n * Automatically re-login using the stored email.\n * Sends a magic link and polls until verified, then updates the\n * credential without changing the active org.\n */\n private async autoReLogin(credential: OrgCredential): Promise<string> {\n const { Formatter } = await import('../utils/formatter.js');\n const { resolveFormat } = await import('../utils/output.js');\n // Auto re-login is triggered from deep inside executeWithAuth and has no\n // direct format context, so read the resolved format from the environment\n // (index.ts mirrors the global --format into AGENZO_FORMAT after parsing).\n // Status lines must go to stderr (never stdout — that would corrupt the\n // JSON payload), and stay silent entirely in json mode for agent consumers.\n const quiet = resolveFormat(undefined) === 'json';\n if (!quiet) {\n console.error(Formatter.status('info', 'Session expired, re-authenticating'));\n console.error(Formatter.status('loading', 'Sending magic link'));\n }\n\n const noAuth: AuthMode = { type: 'none' };\n const loginResult = await this.apiClient.post<{ magic_link_token: string }>(\n '/auth/login',\n noAuth,\n { email: credential.email },\n );\n\n if (!loginResult.success) {\n throw new AuthError(\n `Auto re-login failed: ${loginResult.errorMessage}`,\n 'Please run agenzo-admin-cli auth login manually',\n );\n }\n\n const newCredential = await this.pollMagicLinkStatus(\n loginResult.data.magic_link_token,\n credential.email,\n quiet,\n );\n\n // Check if re-login returned a different org than expected\n const activeOrg = await this.configManager.getActiveOrg();\n if (activeOrg && newCredential.org_id !== activeOrg) {\n // Save the credential for the org we actually logged into\n await this.credentialStore.save(newCredential);\n // Switch active org to match\n await this.configManager.setActiveOrg(newCredential.org_id);\n if (!quiet) {\n console.error(Formatter.status('warning', `You were signed into a different organization: ${newCredential.org_name}. Your active organization has been updated.`));\n }\n throw new AuthError(\n 'Please run your command again.',\n 'The active organization was switched during re-authentication.',\n );\n }\n\n // Same org — update credential and continue\n await this.credentialStore.save(newCredential);\n if (!quiet) {\n console.error(Formatter.status('success', 'Re-authenticated successfully'));\n }\n\n return newCredential.access_token;\n }\n\n async refreshToken(orgId: string): Promise<void> {\n const credential = await this.credentialStore.get(orgId);\n if (!credential) {\n throw new AuthError('Not signed in', 'Please run agenzo-admin-cli auth login first');\n }\n\n const result = await this.apiClient.post<RefreshResponse>(\n '/auth/refresh',\n { type: 'bearer', token: credential.access_token },\n { refresh_token: credential.refresh_token },\n );\n\n if (!result.success) {\n if (result.errorCode === 1002) {\n throw new AuthError('Session expired', 'Please run agenzo-admin-cli auth login again');\n }\n throw new AuthError(\n `Token refresh failed: [${result.errorCode}] ${result.errorMessage}`,\n 'Please run agenzo-admin-cli auth login again',\n );\n }\n\n credential.access_token = result.data.access_token;\n credential.refresh_token = result.data.refresh_token;\n\n // Handle expires_at: backend returns ISO string, we need unix timestamp\n if (result.data.access_token_expires_at) {\n credential.access_token_expires_at = result.data.access_token_expires_at;\n } else if (result.data.expires_at) {\n credential.access_token_expires_at = Math.floor(new Date(result.data.expires_at).getTime() / 1000);\n }\n\n await this.credentialStore.save(credential);\n }\n\n /**\n * Execute an authenticated API call with automatic token recovery.\n * If the call returns 1002 (token invalid), attempts refresh → re-login → retry once.\n */\n async executeWithAuth<T>(\n apiFn: (token: string) => Promise<ApiResult<T>>,\n ): Promise<ApiResult<T>> {\n const token = await this.getValidAccessToken();\n const result = await apiFn(token);\n\n if (!result.success && result.errorCode === 1002) {\n // Token rejected server-side — attempt recovery\n const freshToken = await this.recoverToken();\n return apiFn(freshToken);\n }\n\n return result;\n }\n\n /**\n * Attempt token refresh; if that fails, fall back to auto re-login.\n */\n private async recoverToken(): Promise<string> {\n const orgId = await this.configManager.getActiveOrg();\n if (!orgId) {\n throw new AuthError('Not signed in', 'Please run agenzo-admin-cli auth login first');\n }\n\n const credential = await this.credentialStore.get(orgId);\n if (!credential) {\n throw new AuthError('Not signed in', 'Please run agenzo-admin-cli auth login first');\n }\n\n try {\n await this.refreshToken(orgId);\n const refreshed = await this.credentialStore.get(orgId);\n return refreshed!.access_token;\n } catch {\n return this.autoReLogin(credential);\n }\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n","/**\n * Exit-code mapper.\n *\n * Maps any thrown error reaching the top-level handler to one of the CLI's\n * non-zero exit codes (cli-standard §5.4). Normal completion implies `0` and\n * never consults this module.\n *\n * 1 — business / param (4xx): ApiBusinessError 4xx (except 401/403),\n * ValidationError, ConfigError, and unknown errors\n * 2 — upgrade required: UpgradeRequiredError\n * 3 — auth-fail / invalid-key / scope denied: AuthError, ApiBusinessError 401/403\n * 4 — network / 5xx: NetworkError, ApiBusinessError 5xx\n * 5 — user-cancel: UserCancelError / SIGINT\n *\n * Pure function, no I/O.\n */\nimport {\n ApiBusinessError,\n AuthError,\n ConfigError,\n IdempotencyKeyRequiredError,\n NetworkError,\n UpgradeRequiredError,\n ValidationError,\n} from './errors.js';\n\n/**\n * Detect a user-cancel error without a hard dependency on `UserCancelError`.\n * That subclass is introduced by task 5.3 and may not exist when this module\n * is compiled, so we match on the conventional `code` field / class name. Once\n * `UserCancelError` lands (with `code = 'USER_CANCEL_ERROR'`) this keeps working.\n */\nfunction isUserCancel(error: unknown): boolean {\n if (typeof error !== 'object' || error === null) {\n return false;\n }\n const code = (error as { code?: unknown }).code;\n const name = (error as { name?: unknown }).name;\n return code === 'USER_CANCEL_ERROR' || name === 'UserCancelError';\n}\n\n/** Map a thrown error to an exit code in the 1–5 range. */\nexport function exitCodeFor(error: unknown): 1 | 2 | 3 | 4 | 5 {\n // instanceof checks take priority over status-code subdivision.\n\n // 2 — CLI is below the server-advertised minimum version.\n if (error instanceof UpgradeRequiredError) {\n return 2;\n }\n\n // 3 — auth failure (not signed in, session expired, magic-link timeout).\n if (error instanceof AuthError) {\n return 3;\n }\n\n // 5 — user cancelled (Ctrl+C / `n` at a prompt). UserCancelError may not be\n // importable yet, so detect it structurally.\n if (isUserCancel(error)) {\n return 5;\n }\n\n // 4 — network timeout / connection failure.\n if (error instanceof NetworkError) {\n return 4;\n }\n\n // 1 — local input validation / config errors.\n if (error instanceof ValidationError) {\n return 1;\n }\n if (error instanceof IdempotencyKeyRequiredError) {\n return 1;\n }\n if (error instanceof ConfigError) {\n return 1;\n }\n\n // ApiBusinessError — subdivide by HTTP status.\n if (error instanceof ApiBusinessError) {\n const status = error.statusCode;\n // auth-fail / invalid-key / scope denied\n if (status === 401 || status === 403) {\n return 3;\n }\n // backend 5xx\n if (status >= 500) {\n return 4;\n }\n // 404 / 409 / 429 / other 4xx → business / param\n return 1;\n }\n\n // unknown / unexpected → business bucket\n return 1;\n}\n","import { Command } from 'commander';\nimport { AuthService } from './auth-service.js';\nimport { PromptEngine } from '../utils/prompt-engine.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { resolveFormat, render, notify } from '../utils/output.js';\nimport { IdempotencyKeyRequiredError } from '../utils/errors.js';\nimport type { CommandResult } from '../types/commands.js';\n\n/**\n * Machine payload for `auth login` (`--format json`).\n *\n * Tokens are deliberately excluded — Bearer `access_token` / `refresh_token`\n * never reach stdout in any format (Requirement 6.1).\n */\ninterface LoginData {\n org_id: string;\n org_name: string;\n email: string;\n is_new_registration: boolean;\n}\n\nexport function registerLoginCommand(\n program: Command,\n deps: { authService: AuthService },\n): void {\n program\n .command('login')\n .description('Sign in to Agent Payment API')\n .option('--email <email>', 'Email address')\n .option(\n '--idempotency-key <key>',\n 'Forwarded verbatim as the Idempotency-Key header on login/registration',\n )\n .action(async (options, command) => {\n // Global `--format` is added by the top-level wiring (task 7.1); until\n // then this falls back to AGENZO_FORMAT / the `table` default.\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const email = await PromptEngine.resolveInput(options.email, {\n message: 'Email:',\n });\n\n // --idempotency-key is mandatory on every server write; the CLI never\n // auto-generates it. When absent, prompt for it interactively. In\n // non-interactive mode (--yes) prompting would hang, so require the flag.\n let idempotencyKey = options.idempotencyKey as string | undefined;\n if (!idempotencyKey) {\n if (command.optsWithGlobals().yes) {\n throw new IdempotencyKeyRequiredError('auth login');\n }\n idempotencyKey = await PromptEngine.resolveInput(undefined, {\n message: 'Idempotency key (unique per write, for safe retry):',\n validate: (v) => v.trim().length > 0 || 'Idempotency key is required',\n });\n }\n\n // Forward `--idempotency-key` verbatim; never auto-generate (Requirement 4.3).\n // quiet in json mode so agent consumers get clean output.\n const result = await deps.authService.login(email, {\n idempotencyKey,\n quiet: format === 'json',\n });\n\n // Status/progress lines are logs, not payload — stderr only, and only in\n // table mode (json mode stays silent for agent consumers).\n const signedInMessage = result.isNewRegistration\n ? 'Registered and signed in'\n : 'Signed in successfully';\n notify(format, 'success', signedInMessage);\n\n const data: LoginData = {\n org_id: result.credential.org_id,\n org_name: result.credential.org_name,\n email: result.credential.email,\n is_new_registration: result.isNewRegistration,\n };\n\n const commandResult: CommandResult<LoginData> = {\n data,\n text: () =>\n Formatter.keyValue([\n ['Org ID', data.org_id],\n ['Org Name', data.org_name],\n ['Email', data.email],\n ]),\n note: signedInMessage,\n };\n\n render(commandResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { AuthService } from './auth-service.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { resolveFormat, render, notify } from '../utils/output.js';\nimport type { CommandResult } from '../types/commands.js';\n\n/** Machine payload for `auth logout` (`--format json`). Local-only operation. */\ninterface LogoutData {\n signed_out: true;\n}\n\nexport function registerLogoutCommand(\n program: Command,\n deps: { authService: AuthService },\n): void {\n program\n .command('logout')\n .description('Sign out of current organization')\n .action(async (_options, command) => {\n // Global `--format` is added by the top-level wiring (task 7.1); until\n // then this falls back to AGENZO_FORMAT / the `table` default.\n const format = resolveFormat(command.optsWithGlobals().format);\n\n // Throws AuthError when not signed in — the top-level handler owns the\n // exit code and error envelope (Requirement 5.3).\n await deps.authService.logout();\n\n // Status line is a log, not payload — stderr only, table mode only\n // (json mode stays silent for agent consumers).\n notify(format, 'success', 'Signed out');\n\n const data: LogoutData = { signed_out: true };\n const commandResult: CommandResult<LogoutData> = {\n data,\n text: () => Formatter.status('success', 'Signed out'),\n note: 'Signed out',\n };\n\n render(commandResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ConfigManager } from './config-manager.js';\nimport { CredentialStore } from './credential-store.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { CommandResult } from '../types/commands.js';\nimport { resolveFormat, render, notify, type OutputFormat } from '../utils/output.js';\n\nconst DEFAULT_HOST = 'https://agent.everonet.com';\n\n/** Payload for `config set-host` / `config reset-host` (client-constructed; no API call). */\ninterface HostResult {\n api_host: string;\n active_org: string | null;\n}\n\n/** Payload for `config show` (client-constructed local read; no API call). */\ninterface ShowResult {\n api_host: string;\n api_path: string;\n active_org: string | null;\n}\n\n/**\n * Apply a new API host locally and auto-switch the active org to a stored\n * credential that matches the host (clearing it when none match). All status\n * lines are logs and go to stderr; the returned `CommandResult` carries the\n * payload for the central renderer. Any corrupted/unwritable config surfaces\n * as a `ConfigError` thrown from `ConfigManager`, which the top-level handler\n * owns.\n */\nasync function applyHost(\n deps: { configManager: ConfigManager; credentialStore: CredentialStore },\n host: string,\n verb: 'set to' | 'reset to',\n format: OutputFormat,\n): Promise<CommandResult<HostResult>> {\n await deps.configManager.setApiHost(host);\n\n // Auto-switch active org to one matching the new host.\n const credentials = await deps.credentialStore.listAll();\n const match = credentials.find((c) => c.api_host === host);\n\n let activeOrg: string | null;\n if (match) {\n await deps.configManager.setActiveOrg(match.org_id);\n activeOrg = match.org_id;\n } else {\n // No matching org — clear active org to prevent cross-env pollution.\n const config = await deps.configManager.load();\n config.active_org = null;\n await deps.configManager.save(config);\n activeOrg = null;\n }\n\n // Status/info lines are logs — stderr, table mode only (json stays silent\n // so agent consumers get a clean stdout payload).\n notify(format, 'success', `API host ${verb}: ${host}`);\n notify(\n format,\n 'info',\n match\n ? `Switched to organization: ${match.org_name} (${match.org_id})`\n : 'No organization found for this host. Please run login.',\n );\n\n return {\n data: { api_host: host, active_org: activeOrg },\n // stdout payload projection (table mode). The ✓/ℹ status lines are emitted\n // by `notify` above (stderr) — do NOT repeat them here, or table mode would\n // print each line twice (once on stderr via notify, once on stdout via render).\n text: () =>\n Formatter.keyValue([\n ['API Host', host],\n ['Active Org', activeOrg ?? '(none)'],\n ]),\n };\n}\n\nexport function registerConfigCommand(\n program: Command,\n deps: { configManager: ConfigManager; credentialStore: CredentialStore },\n): void {\n const configCmd = program.command('config').description('Manage CLI configuration');\n\n configCmd\n .command('set-host <host>')\n .description('Set API host (e.g. https://agent.everonet.com)')\n .action(async (host: string, _options, command: Command) => {\n // Global `--format` is added by the top-level wiring (task 7.1); until\n // then this falls back to AGENZO_FORMAT / the `table` default.\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const result = await applyHost(deps, host, 'set to', format);\n render(result, { format });\n });\n\n configCmd\n .command('show')\n .description('Show current configuration')\n .action(async (_options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const config = await deps.configManager.load();\n const data: ShowResult = {\n api_host: config.api_host,\n api_path: config.api_path,\n active_org: config.active_org,\n };\n\n const commandResult: CommandResult<ShowResult> = {\n data,\n text: () =>\n Formatter.keyValue([\n ['API Host', data.api_host],\n ['API Path', data.api_path],\n ['Active Org', data.active_org ?? '(none)'],\n ]),\n };\n\n render(commandResult, { format });\n });\n\n configCmd\n .command('reset-host')\n .description('Reset API host to default (https://agent.everonet.com)')\n .action(async (_options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const result = await applyHost(deps, DEFAULT_HOST, 'reset to', format);\n render(result, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { Organization } from '../types/api.js';\nimport { CommandResult } from '../types/commands.js';\nimport { resolveFormat, render } from '../utils/output.js';\nimport { ApiBusinessError } from '../utils/errors.js';\n\nexport function registerMeCommand(\n parent: Command,\n deps: { apiClient: ApiClient; authService: AuthService },\n): void {\n parent\n .command('get')\n .description('View current organization')\n .action(async (_options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.get<Organization>(\n '/organizations/me',\n { type: 'bearer', token },\n ),\n );\n\n if (!result.success) {\n // Throw so the top-level handler owns the error envelope + exit code.\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n const org = result.data;\n const commandResult: CommandResult<Organization> = {\n data: org,\n text: () =>\n Formatter.keyValue([\n ['Org ID', org.id],\n ['Name', org.name],\n ['Email', org.email],\n ['Status', org.status],\n ['Created', Formatter.formatTime(org.created_at)],\n ['Updated', Formatter.formatTime(org.updated_at)],\n ]),\n };\n\n render(commandResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { CredentialStore } from '../config/credential-store.js';\nimport { ConfigManager } from '../config/config-manager.js';\nimport { PromptEngine } from '../utils/prompt-engine.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { Organization } from '../types/api.js';\nimport { CommandResult } from '../types/commands.js';\nimport { resolveFormat, render, notify } from '../utils/output.js';\nimport { ApiBusinessError, IdempotencyKeyRequiredError } from '../utils/errors.js';\n\nexport function registerUpdateCommand(\n parent: Command,\n deps: {\n apiClient: ApiClient;\n authService: AuthService;\n credentialStore: CredentialStore;\n configManager: ConfigManager;\n },\n): void {\n parent\n .command('update')\n .description('Update current organization')\n .option('--name <name>', 'New organization name')\n .option('--email <email>', 'New email')\n .option('--idempotency-key <key>', 'Idempotency key forwarded as the Idempotency-Key header')\n .action(async (options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const body: Record<string, unknown> = {};\n if (options.name) body.name = options.name;\n if (options.email) body.email = options.email;\n\n // --idempotency-key is mandatory on every server write; the CLI never\n // auto-generates it. When absent, prompt for it interactively. In\n // non-interactive mode (--yes) prompting would hang, so require the flag.\n let idempotencyKey = options.idempotencyKey as string | undefined;\n if (!idempotencyKey) {\n if (command.optsWithGlobals().yes) {\n throw new IdempotencyKeyRequiredError('orgs update');\n }\n idempotencyKey = await PromptEngine.resolveInput(undefined, {\n message: 'Idempotency key (unique per write, for safe retry):',\n validate: (v) => v.trim().length > 0 || 'Idempotency key is required',\n });\n }\n const extraHeaders: Record<string, string> = {\n 'Idempotency-Key': String(idempotencyKey),\n };\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.post<Organization & {\n magic_link_token?: string;\n expires_at?: string;\n }>(\n '/organizations/me/update',\n { type: 'bearer', token },\n body,\n extraHeaders,\n ),\n );\n\n if (!result.success) {\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n const data = result.data;\n\n // Email change does NOT update the org inline — the backend returns a\n // magic-link verification payload ({ magic_link_token, expires_at })\n // instead of the Organization. Detect that shape and render it as a\n // pending-verification result rather than an Organization (which would\n // show every field as `undefined`).\n if (data.magic_link_token) {\n notify(\n format,\n 'info',\n 'Verification email sent to the new address. The email changes once verified.',\n );\n const verifyResult: CommandResult<{\n magic_link_token: string;\n expires_at?: string;\n }> = {\n data: {\n magic_link_token: data.magic_link_token,\n expires_at: data.expires_at,\n },\n text: () =>\n Formatter.keyValue([\n ['Status', 'PENDING_EMAIL_VERIFICATION'],\n ['Magic Link Token', data.magic_link_token ?? ''],\n ['Expires At', Formatter.formatTime(data.expires_at)],\n ]),\n };\n render(verifyResult, { format });\n return;\n }\n\n const org = data;\n\n // Sync local credential cache with updated org info.\n const activeOrg = await deps.configManager.getActiveOrg();\n if (activeOrg) {\n const cred = await deps.credentialStore.get(activeOrg);\n if (cred && options.name) {\n cred.org_name = org.name;\n await deps.credentialStore.save(cred);\n }\n }\n\n // Status / hint lines are logs — stderr, and only in table mode\n // (json mode stays silent for agent consumers).\n notify(format, 'success', 'Organization updated');\n\n const commandResult: CommandResult<Organization> = {\n data: org,\n text: () =>\n Formatter.keyValue([\n ['Org ID', org.id],\n ['Name', org.name],\n ['Email', org.email],\n ['Status', org.status],\n ]),\n };\n\n render(commandResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { CredentialStore } from '../config/credential-store.js';\nimport { ConfigManager } from '../config/config-manager.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { CommandResult } from '../types/commands.js';\nimport { resolveFormat, render } from '../utils/output.js';\n\ninterface OrgListItem {\n org_id: string;\n org_name: string;\n email: string;\n active: boolean;\n}\n\nexport function registerListCommand(\n parent: Command,\n deps: { credentialStore: CredentialStore; configManager: ConfigManager },\n): void {\n parent\n .command('list')\n .description('List all signed-in organizations')\n .action(async (_options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const credentials = await deps.credentialStore.listAll();\n const activeOrg = await deps.configManager.getActiveOrg();\n const currentHost = await deps.configManager.getApiHost();\n\n // Only show orgs that belong to the current api_host.\n const data: OrgListItem[] = credentials\n .filter((cred) => cred.api_host === currentHost)\n .map((cred) => ({\n org_id: cred.org_id,\n org_name: cred.org_name,\n email: cred.email,\n active: cred.org_id === activeOrg,\n }));\n\n const commandResult: CommandResult<OrgListItem[]> = {\n data,\n text: () => {\n if (data.length === 0) {\n return Formatter.status('info', 'No signed-in organizations');\n }\n const headers = ['', 'Org ID', 'Org Name', 'Email'];\n const rows = data.map((item) => [\n item.active ? '*' : '',\n item.org_id,\n item.org_name,\n item.email,\n ]);\n return Formatter.table(headers, rows);\n },\n };\n\n render(commandResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { CredentialStore } from '../config/credential-store.js';\nimport { ConfigManager } from '../config/config-manager.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { CommandResult } from '../types/commands.js';\nimport { resolveFormat, render, notify } from '../utils/output.js';\nimport { AuthError, ValidationError } from '../utils/errors.js';\n\ninterface SwitchResult {\n active_org: string;\n}\n\nexport function registerSwitchCommand(\n parent: Command,\n deps: { credentialStore: CredentialStore; configManager: ConfigManager },\n): void {\n parent\n .command('switch <org_id>')\n .description('Switch active organization')\n .action(async (orgId: string, _options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const credential = await deps.credentialStore.get(orgId);\n if (!credential) {\n throw new AuthError(\n `Organization ${orgId} not signed in locally`,\n 'Please run agenzo-admin-cli auth login to sign in to this organization',\n );\n }\n\n // Cross-environment guard: never switch to a credential from another host.\n const currentHost = await deps.configManager.getApiHost();\n if (credential.api_host && credential.api_host !== currentHost) {\n throw new ValidationError(\n `Organization ${orgId} belongs to a different environment (${credential.api_host})`,\n );\n }\n\n await deps.configManager.setActiveOrg(orgId);\n\n // Status line is a log — stderr, table mode only (json stays silent).\n notify(format, 'success', `Switched to organization ${orgId}`);\n\n const commandResult: CommandResult<SwitchResult> = {\n data: { active_org: orgId },\n text: () => Formatter.status('success', `Switched to organization ${orgId}`),\n };\n\n render(commandResult, { format });\n });\n}\n","import { ValidationError } from '../utils/errors.js';\n\n/**\n * Developer billing modes (cli-design §4.2.2). Decides the funds-settlement\n * path when calling merchant fulfillment:\n * - pay_per_call → charge per transaction via payment-cli\n * - monthly_settlement → deduct from a pre-funded settlement account\n */\nexport const VALID_BILLING_MODES = ['pay_per_call', 'monthly_settlement'] as const;\nexport type BillingMode = (typeof VALID_BILLING_MODES)[number];\n\n/** Default when --billing-mode is not supplied. */\nexport const DEFAULT_BILLING_MODE: BillingMode = 'pay_per_call';\n\nfunction isBillingMode(value: string): value is BillingMode {\n return (VALID_BILLING_MODES as readonly string[]).includes(value);\n}\n\n/**\n * Validate a `--billing-mode` flag value. Throws `ValidationError` on an\n * unknown value so the top-level handler maps it to PARAM_INVALID / exit 1.\n * Absent flag falls back to the default.\n */\nexport function resolveBillingMode(flag: string | undefined): BillingMode {\n if (flag === undefined) {\n return DEFAULT_BILLING_MODE;\n }\n const normalized = flag.trim().toLowerCase();\n if (!isBillingMode(normalized)) {\n throw new ValidationError(\n `Invalid --billing-mode: ${flag}. Allowed: ${VALID_BILLING_MODES.join(', ')}.`,\n );\n }\n return normalized;\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { PromptEngine } from '../utils/prompt-engine.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { render, resolveFormat, notify } from '../utils/output.js';\nimport { ApiBusinessError, IdempotencyKeyRequiredError } from '../utils/errors.js';\nimport { CommandResult } from '../types/commands.js';\nimport { Developer } from '../types/api.js';\nimport { resolveBillingMode } from './billing-mode.js';\n\nexport function registerCreateCommand(\n parent: Command,\n deps: { apiClient: ApiClient; authService: AuthService },\n): void {\n parent\n .command('create')\n .description('Create a developer')\n .option('--developer-name <name>', 'Developer name')\n .option('--developer-email <email>', 'Developer email')\n .option(\n '--billing-mode <mode>',\n 'Billing mode: pay_per_call | monthly_settlement (default: pay_per_call)',\n )\n .option('--idempotency-key <key>', 'Idempotency key forwarded as the Idempotency-Key header')\n .action(async (options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const name = await PromptEngine.resolveInput(options.developerName, {\n message: 'Developer name:',\n });\n const email = await PromptEngine.resolveInput(options.developerEmail, {\n message: 'Developer email:',\n });\n\n // Validate --billing-mode locally (defaults to pay_per_call). An invalid\n // value throws ValidationError -> PARAM_INVALID / exit 1.\n const billingMode = resolveBillingMode(options.billingMode);\n\n // --idempotency-key is mandatory on every server write; the CLI never\n // auto-generates it. When absent, prompt for it interactively. In\n // non-interactive mode (--yes) prompting would hang, so require the flag.\n let idempotencyKey = options.idempotencyKey as string | undefined;\n if (!idempotencyKey) {\n if (command.optsWithGlobals().yes) {\n throw new IdempotencyKeyRequiredError('developers create');\n }\n idempotencyKey = await PromptEngine.resolveInput(undefined, {\n message: 'Idempotency key (unique per write, for safe retry):',\n validate: (v) => v.trim().length > 0 || 'Idempotency key is required',\n });\n }\n const extraHeaders: Record<string, string> = {\n 'Idempotency-Key': String(idempotencyKey),\n };\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.post<Developer>(\n '/developers/create',\n { type: 'bearer', token },\n { name, email, billing_mode: billingMode },\n extraHeaders,\n ),\n );\n\n if (!result.success) {\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n const dev = result.data;\n // Preserve the original handler's defensive `id ?? developer_id` read,\n // type-safely (the backend has historically returned either field).\n const idDisplay = String(\n dev.id ?? (dev as { developer_id?: string }).developer_id ?? '-',\n );\n const commandResult: CommandResult<Developer> = {\n data: dev,\n note: 'Developer created',\n text: () =>\n Formatter.keyValue([\n ['ID', idDisplay],\n ['Org ID', String(dev.organization_id ?? '-')],\n ['Name', String(dev.name ?? '-')],\n ['Email', String(dev.email ?? '-')],\n ['Status', String(dev.status ?? '-')],\n ['Billing Mode', String(dev.billing_mode ?? '-')],\n ]),\n };\n\n // Status / progress lines belong on stderr (table mode only); stdout\n // carries only the payload.\n if (commandResult.note) {\n notify(format, 'success', commandResult.note);\n }\n render(commandResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { render, resolveFormat } from '../utils/output.js';\nimport { ApiBusinessError } from '../utils/errors.js';\nimport { CommandResult } from '../types/commands.js';\nimport { Developer } from '../types/api.js';\n\nexport function registerListCommand(\n parent: Command,\n deps: { apiClient: ApiClient; authService: AuthService },\n): void {\n parent\n .command('list')\n .description('List all developers')\n .action(async (_options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.get<Developer[]>(\n '/developers',\n { type: 'bearer', token },\n ),\n );\n\n if (!result.success) {\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n const developers = result.data;\n const commandResult: CommandResult<Developer[]> = {\n data: developers,\n text: () => {\n if (developers.length === 0) {\n return Formatter.status('info', 'No developers found');\n }\n const headers = ['ID', 'Name', 'Email', 'Status'];\n const rows = developers.map((d) => [d.id, d.name, d.email, d.status]);\n return Formatter.table(headers, rows);\n },\n };\n\n render(commandResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { render, resolveFormat } from '../utils/output.js';\nimport { ApiBusinessError } from '../utils/errors.js';\nimport { CommandResult } from '../types/commands.js';\nimport { Developer } from '../types/api.js';\n\nexport function registerGetCommand(\n parent: Command,\n deps: { apiClient: ApiClient; authService: AuthService },\n): void {\n parent\n .command('get <developer_id>')\n .description('View developer details')\n .action(async (developerId: string, _options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.get<Developer>(\n `/developers/${developerId}`,\n { type: 'bearer', token },\n ),\n );\n\n if (!result.success) {\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n const dev = result.data;\n const commandResult: CommandResult<Developer> = {\n data: dev,\n text: () =>\n Formatter.keyValue([\n ['ID', dev.id],\n ['Name', dev.name],\n ['Email', dev.email],\n ['Status', dev.status],\n ['Billing Mode', dev.billing_mode ?? '-'],\n ['Created', Formatter.formatTime(dev.created_at)],\n ['Updated', Formatter.formatTime(dev.updated_at)],\n ]),\n };\n\n render(commandResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { PromptEngine } from '../utils/prompt-engine.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { render, resolveFormat, notify } from '../utils/output.js';\nimport { ApiBusinessError, IdempotencyKeyRequiredError } from '../utils/errors.js';\nimport { CommandResult } from '../types/commands.js';\nimport { Developer } from '../types/api.js';\n\nexport function registerUpdateCommand(\n parent: Command,\n deps: { apiClient: ApiClient; authService: AuthService },\n): void {\n parent\n .command('update <developer_id>')\n .description('Update developer info')\n .option('--name <name>', 'New name')\n .option('--email <email>', 'New email')\n .option('--idempotency-key <key>', 'Idempotency key forwarded as the Idempotency-Key header')\n .action(async (developerId: string, options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const body: Record<string, unknown> = {};\n if (options.name) body.name = options.name;\n if (options.email) body.email = options.email;\n\n // --idempotency-key is mandatory on every server write; the CLI never\n // auto-generates it. When absent, prompt for it interactively. In\n // non-interactive mode (--yes) prompting would hang, so require the flag.\n let idempotencyKey = options.idempotencyKey as string | undefined;\n if (!idempotencyKey) {\n if (command.optsWithGlobals().yes) {\n throw new IdempotencyKeyRequiredError('developers update');\n }\n idempotencyKey = await PromptEngine.resolveInput(undefined, {\n message: 'Idempotency key (unique per write, for safe retry):',\n validate: (v) => v.trim().length > 0 || 'Idempotency key is required',\n });\n }\n const extraHeaders: Record<string, string> = {\n 'Idempotency-Key': String(idempotencyKey),\n };\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.post<Developer>(\n `/developers/${developerId}/update`,\n { type: 'bearer', token },\n body,\n extraHeaders,\n ),\n );\n\n if (!result.success) {\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n const dev = result.data;\n const commandResult: CommandResult<Developer> = {\n data: dev,\n note: 'Developer updated',\n text: () =>\n Formatter.keyValue([\n ['ID', dev.id],\n ['Name', dev.name],\n ['Email', dev.email],\n ['Status', dev.status],\n ]),\n };\n\n // Status / progress lines belong on stderr (table mode only); stdout\n // carries only the payload.\n if (commandResult.note) {\n notify(format, 'success', commandResult.note);\n }\n render(commandResult, { format });\n });\n}\n","import { checkbox } from '@inquirer/prompts';\nimport { ValidationError } from '../utils/errors.js';\n\n/**\n * The CLI scopes an API Key may be granted. A scope controls which runtime\n * CLI(s) the key can call (cli-design §2.4.14):\n * - token → agenzo-token-cli (payment-methods / payment-tokens)\n * - merchant → agenzo-merchant-cli (ride / services / ...)\n * - payment → agenzo-payment-cli (charges / refunds / ...)\n */\nexport const VALID_SCOPES = ['token', 'merchant', 'payment'] as const;\nexport type Scope = (typeof VALID_SCOPES)[number];\n\n/** Default when neither --scope nor an interactive selection narrows it: all three. */\nexport const DEFAULT_SCOPES: Scope[] = ['token', 'merchant', 'payment'];\n\nfunction isScope(value: string): value is Scope {\n return (VALID_SCOPES as readonly string[]).includes(value);\n}\n\n/**\n * Parse a comma-separated `--scope` value into a validated, de-duplicated,\n * canonically-ordered list. Throws `ValidationError` on any unknown token so\n * the top-level handler maps it to PARAM_INVALID / exit 1.\n */\nexport function parseScopeFlag(raw: string): Scope[] {\n const parts = raw\n .split(',')\n .map((s) => s.trim().toLowerCase())\n .filter((s) => s.length > 0);\n\n if (parts.length === 0) {\n throw new ValidationError(\n `Invalid --scope: empty. Expected a comma-separated subset of ${VALID_SCOPES.join(', ')}.`,\n );\n }\n\n const invalid = parts.filter((p) => !isScope(p));\n if (invalid.length > 0) {\n throw new ValidationError(\n `Invalid --scope value(s): ${invalid.join(', ')}. Allowed: ${VALID_SCOPES.join(', ')}.`,\n );\n }\n\n // De-duplicate while preserving the canonical token/merchant/payment order.\n return DEFAULT_SCOPES.filter((s) => parts.includes(s));\n}\n\n/**\n * Resolve the scope list for `keys create`.\n *\n * Precedence:\n * 1. `--scope` flag (validated via {@link parseScopeFlag}).\n * 2. `--yes` (non-interactive): default to all three scopes.\n * 3. Interactive multi-select (defaults all checked); empty selection falls\n * back to all three.\n */\nexport async function resolveScopes(\n flag: string | undefined,\n nonInteractive: boolean,\n): Promise<Scope[]> {\n if (flag !== undefined) {\n return parseScopeFlag(flag);\n }\n\n if (nonInteractive) {\n return DEFAULT_SCOPES;\n }\n\n const selected = await checkbox<Scope>({\n message: 'Select scopes (which CLIs this key may call):',\n choices: DEFAULT_SCOPES.map((s) => ({ name: s, value: s, checked: true })),\n });\n\n return selected.length > 0 ? selected : DEFAULT_SCOPES;\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { KeyStore } from '../config/key-store.js';\nimport { ConfigManager } from '../config/config-manager.js';\nimport { PromptEngine } from '../utils/prompt-engine.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { render, resolveFormat, notify } from '../utils/output.js';\nimport { ApiBusinessError, IdempotencyKeyRequiredError } from '../utils/errors.js';\nimport { ApiKey } from '../types/api.js';\nimport type { CommandResult } from '../types/commands.js';\nimport { resolveScopes } from './scope.js';\n\nexport function registerCreateCommand(\n parent: Command,\n deps: {\n apiClient: ApiClient;\n authService: AuthService;\n keyStore: KeyStore;\n configManager: ConfigManager;\n },\n): void {\n const cmd = parent\n .command('create')\n .description('Create an API Key')\n .option('--developer-id <developer_id>', 'Developer ID (e.g. dev_01KPX...)')\n .option('--key-name <key_name>', 'Key name (e.g. Production Key)')\n .option(\n '--scope <scope>',\n 'Comma-separated CLI scopes: token,merchant,payment (default: all three)',\n )\n .option(\n '--idempotency-key <key>',\n 'Idempotency key forwarded verbatim as the Idempotency-Key header',\n );\n\n cmd.action(async () => {\n const opts = cmd.optsWithGlobals();\n const format = resolveFormat(opts.format as string | undefined);\n\n const developerId = await PromptEngine.resolveInput(opts.developerId, {\n message: 'Developer ID (e.g. dev_01KPX...):',\n });\n const name = await PromptEngine.resolveInput(opts.keyName, {\n message: 'Key name (e.g. Production Key):',\n });\n\n // Resolve scopes: --scope flag (validated) > --yes default-all > interactive\n // multi-select. Sent to the backend as a `scope` array (cli-design §2.4.14).\n const scope = await resolveScopes(\n opts.scope as string | undefined,\n Boolean(opts.yes),\n );\n\n // --idempotency-key is mandatory on every server write; the CLI never\n // auto-generates it. When absent, prompt for it interactively. In\n // non-interactive mode (--yes) prompting would hang, so require the flag.\n let idempotencyKey = opts.idempotencyKey as string | undefined;\n if (!idempotencyKey) {\n if (opts.yes) {\n throw new IdempotencyKeyRequiredError('keys create');\n }\n idempotencyKey = await PromptEngine.resolveInput(undefined, {\n message: 'Idempotency key (unique per write, for safe retry):',\n validate: (v) => v.trim().length > 0 || 'Idempotency key is required',\n });\n }\n const extraHeaders: Record<string, string> = {\n 'Idempotency-Key': idempotencyKey,\n };\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.post<ApiKey>(\n '/keys/create',\n { type: 'bearer', token },\n { developer_id: developerId, name, scope },\n extraHeaders,\n ),\n );\n\n if (!result.success) {\n // Throw so the top-level handler owns the error envelope + exit code.\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n const key = result.data;\n // The backend now persists and echoes `scope`. Keep this fallback as a\n // defensive no-op for older servers / edge responses that omit it, so the\n // payload/table always show the granted scope.\n if (!key.scope || key.scope.length === 0) {\n key.scope = scope;\n }\n\n // Persist the full plaintext key (written only on create/rotate).\n const orgId = await deps.configManager.getActiveOrg();\n if (orgId && key.api_key) {\n await deps.keyStore.add(orgId, {\n key_id: key.id,\n developer_id: key.developer_id,\n name: key.name,\n key_value: key.api_key,\n created_at: key.created_at,\n });\n }\n\n // Status + one-time-secret warning are logs → stderr (never stdout), and\n // only in table mode. In json mode everything here is silent: the key is\n // already part of the stdout payload, so agent consumers get it cleanly.\n notify(format, 'success', 'API Key created');\n if (format === 'table') {\n console.error(Formatter.status('warning', `API Key: ${key.api_key}`));\n console.error(\n Formatter.status('warning', 'Save it now — this key is shown only once'),\n );\n }\n\n const cmdResult: CommandResult<ApiKey> = {\n data: key,\n text: () =>\n Formatter.keyValue([\n ['Name', key.name],\n ['Scope', (key.scope ?? []).join(', ')],\n ['Status', key.status],\n ]),\n };\n render(cmdResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { PromptEngine } from '../utils/prompt-engine.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { render, resolveFormat } from '../utils/output.js';\nimport { ApiBusinessError } from '../utils/errors.js';\nimport { ApiKey } from '../types/api.js';\nimport type { CommandResult } from '../types/commands.js';\n\n/** Strip the one-time plaintext key so read commands never expose a secret. */\nfunction toMetadata(key: ApiKey): ApiKey {\n const { api_key: _api_key, ...metadata } = key;\n return metadata;\n}\n\nexport function registerListCommand(\n parent: Command,\n deps: { apiClient: ApiClient; authService: AuthService },\n): void {\n const cmd = parent\n .command('list')\n .description('List API Keys')\n .option('--developer-id <developer_id>', 'Developer ID (e.g. dev_01KPX...)');\n\n cmd.action(async () => {\n const opts = cmd.optsWithGlobals();\n const format = resolveFormat(opts.format as string | undefined);\n\n const developerId = await PromptEngine.resolveInput(opts.developerId, {\n message: 'Developer ID (e.g. dev_01KPX...):',\n });\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.get<ApiKey[]>(\n '/keys',\n { type: 'bearer', token },\n { developer_id: developerId },\n ),\n );\n\n if (!result.success) {\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n // Metadata only — never expose the plaintext key on a read command.\n const keys = result.data.map(toMetadata);\n\n const cmdResult: CommandResult<ApiKey[]> = {\n data: keys,\n text: () => {\n if (keys.length === 0) {\n return Formatter.status('info', 'No API Keys found');\n }\n const headers = ['ID', 'Developer', 'Name', 'Scope', 'Status', 'Last Used'];\n const rows = keys.map((k) => [\n k.id,\n k.developer_id,\n k.name,\n (k.scope ?? []).join(','),\n k.status,\n k.last_used_at ? Formatter.formatTime(k.last_used_at) : 'Never',\n ]);\n return Formatter.table(headers, rows);\n },\n };\n render(cmdResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { render, resolveFormat } from '../utils/output.js';\nimport { ApiBusinessError } from '../utils/errors.js';\nimport { ApiKey } from '../types/api.js';\nimport type { CommandResult } from '../types/commands.js';\n\n/** Strip the one-time plaintext key so read commands never expose a secret. */\nfunction toMetadata(key: ApiKey): ApiKey {\n const { api_key: _api_key, ...metadata } = key;\n return metadata;\n}\n\nexport function registerGetCommand(\n parent: Command,\n deps: { apiClient: ApiClient; authService: AuthService },\n): void {\n const cmd = parent.command('get <key_id>').description('View API Key details');\n\n cmd.action(async (keyId: string) => {\n const opts = cmd.optsWithGlobals();\n const format = resolveFormat(opts.format as string | undefined);\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.get<ApiKey>(\n `/keys/${keyId}`,\n { type: 'bearer', token },\n ),\n );\n\n if (!result.success) {\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n // Metadata only — never expose the plaintext key on a read command.\n const k = toMetadata(result.data);\n\n const cmdResult: CommandResult<ApiKey> = {\n data: k,\n text: () =>\n Formatter.keyValue([\n ['Key ID', k.id],\n ['Developer ID', k.developer_id],\n ['Name', k.name],\n ['Scope', (k.scope ?? []).join(', ')],\n ['Status', k.status],\n ['Last Used', k.last_used_at ? Formatter.formatTime(k.last_used_at) : 'Never'],\n ['Created', Formatter.formatTime(k.created_at)],\n ]),\n };\n render(cmdResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { KeyStore } from '../config/key-store.js';\nimport { ConfigManager } from '../config/config-manager.js';\nimport { PromptEngine } from '../utils/prompt-engine.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { render, resolveFormat, notify } from '../utils/output.js';\nimport { ApiBusinessError, IdempotencyKeyRequiredError } from '../utils/errors.js';\nimport { ApiKey } from '../types/api.js';\nimport type { CommandResult } from '../types/commands.js';\n\nexport function registerRotateCommand(\n parent: Command,\n deps: {\n apiClient: ApiClient;\n authService: AuthService;\n keyStore: KeyStore;\n configManager: ConfigManager;\n },\n): void {\n const cmd = parent\n .command('rotate <key_id>')\n .description('Rotate API Key')\n .option(\n '--idempotency-key <key>',\n 'Idempotency key forwarded verbatim as the Idempotency-Key header',\n );\n\n cmd.action(async (keyId: string) => {\n const opts = cmd.optsWithGlobals();\n const format = resolveFormat(opts.format as string | undefined);\n\n // --idempotency-key is mandatory on every server write; the CLI never\n // auto-generates it. When absent, prompt for it interactively. In\n // non-interactive mode (--yes) prompting would hang, so require the flag.\n let idempotencyKey = opts.idempotencyKey as string | undefined;\n if (!idempotencyKey) {\n if (opts.yes) {\n throw new IdempotencyKeyRequiredError('keys rotate');\n }\n idempotencyKey = await PromptEngine.resolveInput(undefined, {\n message: 'Idempotency key (unique per write, for safe retry):',\n validate: (v) => v.trim().length > 0 || 'Idempotency key is required',\n });\n }\n const extraHeaders: Record<string, string> = {\n 'Idempotency-Key': idempotencyKey,\n };\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.post<ApiKey>(\n `/keys/${keyId}/rotate`,\n { type: 'bearer', token },\n undefined,\n extraHeaders,\n ),\n );\n\n if (!result.success) {\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n const key = result.data;\n\n // Update the stored plaintext key (written only on create/rotate).\n const orgId = await deps.configManager.getActiveOrg();\n if (orgId && key.api_key) {\n await deps.keyStore.update(orgId, keyId, key.api_key);\n }\n\n // Status + one-time-secret warning are logs → stderr (never stdout), and\n // only in table mode. In json mode everything here is silent: the new key\n // is already part of the stdout payload for agent consumers.\n notify(format, 'success', 'API Key rotated');\n if (format === 'table') {\n console.error(Formatter.status('warning', `New API Key: ${key.api_key}`));\n console.error(\n Formatter.status('warning', 'Save it now — this key is shown only once'),\n );\n }\n\n const cmdResult: CommandResult<ApiKey> = {\n data: key,\n text: () =>\n Formatter.keyValue([\n ['Key ID', key.id],\n ['Name', key.name],\n ['Scope', (key.scope ?? []).join(', ')],\n ['Status', key.status],\n ]),\n };\n render(cmdResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { PromptEngine } from '../utils/prompt-engine.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { render, resolveFormat, notify } from '../utils/output.js';\nimport { ApiBusinessError, IdempotencyKeyRequiredError } from '../utils/errors.js';\nimport { DisableResult } from '../types/api.js';\nimport type { CommandResult } from '../types/commands.js';\n\nexport function registerDisableCommand(\n parent: Command,\n deps: { apiClient: ApiClient; authService: AuthService },\n): void {\n const cmd = parent\n .command('disable <key_id>')\n .description('Disable API Key')\n .option(\n '--idempotency-key <key>',\n 'Idempotency key forwarded verbatim as the Idempotency-Key header',\n );\n\n cmd.action(async (keyId: string) => {\n const opts = cmd.optsWithGlobals();\n const format = resolveFormat(opts.format as string | undefined);\n\n // --idempotency-key is mandatory on every server write; the CLI never\n // auto-generates it. When absent, prompt for it interactively. In\n // non-interactive mode (--yes) prompting would hang, so require the flag.\n let idempotencyKey = opts.idempotencyKey as string | undefined;\n if (!idempotencyKey) {\n if (opts.yes) {\n throw new IdempotencyKeyRequiredError('keys disable');\n }\n idempotencyKey = await PromptEngine.resolveInput(undefined, {\n message: 'Idempotency key (unique per write, for safe retry):',\n validate: (v) => v.trim().length > 0 || 'Idempotency key is required',\n });\n }\n const extraHeaders: Record<string, string> = {\n 'Idempotency-Key': idempotencyKey,\n };\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.post<DisableResult>(\n `/keys/${keyId}/disable`,\n { type: 'bearer', token },\n undefined,\n extraHeaders,\n ),\n );\n\n if (!result.success) {\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n const disableResult = result.data;\n\n // Status line is a log → stderr, table mode only (json stays silent).\n notify(format, 'success', `API Key ${keyId} disabled`);\n\n const cmdResult: CommandResult<DisableResult> = {\n data: disableResult,\n text: () =>\n Formatter.keyValue([\n ['Status', disableResult.status],\n ]),\n };\n render(cmdResult, { format });\n });\n}\n","import { Command } from 'commander';\nimport { ApiClient } from '../api/client.js';\nimport { AuthService } from '../auth/auth-service.js';\nimport { PromptEngine } from '../utils/prompt-engine.js';\nimport { Formatter } from '../utils/formatter.js';\nimport { render, resolveFormat, notify } from '../utils/output.js';\nimport { ApiBusinessError } from '../utils/errors.js';\nimport { CommandResult } from '../types/commands.js';\nimport { SettlementAccount } from '../types/api.js';\n\nexport function registerGetCommand(\n parent: Command,\n deps: { apiClient: ApiClient; authService: AuthService },\n): void {\n parent\n .command('get')\n .description(\"Query a developer's settlement account\")\n .option('--developer-id <id>', 'Developer ID to query')\n .action(async (options, command: Command) => {\n const format = resolveFormat(command.optsWithGlobals().format);\n\n const developerId = await PromptEngine.resolveInput(options.developerId, {\n message: 'Developer ID (e.g. dev_01HZ...):',\n });\n\n const result = await deps.authService.executeWithAuth((token) =>\n deps.apiClient.get<SettlementAccount | null>(\n '/accounts',\n { type: 'bearer', token },\n { developer_id: developerId },\n ),\n );\n\n if (!result.success) {\n throw new ApiBusinessError(result.errorCode, result.errorMessage, result.statusCode);\n }\n\n const account = result.data;\n\n // Auto-provisioning means an absent account only happens for legacy\n // developers. The backend returns data:null with a message; render an\n // info line in table mode and emit null in json mode.\n if (!account) {\n notify(\n format,\n 'info',\n 'No settlement account found for this developer. Complete offline contract signing first.',\n );\n render({ data: null, text: () => '' }, { format });\n return;\n }\n\n const commandResult: CommandResult<SettlementAccount> = {\n data: account,\n text: () =>\n Formatter.keyValue([\n ['Account ID', account.id],\n ['Developer ID', account.developer_id],\n ['Balance', String(account.balance)],\n ['Currency', account.currency],\n ['Status', account.status],\n ['Created', Formatter.formatTime(account.created_at)],\n ['Updated', Formatter.formatTime(account.updated_at)],\n ]),\n };\n\n render(commandResult, { format });\n });\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,eAAe;;;ACCjB,IAAe,WAAf,cAAgC,MAAM;AAE7C;AAGO,IAAM,mBAAN,cAA+B,SAAS;AAAA,EAE7C,YACkB,WACA,cACA,YAChB;AACA,UAAM,IAAI,SAAS,KAAK,YAAY,EAAE;AAJtB;AACA;AACA;AAAA,EAGlB;AAAA,EALkB;AAAA,EACA;AAAA,EACA;AAAA,EAJT,OAAO;AAQlB;AAGO,IAAM,eAAN,cAA2B,SAAS;AAAA,EAEzC,YACkB,KACA,SACA,OAChB;AACA,UAAM,SAAS,OAAO;AACtB,QAAI;AACJ,QAAI,SAAS;AACX,YAAM,sBAAsB,OAAO,QAAQ,GAAG;AAAA,IAChD,WAAW,QAAQ;AACjB,YAAM,sBAAsB,GAAG,KAAK,MAAM;AAAA,IAC5C,OAAO;AACL,YAAM,sBAAsB,GAAG;AAAA,IACjC;AACA,UAAM,GAAG;AAbO;AACA;AACA;AAAA,EAYlB;AAAA,EAdkB;AAAA,EACA;AAAA,EACA;AAAA,EAJT,OAAO;AAiBlB;AAGO,IAAM,YAAN,cAAwB,SA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ACtE,cAAQ,MAAM,KAAK;AAAA,IACrB;AAAA,EACF;AAIA,UAAQ,KAAK,YAAY,KAAK,CAAC;AACjC;AAGA,QAAQ,GAAG,UAAU,MAAM;AACzB,cAAY,IAAI,gBAAgB,CAAC;AACnC,CAAC;AAID,KAAK,EAAE,MAAM,WAAW;","names":["join","join","readFile","writeFile","mkdir","join","homedir","readFile","writeFile","mkdir","dirname","join","homedir","Formatter","resolveFormat","registerListCommand","registerUpdateCommand","registerCreateCommand","registerListCommand","toMetadata","registerGetCommand","registerGetCommand","registerListCommand","registerUpdateCommand","registerCreateCommand","registerGetCommand"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agenzo/admin-cli",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Admin CLI for the Agenzo platform (login, orgs, developers, API keys)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"agenzo-admin-cli": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsup",
|
|
17
|
+
"dev": "tsup --watch",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"test:watch": "vitest",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/CardInfoLink/agent-token-cli.git"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"cli",
|
|
28
|
+
"agent",
|
|
29
|
+
"agenzo",
|
|
30
|
+
"admin",
|
|
31
|
+
"identity",
|
|
32
|
+
"ai-agent",
|
|
33
|
+
"organization",
|
|
34
|
+
"developer",
|
|
35
|
+
"api-key",
|
|
36
|
+
"developer-tools"
|
|
37
|
+
],
|
|
38
|
+
"author": "",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/CardInfoLink/agent-token-cli/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/CardInfoLink/agent-token-cli#readme",
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18.0.0"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@inquirer/prompts": "^8.4.2",
|
|
49
|
+
"commander": "^14.0.3"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^25.6.0",
|
|
53
|
+
"fast-check": "^4.7.0",
|
|
54
|
+
"tsup": "^8.5.1",
|
|
55
|
+
"typescript": "^6.0.3",
|
|
56
|
+
"vitest": "^4.1.5"
|
|
57
|
+
}
|
|
58
|
+
}
|