/** * Per-agent runtime state for mutable built-in tool behavior. * * Cortex clones runtime-aware built-in tools into a fresh runtime for each * agent so parent and child agents do not share mutable closures. */ import type * as child_process from 'node:child_process'; import { CwdTracker } from './shared/cwd-tracker.js'; import { EditHistory } from './shared/edit-history.js'; import { FileMutationLock } from './shared/file-mutation-lock.js'; import { ReadRegistry } from './shared/read-registry.js'; import { WebFetchCache } from './web-fetch/cache.js'; export interface BackgroundTask { id: string; /** The command that was executed (for status display). */ command: string; process: child_process.ChildProcess; stdout: string; stderr: string; exitCode: number | null; completed: boolean; /** * Whether the agent has already been informed of this task's terminal state: * delivered via a completion wake-up, observed through a TaskOutput poll that * returned completed/failed, or deliberately killed. Guards against delivering * the same completion twice. */ notified: boolean; startTime: number; } export declare class BackgroundTaskStore { private readonly tasks; private taskIdCounter; nextTaskId(): string; set(task: BackgroundTask): void; get(taskId: string): BackgroundTask | undefined; getAll(): Map; cleanupCompletedTasks(maxAgeMs?: number): void; clear(): void; } export declare const globalBackgroundTaskStore: BackgroundTaskStore; export declare class WebFetchRuntimeState { private readonly cache; private fetchesThisLoop; getCache(): WebFetchCache; get fetchCount(): number; incrementFetchCount(): void; resetLoop(): void; destroy(): void; } export declare class CortexToolRuntime { readonly cwdTracker: CwdTracker; readonly readRegistry: ReadRegistry; readonly fileMutationLock: FileMutationLock; readonly editHistory: EditHistory; readonly backgroundTasks: BackgroundTaskStore; readonly webFetch: WebFetchRuntimeState; constructor(workingDirectory: string); resetForLoop(): void; destroy(): void; } export interface RuntimeAwareToolMetadata { readonly toolKind: string; cloneForRuntime: (runtime: CortexToolRuntime) => TTool; } export declare function attachRuntimeAwareTool(tool: TTool, metadata: RuntimeAwareToolMetadata): TTool; export declare function getRuntimeAwareToolMetadata(tool: TTool): RuntimeAwareToolMetadata | undefined; export declare function cloneRuntimeAwareTool(tool: TTool, runtime: CortexToolRuntime): TTool | null; //# sourceMappingURL=runtime.d.ts.map