@hasna/loops 0.4.28 → 0.4.29

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +84 -1
  2. package/README.md +226 -49
  3. package/dist/api/index.d.ts +20 -19
  4. package/dist/api/index.js +6846 -1087
  5. package/dist/cli/index.js +2471 -885
  6. package/dist/cli/safe-error-context.d.ts +1 -0
  7. package/dist/daemon/daemon.d.ts +1 -0
  8. package/dist/daemon/index.js +1786 -493
  9. package/dist/generated/storage-kit/index.d.ts +1 -1
  10. package/dist/generated/storage-kit/mode.d.ts +6 -12
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +4778 -1016
  13. package/dist/lib/advancement.d.ts +52 -0
  14. package/dist/lib/agent-adapter.d.ts +20 -2
  15. package/dist/lib/auth/route-policy.d.ts +14 -0
  16. package/dist/lib/auth/tenant-auth.d.ts +38 -0
  17. package/dist/lib/cloud/mode.d.ts +2 -8
  18. package/dist/lib/cloud/storage.d.ts +1 -2
  19. package/dist/lib/cloud/transport.d.ts +4 -18
  20. package/dist/lib/errors.d.ts +43 -1
  21. package/dist/lib/format.d.ts +2 -2
  22. package/dist/lib/goal/runner.d.ts +36 -3
  23. package/dist/lib/health.d.ts +1 -1
  24. package/dist/lib/labels.d.ts +4 -0
  25. package/dist/lib/loop-status.d.ts +4 -0
  26. package/dist/lib/migration.d.ts +4 -17
  27. package/dist/lib/mode.d.ts +2 -5
  28. package/dist/lib/mode.js +27 -36
  29. package/dist/lib/route/index.d.ts +2 -2
  30. package/dist/lib/route/throttle.d.ts +7 -0
  31. package/dist/lib/route/types.d.ts +3 -0
  32. package/dist/lib/run-completion.d.ts +18 -0
  33. package/dist/lib/scheduler.d.ts +5 -11
  34. package/dist/lib/storage/contract.d.ts +15 -1
  35. package/dist/lib/storage/index.d.ts +1 -1
  36. package/dist/lib/storage/index.js +3864 -457
  37. package/dist/lib/storage/pg-executor.d.ts +10 -5
  38. package/dist/lib/storage/postgres-loop-storage.d.ts +50 -24
  39. package/dist/lib/storage/postgres-schema.d.ts +8 -0
  40. package/dist/lib/storage/postgres-schema.js +1323 -1
  41. package/dist/lib/storage/postgres.d.ts +3 -1
  42. package/dist/lib/storage/postgres.js +1353 -27
  43. package/dist/lib/storage/provider-credentials.d.ts +84 -0
  44. package/dist/lib/storage/shared-database-transfer.d.ts +136 -0
  45. package/dist/lib/storage/sqlite.d.ts +15 -2
  46. package/dist/lib/storage/sqlite.js +1299 -217
  47. package/dist/lib/storage/tenant-backfill-s3.d.ts +53 -0
  48. package/dist/lib/storage/tenant-backfill.d.ts +40 -0
  49. package/dist/lib/store/index.d.ts +11 -8
  50. package/dist/lib/store.d.ts +52 -7
  51. package/dist/lib/store.js +1266 -217
  52. package/dist/lib/templates.d.ts +11 -0
  53. package/dist/lib/workflow-events.d.ts +6 -0
  54. package/dist/lib/workflow-provenance.d.ts +8 -0
  55. package/dist/lib/workflow-runner.d.ts +52 -4
  56. package/dist/mcp/index.js +1961 -651
  57. package/dist/runner/index.d.ts +20 -2
  58. package/dist/runner/index.js +2113 -177
  59. package/dist/sdk/http.d.ts +211 -3
  60. package/dist/sdk/http.js +301 -0
  61. package/dist/sdk/index.d.ts +7 -2
  62. package/dist/sdk/index.js +1959 -711
  63. package/dist/serve/index.d.ts +14 -0
  64. package/dist/serve/index.js +12323 -1743
  65. package/dist/types.d.ts +64 -3
  66. package/docs/AUTOMATION_RUNTIME_DESIGN.md +32 -32
  67. package/docs/CUTOVER-RUNBOOK.md +158 -31
  68. package/docs/DEPLOYMENT_MODES.md +78 -56
  69. package/docs/RUNTIME_BOUNDARY.md +26 -26
  70. package/docs/SHARED-DATABASE-TRANSFER.md +95 -0
  71. package/docs/SHARED_KIT_EXTRACTION_INVENTORY.md +631 -0
  72. package/docs/TRANSCRIPT_LOOP_PATTERNS.md +3 -3
  73. package/docs/UNIFIED_PRODUCT_CONTRACT.md +365 -0
  74. package/docs/USAGE.md +143 -52
  75. package/docs/workflows/transcript-feedback-to-loops.json +2 -2
  76. package/package.json +7 -3
  77. package/dist/lib/storage/pg-runner-claim.d.ts +0 -40
