runwork 0.26.0 → 0.27.1

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.
@@ -229,14 +229,17 @@ export declare const integrationApiSchema: z.ZodObject<{
229
229
  method: z.ZodDefault<z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE"]>>;
230
230
  endpoint: z.ZodString;
231
231
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
232
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
232
233
  }, "strip", z.ZodTypeAny, {
233
234
  endpoint: string;
234
235
  method: "POST" | "GET" | "PUT" | "PATCH" | "DELETE";
235
236
  data?: Record<string, unknown> | undefined;
237
+ headers?: Record<string, string> | undefined;
236
238
  }, {
237
239
  endpoint: string;
238
240
  data?: Record<string, unknown> | undefined;
239
241
  method?: "POST" | "GET" | "PUT" | "PATCH" | "DELETE" | undefined;
242
+ headers?: Record<string, string> | undefined;
240
243
  }>;
241
244
  /**
242
245
  * Get tool definitions for integration access
@@ -6,6 +6,16 @@
6
6
  * - Creates WorkflowInstance DOs
7
7
  * - Maintains an index for querying workflows
8
8
  * - Routes signals to correct instances
9
+ *
10
+ * Index storage: one storage key per instance entry (`index:<instanceId>`),
11
+ * read back with a prefix list. A single-value index hits the 2 MB per-value
12
+ * limit of SQLite-backed DO storage at roughly 11,000 entries, after which every
13
+ * write fails with SQLITE_TOOBIG. Apps deployed before the per-key layout still
14
+ * hold the legacy `workflow_index` value; it is migrated on first load.
15
+ *
16
+ * Retention: terminal entries older than the retention window are pruned from
17
+ * a self-armed alarm, and the index is trimmed inline when a write pushes it
18
+ * past the entry cap, so the index stays bounded without an external caller.
9
19
  */
10
20
  import { DurableObject } from 'cloudflare:workers';
11
21
  import type { NativeWorkflowStatus, NativeWorkflowConfig, ListWorkflowsOptions, WorkflowInstanceInfo, WorkflowInstanceStub } from './core-workflow-types';
@@ -19,8 +29,14 @@ import { type Env } from './core-utils';
19
29
  */
20
30
  export declare class WorkflowCoordinator extends DurableObject<Env> {
21
31
  private index;
32
+ /** Entry cap applied inline on writes and by the retention alarm. */
33
+ readonly retentionMaxEntries = 10000;
22
34
  /**
23
- * Create a new workflow instance
35
+ * Create a new workflow instance.
36
+ *
37
+ * The index entry and stored params are written before the instance starts,
38
+ * so a completion notification from a fast workflow can never race ahead of
39
+ * its own pending entry, and an index failure surfaces before any work runs.
24
40
  */
25
41
  create(workflowName: string, params: Record<string, unknown>, config?: Partial<NativeWorkflowConfig>, metadata?: Record<string, unknown>): Promise<string>;
26
42
  /**
@@ -65,14 +81,36 @@ export declare class WorkflowCoordinator extends DurableObject<Env> {
65
81
  byWorkflow: Record<string, number>;
66
82
  }>;
67
83
  /**
68
- * Clean up completed/old workflow entries
69
- * Should be called periodically to prevent index bloat
84
+ * Clean up completed/old workflow entries.
85
+ *
86
+ * Removes terminal entries older than `olderThanMs`, every completed entry
87
+ * unless `keepCompleted` is set, and then the oldest terminal entries until
88
+ * the index fits within `maxEntries`. Active entries (pending, running,
89
+ * sleeping, waiting, paused) are never removed. Runs from the retention alarm
90
+ * and inline on writes; explicit calls remain supported.
70
91
  */
71
92
  cleanup(options?: {
72
93
  olderThanMs?: number;
73
94
  keepCompleted?: boolean;
74
95
  maxEntries?: number;
75
96
  }): Promise<number>;
97
+ /**
98
+ * Retention alarm: prune old terminal entries and re-arm while the index
99
+ * still holds anything.
100
+ */
101
+ alarm(): Promise<void>;
76
102
  private ensureIndexLoaded;
77
- private persistIndex;
103
+ /**
104
+ * Move a legacy single-value index into per-entry keys. Per-entry values
105
+ * already present win, since they were written after the legacy value.
106
+ * An unreadable legacy value is dropped: the workflow instances themselves
107
+ * still hold their state, only the listing loses history.
108
+ */
109
+ private migrateLegacyIndex;
110
+ private deleteLegacyIndexKey;
111
+ /**
112
+ * Remove index entries and their stored params, in storage batches.
113
+ */
114
+ private removeEntries;
115
+ private ensureRetentionAlarm;
78
116
  }
@@ -28,7 +28,12 @@ export interface NangoProxyOptions {
28
28
  method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
29
29
  endpoint: string;
30
30
  providerConfigKey: string;
31
- data?: Record<string, unknown>;
31
+ /**
32
+ * Request body. Encoded per the Content-Type in `headers`: form-encoded with
33
+ * bracket notation for application/x-www-form-urlencoded, JSON otherwise.
34
+ * A string is sent verbatim.
35
+ */
36
+ data?: Record<string, unknown> | string;
32
37
  headers?: Record<string, string>;
33
38
  params?: Record<string, string>;
34
39
  retries?: number;