/** * WorkerLite — v3 worker backed by the embedded Rust engine. * * No gRPC. No server. No broker. Just start and run workflows locally. * SQLite is the durable source of truth for workflows, checkpoints, timers, and signals. */ import { NativeEngine, type SqliteBackupArtifactJs, type SqliteRestoreReportJs } from '@memoflowio/memoflow-engine'; import { ClientLite } from '../client/client-lite.js'; import type { ImplicitStepsConfig } from './http-effect.js'; export interface WorkerLiteOptions { /** Explicit root directory containing `engine.sqlite3`. */ dataDir: string; /** Task queue name (used for filtering, default: "default") */ taskQueue?: string; /** Required durability profile: strict (`FULL`) or relaxed (`NORMAL`). */ durabilityProfile: 'strict' | 'relaxed'; /** Authorize changing the profile persisted in an existing SQLite database during this open. */ allowProfileChange?: boolean; /** Maximum workflow bodies executing concurrently. Additional durable runs wait FIFO. Default: 100. */ maxConcurrentWorkflows?: number; /** * Implicit HTTP steps (P6.1): a bare `await fetch(...)` inside a workflow * body is a durable step by default. Pass `{ enabled: false }` to opt out * (fetch becomes byte-identical pass-through), or override identity mode, * body cap, LLM endpoints, etc. See `ImplicitStepsConfig`. */ implicitSteps?: Partial; } export interface EmbeddedCapabilities { mode: 'embedded'; backend: 'sqlite'; workflowExecution: true; signals: true; queries: true; cancellation: true; restartRecovery: true; boundedConcurrency: true; payloadCodecs: true; backupRestore: true; fork: false; outputStreaming: false; transactionalPostgresStep: false; } export declare class WorkerLite { private engine; private taskQueue; private active; private resultWaiters; private running; private closed; private maxConcurrentWorkflows; private _client; private implicitSteps?; constructor(options: WorkerLiteOptions); /** * Start the worker. Unlike v1, this is instant — no gRPC connection to establish. */ run(): Promise; /** * Get the underlying NativeEngine instance (for use with extensions like @memoflowio/memoflow-dashboard). */ nativeEngine(): NativeEngine; /** Publish a verified online SQLite backup; the manifest is made visible last. */ backup(databaseOutput: string, manifestOutput: string): Promise; /** Restore a verified backup into an offline directory before constructing a worker. */ static restoreBackup(backupDatabase: string, backupManifest: string, targetDataDir: string): Promise; /** Machine-readable feature contract; unsupported features never silently degrade. */ capabilities(): Readonly; /** * Get an in-process client for starting/signaling workflows. */ client(): ClientLite; /** @internal Validate an embedded start before creating its durable SQLite row. */ validateStart(workflowType: string, taskQueue: string): void; /** * Execute a workflow. Called by the client when starting a new workflow. * Returns immediately — the workflow runs asynchronously. */ executeWorkflow(workflowId: string, runId: string, workflowType: string, input: any): Promise; private startWorkflowExecution; private drainPending; cancelWorkflow(workflowId: string, reason?: string): Promise; /** * Deliver a signal to a running workflow. */ deliverSignal(workflowId: string, signalName: string, payload: any): void; /** * Execute a query on a running workflow. */ executeQuery(workflowId: string, queryName: string): any; /** * Wait for a workflow to complete and return its result. */ awaitResult(workflowId: string, timeoutMs?: number): Promise; private settleResultWaiters; /** * Shutdown the worker. */ shutdown(): void; }