@dudousxd/nestjs-durable-core 0.93.0 → 0.95.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.cjs +210 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +96 -3
- package/dist/index.d.ts +96 -3
- package/dist/index.js +206 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3186,6 +3186,18 @@ interface Transport {
|
|
|
3186
3186
|
* taking runs and resolves once the runs in flight have settled. Pair with {@link dispatchRuns}.
|
|
3187
3187
|
*/
|
|
3188
3188
|
onDispatchedRun?(handler: (run: RunDispatch) => Promise<void>, opts: RunConsumerOptions): () => Promise<void>;
|
|
3189
|
+
/**
|
|
3190
|
+
* The live consumers of the run queue `opts` names ({@link onDispatchedRun}): the engine instances
|
|
3191
|
+
* executing this deployment's IN-PROCESS workflow bodies. They take no task queue, so they never
|
|
3192
|
+
* appear in the worker-heartbeat keyspace {@link listWorkerGroups}/{@link groupHealth} read, and a
|
|
3193
|
+
* control plane driving its own workflows looked like it had no worker at all. Kept in a keyspace of
|
|
3194
|
+
* its own on purpose: a worker heartbeat makes its group a target for convention routing and the
|
|
3195
|
+
* workflow directory, and nothing consumes a task queue under these names.
|
|
3196
|
+
*
|
|
3197
|
+
* Optional, like {@link groupHealth}: only a broker transport that can introspect liveness (BullMQ)
|
|
3198
|
+
* implements it. The engine folds the result into {@link WorkflowEngine.workerHealth}.
|
|
3199
|
+
*/
|
|
3200
|
+
liveRunConsumers?(opts?: RunQueueOptions): Promise<WorkerHeartbeat[]>;
|
|
3189
3201
|
/** control plane → tenant worker: publish a correlated {@link RunReply} on `<effectivePrefix>-run-reply`
|
|
3190
3202
|
* (pub/sub; every tenant subscribes and filters by `requestId`). */
|
|
3191
3203
|
publishRunReply?(reply: RunReply): Promise<void>;
|
|
@@ -7368,9 +7380,24 @@ declare class WorkflowEngine {
|
|
|
7368
7380
|
/** Per-group worker health (queue backlog + live worker heartbeats). Covers {@link knownGroups}
|
|
7369
7381
|
* (so a registered group with backlog and ZERO workers still reports — the alert case) UNION the
|
|
7370
7382
|
* groups discovered from live heartbeats (so a local-step group like `pipeline`, not derivable
|
|
7371
|
-
* from registrations, shows once its workers beat)
|
|
7372
|
-
*
|
|
7383
|
+
* from registrations, shows once its workers beat) UNION this engine's in-process workflows while
|
|
7384
|
+
* the run queue has a live consumer (see {@link inProcessWorkflowHealth}). Empty when no transport
|
|
7385
|
+
* can introspect health (only the BullMQ transport implements `groupHealth`). */
|
|
7373
7386
|
workerHealth(extra?: string[]): Promise<GroupHealth[]>;
|
|
7387
|
+
/**
|
|
7388
|
+
* The workflows this deployment executes IN-PROCESS — registered here with a body, so a run of one
|
|
7389
|
+
* is driven by whichever engine instance takes it off the run queue — and the instances consuming
|
|
7390
|
+
* that queue right now. Those instances ARE the workers of these workflows, yet they consume no task
|
|
7391
|
+
* queue and so never wrote a worker heartbeat: a control plane running its own workflows showed
|
|
7392
|
+
* "0 live workers" while it completed runs. Each workflow is reported under the token a worker
|
|
7393
|
+
* serving it would use (`tenantGroup(name, namespace)`), with the run-queue consumers as its live
|
|
7394
|
+
* workers. The engine's internal `__` workflows are left out.
|
|
7395
|
+
*
|
|
7396
|
+
* Nothing when no run-queue consumer is live (a transport that cannot report one, or no driving
|
|
7397
|
+
* instance): the workflows are not served by anything the transport can see, and claiming a worker
|
|
7398
|
+
* for them would hide a starved queue.
|
|
7399
|
+
*/
|
|
7400
|
+
private inProcessWorkflowHealth;
|
|
7374
7401
|
/**
|
|
7375
7402
|
* What workflows the LIVE fleet announces it can execute — the deployment-wide registry a picker
|
|
7376
7403
|
* ("call this existing workflow") needs, and the one question this engine's own registry cannot
|
|
@@ -8977,6 +9004,72 @@ declare function markRemoteEvent<E extends object>(event: E): E;
|
|
|
8977
9004
|
/** Whether `event` was produced by another instance and re-delivered here over the control plane. */
|
|
8978
9005
|
declare function isRemoteEvent(event: object): boolean;
|
|
8979
9006
|
|
|
9007
|
+
/**
|
|
9008
|
+
* The trace id of `runId`: 32 lowercase hex, never all zeros, the same in every process. A control
|
|
9009
|
+
* plane records a tenant run's lifecycle events in this trace, and a tenant pod running the run's
|
|
9010
|
+
* steps under Telescope records the steps' own work in it too (the Telescope integration derives the
|
|
9011
|
+
* same id), so the two views join on `trace:<id>` without either side calling the other.
|
|
9012
|
+
*/
|
|
9013
|
+
declare function runTraceId(runId: string): string;
|
|
9014
|
+
/**
|
|
9015
|
+
* How an observer on a control plane finds the tenant app of a run. A tenant's runs live in the
|
|
9016
|
+
* partition its token verified to (`run.namespace`); `run.*` events carry it, `step.*` events do
|
|
9017
|
+
* not, so the observer remembers it per run and, for a run it has seen no event of yet (a run
|
|
9018
|
+
* resumed after a restart, another pod's run), reads it once.
|
|
9019
|
+
*/
|
|
9020
|
+
interface RunAppAttribution {
|
|
9021
|
+
/** The namespace (tenant partition) of `runId`, or `undefined` when the run is unknown. */
|
|
9022
|
+
namespaceOf(runId: string): Promise<string | undefined>;
|
|
9023
|
+
/**
|
|
9024
|
+
* The control plane's own namespaces: runs in these are its own, not a tenant's, and get no app.
|
|
9025
|
+
* `'default'` and an absent namespace are always the control plane's.
|
|
9026
|
+
*/
|
|
9027
|
+
own?: readonly string[] | undefined;
|
|
9028
|
+
/** How many run → app answers to keep (oldest dropped first). Default 10,000. */
|
|
9029
|
+
cacheSize?: number | undefined;
|
|
9030
|
+
/**
|
|
9031
|
+
* How long one read may take before the event is forwarded unattributed (the run's next event
|
|
9032
|
+
* reads again). Default 5,000 ms.
|
|
9033
|
+
*/
|
|
9034
|
+
lookupTimeoutMs?: number | undefined;
|
|
9035
|
+
}
|
|
9036
|
+
/** The tenant app of a run in `namespace`, or `undefined` for the control plane's own runs. */
|
|
9037
|
+
declare function tenantAppOf(namespace: string | undefined, own?: ReadonlySet<string> | readonly string[]): string | undefined;
|
|
9038
|
+
/** An engine event a control plane attributed to a tenant app. */
|
|
9039
|
+
type AttributedEngineEvent = EngineEvent & {
|
|
9040
|
+
app?: string | undefined;
|
|
9041
|
+
};
|
|
9042
|
+
/**
|
|
9043
|
+
* Remembers which tenant app each run belongs to and stamps it on that run's events, keeping their
|
|
9044
|
+
* order. An event whose run is not known yet waits for one read; that run's later events wait behind
|
|
9045
|
+
* it (a run's `step.completed` is never forwarded before its `step.started`), other runs' do not. A
|
|
9046
|
+
* read that fails or takes longer than `lookupTimeoutMs` forwards the event unattributed and is not
|
|
9047
|
+
* remembered, so the run's next event reads again.
|
|
9048
|
+
*
|
|
9049
|
+
* A tenant's event is forwarded with `app` set and, when the engine left it off (step events), its
|
|
9050
|
+
* partition as `namespace`. The control plane's own runs are forwarded unchanged.
|
|
9051
|
+
*/
|
|
9052
|
+
declare class RunAppStamper {
|
|
9053
|
+
#private;
|
|
9054
|
+
constructor(options: RunAppAttribution);
|
|
9055
|
+
/** Call `forward` with `event` stamped with its app (when it has one), now or once it is known. */
|
|
9056
|
+
stamp(event: EngineEvent, forward: (event: AttributedEngineEvent) => void): void;
|
|
9057
|
+
}
|
|
9058
|
+
/** The slice of the durable module options {@link controlPlaneAttribution} reads. */
|
|
9059
|
+
interface RunAppTopologyOptions {
|
|
9060
|
+
topology?: string | undefined;
|
|
9061
|
+
namespace?: string | undefined;
|
|
9062
|
+
partition?: string | undefined;
|
|
9063
|
+
}
|
|
9064
|
+
/**
|
|
9065
|
+
* The {@link RunAppAttribution} of a control plane, or `undefined` for any other topology (a
|
|
9066
|
+
* standalone app or a tenant pod attributes nothing). `getRun` reads a run's namespace (the engine's
|
|
9067
|
+
* or the store's); the control plane's own `namespace`/`partition` are its own runs.
|
|
9068
|
+
*/
|
|
9069
|
+
declare function controlPlaneAttribution(options: RunAppTopologyOptions | undefined, getRun: (runId: string) => Promise<{
|
|
9070
|
+
namespace?: string | undefined;
|
|
9071
|
+
} | null>): RunAppAttribution | undefined;
|
|
9072
|
+
|
|
8980
9073
|
/**
|
|
8981
9074
|
* The origin (see {@link import('./interfaces').WorkflowRun.origin}) stamped onto runs of the
|
|
8982
9075
|
* workflows this package registers ITSELF — the built-in `__entity` runner behind durable entities
|
|
@@ -9666,4 +9759,4 @@ declare function prevRRuleFireMs(rule: ParsedRRule, atMs: number): number | null
|
|
|
9666
9759
|
*/
|
|
9667
9760
|
declare function settleResultsWithPlainCalls(store: Pick<StateStore, 'getRun' | 'getCheckpoint'> & Partial<Pick<StateStore, 'getRuns' | 'getCheckpointsForSettle' | 'getCheckpoints' | 'settleCheckpointsIfPending'>>, results: StepResultSettlement[]): Promise<(StepCheckpoint | null)[]>;
|
|
9668
9761
|
|
|
9669
|
-
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 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, 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, 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 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, 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, 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, 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, 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, tenantGroup, tenantIdsFor, tenantVisible, toEventSubscription, traceIdOfTraceparent, triggerFailedSubscribersOf, triggeredRunsOf, triggeredSubscribersOf, useDurableExecution, verifyWireTenant, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
|
|
9762
|
+
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, 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, 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, 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, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -3186,6 +3186,18 @@ interface Transport {
|
|
|
3186
3186
|
* taking runs and resolves once the runs in flight have settled. Pair with {@link dispatchRuns}.
|
|
3187
3187
|
*/
|
|
3188
3188
|
onDispatchedRun?(handler: (run: RunDispatch) => Promise<void>, opts: RunConsumerOptions): () => Promise<void>;
|
|
3189
|
+
/**
|
|
3190
|
+
* The live consumers of the run queue `opts` names ({@link onDispatchedRun}): the engine instances
|
|
3191
|
+
* executing this deployment's IN-PROCESS workflow bodies. They take no task queue, so they never
|
|
3192
|
+
* appear in the worker-heartbeat keyspace {@link listWorkerGroups}/{@link groupHealth} read, and a
|
|
3193
|
+
* control plane driving its own workflows looked like it had no worker at all. Kept in a keyspace of
|
|
3194
|
+
* its own on purpose: a worker heartbeat makes its group a target for convention routing and the
|
|
3195
|
+
* workflow directory, and nothing consumes a task queue under these names.
|
|
3196
|
+
*
|
|
3197
|
+
* Optional, like {@link groupHealth}: only a broker transport that can introspect liveness (BullMQ)
|
|
3198
|
+
* implements it. The engine folds the result into {@link WorkflowEngine.workerHealth}.
|
|
3199
|
+
*/
|
|
3200
|
+
liveRunConsumers?(opts?: RunQueueOptions): Promise<WorkerHeartbeat[]>;
|
|
3189
3201
|
/** control plane → tenant worker: publish a correlated {@link RunReply} on `<effectivePrefix>-run-reply`
|
|
3190
3202
|
* (pub/sub; every tenant subscribes and filters by `requestId`). */
|
|
3191
3203
|
publishRunReply?(reply: RunReply): Promise<void>;
|
|
@@ -7368,9 +7380,24 @@ declare class WorkflowEngine {
|
|
|
7368
7380
|
/** Per-group worker health (queue backlog + live worker heartbeats). Covers {@link knownGroups}
|
|
7369
7381
|
* (so a registered group with backlog and ZERO workers still reports — the alert case) UNION the
|
|
7370
7382
|
* groups discovered from live heartbeats (so a local-step group like `pipeline`, not derivable
|
|
7371
|
-
* from registrations, shows once its workers beat)
|
|
7372
|
-
*
|
|
7383
|
+
* from registrations, shows once its workers beat) UNION this engine's in-process workflows while
|
|
7384
|
+
* the run queue has a live consumer (see {@link inProcessWorkflowHealth}). Empty when no transport
|
|
7385
|
+
* can introspect health (only the BullMQ transport implements `groupHealth`). */
|
|
7373
7386
|
workerHealth(extra?: string[]): Promise<GroupHealth[]>;
|
|
7387
|
+
/**
|
|
7388
|
+
* The workflows this deployment executes IN-PROCESS — registered here with a body, so a run of one
|
|
7389
|
+
* is driven by whichever engine instance takes it off the run queue — and the instances consuming
|
|
7390
|
+
* that queue right now. Those instances ARE the workers of these workflows, yet they consume no task
|
|
7391
|
+
* queue and so never wrote a worker heartbeat: a control plane running its own workflows showed
|
|
7392
|
+
* "0 live workers" while it completed runs. Each workflow is reported under the token a worker
|
|
7393
|
+
* serving it would use (`tenantGroup(name, namespace)`), with the run-queue consumers as its live
|
|
7394
|
+
* workers. The engine's internal `__` workflows are left out.
|
|
7395
|
+
*
|
|
7396
|
+
* Nothing when no run-queue consumer is live (a transport that cannot report one, or no driving
|
|
7397
|
+
* instance): the workflows are not served by anything the transport can see, and claiming a worker
|
|
7398
|
+
* for them would hide a starved queue.
|
|
7399
|
+
*/
|
|
7400
|
+
private inProcessWorkflowHealth;
|
|
7374
7401
|
/**
|
|
7375
7402
|
* What workflows the LIVE fleet announces it can execute — the deployment-wide registry a picker
|
|
7376
7403
|
* ("call this existing workflow") needs, and the one question this engine's own registry cannot
|
|
@@ -8977,6 +9004,72 @@ declare function markRemoteEvent<E extends object>(event: E): E;
|
|
|
8977
9004
|
/** Whether `event` was produced by another instance and re-delivered here over the control plane. */
|
|
8978
9005
|
declare function isRemoteEvent(event: object): boolean;
|
|
8979
9006
|
|
|
9007
|
+
/**
|
|
9008
|
+
* The trace id of `runId`: 32 lowercase hex, never all zeros, the same in every process. A control
|
|
9009
|
+
* plane records a tenant run's lifecycle events in this trace, and a tenant pod running the run's
|
|
9010
|
+
* steps under Telescope records the steps' own work in it too (the Telescope integration derives the
|
|
9011
|
+
* same id), so the two views join on `trace:<id>` without either side calling the other.
|
|
9012
|
+
*/
|
|
9013
|
+
declare function runTraceId(runId: string): string;
|
|
9014
|
+
/**
|
|
9015
|
+
* How an observer on a control plane finds the tenant app of a run. A tenant's runs live in the
|
|
9016
|
+
* partition its token verified to (`run.namespace`); `run.*` events carry it, `step.*` events do
|
|
9017
|
+
* not, so the observer remembers it per run and, for a run it has seen no event of yet (a run
|
|
9018
|
+
* resumed after a restart, another pod's run), reads it once.
|
|
9019
|
+
*/
|
|
9020
|
+
interface RunAppAttribution {
|
|
9021
|
+
/** The namespace (tenant partition) of `runId`, or `undefined` when the run is unknown. */
|
|
9022
|
+
namespaceOf(runId: string): Promise<string | undefined>;
|
|
9023
|
+
/**
|
|
9024
|
+
* The control plane's own namespaces: runs in these are its own, not a tenant's, and get no app.
|
|
9025
|
+
* `'default'` and an absent namespace are always the control plane's.
|
|
9026
|
+
*/
|
|
9027
|
+
own?: readonly string[] | undefined;
|
|
9028
|
+
/** How many run → app answers to keep (oldest dropped first). Default 10,000. */
|
|
9029
|
+
cacheSize?: number | undefined;
|
|
9030
|
+
/**
|
|
9031
|
+
* How long one read may take before the event is forwarded unattributed (the run's next event
|
|
9032
|
+
* reads again). Default 5,000 ms.
|
|
9033
|
+
*/
|
|
9034
|
+
lookupTimeoutMs?: number | undefined;
|
|
9035
|
+
}
|
|
9036
|
+
/** The tenant app of a run in `namespace`, or `undefined` for the control plane's own runs. */
|
|
9037
|
+
declare function tenantAppOf(namespace: string | undefined, own?: ReadonlySet<string> | readonly string[]): string | undefined;
|
|
9038
|
+
/** An engine event a control plane attributed to a tenant app. */
|
|
9039
|
+
type AttributedEngineEvent = EngineEvent & {
|
|
9040
|
+
app?: string | undefined;
|
|
9041
|
+
};
|
|
9042
|
+
/**
|
|
9043
|
+
* Remembers which tenant app each run belongs to and stamps it on that run's events, keeping their
|
|
9044
|
+
* order. An event whose run is not known yet waits for one read; that run's later events wait behind
|
|
9045
|
+
* it (a run's `step.completed` is never forwarded before its `step.started`), other runs' do not. A
|
|
9046
|
+
* read that fails or takes longer than `lookupTimeoutMs` forwards the event unattributed and is not
|
|
9047
|
+
* remembered, so the run's next event reads again.
|
|
9048
|
+
*
|
|
9049
|
+
* A tenant's event is forwarded with `app` set and, when the engine left it off (step events), its
|
|
9050
|
+
* partition as `namespace`. The control plane's own runs are forwarded unchanged.
|
|
9051
|
+
*/
|
|
9052
|
+
declare class RunAppStamper {
|
|
9053
|
+
#private;
|
|
9054
|
+
constructor(options: RunAppAttribution);
|
|
9055
|
+
/** Call `forward` with `event` stamped with its app (when it has one), now or once it is known. */
|
|
9056
|
+
stamp(event: EngineEvent, forward: (event: AttributedEngineEvent) => void): void;
|
|
9057
|
+
}
|
|
9058
|
+
/** The slice of the durable module options {@link controlPlaneAttribution} reads. */
|
|
9059
|
+
interface RunAppTopologyOptions {
|
|
9060
|
+
topology?: string | undefined;
|
|
9061
|
+
namespace?: string | undefined;
|
|
9062
|
+
partition?: string | undefined;
|
|
9063
|
+
}
|
|
9064
|
+
/**
|
|
9065
|
+
* The {@link RunAppAttribution} of a control plane, or `undefined` for any other topology (a
|
|
9066
|
+
* standalone app or a tenant pod attributes nothing). `getRun` reads a run's namespace (the engine's
|
|
9067
|
+
* or the store's); the control plane's own `namespace`/`partition` are its own runs.
|
|
9068
|
+
*/
|
|
9069
|
+
declare function controlPlaneAttribution(options: RunAppTopologyOptions | undefined, getRun: (runId: string) => Promise<{
|
|
9070
|
+
namespace?: string | undefined;
|
|
9071
|
+
} | null>): RunAppAttribution | undefined;
|
|
9072
|
+
|
|
8980
9073
|
/**
|
|
8981
9074
|
* The origin (see {@link import('./interfaces').WorkflowRun.origin}) stamped onto runs of the
|
|
8982
9075
|
* workflows this package registers ITSELF — the built-in `__entity` runner behind durable entities
|
|
@@ -9666,4 +9759,4 @@ declare function prevRRuleFireMs(rule: ParsedRRule, atMs: number): number | null
|
|
|
9666
9759
|
*/
|
|
9667
9760
|
declare function settleResultsWithPlainCalls(store: Pick<StateStore, 'getRun' | 'getCheckpoint'> & Partial<Pick<StateStore, 'getRuns' | 'getCheckpointsForSettle' | 'getCheckpoints' | 'settleCheckpointsIfPending'>>, results: StepResultSettlement[]): Promise<(StepCheckpoint | null)[]>;
|
|
9668
9761
|
|
|
9669
|
-
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 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, 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, 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 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, 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, 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, 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, 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, tenantGroup, tenantIdsFor, tenantVisible, toEventSubscription, traceIdOfTraceparent, triggerFailedSubscribersOf, triggeredRunsOf, triggeredSubscribersOf, useDurableExecution, verifyWireTenant, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
|
|
9762
|
+
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, 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, 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, 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, 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 };
|
package/dist/index.js
CHANGED
|
@@ -5023,6 +5023,24 @@ var TransportPool = class {
|
|
|
5023
5023
|
return stops;
|
|
5024
5024
|
}
|
|
5025
5025
|
/**
|
|
5026
|
+
* The live run-queue consumers ({@link Transport.liveRunConsumers}) across every transport that
|
|
5027
|
+
* reports them, one per instance (its latest beat): an engine consuming the run queue of two
|
|
5028
|
+
* pinned transports is still one process.
|
|
5029
|
+
*/
|
|
5030
|
+
async liveRunConsumers(opts) {
|
|
5031
|
+
const byInstance = /* @__PURE__ */ new Map();
|
|
5032
|
+
for (const { transport } of this.transports) {
|
|
5033
|
+
if (!transport.liveRunConsumers) continue;
|
|
5034
|
+
for (const beat of await transport.liveRunConsumers(opts)) {
|
|
5035
|
+
const seen = byInstance.get(beat.instanceId);
|
|
5036
|
+
if (!seen || beat.lastBeatAt > seen.lastBeatAt) byInstance.set(beat.instanceId, beat);
|
|
5037
|
+
}
|
|
5038
|
+
}
|
|
5039
|
+
return [
|
|
5040
|
+
...byInstance.values()
|
|
5041
|
+
];
|
|
5042
|
+
}
|
|
5043
|
+
/**
|
|
5026
5044
|
* The live handshake descriptors advertised for `group` (design §7.2), merged across every transport
|
|
5027
5045
|
* that can report them. Returns `[]` when NO transport implements
|
|
5028
5046
|
* {@link Transport.readWorkerDescriptors} (a pure in-process pool) OR when descriptors are supported
|
|
@@ -11492,13 +11510,16 @@ var WorkflowEngine = class _WorkflowEngine {
|
|
|
11492
11510
|
/** Per-group worker health (queue backlog + live worker heartbeats). Covers {@link knownGroups}
|
|
11493
11511
|
* (so a registered group with backlog and ZERO workers still reports — the alert case) UNION the
|
|
11494
11512
|
* groups discovered from live heartbeats (so a local-step group like `pipeline`, not derivable
|
|
11495
|
-
* from registrations, shows once its workers beat)
|
|
11496
|
-
*
|
|
11513
|
+
* from registrations, shows once its workers beat) UNION this engine's in-process workflows while
|
|
11514
|
+
* the run queue has a live consumer (see {@link inProcessWorkflowHealth}). Empty when no transport
|
|
11515
|
+
* can introspect health (only the BullMQ transport implements `groupHealth`). */
|
|
11497
11516
|
async workerHealth(extra = []) {
|
|
11517
|
+
const inProcess = await this.inProcessWorkflowHealth();
|
|
11498
11518
|
const groups = /* @__PURE__ */ new Set([
|
|
11499
11519
|
...this.knownGroups(extra),
|
|
11500
11520
|
...await this.pool.listWorkerGroups(),
|
|
11501
|
-
...await this.inflightStepGroups()
|
|
11521
|
+
...await this.inflightStepGroups(),
|
|
11522
|
+
...inProcess.groups
|
|
11502
11523
|
]);
|
|
11503
11524
|
const workflowTokens = /* @__PURE__ */ new Set();
|
|
11504
11525
|
for (const def of this.workflows.values()) {
|
|
@@ -11511,14 +11532,54 @@ var WorkflowEngine = class _WorkflowEngine {
|
|
|
11511
11532
|
if (!health) continue;
|
|
11512
11533
|
const at = group.lastIndexOf("@");
|
|
11513
11534
|
const baseToken = at === -1 ? group : group.slice(0, at);
|
|
11535
|
+
const consumers = inProcess.groups.has(group) ? inProcess.consumers.filter((c) => !health.liveWorkers.some((w) => w.instanceId === c.instanceId)).map((c) => ({
|
|
11536
|
+
...c,
|
|
11537
|
+
group
|
|
11538
|
+
})) : [];
|
|
11514
11539
|
out.push({
|
|
11515
11540
|
...health,
|
|
11541
|
+
liveWorkers: [
|
|
11542
|
+
...health.liveWorkers,
|
|
11543
|
+
...consumers
|
|
11544
|
+
],
|
|
11516
11545
|
kind: workflowTokens.has(baseToken) ? "workflow" : "step"
|
|
11517
11546
|
});
|
|
11518
11547
|
}
|
|
11519
11548
|
return out;
|
|
11520
11549
|
}
|
|
11521
11550
|
/**
|
|
11551
|
+
* The workflows this deployment executes IN-PROCESS — registered here with a body, so a run of one
|
|
11552
|
+
* is driven by whichever engine instance takes it off the run queue — and the instances consuming
|
|
11553
|
+
* that queue right now. Those instances ARE the workers of these workflows, yet they consume no task
|
|
11554
|
+
* queue and so never wrote a worker heartbeat: a control plane running its own workflows showed
|
|
11555
|
+
* "0 live workers" while it completed runs. Each workflow is reported under the token a worker
|
|
11556
|
+
* serving it would use (`tenantGroup(name, namespace)`), with the run-queue consumers as its live
|
|
11557
|
+
* workers. The engine's internal `__` workflows are left out.
|
|
11558
|
+
*
|
|
11559
|
+
* Nothing when no run-queue consumer is live (a transport that cannot report one, or no driving
|
|
11560
|
+
* instance): the workflows are not served by anything the transport can see, and claiming a worker
|
|
11561
|
+
* for them would hide a starved queue.
|
|
11562
|
+
*/
|
|
11563
|
+
async inProcessWorkflowHealth() {
|
|
11564
|
+
const groups = /* @__PURE__ */ new Set();
|
|
11565
|
+
for (const def of this.workflows.values()) {
|
|
11566
|
+
if (def.remote || def.hasBody === false || def.name.startsWith("__")) continue;
|
|
11567
|
+
groups.add(tenantGroup(sanitizeQueueToken(def.name), this.namespace));
|
|
11568
|
+
}
|
|
11569
|
+
if (groups.size === 0) return {
|
|
11570
|
+
groups,
|
|
11571
|
+
consumers: []
|
|
11572
|
+
};
|
|
11573
|
+
const consumers = await this.pool.liveRunConsumers({
|
|
11574
|
+
namespace: this.namespace
|
|
11575
|
+
}).catch(() => []);
|
|
11576
|
+
if (consumers.length === 0) groups.clear();
|
|
11577
|
+
return {
|
|
11578
|
+
groups,
|
|
11579
|
+
consumers
|
|
11580
|
+
};
|
|
11581
|
+
}
|
|
11582
|
+
/**
|
|
11522
11583
|
* What workflows the LIVE fleet announces it can execute — the deployment-wide registry a picker
|
|
11523
11584
|
* ("call this existing workflow") needs, and the one question this engine's own registry cannot
|
|
11524
11585
|
* answer. {@link workflowBody} answers only for this process, and a missing body is ambiguous: it
|
|
@@ -16119,6 +16180,144 @@ function collectMetrics(engine) {
|
|
|
16119
16180
|
}
|
|
16120
16181
|
__name(collectMetrics, "collectMetrics");
|
|
16121
16182
|
|
|
16183
|
+
// src/run-app.ts
|
|
16184
|
+
import { createHash } from "node:crypto";
|
|
16185
|
+
function runTraceId(runId) {
|
|
16186
|
+
const hex = createHash("sha256").update(`durable:run:${runId}`).digest("hex").slice(0, 32);
|
|
16187
|
+
return /^0+$/.test(hex) ? `${hex.slice(0, 31)}1` : hex;
|
|
16188
|
+
}
|
|
16189
|
+
__name(runTraceId, "runTraceId");
|
|
16190
|
+
function tenantAppOf(namespace, own = []) {
|
|
16191
|
+
if (namespace === void 0 || namespace === "" || namespace === "default") return void 0;
|
|
16192
|
+
const mine = Array.isArray(own) ? own.includes(namespace) : own.has(namespace);
|
|
16193
|
+
return mine ? void 0 : namespace;
|
|
16194
|
+
}
|
|
16195
|
+
__name(tenantAppOf, "tenantAppOf");
|
|
16196
|
+
function positive(value, fallback) {
|
|
16197
|
+
return value !== void 0 && Number.isFinite(value) ? Math.max(1, value) : fallback;
|
|
16198
|
+
}
|
|
16199
|
+
__name(positive, "positive");
|
|
16200
|
+
var FAILED = Symbol("failed");
|
|
16201
|
+
var RunAppStamper = class {
|
|
16202
|
+
static {
|
|
16203
|
+
__name(this, "RunAppStamper");
|
|
16204
|
+
}
|
|
16205
|
+
#lookup;
|
|
16206
|
+
#own;
|
|
16207
|
+
#max;
|
|
16208
|
+
#timeoutMs;
|
|
16209
|
+
/** runId → app (`null`: the control plane's own run). */
|
|
16210
|
+
#apps = /* @__PURE__ */ new Map();
|
|
16211
|
+
/** runId → the last queued event of that run, while one is waiting on a read. */
|
|
16212
|
+
#tails = /* @__PURE__ */ new Map();
|
|
16213
|
+
constructor(options) {
|
|
16214
|
+
this.#lookup = (runId) => options.namespaceOf(runId);
|
|
16215
|
+
this.#own = new Set(options.own ?? []);
|
|
16216
|
+
this.#max = positive(options.cacheSize, 1e4);
|
|
16217
|
+
this.#timeoutMs = positive(options.lookupTimeoutMs, 5e3);
|
|
16218
|
+
}
|
|
16219
|
+
/** Call `forward` with `event` stamped with its app (when it has one), now or once it is known. */
|
|
16220
|
+
stamp(event, forward) {
|
|
16221
|
+
const runId = event.runId;
|
|
16222
|
+
const tail = this.#tails.get(runId);
|
|
16223
|
+
if (tail === void 0) {
|
|
16224
|
+
const known = this.#known(event);
|
|
16225
|
+
if (known !== void 0) {
|
|
16226
|
+
this.#forward(event, known, forward);
|
|
16227
|
+
return;
|
|
16228
|
+
}
|
|
16229
|
+
}
|
|
16230
|
+
const next = (tail ?? Promise.resolve()).then(async () => {
|
|
16231
|
+
try {
|
|
16232
|
+
let app = this.#known(event);
|
|
16233
|
+
if (app === void 0) {
|
|
16234
|
+
const namespace = await this.#read(runId);
|
|
16235
|
+
if (namespace === FAILED) {
|
|
16236
|
+
app = null;
|
|
16237
|
+
} else {
|
|
16238
|
+
app = tenantAppOf(namespace, this.#own) ?? null;
|
|
16239
|
+
this.#remember(runId, app);
|
|
16240
|
+
}
|
|
16241
|
+
}
|
|
16242
|
+
this.#forward(event, app, forward);
|
|
16243
|
+
} catch {
|
|
16244
|
+
}
|
|
16245
|
+
});
|
|
16246
|
+
this.#tails.set(runId, next);
|
|
16247
|
+
void next.then(() => {
|
|
16248
|
+
if (this.#tails.get(runId) === next) this.#tails.delete(runId);
|
|
16249
|
+
});
|
|
16250
|
+
}
|
|
16251
|
+
#forward(event, app, forward) {
|
|
16252
|
+
try {
|
|
16253
|
+
forward(this.#with(event, app));
|
|
16254
|
+
} finally {
|
|
16255
|
+
if (event.type === "run.completed" || event.type === "run.failed") {
|
|
16256
|
+
this.#apps.delete(event.runId);
|
|
16257
|
+
}
|
|
16258
|
+
}
|
|
16259
|
+
}
|
|
16260
|
+
/** The run's namespace, or {@link FAILED} when the read threw or did not answer in time. */
|
|
16261
|
+
async #read(runId) {
|
|
16262
|
+
let timer;
|
|
16263
|
+
const timeout = new Promise((resolve) => {
|
|
16264
|
+
timer = setTimeout(() => resolve(FAILED), this.#timeoutMs);
|
|
16265
|
+
timer.unref?.();
|
|
16266
|
+
});
|
|
16267
|
+
try {
|
|
16268
|
+
return await Promise.race([
|
|
16269
|
+
Promise.resolve().then(() => this.#lookup(runId)).catch(() => FAILED),
|
|
16270
|
+
timeout
|
|
16271
|
+
]);
|
|
16272
|
+
} finally {
|
|
16273
|
+
clearTimeout(timer);
|
|
16274
|
+
}
|
|
16275
|
+
}
|
|
16276
|
+
/** The app of `event`'s run when it is known without a read (`null`: no app). */
|
|
16277
|
+
#known(event) {
|
|
16278
|
+
if (event.namespace !== void 0) {
|
|
16279
|
+
const app = tenantAppOf(event.namespace, this.#own) ?? null;
|
|
16280
|
+
this.#remember(event.runId, app);
|
|
16281
|
+
return app;
|
|
16282
|
+
}
|
|
16283
|
+
return this.#apps.get(event.runId);
|
|
16284
|
+
}
|
|
16285
|
+
/** A tenant's event carries its app, and its partition as `namespace` (step events have none). */
|
|
16286
|
+
#with(event, app) {
|
|
16287
|
+
if (app === null) return event;
|
|
16288
|
+
return event.namespace === void 0 ? {
|
|
16289
|
+
...event,
|
|
16290
|
+
namespace: app,
|
|
16291
|
+
app
|
|
16292
|
+
} : {
|
|
16293
|
+
...event,
|
|
16294
|
+
app
|
|
16295
|
+
};
|
|
16296
|
+
}
|
|
16297
|
+
#remember(runId, app) {
|
|
16298
|
+
if (this.#apps.has(runId)) this.#apps.delete(runId);
|
|
16299
|
+
else if (this.#apps.size >= this.#max) {
|
|
16300
|
+
const oldest = this.#apps.keys().next().value;
|
|
16301
|
+
if (oldest !== void 0) this.#apps.delete(oldest);
|
|
16302
|
+
}
|
|
16303
|
+
this.#apps.set(runId, app);
|
|
16304
|
+
}
|
|
16305
|
+
};
|
|
16306
|
+
function controlPlaneAttribution(options, getRun) {
|
|
16307
|
+
if (options?.topology !== "control-plane") return void 0;
|
|
16308
|
+
const own = [
|
|
16309
|
+
options.namespace,
|
|
16310
|
+
options.partition
|
|
16311
|
+
].filter((ns) => typeof ns === "string" && ns !== "");
|
|
16312
|
+
return {
|
|
16313
|
+
namespaceOf: /* @__PURE__ */ __name(async (runId) => (await getRun(runId))?.namespace, "namespaceOf"),
|
|
16314
|
+
...own.length > 0 ? {
|
|
16315
|
+
own
|
|
16316
|
+
} : {}
|
|
16317
|
+
};
|
|
16318
|
+
}
|
|
16319
|
+
__name(controlPlaneAttribution, "controlPlaneAttribution");
|
|
16320
|
+
|
|
16122
16321
|
// src/search-attributes.ts
|
|
16123
16322
|
function compare(actual, filter) {
|
|
16124
16323
|
if (filter.op === "in") return filter.values.some((v) => actual === v);
|
|
@@ -17249,6 +17448,7 @@ export {
|
|
|
17249
17448
|
RemoteStepTimeout,
|
|
17250
17449
|
RemoteWorkflowExecutor,
|
|
17251
17450
|
RemoteWorkflowTimeout,
|
|
17451
|
+
RunAppStamper,
|
|
17252
17452
|
RunGateway,
|
|
17253
17453
|
SINGLETON_ACTIVE_STATUSES,
|
|
17254
17454
|
SINGLETON_ADMITTED_TAG,
|
|
@@ -17305,6 +17505,7 @@ export {
|
|
|
17305
17505
|
codeOf,
|
|
17306
17506
|
collectMetrics,
|
|
17307
17507
|
concurrencyTag,
|
|
17508
|
+
controlPlaneAttribution,
|
|
17308
17509
|
controlPlaneDescriptor,
|
|
17309
17510
|
countRuns,
|
|
17310
17511
|
coveredTokens,
|
|
@@ -17414,6 +17615,7 @@ export {
|
|
|
17414
17615
|
runOutsideWorkflowCtx,
|
|
17415
17616
|
runSchedules,
|
|
17416
17617
|
runStepHandler,
|
|
17618
|
+
runTraceId,
|
|
17417
17619
|
runValueFacetsFromRuns,
|
|
17418
17620
|
runWaitPrefix,
|
|
17419
17621
|
runWaitTargetOf,
|
|
@@ -17439,6 +17641,7 @@ export {
|
|
|
17439
17641
|
summarizeFan,
|
|
17440
17642
|
summarizeRunFromStore,
|
|
17441
17643
|
summarizeTimeline,
|
|
17644
|
+
tenantAppOf,
|
|
17442
17645
|
tenantGroup,
|
|
17443
17646
|
tenantIdsFor,
|
|
17444
17647
|
tenantVisible,
|