/** * Daemon-internal HTTP client (PR2 C7) — used by daemon processes to talk to * the dashboard's `/__daemon/*` Route B endpoints with HMAC auth. * * Retry policy (codex C7 gate): * - GET defaults to N retries with exponential backoff. Each attempt mints * a fresh `ts + nonce + sig`; we never reuse a signature. * - Non-GET (POST/PUT/DELETE) defaults to NO retry to avoid double-effect * on close/resume/leave/disband/settings-write/etc. Callers can opt in * with `retryUnsafeWrites: true` when they're confident the endpoint is * idempotent end-to-end. * - 401 is never retried (sig will not become valid by retrying). * - 4xx other than 408/429 is also never retried. * - Network errors and timeouts follow the same per-method policy. * * Signed `pathWithQuery` is forwarded BYTE-FOR-BYTE to fetch; we never * canonicalise the query string. Callers that build URLs MUST control their * own parameter order. * * The client never touches the real dashboard in tests — `fetch` / `now` / * `randomNonce` / `secret` are all injectable. */ export interface DaemonClientOptions { /** Base URL of the dashboard process (default `http://127.0.0.1:7891`). */ dashboardUrl?: string; /** Override the HMAC key. Production loads from `.dashboard-secret` if omitted. */ secret?: string; /** Override `.dashboard-secret` path (tests). */ secretPath?: string; /** Identifier this daemon reports in the `X-Botmux-Daemon-AppId` header (audit, not authn). */ appId: string; /** Override `fetch` (tests). */ fetch?: typeof fetch; /** Override `Date.now` (tests). */ now?: () => number; /** Override nonce source (tests). Default 32 random bytes base64url. */ randomNonce?: () => string; /** Default retry count for GETs / write+retryUnsafeWrites. Default 3. */ retries?: number; /** Override backoff schedule. Default: min(100ms * 2^attempt, 5000ms). */ backoffMs?: (attempt: number) => number; /** Per-request timeout default. Default 5000ms. */ timeoutMs?: number; /** Skip sleeping between retries — used by tests to keep runtime O(ms). */ skipBackoffSleep?: boolean; } export interface DaemonRequestOptions { method?: string; /** Path + query as a single string, e.g. '/__daemon/sessions-list?all=1'. Signed verbatim. */ path: string; body?: unknown; retryUnsafeWrites?: boolean; retries?: number; timeoutMs?: number; } export interface DaemonClientResponse { status: number; /** Decoded JSON when the response was JSON; otherwise the raw text. */ body: unknown; /** Raw response text (whether or not it was JSON-parseable). */ raw: string; } export interface DaemonClient { request(opts: DaemonRequestOptions): Promise; } export declare function createDaemonClient(opts: DaemonClientOptions): DaemonClient; //# sourceMappingURL=daemon-internal-client.d.ts.map