## Public API Report File for "@grackle-ai/runtime-sdk"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import { Logger } from 'pino';

// @public
export interface AgentEvent {
    // (undocumented)
    content: string;
    // (undocumented)
    raw?: unknown;
    // (undocumented)
    timestamp: string;
    // Warning: (ae-forgotten-export) The symbol "AgentEventType" needs to be exported by the entry point index.d.ts
    //
    // (undocumented)
    type: AgentEventType;
}

// @public
export interface AgentRuntime {
    // (undocumented)
    name: string;
    resume(opts: ResumeOptions): AgentSession;
    spawn(opts: SpawnOptions): AgentSession;
}

// @public
export interface AgentSession {
    drainBufferedEvents(): AgentEvent[];
    // (undocumented)
    id: string;
    kill(reason?: string): void;
    // (undocumented)
    runtimeName: string;
    // (undocumented)
    runtimeSessionId: string;
    sendInput(text: string): void;
    // Warning: (ae-forgotten-export) The symbol "SessionStatus" needs to be exported by the entry point index.d.ts
    //
    // (undocumented)
    status: SessionStatus;
    stream(): AsyncIterable<AgentEvent>;
}

// @public
export class AsyncQueue<T> {
    // (undocumented)
    [Symbol.asyncIterator](): AsyncIterableIterator<T>;
    // (undocumented)
    close(): void;
    drain(): T[];
    // (undocumented)
    push(item: T): void;
    // (undocumented)
    shift(): Promise<T | undefined>;
}

// @public
export abstract class BaseAgentRuntime implements AgentRuntime {
    protected abstract createSession(opts: CreateSessionOptions): AgentSession;
    // (undocumented)
    abstract name: string;
    resume(opts: ResumeOptions): AgentSession;
    protected resumePrompt: string;
    spawn(opts: SpawnOptions): AgentSession;
}

// @public
export abstract class BaseAgentSession implements AgentSession {
    constructor(opts: CreateSessionOptions);
    protected abstract abortActive(): void;
    // (undocumented)
    protected readonly branch?: string;
    protected buildInitialPrompt(): string;
    drainBufferedEvents(): AgentEvent[];
    // (undocumented)
    protected readonly eventQueue: AsyncQueue<AgentEvent>;
    protected abstract executeFollowUp(text: string): Promise<void>;
    // (undocumented)
    protected readonly hooks?: Record<string, unknown>;
    // (undocumented)
    id: string;
    kill(reason?: string): void;
    // (undocumented)
    protected killed: boolean;
    // (undocumented)
    protected readonly maxTurns: number;
    // (undocumented)
    protected readonly mcpBroker?: {
        url: string;
        token: string;
    };
    // (undocumented)
    protected readonly mcpServers?: Record<string, unknown>;
    // (undocumented)
    protected readonly model: string;
    protected abstract readonly noMessagesError: string;
    // (undocumented)
    protected readonly prompt: string;
    protected pushUsageEvent(inputTokens: number, outputTokens: number, costMillicents: number): void;
    protected releaseResources(): void;
    protected resolveMcp(): ResolvedMcpConfig;
    protected resolveWorkDir(requireNonEmpty?: boolean): Promise<string | undefined>;
    // (undocumented)
    protected readonly resumeSessionId?: string;
    protected abstract runInitialQuery(prompt: string): Promise<number>;
    protected abstract readonly runtimeDisplayName: string;
    // (undocumented)
    abstract runtimeName: string;
    // (undocumented)
    runtimeSessionId: string;
    sendInput(text: string): void;
    protected setRuntimeSessionId(id: string): void;
    protected setupForResume(): Promise<void>;
    protected abstract setupSdk(): Promise<void>;
    // (undocumented)
    status: SessionStatus;
    // (undocumented)
    stream(): AsyncIterable<AgentEvent>;
    // (undocumented)
    protected readonly systemContext?: string;
    // (undocumented)
    protected readonly useWorktrees: boolean;
    // (undocumented)
    protected readonly workingDirectory?: string;
}

// @public
export interface BrokerConfig {
    token: string;
    url: string;
}

// @public
export function convertMcpServers(servers: Record<string, unknown> | undefined): Record<string, unknown>[];

// @public
export interface CreateSessionOptions {
    branch?: string;
    hooks?: Record<string, unknown>;
    id: string;
    maxTurns: number;
    mcpBroker?: {
        url: string;
        token: string;
    };
    mcpServers?: Record<string, unknown>;
    model: string;
    prompt: string;
    resumeSessionId?: string;
    systemContext?: string;
    useWorktrees?: boolean;
    workingDirectory?: string;
}

