import type { ChildProcess } from "node:child_process"; import type { AdapterExecutionContext } from "@tickernelz/paperclip-pro-adapter-utils"; import type { AcpRuntime, AcpRuntimeHandle } from "acpx/runtime"; import type { AcpRunContext, HostReuseCandidate, PlacedWorkspace, ReadyRunResources, RunSiteTransport, SessionReuseStore, SitePlan } from "./run-contracts.js"; /** The agent child's identity, as the runtime reports it on each spawn. */ export type AcpxAgentProcessIdentity = { pid: number; startedAt: string; }; /** * The mutable spawn-callback target and the last spawn identity a warm runtime * carries across runs. A warm handle can outlive the run that created it, so the * `current` callback stays mutable: a later heartbeat repoints it to its own * `onSpawn`, and `latest` lets that heartbeat re-announce the running agent. */ export type AcpxProcessIdentitySink = { current: AdapterExecutionContext["onSpawn"]; latest: AcpxAgentProcessIdentity | null; localProcess?: ChildProcess; }; /** The live-line buffer and log path a warm runtime's child stderr carries. */ export interface ChildStderrState { logPath: string | null; pendingLiveLine: string; } /** * One warm host runtime the store keeps for the next compatible resume. It is * the value the host warm-handle map holds. The entry carries its own last-used * time and its own optional idle timer, which the store reads and writes. */ export interface RuntimeCacheEntry { runtime: AcpRuntime; handle: AcpRuntimeHandle; childStderrState: ChildStderrState; processIdentitySink: AcpxProcessIdentitySink; fingerprint: string; lastUsedAt: number; cleanupTimer?: ReturnType; } /** Construction options for the host site. */ export interface HostRunSiteOptions { /** * The warm-handle map the store operates over. The engine owns it and reuses * it across runs, so a saved runtime stays warm for the next resume. */ readonly warmHandles: Map; readonly now: () => number; /** The warm-idle bound, in milliseconds. `0` or less disables the store. */ readonly idleMs: number; /** * Close a warm runtime and flush its child stderr. The store fires it when the * per-entry timer expires, when the run-start sweep evicts an idle entry, and * on an explicit discard. The engine injects it, because the close reason and * the stderr flush live in the engine module. */ readonly closeWarmEntry: (entry: RuntimeCacheEntry) => Promise; } /** * The host run site. Its store keeps warm runtimes; every other operation is the * null path the host lane always ran. */ export interface HostRunSite { readonly kind: "host"; plan(context: AcpRunContext): SitePlan; placeWorkspace(context: AcpRunContext): Promise; startTransport(context: AcpRunContext): Promise; reuse(): SessionReuseStore; reuseCandidate(resources: ReadyRunResources): HostReuseCandidate; syncBack(context: AcpRunContext): Promise; } /** Create the host run site over the engine's warm-handle map. */ export declare function createHostRunSite(options: HostRunSiteOptions): HostRunSite; //# sourceMappingURL=run-site-host.d.ts.map