import { type FreestyleOptions, type Vm } from "freestyle"; import type { CloneOptions, DiffResult, EnvMapping, PiRunOptions, PiRunResult, VmHandle } from "./types"; export declare class FreestyleClient { private readonly sdk; private readonly activeVMs; private cachedSnapshotId?; constructor(options?: FreestyleOptions); /** * Execute a command in the VM and throw VmExecError on non-zero exit. * By default the wrapper script is prepended so env vars are available. * Use `raw: true` for bootstrap commands that run before the wrapper exists. */ private vmExec; /** * Execute a command in the VM via the wrapper WITHOUT throwing on non-zero exit. * Use for probes where failure is an expected branch (e.g. "is this a git repo?"). */ private vmExecGraceful; /** * Wrap a command string in bash -c for compound commands with shell builtins. * Used when commands contain shell operators (&&, ||, ;, |) or builtins (cd). */ private wrapInBash; /** * Ensure a snapshot with pi + node pre-installed exists. * If an explicit snapshotId is provided, return it unchanged. * Otherwise, look for an existing snapshot by name. If none is found, * create one via Dockerfile. The resolved ID is cached in-memory so * subsequent calls are free. */ ensureSnapshot(snapshotId?: string): Promise; /** Fetch the full list of snapshots from the API. */ private listSnapshots; /** Look up a snapshot by name via the Freestyle REST API. */ private findSnapshotByName; /** Check whether a snapshot with the given ID exists via the Freestyle REST API. */ private findSnapshotById; /** * Create an ephemeral VM from a snapshot. * The VM is tracked internally and will be cleaned up on destroyVM() or cleanupAll(). * Auto-deletes after idle timeout even if cleanup fails. */ createVM(snapshotId: string): Promise; /** * Destroy a VM by ID. Best-effort — ephemeral VMs auto-delete on idle timeout. * Removes the VM from the tracked set. */ destroyVM(vmId: string): Promise; /** * List all VMs from the Freestyle API. */ listVMs(): Promise<{ vms: { id: string; state: string; }[]; }>; /** * List only VMs that were created by this client instance (tracked in-memory). * Fetches current state from the API but filters to tracked VM IDs only. */ listTrackedVMs(): Promise<{ vms: { id: string; state: string; createdAt?: string | null; }[]; }>; /** * Destroy all VMs tracked by this client instance. */ cleanupAll(): Promise; /** IDs of VMs currently tracked by this client. */ get trackedVmIds(): string[]; /** * Write the env-wrapper script into the VM and make it executable. * Must be called before any other business-logic command so that * ${WRAPPER_PATH} is available for all subsequent exec calls. */ syncEnvironment(vm: Vm, env: EnvMapping): Promise; /** * Copy the host's pi auth.json and models.json into the VM so pi inside * can authenticate with the same providers the parent session uses. * Throws if auth.json is missing (required for the subagent to work). */ syncPiAuth(vm: Vm): Promise; /** * Authenticate the gh CLI inside the VM using the provided token. * Also configures gh as git credential helper for seamless private repo access. */ setupGhAuth(vm: Vm, token: string): Promise; /** * Clone a git repo into a VM. * If `options.gitToken` is set and the URL is a GitHub HTTPS URL, * the token is embedded for private repo access. * Returns a typed result — check `.ok` to determine success. */ cloneRepo(vm: Vm, options: CloneOptions): Promise<{ ok: true; } | { ok: false; exitCode: number | null; stderr: string; }>; /** * Run `pi --mode json` inside a VM and parse the JSONL output. * Blocking — returns only after pi finishes inside the VM. * Supports cancellation via AbortSignal. * * Note: pi may exit non-zero (e.g. syntax error in task). We capture * the raw result and let the caller interpret it via parseJsonlOutput. */ runPi(vm: Vm, options: PiRunOptions): Promise; /** * Capture git diff from a VM workspace. * Returns null if the workspace is clean (no changes) or not a git repository. * Supports cancellation via AbortSignal. */ captureDiff(vm: Vm, cwd: string, signal?: AbortSignal): Promise; } //# sourceMappingURL=client.d.ts.map