import { Context } from "@earendil-works/pi-ai"; import { SettingSource, query } from "@anthropic-ai/claude-agent-sdk"; import "cc-session-io"; import { ExtensionAPI, ExtensionUIContext } from "@earendil-works/pi-coding-agent"; //#region config.d.ts interface Config { askClaude?: { enabled?: boolean; name?: string; label?: string; description?: string; defaultMode?: 'full' | 'read' | 'none'; defaultIsolated?: boolean; allowFullMode?: boolean; appendSkills?: boolean; }; /** Low-level Claude Agent SDK plumbing. Most users won't need these. */ provider?: { appendSystemPrompt?: boolean; settingSources?: SettingSource[]; strictMcpConfig?: boolean; pathToClaudeCodeExecutable?: string; plan?: 'pro' | 'max'; longContextExtraUsage?: boolean; }; } //#endregion //#region models.d.ts type LongContextSettings = { plan: 'pro' | 'max'; longContextExtraUsage: boolean; }; //#endregion //#region session-store.d.ts interface SessionState { sessionId: string; cursor: number; cwd: string; needsRebuild?: boolean; forceRotate?: boolean; } interface SyncResult { sessionId: string | null; path: 'clean-start' | 'empty-rebuild' | 'reuse' | 'append' | 'rebuild'; } type SyncDiagnostics = Record; type NotifyFn = (message: string, level: 'warning' | 'error') => void; declare class SessionStore { private state; private notify?; private owner; private inputHashes; private inputPolicy; private stagedHashes; /** Why the last sync took its path; cache diagnostics only, never content. */ lastSyncDiagnostics: SyncDiagnostics; constructor(notify?: NotifyFn); get current(): SessionState | null; clear(): void; /** Force a rebuild on the next sync, keeping the same session id. */ markRebuild(): void; /** Force a rebuild with a rotated id (post-abort: avoid racing an orphaned writer). */ markAborted(): void; /** Move the cursor forward after messages were handled outside sync(). */ advanceCursor(cursor: number): void; /** Record the session a completed query ended on. */ commit(sessionId: string, cursor: number, cwd: string, owner?: string | undefined): void; private hashes; private policy; matchesPrefix(messages: Context['messages'], map?: Map, model?: string, cwd?: string | undefined, owner?: string | undefined): boolean; private matchesHashes; /** Which matchesHashes condition failed, checked in the same order. */ private mismatchReason; /** Tail not yet handled by the live query (including busy steering). */ unacceptedTail(messages: Context['messages']): Context['messages']; accept(messages: Context['messages'], map?: Map, model?: string): void; sync(messages: Context['messages'], cwd: string, customToolNameToSdk?: Map, modelId?: string, owner?: string): SyncResult; private verify; } //#endregion //#region runtime.d.ts /** The Claude Agent SDK `query` entry point; injectable so provider.ts and * askclaude.ts orchestration can be driven by a scripted fake in tests. */ type QueryFn = typeof query; interface BridgeRuntime { providerSettings: NonNullable; longContextSettings: LongContextSettings; sessions: SessionStore; ui: ExtensionUIContext | null; askClaudeToolName: string; /** Cached because oh-my-pi's CustomToolContext lacks getSystemPrompt. */ cachedSystemPrompt: string[]; queryFn: QueryFn; } //#endregion //#region index.d.ts export declare function registerClaudeBridge(pi: ExtensionAPI, options?: { cwd?: string; }): BridgeRuntime; //#endregion export { registerClaudeBridge as default };