@dudousxd/nestjs-durable-core 0.82.0 → 0.84.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2877,8 +2877,8 @@ interface WorkflowCtx<A extends SearchAttributes = SearchAttributes> {
2877
2877
  *
2878
2878
  * When the workflow declares a `@Workflow({ searchAttributes })` schema, the MERGED result (this
2879
2879
  * run's existing `searchAttributes` shallow-merged with `attrs`) is validated against it before the
2880
- * write — an invalid merge throws, naming the workflow, the offending key(s), and the schema's
2881
- * issues. Validation runs once, on the same first-run-only position as the write itself (skipped
2880
+ * write — an invalid merge throws a `SchemaValidationError` (code `schema_validation`, never
2881
+ * retried) naming the workflow, with the schema's issues. Validation runs once, on the same first-run-only position as the write itself (skipped
2882
2882
  * entirely on replay, so it's never a source of nondeterminism); it must be synchronous — a schema
2883
2883
  * whose `validate` returns a `Promise` throws instead of being awaited. No schema declared ⇒
2884
2884
  * unchanged, unvalidated behavior.
@@ -3827,7 +3827,10 @@ declare function liveHandoff<C extends {
3827
3827
  seq: number;
3828
3828
  name: string;
3829
3829
  }>(runId: string, checkpoints: readonly C[]): C | undefined;
3830
- /** The route a failure takes: the one for its exact code, else the catch-all, else none. */
3830
+ /**
3831
+ * The route a failure takes: the one for its exact code, else (for an `invalid_input` /
3832
+ * `invalid_output` failure) a `schema_validation` route, else the catch-all, else none.
3833
+ */
3831
3834
  declare function routeFor(routes: OnErrorRoute[] | undefined, error: StepError): OnErrorRoute | undefined;
3832
3835
  /** Reject two routes for one code, or two catch-alls — ambiguous config, caught at registration. */
3833
3836
  declare function assertRoutes(workflow: string, routes: OnErrorRoute[]): void;
@@ -4064,6 +4067,85 @@ interface FindStalledRunsOptions {
4064
4067
  */
4065
4068
  declare function findStalledRuns(store: Pick<StateStore, 'listRuns' | 'listCheckpoints'>, options?: FindStalledRunsOptions): Promise<StalledRunInfo[]>;
4066
4069
 
4070
+ /**
4071
+ * Layered tenant auth for the store-less cluster. On a tenant worker the `tenant` on a
4072
+ * {@link import('./interfaces').RunRequest} / {@link import('./interfaces').StartRunMessage} is only
4073
+ * a CLAIM: without a signed proof, any broker client can act as any tenant. This module is the
4074
+ * default defense in depth on top of prefix/network isolation: a symmetric HMAC token the tenant
4075
+ * worker presents IN the existing `tenant` wire field, which the operator's {@link TenantVerifier}
4076
+ * checks and DERIVES the real tenant from, never trusting the body.
4077
+ *
4078
+ * Wire-compatible with Agora (`@adonis-agora/durable`) byte for byte: the token is
4079
+ * `<claim>.<base64url(HMAC-SHA256(secret, claim))>`, where `claim` is the tenant name, optionally
4080
+ * followed by `.exp<epochMs>`. It fits the `tenant: string` field with NO envelope change, so an
4081
+ * operator that does not verify simply treats the whole string as the tenant name (and finds no
4082
+ * runs, a safe failure), while an operator configured with {@link hmacTenantVerifier} verifies the
4083
+ * signature and scopes to the embedded tenant. Agora and Aviary tokens are interchangeable.
4084
+ *
4085
+ * HMAC (shared secret) is the zero-infra default; a deployment that prefers asymmetric or issued
4086
+ * tokens supplies its own {@link TenantVerifier} instead.
4087
+ */
4088
+ /** The identity a {@link TenantVerifier} derives from a tenant's signed claim. */
4089
+ interface VerifiedTenant {
4090
+ /** The tenant the token authenticates as. The responder trusts THIS, never the request body. */
4091
+ tenant: string;
4092
+ /** Capabilities the token grants, if the issuer scopes them. */
4093
+ capabilities?: string[] | undefined;
4094
+ }
4095
+ /**
4096
+ * Verifies a tenant's signed claim on the **operator** side, returning the {@link VerifiedTenant} it
4097
+ * authenticates as, or `null` (or throwing) to reject a tampered/invalid/absent token. The signed
4098
+ * token travels in the wire `tenant` field, so the responder passes that value as both `token` and
4099
+ * the advisory `tenant`.
4100
+ */
4101
+ type TenantVerifier = (input: {
4102
+ /** The signed token presented on the request. */
4103
+ token?: string | undefined;
4104
+ /** The tenant the request *claims* to be. Advisory only: the verifier derives the real one. */
4105
+ tenant?: string | undefined;
4106
+ }) => VerifiedTenant | null | Promise<VerifiedTenant | null>;
4107
+ /**
4108
+ * Where the tenant side gets the token it presents: a static string, or a function called before
4109
+ * every request (so a short-lived token from {@link signTenantToken} with `ttlMs` can be re-minted
4110
+ * or fetched from a secret store without restarting the worker).
4111
+ */
4112
+ type TenantTokenSource = string | (() => string | Promise<string>);
4113
+ /**
4114
+ * Mint the signed token a tenant worker presents:
4115
+ * `` `${tenant}.${base64url(HMAC-SHA256(secret, tenant))}` ``. The worker carries only the token
4116
+ * (never the secret); the operator verifies it with the SAME `secret` via {@link hmacTenantVerifier}.
4117
+ */
4118
+ declare function signTenantToken(tenant: string, secret: string, opts?: {
4119
+ /**
4120
+ * Optional lifetime: the claim gains a `.exp<epochMs>` suffix, signed together with the tenant,
4121
+ * and {@link hmacTenantVerifier} rejects the token once that instant passes. Without it the
4122
+ * token never expires. Expiring and non-expiring tokens verify side by side. Tenant names
4123
+ * ending in `.exp<digits>` are reserved by this scheme.
4124
+ */
4125
+ ttlMs?: number;
4126
+ /** Injectable clock for tests. */
4127
+ now?: number;
4128
+ }): string;
4129
+ /**
4130
+ * Build the operator-side {@link TenantVerifier} for {@link signTenantToken} tokens under `secret`.
4131
+ * It recomputes the HMAC over the embedded claim and compares it in constant time, so a tampered
4132
+ * tenant, a forged/absent signature, a token signed with another secret, or an expired token all
4133
+ * return `null`. The tenant is DERIVED from the token's own claim.
4134
+ *
4135
+ * A LIST of secrets makes rotation a two-step deploy: verify with `[next, current]` everywhere first,
4136
+ * then re-mint tenant tokens with `next` at leisure. `capabilities`, if given, is a static grant
4137
+ * stamped onto every {@link VerifiedTenant} this verifier authenticates.
4138
+ */
4139
+ declare function hmacTenantVerifier(secret: string | string[], capabilities?: string[]): TenantVerifier;
4140
+ /**
4141
+ * Resolve the tenant a wire message is ALLOWED to act as. With a verifier, the wire `tenant` is the
4142
+ * signed token: it is verified and the real tenant derived from it (`null` on reject). Without one,
4143
+ * the wire value is trusted verbatim (prefix/network isolation only, today's behaviour).
4144
+ */
4145
+ declare function resolveWireTenant(wireTenant: string, verifyTenant: TenantVerifier | undefined): Promise<string | null>;
4146
+ /** Resolve a {@link TenantTokenSource} to the token string to put on the wire. */
4147
+ declare function resolveTenantToken(source: TenantTokenSource): Promise<string>;
4148
+
4067
4149
  type WorkflowFn = (ctx: InternalWorkflowCtx, input: unknown) => Promise<unknown>;
4068
4150
  /**
4069
4151
  * Options for {@link WorkflowEngine.start}.
@@ -4207,6 +4289,13 @@ interface WorkflowEngineDeps {
4207
4289
  * plane: "ver tudo = ausência de namespace".
4208
4290
  */
4209
4291
  namespace?: string | undefined;
4292
+ /**
4293
+ * Verifies the signed tenant token a store-less tenant worker presents in the `tenant` field of a
4294
+ * {@link StartRunMessage}, and DERIVES the run's namespace from it (see `hmacTenantVerifier`).
4295
+ * A message whose token is rejected (or whose verifier throws) is dropped without creating a run.
4296
+ * Absent: the wire `tenant` is trusted verbatim, as before.
4297
+ */
4298
+ verifyTenant?: TenantVerifier | undefined;
4210
4299
  /** Recovery lease duration in ms — how long this instance owns a run it picked up. Default 30s. */
4211
4300
  leaseMs?: number | undefined;
4212
4301
  /**
@@ -4847,6 +4936,8 @@ declare class WorkflowEngine {
4847
4936
  * between this call and `drain()` (other hooks, the HTTP server closing) never is. Calls add up.
4848
4937
  */
4849
4938
  beginDrain(spentMs?: number): void;
4939
+ /** True once {@link beginDrain} (or {@link drain}) has been called. */
4940
+ isDraining(): boolean;
4850
4941
  /**
4851
4942
  * Graceful shutdown: stop picking up new runs (recovery/timer become no-ops) and wait for
4852
4943
  * in-flight executions to settle, up to `timeoutMs`. Call from your app's shutdown hook so a
@@ -5966,6 +6057,44 @@ declare class FatalError extends Error {
5966
6057
  readonly retryable = false;
5967
6058
  constructor(message: string, code?: string, details?: unknown);
5968
6059
  }
6060
+ /** One schema issue in JSON-safe form: its message and the path segments, as strings. */
6061
+ interface SchemaIssue {
6062
+ message: string;
6063
+ path: string[];
6064
+ }
6065
+ /**
6066
+ * The code a {@link SchemaValidationError} carries: `invalid_input` for an input schema (a
6067
+ * workflow's or a step's), `invalid_output` for an output schema, `schema_validation` for anything
6068
+ * else (a typed `searchAttributes` write). The same codes `@adonis-agora/durable` uses.
6069
+ */
6070
+ type SchemaValidationCode = 'invalid_input' | 'invalid_output' | 'schema_validation';
6071
+ /**
6072
+ * Thrown when a value fails a schema the app declared: `@Workflow({ input, output })`,
6073
+ * `@Step({ input, output })`, or the workflow's typed `searchAttributes`. A {@link FatalError}, so it
6074
+ * is NOT retried — retrying cannot fix a value that doesn't match its schema. Its `code` says which
6075
+ * schema rejected the value ({@link SchemaValidationCode}). `issues` (also `details.issues`, so it
6076
+ * survives the transport to the run's error and an onError handler's input) lists every issue with
6077
+ * a JSON-safe `path`. Route one code with `onError: [{ code: 'invalid_input', workflow }]`, or all
6078
+ * three with `onError: [{ code: SchemaValidationError, workflow }]`: its `static code`,
6079
+ * `schema_validation`, also catches an `invalid_input` or `invalid_output` no route of its own
6080
+ * matches. Same class, codes, message and `details` as `@adonis-agora/durable`.
6081
+ */
6082
+ declare class SchemaValidationError extends FatalError {
6083
+ static readonly code = "schema_validation";
6084
+ readonly issues: SchemaIssue[];
6085
+ /**
6086
+ * @param label What was validated, e.g. `workflow "checkout" input`; the message is
6087
+ * `invalid <label>: <path>: <message>; …`.
6088
+ * @param summary Overrides the `<path>: <message>; …` part, for issues whose messages already
6089
+ * name their field (class-validator's `orderId must be a string`).
6090
+ */
6091
+ constructor(label: string, issues: ReadonlyArray<{
6092
+ readonly message: string;
6093
+ readonly path?: ReadonlyArray<PropertyKey | {
6094
+ readonly key: PropertyKey;
6095
+ }> | undefined;
6096
+ }>, code?: SchemaValidationCode, summary?: string);
6097
+ }
5969
6098
  /**
5970
6099
  * Thrown by `start` when a run would exceed its concurrency quota: `active` runs sharing the quota
5971
6100
  * `key` are already in flight (in the quota's counted statuses) and the `limit` is `limit`. Nothing
@@ -6634,11 +6763,20 @@ type Subscribable = {
6634
6763
  */
6635
6764
  declare function collectMetrics(engine: Subscribable): MetricsCollector;
6636
6765
 
6637
- interface ScheduledWorkflow {
6766
+ /**
6767
+ * A recurring start of `workflow`, fired on a fixed interval or a cron.
6768
+ *
6769
+ * `workflow` is a registered name or a `@Workflow` class. A class types `input` against its `run`;
6770
+ * annotate the schedule to get that check, as in
6771
+ * `const nightly: ScheduledWorkflow<typeof ReportWorkflow> = { workflow: ReportWorkflow, … }`.
6772
+ */
6773
+ interface ScheduledWorkflow<W extends WorkflowRef = WorkflowRef> {
6638
6774
  /** Stable key identifying this schedule — part of the deterministic run id. */
6639
6775
  key: string;
6640
- workflow: string;
6641
- input?: unknown;
6776
+ /** The workflow to start: a registered name (any runtime) or a `@Workflow` class. */
6777
+ workflow: W;
6778
+ /** The input every run starts with — typed against `run` when `workflow` is a class. */
6779
+ input?: WorkflowInputOf<W>;
6642
6780
  /** Start one run every `everyMs`. Mutually exclusive with `cron`. */
6643
6781
  everyMs?: number;
6644
6782
  /**
@@ -6676,6 +6814,16 @@ interface ScheduledWorkflow {
6676
6814
  backfill?: {
6677
6815
  maxCatchup: number;
6678
6816
  };
6817
+ /**
6818
+ * The namespace this schedule's runs are stamped with, overriding the ticking engine's own. Opt-in;
6819
+ * absent = the run gets the namespace of whichever engine fired it.
6820
+ *
6821
+ * The run id is a time bucket, so the instance that wins the race to fire a window decides which
6822
+ * namespace (worker pool) the run lands in. When the workflow can only run in one pool — its steps
6823
+ * need a capability only that pool's workers have — pin it here, so whoever fires the window, the
6824
+ * run is stamped for (and only picked up by) that pool.
6825
+ */
6826
+ namespace?: string;
6679
6827
  }
6680
6828
  /** Injectable dispatch-path effects (kept out of the deterministic run-id logic). Defaults to real
6681
6829
  * `Math.random` + `setTimeout`; overridden in tests so jitter is deterministic and instant. */
@@ -6697,14 +6845,23 @@ declare function prevCronFireMs(expr: string, nowMs: number, timezone?: string):
6697
6845
  * schedule is next due.
6698
6846
  */
6699
6847
  declare function nextCronFireMs(expr: string, afterMs: number, timezone?: string): number;
6848
+ /**
6849
+ * The deterministic, idempotent run id for a schedule at `nowMs` — its current fire window
6850
+ * (`sched:<key>:<bucket>`, the bucket being a fixed-interval index or the cron fire time). Pass the
6851
+ * same `ScheduledWorkflow` you registered to look a window's run up, e.g.
6852
+ * `engine.getRun(scheduleRunIdAt(dailyReport, Date.now()))`, rather than rebuilding the id by hand.
6853
+ */
6854
+ declare function scheduleRunIdAt(s: ScheduledWorkflow, nowMs: number): string;
6700
6855
  /**
6701
6856
  * Start each schedule's current-window run. The run id is the time bucket (a fixed-interval index,
6702
6857
  * or the cron fire time) and `engine.start` is idempotent, so firing this on an interval — or
6703
6858
  * racing two instances on the same tick — starts **each window exactly once**. Wire it to a
6704
- * `setInterval`, the durable timer poller, or `@nestjs/schedule`. Returns the run ids for the
6705
- * current windows.
6859
+ * `setInterval`, the durable timer poller, or `@nestjs/schedule`. Returns the run ids this call
6860
+ * started: a window that already has a run is not started or returned again, and once this process
6861
+ * has seen a window's run exist, later calls in that window skip it without a store read or a
6862
+ * jitter sleep.
6706
6863
  */
6707
- declare function runSchedules(engine: Pick<WorkflowEngine, 'start' | 'getRun'>, schedules: readonly ScheduledWorkflow[], nowMs: number, opts?: RunSchedulesOptions): Promise<string[]>;
6864
+ declare function runSchedules(engine: Pick<WorkflowEngine, 'start' | 'getRun'> & Partial<Pick<WorkflowEngine, 'isDraining'>>, schedules: readonly ScheduledWorkflow[], nowMs: number, opts?: RunSchedulesOptions): Promise<string[]>;
6708
6865
 
6709
6866
  /**
6710
6867
  * A {@link StepLogger} that appends to `events`, stamping each line with `now()`. Shared by the
@@ -7117,4 +7274,4 @@ declare function singletonAdmissionDenialPatch(runs: WorkflowRun[], runId: strin
7117
7274
  updatedAt: Date;
7118
7275
  } | undefined;
7119
7276
 
7120
- export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type CheckpointAggregatingStore, type CheckpointNameKind, type CheckpointQuery, type CheckpointStat, type ChildCallOptions, type ChildWait, CodecStateStore, type CodecStateStoreOptions, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DEFAULT_STALLED_AFTER_MS, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, ENTITY_WORKFLOW, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, type FindStalledRunsOptions, GatherError, type GatherItemFailure, type GroupHealth, HANDOFF_SEQ_BASE, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type ListStalledRunsOptions, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OwnedLeaseReclaim, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_HISTORY_FIXTURE_VERSION, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDetailOptions, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, type Settled, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StalePendingStep, type StalledRunInfo, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, applyAttributeQuery, assertConcurrency, assertRoutes, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, fanPageBounds, fanPageEtag, findStalledRuns, foldedCount, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, legacySingletonHolders, listSignalWaitersOfRuns, liveHandoff, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, queryCheckpointsOf, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, retiredHandoffName, routeFor, runDetailEtag, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantGroup, useDurableExecution, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
7277
+ export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type CheckpointAggregatingStore, type CheckpointNameKind, type CheckpointQuery, type CheckpointStat, type ChildCallOptions, type ChildWait, CodecStateStore, type CodecStateStoreOptions, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DEFAULT_STALLED_AFTER_MS, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, ENTITY_WORKFLOW, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, type FindStalledRunsOptions, GatherError, type GatherItemFailure, type GroupHealth, HANDOFF_SEQ_BASE, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type ListStalledRunsOptions, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OwnedLeaseReclaim, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_HISTORY_FIXTURE_VERSION, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDetailOptions, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SchemaIssue, type SchemaValidationCode, SchemaValidationError, type SearchAttributes, type SearchAttributesSchema, type Settled, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StalePendingStep, type StalledRunInfo, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type TenantTokenSource, type TenantVerifier, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, type VerifiedTenant, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, applyAttributeQuery, assertConcurrency, assertRoutes, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, fanPageBounds, fanPageEtag, findStalledRuns, foldedCount, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, hmacTenantVerifier, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, legacySingletonHolders, listSignalWaitersOfRuns, liveHandoff, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, queryCheckpointsOf, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, resolveTenantToken, resolveWireTenant, retiredHandoffName, routeFor, runDetailEtag, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduleRunIdAt, scheduledRunId, signTenantToken, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantGroup, useDurableExecution, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
package/dist/index.d.ts CHANGED
@@ -2877,8 +2877,8 @@ interface WorkflowCtx<A extends SearchAttributes = SearchAttributes> {
2877
2877
  *
2878
2878
  * When the workflow declares a `@Workflow({ searchAttributes })` schema, the MERGED result (this
2879
2879
  * run's existing `searchAttributes` shallow-merged with `attrs`) is validated against it before the
2880
- * write — an invalid merge throws, naming the workflow, the offending key(s), and the schema's
2881
- * issues. Validation runs once, on the same first-run-only position as the write itself (skipped
2880
+ * write — an invalid merge throws a `SchemaValidationError` (code `schema_validation`, never
2881
+ * retried) naming the workflow, with the schema's issues. Validation runs once, on the same first-run-only position as the write itself (skipped
2882
2882
  * entirely on replay, so it's never a source of nondeterminism); it must be synchronous — a schema
2883
2883
  * whose `validate` returns a `Promise` throws instead of being awaited. No schema declared ⇒
2884
2884
  * unchanged, unvalidated behavior.
@@ -3827,7 +3827,10 @@ declare function liveHandoff<C extends {
3827
3827
  seq: number;
3828
3828
  name: string;
3829
3829
  }>(runId: string, checkpoints: readonly C[]): C | undefined;
3830
- /** The route a failure takes: the one for its exact code, else the catch-all, else none. */
3830
+ /**
3831
+ * The route a failure takes: the one for its exact code, else (for an `invalid_input` /
3832
+ * `invalid_output` failure) a `schema_validation` route, else the catch-all, else none.
3833
+ */
3831
3834
  declare function routeFor(routes: OnErrorRoute[] | undefined, error: StepError): OnErrorRoute | undefined;
3832
3835
  /** Reject two routes for one code, or two catch-alls — ambiguous config, caught at registration. */
3833
3836
  declare function assertRoutes(workflow: string, routes: OnErrorRoute[]): void;
@@ -4064,6 +4067,85 @@ interface FindStalledRunsOptions {
4064
4067
  */
4065
4068
  declare function findStalledRuns(store: Pick<StateStore, 'listRuns' | 'listCheckpoints'>, options?: FindStalledRunsOptions): Promise<StalledRunInfo[]>;
4066
4069
 
4070
+ /**
4071
+ * Layered tenant auth for the store-less cluster. On a tenant worker the `tenant` on a
4072
+ * {@link import('./interfaces').RunRequest} / {@link import('./interfaces').StartRunMessage} is only
4073
+ * a CLAIM: without a signed proof, any broker client can act as any tenant. This module is the
4074
+ * default defense in depth on top of prefix/network isolation: a symmetric HMAC token the tenant
4075
+ * worker presents IN the existing `tenant` wire field, which the operator's {@link TenantVerifier}
4076
+ * checks and DERIVES the real tenant from, never trusting the body.
4077
+ *
4078
+ * Wire-compatible with Agora (`@adonis-agora/durable`) byte for byte: the token is
4079
+ * `<claim>.<base64url(HMAC-SHA256(secret, claim))>`, where `claim` is the tenant name, optionally
4080
+ * followed by `.exp<epochMs>`. It fits the `tenant: string` field with NO envelope change, so an
4081
+ * operator that does not verify simply treats the whole string as the tenant name (and finds no
4082
+ * runs, a safe failure), while an operator configured with {@link hmacTenantVerifier} verifies the
4083
+ * signature and scopes to the embedded tenant. Agora and Aviary tokens are interchangeable.
4084
+ *
4085
+ * HMAC (shared secret) is the zero-infra default; a deployment that prefers asymmetric or issued
4086
+ * tokens supplies its own {@link TenantVerifier} instead.
4087
+ */
4088
+ /** The identity a {@link TenantVerifier} derives from a tenant's signed claim. */
4089
+ interface VerifiedTenant {
4090
+ /** The tenant the token authenticates as. The responder trusts THIS, never the request body. */
4091
+ tenant: string;
4092
+ /** Capabilities the token grants, if the issuer scopes them. */
4093
+ capabilities?: string[] | undefined;
4094
+ }
4095
+ /**
4096
+ * Verifies a tenant's signed claim on the **operator** side, returning the {@link VerifiedTenant} it
4097
+ * authenticates as, or `null` (or throwing) to reject a tampered/invalid/absent token. The signed
4098
+ * token travels in the wire `tenant` field, so the responder passes that value as both `token` and
4099
+ * the advisory `tenant`.
4100
+ */
4101
+ type TenantVerifier = (input: {
4102
+ /** The signed token presented on the request. */
4103
+ token?: string | undefined;
4104
+ /** The tenant the request *claims* to be. Advisory only: the verifier derives the real one. */
4105
+ tenant?: string | undefined;
4106
+ }) => VerifiedTenant | null | Promise<VerifiedTenant | null>;
4107
+ /**
4108
+ * Where the tenant side gets the token it presents: a static string, or a function called before
4109
+ * every request (so a short-lived token from {@link signTenantToken} with `ttlMs` can be re-minted
4110
+ * or fetched from a secret store without restarting the worker).
4111
+ */
4112
+ type TenantTokenSource = string | (() => string | Promise<string>);
4113
+ /**
4114
+ * Mint the signed token a tenant worker presents:
4115
+ * `` `${tenant}.${base64url(HMAC-SHA256(secret, tenant))}` ``. The worker carries only the token
4116
+ * (never the secret); the operator verifies it with the SAME `secret` via {@link hmacTenantVerifier}.
4117
+ */
4118
+ declare function signTenantToken(tenant: string, secret: string, opts?: {
4119
+ /**
4120
+ * Optional lifetime: the claim gains a `.exp<epochMs>` suffix, signed together with the tenant,
4121
+ * and {@link hmacTenantVerifier} rejects the token once that instant passes. Without it the
4122
+ * token never expires. Expiring and non-expiring tokens verify side by side. Tenant names
4123
+ * ending in `.exp<digits>` are reserved by this scheme.
4124
+ */
4125
+ ttlMs?: number;
4126
+ /** Injectable clock for tests. */
4127
+ now?: number;
4128
+ }): string;
4129
+ /**
4130
+ * Build the operator-side {@link TenantVerifier} for {@link signTenantToken} tokens under `secret`.
4131
+ * It recomputes the HMAC over the embedded claim and compares it in constant time, so a tampered
4132
+ * tenant, a forged/absent signature, a token signed with another secret, or an expired token all
4133
+ * return `null`. The tenant is DERIVED from the token's own claim.
4134
+ *
4135
+ * A LIST of secrets makes rotation a two-step deploy: verify with `[next, current]` everywhere first,
4136
+ * then re-mint tenant tokens with `next` at leisure. `capabilities`, if given, is a static grant
4137
+ * stamped onto every {@link VerifiedTenant} this verifier authenticates.
4138
+ */
4139
+ declare function hmacTenantVerifier(secret: string | string[], capabilities?: string[]): TenantVerifier;
4140
+ /**
4141
+ * Resolve the tenant a wire message is ALLOWED to act as. With a verifier, the wire `tenant` is the
4142
+ * signed token: it is verified and the real tenant derived from it (`null` on reject). Without one,
4143
+ * the wire value is trusted verbatim (prefix/network isolation only, today's behaviour).
4144
+ */
4145
+ declare function resolveWireTenant(wireTenant: string, verifyTenant: TenantVerifier | undefined): Promise<string | null>;
4146
+ /** Resolve a {@link TenantTokenSource} to the token string to put on the wire. */
4147
+ declare function resolveTenantToken(source: TenantTokenSource): Promise<string>;
4148
+
4067
4149
  type WorkflowFn = (ctx: InternalWorkflowCtx, input: unknown) => Promise<unknown>;
4068
4150
  /**
4069
4151
  * Options for {@link WorkflowEngine.start}.
@@ -4207,6 +4289,13 @@ interface WorkflowEngineDeps {
4207
4289
  * plane: "ver tudo = ausência de namespace".
4208
4290
  */
4209
4291
  namespace?: string | undefined;
4292
+ /**
4293
+ * Verifies the signed tenant token a store-less tenant worker presents in the `tenant` field of a
4294
+ * {@link StartRunMessage}, and DERIVES the run's namespace from it (see `hmacTenantVerifier`).
4295
+ * A message whose token is rejected (or whose verifier throws) is dropped without creating a run.
4296
+ * Absent: the wire `tenant` is trusted verbatim, as before.
4297
+ */
4298
+ verifyTenant?: TenantVerifier | undefined;
4210
4299
  /** Recovery lease duration in ms — how long this instance owns a run it picked up. Default 30s. */
4211
4300
  leaseMs?: number | undefined;
4212
4301
  /**
@@ -4847,6 +4936,8 @@ declare class WorkflowEngine {
4847
4936
  * between this call and `drain()` (other hooks, the HTTP server closing) never is. Calls add up.
4848
4937
  */
4849
4938
  beginDrain(spentMs?: number): void;
4939
+ /** True once {@link beginDrain} (or {@link drain}) has been called. */
4940
+ isDraining(): boolean;
4850
4941
  /**
4851
4942
  * Graceful shutdown: stop picking up new runs (recovery/timer become no-ops) and wait for
4852
4943
  * in-flight executions to settle, up to `timeoutMs`. Call from your app's shutdown hook so a
@@ -5966,6 +6057,44 @@ declare class FatalError extends Error {
5966
6057
  readonly retryable = false;
5967
6058
  constructor(message: string, code?: string, details?: unknown);
5968
6059
  }
6060
+ /** One schema issue in JSON-safe form: its message and the path segments, as strings. */
6061
+ interface SchemaIssue {
6062
+ message: string;
6063
+ path: string[];
6064
+ }
6065
+ /**
6066
+ * The code a {@link SchemaValidationError} carries: `invalid_input` for an input schema (a
6067
+ * workflow's or a step's), `invalid_output` for an output schema, `schema_validation` for anything
6068
+ * else (a typed `searchAttributes` write). The same codes `@adonis-agora/durable` uses.
6069
+ */
6070
+ type SchemaValidationCode = 'invalid_input' | 'invalid_output' | 'schema_validation';
6071
+ /**
6072
+ * Thrown when a value fails a schema the app declared: `@Workflow({ input, output })`,
6073
+ * `@Step({ input, output })`, or the workflow's typed `searchAttributes`. A {@link FatalError}, so it
6074
+ * is NOT retried — retrying cannot fix a value that doesn't match its schema. Its `code` says which
6075
+ * schema rejected the value ({@link SchemaValidationCode}). `issues` (also `details.issues`, so it
6076
+ * survives the transport to the run's error and an onError handler's input) lists every issue with
6077
+ * a JSON-safe `path`. Route one code with `onError: [{ code: 'invalid_input', workflow }]`, or all
6078
+ * three with `onError: [{ code: SchemaValidationError, workflow }]`: its `static code`,
6079
+ * `schema_validation`, also catches an `invalid_input` or `invalid_output` no route of its own
6080
+ * matches. Same class, codes, message and `details` as `@adonis-agora/durable`.
6081
+ */
6082
+ declare class SchemaValidationError extends FatalError {
6083
+ static readonly code = "schema_validation";
6084
+ readonly issues: SchemaIssue[];
6085
+ /**
6086
+ * @param label What was validated, e.g. `workflow "checkout" input`; the message is
6087
+ * `invalid <label>: <path>: <message>; …`.
6088
+ * @param summary Overrides the `<path>: <message>; …` part, for issues whose messages already
6089
+ * name their field (class-validator's `orderId must be a string`).
6090
+ */
6091
+ constructor(label: string, issues: ReadonlyArray<{
6092
+ readonly message: string;
6093
+ readonly path?: ReadonlyArray<PropertyKey | {
6094
+ readonly key: PropertyKey;
6095
+ }> | undefined;
6096
+ }>, code?: SchemaValidationCode, summary?: string);
6097
+ }
5969
6098
  /**
5970
6099
  * Thrown by `start` when a run would exceed its concurrency quota: `active` runs sharing the quota
5971
6100
  * `key` are already in flight (in the quota's counted statuses) and the `limit` is `limit`. Nothing
@@ -6634,11 +6763,20 @@ type Subscribable = {
6634
6763
  */
6635
6764
  declare function collectMetrics(engine: Subscribable): MetricsCollector;
6636
6765
 
6637
- interface ScheduledWorkflow {
6766
+ /**
6767
+ * A recurring start of `workflow`, fired on a fixed interval or a cron.
6768
+ *
6769
+ * `workflow` is a registered name or a `@Workflow` class. A class types `input` against its `run`;
6770
+ * annotate the schedule to get that check, as in
6771
+ * `const nightly: ScheduledWorkflow<typeof ReportWorkflow> = { workflow: ReportWorkflow, … }`.
6772
+ */
6773
+ interface ScheduledWorkflow<W extends WorkflowRef = WorkflowRef> {
6638
6774
  /** Stable key identifying this schedule — part of the deterministic run id. */
6639
6775
  key: string;
6640
- workflow: string;
6641
- input?: unknown;
6776
+ /** The workflow to start: a registered name (any runtime) or a `@Workflow` class. */
6777
+ workflow: W;
6778
+ /** The input every run starts with — typed against `run` when `workflow` is a class. */
6779
+ input?: WorkflowInputOf<W>;
6642
6780
  /** Start one run every `everyMs`. Mutually exclusive with `cron`. */
6643
6781
  everyMs?: number;
6644
6782
  /**
@@ -6676,6 +6814,16 @@ interface ScheduledWorkflow {
6676
6814
  backfill?: {
6677
6815
  maxCatchup: number;
6678
6816
  };
6817
+ /**
6818
+ * The namespace this schedule's runs are stamped with, overriding the ticking engine's own. Opt-in;
6819
+ * absent = the run gets the namespace of whichever engine fired it.
6820
+ *
6821
+ * The run id is a time bucket, so the instance that wins the race to fire a window decides which
6822
+ * namespace (worker pool) the run lands in. When the workflow can only run in one pool — its steps
6823
+ * need a capability only that pool's workers have — pin it here, so whoever fires the window, the
6824
+ * run is stamped for (and only picked up by) that pool.
6825
+ */
6826
+ namespace?: string;
6679
6827
  }
6680
6828
  /** Injectable dispatch-path effects (kept out of the deterministic run-id logic). Defaults to real
6681
6829
  * `Math.random` + `setTimeout`; overridden in tests so jitter is deterministic and instant. */
@@ -6697,14 +6845,23 @@ declare function prevCronFireMs(expr: string, nowMs: number, timezone?: string):
6697
6845
  * schedule is next due.
6698
6846
  */
6699
6847
  declare function nextCronFireMs(expr: string, afterMs: number, timezone?: string): number;
6848
+ /**
6849
+ * The deterministic, idempotent run id for a schedule at `nowMs` — its current fire window
6850
+ * (`sched:<key>:<bucket>`, the bucket being a fixed-interval index or the cron fire time). Pass the
6851
+ * same `ScheduledWorkflow` you registered to look a window's run up, e.g.
6852
+ * `engine.getRun(scheduleRunIdAt(dailyReport, Date.now()))`, rather than rebuilding the id by hand.
6853
+ */
6854
+ declare function scheduleRunIdAt(s: ScheduledWorkflow, nowMs: number): string;
6700
6855
  /**
6701
6856
  * Start each schedule's current-window run. The run id is the time bucket (a fixed-interval index,
6702
6857
  * or the cron fire time) and `engine.start` is idempotent, so firing this on an interval — or
6703
6858
  * racing two instances on the same tick — starts **each window exactly once**. Wire it to a
6704
- * `setInterval`, the durable timer poller, or `@nestjs/schedule`. Returns the run ids for the
6705
- * current windows.
6859
+ * `setInterval`, the durable timer poller, or `@nestjs/schedule`. Returns the run ids this call
6860
+ * started: a window that already has a run is not started or returned again, and once this process
6861
+ * has seen a window's run exist, later calls in that window skip it without a store read or a
6862
+ * jitter sleep.
6706
6863
  */
6707
- declare function runSchedules(engine: Pick<WorkflowEngine, 'start' | 'getRun'>, schedules: readonly ScheduledWorkflow[], nowMs: number, opts?: RunSchedulesOptions): Promise<string[]>;
6864
+ declare function runSchedules(engine: Pick<WorkflowEngine, 'start' | 'getRun'> & Partial<Pick<WorkflowEngine, 'isDraining'>>, schedules: readonly ScheduledWorkflow[], nowMs: number, opts?: RunSchedulesOptions): Promise<string[]>;
6708
6865
 
6709
6866
  /**
6710
6867
  * A {@link StepLogger} that appends to `events`, stamping each line with `now()`. Shared by the
@@ -7117,4 +7274,4 @@ declare function singletonAdmissionDenialPatch(runs: WorkflowRun[], runId: strin
7117
7274
  updatedAt: Date;
7118
7275
  } | undefined;
7119
7276
 
7120
- export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type CheckpointAggregatingStore, type CheckpointNameKind, type CheckpointQuery, type CheckpointStat, type ChildCallOptions, type ChildWait, CodecStateStore, type CodecStateStoreOptions, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DEFAULT_STALLED_AFTER_MS, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, ENTITY_WORKFLOW, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, type FindStalledRunsOptions, GatherError, type GatherItemFailure, type GroupHealth, HANDOFF_SEQ_BASE, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type ListStalledRunsOptions, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OwnedLeaseReclaim, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_HISTORY_FIXTURE_VERSION, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDetailOptions, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, type Settled, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StalePendingStep, type StalledRunInfo, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, applyAttributeQuery, assertConcurrency, assertRoutes, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, fanPageBounds, fanPageEtag, findStalledRuns, foldedCount, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, legacySingletonHolders, listSignalWaitersOfRuns, liveHandoff, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, queryCheckpointsOf, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, retiredHandoffName, routeFor, runDetailEtag, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantGroup, useDurableExecution, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
7277
+ export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type CheckpointAggregatingStore, type CheckpointNameKind, type CheckpointQuery, type CheckpointStat, type ChildCallOptions, type ChildWait, CodecStateStore, type CodecStateStoreOptions, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DEFAULT_STALLED_AFTER_MS, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, ENTITY_WORKFLOW, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, type FindStalledRunsOptions, GatherError, type GatherItemFailure, type GroupHealth, HANDOFF_SEQ_BASE, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type ListStalledRunsOptions, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OwnedLeaseReclaim, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_HISTORY_FIXTURE_VERSION, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDetailOptions, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SchemaIssue, type SchemaValidationCode, SchemaValidationError, type SearchAttributes, type SearchAttributesSchema, type Settled, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StalePendingStep, type StalledRunInfo, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type TenantTokenSource, type TenantVerifier, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, type VerifiedTenant, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, applyAttributeQuery, assertConcurrency, assertRoutes, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, fanPageBounds, fanPageEtag, findStalledRuns, foldedCount, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, hmacTenantVerifier, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, legacySingletonHolders, listSignalWaitersOfRuns, liveHandoff, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, queryCheckpointsOf, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, resolveTenantToken, resolveWireTenant, retiredHandoffName, routeFor, runDetailEtag, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduleRunIdAt, scheduledRunId, signTenantToken, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantGroup, useDurableExecution, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };