/** * Cursor runtime core — runtime-agnostic plugin internals shared by the v1 * hook adapter (src/index.ts) and the v2 domain adapter (src/v2-entry.ts). * * Owns: Cursor OAuth token lifecycle, local proxy lifecycle, model catalog * stamping, tool implementations, workspace/index managers, and (v1-only) * config-object mutation for the legacy auth.loader path. * cleanup-traps: ok -- background-shell supervisor owns process groups and disposes them on session teardown. */ import { type ToolDefinition } from "@opencode-ai/plugin"; export { CURSOR_CONTEXT_HEADER, CURSOR_SESSION_HEADER, CURSOR_AGENT_HEADER, } from "./request-scope"; import { loadCursorPluginConfig } from "./config"; import { type GenerateCursorImageOptions, type GenerateCursorImageResult } from "./cursor-image"; import { type CursorModel } from "./models"; import { type WorkspaceContextOptions } from "./workspace-context"; type GenerateCursorImageFn = (options: GenerateCursorImageOptions) => Promise; declare function disposeBackgroundShellSupervisorsForTest(): Promise; export declare const CURSOR_PROVIDER_ID = "cursor"; export declare const CURSOR_CODE_PROVIDER_ID = "cursor-code"; export declare function isOAuthAccessTokenUsable(expires: number, now?: number): boolean; /** Setup placeholder; auth.loader / chat.params replace with the live proxy port. */ export declare const CURSOR_PROXY_PLACEHOLDER_PORT = 65535; export declare const CURSOR_PROVIDER_API_PLACEHOLDER = "http://127.0.0.1:65535/v1"; export declare const CURSOR_CODE_PROVIDER_API_PLACEHOLDER = "http://127.0.0.1:65535/v1/code"; /** Proxy base path per provider: /v1 (code OFF) for cursor, /v1/code (code ON) for cursor-code. */ export declare function providerBasePath(providerID: string): string; /** * OpenCode builds the AI SDK client from `provider.options.baseURL ?? model.api.url` * *before* `chat.params` runs, and `auth.loader` only stamps the primary `cursor` * provider. `cursor-code` therefore keeps the setup placeholder (:65535) baked into * the SDK. Rewrite placeholder-port requests to the live proxy at fetch time so * both providers work even when options.baseURL / model.api.url stay stale. */ export declare function rewritePlaceholderProxyUrl(rawUrl: string, livePort: number): string; /** * Cursor runtime factory input. `client` is the v1 OpenCode SDK client and is * absent on v2: self-update toasts, conversation search, subagent await, and * auth-store persistence are v1-only and degrade gracefully without it. * `externalTokenProvider` (v2) resolves access tokens from the integration * credential store instead of the v1 auth loader / on-disk auth.json. */ export interface CursorRuntimeInput { client?: any; directory: string; worktree: string; externalTokenProvider?: () => Promise; } /** v1 hook-shaped callbacks assembled by src/index.ts into a Hooks object. */ export interface CursorRuntimeV1Hooks { config: (cfg: any) => Promise; chatParams: (chatInput: any, output: any) => Promise; chatHeaders: (chatInput: any, output: any) => Promise; chatMessage: (chatInput: any, output: any) => Promise; toolExecuteBefore: (hookInput: any, output: any) => Promise; toolExecuteAfter: (hookInput: any, output: any) => Promise; event: (eventInput: { event: { type: string; properties?: any; }; }) => Promise; auth: { provider: string; loader: (getAuth: () => Promise, provider: any) => Promise>; methods: any[]; }; } /** Primitives shared by the v1 and v2 plugin adapters. */ export interface CursorRuntime { readonly proxyContextId: string; readonly pluginConfig: ReturnType; readonly workspaceOptions: WorkspaceContextOptions; readonly tools: Record; readonly v1: CursorRuntimeV1Hooks; resolveCursorAccessToken(): Promise; resolveCloudIndexAccessToken(): Promise; ensureCursorProxyPort(): Promise; resolveLiveProxyPort(): Promise; getCachedModels(apiKey?: string): import("./models").CursorModel[]; stampSecondaryProvider(models: ReadonlyArray, port: number): void; installProxyFetchOption(provider: any): void; refreshModelsInBackground(provider: any | undefined, port: number, accessToken?: string): void; ensureCloudIndexInBackground(): void; deleteSessionState(sessionId: string): Promise; dispose(): Promise; } /** * Cursor runtime: one instance per plugin load. See CursorRuntimeInput. */ export declare function createCursorRuntime(input: CursorRuntimeInput): CursorRuntime; export declare function modelAcceptsInboundImages(model: CursorModel): boolean; export declare function buildCursorProviderModels(models: CursorModel[], port: number, providerID?: string): Record; export declare const coreTestSeams: { disposeBackgroundShellSupervisors: typeof disposeBackgroundShellSupervisorsForTest; setGenerateCursorImage(fn: GenerateCursorImageFn | null): void; };