@remoraflow/core 0.3.0 → 0.4.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.
@@ -11,9 +11,9 @@ export interface WorkflowExecutionStateChannelOptions {
11
11
  /** Pub/sub channel for streaming {@link ExecutionState} snapshots from an executor to one or more consumers. */
12
12
  export interface WorkflowExecutionStateChannel {
13
13
  /** Push a new state snapshot into the channel. */
14
- publish(state: ExecutionState): void;
14
+ publish(state: ExecutionState): void | Promise<void>;
15
15
  /** Signal that no more states will be published. Subscribers will drain and terminate. */
16
- close(): void;
16
+ close(): void | Promise<void>;
17
17
  /**
18
18
  * Subscribe to state updates.
19
19
  *
@@ -37,14 +37,14 @@ export declare abstract class BaseExecutionStateChannel implements WorkflowExecu
37
37
  private bufferedState;
38
38
  constructor(options?: WorkflowExecutionStateChannelOptions);
39
39
  /** Push a state snapshot, applying debounce if configured. */
40
- publish(state: ExecutionState): void;
40
+ publish(state: ExecutionState): Promise<void>;
41
41
  /** Close the channel, flushing any buffered state first. */
42
- close(): void;
42
+ close(): Promise<void>;
43
43
  private clearDebounce;
44
44
  /** Deliver a state snapshot to subscribers. Subclasses implement storage + notification. */
45
- protected abstract emit(state: ExecutionState): void;
45
+ protected abstract emit(state: ExecutionState): void | Promise<void>;
46
46
  /** Perform subclass-specific close logic (e.g. resolve pending waiters). */
47
- protected abstract doClose(): void;
47
+ protected abstract doClose(): void | Promise<void>;
48
48
  abstract subscribe(opts?: {
49
49
  replay?: boolean;
50
50
  }): AsyncIterable<ExecutionState>;
@@ -1 +1 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/executor/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,mEAAmE;AACnE,MAAM,WAAW,oCAAoC;IACnD,QAAQ,CAAC,EAAE;QACT,+DAA+D;QAC/D,EAAE,EAAE,MAAM,CAAC;QACX,4HAA4H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e,CAAU;IAC1C,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,aAAa,CAA+B;gBAExC,OAAO,CAAC,EAAE,oCAAoC;IAK1D,8DAA8D;IACxD,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnD,4DAA4D;IACtD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5B,OAAO,CAAC,aAAa;IAOrB,4FAA4F;IAC5F,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IACpE,4EAA4E;IAC5E,SAAS,CAAC,QAAQ,CAAC,OAAO,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAElD,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;QACxB,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,GAAG,aAAa,CAAC,cAAc,CAAC;IAEjC,gFAAgF;IAChF,MAAM,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;CAGzC;AAID;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,yBAAyB;IACxE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,MAAM,CAAS;IAEvB,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAS3C,SAAS,CAAC,OAAO,IAAI,IAAI;IAQhB,MAAM,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAQjD,SAAS,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,aAAa,CAAC,cAAc,CAAC;CAkCtE"}
@@ -61,7 +61,7 @@ export interface ExecuteWorkflowOptions<ExecutionContext extends Record<string,
61
61
  /** Called when a step completes successfully. */
62
62
  onStepComplete?: (stepId: string, output: unknown) => void;
63
63
  /** Called on every state transition with the full execution state and the idempotent delta that produced it. */
64
- onStateChange?: (state: ExecutionState, delta: ExecutionDelta) => void;
64
+ onStateChange?: (state: ExecutionState, delta: ExecutionDelta) => void | Promise<void>;
65
65
  /** Optional channel for publishing execution state snapshots. Publishes on every state transition, in addition to {@link onStateChange}. */
66
66
  channel?: WorkflowExecutionStateChannel;
67
67
  /** Injectable durable execution context. Default: simple in-process implementation. */
@@ -121,18 +121,18 @@ export declare class ExecutionTimer {
121
121
  export declare class ExecutionStateManager {
122
122
  private state;
123
123
  private readonly onChange?;
124
- constructor(onChange?: (state: ExecutionState, delta: ExecutionDelta) => void, initialState?: ExecutionState, workflowHash?: string);
124
+ constructor(onChange?: (state: ExecutionState, delta: ExecutionDelta) => void | Promise<void>, initialState?: ExecutionState, workflowHash?: string);
125
125
  get currentState(): ExecutionState;
126
126
  private emit;
127
- runStarted(): void;
128
- stepStarted(stepId: string, path: ExecutionPathSegment[]): void;
129
- stepCompleted(stepId: string, path: ExecutionPathSegment[], output: unknown, durationMs: number, resolvedInputs?: unknown, trace?: TraceEntry[]): void;
130
- stepFailed(stepId: string, path: ExecutionPathSegment[], error: StepExecutionError, durationMs: number, resolvedInputs?: unknown): void;
131
- retryAttempted(stepId: string, path: ExecutionPathSegment[], retry: RetryRecord): void;
132
- runCompleted(output?: unknown): void;
133
- runFailed(error: StepExecutionError): void;
134
- stepAwaitingApproval(stepId: string, path: ExecutionPathSegment[], sourcePolicyId: string): void;
135
- stepApproved(stepId: string, path: ExecutionPathSegment[], sourcePolicyId: string): void;
136
- stepDenied(stepId: string, path: ExecutionPathSegment[], sourcePolicyId: string, reason?: string): void;
127
+ runStarted(): Promise<void>;
128
+ stepStarted(stepId: string, path: ExecutionPathSegment[]): Promise<void>;
129
+ stepCompleted(stepId: string, path: ExecutionPathSegment[], output: unknown, durationMs: number, resolvedInputs?: unknown, trace?: TraceEntry[]): Promise<void>;
130
+ stepFailed(stepId: string, path: ExecutionPathSegment[], error: StepExecutionError, durationMs: number, resolvedInputs?: unknown): Promise<void>;
131
+ retryAttempted(stepId: string, path: ExecutionPathSegment[], retry: RetryRecord): Promise<void>;
132
+ runCompleted(output?: unknown): Promise<void>;
133
+ runFailed(error: StepExecutionError): Promise<void>;
134
+ stepAwaitingApproval(stepId: string, path: ExecutionPathSegment[], sourcePolicyId: string): Promise<void>;
135
+ stepApproved(stepId: string, path: ExecutionPathSegment[], sourcePolicyId: string): Promise<void>;
136
+ stepDenied(stepId: string, path: ExecutionPathSegment[], sourcePolicyId: string, reason?: string): Promise<void>;
137
137
  }
138
138
  //# sourceMappingURL=executor-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"executor-types.d.ts","sourceRoot":"","sources":["../../src/executor/executor-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,UAAU,EACX,MAAM,SAAS,CAAC;AAKjB,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,qFAAqF;IACrF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,kEAAk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ANGED
@@ -1651,36 +1651,36 @@ class BaseExecutionStateChannel {
1651
1651
  this.debounceMs = options?.debounce?.ms;
1652
1652
  this.flushOnComplete = options?.debounce?.flushOnComplete ?? true;
1653
1653
  }
1654
- publish(state) {
1654
+ async publish(state) {
1655
1655
  if (this.debounceMs === undefined) {
1656
- this.emit(state);
1656
+ await this.emit(state);
1657
1657
  return;
1658
1658
  }
1659
1659
  if (this.flushOnComplete && TERMINAL_STATUSES.has(state.status)) {
1660
1660
  this.clearDebounce();
1661
- this.emit(state);
1661
+ await this.emit(state);
1662
1662
  return;
1663
1663
  }
1664
1664
  this.bufferedState = state;
1665
1665
  if (this.debounceTimer === null) {
1666
- this.debounceTimer = setTimeout(() => {
1666
+ this.debounceTimer = setTimeout(async () => {
1667
1667
  this.debounceTimer = null;
1668
1668
  if (this.bufferedState) {
1669
1669
  const s = this.bufferedState;
1670
1670
  this.bufferedState = null;
1671
- this.emit(s);
1671
+ await this.emit(s);
1672
1672
  }
1673
1673
  }, this.debounceMs);
1674
1674
  }
1675
1675
  }
1676
- close() {
1676
+ async close() {
1677
1677
  this.clearDebounce();
1678
1678
  if (this.bufferedState) {
1679
1679
  const s = this.bufferedState;
1680
1680
  this.bufferedState = null;
1681
- this.emit(s);
1681
+ await this.emit(s);
1682
1682
  }
1683
- this.doClose();
1683
+ await this.doClose();
1684
1684
  }
1685
1685
  clearDebounce() {
1686
1686
  if (this.debounceTimer !== null) {
@@ -2200,27 +2200,27 @@ class ExecutionStateManager {
2200
2200
  get currentState() {
2201
2201
  return this.state;
2202
2202
  }
2203
- emit(delta) {
2203
+ async emit(delta) {
2204
2204
  this.state = applyDelta(this.state, delta);
2205
- this.onChange?.(this.state, delta);
2205
+ await this.onChange?.(this.state, delta);
2206
2206
  }
2207
- runStarted() {
2208
- this.emit({
2207
+ async runStarted() {
2208
+ await this.emit({
2209
2209
  type: "run-started",
2210
2210
  runId: this.state.runId,
2211
2211
  startedAt: this.state.startedAt
2212
2212
  });
2213
2213
  }
2214
- stepStarted(stepId, path) {
2215
- this.emit({
2214
+ async stepStarted(stepId, path) {
2215
+ await this.emit({
2216
2216
  type: "step-started",
2217
2217
  stepId,
2218
2218
  path,
2219
2219
  startedAt: new Date().toISOString()
2220
2220
  });
2221
2221
  }
2222
- stepCompleted(stepId, path, output, durationMs, resolvedInputs, trace) {
2223
- this.emit({
2222
+ async stepCompleted(stepId, path, output, durationMs, resolvedInputs, trace) {
2223
+ await this.emit({
2224
2224
  type: "step-completed",
2225
2225
  stepId,
2226
2226
  path,
@@ -2231,8 +2231,8 @@ class ExecutionStateManager {
2231
2231
  trace
2232
2232
  });
2233
2233
  }
2234
- stepFailed(stepId, path, error, durationMs, resolvedInputs) {
2235
- this.emit({
2234
+ async stepFailed(stepId, path, error, durationMs, resolvedInputs) {
2235
+ await this.emit({
2236
2236
  type: "step-failed",
2237
2237
  stepId,
2238
2238
  path,
@@ -2242,17 +2242,17 @@ class ExecutionStateManager {
2242
2242
  resolvedInputs
2243
2243
  });
2244
2244
  }
2245
- retryAttempted(stepId, path, retry) {
2246
- this.emit({
2245
+ async retryAttempted(stepId, path, retry) {
2246
+ await this.emit({
2247
2247
  type: "step-retry",
2248
2248
  stepId,
2249
2249
  path,
2250
2250
  retry
2251
2251
  });
2252
2252
  }
2253
- runCompleted(output) {
2253
+ async runCompleted(output) {
2254
2254
  const startMs = new Date(this.state.startedAt).getTime();
2255
- this.emit({
2255
+ await this.emit({
2256
2256
  type: "run-completed",
2257
2257
  runId: this.state.runId,
2258
2258
  completedAt: new Date().toISOString(),
@@ -2260,9 +2260,9 @@ class ExecutionStateManager {
2260
2260
  output
2261
2261
  });
2262
2262
  }
2263
- runFailed(error) {
2263
+ async runFailed(error) {
2264
2264
  const startMs = new Date(this.state.startedAt).getTime();
2265
- this.emit({
2265
+ await this.emit({
2266
2266
  type: "run-failed",
2267
2267
  runId: this.state.runId,
2268
2268
  failedAt: new Date().toISOString(),
@@ -2270,8 +2270,8 @@ class ExecutionStateManager {
2270
2270
  error: snapshotError(error)
2271
2271
  });
2272
2272
  }
2273
- stepAwaitingApproval(stepId, path, sourcePolicyId) {
2274
- this.emit({
2273
+ async stepAwaitingApproval(stepId, path, sourcePolicyId) {
2274
+ await this.emit({
2275
2275
  type: "step-awaiting-approval",
2276
2276
  stepId,
2277
2277
  path,
@@ -2279,8 +2279,8 @@ class ExecutionStateManager {
2279
2279
  requestedAt: new Date().toISOString()
2280
2280
  });
2281
2281
  }
2282
- stepApproved(stepId, path, sourcePolicyId) {
2283
- this.emit({
2282
+ async stepApproved(stepId, path, sourcePolicyId) {
2283
+ await this.emit({
2284
2284
  type: "step-approved",
2285
2285
  stepId,
2286
2286
  path,
@@ -2288,8 +2288,8 @@ class ExecutionStateManager {
2288
2288
  approvedAt: new Date().toISOString()
2289
2289
  });
2290
2290
  }
2291
- stepDenied(stepId, path, sourcePolicyId, reason) {
2292
- this.emit({
2291
+ async stepDenied(stepId, path, sourcePolicyId, reason) {
2292
+ await this.emit({
2293
2293
  type: "step-denied",
2294
2294
  stepId,
2295
2295
  path,
@@ -3156,7 +3156,7 @@ async function evaluatePolicies(action, stepId, options, context, stateManager,
3156
3156
  case "defer":
3157
3157
  continue;
3158
3158
  case "request": {
3159
- stateManager?.stepAwaitingApproval(stepId, execPath, sourcePolicyId);
3159
+ await stateManager?.stepAwaitingApproval(stepId, execPath, sourcePolicyId);
3160
3160
  const timeoutMs = options.approvalTimeoutMs ?? DEFAULT_APPROVAL_TIMEOUT_MS;
3161
3161
  const intervalMs = options.approvalIntervalMs ?? DEFAULT_APPROVAL_INTERVAL_MS;
3162
3162
  const backoffMultiplier = options.approvalBackoffMultiplier ?? DEFAULT_APPROVAL_BACKOFF_MULTIPLIER;
@@ -3211,7 +3211,7 @@ async function evaluatePolicies(action, stepId, options, context, stateManager,
3211
3211
  approvalResult = await pollingPromise;
3212
3212
  }
3213
3213
  } catch {
3214
- stateManager?.stepDenied(stepId, execPath, sourcePolicyId, "Approval request timed out");
3214
+ await stateManager?.stepDenied(stepId, execPath, sourcePolicyId, "Approval request timed out");
3215
3215
  throw new AuthorizationError(stepId, "Approval request timed out", sourcePolicyId);
3216
3216
  }
3217
3217
  const approvalDecision = approvalResult;
@@ -3219,10 +3219,10 @@ async function evaluatePolicies(action, stepId, options, context, stateManager,
3219
3219
  await decision.onApproval(approvalDecision);
3220
3220
  }
3221
3221
  if (approvalDecision.approved) {
3222
- stateManager?.stepApproved(stepId, execPath, sourcePolicyId);
3222
+ await stateManager?.stepApproved(stepId, execPath, sourcePolicyId);
3223
3223
  return;
3224
3224
  }
3225
- stateManager?.stepDenied(stepId, execPath, sourcePolicyId, approvalDecision.reason);
3225
+ await stateManager?.stepDenied(stepId, execPath, sourcePolicyId, approvalDecision.reason);
3226
3226
  throw new AuthorizationError(stepId, approvalDecision.reason ?? "Approval denied", sourcePolicyId);
3227
3227
  }
3228
3228
  }
@@ -3367,7 +3367,7 @@ async function retryStep(step, stepIndex, stepOutputs, loopVars, options, origin
3367
3367
  try {
3368
3368
  return await executeStep(step, scope, stepIndex, stepOutputs, loopVars, options, context, timer, stateManager, execPath);
3369
3369
  } catch (e) {
3370
- stateManager?.retryAttempted(step.id, execPath, {
3370
+ await stateManager?.retryAttempted(step.id, execPath, {
3371
3371
  attempt,
3372
3372
  startedAt: retryStartedAt,
3373
3373
  failedAt: new Date().toISOString(),
@@ -3415,7 +3415,7 @@ var executeChain = async function executeChain2(startStepId, stepIndex, stepOutp
3415
3415
  }
3416
3416
  timer?.checkTotal(step.id);
3417
3417
  const stepStartTime = Date.now();
3418
- stateManager?.stepStarted(step.id, execPath);
3418
+ await stateManager?.stepStarted(step.id, execPath);
3419
3419
  options.onStepStart?.(step.id, step);
3420
3420
  const scope = { ...stepOutputs, ...loopVars };
3421
3421
  const resolvedInputs = stateManager ? resolveStepInputs(step, scope) : undefined;
@@ -3441,21 +3441,21 @@ var executeChain = async function executeChain2(startStepId, stepIndex, stepOutp
3441
3441
  if (!(e instanceof StepExecutionError)) {
3442
3442
  const durationMs2 = Date.now() - stepStartTime;
3443
3443
  const wrappedError = new ExternalServiceError(step.id, "TOOL_EXECUTION_FAILED", e instanceof Error ? e.message : String(e), e, undefined, false);
3444
- stateManager?.stepFailed(step.id, execPath, wrappedError, durationMs2, resolvedInputs);
3444
+ await stateManager?.stepFailed(step.id, execPath, wrappedError, durationMs2, resolvedInputs);
3445
3445
  throw e;
3446
3446
  }
3447
3447
  try {
3448
3448
  stepResult = await recoverFromError(e, step, stepIndex, stepOutputs, loopVars, options, context, timer ?? new ExecutionTimer, stateManager, execPath);
3449
3449
  } catch (unrecoverable) {
3450
3450
  const durationMs2 = Date.now() - stepStartTime;
3451
- stateManager?.stepFailed(step.id, execPath, e, durationMs2, resolvedInputs);
3451
+ await stateManager?.stepFailed(step.id, execPath, e, durationMs2, resolvedInputs);
3452
3452
  throw unrecoverable;
3453
3453
  }
3454
3454
  }
3455
3455
  const durationMs = Date.now() - stepStartTime;
3456
3456
  stepOutputs[step.id] = stepResult.output;
3457
3457
  lastOutput = stepResult.output;
3458
- stateManager?.stepCompleted(step.id, execPath, stepResult.output, durationMs, resolvedInputs, stepResult.trace);
3458
+ await stateManager?.stepCompleted(step.id, execPath, stepResult.output, durationMs, resolvedInputs, stepResult.trace);
3459
3459
  options.onStepComplete?.(step.id, stepResult.output);
3460
3460
  currentStepId = step.nextStepId;
3461
3461
  }
@@ -3515,12 +3515,12 @@ async function executeWorkflow(workflow, options) {
3515
3515
  workflowHash: wfHash,
3516
3516
  stepRecords: validInitialState.stepRecords.filter((r) => r.status === "completed")
3517
3517
  } : undefined;
3518
- const combinedOnChange = options.channel ? (state, delta) => {
3519
- options.channel?.publish(state);
3520
- options.onStateChange?.(state, delta);
3518
+ const combinedOnChange = options.channel ? async (state, delta) => {
3519
+ await options.channel?.publish(state);
3520
+ await options.onStateChange?.(state, delta);
3521
3521
  } : options.onStateChange;
3522
3522
  const stateManager = new ExecutionStateManager(combinedOnChange, cleanedInitialState, wfHash);
3523
- stateManager.runStarted();
3523
+ await stateManager.runStarted();
3524
3524
  try {
3525
3525
  validateWorkflowConfig(workflow, resolvedOptions);
3526
3526
  const inputs = options.inputs ?? {};
@@ -3536,7 +3536,7 @@ async function executeWorkflow(workflow, options) {
3536
3536
  }
3537
3537
  validateWorkflowOutput(workflow.outputSchema, chainOutput, endStepId);
3538
3538
  }
3539
- stateManager.runCompleted(chainOutput);
3539
+ await stateManager.runCompleted(chainOutput);
3540
3540
  return {
3541
3541
  success: true,
3542
3542
  stepOutputs,
@@ -3545,7 +3545,7 @@ async function executeWorkflow(workflow, options) {
3545
3545
  };
3546
3546
  } catch (e) {
3547
3547
  const error = e instanceof StepExecutionError ? e : new ExternalServiceError("unknown", "TOOL_EXECUTION_FAILED", e instanceof Error ? e.message : String(e), e, undefined, false);
3548
- stateManager.runFailed(error);
3548
+ await stateManager.runFailed(error);
3549
3549
  return {
3550
3550
  success: false,
3551
3551
  stepOutputs,
@@ -3553,7 +3553,7 @@ async function executeWorkflow(workflow, options) {
3553
3553
  executionState: stateManager.currentState
3554
3554
  };
3555
3555
  } finally {
3556
- options.channel?.close();
3556
+ await options.channel?.close();
3557
3557
  }
3558
3558
  }
3559
3559
  function executeWorkflowStream(workflow, options) {
@@ -4111,4 +4111,4 @@ export {
4111
4111
  AuthorizationError
4112
4112
  };
4113
4113
 
4114
- //# debugId=90EB293769CDA18E64756E2164756E21
4114
+ //# debugId=BAD6C301D3B992F364756E2164756E21