@dudousxd/nestjs-durable-core 0.100.0 → 0.102.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
@@ -266,6 +266,86 @@ interface WorkflowRegistration {
266
266
  * nothing.
267
267
  */
268
268
  subscribes?: string[];
269
+ /**
270
+ * The `@Workflow` options a control plane applies to this workflow when it serves it by convention
271
+ * (it knows a tenant's workflow by name alone). Only the data options travel: the ones that are
272
+ * functions of the input (a singleton or concurrency `key`, an input schema, `validateInput`) are
273
+ * evaluated by the starting app and carried on its start-run (see `StartRunMessage.singleton`).
274
+ * Absent = not stated, which applies nothing (the behaviour before this field).
275
+ */
276
+ options?: AnnouncedWorkflowOptions;
277
+ /**
278
+ * The workflow this workflow's dead-lettered runs are routed to: an inline `@DeadLetter()` handler
279
+ * (`<name>.dlq`, served by the same worker), a `deadLetterWorkflow` reference, or the app's
280
+ * module-level default. A control plane serving the workflow by convention starts it, in the dead
281
+ * run's namespace, when no dead-letter route of its own applies. Absent = not stated.
282
+ */
283
+ deadLetter?: string;
284
+ }
285
+ /**
286
+ * The JSON-safe `@Workflow` options a worker announces for a workflow (see
287
+ * {@link WorkflowRegistration.options}). Every field is optional and means "not stated" when absent.
288
+ */
289
+ interface AnnouncedWorkflowOptions {
290
+ /** Static tags stamped on every run, merged with the start's own tags. */
291
+ tags?: string[];
292
+ /** Max wall-clock lifetime of a run, in ms (`@Workflow({ executionTimeout })`). */
293
+ executionTimeoutMs?: number;
294
+ /**
295
+ * The workflow is a singleton (`@Workflow({ singleton })`): its runs that share a key are admitted
296
+ * at most `limit` (default 1) at a time. The key is a function of the input, so the starter computes
297
+ * it and the run carries it as its `singleton:<key>` tag; this states the limit the control plane
298
+ * admits against on every turn.
299
+ */
300
+ singleton?: {
301
+ limit?: number;
302
+ maxQueueDepth?: number;
303
+ };
304
+ }
305
+ /**
306
+ * One recurring start a tenant app declares (its `schedules` module option), as its worker
307
+ * ANNOUNCES it to the control plane, which adopts it as a persisted schedule and fires it (see
308
+ * `WorkflowEngine.syncAnnouncedSchedules`). JSON-safe: a workflow class is announced by its name.
309
+ */
310
+ interface AnnouncedSchedule {
311
+ /** The schedule's key in the app. The control plane's schedule id is `app:<namespace>:<key>`. */
312
+ key: string;
313
+ /** Registered workflow name. */
314
+ workflow: string;
315
+ /** The input every run starts with. */
316
+ input?: unknown;
317
+ /** Fixed interval in ms. Exactly one of `everyMs` and `cron`. */
318
+ everyMs?: number;
319
+ /** Cron expression (5 fields, or 6 with leading seconds). */
320
+ cron?: string;
321
+ /** IANA timezone the cron is evaluated in. Default UTC. */
322
+ timezone?: string;
323
+ /** Declared paused. */
324
+ paused?: boolean;
325
+ /** `'skip'`: no new window while the previous run is still in flight. Default `'allow'`. */
326
+ overlap?: 'allow' | 'skip';
327
+ /** Delay each fire by a stable offset of up to this many ms. */
328
+ jitterMs?: number;
329
+ /**
330
+ * The workflow's `@Workflow({ singleton })` key, evaluated by the app against this schedule's
331
+ * `input` (a key is a function of the input, which the control plane cannot run). Its fires are
332
+ * serialized with the app's other runs of that key. Absent = not a singleton.
333
+ */
334
+ singleton?: {
335
+ key: string;
336
+ limit?: number;
337
+ maxQueueDepth?: number;
338
+ };
339
+ }
340
+ /**
341
+ * The schedules a tenant worker announces, and the wire tenant they belong to: the partition, or
342
+ * the signed tenant token when the app has one (verified by the control plane exactly like a
343
+ * start-run's `tenant`). `items: []` is a statement too ("this app declares no schedules"), which is
344
+ * what lets the control plane withdraw a schedule the app stopped declaring.
345
+ */
346
+ interface ScheduleAnnouncement {
347
+ tenant: string;
348
+ items: AnnouncedSchedule[];
269
349
  }
270
350
  /**
271
351
  * A worker's (or control-plane's) advertised identity, wire-protocol support, feature capabilities
@@ -312,6 +392,13 @@ interface WorkerDescriptor {
312
392
  * that fails at run time.
313
393
  */
314
394
  registrations?: WorkflowRegistration[];
395
+ /**
396
+ * The recurring starts this app declares (see {@link ScheduleAnnouncement}). OPTIONAL and additive:
397
+ * absent = this SDK does not announce schedules (a control plane then neither adopts nor withdraws
398
+ * any for it); a control plane that predates the field ignores it. Rides the descriptor so it
399
+ * inherits its liveness: the control plane only reconciles against what LIVE workers announce.
400
+ */
401
+ schedules?: ScheduleAnnouncement;
315
402
  /** Optional routing partition (queue/group sharding). */
316
403
  partition?: string;
317
404
  /** Optional tenant namespace this instance serves. */
