import type { Command } from 'commander'; import type { Config } from '../types/index.js'; export interface ErrorWatcherOptions { create?: boolean; list?: boolean; show?: string; /** `--events [watcherId]`: `true` (all watchers) or a specific watcher id. */ events?: string | boolean; update?: string; delete?: string; /** `--print-setup [watcherId]`: the id is informational only. */ printSetup?: string | boolean; name?: string; dedupeWindow?: number; maxFixesPerDay?: number; environments?: string; outcomeType?: string; prPolicy?: string; enabled?: string; /** Trusted guidance rendered into the fix agent's brief. */ instructions?: string; /** Clear the stored instructions (sends `instructions: null`). */ clearInstructions?: boolean; /** Repeatable `KEY=VALUE` env vars injected into the fix sandbox. */ errorEnv?: string[]; /** Clear all errorEnvVars (sends an empty map). */ clearErrorEnv?: boolean; /** Repeatable literal values redacted from every payload for this watcher. */ secret?: string[]; /** Clear the extra redaction list (sends an empty array). */ clearSecrets?: boolean; status?: string; limit?: number; provider?: string; providerKey?: string; containerCpu?: number; containerMemory?: number; containerDisk?: number; updateNotificationUrl?: string; updateNotificationNameTag?: string; project?: string; url?: string; apiKey?: string; json?: boolean; yes?: boolean; } /** The mutually-exclusive command modes, in dispatch order. */ export type WatcherMode = 'create' | 'list' | 'show' | 'events' | 'update' | 'delete' | 'print-setup'; /** * Manage production Error Watchers — thin REST client over * `/api/v1/error-watchers`, structured like `hula schedule`. */ export declare function errorWatcherCommand(program: Command, config: Config): void; /** * Commander collector for a repeatable flag. `previous` is undefined on the * first occurrence, which is what lets a caller distinguish "flag omitted" * (undefined) from "flag given" — the distinction PATCH relies on to leave a * field untouched rather than clearing it. */ export declare function collectRepeatable(value: string, previous?: string[]): string[]; /** * Which mode flags are active. `--events` and `--print-setup` count when * present even without a value (`true`); every other flag counts when truthy. */ export declare function selectModes(options: ErrorWatcherOptions): WatcherMode[]; /** * Dispatch a single mode. Enforces mutual exclusion BEFORE any network call, so * two mode flags fail without issuing a request. With no mode flag, prints help. */ export declare function runErrorWatcher(config: Config, options: ErrorWatcherOptions, showHelp?: () => void): Promise; /** * The ingest webhook URL the customer's production app POSTs to. Defaults to * `/api/v1/webhooks/error`, overridable via `config.errorWebhookUrl` * for self-hosted servers whose webhook host differs from `hulaProjectUrl`. */ export declare function resolveWebhookUrl(serverUrl: string, config: Config): string; /** * Where a project ingest key (`hik_…`) is minted. Key CRUD is exposed over * tRPC only — there is no REST route for the CLI to call — so every setup path * points the user at this page rather than pretending to issue a credential. */ export declare function resolveProjectSettingsUrl(serverUrl: string): string; /** * Validate tuning flags client-side so the common mistakes are caught without a * network round trip. Returns a list of error strings (empty when all valid). * The server validates independently; this is a convenience, not the boundary. */ export declare function validateTuningOptions(options: ErrorWatcherOptions): string[]; /** * Validate the repeatable `--error-env KEY=VALUE` pairs. Reserved names are * rejected here because the server returns a 400 for them, and the platform * owns those variables inside the fix sandbox. */ export declare function validateErrorEnv(entries: string[] | undefined): string[]; /** * Validate the repeatable `--secret` values. The minimum length is the server's * floor: a very short literal would match everywhere and shred the very error * text the fix agent needs. */ export declare function validateSecrets(entries: string[] | undefined): string[]; /** Parse validated `KEY=VALUE` entries into the map the server expects. */ export declare function parseErrorEnv(entries: string[]): Record; /** * The signed-request snippet. HARD-CODED (never fetched) so `--print-setup` * works with the server unreachable. Built line-by-line from single/double * quoted strings so the literal `${timestamp}.${body}` signing payload survives * verbatim into the printed output (it must NOT be interpolated here). */ export declare function buildSigningSnippet(): string; /** * The `.env` block for the customer's production environment. * * The credential is the PROJECT ingest key (`hik_…`) and its own signing secret * (`his_…`), minted in the dashboard settings page — not the watcher. The CLI * never holds either value, so both are always placeholders. */ export declare function buildEnvBlock(webhookUrl: string): string; /** * Print the wiring steps for a watcher: mint the project ingest key, set the * env vars, paste the signed-request snippet. * * The CLI deliberately prints no credential of its own. Ingest keys are created * over tRPC from the dashboard and have no REST route, so the only honest thing * the CLI can do is say where to get one. The watcher `hew_`/`hes_` values the * create endpoint still returns authenticate nothing and are never shown. */ export declare function printSetupInstructions(serverUrl: string, webhookUrl: string): void; /** * One-line rendering of the watcher's `instructions`. Long guidance is elided * rather than wrapped so the field stays one row in the detail block. */ export declare function summarizeInstructions(instructions: string | null | undefined, maxLen?: number): string; /** Humanize a duration in seconds: 300 → 5m, 3600 → 1h, 86400 → 24h, 604800 → 7d. */ export declare function humanizeDuration(seconds: number): string; /** Relative time such as "12m ago" for an ISO timestamp. */ export declare function relativeTime(iso: string): string; /** * Map server responses to actionable messages. NEVER echoes the Authorization * header, the watcher token, or the secret — none of those are read from the * error object, so no redaction pass is needed. Re-throws non-axios errors for * the caller's outer handler. */ export declare function handleWatcherApiError(error: unknown, serverUrl: string, ctx?: { project?: string; watcherId?: string; }): void; //# sourceMappingURL=errorWatcher.d.ts.map