/** * Build one registered workflow's {@link WorkflowRevisionManifest} — the * per-workflow entry/message/scoped-activity conversion `buildRegistrySnapshot` * (`registry-snapshot.ts`) folds into every manifest in a full snapshot, and * that {@link buildWorkflowManifestForType} exposes standalone for a caller * that wants one or a few workflows' manifests without reading, hashing, or * being bounded by the rest of the engine's registrations. * * Split out of `registry-snapshot.ts` specifically so `buildWorkerManifestFromRegistry` * (`worker/manifest/registry-contract-builder.ts`) can depend on * {@link buildWorkflowManifestForType} without also inheriting * `buildRegistrySnapshot`'s full-snapshot `RegistryWorkflowCountLimitError` * aggregate check, or an *unrelated* registered workflow's own * {@link RegistryManifestLimitError} — neither is the right contract for a * caller that only ever looks up the handful of workflows it names. * * @module core/registry-workflow-manifest */ import type { ActivityMetadata } from './activity-registry.ts'; import { type WorkflowRevisionManifest } from './contract/index.ts'; import type { Engine } from './engine.ts'; import type { RegisteredWorkflowDefinition } from './types/workflow-registry.ts'; import { WeftError } from './weft-error.ts'; /** Schema metadata reported for a statically registered workflow message. */ export type RegistryMessageEntry = { inputSchema?: Record; outputSchema?: Record; }; /** Metadata reported per workflow in a registry snapshot. */ export type RegistryWorkflowEntry = { inputSchema?: Record; outputSchema?: Record; description?: string; tags?: ReadonlyArray; signals?: Record; updates?: Record; queries?: Record; /** Schema metadata for the workflow's definition-level finalizer activity, when registered. */ finalizer?: RegistryMessageEntry; }; /** * Thrown when a registered workflow's contract cannot be published as a * {@link WorkflowRevisionManifest} because it exceeds one of the WFT-5 * hostile-input limits (`core/contract/limits.ts`) — an identifier over * `MAX_CONTRACT_IDENTIFIER_BYTES`, too many signal/update/query/activity * entries, a schema nested past `MAX_CONTRACT_SCHEMA_DEPTH`, or a * normalized contract over `MAX_NORMALIZED_CONTRACT_BYTES`. Nothing in * engine registration enforces those bounds (`name-grammar.ts` has no * length cap; `description`/`tags`/`version`/schema depth are unbounded at * registration time), so a registration the engine happily accepts can * still fail here, at manifest-build time. Mirrors * `RegistrySchemaConversionError`'s masked-500 handling in * `server/operations/get-registry.ts`: the wire response stays a generic * `500 / Internal server error`, and `workflowType` plus the underlying * limit reason reach server-side logs only. */ export declare class RegistryManifestLimitError extends WeftError<'RegistryManifestLimitError'> { readonly workflowType: string; constructor(workflowType: string, cause: unknown); } /** * Build one workflow definition's {@link WorkflowRevisionManifest} from its * already-resolved scoped activity metadata, folding in its * `.activities({...})`-scoped registrations (WFT-6). This is the shared * normalization core both {@link buildOneWorkflowManifest} (the eager * `engine.register()` drain path, which looks `activityDefinitions` up from * the engine's registry) and the dynamic workflow-source loader path * (WFT-13/14, `core/source/validate.ts`, which has no committed `Engine` * registration to look up from) route through — so a workflow registered * both eagerly and lazily from logically identical content always produces * byte-identical manifests, never two independently-derived contracts that * could disagree. * * Throws {@link RegistryManifestLimitError} if `definition`'s contract * exceeds a WFT-5 hostile-input limit. * * @example * ```ts * import { Engine } from '@lostgradient/weft'; * * declare const engine: Engine; * const definition = engine.getWorkflowDefinition('checkout'); * void definition; * ``` */ export declare function buildWorkflowManifestFromDefinition(definition: RegisteredWorkflowDefinition, activityDefinitions: readonly ActivityMetadata[]): Promise; /** * Build one registered workflow's {@link WorkflowRevisionManifest}, folding * in its `.activities({...})`-scoped registrations (WFT-6). Shared by * `buildRegistrySnapshot`'s per-workflow `Promise.all` and * {@link buildWorkflowManifestForType}'s single-workflow lookup, so the two * call paths can never disagree on what one workflow's manifest contains. * A thin wrapper around {@link buildWorkflowManifestFromDefinition} that * resolves `activityDefinitions` from `engine`'s own registry. * * Throws {@link RegistryManifestLimitError} if `definition`'s contract * exceeds a WFT-5 hostile-input limit. */ export declare function buildOneWorkflowManifest(engine: Engine, definition: RegisteredWorkflowDefinition): Promise; /** * Build a single registered workflow's {@link WorkflowRevisionManifest} — * the scoped counterpart to `buildRegistrySnapshot` for a caller that wants * one or a few workflows' manifests without reading, hashing, or being * bounded by the rest of the engine's registrations. * `buildWorkerManifestFromRegistry` (`worker/manifest/registry-contract-builder.ts`) * is exactly that caller: it resolves only the workflows its own * caller-declared `options.workflows` names, so neither * `RegistryWorkflowCountLimitError` (an aggregate, whole-snapshot concern) * nor an unrelated registration's own {@link RegistryManifestLimitError} * should ever block it from producing an otherwise-valid, * independently-bounded worker manifest for the workflows it actually * asked for. * * Returns `undefined` if `workflowType` is not registered on `engine` — the * caller decides how to report that (`buildWorkerManifestFromRegistry` * throws `WorkerManifestBuildError`, naming the type). * * Throws a schema-conversion error if the registered schema fails JSON * Schema conversion, or {@link RegistryManifestLimitError} if the contract * exceeds a WFT-5 hostile-input limit. */ export declare function buildWorkflowManifestForType(engine: Engine, workflowType: string): Promise;