@@ -0,0 +1,53 @@
1
+ import type { PoolQueryClient } from "../../generated/storage-kit/query.js";
2
+ import { loadTenantBackfillBundle } from "./tenant-backfill.js";
3
+ export declare const TENANT_BACKFILL_MAX_BYTES: number;
4
+ export interface TenantBackfillS3Client {
5
+ list(input: {
6
+ prefix: string;
7
+ maxKeys: number;
8
+ }): Promise<{
9
+ contents?: Array<{
10
+ key: string;
11
+ size?: number;
12
+ }>;
13
+ isTruncated?: boolean;
14
+ }>;
15
+ file(key: string): {
16
+ bytes(): Promise<Uint8Array>;
17
+ };
18
+ delete(key: string): Promise<void>;
19
+ }
20
+ interface TaskRoleCredentials {
21
+ accessKeyId: string;
22
+ secretAccessKey: string;
23
+ sessionToken: string;
24
+ }
25
+ export type TenantBackfillFetch = (input: string, init?: RequestInit) => Promise<Response>;
26
+ interface TenantBackfillS3Options {
27
+ bucket: string;
28
+ region: string;
29
+ credentialsRelativeUri: string;
30
+ }
31
+ interface TenantBackfillS3Dependencies {
32
+ fetch?: TenantBackfillFetch;
33
+ createS3Client?: (options: TaskRoleCredentials & {
34
+ bucket: string;
35
+ region: string;
36
+ endpoint: string;
37
+ }) => TenantBackfillS3Client;
38
+ loadBundle?: typeof loadTenantBackfillBundle;
39
+ }
40
+ export interface TenantBackfillS3Result {
41
+ digest: string;
42
+ counts: {
43
+ tenants: number;
44
+ principals: number;
45
+ memberships: number;
46
+ keyBindings: number;
47
+ rowAssignments: number;
48
+ };
49
+ }
50
+ export declare function fetchEcsTaskRoleCredentials(relativeUri: string, fetchImpl?: TenantBackfillFetch): Promise<TaskRoleCredentials>;
51
+ export declare function loadApprovedTenantBackfillBundle(queryClient: PoolQueryClient, options: TenantBackfillS3Options, dependencies?: TenantBackfillS3Dependencies): Promise<TenantBackfillS3Result>;
52
+ export declare function logTenantBackfillS3Success(result: TenantBackfillS3Result): void;
53
+ export {};
@@ -0,0 +1,40 @@
1
+ import type { PoolQueryClient } from "../../generated/storage-kit/query.js";
2
+ declare const BUNDLE_SCHEMA = "open-loops.tenant-backfill/v1";
3
+ export interface TenantBackfillBundle {
4
+ schema: typeof BUNDLE_SCHEMA;
5
+ tenants: Array<{
6
+ id: string;
7
+ slug: string;
8
+ name: string;
9
+ status: "active" | "suspended";
10
+ }>;
11
+ principals: Array<{
12
+ id: string;
13
+ kind: "human" | "service" | "machine";
14
+ displayName: string;
15
+ status: "active" | "suspended";
16
+ }>;
17
+ memberships: Array<{
18
+ tenantId: string;
19
+ principalId: string;
20
+ status: "active" | "suspended";
21
+ roles: string[];
22
+ }>;
23
+ keyBindings: Array<{
24
+ kid: string;
25
+ tenantId: string;
26
+ principalId: string;
27
+ tokenKind: "api_key" | "service" | "machine";
28
+ }>;
29
+ rowAssignments: Array<{
30
+ table: string;
31
+ rowId: string;
32
+ tenantId: string;
33
+ }>;
34
+ }
35
+ export declare function parseTenantBackfillBundle(value: unknown): TenantBackfillBundle;
36
+ export declare function loadTenantBackfillBundle(client: PoolQueryClient, bundle: TenantBackfillBundle): Promise<{
37
+ digest: string;
38
+ assignments: number;
39
+ }>;
40
+ export {};
@@ -1,4 +1,4 @@
1
- import type { CreateLoopInput, CreateWorkflowInput, Loop, LoopRun, LoopStatus, RunReceipt, RunStatus, WorkflowEvent, WorkflowInvocation, WorkflowRun, WorkflowSpec, WorkflowStepRun, WorkflowWorkItem, WorkflowWorkItemStatus, WriteRunReceiptInput } from "../../types.js";
1
+ import type { CreateLoopInput, CreateWorkflowInput, Loop, LoopRun, LoopStatus, PublicWorkflowEvent, RunReceipt, RunStatus, WorkflowInvocation, WorkflowRun, WorkflowSpec, WorkflowStepRun, WorkflowWorkItem, WorkflowWorkItemStatus, WriteRunReceiptInput } from "../../types.js";
2
2
  import type { Goal, GoalPlanNode, GoalRun, GoalStatus } from "../goal/types.js";
