@hasna/loops 0.4.27 → 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 (79) hide show
  1. package/CHANGELOG.md +205 -1
  2. package/README.md +232 -49
  3. package/dist/api/index.d.ts +20 -19
  4. package/dist/api/index.js +7770 -1342
  5. package/dist/cli/index.js +2976 -966
  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 +1899 -499
  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 +5319 -1096
  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/executor.d.ts +9 -0
  22. package/dist/lib/format.d.ts +2 -2
  23. package/dist/lib/goal/runner.d.ts +36 -3
  24. package/dist/lib/health.d.ts +1 -1
  25. package/dist/lib/labels.d.ts +4 -0
  26. package/dist/lib/loop-status.d.ts +4 -0
  27. package/dist/lib/migration.d.ts +70 -17
  28. package/dist/lib/mode.d.ts +2 -5
  29. package/dist/lib/mode.js +28 -37
  30. package/dist/lib/route/fields.d.ts +8 -0
  31. package/dist/lib/route/index.d.ts +2 -2
  32. package/dist/lib/route/throttle.d.ts +7 -0
  33. package/dist/lib/route/types.d.ts +3 -0
  34. package/dist/lib/run-completion.d.ts +18 -0
  35. package/dist/lib/scheduler.d.ts +5 -11
  36. package/dist/lib/storage/contract.d.ts +15 -1
  37. package/dist/lib/storage/index.d.ts +1 -1
  38. package/dist/lib/storage/index.js +4083 -486
  39. package/dist/lib/storage/pg-executor.d.ts +10 -5
  40. package/dist/lib/storage/postgres-loop-storage.d.ts +52 -26
  41. package/dist/lib/storage/postgres-schema.d.ts +8 -0
  42. package/dist/lib/storage/postgres-schema.js +1326 -1
  43. package/dist/lib/storage/postgres.d.ts +3 -1
  44. package/dist/lib/storage/postgres.js +1356 -27
  45. package/dist/lib/storage/provider-credentials.d.ts +84 -0
  46. package/dist/lib/storage/shared-database-transfer.d.ts +136 -0
  47. package/dist/lib/storage/sqlite.d.ts +15 -2
  48. package/dist/lib/storage/sqlite.js +1379 -217
  49. package/dist/lib/storage/tenant-backfill-s3.d.ts +53 -0
  50. package/dist/lib/storage/tenant-backfill.d.ts +40 -0
  51. package/dist/lib/store/index.d.ts +14 -8
  52. package/dist/lib/store.d.ts +129 -7
  53. package/dist/lib/store.js +1352 -218
  54. package/dist/lib/templates.d.ts +11 -0
  55. package/dist/lib/workflow-events.d.ts +6 -0
  56. package/dist/lib/workflow-provenance.d.ts +8 -0
  57. package/dist/lib/workflow-runner.d.ts +52 -4
  58. package/dist/mcp/index.js +2074 -657
  59. package/dist/runner/index.d.ts +20 -2
  60. package/dist/runner/index.js +2146 -183
  61. package/dist/sdk/http.d.ts +364 -4
  62. package/dist/sdk/http.js +379 -1
  63. package/dist/sdk/index.d.ts +7 -2
  64. package/dist/sdk/index.js +2341 -742
  65. package/dist/serve/index.d.ts +14 -0
  66. package/dist/serve/index.js +13269 -1830
  67. package/dist/types.d.ts +75 -3
  68. package/docs/AUTOMATION_RUNTIME_DESIGN.md +32 -32
  69. package/docs/CUTOVER-RUNBOOK.md +158 -31
  70. package/docs/DEPLOYMENT_MODES.md +84 -56
  71. package/docs/RUNTIME_BOUNDARY.md +26 -26
  72. package/docs/SHARED-DATABASE-TRANSFER.md +95 -0
  73. package/docs/SHARED_KIT_EXTRACTION_INVENTORY.md +631 -0
  74. package/docs/TRANSCRIPT_LOOP_PATTERNS.md +3 -3
  75. package/docs/UNIFIED_PRODUCT_CONTRACT.md +365 -0
  76. package/docs/USAGE.md +150 -56
  77. package/docs/workflows/transcript-feedback-to-loops.json +2 -2
  78. package/package.json +8 -4
  79. package/dist/lib/storage/pg-runner-claim.d.ts +0 -40