@@ -435,6 +522,8 @@ declare function describeWorker(opts: {
435
522
  * the descriptor entirely when absent or empty, so a worker with nothing to announce keeps the
436
523
  * pre-registrations bytes (and therefore the pre-registrations hash). */
437
524
  registrations?: readonly WorkflowRegistration[] | undefined;
525
+ /** The schedules this app announces. Omitted from the descriptor when absent; `items: []` is kept. */
526
+ schedules?: ScheduleAnnouncement | undefined;
438
527
  startedAt: number;
439
528
  partition?: string | undefined;
440
529
  namespace?: string | undefined;
@@ -920,69 +1009,6 @@ declare function fanPageBounds(query: FanPageQuery): {
920
1009
  limit: number;
921
1010
  };
922
1011
 
923
- /**
924
- * One end of a `ctx.waitForRun` wait, as a run detail lists it: the run waited for (`waitsFor`) or
925
- * the waiting run (`awaitedBy`), the waiting run's `seq` of the call, and the other run's status and
926
- * namespace when it was read.
927
- */
928
- interface RunWaitLink {
929
- runId: string;
930
- seq: number;
931
- status?: RunStatus | undefined;
932
- namespace?: string | undefined;
933
- }
934
- /**
935
- * Where a settled run's lifecycle event stands for one subscriber:
936
- * - `started`: its run exists (`runId`, a `durable:triggered:<subscriber>` tag);
937
- * - `owed`: still pending (a `durable:lifecycle:owed:<subscriber>` tag);
938
- * - `coalesced`: routed into a debounce/batch accumulator (a `durable:coalesced:<subscriber>` tag,
939
- * or the caller's `coalesced` map; `runId` is the accumulator's, when it can be derived);
940
- * - `failed`: its start failed (a `durable:trigger_failed:<subscriber>` tag): its `where` threw, its
941
- * input was rejected, its start threw, or the sweep dropped it as orphaned. A republish retries it;
942
- * - `not-started`: no run and nothing owed: its `where` declined the event, or it subscribed after
943
- * the run settled.
944
- */
945
- type LifecycleDeliveryState = 'started' | 'owed' | 'coalesced' | 'failed' | 'not-started';
946
- /** One subscriber of a settled run's lifecycle event, as the run detail lists it. */
947
- interface LifecycleDelivery {
948
- subscriber: string;
949
- state: LifecycleDeliveryState;
950
- /** The subscriber's run when `started`; the accumulator run when `coalesced` and derivable. */
951
- runId?: string | undefined;
952
- /** The status of a `started` subscriber's run, when it was read. */
953
- status?: RunStatus | undefined;
954
- /** The namespace of a `started` subscriber's run, when it was read. */
955
- namespace?: string | undefined;
956
- /** When an `owed` subscriber became owed: the settled run's last update (epoch ms). */
957
- owedSince?: number | undefined;
958
- /**
959
- * When the lifecycle sweep drops an `owed` subscriber that no live instance registers or
960
- * announces for the run's namespace (epoch ms; see {@link LIFECYCLE_ORPHAN_MS}). Absent while one
961
- * does.
962
- */
963
- orphanAt?: number | undefined;
964
- /**
965
- * Why a `failed` subscriber did not start, when the caller knows it (the run's tags record only
966
- * that it failed; the `run.trigger_failed` event carries the message). {@link lifecycleDeliveriesOf}
967
- * leaves it unset.
968
- */
969
- error?: string | undefined;
970
- }
971
- /**
972
- * The {@link LifecycleDelivery} of each subscriber of a settled run, sorted by subscriber: the
973
- * union of `subscribers` (the ones the run's event goes to now) and the owed, triggered, coalesced
974
- * and trigger-failed tags. `live` names the subscribers a live instance registers or announces; an owed subscriber
975
- * outside it gets `orphanAt`. `coalesced` maps each subscriber that coalesces its events to its
976
- * accumulator run id (undefined when it cannot be derived). Empty for a run that has not settled.
977
- */
978
- declare function lifecycleDeliveriesOf(run: Pick<WorkflowRun, 'id' | 'status' | 'tags' | 'updatedAt'>, opts: {
979
- subscribers: readonly string[];
980
- live: ReadonlySet<string>;
981
- coalesced?: ReadonlyMap<string, string | undefined> | undefined;
982
- }): LifecycleDelivery[];
983
- /** The trace id of a W3C `traceparent` (`00-<trace id>-<span id>-<flags>`), or undefined. */
984
- declare function traceIdOfTraceparent(traceparent: string | undefined): string | undefined;
985
-
986
1012
  /**
987
1013
  * One loaded copy of this package: its version and the real path of its package root. Two copies are
988
1014
  * the same when their roots are, so the `src` and `dist` builds of one checkout, the ESM and CJS
@@ -1824,6 +1850,282 @@ declare function codeAndDetails(err: unknown): {
1824
1850
  details?: unknown;
1825
1851
  };
1826
1852
 
1853
+ /**
1854
+ * A schedule definition — what `engine.schedules.create/upsert` take. Temporal-style: a persisted,
1855
+ * runtime-managed recurring start of `workflow` with `input`, fired by every driving engine's timer
1856
+ * poll (safe with many workers: each window's run id is deterministic, `start` is idempotent, and
1857
+ * advancing the schedule is a compare-and-set).
1858
+ */
1859
+ interface ScheduleOptions {
1860
+ /** Stable id, unique per store (e.g. `digest:user-42`). Part of every run id it starts. */
1861
+ id: string;
1862
+ /** The workflow to start — a registered name or `@Workflow` class. */
1863
+ workflow: WorkflowRef;
1864
+ /** The input every run starts with. */
1865
+ input?: unknown;
1866
+ /** Cron expression (5 fields, or 6 with leading seconds). Needs the `cron-parser` peer. */
1867
+ cron?: string | undefined;
1868
+ /** Fixed interval (`'15m'`, or ms), windows aligned to the epoch. Exclusive with `cron`. */
1869
+ every?: string | number | undefined;
1870
+ /**
1871
+ * An RFC 5545 recurrence rule (`'FREQ=WEEKLY;BYDAY=MO;BYHOUR=8'`, optionally with a
1872
+ * `DTSTART:…` line), evaluated in `timezone`. Exactly one of `cron`, `every` and `rrule`. See
1873
+ * {@link parseRRule} for the supported parts. No peer needed.
1874
+ */
1875
+ rrule?: string | undefined;
1876
+ /** IANA timezone the cron / rrule is evaluated in (e.g. `America/Sao_Paulo`). Default UTC. */
1877
+ timezone?: string | undefined;
1878
+ /**
1879
+ * Delay each fire by up to this much (`'30s'` or ms) — a stable per-(schedule, window) offset, so
1880
+ * thousands of schedules on the same cron don't all start in the same second.
1881
+ */
1882
+ jitter?: string | number | undefined;
1883
+ /**
1884
+ * The previous run of this schedule is still in flight when the next window comes due:
1885
+ * `'allow'` (default) starts the new one anyway; `'skip'` skips that window.
1886
+ */
1887
+ overlap?: 'allow' | 'skip' | undefined;
1888
+ /**
1889
+ * Windows missed while nothing polled (all schedulers down): `'latest'` (default) fires the most
1890
+ * recent missed window once; `'skip'` drops them and waits for the next window. Never more than one
1891
+ * catch-up run per schedule.
1892
+ */
1893
+ catchup?: 'latest' | 'skip' | undefined;
1894
+ /** Create paused (never due until `resume`). On `upsert`, omit to keep the current paused state. */
1895
+ paused?: boolean | undefined;
1896
+ /** Free-form note shown with the schedule (why it exists / why it's paused). */
1897
+ note?: string | undefined;
1898
+ /** Namespace of the schedule and of the runs it starts. Defaults to the engine's own namespace. */
1899
+ namespace?: string | undefined;
1900
+ /** Labels to find the schedule by — also stamped on every run it starts (plus `schedule:<id>`). */
1901
+ tags?: string[] | undefined;
1902
+ /** Search attributes stamped on every run it starts. */
1903
+ searchAttributes?: SearchAttributes | undefined;
1904
+ /** Dispatch priority for the runs it starts. */
1905
+ priority?: number | undefined;
1906
+ /**
1907
+ * A start-time concurrency quota applied to every run it starts (see `StartOptions.concurrency`):
1908
+ * a window whose start would exceed it is recorded as the schedule's `lastError` and skipped, and
1909
+ * the schedule moves on to its next window.
1910
+ */
1911
+ concurrency?: ConcurrencyQuota | undefined;
1912
+ /**
1913
+ * The customer the schedule belongs to; every run it starts inherits it. An explicit value wins
1914
+ * (`null` = none); omit it and the schedule takes the context tenant when tenancy is on. On
1915
+ * `upsert`, omit to keep the schedule's current tenant.
1916
+ */
1917
+ tenantId?: string | null | undefined;
1918
+ /** The kind of {@link tenantId}. Only read with an explicit `tenantId`. */
1919
+ tenantKind?: string | undefined;
1920
+ }
1921
+ /** A schedule as `engine.schedules.get/list` describe it. */
1922
+ interface ScheduleDescription {
1923
+ id: string;
1924
+ workflow: string;
1925
+ input: unknown;
1926
+ namespace: string;
1927
+ cron?: string | undefined;
1928
+ everyMs?: number | undefined;
1929
+ rrule?: string | undefined;
1930
+ timezone?: string | undefined;
1931
+ jitterMs?: number | undefined;
1932
+ overlap: 'allow' | 'skip';
1933
+ catchup: 'latest' | 'skip';
1934
+ paused: boolean;
1935
+ note?: string | undefined;
1936
+ tags?: string[] | undefined;
1937
+ searchAttributes?: SearchAttributes | undefined;
1938
+ priority?: number | undefined;
1939
+ concurrency?: ConcurrencyQuota | undefined;
1940
+ /** When it is next due (jitter included), or null if it never fires again / paused. */
1941
+ nextFireAt: Date | null;
1942
+ /** The last window it fired for, and the run that window started. */
1943
+ lastFireAt?: Date | undefined;
1944
+ lastRunId?: string | undefined;
1945
+ /** How many windows it has fired (manual triggers excluded). */
1946
+ fires: number;
1947
+ /** The last start failure (e.g. a concurrency limit), cleared by the next successful start. */
1948
+ lastError?: string | undefined;
1949
+ /** The customer the schedule and its runs belong to, when it has one. */
1950
+ tenantId?: string | undefined;
1951
+ tenantKind?: string | undefined;
1952
+ /**
1953
+ * Set on a schedule a tenant app ANNOUNCED (its `schedules` module option) and the control plane
1954
+ * adopted: the key the app declares it under. Its `namespace` is the app (partition).
1955
+ */
1956
+ announcedKey?: string | undefined;
1957
+ /** An announced schedule that no live worker of its app announces any more: since when. */
1958
+ unannouncedSince?: Date | undefined;
1959
+ /** When the control plane paused it for staying unannounced past the grace period. */
1960
+ withdrawnAt?: Date | undefined;
1961
+ createdAt: Date;
1962
+ updatedAt: Date;
1963
+ }
1964
+ /** The tag on every schedule adopted from a tenant's announcement (and on the runs it starts). */
1965
+ declare const ANNOUNCED_SCHEDULE_TAG = "schedule:announced";
1966
+ /** The control plane's schedule id for the schedule `key` announced by the app on `namespace`. */
1967
+ declare function announcedScheduleId(namespace: string, key: string): string;
1968
+ /** Filter for `engine.schedules.list`. */
1969
+ type ScheduleListQuery = Omit<ScheduleQuery, 'dueBy'>;
1970
+ /** Thrown by `engine.schedules.create` when the id is taken (use `upsert` to replace). */
1971
+ declare class ScheduleAlreadyExistsError extends Error {
1972
+ readonly scheduleId: string;
1973
+ constructor(scheduleId: string);
1974
+ }
1975
+ /** Thrown by `engine.schedules.*` on an id that doesn't exist. */
1976
+ declare class ScheduleNotFoundError extends Error {
1977
+ readonly scheduleId: string;
1978
+ constructor(scheduleId: string);
1979
+ }
1980
+ /** What {@link ScheduleClient.syncAnnounced} did to a namespace's adopted schedules. */
1981
+ interface AnnouncedScheduleSync {
1982
+ /** Created, or re-applied because the announced definition changed. */
1983
+ adopted: string[];
1984
+ /** Announced again after missing (and resumed, when it had been withdrawn). */
1985
+ restored: string[];
1986
+ /** Missing from the announcement for the first time: the grace period starts. */
1987
+ missing: string[];
1988
+ /** Paused because it stayed unannounced past the grace period. */
1989
+ withdrawn: string[];
1990
+ /** Announced, but the definition does not evaluate (bad cron, both or neither cadence). */
1991
+ invalid: {
1992
+ key: string;
1993
+ error: string;
1994
+ }[];
1995
+ }
1996
+ /** The engine surface the schedule client drives. */
1997
+ interface ScheduleHost {
1998
+ start(workflow: string, input: unknown, runId: string, opts?: StartOptions): Promise<RunResult>;
1999
+ /**
2000
+ * The tenant start path, used to fire an announced schedule: a workflow no live worker serves yet
2001
+ * is parked `blocked` (`no_live_worker`) until one is, instead of throwing. Absent = `start`.
2002
+ */
2003
+ startParked?(workflow: string, input: unknown, runId: string, opts?: StartOptions, singleton?: StartRunSingleton): Promise<RunResult>;
2004
+ getRun(runId: string): Promise<WorkflowRun | null>;
2005
+ /** True once the engine has begun shutting down; `tick` fires nothing more after that. */
2006
+ isDraining?(): boolean;
2007
+ /** The context tenant to stamp on a schedule created now (tenancy on), else undefined. */
2008
+ tenant?(): RunTenant | undefined;
2009
+ /** The tenancy matching filter for an app-facing call made now. Absent = sees everything. */
2010
+ tenantFilter?(): TenantFilter;
2011
+ }
2012
+ /** Engine-level knobs for the client. */
2013
+ interface ScheduleClientOptions {
2014
+ /** The engine's namespace: the default for new schedules, and which ones `tick` fires. */
2015
+ namespace?: string | undefined;
2016
+ clock?: (() => number) | undefined;
2017
+ }
2018
+ /**
2019
+ * Persisted, runtime-managed schedules — `engine.schedules`. Unlike the code-registered
2020
+ * `schedules` module option, these live in the store: create/update/pause/delete them at runtime
2021
+ * (one per user, per tenant, per automation…), and every driving engine's timer poll fires the due
2022
+ * ones via {@link tick}.
2023
+ *
2024
+ * Multi-worker safety comes from two properties, not from a lock: a window's run id is deterministic
2025
+ * (`sched:<id>:<windowMs>`), so racing starts of the same window collapse into one run; and a
2026
+ * schedule is advanced with a compare-and-set on its `nextFireAt`, so exactly one poller moves it on.
2027
+ * A crash between starting the run and advancing the schedule just re-fires the (idempotent) start.
2028
+ */
2029
+ declare class ScheduleClient {
2030
+ private readonly store;
2031
+ private readonly host;
2032
+ private readonly options;
2033
+ constructor(store: StateStore, host: ScheduleHost, options?: ScheduleClientOptions);
2034
+ private now;
2035
+ /** Whether the store persists schedules (implements the schedule methods). */
2036
+ get supported(): boolean;
2037
+ private requireStore;
2038
+ private filter;
2039
+ /** The schedule `id` if it exists and the caller may see it (tenancy), else null. */
2040
+ private visible;
2041
+ /** Create a schedule. Throws {@link ScheduleAlreadyExistsError} if the id is taken. */
2042
+ create(opts: ScheduleOptions): Promise<ScheduleDescription>;
2043
+ /**
2044
+ * Create the schedule, or replace the definition of an existing one (its history — last fire, last
2045
+ * run, fire count — is kept). The next fire is recomputed from now under the new definition, so a
2046
+ * window that already fired is never fired again by an upsert.
2047
+ */
2048
+ upsert(opts: ScheduleOptions): Promise<ScheduleDescription>;
2049
+ /** The schedule `id`, or null (also null for another tenant's schedule). */
2050
+ get(id: string): Promise<ScheduleDescription | null>;
2051
+ /** Schedules matching `query` (and visible to the caller's tenant), soonest-due first. */
2052
+ list(query?: ScheduleListQuery): Promise<ScheduleDescription[]>;
2053
+ /** Delete the schedule. Runs it already started are left alone. Returns whether it existed. */
2054
+ delete(id: string): Promise<boolean>;
2055
+ /** Stop firing until {@link resume}. `note` records why (shown by `get`/`list`). */
2056
+ pause(id: string, note?: string): Promise<ScheduleDescription>;
2057
+ /**
2058
+ * Fire again from the next window after now — the windows skipped while paused are NOT caught up.
2059
+ */
2060
+ resume(id: string): Promise<ScheduleDescription>;
2061
+ /**
2062
+ * Start one run of the schedule right now, outside its cadence (paused or not). The run id is
2063
+ * `sched:<id>:manual:<nowMs>`; it doesn't move the schedule's next fire.
2064
+ */
2065
+ trigger(id: string): Promise<RunResult>;
2066
+ /**
2067
+ * Start one run of `record`: through the tenant start path for an announced schedule (its run waits
2068
+ * `blocked` for a live worker of its app instead of failing), else a plain `start`.
2069
+ */
2070
+ private startFor;
2071
+ /**
2072
+ * Fire every due schedule (in this engine's namespace; all namespaces for an operator engine; only
2073
+ * those carrying `opts.tag` when given):
2074
+ * start its window's run and advance it to the next window. Called by the NestJS timer poller on
2075
+ * each tick when `persistedSchedules` is on; call it yourself from any other driver. Returns the
2076
+ * run ids started (or re-found, for an idempotent re-fire).
2077
+ */
2078
+ tick(nowMs?: number, opts?: {
2079
+ tag?: string;
2080
+ }): Promise<string[]>;
2081
+ /**
2082
+ * When {@link tick} next has a schedule to fire, if one is due by `byMs`: the earliest `nextFireAt`
2083
+ * of the unpaused schedules (of this engine's namespace, carrying `opts.tag` when given) due by
2084
+ * then, else `undefined`. One indexed
2085
+ * read (the due-schedule scan `tick` makes, with a later bound and a limit of one). A store that
2086
+ * does not persist schedules has none.
2087
+ */
2088
+ nextFireAt(byMs: number, opts?: {
2089
+ tag?: string;
2090
+ }): Promise<number | undefined>;
2091
+ /** Fire one due schedule and advance it. Returns the run id started, if any. */
2092
+ private fire;
2093
+ /**
2094
+ * An announced schedule whose previous run is still parked waiting for a live worker of its app
2095
+ * (the app is down): this window is folded into that run instead of parking one more. However long
2096
+ * the app is down, it finds at most one run per schedule waiting when it comes back, the same
2097
+ * bound `catchup: 'latest'` puts on windows missed while no scheduler polled.
2098
+ */
2099
+ private waitingForWorker;
2100
+ /**
2101
+ * Reconcile the schedules adopted from one app (`namespace`) with what its LIVE workers announce
2102
+ * now (`items`, one per key; the caller resolved disagreeing workers). The rule:
2103
+ * - an announced key with no schedule yet is created (id {@link announcedScheduleId}, tagged
2104
+ * {@link ANNOUNCED_SCHEDULE_TAG}, `catchup: 'latest'`); one whose definition changed is
2105
+ * re-applied like `upsert` (its history kept, its next fire recomputed from now). An equal
2106
+ * definition writes nothing, so any number of replicas announcing the same set is a no-op;
2107
+ * - a pause or resume made from the console survives: a re-applied definition keeps the current
2108
+ * paused state, unless the app's own declared `paused` changed;
2109
+ * - an adopted schedule the app no longer announces is marked missing, and paused ("withdrawn")
2110
+ * once it has stayed missing for `graceMs`. It is never deleted: its history stays, and an app
2111
+ * that announces it again (a rollback) gets it back, resumed unless an operator had paused it.
2112
+ *
2113
+ * Call it only for an app that has at least one live worker stating its schedules: with none (the
2114
+ * app is down, or runs an SDK that does not announce schedules), nothing is withdrawn, and its
2115
+ * schedules keep firing into runs that wait for a worker.
2116
+ */
2117
+ syncAnnounced(namespace: string, items: readonly AnnouncedSchedule[], opts: {
2118
+ nowMs?: number;
2119
+ graceMs: number;
2120
+ }): Promise<AnnouncedScheduleSync>;
2121
+ /** `overlap: 'skip'` and the previous run of this schedule is still in flight. */
2122
+ private overlapping;
2123
+ private mustGet;
2124
+ /** Explicit `opts.tenantId` → the existing schedule's tenant (upsert) → the context tenant → none. */
2125
+ private scheduleTenant;
2126
+ private write;
2127
+ }
2128
+
1827
2129
  /** Default idle threshold for a stranded run: 15 minutes. */
1828
2130
  declare const DEFAULT_STALLED_AFTER_MS: number;
1829
2131
  /** The oldest unresolved remote step of a run — the lost-dispatch signature when it is old. */
@@ -2099,6 +2401,12 @@ declare const VERSION_UNDECLARED_TAG = "version:undeclared";
2099
2401
  * consumer boots. Cancel it to drop it.
2100
2402
  */
2101
2403
  declare const NO_LIVE_WORKER = "no_live_worker";
2404
+ /**
2405
+ * How long an adopted tenant schedule may go unannounced by every live worker of its app before the
2406
+ * control plane pauses it (see `WorkflowEngine.syncAnnouncedSchedules`). Long enough to ride out a
2407
+ * rolling deploy; a schedule is never deleted for missing.
2408
+ */
2409
+ declare const DEFAULT_ANNOUNCED_SCHEDULE_GRACE_MS: number;
2102
2410
  interface WorkflowEngineDeps {
2103
2411
  store: StateStore;
2104
2412
  /** A single task transport. Shorthand for a one-entry `transports` pool (id `default`). */
@@ -2422,6 +2730,10 @@ declare class WorkflowEngine {
2422
2730
  private readonly remoteRedispatchMax;
2423
2731
  /** How long a `blocked` run waits before the recovery poll re-checks the live fleet (design §7.5). */
2424
2732
  private readonly blockedPollMs;
2733
+ /** Verifies the wire tenant of a start-run, and of a worker's schedule announcement. */
2734
+ private readonly verifyTenant;
2735
+ /** Wire tenants whose schedule announcement failed verification, warned about once. */
2736
+ private readonly rejectedScheduleTenants;
2425
2737
  private readonly workerDescriptorCacheMs;
2426
2738
  private readonly descriptorCache;
2427
2739
  /** This engine's control-plane handshake descriptor — negotiated against each worker (design §7.3). */
@@ -2627,11 +2939,13 @@ declare class WorkflowEngine {
2627
2939
  * The earliest known time (epoch ms) the poll has work, if it is at or before `byMs`: this
2628
2940
  * namespace's next due timer (`listDueTimers` up to `byMs`, limit one: it returns the most overdue
2629
2941
  * first), the next `blocked` run's recovery poll, and with `persistedSchedules` the next persisted
2630
- * schedule to fire (see {@link ScheduleClient.nextFireAt}). `undefined` when nothing is due by
2942
+ * schedule to fire (see {@link ScheduleClient.nextFireAt}; with `announcedSchedules` alone, the next
2943
+ * schedule adopted from a tenant). `undefined` when nothing is due by
2631
2944
  * then. A poller reads it before waiting longer than its tick, so the wait never outlasts a timer.
2632
2945
  */
2633
2946
  nextDueAt(byMs: number, opts?: {
2634
2947
  persistedSchedules?: boolean;
2948
+ announcedSchedules?: boolean;
2635
2949
  }): Promise<number | undefined>;
2636
2950
  /**
2637
2951
  * Pick up a run another instance announced as enqueued: run it here if it is still `pending`.
@@ -2921,6 +3235,20 @@ declare class WorkflowEngine {
2921
3235
  */
2922
3236
  listStalledRuns(options?: ListStalledRunsOptions): Promise<StalledRunInfo[]>;
2923
3237
  private notifyDead;
3238
+ /**
3239
+ * The dead-letter workflow the live workers serving `run`'s workflow announce (a tenant's inline
3240
+ * `@DeadLetter()` handler, its `deadLetterWorkflow`, or its module-level default), or `undefined`
3241
+ * when the workflow is registered on this engine (its own routing applies), they announce none, or
3242
+ * they cannot be read. A dead-letter listener with a catch-all default (`DurableModule`'s
3243
+ * `deadLetterWorkflow`) checks it first, so the app's own route wins over the default.
3244
+ */
3245
+ announcedDeadLetter(run: WorkflowRun): Promise<string | undefined>;
3246
+ /**
3247
+ * Start the announced dead-letter workflow of a dead run (see {@link announcedDeadLetter}) in the
3248
+ * run's namespace, as `dlq:<runId>` with the `DeadLetter` payload, through the tenant start path:
3249
+ * with no live worker of the app it waits `blocked` instead of being lost. Idempotent by run id.
3250
+ */
3251
+ private routeAnnouncedDeadLetter;
2924
3252
  /**
2925
3253
  * Emit a locally-produced lifecycle event: deliver to subscribers AND broadcast it on the control
2926
3254
  * plane so other instances (e.g. a dashboard pod) can live-tail this run. A `run.completed` or
@@ -3281,6 +3609,32 @@ declare class WorkflowEngine {
3281
3609
  * redelivery is a no-op once the run exists (idempotent by run id).
3282
3610
  */
3283
3611
  startForTenant(message: StartRunMessage, namespace: string, tenant: Pick<StartOptions, 'tenantId' | 'tenantKind'>): Promise<RunResult>;
3612
+ /**
3613
+ * The control plane's half of a tenant's `signalWithStart` (a `signalWithStart` run request):
3614
+ * start `start` like {@link startForTenant} unless its run exists, then signal `signal.token`.
3615
+ * Authorization is the caller's (the run-request responder): the run must belong to `namespace`,
3616
+ * and so must a run already waiting on the token. Delivered at once to a waiting run; with none
3617
+ * waiting yet it is buffered only when the token contains the run id (a run-scoped token), so a
3618
+ * tenant can never plant a payload for a wait another namespace opens later. `signalled: false`
3619
+ * when it was neither delivered nor buffered.
3620
+ */
3621
+ signalWithStartForTenant(start: StartRunMessage & {
3622
+ runId: string;
3623
+ }, namespace: string, tenant: Pick<StartOptions, 'tenantId' | 'tenantKind'>, signal: {
3624
+ token: string;
3625
+ payload?: unknown;
3626
+ }): Promise<{
3627
+ runId: string;
3628
+ signalled: boolean;
3629
+ }>;
3630
+ /**
3631
+ * The control plane's half of a tenant's `publishEvent` (a `publishEvent` run request): resume the
3632
+ * runs of `namespace` waiting on event `name` whose match the payload satisfies. Starting the
3633
+ * tenant's own subscribers is the tenant's (it holds their `where` and `input`); nothing is
3634
+ * buffered, since a buffered event could reach another namespace's later wait. Returns how many
3635
+ * runs it resumed.
3636
+ */
3637
+ publishEventForTenant(name: string, payload: unknown, namespace: string): Promise<number>;
3284
3638
  /** A tenant start {@link startForTenant} could not admit, kept as a `failed` run with the reason. */
3285
3639
  private recordRejectedStart;
3286
3640
  /**
@@ -3449,6 +3803,15 @@ declare class WorkflowEngine {
3449
3803
  * liveness changes between calls, exactly as {@link synthesizeRemoteChild} does.
3450
3804
  */
3451
3805
  private resolveRemoteByConvention;
3806
+ /**
3807
+ * The registration the live workers of `group` announce for `workflow` (at `version`, when one of
3808
+ * them states it): where they disagree (a rolling deploy), the one from the worker that started
3809
+ * last, as for announced schedules. `undefined` when none announces it, `null` when the read
3810
+ * failed (what the workers state is then unknown, not "nothing"). Reads
3811
+ * through the descriptor cache ({@link workerDescriptorCacheMs}), so a turn costs no extra round
3812
+ * trip in steady state.
3813
+ */
3814
+ private announcedRegistration;
3452
3815
  /**
3453
3816
  * The version the LIVE fleet declares for `workflow` on `group`, or `undefined` when it declares
3454
3817
  * none — which is a fact about the fleet, not a failure to read it.
@@ -3558,6 +3921,24 @@ declare class WorkflowEngine {
3558
3921
  * child: one unreachable child must not abort the sweep and leave every LATER timed-out run alive.
3559
3922
  */
3560
3923
  sweepTimeouts(now?: number): Promise<void>;
3924
+ /**
3925
+ * The singleton limit last resolved for a workflow served by convention, by `<namespace>\0<name>`
3926
+ * (see {@link resolveRemoteByConvention}): what the singleton gate's release wake-up reads, since
3927
+ * it cannot wait on the fleet. One entry per convention singleton the fleet serves.
3928
+ */
3929
+ private readonly conventionSingletonLimits;
3930
+ /** The last read of the announced execution timeouts (see {@link announcedTimeouts}). */
3931
+ private announcedTimeoutsRead;
3932
+ /**
3933
+ * The `executionTimeoutMs` live workers announce (`@Workflow({ executionTimeout })` on a tenant),
3934
+ * per workflow and namespace, for workflows this engine does not register (a registration here
3935
+ * applies its own). Where workers disagree, the one that started last wins. Read at most once per
3936
+ * {@link ANNOUNCED_TIMEOUTS_TTL_MS}; empty without a transport that reads the fleet, or when the
3937
+ * read fails.
3938
+ */
3939
+ private announcedTimeouts;
3940
+ /** Cancel (`execution_timeout`) the in-flight runs of `workflow` in `namespace` created before `deadline`. */
3941
+ private cancelTimedOut;
3561
3942
  /**
3562
3943
  * Resume every run left incomplete by a crash or deploy. Called on boot. Completed steps
3563
3944
  * replay from their checkpoints, so only the work that had not finished runs again.
@@ -4141,6 +4522,23 @@ declare class WorkflowEngine {
4141
4522
  *
4142
4523
  * Workflows only, and deliberately: see the "steps are out of scope" note in `handshake/announced`.
4143
4524
  */
4525
+ /**
4526
+ * Adopt the schedules tenant apps announce (their `schedules` module option, carried on their live
4527
+ * workers' descriptors) as persisted schedules, and withdraw the ones an app stopped announcing.
4528
+ * The control plane's timer poll calls it; {@link ScheduleClient.tick} fires them.
4529
+ *
4530
+ * Per app (the namespace its announcement's verified `tenant` maps to, as for a start-run): the
4531
+ * schedules announced by its live workers, where two workers disagree on a key the one that
4532
+ * started last (its deploy is the newer one) wins. An app with no live worker that states its
4533
+ * schedules is left alone, so its schedules keep firing into runs that wait for a worker. See
4534
+ * {@link ScheduleClient.syncAnnounced} for the reconciliation rule and `graceMs` (default 10
4535
+ * minutes). A namespaced engine adopts only its own namespace's. Nothing without a store that
4536
+ * persists schedules or a transport that reads worker descriptors.
4537
+ */
4538
+ syncAnnouncedSchedules(opts?: {
4539
+ graceMs?: number;
4540
+ nowMs?: number;
4541
+ }): Promise<Map<string, AnnouncedScheduleSync>>;
4144
4542
  announcedWorkflows(): Promise<AnnouncedWorkflow[]>;
4145
4543
  /**
4146
4544
  * {@link announcedWorkflows}, plus the thing a list of workflows can never say: why it is the
@@ -4819,246 +5217,106 @@ declare class WorkflowEngine {
4819
5217
  *
4820
5218
  * THROTTLED exactly as {@link rearmStepLease} is, and for the same reason: a long workflow turn's
4821
5219
  * worker beats every couple of seconds, and each beat otherwise cost a `getRun` + `updateRun`.
4822
- * The window here is `remoteAdvanceSilenceMs`, and a renewal buys at most one of them — so it is
4823
- * only worth a write once the window is half spent, which leaves a full half-window of headroom
4824
- * before the timer poller would re-drive the turn. The in-memory mark is a pure optimisation: a
4825
- * cold (or different) instance re-derives the same answer from the run's own `wakeAt`.
4826
- */
4827
- private rearmDecisionDeadline;
4828
- /**
4829
- * A slot freed on `queue` (a fleet-wide signal): resume this instance's runs blocked on it so they
4830
- * re-contend now instead of at their retry tick. Snapshot-and-clear — a run still blocked after the
4831
- * retry re-registers itself, and one that's gone (cancelled/admitted) is dropped. Best-effort.
4832
- */
4833
- private wakeQueueWaiters;
4834
- /** Release the flow-control slot a dispatched step held (if any), by its stepId. */
4835
- private releaseQueueSlot;
4836
- /** In-memory await path for a remote step with a liveness `timeoutMs` (re-dispatch on timeout). */
4837
- private callRemoteInMemory;
4838
- /**
4839
- * Await `resultPromise`, but reject with `onTimeout()` if neither it settles nor a heartbeat for `id`
4840
- * arrives within `timeoutMs`. Each heartbeat (delivered via `transport.onHeartbeat`, looked up in
4841
- * `heartbeatResets` by `id`) REARMS the window, so a worker that keeps beating stays alive past
4842
- * `timeoutMs`. Shared by the remote-STEP liveness (keyed by stepId) and the remote-WORKFLOW advance
4843
- * liveness (keyed by runId); the caller supplies the timeout error and any extra cleanup via `onTimeout`.
4844
- */
4845
- private awaitWithLivenessDeadline;
4846
- /** Remote-STEP liveness: await a worker result, timing out (with the step's pending-map cleanup) to
4847
- * `RemoteStepTimeout` if it neither lands nor beats within `timeoutMs`. See {@link awaitWithLivenessDeadline}. */
4848
- private awaitWithHeartbeat;
4849
- }
4850
- /** Raised inside the workflow when a remote worker reports a step failure. */
4851
- declare class RemoteStepError extends Error {
4852
- readonly stepError?: StepError | undefined;
4853
- constructor(stepError?: StepError);
4854
- }
4855
- /** Checkpoint names that record a parent→child edge: an awaited child, a folded group of them, a spawn. */
4856
- declare const CHILD_EDGE_PREFIXES: string[];
4857
- /** The child run ids a parent's {@link CHILD_EDGE_PREFIXES} checkpoints point at (others are skipped). */
4858
- declare function childIdsOf(checkpoints: StepCheckpoint[]): string[];
4859
-
4860
- /**
4861
- * A schedule definition — what `engine.schedules.create/upsert` take. Temporal-style: a persisted,
4862
- * runtime-managed recurring start of `workflow` with `input`, fired by every driving engine's timer
4863
- * poll (safe with many workers: each window's run id is deterministic, `start` is idempotent, and
4864
- * advancing the schedule is a compare-and-set).
4865
- */
4866
- interface ScheduleOptions {
4867
- /** Stable id, unique per store (e.g. `digest:user-42`). Part of every run id it starts. */
4868
- id: string;
4869
- /** The workflow to start — a registered name or `@Workflow` class. */
4870
- workflow: WorkflowRef;
4871
- /** The input every run starts with. */
4872
- input?: unknown;
4873
- /** Cron expression (5 fields, or 6 with leading seconds). Needs the `cron-parser` peer. */
4874
- cron?: string | undefined;
4875
- /** Fixed interval (`'15m'`, or ms), windows aligned to the epoch. Exclusive with `cron`. */
4876
- every?: string | number | undefined;
4877
- /**
4878
- * An RFC 5545 recurrence rule (`'FREQ=WEEKLY;BYDAY=MO;BYHOUR=8'`, optionally with a
4879
- * `DTSTART:…` line), evaluated in `timezone`. Exactly one of `cron`, `every` and `rrule`. See
4880
- * {@link parseRRule} for the supported parts. No peer needed.
4881
- */
4882
- rrule?: string | undefined;
4883
- /** IANA timezone the cron / rrule is evaluated in (e.g. `America/Sao_Paulo`). Default UTC. */
4884
- timezone?: string | undefined;
4885
- /**
4886
- * Delay each fire by up to this much (`'30s'` or ms) — a stable per-(schedule, window) offset, so
4887
- * thousands of schedules on the same cron don't all start in the same second.
4888
- */
4889
- jitter?: string | number | undefined;
4890
- /**
4891
- * The previous run of this schedule is still in flight when the next window comes due:
4892
- * `'allow'` (default) starts the new one anyway; `'skip'` skips that window.
4893
- */
4894
- overlap?: 'allow' | 'skip' | undefined;
4895
- /**
4896
- * Windows missed while nothing polled (all schedulers down): `'latest'` (default) fires the most
4897
- * recent missed window once; `'skip'` drops them and waits for the next window. Never more than one
4898
- * catch-up run per schedule.
5220
+ * The window here is `remoteAdvanceSilenceMs`, and a renewal buys at most one of them — so it is
5221
+ * only worth a write once the window is half spent, which leaves a full half-window of headroom
5222
+ * before the timer poller would re-drive the turn. The in-memory mark is a pure optimisation: a
5223
+ * cold (or different) instance re-derives the same answer from the run's own `wakeAt`.
4899
5224
  */
4900
- catchup?: 'latest' | 'skip' | undefined;
4901
- /** Create paused (never due until `resume`). On `upsert`, omit to keep the current paused state. */
4902
- paused?: boolean | undefined;
4903
- /** Free-form note shown with the schedule (why it exists / why it's paused). */
4904
- note?: string | undefined;
4905
- /** Namespace of the schedule and of the runs it starts. Defaults to the engine's own namespace. */
4906
- namespace?: string | undefined;
4907
- /** Labels to find the schedule by — also stamped on every run it starts (plus `schedule:<id>`). */
4908
- tags?: string[] | undefined;
4909
- /** Search attributes stamped on every run it starts. */
4910
- searchAttributes?: SearchAttributes | undefined;
4911
- /** Dispatch priority for the runs it starts. */
4912
- priority?: number | undefined;
5225
+ private rearmDecisionDeadline;
4913
5226
  /**
4914
- * A start-time concurrency quota applied to every run it starts (see `StartOptions.concurrency`):
4915
- * a window whose start would exceed it is recorded as the schedule's `lastError` and skipped, and
4916
- * the schedule moves on to its next window.
5227
+ * A slot freed on `queue` (a fleet-wide signal): resume this instance's runs blocked on it so they
5228
+ * re-contend now instead of at their retry tick. Snapshot-and-clear — a run still blocked after the
5229
+ * retry re-registers itself, and one that's gone (cancelled/admitted) is dropped. Best-effort.
4917
5230
  */
4918
- concurrency?: ConcurrencyQuota | undefined;
5231
+ private wakeQueueWaiters;
5232
+ /** Release the flow-control slot a dispatched step held (if any), by its stepId. */
5233
+ private releaseQueueSlot;
5234
+ /** In-memory await path for a remote step with a liveness `timeoutMs` (re-dispatch on timeout). */
5235
+ private callRemoteInMemory;
4919
5236
  /**
4920
- * The customer the schedule belongs to; every run it starts inherits it. An explicit value wins
4921
- * (`null` = none); omit it and the schedule takes the context tenant when tenancy is on. On
4922
- * `upsert`, omit to keep the schedule's current tenant.
5237
+ * Await `resultPromise`, but reject with `onTimeout()` if neither it settles nor a heartbeat for `id`
5238
+ * arrives within `timeoutMs`. Each heartbeat (delivered via `transport.onHeartbeat`, looked up in
5239
+ * `heartbeatResets` by `id`) REARMS the window, so a worker that keeps beating stays alive past
5240
+ * `timeoutMs`. Shared by the remote-STEP liveness (keyed by stepId) and the remote-WORKFLOW advance
5241
+ * liveness (keyed by runId); the caller supplies the timeout error and any extra cleanup via `onTimeout`.
4923
5242
  */
4924
- tenantId?: string | null | undefined;
4925
- /** The kind of {@link tenantId}. Only read with an explicit `tenantId`. */
4926
- tenantKind?: string | undefined;
4927
- }
4928
- /** A schedule as `engine.schedules.get/list` describe it. */
4929
- interface ScheduleDescription {
4930
- id: string;
4931
- workflow: string;
4932
- input: unknown;
4933
- namespace: string;
4934
- cron?: string | undefined;
4935
- everyMs?: number | undefined;
4936
- rrule?: string | undefined;
4937
- timezone?: string | undefined;
4938
- jitterMs?: number | undefined;
4939
- overlap: 'allow' | 'skip';
4940
- catchup: 'latest' | 'skip';
4941
- paused: boolean;
4942
- note?: string | undefined;
4943
- tags?: string[] | undefined;
4944
- searchAttributes?: SearchAttributes | undefined;
4945
- priority?: number | undefined;
4946
- concurrency?: ConcurrencyQuota | undefined;
4947
- /** When it is next due (jitter included), or null if it never fires again / paused. */
4948
- nextFireAt: Date | null;
4949
- /** The last window it fired for, and the run that window started. */
4950
- lastFireAt?: Date | undefined;
4951
- lastRunId?: string | undefined;
4952
- /** How many windows it has fired (manual triggers excluded). */
4953
- fires: number;
4954
- /** The last start failure (e.g. a concurrency limit), cleared by the next successful start. */
4955
- lastError?: string | undefined;
4956
- /** The customer the schedule and its runs belong to, when it has one. */
4957
- tenantId?: string | undefined;
4958
- tenantKind?: string | undefined;
4959
- createdAt: Date;
4960
- updatedAt: Date;
4961
- }
4962
- /** Filter for `engine.schedules.list`. */
4963
- type ScheduleListQuery = Omit<ScheduleQuery, 'dueBy'>;
4964
- /** Thrown by `engine.schedules.create` when the id is taken (use `upsert` to replace). */
4965
- declare class ScheduleAlreadyExistsError extends Error {
4966
- readonly scheduleId: string;
4967
- constructor(scheduleId: string);
4968
- }
4969
- /** Thrown by `engine.schedules.*` on an id that doesn't exist. */
4970
- declare class ScheduleNotFoundError extends Error {
4971
- readonly scheduleId: string;
4972
- constructor(scheduleId: string);
5243
+ private awaitWithLivenessDeadline;
5244
+ /** Remote-STEP liveness: await a worker result, timing out (with the step's pending-map cleanup) to
5245
+ * `RemoteStepTimeout` if it neither lands nor beats within `timeoutMs`. See {@link awaitWithLivenessDeadline}. */
5246
+ private awaitWithHeartbeat;
4973
5247
  }
4974
- /** The engine surface the schedule client drives. */
4975
- interface ScheduleHost {
4976
- start(workflow: string, input: unknown, runId: string, opts?: StartOptions): Promise<RunResult>;
4977
- getRun(runId: string): Promise<WorkflowRun | null>;
4978
- /** True once the engine has begun shutting down; `tick` fires nothing more after that. */
4979
- isDraining?(): boolean;
4980
- /** The context tenant to stamp on a schedule created now (tenancy on), else undefined. */
4981
- tenant?(): RunTenant | undefined;
4982
- /** The tenancy matching filter for an app-facing call made now. Absent = sees everything. */
4983
- tenantFilter?(): TenantFilter;
5248
+ /** Raised inside the workflow when a remote worker reports a step failure. */
5249
+ declare class RemoteStepError extends Error {
5250
+ readonly stepError?: StepError | undefined;
5251
+ constructor(stepError?: StepError);
4984
5252
  }
4985
- /** Engine-level knobs for the client. */
4986
- interface ScheduleClientOptions {
4987
- /** The engine's namespace: the default for new schedules, and which ones `tick` fires. */
5253
+ /** Checkpoint names that record a parent→child edge: an awaited child, a folded group of them, a spawn. */
5254
+ declare const CHILD_EDGE_PREFIXES: string[];
5255
+ /** The child run ids a parent's {@link CHILD_EDGE_PREFIXES} checkpoints point at (others are skipped). */
5256
+ declare function childIdsOf(checkpoints: StepCheckpoint[]): string[];
5257
+
5258
+ /**
5259
+ * One end of a `ctx.waitForRun` wait, as a run detail lists it: the run waited for (`waitsFor`) or
5260
+ * the waiting run (`awaitedBy`), the waiting run's `seq` of the call, and the other run's status and
5261
+ * namespace when it was read.
5262
+ */
5263
+ interface RunWaitLink {
5264
+ runId: string;
5265
+ seq: number;
5266
+ status?: RunStatus | undefined;
4988
5267
  namespace?: string | undefined;
4989
- clock?: (() => number) | undefined;
4990
5268
  }
4991
5269
  /**
4992
- * Persisted, runtime-managed schedules — `engine.schedules`. Unlike the code-registered
4993
- * `schedules` module option, these live in the store: create/update/pause/delete them at runtime
4994
- * (one per user, per tenant, per automation…), and every driving engine's timer poll fires the due
4995
- * ones via {@link tick}.
4996
- *
4997
- * Multi-worker safety comes from two properties, not from a lock: a window's run id is deterministic
4998
- * (`sched:<id>:<windowMs>`), so racing starts of the same window collapse into one run; and a
4999
- * schedule is advanced with a compare-and-set on its `nextFireAt`, so exactly one poller moves it on.
5000
- * A crash between starting the run and advancing the schedule just re-fires the (idempotent) start.
5270
+ * Where a settled run's lifecycle event stands for one subscriber:
5271
+ * - `started`: its run exists (`runId`, a `durable:triggered:<subscriber>` tag);
5272
+ * - `owed`: still pending (a `durable:lifecycle:owed:<subscriber>` tag);
5273
+ * - `coalesced`: routed into a debounce/batch accumulator (a `durable:coalesced:<subscriber>` tag,
5274
+ * or the caller's `coalesced` map; `runId` is the accumulator's, when it can be derived);
5275
+ * - `failed`: its start failed (a `durable:trigger_failed:<subscriber>` tag): its `where` threw, its
5276
+ * input was rejected, its start threw, or the sweep dropped it as orphaned. A republish retries it;
5277
+ * - `not-started`: no run and nothing owed: its `where` declined the event, or it subscribed after
5278
+ * the run settled.
5001
5279
  */
5002
- declare class ScheduleClient {
5003
- private readonly store;
5004
- private readonly host;
5005
- private readonly options;
5006
- constructor(store: StateStore, host: ScheduleHost, options?: ScheduleClientOptions);
5007
- private now;
5008
- /** Whether the store persists schedules (implements the schedule methods). */
5009
- get supported(): boolean;
5010
- private requireStore;
5011
- private filter;
5012
- /** The schedule `id` if it exists and the caller may see it (tenancy), else null. */
5013
- private visible;
5014
- /** Create a schedule. Throws {@link ScheduleAlreadyExistsError} if the id is taken. */
5015
- create(opts: ScheduleOptions): Promise<ScheduleDescription>;
5016
- /**
5017
- * Create the schedule, or replace the definition of an existing one (its history — last fire, last
5018
- * run, fire count — is kept). The next fire is recomputed from now under the new definition, so a
5019
- * window that already fired is never fired again by an upsert.
5020
- */
5021
- upsert(opts: ScheduleOptions): Promise<ScheduleDescription>;
5022
- /** The schedule `id`, or null (also null for another tenant's schedule). */
5023
- get(id: string): Promise<ScheduleDescription | null>;
5024
- /** Schedules matching `query` (and visible to the caller's tenant), soonest-due first. */
5025
- list(query?: ScheduleListQuery): Promise<ScheduleDescription[]>;
5026
- /** Delete the schedule. Runs it already started are left alone. Returns whether it existed. */
5027
- delete(id: string): Promise<boolean>;
5028
- /** Stop firing until {@link resume}. `note` records why (shown by `get`/`list`). */
5029
- pause(id: string, note?: string): Promise<ScheduleDescription>;
5030
- /**
5031
- * Fire again from the next window after now — the windows skipped while paused are NOT caught up.
5032
- */
5033
- resume(id: string): Promise<ScheduleDescription>;
5034
- /**
5035
- * Start one run of the schedule right now, outside its cadence (paused or not). The run id is
5036
- * `sched:<id>:manual:<nowMs>`; it doesn't move the schedule's next fire.
5037
- */
5038
- trigger(id: string): Promise<RunResult>;
5280
+ type LifecycleDeliveryState = 'started' | 'owed' | 'coalesced' | 'failed' | 'not-started';
5281
+ /** One subscriber of a settled run's lifecycle event, as the run detail lists it. */
5282
+ interface LifecycleDelivery {
5283
+ subscriber: string;
5284
+ state: LifecycleDeliveryState;
5285
+ /** The subscriber's run when `started`; the accumulator run when `coalesced` and derivable. */
5286
+ runId?: string | undefined;
5287
+ /** The status of a `started` subscriber's run, when it was read. */
5288
+ status?: RunStatus | undefined;
5289
+ /** The namespace of a `started` subscriber's run, when it was read. */
5290
+ namespace?: string | undefined;
5291
+ /** When an `owed` subscriber became owed: the settled run's last update (epoch ms). */
5292
+ owedSince?: number | undefined;
5039
5293
  /**
5040
- * Fire every due schedule (in this engine's namespace; all namespaces for an operator engine):
5041
- * start its window's run and advance it to the next window. Called by the NestJS timer poller on
5042
- * each tick when `persistedSchedules` is on; call it yourself from any other driver. Returns the
5043
- * run ids started (or re-found, for an idempotent re-fire).
5294
+ * When the lifecycle sweep drops an `owed` subscriber that no live instance registers or
5295
+ * announces for the run's namespace (epoch ms; see {@link LIFECYCLE_ORPHAN_MS}). Absent while one
5296
+ * does.
5044
5297
  */
5045
- tick(nowMs?: number): Promise<string[]>;
5298
+ orphanAt?: number | undefined;
5046
5299
  /**
5047
- * When {@link tick} next has a schedule to fire, if one is due by `byMs`: the earliest `nextFireAt`
5048
- * of the unpaused schedules (of this engine's namespace) due by then, else `undefined`. One indexed
5049
- * read (the due-schedule scan `tick` makes, with a later bound and a limit of one). A store that
5050
- * does not persist schedules has none.
5300
+ * Why a `failed` subscriber did not start, when the caller knows it (the run's tags record only
5301
+ * that it failed; the `run.trigger_failed` event carries the message). {@link lifecycleDeliveriesOf}
5302
+ * leaves it unset.
5051
5303
  */
5052
- nextFireAt(byMs: number): Promise<number | undefined>;
5053
- /** Fire one due schedule and advance it. Returns the run id started, if any. */
5054
- private fire;
5055
- /** `overlap: 'skip'` and the previous run of this schedule is still in flight. */
5056
- private overlapping;
5057
- private mustGet;
5058
- /** Explicit `opts.tenantId` → the existing schedule's tenant (upsert) → the context tenant → none. */
5059
- private scheduleTenant;
5060
- private write;
5304
+ error?: string | undefined;
5061
5305
  }
5306
+ /**
5307
+ * The {@link LifecycleDelivery} of each subscriber of a settled run, sorted by subscriber: the
5308
+ * union of `subscribers` (the ones the run's event goes to now) and the owed, triggered, coalesced
5309
+ * and trigger-failed tags. `live` names the subscribers a live instance registers or announces; an owed subscriber
5310
+ * outside it gets `orphanAt`. `coalesced` maps each subscriber that coalesces its events to its
5311
+ * accumulator run id (undefined when it cannot be derived). Empty for a run that has not settled.
5312
+ */
5313
+ declare function lifecycleDeliveriesOf(run: Pick<WorkflowRun, 'id' | 'status' | 'tags' | 'updatedAt'>, opts: {
5314
+ subscribers: readonly string[];
5315
+ live: ReadonlySet<string>;
5316
+ coalesced?: ReadonlyMap<string, string | undefined> | undefined;
5317
+ }): LifecycleDelivery[];
5318
+ /** The trace id of a W3C `traceparent` (`00-<trace id>-<span id>-<flags>`), or undefined. */
5319
+ declare function traceIdOfTraceparent(traceparent: string | undefined): string | undefined;
5062
5320
 
5063
5321
  /** A run as returned by the gateway's list — the durable run plus an optional {@link RunWaiting}
5064
5322
  * descriptor the control plane resolves (what a suspended run is parked on), so the dashboard can
@@ -5329,9 +5587,29 @@ declare abstract class RunGateway {
5329
5587
  * Deliver `payload` to the run waiting on `token` (`WorkflowEngine.signal`). Null when no run waits
5330
5588
  * on it. Optional, like {@link listSchedules}.
5331
5589
  */
5332
- signal?(token: string, payload: unknown): Promise<RunResult | null>;
5590
+ signal?(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
5333
5591
  /** The id of the run waiting on signal `token`, or null when none waits on it yet. Optional. */
5334
5592
  signalWaiter?(token: string): Promise<string | null>;
5593
+ /**
5594
+ * A tenant's `signalWithStart` (`WorkflowEngine.signalWithStartForTenant`): start `start` in
5595
+ * `namespace` unless its run exists, then signal it. Optional, like {@link listSchedules}.
5596
+ */
5597
+ signalWithStartForTenant?(start: StartRunMessage & {
5598
+ runId: string;
5599
+ }, namespace: string, clientTenant: Pick<StartOptions, 'tenantId' | 'tenantKind'>, signal: {
5600
+ token: string;
5601
+ payload?: unknown;
5602
+ }): Promise<{
5603
+ runId: string;
5604
+ signalled: boolean;
5605
+ }>;
5606
+ /**
5607
+ * A tenant's `publishEvent`, scoped to `namespace` (`WorkflowEngine.publishEventForTenant`).
5608
+ * Resolves how many runs it resumed or started. Optional, like {@link listSchedules}.
5609
+ */
5610
+ publishEventForTenant?(name: string, payload: unknown, namespace: string, opts?: {
5611
+ id?: string;
5612
+ }): Promise<number>;
5335
5613
  /** Live lifecycle events for one run; returns an unsubscribe fn. Framework-agnostic (no rxjs). */
5336
5614
  abstract subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
5337
5615
  }
@@ -6867,6 +7145,21 @@ interface StartRunMessage {
6867
7145
  * the tenant caller has already returned.
6868
7146
  */
6869
7147
  concurrency?: ConcurrencyQuota | undefined;
7148
+ /**
7149
+ * The workflow's `@Workflow({ singleton })`, evaluated by the starting app against this input: the
7150
+ * serialization key, the limit and the queue depth. A control plane that serves the workflow by
7151
+ * convention (it has no registration of its own, so it cannot evaluate the key) stamps the run
7152
+ * `singleton:<key>` and admits it against `limit`, like a local singleton. A control plane with its
7153
+ * own registration of the workflow applies its own `singleton` instead, and one older than this
7154
+ * field ignores it.
7155
+ */
7156
+ singleton?: StartRunSingleton | undefined;
7157
+ }
7158
+ /** A singleton key the starter evaluated (see {@link StartRunMessage.singleton}). */
7159
+ interface StartRunSingleton {
7160
+ key: string;
7161
+ limit?: number | undefined;
7162
+ maxQueueDepth?: number | undefined;
6870
7163
  }
6871
7164
  /**
6872
7165
  * A tenant worker → control plane read/control request over the shared transport. Enqueued on
@@ -6938,6 +7231,23 @@ type RunRequestKind = {
6938
7231
  kind: 'signal';
6939
7232
  token: string;
6940
7233
  payload: unknown;
7234
+ opts?: SignalOptions | undefined;
7235
+ } | {
7236
+ kind: 'signalWithStart';
7237
+ start: Omit<StartRunMessage, 'tenant'> & {
7238
+ runId: string;
7239
+ };
7240
+ signal: {
7241
+ token: string;
7242
+ payload?: unknown;
7243
+ };
7244
+ } | {
7245
+ kind: 'publishEvent';
7246
+ name: string;
7247
+ payload: unknown;
7248
+ opts?: {
7249
+ id?: string;
7250
+ } | undefined;
6941
7251
  } | {
6942
7252
  kind: 'schedule';
6943
7253
  id: string;
@@ -9967,4 +10277,4 @@ declare function prevRRuleFireMs(rule: ParsedRRule, atMs: number): number | null
9967
10277
  */
9968
10278
  declare function settleResultsWithPlainCalls(store: Pick<StateStore, 'getRun' | 'getCheckpoint'> & Partial<Pick<StateStore, 'getRuns' | 'getCheckpointsForSettle' | 'getCheckpoints' | 'settleCheckpointsIfPending'>>, results: StepResultSettlement[]): Promise<(StepCheckpoint | null)[]>;
9969
10279
 
9970
- export { ACCUMULATOR_SEEN_MAX, ANY_WAIT_GROUP, type AccumulatorHost, type AccumulatorStartOptions, 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 AttributedEngineEvent, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, type BufferedSignalRow, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CORE_ORIGIN, 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, type ConsoleCapabilities, type ConsoleFederation, 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, DuplicateDurableCopyError, type DurableCopy, 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, type EngineTenancy, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, type EventSubscription, 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, InMemoryRunQueue, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, LIFECYCLE_COALESCED_TAG_PREFIX, LIFECYCLE_HEAL_WINDOW_MS, LIFECYCLE_ORPHAN_MS, LIFECYCLE_OWED_TAG_PREFIX, LIFECYCLE_PENDING_TAG, LIFECYCLE_REGISTRY_HEARTBEAT_MS, LIFECYCLE_REGISTRY_STALE_MS, LIFECYCLE_REGISTRY_TAG, LIFECYCLE_REGISTRY_TTL_MS, LIFECYCLE_REGISTRY_WORKFLOW, LIFECYCLE_TRACE_TAG_PREFIX, LIFECYCLE_TRIGGERED_TAG_PREFIX, LIFECYCLE_TRIGGER_FAILED_TAG_PREFIX, type LifecycleDelivery, type LifecycleDeliveryState, type LifecycleEventOf, type LifecycleKind, type LifecycleRegistryEntry, type LifecycleSource, type LifecycleSubscriptionLink, type ListStalledRunsOptions, type MetricsCollector, type MetricsSnapshot, NO_LIVE_WORKER, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OnEventEntry, type OwnedLeaseReclaim, PARENT_CLOSE_TAG_PREFIX, type ParentClosePolicy, type ParsedRRule, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, REMOTE_EVENT, RUN_HISTORY_FIXTURE_VERSION, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, RUN_WAIT_TOKEN_PREFIX, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RepublishLifecycleResult, type RepublishLifecycleTarget, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAppAttribution, RunAppStamper, type RunAppTopologyOptions, type RunAttributeRow, type RunConsumerOptions, type RunDetail, type RunDetailOptions, type RunDispatch, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunQueueOptions, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunTenant, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaitLink, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_LOCK_CHUNK, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, type ScheduleAction, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduleTickEngine, type ScheduledWorkflow, type SchemaIssue, type SchemaValidationCode, SchemaValidationError, type SearchAttributes, type SearchAttributesSchema, type Settled, type SignalOptions, 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 StepResultSettlement, type StepScope, type StepSettlement, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type TenantFilter, type TenantRow, type TenantTokenSource, type TenantVerifier, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, type VerifiedTenant, WORKFLOW_NAME_KEY, type WaitAnyCondition, type WaitAnyOutcome, type WaitAnyResult, type WaitCondition, type WaitConditionSpec, type WaitForRunOptions, 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 WorkflowLifecycleEvent, type WorkflowLifecycleLinks, WorkflowNotRegistered, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, acceptingSubscription, accumulatorRunId, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, anyCheckpointName, applyAttributeQuery, assertConcurrency, assertRoutes, assertSingleDurableCopy, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, bufferedEventReaches, buildWorkflowDirectory, canRoute, capableWorkers, carriesLifecyclePending, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, coalescedSubscribersOf, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneAttribution, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, durableCopies, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, extendEtag, facetOrigin, fanPageBounds, fanPageEtag, findStalledRuns, foldedCount, getRunsByIds, grantsClientTenant, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, hmacTenantVerifier, indexWaitersByRun, info, inheritTenant, isAnyCheckpoint, isAnyMember, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isLifecycleTag, isNonEmptyRunScope, isRemoteEvent, isWorkflowControlFlowSignal, legacySingletonHolders, lifecycleDeliveriesOf, lifecycleEventName, lifecycleEventOf, lifecycleKindOf, lifecycleRegistryNamespace, lifecycleRegistryRunId, lifecycleRegistrySubscriptions, lifecycleRunId, lifecycleSourceOf, lifecycleTraceparentOf, listSignalWaitersOfRuns, liveHandoff, log, markRemoteEvent, matchesAttributes, matchesTenantPredicates, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, nextRRuleFireMs, nextScheduleFireAt, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, owedSubscribersOf, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseLifecycleEvent, parseRRule, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, prevRRuleFireMs, queryCheckpointsOf, readBufferedEvent, readRunsByIds, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, resolveTenantToken, resolveWireTenant, retentionKeeps, retiredHandoffName, routeFor, rowTenant, runCompletedEvent, runDetailEtag, runDurableExecution, runFailedEvent, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runTraceId, runValueFacetsFromRuns, runWaitPrefix, runWaitTargetOf, runWaitToken, sanitizeQueueToken, scheduleRunIdAt, scheduledRunId, scopeBufferedEvent, scopeTenantQuery, sealDurableCopies, settleResultsWithPlainCalls, signTenantToken, singletonAdmissionDenialPatch, singletonAdmissionTags, singletonClaimantIds, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantAppOf, tenantGroup, tenantIdsFor, tenantVisible, toEventSubscription, traceIdOfTraceparent, triggerFailedSubscribersOf, triggeredRunsOf, triggeredSubscribersOf, useDurableExecution, verifyWireTenant, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
10280
+ export { ACCUMULATOR_SEEN_MAX, ANNOUNCED_SCHEDULE_TAG, ANY_WAIT_GROUP, type AccumulatorHost, type AccumulatorStartOptions, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedSchedule, type AnnouncedScheduleSync, type AnnouncedWorkflow, type AnnouncedWorkflowOptions, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type AttributedEngineEvent, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, type BufferedSignalRow, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CORE_ORIGIN, 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, type ConsoleCapabilities, type ConsoleFederation, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_ANNOUNCED_SCHEDULE_GRACE_MS, 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, DuplicateDurableCopyError, type DurableCopy, 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, type EngineTenancy, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, type EventSubscription, 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, InMemoryRunQueue, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, LIFECYCLE_COALESCED_TAG_PREFIX, LIFECYCLE_HEAL_WINDOW_MS, LIFECYCLE_ORPHAN_MS, LIFECYCLE_OWED_TAG_PREFIX, LIFECYCLE_PENDING_TAG, LIFECYCLE_REGISTRY_HEARTBEAT_MS, LIFECYCLE_REGISTRY_STALE_MS, LIFECYCLE_REGISTRY_TAG, LIFECYCLE_REGISTRY_TTL_MS, LIFECYCLE_REGISTRY_WORKFLOW, LIFECYCLE_TRACE_TAG_PREFIX, LIFECYCLE_TRIGGERED_TAG_PREFIX, LIFECYCLE_TRIGGER_FAILED_TAG_PREFIX, type LifecycleDelivery, type LifecycleDeliveryState, type LifecycleEventOf, type LifecycleKind, type LifecycleRegistryEntry, type LifecycleSource, type LifecycleSubscriptionLink, type ListStalledRunsOptions, type MetricsCollector, type MetricsSnapshot, NO_LIVE_WORKER, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OnEventEntry, type OwnedLeaseReclaim, PARENT_CLOSE_TAG_PREFIX, type ParentClosePolicy, type ParsedRRule, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, REMOTE_EVENT, RUN_HISTORY_FIXTURE_VERSION, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, RUN_WAIT_TOKEN_PREFIX, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RepublishLifecycleResult, type RepublishLifecycleTarget, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAppAttribution, RunAppStamper, type RunAppTopologyOptions, type RunAttributeRow, type RunConsumerOptions, type RunDetail, type RunDetailOptions, type RunDispatch, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunQueueOptions, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunTenant, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaitLink, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_LOCK_CHUNK, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, type ScheduleAction, ScheduleAlreadyExistsError, type ScheduleAnnouncement, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduleTickEngine, type ScheduledWorkflow, type SchemaIssue, type SchemaValidationCode, SchemaValidationError, type SearchAttributes, type SearchAttributesSchema, type Settled, type SignalOptions, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StalePendingStep, type StalledRunInfo, StandardSchemaV1, type StartOptions, type StartRunMessage, type StartRunSingleton, 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 StepResultSettlement, type StepScope, type StepSettlement, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type TenantFilter, type TenantRow, type TenantTokenSource, type TenantVerifier, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, type VerifiedTenant, WORKFLOW_NAME_KEY, type WaitAnyCondition, type WaitAnyOutcome, type WaitAnyResult, type WaitCondition, type WaitConditionSpec, type WaitForRunOptions, 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 WorkflowLifecycleEvent, type WorkflowLifecycleLinks, WorkflowNotRegistered, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, acceptingSubscription, accumulatorRunId, aggregateAnnouncements, aggregatesCheckpoints, announcedScheduleId, announcementsOf, anyCheckpointName, applyAttributeQuery, assertConcurrency, assertRoutes, assertSingleDurableCopy, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, bufferedEventReaches, buildWorkflowDirectory, canRoute, capableWorkers, carriesLifecyclePending, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, coalescedSubscribersOf, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneAttribution, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, durableCopies, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, extendEtag, facetOrigin, fanPageBounds, fanPageEtag, findStalledRuns, foldedCount, getRunsByIds, grantsClientTenant, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, hmacTenantVerifier, indexWaitersByRun, info, inheritTenant, isAnyCheckpoint, isAnyMember, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isLifecycleTag, isNonEmptyRunScope, isRemoteEvent, isWorkflowControlFlowSignal, legacySingletonHolders, lifecycleDeliveriesOf, lifecycleEventName, lifecycleEventOf, lifecycleKindOf, lifecycleRegistryNamespace, lifecycleRegistryRunId, lifecycleRegistrySubscriptions, lifecycleRunId, lifecycleSourceOf, lifecycleTraceparentOf, listSignalWaitersOfRuns, liveHandoff, log, markRemoteEvent, matchesAttributes, matchesTenantPredicates, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, nextRRuleFireMs, nextScheduleFireAt, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, owedSubscribersOf, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseLifecycleEvent, parseRRule, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, prevRRuleFireMs, queryCheckpointsOf, readBufferedEvent, readRunsByIds, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, resolveTenantToken, resolveWireTenant, retentionKeeps, retiredHandoffName, routeFor, rowTenant, runCompletedEvent, runDetailEtag, runDurableExecution, runFailedEvent, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runTraceId, runValueFacetsFromRuns, runWaitPrefix, runWaitTargetOf, runWaitToken, sanitizeQueueToken, scheduleRunIdAt, scheduledRunId, scopeBufferedEvent, scopeTenantQuery, sealDurableCopies, settleResultsWithPlainCalls, signTenantToken, singletonAdmissionDenialPatch, singletonAdmissionTags, singletonClaimantIds, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantAppOf, tenantGroup, tenantIdsFor, tenantVisible, toEventSubscription, traceIdOfTraceparent, triggerFailedSubscribersOf, triggeredRunsOf, triggeredSubscribersOf, useDurableExecution, verifyWireTenant, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };