/** * Z.AI Repository Adapter (DESIGN.md §18, PRD FR-081, FR-087, * FR-089–FR-091, FR-093; NFR-004, NFR-006). * * Owns the Provider-facing half of the provider-neutral Repository * Capability defined in `src/capabilities/repository.ts`: * * - total parsers for the characterized ZRead Search, File, and * Directory Listing responses (``, ``, * ``); * - per-operation Z.AI descriptors with `validate`, `cacheIdentity`, * `decodeCached`, and `invoke`; * - a single resolved-credential fingerprint per cache identity and * exact per-operation legacy cache candidates/decoders; * - encoded MCP error classification BEFORE success parsing * (exhausted quota is terminal `QUOTA_ERROR`; the rest of the * taxonomy uses the shared retry/terminal classification); * - a fresh transport per invocation attempt and exactly one * best-effort close in `finally`; close failure never replaces * success nor masks the primary failure; * - no leakage of raw ZRead response types outside this module. * * Boundary rules (ARCHITECTURE.md §2): * - May import capability types, normalized errors, the Z.AI MCP * tool-name helpers, the legacy cache-key helper, and the * shared `ZaiAdapterClientPort` typed client port. * - Must NOT import another Provider's Adapter, command * presentation, BFS/Explorer logic, or path canonicalization. * * Scope: * - implements Search, File, and Directory Listing only. Tree * projection, BFS, depth/path policy, and `--max-chars` all * belong to the Explorer layer (P6-05+) or the command layer. * - descriptor metadata sequencing: P6-04 introduced this Adapter * handle and wired it through `ProviderAdapter.repository` * WITHOUT advertising `repository-exploration` on * `createZaiDescriptor.capabilities()`; P6-06 then flipped the * descriptor to advertise `repository-exploration` so Provider * selection and Doctor inventory derive from a single source of * truth. This module itself still owns no registry, selection, * or command cutover — `commands/repo.ts` continues to dispatch * through the legacy `ZReadMcpClient` until P6-07 exclusively * owns that dispatch cutover. */ import type { ZaiAdapterClientPort, ZaiMcpClientOptions } from "../types.js"; import { type RepositoryCapability } from "../../capabilities/repository.js"; /** * Production close bound (ms). Matches the existing * `ZaiMcpClient.close(timeoutMs = 2000)` semantic; the Adapter races * the close against a 2 second timer that resolves silently so a stuck * close cannot stall the attempt. Tests may inject a shorter bound via * {@link ZaiRepositoryCapabilityOptions.closeTimeoutMs}. */ export declare const ZAI_REPOSITORY_CLOSE_BOUND_MS = 2000; /** * Options accepted by {@link createZaiRepositoryCapability}. * * `closeTimeoutMs` defaults to {@link ZAI_REPOSITORY_CLOSE_BOUND_MS} * (2000 ms) — the existing `ZaiMcpClient.close(timeoutMs = 2000)` * semantic. Tests may inject a shorter bound to bound a never- * resolving `close()` without waiting for the production default. */ export interface ZaiRepositoryCapabilityOptions { readonly env: NodeJS.ProcessEnv; readonly clientFactory: (options: ZaiMcpClientOptions) => ZaiAdapterClientPort; readonly closeTimeoutMs?: number; } /** * Build the Z.AI Repository Capability. The capability is composed of * three typed `RepositoryOperation` descriptors; the Adapter owns * credentials, transport lifecycle, raw request/response mapping, and * error normalization. No transport, credential resolution, or I/O * happens during construction. */ export declare function createZaiRepositoryCapability(options: ZaiRepositoryCapabilityOptions): RepositoryCapability; //# sourceMappingURL=repository.d.ts.map