/** * In-process client that wraps an {@link Engine} instance directly. * Use this when running Weft as an embedded library — no network hop. * * Implements the same {@link WeftClient} interface as {@link HttpClient}, * so switching from library mode to server mode is a constructor change. * * @module client/local */ import { type ClientOperationName, type ClientOperationTypes, type ClientOperations } from '../cli/generated/operation-client.generated.ts'; import type { Engine } from '../core/engine.ts'; import type { AttributeFilterKey, BulkCancelResult, BulkDeleteResult, BulkRetryFailedResult, BulkSignalResult, BulkTagResult, CoordinatedUpdateResult, DefaultActivityTypes, DefaultWorkflowRegistry, ForkOptions, ListFilter, PaginatedResult, PurgeResult, QueryDefinition, RetentionOverview, ReviewListEntry, ReviewListFilter, ScheduleFilter, ScheduleOptions, ScheduleSpec, ScheduleSummary, ScheduleUpdateOptions, SearchAttributeValue, SignalDefinition, SignalDeliveryOptions, StartOptions, StartOrSignalOptions, StartOrSignalSignal, SubmitReviewOptions, TypedListFilter, UpdateDefinition, WorkflowEvent, WorkflowInput, WorkflowOutput, WorkflowRegistry, WorkflowReplay, WorkflowState, WorkflowSummary, WorkflowTimelineEntry } from '../core/types.ts'; import { type WeftClientStorage } from './client-storage.ts'; import type { WorkflowEventTail } from './event-tail.ts'; import type { ClientHandle, ClientScheduleHandle, UpdateResult, WeftClient, WeftClientActivity } from './interface.ts'; import type { KnownWorkflowName, UnknownNameWhenRegistryEmpty } from './workflow-name-typing.ts'; /** * In-process Weft client backed by a local {@link Engine}. * * @example * ```ts * import { workflow, Engine, MemoryStorage, LocalClient, type WorkflowContext } from '@lostgradient/weft'; * * await using engine = new Engine({ storage: new MemoryStorage() }); * engine.register( * workflow({ name: 'greet' }).execute(async function* (ctx: WorkflowContext, input: { name: string }) { * return `Hello, ${input.name}!`; * }), * ); * * const client = new LocalClient(engine); * const handle = await client.start('greet', { name: 'World' }); * console.log(await handle.result()); // 'Hello, World!' * ``` */ export declare class LocalClient implements WeftClient { #private; /** Typed low-level accessor for every client-callable operation, routed in-process. */ readonly operations: ClientOperations; /** Raw storage administration against the engine-owned backend. */ readonly storage: WeftClientStorage; /** * Out-of-band ("async") activity completion. An activity that called * `ActivityContext.completeAsync()` parks its workflow until an external * system resolves it by task token through these methods. * * @example * ```ts * import { Engine, LocalClient } from '@lostgradient/weft'; * * const engine = new Engine(); * const client = new LocalClient(engine); * // `token` came from the engine's `activity:async-pending` event. * // await client.activity.complete(token, { ok: true }); * void client; * ``` */ readonly activity: WeftClientActivity; constructor(engine: Engine | Engine); call(name: Name, input: ClientOperationTypes[Name]['input']): Promise; start(type: TName, input: WorkflowInput, options?: StartOptions): Promise>>; start(type: UnknownNameWhenRegistryEmpty, input: unknown, options?: StartOptions): Promise; startOrSignal(type: TName, input: WorkflowInput, signal: StartOrSignalSignal, options?: StartOrSignalOptions): Promise>>; startOrSignal(type: UnknownNameWhenRegistryEmpty, input: unknown, signal: StartOrSignalSignal, options?: StartOrSignalOptions): Promise; schedule(type: TName, input: WorkflowInput, spec: string | ScheduleSpec, options?: ScheduleOptions): Promise; schedule(type: UnknownNameWhenRegistryEmpty, input: unknown, spec: string | ScheduleSpec, options?: ScheduleOptions): Promise; get(id: string): Promise; getHandle(id: string): Promise; getHandle(id: string): Promise> | null>; getSchedule(id: string): Promise; list(filter?: TypedListFilter): Promise>; listSchedules(filter?: ScheduleFilter): Promise>; cancel(id: string): Promise; suspend(id: string): Promise; pauseSchedule(id: string): Promise; resumeSchedule(id: string): Promise; cancelSchedule(id: string): Promise; updateSchedule(id: string, newSpec: string | ScheduleSpec, options?: ScheduleUpdateOptions): Promise; signal(id: string, name: SignalDefinition): Promise; signal(id: string, name: SignalDefinition, payload: TInput, options?: SignalDeliveryOptions): Promise; signal(id: string, name: string, payload?: unknown, options?: SignalDeliveryOptions): Promise; query(id: string, name: QueryDefinition): Promise; query(id: string, name: QueryDefinition, input: TInput): Promise; query(id: string, name: string, input?: unknown): Promise; update(id: string, name: UpdateDefinition, payload?: void, options?: { timeout?: number; }): Promise; update(id: string, name: UpdateDefinition, payload: TInput, options?: { timeout?: number; }): Promise; update(id: string, name: string, payload?: unknown, options?: { timeout?: number; }): Promise; resume(id: string): Promise; recoverAll(): Promise; timeout(id: string): Promise; getAttributes(id: string): Promise | null>; setAttributes(id: string, attributes: Record): Promise; addTags(id: string, ...tags: string[]): Promise; removeTags(id: string, ...tags: string[]): Promise; getEvents(id: string): Promise; tail(id: string): WorkflowEventTail; getTimeline(id: string): Promise; replayTo(id: string, step: number): Promise; listReviews(filter?: ReviewListFilter): Promise; submitReview(reviewId: string, options: SubmitReviewOptions): Promise; getStreamChunks(workflowId: string, key: string, options?: { after?: number; }): ReturnType; fork(id: string, options?: ForkOptions): Promise; getRetentionOverview(): Promise; purge(filter?: ListFilter): Promise; cancelAll(filter: ListFilter): Promise; retryFailedAll(filter: ListFilter): Promise; signalAll(filter: ListFilter, name: string, payload?: unknown): Promise; deleteAll(filter: ListFilter): Promise; tagAll(filter: ListFilter, tags: string[]): Promise; untagAll(filter: ListFilter, tags: string[]): Promise; submitCoordinatedUpdate(id: string, name: string, payload?: unknown, options?: { timeout?: number; idempotencyKey?: string; }): Promise; getUpdateResult(updateId: string): Promise; }