3
3
  import type { HasnaStorageClient } from "../cloud/storage.js";
4
4
  import type { Env } from "../cloud/mode.js";
@@ -16,7 +16,7 @@ export declare class CloudUnsupportedError extends Error {
16
16
  constructor(operation: string);
17
17
  }
18
18
  /**
19
- * The single data interface for the OpenLoops client. Both {@link LocalStore}
19
+ * The single data interface for the Loops client. Both {@link LocalStore}
20
20
  * and {@link ApiStore} implement it; callers hold a `LoopStore` and never know
21
21
  * (or branch on) which one. Every method is async so the two transports share
22
22
  * one surface.
@@ -31,6 +31,7 @@ export interface LoopStore {
31
31
  requireUniqueLoop(idOrName: string): Promise<Loop>;
32
32
  listLoops(opts?: {
33
33
  status?: LoopStatus;
34
+ labels?: string[];
34
35
  limit?: number;
35
36
  offset?: number;
36
37
  archived?: boolean;
@@ -41,7 +42,7 @@ export interface LoopStore {
41
42
  archived?: boolean;
42
43
  includeArchived?: boolean;
43
44
  }): Promise<number>;
44
- updateLoop(id: string, patch: Partial<Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor" | "expiresAt">>): Promise<Loop>;
45
+ updateLoop(id: string, patch: Partial<Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor" | "expiresAt" | "labels">>): Promise<Loop>;
45
46
  renameLoop(id: string, name: string): Promise<Loop>;
46
47
  archiveLoop(idOrName: string): Promise<Loop>;
47
48
  unarchiveLoop(idOrName: string): Promise<Loop>;
@@ -67,7 +68,7 @@ export interface LoopStore {
67
68
  limit?: number;
68
69
  }): Promise<WorkflowRun[]>;
69
70
  listWorkflowStepRuns(workflowRunId: string): Promise<WorkflowStepRun[]>;
70
- listWorkflowEvents(workflowRunId: string, limit?: number): Promise<WorkflowEvent[]>;
71
+ listWorkflowEvents(workflowRunId: string, limit?: number): Promise<PublicWorkflowEvent[]>;
71
72
  recoverWorkflowRun(workflowRunId: string, reason?: string): Promise<{
72
73
  run: WorkflowRun;
73
74
  recoveredSteps: WorkflowStepRun[];
@@ -103,6 +104,7 @@ export interface LoopStore {
103
104
  listRuns(opts?: {
104
105
  loopId?: string;
105
106
  status?: RunStatus;
107
+ labels?: string[];
106
108
  limit?: number;
107
109
  offset?: number;
108
110
  }): Promise<LoopRun[]>;
@@ -147,7 +149,7 @@ export declare class LocalStore implements LoopStore {
147
149
  archived?: boolean;
148
150
  includeArchived?: boolean;
149
151
  }): Promise<number>;
150
- updateLoop(id: string, patch: Partial<Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor" | "expiresAt">>): Promise<Loop>;
152
+ updateLoop(id: string, patch: Partial<Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor" | "expiresAt" | "labels">>): Promise<Loop>;
151
153
  renameLoop(id: string, name: string): Promise<Loop>;
152
154
  archiveLoop(idOrName: string): Promise<Loop>;
153
155
  unarchiveLoop(idOrName: string): Promise<Loop>;
@@ -165,7 +167,7 @@ export declare class LocalStore implements LoopStore {
165
167
  requireWorkflowRun(id: string): Promise<WorkflowRun>;
166
168
  listWorkflowRuns(opts?: Parameters<Store["listWorkflowRuns"]>[0]): Promise<WorkflowRun[]>;
167
169
  listWorkflowStepRuns(workflowRunId: string): Promise<WorkflowStepRun[]>;
168
- listWorkflowEvents(workflowRunId: string, limit?: number): Promise<WorkflowEvent[]>;
170
+ listWorkflowEvents(workflowRunId: string, limit?: number): Promise<PublicWorkflowEvent[]>;
169
171
  recoverWorkflowRun(workflowRunId: string, reason?: string): Promise<{
170
172
  run: WorkflowRun;
171
173
  recoveredSteps: WorkflowStepRun[];
@@ -216,10 +218,11 @@ export declare class ApiStore implements LoopStore {
216
218
  archived?: boolean;
217
219
  includeArchived?: boolean;
218
220
  }): Promise<number>;
219
- updateLoop(id: string, patch: Partial<Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor" | "expiresAt">>): Promise<Loop>;
221
+ updateLoop(id: string, patch: Partial<Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor" | "expiresAt" | "labels">>): Promise<Loop>;
220
222
  renameLoop(id: string, name: string): Promise<Loop>;
221
223
  archiveLoop(idOrName: string): Promise<Loop>;
222
224
  unarchiveLoop(idOrName: string): Promise<Loop>;
225
+ private mutateArchiveState;
223
226
  deleteLoop(idOrName: string): Promise<boolean>;
224
227
  createWorkflow(input: CreateWorkflowInput): Promise<WorkflowSpec>;
225
228
  getWorkflow(id: string): Promise<WorkflowSpec | undefined>;
@@ -234,7 +237,7 @@ export declare class ApiStore implements LoopStore {
234
237
  requireWorkflowRun(id: string): Promise<WorkflowRun>;
235
238
  listWorkflowRuns(opts?: Parameters<LoopStore["listWorkflowRuns"]>[0]): Promise<WorkflowRun[]>;
236
239
  listWorkflowStepRuns(workflowRunId: string): Promise<WorkflowStepRun[]>;
237
- listWorkflowEvents(workflowRunId: string, limit?: number): Promise<WorkflowEvent[]>;
240
+ listWorkflowEvents(workflowRunId: string, limit?: number): Promise<PublicWorkflowEvent[]>;
238
241
  recoverWorkflowRun(workflowRunId: string, reason?: string): Promise<{
239
242
  run: WorkflowRun;
240
243
  recoveredSteps: WorkflowStepRun[];
@@ -1,13 +1,31 @@
1
- import type { CreateLoopInput, CreateWorkflowInvocationInput, CreateWorkflowInput, Goal, GoalAutoExecute, GoalPlanNode, GoalRun, GoalStatus, Loop, LoopRun, LoopStatus, RunReceipt, RunStatus, TimeoutMs, WriteRunReceiptInput, WorkflowEvent, WorkflowInvocation, WorkflowRun, WorkflowRunStatus, WorkflowSpec, WorkflowStepRun, WorkflowWorkItem, WorkflowWorkItemStatus, UpsertWorkflowWorkItemInput } from "../types.js";
1
+ import type { CreateLoopInput, CreateWorkflowInvocationInput, CreateWorkflowInput, Goal, GoalAutoExecute, GoalPlanNode, GoalRun, GoalStatus, Loop, LoopRun, LoopStatus, RecoveredLeaseRunSnapshotEntry, RunReceipt, RunStatus, TimeoutMs, StoredWorkflowEvent, WriteRunReceiptInput, WorkflowInvocation, WorkflowRun, WorkflowRunStatus, WorkflowSpec, WorkflowStepRun, WorkflowWorkItem, WorkflowWorkItemStatus, UpsertWorkflowWorkItemInput } from "../types.js";
2
+ import { type InitialAgentSessionContractEvent } from "./workflow-provenance.js";
2
3
  interface DaemonLeaseFence {
3
4
  daemonLeaseId?: string;
4
5
  now?: Date;
5
6
  claimToken?: string;
7
+ recoveredRun?: RecoveredLeaseRunSnapshotEntry;
6
8
  }
9
+ export interface WorkflowRecoveryContext {
10
+ mode?: "internal" | "operator" | "runner";
11
+ now?: Date;
12
+ loopRunId?: string;
13
+ claimedBy?: string;
14
+ claimToken?: string;
15
+ }
16
+ export type LoopSchedulingState = Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor">;
17
+ export interface CircuitBreakerTransitionResult {
18
+ loop: Loop;
19
+ marker: LoopRun;
20
+ }
21
+ export declare const GENERATED_ROUTE_TEMPLATE_IDS: Set<string>;
22
+ export declare const GENERATED_ROUTE_KEYS: Set<string>;
23
+ export declare function isGeneratedRouteTemplate(routeKey: string, templateId: string): boolean;
7
24
  export interface LoopRow {
8
25
  id: string;
9
26
  name: string;
10
27
  description: string | null;
28
+ labels_json: string | null;
11
29
  status: string;
12
30
  archived_at: string | null;
13
31
  archived_from_status: string | null;
@@ -89,6 +107,7 @@ export interface WorkflowRunRow {
89
107
  work_item_id: string | null;
90
108
  scheduled_for: string | null;
91
109
  idempotency_key: string | null;
110
+ workflow_definition_hash: string | null;
92
111
  manifest_path: string | null;
93
112
  status: string;
94
113
  started_at: string | null;
@@ -258,12 +277,13 @@ export declare function rowToWorkflowStepRun(row: WorkflowStepRunRow): WorkflowS
258
277
  export declare function rowToGoal(row: GoalRow): Goal;
259
278
  export declare function rowToGoalPlanNode(row: GoalPlanNodeRow): GoalPlanNode;
260
279
  export declare function rowToGoalRun(row: GoalRunRow): GoalRun;
261
- export declare function rowToWorkflowEvent(row: WorkflowEventRow): WorkflowEvent;
280
+ export declare function rowToWorkflowEvent(row: WorkflowEventRow): StoredWorkflowEvent;
281
+ export declare function isLiveStepProcess(pid: number, stepStartedAt: string | null | undefined): boolean;
262
282
  export declare function rowToLease(row: LeaseRow): DaemonLease;
263
283
  export interface ClaimRunResult {
264
284
  run: LoopRun;
265
285
  loop: Loop;
266
- claimToken?: string;
286
+ claimToken: string;
267
287
  }
268
288
  export interface CreateWorkflowRunInput {
269
289
  workflow: WorkflowSpec;
@@ -274,6 +294,8 @@ export interface CreateWorkflowRunInput {
274
294
  invocationId?: string;
275
295
  workItemId?: string;
276
296
  daemonLeaseId?: string;
297
+ /** Internal deterministic fault-injection seam used to verify atomic initial event persistence. */
298
+ beforeInitialWorkflowEventPersist?: (event: InitialAgentSessionContractEvent) => void;
277
299
  }
