/** * Filesystem store for v3 Saved Workflows. * * The caller always supplies `dataDir`; this store never consults HOME/cwd and * therefore cannot accidentally mix the new library with the legacy workflow * search paths. Mutable metadata updates are locked + atomic. Revision files * are immutable, content-addressed, and installed without replacement. */ import { type LoadedSavedWorkflowRevision, type SavedWorkflowMetadata, type SavedWorkflowOwner, type SavedWorkflowRevisionDraft, type SavedWorkflowScope, type StoredSavedWorkflowRevision } from './library-schema.js'; export declare class SavedWorkflowNotFoundError extends Error { readonly workflowId: string; constructor(workflowId: string); } export declare class SavedWorkflowPermissionError extends Error { readonly workflowId: string; constructor(workflowId: string); } export declare class SavedWorkflowConflictError extends Error { constructor(message: string); } export interface CreateSavedWorkflowInput { displayName: string; aliases?: string[]; owner: SavedWorkflowOwner; scope: SavedWorkflowScope; revision: SavedWorkflowRevisionDraft; /** true => immediately runnable; false => draft-only. Defaults to true. */ publish?: boolean; /** Test/import seam. Production callers let the store mint the id. */ workflowId?: string; now?: Date; } export interface AppendSavedWorkflowRevisionInput { actor: SavedWorkflowOwner; revision: SavedWorkflowRevisionDraft; publish?: boolean; /** Optimistic concurrency guard. */ expectedLatestRevision?: string; now?: Date; } export interface SavedWorkflowWriteResult { metadata: SavedWorkflowMetadata; revision: LoadedSavedWorkflowRevision; } /** * Fully allocated deterministic library object used by crash-recoverable * host-owned publishers. Unlike `createSavedWorkflow`, this API never adopts * or removes a partial final directory: an existing target must be the exact * canonical object the caller expected. */ export interface CreateOrRecoverExactSavedWorkflowInput { expectedMetadata: SavedWorkflowMetadata; expectedRevision: StoredSavedWorkflowRevision; /** Committed-state verification sets this false so missing bytes stay fatal. */ createIfMissing?: boolean; } export interface ExactSavedWorkflowWriteResult extends SavedWorkflowWriteResult { created: boolean; } export interface ListSavedWorkflowOptions { chatId?: string; actor?: SavedWorkflowOwner; includeArchived?: boolean; /** Draft-only workflows are owner-visible by default; this can suppress them. */ includeDrafts?: boolean; } export interface SavedWorkflowListResult { entries: SavedWorkflowMetadata[]; invalid: Array<{ workflowId: string; error: string; }>; } export type SavedWorkflowResolution = { kind: 'not_found'; } | { kind: 'resolved'; metadata: SavedWorkflowMetadata; } | { kind: 'ambiguous'; matches: SavedWorkflowMetadata[]; }; export declare function workflowLibraryRoot(dataDir: string): string; export declare function savedWorkflowDir(dataDir: string, workflowId: string): string; export declare function savedWorkflowMetadataPath(dataDir: string, workflowId: string): string; export declare function savedWorkflowRevisionPath(dataDir: string, workflowId: string, revisionId: string): string; /** * Publish one deterministic Saved Workflow as an all-or-nothing directory. * The final target is never cleaned up or repaired in place. Recovery accepts * it only after exact topology, permission, and canonical-byte verification. */ export declare function createOrRecoverExactSavedWorkflow(dataDir: string, input: CreateOrRecoverExactSavedWorkflowInput): Promise; /** * Recover an exact publisher after its original single-revision directory was * legitimately advanced by ordinary owner mutations. The immutable origin * revision must still have the exact canonical bytes and private topology that * were approved; current metadata and later revisions are read under the same * workflow mutation lock and must themselves remain canonical private files. */ export declare function verifyExactSavedWorkflowOrigin(dataDir: string, input: CreateOrRecoverExactSavedWorkflowInput): Promise; export declare function createSavedWorkflow(dataDir: string, input: CreateSavedWorkflowInput): Promise; export declare function readSavedWorkflowMetadata(dataDir: string, workflowId: string): Promise; export declare function readSavedWorkflowRevision(dataDir: string, workflowId: string, revisionId: string): Promise; export declare function loadCurrentSavedWorkflow(dataDir: string, workflowId: string, opts?: { revision?: 'latest' | 'published'; requireActive?: boolean; }): Promise<{ metadata: SavedWorkflowMetadata; revision: LoadedSavedWorkflowRevision; }>; export declare function appendSavedWorkflowRevision(dataDir: string, workflowId: string, input: AppendSavedWorkflowRevisionInput): Promise; /** Publish an already-saved latest draft without creating a new revision. */ export declare function publishLatestSavedWorkflow(dataDir: string, workflowId: string, input: { actor: SavedWorkflowOwner; expectedLatestRevision?: string; now?: Date; }): Promise; export declare function archiveSavedWorkflow(dataDir: string, workflowId: string, input: { actor: SavedWorkflowOwner; now?: Date; }): Promise; export declare function listSavedWorkflows(dataDir: string, opts?: ListSavedWorkflowOptions): Promise; export declare function resolveSavedWorkflowRef(dataDir: string, ref: string, opts?: ListSavedWorkflowOptions): Promise; //# sourceMappingURL=library-store.d.ts.map