/** * Cortex HTTP client — the only OpenKai↔KOS coupling (ADR §4). * * Talks to the Cortex API (`cortex-api:8501` locally) with the same surface * the agent CLIs use: `X-Project` scoping header, optional `X-Agent-Name`. * Per the Cortex access rule this client is the whole contract — OpenKai * never touches Postgres/Redis/workers directly. * * Transport hygiene (ren review): `CORTEX_API_TOKEN` (process env only — * never the project `.env`) adds an `Authorization: Bearer` header; every * JSON call carries a default 15s timeout (`AbortSignal.timeout`, * per-call overridable) so a hung API cannot stall a turn; and a * non-loopback plain-http baseUrl warns once on stderr (tokens and session * content would cross the network in cleartext). */ import type { CortexClientOptions, CortexHealth, CortexProject, CortexStreamItem, SkillBindPayload, SkillInfo, SkillRegisterPayload, StreamEventsOptions } from "./types.js"; /** Default local Cortex API origin (matches `.agents/scripts/_cortex_env.sh`). */ export declare const DEFAULT_CORTEX_API_URL = "http://localhost:8501"; /** Default per-request timeout for JSON calls (ren review). */ export declare const DEFAULT_FETCH_TIMEOUT_MS = 15000; /** Non-2xx response from the Cortex API. `body` carries the server's detail. */ export declare class CortexApiError extends Error { readonly status: number; readonly body: string; constructor(message: string, status: number, body: string); } export declare class CortexClient { /** Normalised base URL (no trailing slash). */ readonly baseUrl: string; /** Project scope for every request. */ readonly project: string; private readonly agent; private readonly fetchImpl; /** Optional bearer token from `CORTEX_API_TOKEN` (process env only). */ private readonly token; constructor(options: CortexClientOptions); private headers; private getJson; /** * `POST` a JSON payload to a Cortex path. Returns the parsed JSON response * (or `undefined` for an empty body). Used by the session-checkpoint and * lifecycle-event writers (P2+). */ postJson(path: string, payload: unknown, options?: { agent?: string; timeoutMs?: number; }): Promise; /** * `DELETE` a Cortex path. Returns the parsed JSON response (or `undefined` * for an empty body). Used by the skill-remove flow (E002 Inc 05). */ deleteJson(path: string, options?: { timeoutMs?: number; }): Promise; /** `GET /health` — liveness + backend configuration of this Cortex API. */ health(): Promise; /** `GET /projects/` — registry record for a project (default: ours). */ getProject(key?: string): Promise; /** `GET /sessions/ingested-ids` — ingested session ids for this project (mode-matrix evidence). */ getIngestedIds(): Promise<{ project: string; ids: string[]; }>; /** `GET /skills` — list skills visible to this project. */ listSkills(): Promise; /** `POST /skills` — register or upsert a skill in the agent_skills registry. */ registerSkill(payload: SkillRegisterPayload): Promise; /** `DELETE /skills/{slug}` — remove a skill from the registry. */ deleteSkill(slug: string): Promise; /** `POST /skills/{slug}/bind` — bind a skill to a role or agent. */ bindSkill(slug: string, payload: SkillBindPayload): Promise; /** * `GET /events` — live SSE bridge over the project's `team_events`. * * Hygiene (OK-3 / handoff contract): * - resume: last delivered id is re-sent as `last_id` (and `Last-Event-ID`) * on every reconnect, so nothing is delivered twice or skipped; * - keep-alives: `: ping` comments surface as `ping` items rather than * being mistaken for events; * - in-band errors: `event: error` frames surface as `stream-error` * items and do NOT tear the stream down (the server keeps it open); * - reconnect: transport failures and unexpected EOFs reconnect with * exponential backoff starting at 1s, doubling to a 30s cap, reset on * every successful connect; * - ids are ascending bigints carried as strings (no precision loss). * * The generator runs until aborted or `maxRetries` is exceeded (then it * throws the last error). */ streamEvents(options?: StreamEventsOptions): AsyncGenerator; } //# sourceMappingURL=client.d.ts.map