278
300
  export interface CreateGoalInput {
279
301
  objective: string;
@@ -306,6 +328,11 @@ export interface RecoverExpiredRunLeasesResult {
306
328
  /** Runs whose lease expired while their process (group) is still alive; lease deferred. */
307
329
  deferred: LoopRun[];
308
330
  }
331
+ export interface RecoveredLeaseRunPage {
332
+ runs: LoopRun[];
333
+ snapshot?: RecoveredLeaseRunSnapshotEntry[];
334
+ nextOffset?: number;
335
+ }
309
336
  export interface PruneHistoryOptions {
310
337
  /** Delete terminal runs whose created_at is older than this many days. */
311
338
  maxAgeDays?: number;
@@ -416,6 +443,9 @@ export declare function classifyNonProductiveStepFailure(steps: ClassifiableStep
416
443
  export declare function scrubbedOrNull(value: string | undefined | null): string | null;
417
444
  /** Scrub secrets then bound size before persisting run stdout/stderr. */
418
445
  export declare function persistedRunOutput(value: string | undefined | null): string | null;
446
+ /** Scrub structured string leaves before stringify, then scrub the encoded JSON. */
447
+ export declare function persistedJson(value: unknown): string;
448
+ export declare function persistedWorkflowEventPayload(payload: Record<string, unknown> | undefined | null): string | null;
419
449
  export declare class Store {
420
450
  private db;
421
451
  private rootDir;
@@ -443,9 +473,11 @@ export declare class Store {
443
473
  getLoop(id: string): Loop | undefined;
444
474
  findLoopByName(name: string): Loop | undefined;
445
475
  requireUniqueLoop(idOrName: string): Loop;
476
+ private requireArchiveMutationLoop;
446
477
  requireLoop(idOrName: string): Loop;
447
478
  listLoops(opts?: {
448
479
  status?: LoopStatus;
480
+ labels?: string[];
449
481
  limit?: number;
450
482
  offset?: number;
451
483
  archived?: boolean;
@@ -454,7 +486,12 @@ export declare class Store {
454
486
  }): Loop[];
455
487
  private withLatestRunSummaries;
456
488
  dueLoops(now: Date, limit?: number): Loop[];
457
- updateLoop(id: string, patch: Partial<Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor" | "expiresAt">>, opts?: DaemonLeaseFence): Loop;
489
+ updateLoop(id: string, patch: Partial<Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor" | "expiresAt" | "labels">>, opts?: DaemonLeaseFence): Loop;
490
+ advanceLoopIfCurrent(id: string, expected: LoopSchedulingState, patch: Partial<Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor">>, opts?: DaemonLeaseFence): Loop | undefined;
491
+ tripCircuitBreakerIfCurrent(id: string, expected: LoopSchedulingState, patch: Partial<Pick<Loop, "status" | "nextRunAt" | "retryScheduledFor">>, marker: {
492
+ scheduledFor: string;
493
+ reason: string;
494
+ }, opts?: DaemonLeaseFence): CircuitBreakerTransitionResult | undefined;
458
495
  private activeLoopReferenceCount;
459
496
  private archiveWorkflowIfUnreferenced;
460
497
  retargetWorkflowLoop(idOrName: string, workflowId: string, opts?: DaemonLeaseFence & {
@@ -630,7 +667,7 @@ export declare class Store {
630
667
  stderr?: string;
631
668
  payload?: Record<string, unknown>;
632
669
  }, opts?: DaemonLeaseFence): WorkflowStepRun;
633
- recoverWorkflowRun(workflowRunId: string, reason?: string): {
670
+ recoverWorkflowRun(workflowRunId: string, reason?: string, _context?: WorkflowRecoveryContext): {
634
671
  run: WorkflowRun;
635
672
  recoveredSteps: WorkflowStepRun[];
636
673
  };
@@ -638,8 +675,8 @@ export declare class Store {
638
675
  skipWorkflowStepRun(workflowRunId: string, stepId: string, reason: string, opts?: DaemonLeaseFence): WorkflowStepRun;
639
676
  finalizeWorkflowRun(workflowRunId: string, status: WorkflowRunStatus, patch?: Partial<Pick<WorkflowRun, "finishedAt" | "durationMs" | "error">>, opts?: DaemonLeaseFence): WorkflowRun;
640
677
  cancelWorkflowRun(workflowRunId: string, reason?: string): WorkflowRun;
641
- appendWorkflowEvent(workflowRunId: string, eventType: string, stepId?: string, payload?: Record<string, unknown>): WorkflowEvent;
642
- listWorkflowEvents(workflowRunId: string, limit?: number): WorkflowEvent[];
678
+ appendWorkflowEvent(workflowRunId: string, eventType: string, stepId?: string, payload?: Record<string, unknown>): StoredWorkflowEvent;
679
+ listWorkflowEvents(workflowRunId: string, limit?: number): StoredWorkflowEvent[];
643
680
  hasRunningRun(loopId: string): boolean;
644
681
  hasRunningRunForSlot(loopId: string, scheduledFor: string): boolean;
645
682
  private hasBlockingRunningRunForOtherSlot;
@@ -665,9 +702,15 @@ export declare class Store {
665
702
  listRuns(opts?: {
666
703
  loopId?: string;
667
704
  status?: RunStatus;
705
+ labels?: string[];
668
706
  limit?: number;
669
707
  offset?: number;
670
708
  }): LoopRun[];
709
+ listRecoveredLeaseRunsPage(opts?: {
710
+ snapshot?: RecoveredLeaseRunSnapshotEntry[];
711
+ offset?: number;
712
+ limit?: number;
713
+ }): RecoveredLeaseRunPage;
671
714
  writeRunReceipt(input: WriteRunReceiptInput, opts?: {
672
715
  now?: Date;
673
716
  }): RunReceipt;
@@ -684,6 +727,7 @@ export declare class Store {
684
727
  recoverExpiredRunLeases(now?: Date, opts?: DaemonLeaseFence & {
685
728
  limit?: number;
686
729
  scanLimit?: number;
730
+ runId?: string;
687
731
  }): LoopRun[];
688
732
  /**
689
733
  * Recover expired run leases and report both outcomes: runs abandoned (no
@@ -694,6 +738,7 @@ export declare class Store {
694
738
  recoverExpiredRunLeasesDetailed(now?: Date, opts?: DaemonLeaseFence & {
695
739
  limit?: number;
696
740
  scanLimit?: number;
741
+ runId?: string;
697
742
  }): RecoverExpiredRunLeasesResult;
698
743
  expireLoops(now?: Date, opts?: DaemonLeaseFence): Loop[];
699
744
  countLoops(status?: LoopStatus, opts?: {