package/dist/sdk/http.js CHANGED
@@ -61,6 +61,20 @@ class LoopsClient {
61
61
  init
62
62
  });
63
63
  }
64
+ async healthzProbe(init) {
65
+ return this.request("GET", `/healthz`, {
66
+ body: undefined,
67
+ query: undefined,
68
+ init
69
+ });
70
+ }
71
+ async openapiJsonProbe(init) {
72
+ return this.request("GET", `/openapi.json`, {
73
+ body: undefined,
74
+ query: undefined,
75
+ init
76
+ });
77
+ }
64
78
  async readyCheck(init) {
65
79
  return this.request("GET", `/ready`, {
66
80
  body: undefined,
@@ -68,6 +82,97 @@ class LoopsClient {
68
82
  init
69
83
  });
70
84
  }
85
+ async readyzProbe(init) {
86
+ return this.request("GET", `/readyz`, {
87
+ body: undefined,
88
+ query: undefined,
89
+ init
90
+ });
91
+ }
92
+ async statusRead(init) {
93
+ return this.request("GET", `/status`, {
94
+ body: undefined,
95
+ query: undefined,
96
+ init
97
+ });
98
+ }
99
+ async apiRead(init) {
100
+ return this.request("GET", `/v1`, {
101
+ body: undefined,
102
+ query: undefined,
103
+ init
104
+ });
105
+ }
106
+ async goalRunsList(init) {
107
+ return this.request("GET", `/v1/goal-runs`, {
108
+ body: undefined,
109
+ query: undefined,
110
+ init
111
+ });
112
+ }
113
+ async goalsList(init) {
114
+ return this.request("GET", `/v1/goals`, {
115
+ body: undefined,
116
+ query: undefined,
117
+ init
118
+ });
119
+ }
120
+ async goalsGet(id, init) {
121
+ return this.request("GET", `/v1/goals/${encodeURIComponent(String(id))}`, {
122
+ body: undefined,
123
+ query: undefined,
124
+ init
125
+ });
126
+ }
127
+ async goalsPlanNodes(id, init) {
128
+ return this.request("GET", `/v1/goals/${encodeURIComponent(String(id))}/plan-nodes`, {
129
+ body: undefined,
130
+ query: undefined,
131
+ init
132
+ });
133
+ }
134
+ async historyPrune(init) {
135
+ return this.request("POST", `/v1/history/prune`, {
136
+ body: undefined,
137
+ query: undefined,
138
+ init
139
+ });
140
+ }
141
+ async importRows(body, init) {
142
+ return this.request("POST", `/v1/import`, {
143
+ body,
144
+ query: undefined,
145
+ init
146
+ });
147
+ }
148
+ async listWorkflowInvocations(query, init) {
149
+ return this.request("GET", `/v1/invocations`, {
150
+ body: undefined,
151
+ query,
152
+ init
153
+ });
154
+ }
155
+ async createWorkflowInvocation(body, init) {
156
+ return this.request("POST", `/v1/invocations`, {
157
+ body,
158
+ query: undefined,
159
+ init
160
+ });
161
+ }
162
+ async invocationsGet(id, init) {
163
+ return this.request("GET", `/v1/invocations/${encodeURIComponent(String(id))}`, {
164
+ body: undefined,
165
+ query: undefined,
166
+ init
167
+ });
168
+ }
169
+ async leasesRecover(init) {
170
+ return this.request("POST", `/v1/leases/recover`, {
171
+ body: undefined,
172
+ query: undefined,
173
+ init
174
+ });
175
+ }
71
176
  async listLoops(query, init) {
72
177
  return this.request("GET", `/v1/loops`, {
73
178
  body: undefined,
@@ -82,6 +187,13 @@ class LoopsClient {
82
187
  init
83
188
  });
84
189
  }
190
+ async countLoops(query, init) {
191
+ return this.request("GET", `/v1/loops/count`, {
192
+ body: undefined,
193
+ query,
194
+ init
195
+ });
196
+ }
85
197
  async getLoop(id, init) {
86
198
  return this.request("GET", `/v1/loops/${encodeURIComponent(String(id))}`, {
87
199
  body: undefined,
@@ -110,6 +222,13 @@ class LoopsClient {
110
222
  init
111
223
  });
112
224
  }
225
+ async loopsRename(id, init) {
226
+ return this.request("POST", `/v1/loops/${encodeURIComponent(String(id))}/rename`, {
227
+ body: undefined,
228
+ query: undefined,
229
+ init
230
+ });
231
+ }
113
232
  async unarchiveLoop(id, init) {
114
233
  return this.request("POST", `/v1/loops/${encodeURIComponent(String(id))}/unarchive`, {
115
234
  body: undefined,
@@ -138,6 +257,20 @@ class LoopsClient {
138
257
  init
139
258
  });
140
259
  }
260
+ async runnersClaim(body, init) {
261
+ return this.request("POST", `/v1/runners/claim`, {
262
+ body,
263
+ query: undefined,
264
+ init
265
+ });
266
+ }
267
+ async runnersPoll(body, init) {
268
+ return this.request("POST", `/v1/runners/poll`, {
269
+ body,
270
+ query: undefined,
271
+ init
272
+ });
273
+ }
141
274
  async listRuns(query, init) {
142
275
  return this.request("GET", `/v1/runs`, {
143
276
  body: undefined,
@@ -145,8 +278,253 @@ class LoopsClient {
145
278
  init
146
279
  });
147
280
  }
148
- async getRun(id, init) {
281
+ async countRuns(query, init) {
282
+ return this.request("GET", `/v1/runs/count`, {
283
+ body: undefined,
284
+ query,
285
+ init
286
+ });
287
+ }
288
+ async getRun(id, query, init) {
149
289
  return this.request("GET", `/v1/runs/${encodeURIComponent(String(id))}`, {
290
+ body: undefined,
291
+ query,
292
+ init
293
+ });
294
+ }
295
+ async runsEvidence(id, body, init) {
296
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/evidence`, {
297
+ body,
298
+ query: undefined,
299
+ init
300
+ });
301
+ }
302
+ async runsFinalize(id, body, init) {
303
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/finalize`, {
304
+ body,
305
+ query: undefined,
306
+ init
307
+ });
308
+ }
309
+ async runsGoalsCreate(id, body, init) {
310
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/goals`, {
311
+ body,
312
+ query: undefined,
313
+ init
314
+ });
315
+ }
316
+ async runsGoalsFind(id, body, init) {
317
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/goals/find`, {
318
+ body,
319
+ query: undefined,
320
+ init
321
+ });
322
+ }
323
+ async runsGoalsEvents(id, goalId, body, init) {
324
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/goals/${encodeURIComponent(String(goalId))}/events`, {
325
+ body,
326
+ query: undefined,
327
+ init
328
+ });
329
+ }
330
+ async runsGoalsGet(id, goalId, body, init) {
331
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/goals/${encodeURIComponent(String(goalId))}/get`, {
332
+ body,
333
+ query: undefined,
334
+ init
335
+ });
336
+ }
337
+ async runsGoalsPlanNodesCreate(id, goalId, body, init) {
338
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/goals/${encodeURIComponent(String(goalId))}/plan-nodes`, {
339
+ body,
340
+ query: undefined,
341
+ init
342
+ });
343
+ }
344
+ async runsGoalsPlanNodesList(id, goalId, body, init) {
345
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/goals/${encodeURIComponent(String(goalId))}/plan-nodes/list`, {
346
+ body,
347
+ query: undefined,
348
+ init
349
+ });
350
+ }
351
+ async runsGoalsPlanNodesUpdate(id, goalId, key, body, init) {
352
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/goals/${encodeURIComponent(String(goalId))}/plan-nodes/${encodeURIComponent(String(key))}`, {
353
+ body,
354
+ query: undefined,
355
+ init
356
+ });
357
+ }
358
+ async runsGoalsStatus(id, goalId, body, init) {
359
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/goals/${encodeURIComponent(String(goalId))}/status`, {
360
+ body,
361
+ query: undefined,
362
+ init
363
+ });
364
+ }
365
+ async runsHeartbeat(id, body, init) {
366
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/heartbeat`, {
367
+ body,
368
+ query: undefined,
369
+ init
370
+ });
371
+ }
372
+ async runsRecover(id, init) {
373
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/recover`, {
374
+ body: undefined,
375
+ query: undefined,
376
+ init
377
+ });
378
+ }
379
+ async runsWorkflowRunsCreate(id, body, init) {
380
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/workflow-runs`, {
381
+ body,
382
+ query: undefined,
383
+ init
384
+ });
385
+ }
386
+ async runsWorkflowRunsEvents(id, workflowRunId, body, init) {
387
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/workflow-runs/${encodeURIComponent(String(workflowRunId))}/events`, {
388
+ body,
389
+ query: undefined,
390
+ init
391
+ });
392
+ }
393
+ async runsWorkflowRunsFinalize(id, workflowRunId, body, init) {
394
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/workflow-runs/${encodeURIComponent(String(workflowRunId))}/finalize`, {
395
+ body,
396
+ query: undefined,
397
+ init
398
+ });
399
+ }
400
+ async runsWorkflowRunsGet(id, workflowRunId, body, init) {
401
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/workflow-runs/${encodeURIComponent(String(workflowRunId))}/get`, {
402
+ body,
403
+ query: undefined,
404
+ init
405
+ });
406
+ }
407
+ async runsWorkflowRunsRecover(id, workflowRunId, body, init) {
408
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/workflow-runs/${encodeURIComponent(String(workflowRunId))}/recover`, {
409
+ body,
410
+ query: undefined,
411
+ init
412
+ });
413
+ }
414
+ async runsWorkflowRunsSteps(id, workflowRunId, body, init) {
415
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/workflow-runs/${encodeURIComponent(String(workflowRunId))}/steps`, {
416
+ body,
417
+ query: undefined,
418
+ init
419
+ });
420
+ }
421
+ async runsWorkflowRunsStepAction(id, workflowRunId, stepId, action, body, init) {
422
+ return this.request("POST", `/v1/runs/${encodeURIComponent(String(id))}/workflow-runs/${encodeURIComponent(String(workflowRunId))}/steps/${encodeURIComponent(String(stepId))}/${encodeURIComponent(String(action))}`, {
423
+ body,
424
+ query: undefined,
425
+ init
426
+ });
427
+ }
428
+ async apiStatus(init) {
429
+ return this.request("GET", `/v1/status`, {
430
+ body: undefined,
431
+ query: undefined,
432
+ init
433
+ });
434
+ }
435
+ async v1VersionProbe(init) {
436
+ return this.request("GET", `/v1/version`, {
437
+ body: undefined,
438
+ query: undefined,
439
+ init
440
+ });
441
+ }
442
+ async listWorkflowWorkItems(query, init) {
443
+ return this.request("GET", `/v1/work-items`, {
444
+ body: undefined,
445
+ query,
446
+ init
447
+ });
448
+ }
449
+ async upsertWorkflowWorkItem(body, init) {
450
+ return this.request("POST", `/v1/work-items`, {
451
+ body,
452
+ query: undefined,
453
+ init
454
+ });
455
+ }
456
+ async workItemsGet(id, init) {
457
+ return this.request("GET", `/v1/work-items/${encodeURIComponent(String(id))}`, {
458
+ body: undefined,
459
+ query: undefined,
460
+ init
461
+ });
462
+ }
463
+ async workflowRunsList(init) {
464
+ return this.request("GET", `/v1/workflow-runs`, {
465
+ body: undefined,
466
+ query: undefined,
467
+ init
468
+ });
469
+ }
470
+ async workflowRunsGet(id, init) {
471
+ return this.request("GET", `/v1/workflow-runs/${encodeURIComponent(String(id))}`, {
472
+ body: undefined,
473
+ query: undefined,
474
+ init
475
+ });
476
+ }
477
+ async workflowRunsEvents(id, init) {
478
+ return this.request("GET", `/v1/workflow-runs/${encodeURIComponent(String(id))}/events`, {
479
+ body: undefined,
480
+ query: undefined,
481
+ init
482
+ });
483
+ }
484
+ async workflowRunsRecover(id, body, init) {
485
+ return this.request("POST", `/v1/workflow-runs/${encodeURIComponent(String(id))}/recover`, {
486
+ body,
487
+ query: undefined,
488
+ init
489
+ });
490
+ }
491
+ async workflowRunsSteps(id, init) {
492
+ return this.request("GET", `/v1/workflow-runs/${encodeURIComponent(String(id))}/steps`, {
493
+ body: undefined,
494
+ query: undefined,
495
+ init
496
+ });
497
+ }
498
+ async listWorkflows(query, init) {
499
+ return this.request("GET", `/v1/workflows`, {
500
+ body: undefined,
501
+ query,
502
+ init
503
+ });
504
+ }
505
+ async createWorkflow(body, init) {
506
+ return this.request("POST", `/v1/workflows`, {
507
+ body,
508
+ query: undefined,
509
+ init
510
+ });
511
+ }
512
+ async countWorkflows(query, init) {
513
+ return this.request("GET", `/v1/workflows/count`, {
514
+ body: undefined,
515
+ query,
516
+ init
517
+ });
518
+ }
519
+ async getWorkflow(id, init) {
520
+ return this.request("GET", `/v1/workflows/${encodeURIComponent(String(id))}`, {
521
+ body: undefined,
522
+ query: undefined,
523
+ init
524
+ });
525
+ }
526
+ async workflowsArchive(id, init) {
527
+ return this.request("POST", `/v1/workflows/${encodeURIComponent(String(id))}/archive`, {
150
528
  body: undefined,
151
529
  query: undefined,
152
530
  init
@@ -6,8 +6,8 @@ import { tick } from "../lib/scheduler.js";
6
6
  import { Store } from "../lib/store.js";
7
7
  import { type LoopStore } from "../lib/store/index.js";
8
8
  export { runGoal } from "../lib/goal/runner.js";
9
- export { LOOPS_MIGRATION_SCHEMA, applyImportMigrationBundle, buildImportMigrationPlan, buildSelfHostedMigrationPlan, exportLoopsMigrationBundle, migrationHash, registerSelfHostedRunner, validateLoopsMigrationBundle, } from "../lib/migration.js";
10
- export type { ApplyLoopsMigrationResult, ExportLoopsMigrationOptions, ImportLoopsMigrationOptions, LoopsMigrationAction, LoopsMigrationBundle, LoopsMigrationPlan, LoopsMigrationPlanRow, LoopsMigrationPlanSummary, LoopsMigrationResource, RunnerRegistrationOptions, RunnerRegistrationResult, SelfHostedPlanOptions, } from "../lib/migration.js";
9
+ export { LOOPS_MIGRATION_SCHEMA, applyImportMigrationBundle, buildImportMigrationPlan, buildSelfHostedMigrationPlan, exportLoopsMigrationBundle, migrationHash, validateLoopsMigrationBundle, } from "../lib/migration.js";
10
+ export type { ApplyLoopsMigrationResult, ExportLoopsMigrationOptions, ImportLoopsMigrationOptions, LoopsMigrationAction, LoopsMigrationBundle, LoopsMigrationPlan, LoopsMigrationPlanRow, LoopsMigrationPlanSummary, LoopsMigrationResource, SelfHostedPlanOptions, } from "../lib/migration.js";
11
11
  export interface LoopsClientOptions {
12
12
  /**
13
13
  * Inject an on-box sqlite {@link Store} (mainly for tests and in-process local
@@ -28,6 +28,7 @@ export interface LoopsClientOptions {
28
28
  }
29
29
  export interface ListLoopsFilters {
30
30
  status?: LoopStatus;
31
+ labels?: string[];
31
32
  limit?: number;
32
33
  /** include archived loops alongside live ones */
33
34
  includeArchived?: boolean;
@@ -36,6 +37,7 @@ export interface ListLoopsFilters {
36
37
  }
37
38
  export interface ListRunsFilters {
38
39
  status?: RunStatus;
40
+ labels?: string[];
39
41
  limit?: number;
40
42
  }
41
43
  export interface ListRunReceiptsFilters {
@@ -70,6 +72,9 @@ export declare class LoopsClient {
70
72
  pause(idOrName: string): Promise<Loop>;
71
73
  resume(idOrName: string): Promise<Loop>;
72
74
  stop(idOrName: string): Promise<Loop>;
75
+ setLabels(idOrName: string, labels: string[]): Promise<Loop>;
76
+ addLabels(idOrName: string, labels: string[]): Promise<Loop>;
77
+ removeLabels(idOrName: string, labels: string[]): Promise<Loop>;
73
78
  archive(idOrName: string): Promise<Loop>;
74
79
  unarchive(idOrName: string): Promise<Loop>;
75
80
  delete(idOrName: string): Promise<boolean>;