// @public
export function drainUntilStatus(nextEvent: () => Promise<AgentEvent | undefined>, statusContent: string): Promise<AgentEvent[]>;

// @public
export function ensureRuntimeInstalled(runtimeName: string, options?: RuntimeInstallOptions): Promise<string>;

// @public (undocumented)
export function ensureWorktree(basePath: string, branch: string, git?: GitExecutor, fileSystem?: WorktreeFileSystem): Promise<WorktreeResult>;

// @public
export function findGitRepoPath(basePath?: string, git?: GitRepository, locator?: WorkspaceLocator): Promise<string | undefined>;

// @public
export function getRuntimeBinDirectory(runtimeName: string): string;

// @public
export interface GitExecutor {
    exec(args: string[], options: {
        cwd: string;
        timeout?: number;
    }): Promise<{
        stdout: string;
        stderr: string;
    }>;
}

// @public
export interface GitRepository {
    checkoutBranch(repoPath: string, branch: string): Promise<void>;
    isRepo(dir: string): Promise<boolean>;
    toplevel(dir: string): Promise<string | undefined>;
}

// @public
export function importFromRuntime<T>(runtimeName: string, packageName: string): Promise<T>;

// @public
export function isDevMode(): boolean;

// @public
export const logger: Logger;

// @public
export const NODE_GIT_REPOSITORY: GitRepository;

// @public
export const NODE_WORKSPACE_LOCATOR: WorkspaceLocator;

// @public (undocumented)
export function removeWorktree(basePath: string, branch: string, git?: GitExecutor): Promise<void>;

// @public
export interface ResolvedMcpConfig {
    // (undocumented)
    disallowedTools: string[];
    // (undocumented)
    servers: Record<string, unknown> | undefined;
}

// @public
export function resolveMcpServers(spawnMcpServers?: Record<string, unknown>, brokerConfig?: BrokerConfig): ResolvedMcpConfig;

// @public
export function resolveWorkingDirectory(options: ResolveWorkingDirectoryOptions): Promise<string | undefined>;

// @public
export interface ResolveWorkingDirectoryOptions {
    branch?: string;
    eventQueue: AsyncQueue<AgentEvent>;
    requireNonEmpty?: boolean;
    useWorktrees?: boolean;
    workingDirectory?: string;
}

// @public
export interface ResumeOptions {
    // (undocumented)
    runtimeSessionId: string;
    // (undocumented)
    sessionId: string;
}

// @public
export interface RuntimeInstallOptions {
    eventCallback?: (message: string) => void;
}

// @public
export interface SpawnOptions {
    // (undocumented)
    branch?: string;
    hooks?: Record<string, unknown>;
    // (undocumented)
    maxTurns: number;
    mcpBroker?: {
        url: string;
        token: string;
    };
    mcpServers?: Record<string, unknown>;
    // (undocumented)
    model: string;
    // Warning: (ae-forgotten-export) The symbol "PipeMode" needs to be exported by the entry point index.d.ts
    pipe?: PipeMode;
    // (undocumented)
    prompt: string;
    scriptContent?: string;
    // (undocumented)
    sessionId: string;
    // (undocumented)
    systemContext?: string;
    // (undocumented)
    taskId?: string;
    // (undocumented)
    useWorktrees?: boolean;
    // (undocumented)
    workingDirectory?: string;
    // (undocumented)
    workspaceId?: string;
}

// @public
export interface WorkspaceLocator {
    exists(path: string): boolean;
    readDirectory(path: string): string[];
}

// @public
export interface WorktreeFileSystem {
    existsSync(path: string): boolean;
}

// @public (undocumented)
export interface WorktreeResult {
    // (undocumented)
    branch: string;
    // (undocumented)
    created: boolean;
    synced: boolean;
    // (undocumented)
    worktreePath: string;
}

// Warnings were encountered during analysis:
//
// src/worktree.ts:47:1 - (ae-internal-missing-underscore) The name "sanitizeBranch" should be prefixed with an underscore because the declaration is marked as @internal
// src/worktree.ts:52:1 - (ae-internal-missing-underscore) The name "worktreeDir" should be prefixed with an underscore because the declaration is marked as @internal

// (No @packageDocumentation comment for this package)

```
