/** * Pi-side shape of a `session_before_compact` result. Pi doesn't re-export * these event result types at the top level, so we inline the minimal shape. */ export type SessionBeforeCompactResult = { cancel?: boolean; compaction?: { summary: string; firstKeptEntryId: string; tokensBefore: number; details?: unknown; }; }; /** * Providers whose wire protocol the Lore gateway can proxy, split by SDK * protocol so we can set the correct `baseUrl` for each group. * * - Anthropic SDK appends `/v1/messages` to baseURL → pass gateway root. * - OpenAI SDK appends `/chat/completions` or `/responses` to baseURL and * expects it to already include `/v1` → pass `${gateway}/v1`. * * Providers using other protocols (Google SDK, AWS Bedrock SDK, Mistral * conversations) are not redirected. * * For local/self-hosted providers, set `LORE_UPSTREAM_=` (e.g. * `LORE_UPSTREAM_VLLM=http://localhost:8000`) so the gateway knows where to * forward requests. Cloud providers are routed automatically by model name * prefix. */ /** Anthropic-messages API → gateway POST /v1/messages */ export declare const ANTHROPIC_PROVIDERS: readonly ["anthropic", "fireworks", "minimax", "minimax-cn", "kimi-coding"]; /** OpenAI-completions / OpenAI-responses API → gateway POST /v1/chat/completions or /v1/responses */ export declare const OPENAI_PROVIDERS: readonly ["github-copilot", "deepseek", "xai", "groq", "cerebras", "openrouter", "huggingface", "zai", "opencode", "opencode-go", "vercel-ai-gateway", "openai", "openai-codex", "vllm", "llamacpp", "ollama", "lmstudio", "jan", "localai", "tgi", "tabbyml", "litellm"]; /** All providers that can be routed through the gateway. */ export declare const GATEWAY_PROVIDERS: readonly string[]; /** Default ports to probe when looking for a running gateway (must match gateway defaults). */ export declare const KNOWN_GATEWAY_PORTS: number[]; /** A provider registration as passed to `pi.registerProvider`. */ export interface ProviderRegistration { provider: string; baseUrl: string; headers: Record; } /** * Check if the Lore gateway is reachable at the given base URL. * Short timeout so this doesn't delay Pi startup noticeably. */ export declare function probeGateway(baseURL: string, timeoutMs?: number): Promise; /** * Resolve the gateway URL by probing known ports and reading the port file. * * Order: LORE_REMOTE_URL → LORE_GATEWAY_URL → port file → known default * ports (3207, 5673). Returns the URL of a running gateway, or null if none * found. */ export declare function resolveGatewayUrl(): Promise; /** * Start the gateway server in-process by importing @loreai/gateway as a * library. The published CJS bundle includes Node.js polyfills that shim * Bun.serve() to node:http.createServer(), so this works under both Bun and * Node.js. * * Uses startGateway() which handles the full port fallback chain * (3207 → 5673 → random) and port file management automatically. * Returns the URL of the started gateway, or null on failure. */ export declare function startInProcess(): Promise; /** * Derive a stable session identifier from Pi's current session file path. * Falls back to an ephemeral, per-process id when no session file is known. */ export declare function sessionIDFor(sessionFile: string | undefined): string; /** * Build the provider registrations for every gateway-routable provider. * * Pure: given the gateway base, the current session/project, the resolved git * remote, and the environment, it returns the `{ provider, baseUrl, headers }` * tuples to hand to `pi.registerProvider`. Anthropic-protocol providers get the * gateway root; OpenAI-protocol providers get `${gateway}/v1`. Each carries the * `x-lore-*` attribution headers and, for local/custom providers, the * `x-lore-upstream-url` from `LORE_UPSTREAM_`. */ export declare function buildProviderRegistrations(opts: { gatewayBase: string; sessionID: string; projectPath: string; gitRemote?: string; env?: NodeJS.ProcessEnv; }): ProviderRegistration[]; /** * Call the gateway's `POST /v1/compact` endpoint and shape the result for Pi's * `session_before_compact` hook. * * The plugin is a dumb relay. The gateway is the single source of truth for * "does this session's raw context fit in the layer-0 budget?" — it returns * either: * * { cancel: true } — host should keep the raw context; * we relay as `{ cancel: true }` to * Pi's `session_before_compact` hook * (which Pi honors on both manual * and auto paths, per * agent-session.js:1275 / :1498). * { summary: string } — use this Lore-aware summary * instead of Pi's default. We shape * it as `{ compaction: {...} }`. * * Returns `undefined` to fall back to Pi's default compaction on ANY error * path: * - 404 `session_not_found` (this session never routed through Lore), * - any other non-2xx response, * - a thrown/network error, * - a 2xx with neither `cancel: true` nor a non-empty `summary`. * * Never throws and never writes to stdout/stderr — all diagnostics go through * the core `log` module (file-based, TUI-safe). `fetchImpl` is injectable for * testing. */ export declare function runCompaction(opts: { gatewayBase: string; sessionID: string; projectPath: string; previousSummary: string | undefined; firstKeptEntryId: string; tokensBefore: number; fetchImpl?: typeof fetch; }): Promise; //# sourceMappingURL=internal.d.ts.map