import { RetryConfig } from '../tools/utils/resilience.js'; /** * MorphAPIClient — the SDK transport. * * One place owns authentication, the Morph service hosts, default headers, * retries, timeouts, and error mapping. Every resource (FastApply, Compact, * Reflex, …) holds a reference to this client and delegates HTTP to it via * `get`/`post`/`delete`/`request`, exactly like the OpenAI SDK. * * This module is intentionally free of tool imports and Node built-ins so it * stays edge-safe (it is reachable from `@morphllm/morphsdk/edge` through the * Compact and model-router resources). */ interface MorphAPIClientOptions { /** Morph API key. Resolved against `MORPH_API_KEY` at request time if omitted. */ apiKey?: string; /** Primary API host (default `https://api.morphllm.com`). */ baseURL?: string; /** Code-storage host for codebase search and git (default `https://repos.morphllm.com`). */ reposURL?: string; /** Browser-automation host (default `https://browser.morphllm.com`). */ browserURL?: string; /** Default per-request timeout in ms (default 60s). Resources may override per call. */ timeout?: number; /** Retry policy for transient failures. */ retryConfig?: RetryConfig; /** Enable debug logging. */ debug?: boolean; } /** Per-request options accepted by `request`/`get`/`post`/`delete`. */ interface RequestOptions { /** JSON body; serialized with `JSON.stringify`. */ body?: unknown; /** Query parameters; `undefined`/`null` values are dropped. */ query?: Record; /** Extra headers, merged over (and able to override) the defaults. */ headers?: Record; /** Override the timeout for this call. */ timeout?: number; /** Hit a different host than the default (e.g. `this._client.reposURL`). */ baseURL?: string; /** Return the raw `Response` of a successful (2xx) request instead of parsed JSON (for streaming). */ stream?: boolean; /** * Return the raw `Response` without throwing on non-2xx and without parsing. * For resources that map errors into their own taxonomy (e.g. GitHub). */ raw?: boolean; /** Caller-supplied abort signal. */ signal?: AbortSignal; } declare class MorphAPIClient { /** Explicit key as provided; resolved against env at request time. */ apiKey?: string; baseURL: string; reposURL: string; browserURL: string; /** Explicit default timeout (ms), if set. The request default is applied lazily so * resources can read an undefined value and supply their own fallback. */ timeout?: number; retryConfig?: RetryConfig; debug: boolean; constructor(options?: MorphAPIClientOptions); /** The key actually used for requests: explicit, else `MORPH_API_KEY`. */ resolveApiKey(): string | undefined; /** Headers shared with tools that bring their own HTTP client (FastApply/WarpGrep via the `openai` package). */ defaultHeaders(): Record; buildURL(path: string, baseURL?: string): string; private buildHeaders; private applyQuery; request(method: string, path: string, opts?: RequestOptions): Promise; get(path: string, opts?: RequestOptions): Promise; post(path: string, opts?: RequestOptions): Promise; delete(path: string, opts?: RequestOptions): Promise; } export { MorphAPIClient, type MorphAPIClientOptions, type RequestOptions };