@voltro/plugin-ai-flows 0.75.0 → 0.77.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.ts CHANGED
@@ -38,7 +38,8 @@ export declare const aiFlowRunsTable: Table<"_voltro_ai_flow_runs", FieldDefinit
38
38
  readonly flowName: ColumnBuilder<string | null, "text", boolean>;
39
39
  /** Snapshot of the mode this run executes in. */
40
40
  readonly mode: ColumnBuilder<string, "text", true>;
41
- /** pending | running | waiting | succeeded | failed | cancelled. */
41
+ /** pending | running | waiting | cancelling | succeeded | failed | cancelled.
42
+ * `cancelling` is a recorded request the engine has not yet confirmed. */
42
43
  readonly status: ColumnBuilder<string, "text", true>;
43
44
  /** manual | cron. */
44
45
  readonly source: ColumnBuilder<string | null, "text", boolean>;
@@ -293,24 +294,43 @@ export declare const buildFlowRunExecute: (ctx: AppContext, deps?: EngineDeps) =
293
294
  export declare const cadenceMatches: (cadence: FlowCadence, now: Date) => boolean;
294
295
 
295
296
  /**
296
- * Cancel a run on BOTH sides in one operation: the row (what the UI and the
297
- * cadence read) and the workflow execution (what actually runs, or waits at a
298
- * human step). Either half alone drifts — a row marked cancelled over a
299
- * suspended execution, or a cancelled execution under a row that still says
300
- * `waiting` — and a reader of one side never learns about the other.
297
+ * Request cancellation on both sides: the row records the request, which stops
298
+ * further cooperative steps, and the workflow facade interrupts a running or
299
+ * suspended execution. The row status carries the request's uncertainty: a
300
+ * live row moves to `cancelling` first and reads `cancelled` only once the
301
+ * engine confirmed — here through a confirmed cancelled snapshot, or later
302
+ * through the engine honouring the request cooperatively, the change tap
303
+ * seeing the engine's own run row cancelled, or a repeated confirmed request.
304
+ * Accepted, unknown and unreachable outcomes leave the row `cancelling`, so a
305
+ * later reader cannot mistake an unheard request for a stopped run.
301
306
  *
302
- * The row is patched first, so a cooperative check between steps sees it even
303
- * if the engine's interrupt is slow; the execution's own interrupt handler
304
- * (`buildFlowRunExecute`) writes the same terminal fields again, harmlessly.
305
- * An execution that cannot be reached (no runtime, not started) leaves the row
306
- * cancelled and says so in `engine`.
307
+ * Terminal rows (succeeded, failed, cancelled) are not rewritten and are not
308
+ * resubmitted to the engine. The conditional row update also protects a
309
+ * completion committed after the initial read. Repeated `cancelling` requests
310
+ * retain the original request timestamp and retry engine cancellation.
307
311
  */
308
312
  export declare const cancelFlow: (ctx: AppContext, args: {
309
313
  runId: string;
310
314
  }) => Effect.Effect<{
311
- runId: string;
312
- status: RunStatus;
313
- engine: "unreachable" | "cancelled";
315
+ readonly status: "failed" | "pending" | "cancelled" | "running" | "succeeded" | "waiting" | "cancelling";
316
+ readonly runId: string;
317
+ readonly control: {
318
+ readonly snapshot: {
319
+ readonly status: "unknown" | "failed" | "cancelled" | "running" | "succeeded" | "suspended";
320
+ readonly id: string;
321
+ readonly error?: {
322
+ readonly message: string;
323
+ readonly tag: string | null;
324
+ } | undefined;
325
+ readonly output?: unknown;
326
+ readonly executionId: string;
327
+ readonly workflowName: string;
328
+ };
329
+ readonly kind: "unknown" | "accepted" | "confirmed" | "already-terminal";
330
+ readonly operation: "resume" | "cancel";
331
+ readonly requestId: string | null;
332
+ } | null;
333
+ readonly engine: "unknown" | "unreachable" | "cancelled" | "accepted" | "already-terminal" | "not-requested";
314
334
  }, FlowRunNotFound, never>;
315
335
 
316
336
  /** Staged follow-up when `chainTo.requireConfirmation` is set. */
@@ -535,6 +555,35 @@ export declare interface FlowCadence {
535
555
  readonly defaultInput?: Json | undefined;
536
556
  }
537
557
 
558
+ /** Row state and engine acknowledgement are separate observations. Retain the
559
+ * control request identity so an accepted/unknown request can be observed.
560
+ * The row never claims `cancelled` on its own: a confirmed engine cancellation
561
+ * is the only receipt that reports a `cancelled` row, every other request
562
+ * outcome leaves the row `cancelling` (or a completion that won a race). */
563
+ export declare const FlowCancelReceipt: Schema.filter<Schema.Struct<{
564
+ runId: typeof Schema.NonEmptyString;
565
+ status: Schema.Literal<["pending", "running", "waiting", "cancelling", "succeeded", "failed", "cancelled"]>;
566
+ engine: Schema.Literal<["cancelled", "accepted", "unknown", "already-terminal", "unreachable", "not-requested"]>;
567
+ control: Schema.NullOr<Schema.filter<Schema.Struct<{
568
+ operation: Schema.Literal<["cancel", "resume"]>;
569
+ kind: Schema.Literal<["accepted", "confirmed", "unknown", "already-terminal"]>;
570
+ requestId: Schema.NullOr<typeof Schema.NonEmptyString>;
571
+ snapshot: Schema.Struct<{
572
+ id: typeof Schema.String;
573
+ workflowName: typeof Schema.String;
574
+ executionId: typeof Schema.String;
575
+ status: Schema.Union<[Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>, Schema.Literal<["unknown"]>]>;
576
+ output: Schema.optional<typeof Schema.Unknown>;
577
+ error: Schema.optional<Schema.Struct<{
578
+ tag: Schema.NullOr<typeof Schema.String>;
579
+ message: typeof Schema.String;
580
+ }>>;
581
+ }>;
582
+ }>>>;
583
+ }>>;
584
+
585
+ export declare type FlowCancelReceipt = typeof FlowCancelReceipt.Type;
586
+
538
587
  /** A generation step required a capability the host did not provide (e.g. a
539
588
  * media modality with no configured generator, or storage for the artifact). */
540
589
  declare class FlowCapabilityMissing extends FlowCapabilityMissing_base {
@@ -1406,8 +1455,12 @@ export declare type RunSource = typeof RunSource.Type;
1406
1455
 
1407
1456
  /** Run status — ONE canonical set (the legacy vocabulary; the Voltro-port
1408
1457
  * additions `awaiting_human`/`completed`/`rejected` are collapsed: `waiting`
1409
- * covers the human pause, `succeeded` is the single terminal-success literal). */
1410
- export declare const RunStatus: Schema.Literal<["pending", "running", "waiting", "succeeded", "failed", "cancelled"]>;
1458
+ * covers the human pause, `succeeded` is the single terminal-success literal).
1459
+ * `cancelling` is a recorded cancellation request the engine has not
1460
+ * confirmed: the row carries that uncertainty until the engine stops the run
1461
+ * (cooperatively, by interruption, or through a later confirmed request).
1462
+ * Only `succeeded`, `failed` and `cancelled` are terminal. */
1463
+ export declare const RunStatus: Schema.Literal<["pending", "running", "waiting", "cancelling", "succeeded", "failed", "cancelled"]>;
1411
1464
 
1412
1465
  export declare type RunStatus = typeof RunStatus.Type;
1413
1466