/** * Code Mode client for tool chaining with UTCP */ import { CodeModeUtcpClient } from "@utcp/code-mode"; import "@utcp/mcp"; /** * Constructor options for {@link ZaiCodeModeClient}. * * `clientFactory` is a behaviour-preserving injection seam: when omitted * the production path uses `CodeModeUtcpClient.create()`. Tests inject a * fake to drive the error path without spinning up a real UTCP client. */ export interface ZaiCodeModeClientOptions { clientFactory?: () => Promise; /** * T2b — Credential view: resolved env (injected env + file keys). * When omitted, ambient `process.env` is used so existing direct * constructors keep working. When supplied, the registration * template authorises with the resolved credential rather than * ambient state. */ env?: NodeJS.ProcessEnv; } /** * Resolve the Code Mode request timeout from `Z_AI_TIMEOUT` (#214). * * PR #142 round 3 (macroscope): only supported positive delays — a * parseable-but-invalid value ("-1", out-of-range) must never reach * AbortSignal.timeout, whose throw degrades the failure-path probe to * inconclusive (generic ApiError instead of AuthError). #214 unifies * the bound at the shared setTimeout 32-bit signed maximum * (clampTimeoutMs) so this resolver matches every other Z_AI_TIMEOUT * consumer. */ export declare function resolveCodeModeTimeoutMs(env: NodeJS.ProcessEnv): number; export declare class ZaiCodeModeClient { private client; private initPromise; private isInitialized; private options; private readonly timeoutMs; constructor(options?: ZaiCodeModeClientOptions); static getPromptTemplate(): string; private init; private _doInit; /** * #135 — classify the real HTTP status behind an initialization failure * with ONE cheap authenticated `initialize` against the MCP endpoint the * registration template was going to use (the same request and Bearer * credential the template carries). Mirrors ZaiMcpClient's #117 probe. * * Z.AI rejects bad credentials as a JSON body (`{"code":401,...}`) * inside HTTP 200, and UTCP's registration error collection drops the * body's values, so the status must be re-read here. Classification * reads the HTTP status and the body's numeric `code` field ONLY — no * byte of the body ever reaches the public error message (NFR-006). * * Returns 401/403 when the failure is an auth rejection, `null` when * the probe is inconclusive (any other status, unreachable endpoint, * unparsable body, missing credential) so the caller keeps today's * error shape. Runs exclusively on the already-failed init path. */ private probeAuthStatusOnFailure; callToolChain(code: string, timeoutMs?: number): Promise<{ result: unknown; logs: string[]; }>; getAllInterfaces(): Promise; close(timeoutMs?: number): Promise; } //# sourceMappingURL=code-mode.d.ts.map