import type { RunnerScope, RuntimeConfig } from "../../poe-code-config/dist/index.js"; import type { RunHandle, Runner, RunSpec } from "../../process-runner/dist/index.js"; import type { StateManager } from "../../poe-code-config/dist/index.js"; export type { RuntimeConfig } from "../../poe-code-config/dist/index.js"; export type { RunHandle, RunSpec } from "../../process-runner/dist/index.js"; export type ExecutionEnvType = "host" | "docker"; export type JobStatus = "running" | "exited" | "killed" | "lost"; export interface ExecutionEnvFactory { readonly type: ExecutionEnvType; readonly supportsDetach?: boolean; /** Whether uploadWorkspace/downloadWorkspace move real files, i.e. whether runner.sync means anything. */ readonly supportsWorkspaceTransfer?: boolean; open(spec: OpenSpec): Promise; attach(envId: string, context?: AttachedJobContext): Promise; } export interface OpenSpec { cwd: string; runtimeCwd?: string; runtime: RuntimeConfig; runner?: RunnerScope; state?: StateManager; hostRunner?: Runner; env: Record; uploadIgnoreFiles: string[]; jobLabel: { tool: string; argv: string[]; displayArgv?: string[]; }; execution?: { wrapForLogTee?: boolean; stdin?: RunSpec["stdin"]; stdout?: RunSpec["stdout"]; stderr?: RunSpec["stderr"]; env?: RunSpec["env"]; tty?: boolean; input?: string | Buffer; captureOutput?: boolean; activityTimeoutMs?: number; activityTimeoutSource?: "all" | "stdout"; onStdout?(chunk: string): void; onStderr?(chunk: string): void; }; shellSpec?: RunSpec; } export interface UploadResult { files: number; bytes: number; skipped: { path: string; bytes: number; reason: "max_size"; }[]; } export interface DownloadResult { files: number; bytes: number; conflicts: { path: string; reason: "local_modified"; }[]; } export interface LogChunk { byteOffset: number; data: string; } export interface AttachedJobContext { jobId: string; tool: string; argv: string[]; cwd: string; reattachContext?: Record; } export interface OpenedEnv { readonly id: string; readonly job: JobHandle | null; readonly reattachContext?: Record; uploadWorkspace(): Promise; downloadWorkspace(opts: { conflictPolicy: "refuse" | "overwrite"; }): Promise; exec(spec: RunSpec): RunHandle; detach(): Promise; shell(): RunHandle; close(): Promise; } export interface JobHandle { readonly id: string; readonly envId: string; readonly tool: string; readonly argv: string[]; status(): Promise; stream(opts?: { sinceByte?: number; since?: Date; follow?: boolean; }): AsyncIterable; wait(): Promise<{ exitCode: number; }>; kill(signal?: NodeJS.Signals): Promise; } export declare function registerExecutionEnvFactory(factory: ExecutionEnvFactory): void; export declare function selectExecutionEnv(runtime: RuntimeConfig): ExecutionEnvFactory; export declare function selectExecutionEnvFactory(type: ExecutionEnvType): ExecutionEnvFactory;