import { type AwaitingCheckpoint, type EffectiveSystemPrompt, type PersistedRun } from "./persistence.js"; import type { AgentAttemptSummary, JsonValue, LaunchSnapshot } from "./types.js"; import { type SubagentProgress, type SubagentRunRequest, type SubagentStatus } from "../subagents/src/contracts.js"; import type { TrajectoryAction, TrajectoryTarget } from "./trajectory-contracts.js"; export type TrajectoryRun = { run: PersistedRun; snapshot: Readonly; awaiting: readonly AwaitingCheckpoint[]; createdAt?: string; transcripts: Readonly>; }; export type TrajectorySubagentArtifact = { readonly truncated: true; readonly path: string; readonly bytes: number; }; export type TrajectorySubagent = { id: string; sessionId: string; cwd: string; label?: string; role?: string; mode: "background" | "foreground"; state: SubagentStatus["state"]; startedAt?: number; finishedAt?: number; attempts?: number; error?: { readonly code: string; readonly message: string; }; worktree?: { readonly path: string; readonly branch: string; }; request: Readonly; tools: readonly string[]; toolDefinitions?: readonly { readonly name: string; readonly description: string; }[]; model?: AgentAttemptSummary["setup"]["model"]; progress?: SubagentProgress; attempt?: AgentAttemptSummary; result?: JsonValue | TrajectorySubagentArtifact; failure?: { readonly code: string; readonly message: string; } | TrajectorySubagentArtifact; transcript: readonly unknown[]; }; export type TrajectorySubagentLoader = () => Promise; export type { TrajectoryAction, TrajectoryTarget } from "./trajectory-contracts.js"; export { isTrajectoryAction, isTrajectoryTarget, trajectoryActionError } from "./trajectory-contracts.js"; export type TrajectoryActionRequest = { action: TrajectoryAction; target: TrajectoryTarget; name?: string; payload?: unknown; }; export type TrajectoryActionResult = { readonly id: string; readonly state: "running"; }; export type TrajectoryActionHandler = (request: Readonly) => Promise | Promise; export type TrajectoryRunLoader = () => Promise; export type TrajectoryPublisherInput = { cwd: string; sessionId: string; port?: number; themes: boolean; loadRuns: TrajectoryRunLoader; loadSubagents: TrajectorySubagentLoader; handleAction: TrajectoryActionHandler; }; export declare function applySystemPrompts(run: PersistedRun, prompts: readonly EffectiveSystemPrompt[]): PersistedRun; export declare function applyToolDescriptions(run: PersistedRun, catalog: ReadonlyMap): PersistedRun; export declare function withPiToolDescriptions(run: PersistedRun): PersistedRun; export declare function withPiToolDescriptionsForTools(tools: readonly string[], cwd: string): readonly { readonly name: string; readonly description: string; }[]; export declare function withResolvedAttemptResources(attempt: AgentAttemptSummary, cwd: string): Promise; export declare function withResolvedResources(run: PersistedRun, cwd: string): Promise; export declare function loadTrajectoryRuns(cwd: string, sessionId: string, home?: string, overlay?: (run: PersistedRun) => PersistedRun): Promise; export declare function createTrajectoryRunLoader(cwd: string, sessionId: string, home?: string, overlay?: (run: PersistedRun) => PersistedRun): TrajectoryRunLoader; export declare function createTrajectorySubagentLoader(cwd: string, sessionId: string, agentDir: string, overlay?: (subagent: TrajectorySubagent) => TrajectorySubagent): TrajectorySubagentLoader;