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

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

```ts

import { ChildProcess } from 'node:child_process';
import type { Client } from '@connectrpc/connect';
import type { GenFile } from '@bufbuild/protobuf/codegenv2';
import type { GenMessage } from '@bufbuild/protobuf/codegenv2';
import type { GenService } from '@bufbuild/protobuf/codegenv2';
import type { Message } from '@bufbuild/protobuf';
import { SpawnOptions } from 'node:child_process';

// @public
export interface AdapterDependencies {
    exec?: ExecFunction;
    isGitHubProviderEnabled?: () => boolean;
    logger?: AdapterLogger;
    resolveGitHubToken?: (accountId?: string) => string | undefined;
    sleep?: (ms: number) => Promise<void>;
}

// @public
export interface AdapterLogger {
    // (undocumented)
    debug(obj: object, msg: string): void;
    // (undocumented)
    error(obj: object, msg: string): void;
    // (undocumented)
    info(obj: object, msg: string): void;
    // (undocumented)
    warn(obj: object, msg: string): void;
}

// @public
type AgentEvent = Message<"grackle.powerline.AgentEvent"> & {
    sessionId: string;
    type: string;
    timestamp: string;
    content: string;
    raw: string;
};

// @public
const AgentEventSchema: GenMessage<AgentEvent>;

// @public
export interface BaseEnvironmentConfig {
    host?: string;
    port?: number;
}

// @public
export interface BootstrapOptions {
    defaultRuntime?: string;
    extraEnv?: Record<string, string>;
    host?: string;
    isGitHubProviderEnabled?: () => boolean;
    logger?: AdapterLogger;
    workingDirectory?: string;
}

// @public
export function bootstrapPowerLine(executor: RemoteExecutor, powerlineToken: string, options?: BootstrapOptions): AsyncGenerator<ProvisionEvent>;

// @public
export function buildEnvFileContent(powerlineToken: string, extraEnv?: Record<string, string>, logger?: AdapterLogger): string;

// @public
export function buildRemoteKillCommand(): string;

// @public
export function closeAllTunnels(logger?: AdapterLogger): Promise<void>;

// @public
export function closeTunnel(environmentId: string): Promise<void>;

// @public
export function connectThroughTunnel(environmentId: string, localPort: number, powerlineToken: string, logger?: AdapterLogger, traceId?: string): Promise<PowerLineConnection>;

// @public
export function createPowerLineClient(baseUrl: string, powerlineToken: string, traceId?: string): PowerLineClient;

// @public
export const defaultLogger: AdapterLogger;

// @public
type DrainRequest = Message<"grackle.powerline.DrainRequest"> & {
    sessionId: string;
};

// @public
const DrainRequestSchema: GenMessage<DrainRequest>;

// @public
type Empty = Message<"grackle.powerline.Empty"> & {};

// @public
const EmptySchema: GenMessage<Empty>;

// @public
export interface EnvironmentAdapter {
    connect(environmentId: string, config: Record<string, unknown>, powerlineToken: string): Promise<PowerLineConnection>;
    destroy(environmentId: string, config: Record<string, unknown>): Promise<void>;
    disconnect(environmentId: string): Promise<void>;
    healthCheck(connection: PowerLineConnection): Promise<boolean>;
    provision(environmentId: string, config: Record<string, unknown>, powerlineToken: string): AsyncGenerator<ProvisionEvent>;
    reconnect?(environmentId: string, config: Record<string, unknown>, powerlineToken: string): AsyncGenerator<ProvisionEvent>;
    stop(environmentId: string, config: Record<string, unknown>): Promise<void>;
    // (undocumented)
    type: string;
}

// @public
type EnvironmentInfo = Message<"grackle.powerline.EnvironmentInfo"> & {
    hostname: string;
    os: string;
    nodeVersion: string;
    availableRuntimes: string[];
    uptimeSeconds: bigint;
};

// @public
const EnvironmentInfoSchema: GenMessage<EnvironmentInfo>;

// @public
export function exec(cmd: string, args: string[], opts?: {
    timeout?: number;
    cwd?: string;
    env?: NodeJS.ProcessEnv;
}): Promise<ExecResult>;

// @public
export type ExecFunction = (cmd: string, args: string[], opts?: {
    timeout?: number;
    cwd?: string;
    env?: NodeJS.ProcessEnv;
}) => Promise<ExecResult>;

// @public
export interface ExecResult {
    // (undocumented)
    stderr: string;
    // (undocumented)
    stdout: string;
}

// @public
export class FatalAdapterError extends Error {
    constructor(message: string);
}

// @public
const file_grackle_powerline_powerline: GenFile;

// @public
export function findFreePort(): Promise<number>;

// @public
export function getPackageVersion(): string;

// @public
export function getTunnel(environmentId: string): TunnelState | undefined;

// @public
const GracklePowerLine: GenService<{
    getInfo: {
        methodKind: "unary";
        input: typeof EmptySchema;
        output: typeof EnvironmentInfoSchema;
    };
    spawn: {
        methodKind: "server_streaming";
        input: typeof SpawnRequestSchema;
        output: typeof AgentEventSchema;
    };
    resume: {
        methodKind: "server_streaming";
        input: typeof ResumeRequestSchema;
        output: typeof AgentEventSchema;
    };
    sendInput: {
        methodKind: "unary";
        input: typeof InputMessageSchema;
        output: typeof EmptySchema;
    };
    kill: {
        methodKind: "unary";
        input: typeof KillRequestSchema;
        output: typeof EmptySchema;
    };
    listSessions: {
        methodKind: "unary";
        input: typeof EmptySchema;
        output: typeof SessionListSchema;
    };
    ping: {
        methodKind: "unary";
        input: typeof EmptySchema;
        output: typeof PongSchema;
    };
    pushTokens: {
        methodKind: "unary";
        input: typeof TokenBundleSchema;
        output: typeof EmptySchema;
    };
    cleanupWorktree: {
        methodKind: "unary";
        input: typeof WorktreeCleanupRequestSchema;
        output: typeof EmptySchema;
    };
    drainBufferedEvents: {
        methodKind: "server_streaming";
        input: typeof DrainRequestSchema;
        output: typeof AgentEventSchema;
    };
}>;

// @public
type InputMessage = Message<"grackle.powerline.InputMessage"> & {
    sessionId: string;
    text: string;
};

// @public
const InputMessageSchema: GenMessage<InputMessage>;

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

// @public
type KillRequest = Message<"grackle.powerline.KillRequest"> & {
    id: string;
    reason: string;
};

// @public
const KillRequestSchema: GenMessage<KillRequest>;

// @public
type Pong = Message<"grackle.powerline.Pong"> & {
    timestamp: bigint;
};

// @public
const PongSchema: GenMessage<Pong>;

// @public
export interface PortProber {
    probe(port: number, host?: string): Promise<boolean>;
}

declare namespace powerline {
    export {
        file_grackle_powerline_powerline,
        Empty,
        EmptySchema,
        SessionId,
        SessionIdSchema,
        KillRequest,
        KillRequestSchema,
        EnvironmentInfo,
        EnvironmentInfoSchema,
        Pong,
        PongSchema,
        SpawnRequest,
        SpawnRequestSchema,
        ResumeRequest,
        ResumeRequestSchema,
        InputMessage,
        InputMessageSchema,
        AgentEvent,
        AgentEventSchema,
        SessionInfo,
        SessionInfoSchema,
        SessionList,
        SessionListSchema,
        TokenItem,
        TokenItemSchema,
        TokenBundle,
        TokenBundleSchema,
        WorktreeCleanupRequest,
        WorktreeCleanupRequestSchema,
        DrainRequest,
        DrainRequestSchema,
        GracklePowerLine
    }
}

// @public
export type PowerLineClient = Client<typeof powerline.GracklePowerLine>;

// @public
export interface PowerLineConnection {
    // (undocumented)
    client: PowerLineClient;
    // (undocumented)
    environmentId: string;
    // (undocumented)
    port: number;
}

// @public
export function probeRemotePowerLine(executor: RemoteExecutor): Promise<void>;

// @public
export abstract class ProcessTunnel implements RemoteTunnel {
    constructor(localPort: number, logger?: AdapterLogger, processFactory?: TunnelProcessFactory, portProbe?: TunnelPortProbe);
    close(): Promise<void>;
    isAlive(): boolean;
    // (undocumented)
    localPort: number;
    // (undocumented)
    protected logger: AdapterLogger;
    open(): Promise<void>;
    // (undocumented)
    protected readonly portProbe: TunnelPortProbe;
    // (undocumented)
    protected process: ChildProcess | undefined;
    // (undocumented)
    protected readonly processFactory: TunnelProcessFactory;
    protected abstract spawnArgs(): {
        command: string;
        args: string[];
    };
    protected spawnEnv: NodeJS.ProcessEnv | undefined;
    protected waitForReady(): Promise<void>;
}

// @public
export interface ProvisionEvent {
    // (undocumented)
    message: string;
    // (undocumented)
    progress: number;
    // (undocumented)
    stage: string;
}

// @public
export function reconnectOrProvision(environmentId: string, adapter: EnvironmentAdapter, config: Record<string, unknown>, powerlineToken: string, bootstrapped: boolean, force?: boolean, logger?: AdapterLogger): AsyncGenerator<ProvisionEvent>;

// @public
export function registerTunnel(environmentId: string, state: TunnelState, logger?: AdapterLogger): void;

// @public
export const REMOTE_EXEC_DEFAULT_TIMEOUT_MS: number;

// @public
export const REMOTE_POWERLINE_DIRECTORY: string;

// @public
export function remoteDestroy(environmentId: string, executor: RemoteExecutor, logger?: AdapterLogger): Promise<void>;

// @public
export interface RemoteExecutor {
    copyTo(localPath: string, remotePath: string): Promise<void>;
    exec(command: string, opts?: {
        timeout?: number;
    }): Promise<string>;
}

// @public
export function remoteHealthCheck(connection: PowerLineConnection): Promise<boolean>;

// @public
export function remoteStop(environmentId: string, executor: RemoteExecutor, logger?: AdapterLogger): Promise<void>;

// @public
export interface RemoteTunnel {
    close(): Promise<void>;
    isAlive(): boolean;
    localPort: number;
    open(): Promise<void>;
}

// @public
type ResumeRequest = Message<"grackle.powerline.ResumeRequest"> & {
    sessionId: string;
    runtimeSessionId: string;
    runtime: string;
};

// @public
const ResumeRequestSchema: GenMessage<ResumeRequest>;

// @public
type SessionId = Message<"grackle.powerline.SessionId"> & {
    id: string;
};

// @public
const SessionIdSchema: GenMessage<SessionId>;

// @public
type SessionInfo = Message<"grackle.powerline.SessionInfo"> & {
    sessionId: string;
    runtime: string;
    status: string;
};

// @public
const SessionInfoSchema: GenMessage<SessionInfo>;

// @public
type SessionList = Message<"grackle.powerline.SessionList"> & {
    sessions: SessionInfo[];
};

// @public
const SessionListSchema: GenMessage<SessionList>;

// @public
export function shellEscape(value: string): string;

// @public
export function sleep(ms: number): Promise<void>;

// @public
type SpawnRequest = Message<"grackle.powerline.SpawnRequest"> & {
    sessionId: string;
    runtime: string;
    prompt: string;
    model: string;
    maxTurns: number;
    branch: string;
    workingDirectory: string;
    systemContext: string;
    workspaceId?: string;
    taskId: string;
    mcpServersJson: string;
    mcpUrl: string;
    mcpToken: string;
    scriptContent: string;
    useWorktrees?: boolean;
    pipe: string;
};

// @public
const SpawnRequestSchema: GenMessage<SpawnRequest>;

// @public
export const SSH_CONNECTIVITY_TIMEOUT_MS: number;

// @public
export function startRemotePowerLine(executor: RemoteExecutor, powerlineToken: string, options?: StartRemotePowerLineOptions): Promise<{
    alreadyRunning: boolean;
}>;

// @public
export interface StartRemotePowerLineOptions {
    autoDetectWorkspace?: boolean;
    extraEnv?: Record<string, string>;
    host?: string;
    logger?: AdapterLogger;
    probeFirst?: boolean;
    workingDirectory?: string;
}

// @public
export const TCP_PORT_PROBER: PortProber;

// @public
type TokenBundle = Message<"grackle.powerline.TokenBundle"> & {
    tokens: TokenItem[];
};

// @public
const TokenBundleSchema: GenMessage<TokenBundle>;

// @public
type TokenItem = Message<"grackle.powerline.TokenItem"> & {
    name: string;
    type: string;
    envVar: string;
    filePath: string;
    value: string;
};

// @public
const TokenItemSchema: GenMessage<TokenItem>;

// @public
export interface TunnelPortProbe {
    waitForPort(port: number): Promise<void>;
}

// @public
export interface TunnelProcessFactory {
    spawn(command: string, args: string[], options: SpawnOptions): ChildProcess;
}

// @public
export interface TunnelState {
    reverseTunnel?: RemoteTunnel;
    // (undocumented)
    tunnel: RemoteTunnel;
}

// @public
export function waitForLocalPort(port: number, options?: WaitForLocalPortOptions): Promise<void>;

// @public
export interface WaitForLocalPortOptions {
    portProber?: PortProber;
    sleep?: (ms: number) => Promise<void>;
}

// @public
type WorktreeCleanupRequest = Message<"grackle.powerline.WorktreeCleanupRequest"> & {
    branch: string;
    workingDirectory: string;
};

// @public
const WorktreeCleanupRequestSchema: GenMessage<WorktreeCleanupRequest>;

// @public
export function writeRemoteEnvFile(executor: RemoteExecutor, powerlineToken: string, extraEnv?: Record<string, string>, logger?: AdapterLogger): Promise<void>;

// (No @packageDocumentation comment for this package)

```
