import type { WorkflowDefinition, WorkflowDefinitionSnapshot, WorkflowRunManifest, WorkflowRunState, WorkflowSessionBinding, WorkflowSessionCapture, WorkflowSessionEntryRecord, WorkflowSessionEventRecord, WorkflowTraceEvent, WorkflowTraceEventDraft } from "./types.js"; export declare const RUN_BUNDLE_SCHEMA: "pi-workflows.run-bundle.v1"; export declare const RUN_STATE_SCHEMA: "pi-workflows.run-state.v1"; export declare const TRACE_EVENT_SCHEMA: "pi-workflows.trace-event.v1"; export declare const DEFINITION_SNAPSHOT_SCHEMA: "pi-workflows.definition-snapshot.v1"; export declare const SESSION_BINDING_SCHEMA: "pi-workflows.session-binding.v1"; export declare const SESSION_EVENT_SCHEMA: "pi-workflows.session-event.v1"; export declare const SESSION_CAPTURE_SCHEMA: "pi-workflows.session-capture.v1"; export declare const SESSION_EVENT_MAX_BYTES: number; /** Runs directory: `$PI_WORKFLOWS_RUNS_DIR` or `~/.pi/agent/workflows/runs`. */ export declare function workflowRunsBaseDir(homeDir?: string): string; export declare function createRunId(workflowName: string, now?: Date): string; /** * Persists run bundles (see docs/run-bundles.md). `trace.ndjson` is the * append-only source of truth; every transition appends the trace event * first, then atomically replaces `state.json` (carrying `traceSeq`) and * `manifest.json`. Large string leaves in persisted values are externalized * into content-addressed `artifacts/`. Bundles are private: directories are * 0700 and files 0600. */ export declare class WorkflowRunStore { readonly outputRoot: string; private readonly contexts; constructor(outputRoot?: string); runDirFor(runId: string): string; private contextFor; /** * Run `task` exclusively for this bundle. Sequence numbers are assigned * inside the lock, so physical file order always matches logical order. */ private withRunLock; private withSessionEventLock; initializeRunBundle(workflow: WorkflowDefinition, state: WorkflowRunState): Promise; /** * Persist one transition: append the trace event, then rewrite the * projections reflecting it. */ writeSnapshot(runDir: string, state: WorkflowRunState, event: WorkflowTraceEventDraft): Promise; /** * Bind the run to a Pi conversation: write `session/binding.json` once and * append a `session_bound` trace event. Projections catch up on the next * snapshot. */ writeSessionBinding(runDir: string, binding: WorkflowSessionBinding): Promise; /** Append one verbatim Pi session entry to `session/entries.ndjson`. */ appendSessionEntry(runDir: string, entry: Record): Promise; /** Append a fully stamped ordered batch to `session/events.ndjson`. */ appendSessionEventBatch(runDir: string, records: WorkflowSessionEventRecord[]): Promise; /** Atomically replace the temporal capture integrity projection. */ writeSessionCapture(runDir: string, capture: WorkflowSessionCapture): Promise; /** Count complete durable session records after both writers have drained. */ sessionCounts(runDir: string): Promise<{ eventCount: number; entryCount: number; lastEventSeq: number; }>; private appendTraceEvent; private writeProjections; } export type SessionCaptureIntegrity = { status: "unavailable" | "recording" | "complete" | "failed" | "invalid"; diagnostics: string[]; }; export type LoadedRunBundle = { runDir: string; manifest: WorkflowRunManifest; state: WorkflowRunState; snapshot: WorkflowDefinitionSnapshot | null; sessionBinding: WorkflowSessionBinding | null; sessionEntries: WorkflowSessionEntryRecord[]; sessionEvents: WorkflowSessionEventRecord[]; sessionCapture: WorkflowSessionCapture | null; sessionIntegrity: SessionCaptureIntegrity; }; /** Read a run bundle from disk. Returns null when the bundle is unreadable. */ export declare function readRunBundle(runDir: string): Promise; /** List run bundles under `outputRoot`, most recently started first. */ export declare function listRunBundles(outputRoot: string): Promise; export declare function createDefinitionSnapshot(workflow: WorkflowDefinition): WorkflowDefinitionSnapshot;