@workflow/world-testing 5.1.4 → 5.1.5

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.
@@ -23881,6 +23881,9 @@ var init_attributes = __esm({
23881
23881
  function getOwnProperty(object2, key) {
23882
23882
  return Object.hasOwn(object2, key) ? object2[key] : void 0;
23883
23883
  }
23884
+ function isSealedNoopEvent(event) {
23885
+ return event.eventType === "noop";
23886
+ }
23884
23887
  function getEventDataRefFields(eventType) {
23885
23888
  return getOwnProperty(EVENT_DATA_REF_FIELDS_BY_EVENT_TYPE, eventType) ?? NO_EVENT_DATA_REF_FIELDS;
23886
23889
  }
@@ -23892,6 +23895,7 @@ var init_event_metadata = __esm({
23892
23895
  "../world/dist/event-metadata.js"() {
23893
23896
  "use strict";
23894
23897
  __name(getOwnProperty, "getOwnProperty");
23898
+ __name(isSealedNoopEvent, "isSealedNoopEvent");
23895
23899
  EVENT_DATA_REF_FIELDS_BY_EVENT_TYPE = {
23896
23900
  run_created: [
23897
23901
  "input"
@@ -26312,6 +26316,260 @@ var init_ulid = __esm({
26312
26316
  }
26313
26317
  });
26314
26318
 
26319
+ // ../world/dist/usage.js
26320
+ function spanOf(eventType, workflowName) {
26321
+ if (eventType.startsWith("hook_")) return {
26322
+ kind: "hook",
26323
+ name: "hook"
26324
+ };
26325
+ if (eventType.startsWith("wait_")) return {
26326
+ kind: "wait",
26327
+ name: "sleep"
26328
+ };
26329
+ if (eventType.startsWith("run_")) return {
26330
+ kind: "run",
26331
+ name: workflowName
26332
+ };
26333
+ if (eventType === "attr_set") {
26334
+ return {
26335
+ kind: "attributes",
26336
+ name: "attributes"
26337
+ };
26338
+ }
26339
+ return {
26340
+ kind: "other",
26341
+ name: "other"
26342
+ };
26343
+ }
26344
+ function compareCodeUnits(a, b) {
26345
+ return a < b ? -1 : a > b ? 1 : 0;
26346
+ }
26347
+ function toCount(value) {
26348
+ const n = Number(value);
26349
+ return Number.isFinite(n) && n > 0 ? n : 0;
26350
+ }
26351
+ function usageEntityOfEventType(eventType) {
26352
+ if (isSealedNoopEvent({
26353
+ eventType
26354
+ })) return null;
26355
+ if (eventType.startsWith("step_")) return "step";
26356
+ if (eventType.startsWith("hook_")) return "hook";
26357
+ return "run";
26358
+ }
26359
+ function buildRunUsage(input2) {
26360
+ const spans = /* @__PURE__ */ new Map();
26361
+ const byEntity = {
26362
+ run: 0,
26363
+ step: 0,
26364
+ hook: 0,
26365
+ stream: toCount(input2.streamBytes)
26366
+ };
26367
+ let events = 0;
26368
+ let retries = 0;
26369
+ const add3 = /* @__PURE__ */ __name((kind, name, entity, count2, retryCount, bytes) => {
26370
+ if (count2 <= 0) return;
26371
+ const key = `${kind}\0${name}`;
26372
+ let span = spans.get(key);
26373
+ if (!span) {
26374
+ span = {
26375
+ kind,
26376
+ name,
26377
+ events: 0,
26378
+ share: 0,
26379
+ retries: 0,
26380
+ calls: 0
26381
+ };
26382
+ spans.set(key, span);
26383
+ }
26384
+ span.events += count2;
26385
+ span.retries += retryCount;
26386
+ events += count2;
26387
+ retries += retryCount;
26388
+ byEntity[entity] += bytes;
26389
+ }, "add");
26390
+ const created = {
26391
+ hook: 0,
26392
+ wait: 0
26393
+ };
26394
+ const hookGroups = input2.hookGroups;
26395
+ let hookEvents = 0;
26396
+ const runEvents = {
26397
+ events: 0,
26398
+ byType: {
26399
+ created: 0,
26400
+ started: 0,
26401
+ completed: 0,
26402
+ failed: 0,
26403
+ cancelled: 0
26404
+ }
26405
+ };
26406
+ for (const group of input2.eventGroups) {
26407
+ const entity = usageEntityOfEventType(group.eventType);
26408
+ if (!entity) continue;
26409
+ const runType = group.eventType.slice("run_".length);
26410
+ if (group.eventType.startsWith("run_") && RUN_USAGE_RUN_EVENT_TYPES.includes(runType)) {
26411
+ runEvents.byType[runType] += toCount(group.events);
26412
+ }
26413
+ if (group.eventType.startsWith("run_")) {
26414
+ runEvents.events += toCount(group.events);
26415
+ }
26416
+ if (group.eventType === "hook_created") created.hook += toCount(group.events);
26417
+ if (group.eventType === "wait_created") created.wait += toCount(group.events);
26418
+ const { kind, name } = spanOf(group.eventType, input2.workflowName);
26419
+ if (kind === "hook" && hookGroups) {
26420
+ hookEvents += toCount(group.events);
26421
+ events += toCount(group.events);
26422
+ byEntity[entity] += toCount(group.bytes);
26423
+ continue;
26424
+ }
26425
+ add3(kind, name, entity, toCount(group.events), 0, toCount(group.bytes));
26426
+ }
26427
+ if (hookGroups) {
26428
+ let grouped = 0;
26429
+ for (const group of hookGroups) {
26430
+ const count2 = toCount(group.events);
26431
+ if (count2 <= 0 || !group.hookId) continue;
26432
+ grouped += count2;
26433
+ spans.set(`hook\0${group.hookId}`, {
26434
+ kind: "hook",
26435
+ name: group.token || group.hookId,
26436
+ id: group.hookId,
26437
+ events: count2,
26438
+ share: 0,
26439
+ retries: 0,
26440
+ calls: 1
26441
+ });
26442
+ }
26443
+ if (hookEvents > grouped) {
26444
+ spans.set("hook\0", {
26445
+ kind: "hook",
26446
+ name: "hook",
26447
+ events: hookEvents - grouped,
26448
+ share: 0,
26449
+ retries: 0,
26450
+ calls: 0
26451
+ });
26452
+ }
26453
+ }
26454
+ const calls = {
26455
+ hook: toCount(created.hook),
26456
+ wait: toCount(input2.calls?.wait ?? created.wait)
26457
+ };
26458
+ const stepEvents = {
26459
+ steps: 0,
26460
+ events: 0,
26461
+ byType: {
26462
+ created: 0,
26463
+ started: 0,
26464
+ completed: 0,
26465
+ failed: 0,
26466
+ retrying: 0,
26467
+ other: 0
26468
+ }
26469
+ };
26470
+ let restarts = 0;
26471
+ for (const group of input2.stepGroups) {
26472
+ restarts += toCount(group.restarts);
26473
+ const counts = {
26474
+ created: toCount(group.created),
26475
+ started: toCount(group.started),
26476
+ completed: toCount(group.completed),
26477
+ failed: toCount(group.failed),
26478
+ retrying: toCount(group.retries)
26479
+ };
26480
+ const total = toCount(group.events);
26481
+ if (total <= 0) continue;
26482
+ stepEvents.steps += toCount(group.steps);
26483
+ stepEvents.events += total;
26484
+ let known = 0;
26485
+ for (const type of RUN_USAGE_STEP_EVENT_TYPES) {
26486
+ stepEvents.byType[type] += counts[type];
26487
+ known += counts[type];
26488
+ }
26489
+ stepEvents.byType.other += Math.max(0, total - known);
26490
+ const name = group.stepName || UNKNOWN_STEP_NAME;
26491
+ add3("step", name, "step", toCount(group.events), toCount(group.retries), toCount(group.bytes));
26492
+ const span = spans.get(`step\0${name}`);
26493
+ if (span) span.calls += toCount(group.steps);
26494
+ }
26495
+ for (const span of spans.values()) {
26496
+ if (span.kind === "run") span.calls = 1;
26497
+ if (span.kind === "hook" && !hookGroups) span.calls = calls.hook;
26498
+ if (span.kind === "wait") span.calls = calls.wait;
26499
+ if (span.kind === "attributes" || span.kind === "other") {
26500
+ span.calls = span.events;
26501
+ }
26502
+ }
26503
+ const eventsBySpan = [
26504
+ ...spans.values()
26505
+ ].map((span) => ({
26506
+ ...span,
26507
+ share: events > 0 ? span.events / events : 0
26508
+ })).sort((a, b) => b.events - a.events || compareCodeUnits(a.name, b.name) || compareCodeUnits(a.kind, b.kind) || compareCodeUnits(a.id ?? "", b.id ?? ""));
26509
+ return {
26510
+ runId: input2.runId,
26511
+ status: input2.status,
26512
+ workflowName: input2.workflowName,
26513
+ billed: input2.billed === true,
26514
+ inProgress: !isTerminalWorkflowRunStatus(input2.status),
26515
+ events,
26516
+ billableEvents: events,
26517
+ retries: {
26518
+ count: retries,
26519
+ events: retries + restarts
26520
+ },
26521
+ runEvents,
26522
+ stepEvents,
26523
+ eventsBySpan,
26524
+ dataWritten: dataWrittenOf(input2, byEntity),
26525
+ dataPurged: input2.dataPurged === true,
26526
+ dataRetained: input2.dataRetained ?? null
26527
+ };
26528
+ }
26529
+ function dataWrittenOf(input2, measured) {
26530
+ const saved = input2.dataPurged ? input2.savedDataWritten : void 0;
26531
+ const byEntity = saved ? {
26532
+ run: toCount(saved.run),
26533
+ step: toCount(saved.step),
26534
+ hook: toCount(saved.hook),
26535
+ stream: toCount(saved.stream)
26536
+ } : measured;
26537
+ return {
26538
+ bytes: byEntity.run + byEntity.step + byEntity.hook + byEntity.stream,
26539
+ byEntity,
26540
+ source: !input2.dataPurged ? "log" : saved ? "saved-at-purge" : "left-after-purge"
26541
+ };
26542
+ }
26543
+ var RUN_USAGE_RUN_EVENT_TYPES, RUN_USAGE_STEP_EVENT_TYPES, UNKNOWN_STEP_NAME;
26544
+ var init_usage = __esm({
26545
+ "../world/dist/usage.js"() {
26546
+ "use strict";
26547
+ init_event_metadata();
26548
+ init_runs();
26549
+ RUN_USAGE_RUN_EVENT_TYPES = [
26550
+ "created",
26551
+ "started",
26552
+ "completed",
26553
+ "failed",
26554
+ "cancelled"
26555
+ ];
26556
+ RUN_USAGE_STEP_EVENT_TYPES = [
26557
+ "created",
26558
+ "started",
26559
+ "completed",
26560
+ "failed",
26561
+ "retrying"
26562
+ ];
26563
+ UNKNOWN_STEP_NAME = "(unknown step)";
26564
+ __name(spanOf, "spanOf");
26565
+ __name(compareCodeUnits, "compareCodeUnits");
26566
+ __name(toCount, "toCount");
26567
+ __name(usageEntityOfEventType, "usageEntityOfEventType");
26568
+ __name(buildRunUsage, "buildRunUsage");
26569
+ __name(dataWrittenOf, "dataWrittenOf");
26570
+ }
26571
+ });
26572
+
26315
26573
  // ../world/dist/index.js
26316
26574
  var init_dist4 = __esm({
26317
26575
  "../world/dist/index.js"() {
@@ -26334,6 +26592,7 @@ var init_dist4 = __esm({
26334
26592
  init_start_hook();
26335
26593
  init_steps();
26336
26594
  init_ulid();
26595
+ init_usage();
26337
26596
  init_waits();
26338
26597
  }
26339
26598
  });
@@ -34133,9 +34392,9 @@ var init_abort_controller = __esm({
34133
34392
  handler.call(this);
34134
34393
  }
34135
34394
  }
34136
- constructor(streamName, hookToken) {
34395
+ constructor(streamName, hookToken2) {
34137
34396
  this[ABORT_STREAM_NAME] = streamName;
34138
- this[ABORT_HOOK_TOKEN] = hookToken;
34397
+ this[ABORT_HOOK_TOKEN] = hookToken2;
34139
34398
  }
34140
34399
  /**
34141
34400
  * @internal Sets aborted state and fires listeners.
@@ -36547,7 +36806,7 @@ var version2;
36547
36806
  var init_version = __esm({
36548
36807
  "../core/dist/version.js"() {
36549
36808
  "use strict";
36550
- version2 = "5.7.1";
36809
+ version2 = "5.7.2";
36551
36810
  }
36552
36811
  });
36553
36812
 
@@ -67319,6 +67578,141 @@ var init_recovery_wake = __esm({
67319
67578
  }
67320
67579
  });
67321
67580
 
67581
+ // ../world-local/dist/storage/purged-usage.js
67582
+ function valueBytesSql(path8) {
67583
+ const data2 = `CAST(json_extract(doc, '${path8}.data') AS BLOB)`;
67584
+ return `CASE WHEN json_extract(doc, '${path8}.__type') = 'Uint8Array'
67585
+ THEN length(${data2}) / 4 * 3 - (CASE WHEN substr(${data2}, -2) = X'3D3D' THEN 2 WHEN substr(${data2}, -1) = X'3D' THEN 1 ELSE 0 END)
67586
+ ELSE coalesce(length(CAST(doc -> '${path8}' AS BLOB)), 0) END`;
67587
+ }
67588
+ function measureStreamBytes(db, runId) {
67589
+ return Number(db.get(STREAM_BYTES_SQL, runId)?.bytes ?? 0);
67590
+ }
67591
+ function tableExists(db) {
67592
+ return db.get("SELECT 1 AS one FROM sqlite_master WHERE type = 'table' AND name = ?", TABLE) !== void 0;
67593
+ }
67594
+ function savePurgedUsage(db, runId, usage) {
67595
+ db.run(CREATE_TABLE_SQL);
67596
+ db.run(`INSERT INTO ${TABLE}
67597
+ (run_id, seq, run_bytes, step_bytes, hook_bytes, stream_bytes)
67598
+ VALUES (?, ?, ?, ?, ?, ?)
67599
+ ON CONFLICT (run_id) DO UPDATE SET
67600
+ seq = excluded.seq,
67601
+ run_bytes = excluded.run_bytes,
67602
+ step_bytes = excluded.step_bytes,
67603
+ hook_bytes = excluded.hook_bytes,
67604
+ stream_bytes = excluded.stream_bytes`, runId, usage.seq, usage.byEntity.run, usage.byEntity.step, usage.byEntity.hook, usage.byEntity.stream);
67605
+ }
67606
+ function readPurgedUsage(db, runId) {
67607
+ if (!tableExists(db)) return null;
67608
+ const row = db.get(`SELECT seq, run_bytes, step_bytes, hook_bytes, stream_bytes
67609
+ FROM ${TABLE} WHERE run_id = ?`, runId);
67610
+ if (!row) return null;
67611
+ return {
67612
+ seq: Number(row.seq),
67613
+ byEntity: {
67614
+ run: Number(row.run_bytes),
67615
+ step: Number(row.step_bytes),
67616
+ hook: Number(row.hook_bytes),
67617
+ stream: Number(row.stream_bytes)
67618
+ }
67619
+ };
67620
+ }
67621
+ function deletePurgedUsage(db, where) {
67622
+ if (!tableExists(db)) return;
67623
+ if (!where) {
67624
+ db.run(`DELETE FROM ${TABLE}`);
67625
+ return;
67626
+ }
67627
+ db.run(`DELETE FROM ${TABLE} WHERE run_id IN (${where.runIdsSql})`, ...where.params);
67628
+ }
67629
+ var PAYLOAD_PATHS, PAYLOAD_EVENT_TYPES, PAYLOAD_BYTES_SQL, STREAM_BYTES_SQL, TABLE, CREATE_TABLE_SQL, EntityBytes;
67630
+ var init_purged_usage = __esm({
67631
+ "../world-local/dist/storage/purged-usage.js"() {
67632
+ "use strict";
67633
+ init_dist4();
67634
+ PAYLOAD_PATHS = {
67635
+ // A dynamic run's code is kept on the run, not on its events, so it is
67636
+ // not here.
67637
+ run_created: [
67638
+ "$.eventData.input",
67639
+ "$.eventData.startHook.metadata"
67640
+ ],
67641
+ run_started: [
67642
+ "$.eventData.input",
67643
+ "$.eventData.startHook.metadata"
67644
+ ],
67645
+ run_completed: [
67646
+ "$.eventData.output"
67647
+ ],
67648
+ run_failed: [
67649
+ "$.eventData.error"
67650
+ ],
67651
+ step_created: [
67652
+ "$.eventData.input"
67653
+ ],
67654
+ step_started: [
67655
+ "$.eventData.input"
67656
+ ],
67657
+ step_completed: [
67658
+ "$.eventData.result"
67659
+ ],
67660
+ step_failed: [
67661
+ "$.eventData.error"
67662
+ ],
67663
+ step_retrying: [
67664
+ "$.eventData.error"
67665
+ ],
67666
+ hook_created: [
67667
+ "$.eventData.metadata"
67668
+ ],
67669
+ hook_received: [
67670
+ "$.eventData.payload"
67671
+ ]
67672
+ };
67673
+ PAYLOAD_EVENT_TYPES = Object.keys(PAYLOAD_PATHS);
67674
+ __name(valueBytesSql, "valueBytesSql");
67675
+ PAYLOAD_BYTES_SQL = `(CASE event_type ${Object.entries(PAYLOAD_PATHS).map(([eventType, paths]) => `WHEN '${eventType}' THEN ${paths.map((path8) => `(${valueBytesSql(path8)})`).join(" + ")}`).join(" ")} ELSE 0 END)`;
67676
+ STREAM_BYTES_SQL = `
67677
+ SELECT COALESCE(SUM(length(data)), 0) AS bytes
67678
+ FROM stream_chunks
67679
+ WHERE run_id = ?
67680
+ `;
67681
+ __name(measureStreamBytes, "measureStreamBytes");
67682
+ TABLE = "run_usage_purged";
67683
+ CREATE_TABLE_SQL = `
67684
+ CREATE TABLE IF NOT EXISTS ${TABLE} (
67685
+ run_id TEXT PRIMARY KEY,
67686
+ -- The last log position the sizes below cover.
67687
+ seq INTEGER NOT NULL,
67688
+ run_bytes INTEGER NOT NULL,
67689
+ step_bytes INTEGER NOT NULL,
67690
+ hook_bytes INTEGER NOT NULL,
67691
+ stream_bytes INTEGER NOT NULL
67692
+ )
67693
+ `;
67694
+ EntityBytes = class {
67695
+ static {
67696
+ __name(this, "EntityBytes");
67697
+ }
67698
+ byEntity = {
67699
+ run: 0,
67700
+ step: 0,
67701
+ hook: 0,
67702
+ stream: 0
67703
+ };
67704
+ add(eventType, bytes) {
67705
+ const entity = usageEntityOfEventType(eventType);
67706
+ if (entity) this.byEntity[entity] += Number(bytes) || 0;
67707
+ }
67708
+ };
67709
+ __name(tableExists, "tableExists");
67710
+ __name(savePurgedUsage, "savePurgedUsage");
67711
+ __name(readPurgedUsage, "readPurgedUsage");
67712
+ __name(deletePurgedUsage, "deletePurgedUsage");
67713
+ }
67714
+ });
67715
+
67322
67716
  // ../world-local/dist/ids.js
67323
67717
  function truncateForError(value) {
67324
67718
  const s = typeof value === "string" ? value : String(value);
@@ -67367,11 +67761,33 @@ function ranPurge(run2) {
67367
67761
  if (readRunRetention(run2.attributes).mode === "none") return true;
67368
67762
  return run2.expiredAt !== void 0 && new Date(run2.expiredAt).getTime() <= Date.now();
67369
67763
  }
67370
- function purgeRunData(db, runId) {
67764
+ function purgeRunData(db, runId, { purgedBefore = false } = {}) {
67371
67765
  for (const row of db.all("SELECT step_id, doc FROM steps WHERE run_id = ?", runId)) {
67372
67766
  writeScrubbedStep(db, runId, row.step_id, row.doc);
67373
67767
  }
67374
- for (const row of db.all("SELECT seq, doc FROM events WHERE run_id = ?", runId)) {
67768
+ const saved = readPurgedUsage(db, runId);
67769
+ const written = new EntityBytes();
67770
+ let lastSeq = 0;
67771
+ const events = db.all(`SELECT seq, event_type, doc, ${PAYLOAD_BYTES_SQL} AS bytes
67772
+ FROM events WHERE run_id = ?`, runId);
67773
+ for (const row of events) {
67774
+ lastSeq = Math.max(lastSeq, Number(row.seq));
67775
+ if (saved && Number(row.seq) <= saved.seq) continue;
67776
+ written.add(row.event_type, row.bytes);
67777
+ }
67778
+ written.byEntity.stream = measureStreamBytes(db, runId);
67779
+ if (saved) {
67780
+ savePurgedUsage(db, runId, {
67781
+ seq: lastSeq,
67782
+ byEntity: addBytes(saved.byEntity, written.byEntity)
67783
+ });
67784
+ } else if (!purgedBefore) {
67785
+ savePurgedUsage(db, runId, {
67786
+ seq: lastSeq,
67787
+ byEntity: written.byEntity
67788
+ });
67789
+ }
67790
+ for (const row of events) {
67375
67791
  writeScrubbedEvent(db, runId, row.seq, row.doc);
67376
67792
  }
67377
67793
  for (const row of db.all("SELECT hook_id, doc FROM hooks WHERE run_id = ?", runId)) {
@@ -67391,7 +67807,28 @@ function purgeLateStepWrite(db, runId, stepId, seq) {
67391
67807
  db.run("UPDATE steps SET doc = ? WHERE run_id = ? AND step_id = ?", encode3(step), runId, stepId);
67392
67808
  }
67393
67809
  const event = db.get("SELECT doc FROM events WHERE run_id = ? AND seq = ?", runId, seq);
67394
- if (event) writeScrubbedEvent(db, runId, seq, event.doc);
67810
+ if (!event) return;
67811
+ const saved = readPurgedUsage(db, runId);
67812
+ if (saved && seq > saved.seq) {
67813
+ const written = new EntityBytes();
67814
+ for (const row of db.all(`SELECT event_type, ${PAYLOAD_BYTES_SQL} AS bytes
67815
+ FROM events WHERE run_id = ? AND seq > ? AND seq <= ?`, runId, saved.seq, seq)) {
67816
+ written.add(row.event_type, row.bytes);
67817
+ }
67818
+ savePurgedUsage(db, runId, {
67819
+ seq,
67820
+ byEntity: addBytes(saved.byEntity, written.byEntity)
67821
+ });
67822
+ }
67823
+ writeScrubbedEvent(db, runId, seq, event.doc);
67824
+ }
67825
+ function addBytes(a, b) {
67826
+ return {
67827
+ run: a.run + b.run,
67828
+ step: a.step + b.step,
67829
+ hook: a.hook + b.hook,
67830
+ stream: a.stream + b.stream
67831
+ };
67395
67832
  }
67396
67833
  function writeScrubbedStep(db, runId, stepId, doc) {
67397
67834
  const step = decode3(doc);
@@ -67427,10 +67864,12 @@ var init_run_retention = __esm({
67427
67864
  "use strict";
67428
67865
  init_dist4();
67429
67866
  init_codec();
67867
+ init_purged_usage();
67430
67868
  __name(purgesUserDataOnFinish2, "purgesUserDataOnFinish");
67431
67869
  __name(ranPurge, "ranPurge");
67432
67870
  __name(purgeRunData, "purgeRunData");
67433
67871
  __name(purgeLateStepWrite, "purgeLateStepWrite");
67872
+ __name(addBytes, "addBytes");
67434
67873
  __name(writeScrubbedStep, "writeScrubbedStep");
67435
67874
  __name(writeScrubbedEvent, "writeScrubbedEvent");
67436
67875
  __name(purgeRunStreams, "purgeRunStreams");
@@ -67725,6 +68164,7 @@ var init_store = __esm({
67725
68164
  eventsBetween(runId, afterSeq, beforeSeq) {
67726
68165
  return this.db.all("SELECT doc FROM events WHERE run_id = ? AND seq > ? AND seq < ? ORDER BY seq", runId, afterSeq, beforeSeq).map((row) => decode3(row.doc));
67727
68166
  }
68167
+ // A caller that rewrites a live run's events makes the usage cache stale (see usage-storage.ts).
67728
68168
  rewriteEvent(event) {
67729
68169
  const seq = eventIdToSlot(event.eventId);
67730
68170
  if (seq === null) return;
@@ -68999,7 +69439,9 @@ function createRunsStorage(db, tag) {
68999
69439
  const now2 = /* @__PURE__ */ new Date();
69000
69440
  const alreadyDeleted = run2.expiredAt !== void 0 && run2.expiredAt.getTime() <= now2.getTime();
69001
69441
  if (!alreadyDeleted) store.updateRun(withRunPayloadsPurged(run2, now2));
69002
- purgeRunData(db, runId);
69442
+ purgeRunData(db, runId, {
69443
+ purgedBefore: alreadyDeleted
69444
+ });
69003
69445
  return {
69004
69446
  runId,
69005
69447
  outcome: alreadyDeleted ? "already_deleted" : "deleted"
@@ -69248,6 +69690,342 @@ var init_steps_storage = __esm({
69248
69690
  }
69249
69691
  });
69250
69692
 
69693
+ // ../world-local/dist/storage/usage-storage.js
69694
+ function countRange(db, runId, counts, from, to) {
69695
+ if (to <= from) return;
69696
+ for (const row of db.all(EVENT_GROUPS_SQL, runId, from, to)) {
69697
+ const entry = counts.eventTypes.get(row.event_type) ?? {
69698
+ events: 0,
69699
+ bytes: 0
69700
+ };
69701
+ entry.events += Number(row.events);
69702
+ entry.bytes += Number(row.bytes ?? 0);
69703
+ counts.eventTypes.set(row.event_type, entry);
69704
+ }
69705
+ for (const row of db.all(STEP_GROUPS_SQL, runId, from, to)) {
69706
+ const stepId = row.correlation_id ?? "";
69707
+ let step = counts.steps.get(stepId);
69708
+ if (!step) {
69709
+ const name = row.correlation_id === null ? null : db.get(STEP_NAME_SQL, runId, row.correlation_id)?.step_name ?? null;
69710
+ step = {
69711
+ name,
69712
+ events: 0,
69713
+ created: 0,
69714
+ started: 0,
69715
+ completed: 0,
69716
+ failed: 0,
69717
+ retries: 0,
69718
+ bytes: 0
69719
+ };
69720
+ counts.steps.set(stepId, step);
69721
+ }
69722
+ step.events += Number(row.events);
69723
+ step.created += Number(row.created);
69724
+ step.started += Number(row.started);
69725
+ step.completed += Number(row.completed);
69726
+ step.failed += Number(row.failed);
69727
+ step.retries += Number(row.retries);
69728
+ step.bytes += Number(row.bytes ?? 0);
69729
+ }
69730
+ for (const row of db.all(HOOK_GROUPS_SQL, runId, from, to)) {
69731
+ let hook = counts.hooks.get(row.correlation_id);
69732
+ if (!hook) {
69733
+ hook = {
69734
+ token: hookToken(db, runId, row.correlation_id),
69735
+ events: 0
69736
+ };
69737
+ counts.hooks.set(row.correlation_id, hook);
69738
+ }
69739
+ hook.events += Number(row.events);
69740
+ }
69741
+ for (const row of db.all(WAIT_IDS_SQL, runId, from, to)) {
69742
+ counts.waitIds.add(row.correlation_id);
69743
+ }
69744
+ counts.countedSeq = to;
69745
+ }
69746
+ function hookToken(db, runId, hookId) {
69747
+ const created = db.get(HOOK_TOKEN_SQL, runId, hookId);
69748
+ if (typeof created?.token === "string" && created.token) return created.token;
69749
+ const row = db.get(HOOK_ROW_TOKEN_SQL, hookId);
69750
+ if (typeof row?.token === "string" && row.token) return row.token;
69751
+ let startHook;
69752
+ try {
69753
+ startHook = startHookId(runId);
69754
+ } catch {
69755
+ return null;
69756
+ }
69757
+ if (hookId !== startHook) return null;
69758
+ const start2 = db.get(START_HOOK_TOKEN_SQL, runId);
69759
+ return typeof start2?.token === "string" && start2.token ? start2.token : null;
69760
+ }
69761
+ function hookGroupsOf(counts) {
69762
+ return [
69763
+ ...counts.hooks
69764
+ ].map(([hookId, hook]) => ({
69765
+ hookId,
69766
+ token: hook.token,
69767
+ events: hook.events
69768
+ }));
69769
+ }
69770
+ function eventGroupsOf(counts) {
69771
+ return [
69772
+ ...counts.eventTypes
69773
+ ].map(([eventType, entry]) => ({
69774
+ eventType,
69775
+ events: entry.events,
69776
+ bytes: entry.bytes
69777
+ }));
69778
+ }
69779
+ function stepGroupsOf(counts) {
69780
+ const byName = /* @__PURE__ */ new Map();
69781
+ for (const step of counts.steps.values()) {
69782
+ let group = byName.get(step.name);
69783
+ if (!group) {
69784
+ group = {
69785
+ stepName: step.name,
69786
+ steps: 0,
69787
+ events: 0,
69788
+ created: 0,
69789
+ started: 0,
69790
+ completed: 0,
69791
+ failed: 0,
69792
+ retries: 0,
69793
+ restarts: 0,
69794
+ bytes: 0
69795
+ };
69796
+ byName.set(step.name, group);
69797
+ }
69798
+ group.steps += 1;
69799
+ group.events += step.events;
69800
+ group.created += step.created;
69801
+ group.started += step.started;
69802
+ group.completed += step.completed;
69803
+ group.failed += step.failed;
69804
+ group.retries += step.retries;
69805
+ group.restarts += Math.min(step.retries, Math.max(0, step.started - 1));
69806
+ group.bytes += step.bytes;
69807
+ }
69808
+ return [
69809
+ ...byName.values()
69810
+ ];
69811
+ }
69812
+ function purgedDataWritten(db, runId, streamBytes) {
69813
+ const saved = readPurgedUsage(db, runId);
69814
+ if (!saved) return null;
69815
+ const late = new EntityBytes();
69816
+ for (const row of db.all(EVENTS_AFTER_SQL, runId, saved.seq)) {
69817
+ late.add(row.event_type, Number(row.bytes ?? 0));
69818
+ }
69819
+ return {
69820
+ run: saved.byEntity.run + late.byEntity.run,
69821
+ step: saved.byEntity.step + late.byEntity.step,
69822
+ hook: saved.byEntity.hook + late.byEntity.hook,
69823
+ stream: saved.byEntity.stream + streamBytes
69824
+ };
69825
+ }
69826
+ function createUsageStorage(db, tag, options = {}) {
69827
+ const maxRuns = options.maxRuns ?? 64;
69828
+ const batchTargetMs = options.batchTargetMs ?? 10;
69829
+ const maxBatchRows = options.maxBatchRows ?? 4096;
69830
+ const initialBatchRows = options.initialBatchRows ?? 4;
69831
+ const cache = /* @__PURE__ */ new Map();
69832
+ const inFlight = /* @__PURE__ */ new Map();
69833
+ const remember = /* @__PURE__ */ __name((runId, counts) => {
69834
+ cache.delete(runId);
69835
+ cache.set(runId, counts);
69836
+ while (cache.size > maxRuns) {
69837
+ cache.delete(cache.keys().next().value);
69838
+ }
69839
+ }, "remember");
69840
+ const runRow = /* @__PURE__ */ __name((runId) => db.get(`SELECT status, workflow_name, seq FROM runs WHERE run_id = ? AND ${tagClause("tag", tag)}`, runId, ...tagParams(tag)), "runRow");
69841
+ async function countInBatches(runId, counts, target2) {
69842
+ let batchRows = initialBatchRows;
69843
+ while (counts.countedSeq < target2) {
69844
+ const end = Number(db.get(BATCH_END_SQL, runId, counts.countedSeq, batchRows)?.seq ?? target2);
69845
+ const started = performance.now();
69846
+ countRange(db, runId, counts, counts.countedSeq, Math.min(end, target2));
69847
+ const took = performance.now() - started;
69848
+ batchRows = Math.max(1, Math.min(maxBatchRows, batchRows * 2, Math.round(batchRows * batchTargetMs / Math.max(took, 0.1))));
69849
+ if (counts.countedSeq < target2) {
69850
+ await options.onBatch?.(runId, counts.countedSeq);
69851
+ await yieldToEventLoop();
69852
+ }
69853
+ }
69854
+ }
69855
+ __name(countInBatches, "countInBatches");
69856
+ async function read3(runId) {
69857
+ const first = runRow(runId);
69858
+ if (!first) {
69859
+ cache.delete(runId);
69860
+ throw new WorkflowRunNotFoundError(runId);
69861
+ }
69862
+ let counts = cache.get(runId) ?? newCounts();
69863
+ if (Number(first.seq) < counts.countedSeq) counts = newCounts();
69864
+ let readBeforeFinish = !isTerminalWorkflowRunStatus(first.status) || counts.countedSeq > 0 && !counts.finished;
69865
+ await countInBatches(runId, counts, Number(first.seq));
69866
+ const snapshot = db.snapshot(() => {
69867
+ const run2 = runRow(runId);
69868
+ if (!run2) return null;
69869
+ const seq = Number(run2.seq);
69870
+ const finished = isTerminalWorkflowRunStatus(run2.status);
69871
+ if (seq < counts.countedSeq) {
69872
+ counts = newCounts();
69873
+ readBeforeFinish = !finished;
69874
+ }
69875
+ countRange(db, runId, counts, counts.countedSeq, seq);
69876
+ const streamBytes = measureStreamBytes(db, runId);
69877
+ const savedDataWritten = purgedDataWritten(db, runId, streamBytes) ?? void 0;
69878
+ const dataPurged = savedDataWritten !== void 0 || finished && Number(db.get(PURGED_RUN_SQL, runId)?.purged) === 1;
69879
+ if (dataPurged && readBeforeFinish && counts.countedSeq > 0) {
69880
+ options.onRecount?.(runId);
69881
+ counts = newCounts();
69882
+ countRange(db, runId, counts, 0, seq);
69883
+ }
69884
+ counts.finished = finished;
69885
+ return {
69886
+ run: run2,
69887
+ streamBytes,
69888
+ dataPurged,
69889
+ savedDataWritten
69890
+ };
69891
+ });
69892
+ if (!snapshot) {
69893
+ cache.delete(runId);
69894
+ throw new WorkflowRunNotFoundError(runId);
69895
+ }
69896
+ remember(runId, counts);
69897
+ return buildRunUsage({
69898
+ runId,
69899
+ status: snapshot.run.status,
69900
+ workflowName: snapshot.run.workflow_name,
69901
+ eventGroups: eventGroupsOf(counts),
69902
+ stepGroups: stepGroupsOf(counts),
69903
+ streamBytes: snapshot.streamBytes,
69904
+ dataPurged: snapshot.dataPurged,
69905
+ savedDataWritten: snapshot.savedDataWritten,
69906
+ hookGroups: hookGroupsOf(counts),
69907
+ calls: {
69908
+ wait: counts.waitIds.size
69909
+ },
69910
+ // Local runs are not billed.
69911
+ billed: false,
69912
+ // world-local has no plan retention, so there is no Data Retained to
69913
+ // report: the UI and CLI hide it.
69914
+ dataRetained: null
69915
+ });
69916
+ }
69917
+ __name(read3, "read");
69918
+ return {
69919
+ async getRun(runId) {
69920
+ assertSafeEntityId("runId", runId);
69921
+ const previous = inFlight.get(runId) ?? Promise.resolve();
69922
+ const current2 = previous.catch(() => {
69923
+ }).then(() => read3(runId));
69924
+ inFlight.set(runId, current2);
69925
+ try {
69926
+ return await current2;
69927
+ } finally {
69928
+ if (inFlight.get(runId) === current2) inFlight.delete(runId);
69929
+ }
69930
+ }
69931
+ };
69932
+ }
69933
+ var IS_STEP_EVENT, EVENT_GROUPS_SQL, STEP_GROUPS_SQL, WAIT_IDS_SQL, HOOK_GROUPS_SQL, HOOK_TOKEN_SQL, HOOK_ROW_TOKEN_SQL, START_HOOK_TOKEN_SQL, STEP_NAME_SQL, BATCH_END_SQL, EVENTS_AFTER_SQL, PURGED_RUN_SQL, newCounts, yieldToEventLoop;
69934
+ var init_usage_storage = __esm({
69935
+ "../world-local/dist/storage/usage-storage.js"() {
69936
+ "use strict";
69937
+ init_dist2();
69938
+ init_dist4();
69939
+ init_ids();
69940
+ init_purged_usage();
69941
+ init_store();
69942
+ IS_STEP_EVENT = `event_type LIKE 'step\\_%' ESCAPE '\\'`;
69943
+ EVENT_GROUPS_SQL = `
69944
+ SELECT event_type,
69945
+ COUNT(*) AS events,
69946
+ SUM(${PAYLOAD_BYTES_SQL}) AS bytes
69947
+ FROM events
69948
+ WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3 AND NOT (${IS_STEP_EVENT})
69949
+ GROUP BY event_type
69950
+ `;
69951
+ STEP_GROUPS_SQL = `
69952
+ SELECT correlation_id,
69953
+ COUNT(*) AS events,
69954
+ SUM(event_type = 'step_created') AS created,
69955
+ SUM(event_type = 'step_started') AS started,
69956
+ SUM(event_type = 'step_completed') AS completed,
69957
+ SUM(event_type = 'step_failed') AS failed,
69958
+ SUM(event_type = 'step_retrying') AS retries,
69959
+ SUM(${PAYLOAD_BYTES_SQL}) AS bytes
69960
+ FROM events
69961
+ WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3 AND ${IS_STEP_EVENT}
69962
+ GROUP BY correlation_id
69963
+ `;
69964
+ WAIT_IDS_SQL = `
69965
+ SELECT DISTINCT correlation_id
69966
+ FROM events
69967
+ WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3
69968
+ AND correlation_id IS NOT NULL AND substr(event_type, 1, 5) = 'wait_'
69969
+ `;
69970
+ HOOK_GROUPS_SQL = `
69971
+ SELECT correlation_id, COUNT(*) AS events
69972
+ FROM events
69973
+ WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3
69974
+ AND correlation_id IS NOT NULL AND substr(event_type, 1, 5) = 'hook_'
69975
+ GROUP BY correlation_id
69976
+ `;
69977
+ HOOK_TOKEN_SQL = `
69978
+ SELECT json_extract(doc, '$.eventData.token') AS token
69979
+ FROM ${EVENTS_BY_CORRELATION}
69980
+ WHERE run_id = ? AND correlation_id = ?
69981
+ AND event_type IN ('hook_created', 'hook_conflict')
69982
+ ORDER BY seq LIMIT 1
69983
+ `;
69984
+ HOOK_ROW_TOKEN_SQL = "SELECT token FROM hooks WHERE hook_id = ?";
69985
+ START_HOOK_TOKEN_SQL = `
69986
+ SELECT json_extract(doc, '$.eventData.startHook.token') AS token
69987
+ FROM events
69988
+ WHERE run_id = ? AND event_type = 'run_created'
69989
+ LIMIT 1
69990
+ `;
69991
+ STEP_NAME_SQL = `
69992
+ SELECT json_extract(doc, '$.stepName') AS step_name
69993
+ FROM steps WHERE run_id = ? AND step_id = ?
69994
+ `;
69995
+ BATCH_END_SQL = `
69996
+ SELECT MAX(seq) AS seq FROM (
69997
+ SELECT seq FROM events WHERE run_id = ? AND seq > ? ORDER BY seq LIMIT ?
69998
+ )
69999
+ `;
70000
+ EVENTS_AFTER_SQL = `
70001
+ SELECT event_type, SUM(${PAYLOAD_BYTES_SQL}) AS bytes
70002
+ FROM events
70003
+ WHERE run_id = ? AND seq > ?
70004
+ GROUP BY event_type
70005
+ `;
70006
+ PURGED_RUN_SQL = `
70007
+ SELECT json_extract(doc, '$.expiredAt') IS NOT NULL AS purged
70008
+ FROM runs WHERE run_id = ?
70009
+ `;
70010
+ newCounts = /* @__PURE__ */ __name(() => ({
70011
+ countedSeq: 0,
70012
+ finished: false,
70013
+ eventTypes: /* @__PURE__ */ new Map(),
70014
+ steps: /* @__PURE__ */ new Map(),
70015
+ hooks: /* @__PURE__ */ new Map(),
70016
+ waitIds: /* @__PURE__ */ new Set()
70017
+ }), "newCounts");
70018
+ __name(countRange, "countRange");
70019
+ __name(hookToken, "hookToken");
70020
+ __name(hookGroupsOf, "hookGroupsOf");
70021
+ __name(eventGroupsOf, "eventGroupsOf");
70022
+ __name(stepGroupsOf, "stepGroupsOf");
70023
+ __name(purgedDataWritten, "purgedDataWritten");
70024
+ yieldToEventLoop = /* @__PURE__ */ __name(() => new Promise((resolve2) => setImmediate(resolve2)), "yieldToEventLoop");
70025
+ __name(createUsageStorage, "createUsageStorage");
70026
+ }
70027
+ });
70028
+
69251
70029
  // ../world-local/dist/storage/index.js
69252
70030
  function createStorage(basedir, tag) {
69253
70031
  const db = databaseFor(basedir);
@@ -69256,12 +70034,14 @@ function createStorage(basedir, tag) {
69256
70034
  const events = createEventsStorage(db, tag);
69257
70035
  const hooks = createHooksStorage(db, tag);
69258
70036
  const snapshots = createSnapshotsStorage(db);
70037
+ const usage = createUsageStorage(db, tag);
69259
70038
  return {
69260
70039
  runs: instrumentObject("world.runs", runs),
69261
70040
  steps: instrumentObject("world.steps", steps),
69262
70041
  events: instrumentObject("world.events", events),
69263
70042
  hooks: instrumentObject("world.hooks", hooks),
69264
70043
  experimental_snapshots: instrumentObject("world.experimental_snapshots", snapshots),
70044
+ experimental_usage: instrumentObject("world.experimental_usage", usage),
69265
70045
  clearCache: /* @__PURE__ */ __name(() => {
69266
70046
  }, "clearCache")
69267
70047
  };
@@ -69276,6 +70056,7 @@ var init_storage = __esm({
69276
70056
  init_runs_storage();
69277
70057
  init_snapshots_storage();
69278
70058
  init_steps_storage();
70059
+ init_usage_storage();
69279
70060
  __name(createStorage, "createStorage");
69280
70061
  }
69281
70062
  });
@@ -69704,9 +70485,16 @@ function createWorld(args) {
69704
70485
  ]) {
69705
70486
  db.run(`DELETE FROM ${table}`);
69706
70487
  }
70488
+ deletePurgedUsage(db);
69707
70489
  return;
69708
70490
  }
69709
70491
  const runs = "SELECT run_id FROM runs WHERE tag = ?";
70492
+ deletePurgedUsage(db, {
70493
+ runIdsSql: runs,
70494
+ params: [
70495
+ tag
70496
+ ]
70497
+ });
69710
70498
  for (const table of [
69711
70499
  "events",
69712
70500
  "steps",
@@ -69746,6 +70534,7 @@ var init_dist5 = __esm({
69746
70534
  init_queue2();
69747
70535
  init_queue_auth_key();
69748
70536
  init_recovery_wake();
70537
+ init_purged_usage();
69749
70538
  init_storage2();
69750
70539
  init_streamer();
69751
70540
  init_build_target_mismatch();
@@ -73582,7 +74371,7 @@ var version3;
73582
74371
  var init_version2 = __esm({
73583
74372
  "../world-vercel/dist/version.js"() {
73584
74373
  "use strict";
73585
- version3 = "5.7.1";
74374
+ version3 = "5.7.2";
73586
74375
  }
73587
74376
  });
73588
74377
 
@@ -82547,17 +83336,17 @@ var require_exec = __commonJS({
82547
83336
  var import_node_path6 = __toESM2(__require("node:path"));
82548
83337
  var import_execa = __toESM2(require_execa());
82549
83338
  var import_envpath = require_envpath();
82550
- var import_errors59 = require_errors2();
83339
+ var import_errors60 = require_errors2();
82551
83340
  var import_lookup = require_lookup();
82552
83341
  async function execVercelCli2(args, options = {}) {
82553
83342
  const cwd = import_node_path6.default.resolve(options.cwd ?? process.cwd());
82554
- await (0, import_errors59.assertValidCwd)(cwd);
83343
+ await (0, import_errors60.assertValidCwd)(cwd);
82555
83344
  const env = mergeExecEnv(options.env);
82556
83345
  const pathValue = (0, import_envpath.getEnvPath)(env);
82557
83346
  try {
82558
83347
  return await execResolvedVercelCli(args, options, cwd, env, pathValue);
82559
83348
  } catch (error62) {
82560
- if (error62 instanceof import_errors59.VercelCliError && error62.code === "VERCEL_CLI_NOT_FOUND") {
83349
+ if (error62 instanceof import_errors60.VercelCliError && error62.code === "VERCEL_CLI_NOT_FOUND") {
82561
83350
  (0, import_lookup.clearCachedCliInvocation)(cwd, pathValue);
82562
83351
  return await execResolvedVercelCli(args, options, cwd, env, pathValue);
82563
83352
  }
@@ -82592,16 +83381,16 @@ var require_exec = __commonJS({
82592
83381
  invocation
82593
83382
  };
82594
83383
  } catch (error62) {
82595
- throw (0, import_errors59.toVercelCliError)(invocation, error62);
83384
+ throw (0, import_errors60.toVercelCliError)(invocation, error62);
82596
83385
  }
82597
83386
  }
82598
83387
  __name(execResolvedVercelCli, "execResolvedVercelCli");
82599
83388
  async function resolveInvocationOrThrow(cwd, pathValue) {
82600
83389
  const resolution = await (0, import_lookup.resolveCachedCliInvocation)(cwd, pathValue);
82601
83390
  if (!resolution.found) {
82602
- throw new import_errors59.VercelCliError({
83391
+ throw new import_errors60.VercelCliError({
82603
83392
  code: "VERCEL_CLI_NOT_FOUND",
82604
- message: (0, import_errors59.getCliNotFoundMessage)(resolution.diagnostics)
83393
+ message: (0, import_errors60.getCliNotFoundMessage)(resolution.diagnostics)
82605
83394
  });
82606
83395
  }
82607
83396
  return (0, import_lookup.toVercelCliInvocation)(resolution);
@@ -82659,13 +83448,13 @@ var require_dist2 = __commonJS({
82659
83448
  }), mod), "__toCommonJS");
82660
83449
  var src_exports = {};
82661
83450
  __export2(src_exports, {
82662
- VercelCliError: /* @__PURE__ */ __name(() => import_errors59.VercelCliError, "VercelCliError"),
83451
+ VercelCliError: /* @__PURE__ */ __name(() => import_errors60.VercelCliError, "VercelCliError"),
82663
83452
  clearVercelCliLookupCache: /* @__PURE__ */ __name(() => import_lookup.clearVercelCliLookupCache, "clearVercelCliLookupCache"),
82664
83453
  execVercelCli: /* @__PURE__ */ __name(() => import_exec.execVercelCli, "execVercelCli"),
82665
83454
  findVercelCli: /* @__PURE__ */ __name(() => import_lookup.findVercelCli, "findVercelCli")
82666
83455
  });
82667
83456
  module.exports = __toCommonJS(src_exports);
82668
- var import_errors59 = require_errors2();
83457
+ var import_errors60 = require_errors2();
82669
83458
  var import_exec = require_exec();
82670
83459
  var import_lookup = require_lookup();
82671
83460
  }
@@ -110588,35 +111377,35 @@ function getAllBaseReducers(global2 = globalThis) {
110588
111377
  }
110589
111378
  function reduceAbortWithListener(signal, holder, global2, ops, runId, cryptoKey, framedAbortStreams) {
110590
111379
  let streamName = holder[ABORT_STREAM_NAME];
110591
- let hookToken = holder[ABORT_HOOK_TOKEN];
111380
+ let hookToken2 = holder[ABORT_HOOK_TOKEN];
110592
111381
  if (!streamName) {
110593
111382
  const id = (global2[STABLE_ULID] || defaultUlid)();
110594
111383
  streamName = getAbortStreamId(id);
110595
- hookToken = `abrt_${id}`;
111384
+ hookToken2 = `abrt_${id}`;
110596
111385
  holder[ABORT_STREAM_NAME] = streamName;
110597
- holder[ABORT_HOOK_TOKEN] = hookToken;
111386
+ holder[ABORT_HOOK_TOKEN] = hookToken2;
110598
111387
  if (holder.signal) {
110599
111388
  holder.signal[ABORT_STREAM_NAME] = streamName;
110600
- holder.signal[ABORT_HOOK_TOKEN] = hookToken;
111389
+ holder.signal[ABORT_HOOK_TOKEN] = hookToken2;
110601
111390
  }
110602
111391
  }
110603
111392
  attachAbortListenerOnce(signal, streamName, runId, cryptoKey, ops, framedAbortStreams);
110604
111393
  return {
110605
111394
  streamName,
110606
- hookToken,
111395
+ hookToken: hookToken2,
110607
111396
  aborted: signal.aborted,
110608
111397
  reason: signal.aborted ? signal.reason : void 0
110609
111398
  };
110610
111399
  }
110611
111400
  function reduceAbortBySymbol(signal, holder) {
110612
111401
  const streamName = holder[ABORT_STREAM_NAME] ?? holder.signal?.[ABORT_STREAM_NAME];
110613
- const hookToken = holder[ABORT_HOOK_TOKEN] ?? holder.signal?.[ABORT_HOOK_TOKEN];
111402
+ const hookToken2 = holder[ABORT_HOOK_TOKEN] ?? holder.signal?.[ABORT_HOOK_TOKEN];
110614
111403
  if (!streamName) {
110615
111404
  throw new Error("AbortController/AbortSignal stream name is not set");
110616
111405
  }
110617
111406
  return {
110618
111407
  streamName,
110619
- hookToken,
111408
+ hookToken: hookToken2,
110620
111409
  aborted: signal.aborted,
110621
111410
  reason: signal.aborted ? signal.reason : void 0
110622
111411
  };
@@ -120573,7 +121362,7 @@ __name(start, "start");
120573
121362
  value: "start",
120574
121363
  configurable: true
120575
121364
  });
120576
- })(start, "step//@workflow/core/runtime/start@5.7.1//start");
121365
+ })(start, "step//@workflow/core/runtime/start@5.7.2//start");
120577
121366
 
120578
121367
  // ../core/dist/runtime/runs.js
120579
121368
  function isSingleOrchestratorRun(run2) {
@@ -121339,7 +122128,7 @@ var Run = class _Run {
121339
122128
  value: "readFinishedRunIds",
121340
122129
  configurable: true
121341
122130
  });
121342
- })(Run.readFinishedRunIds, "step//@workflow/core/runtime/run@5.7.1//Run.readFinishedRunIds");
122131
+ })(Run.readFinishedRunIds, "step//@workflow/core/runtime/run@5.7.2//Run.readFinishedRunIds");
121343
122132
  (function(__wf_fn, __wf_id) {
121344
122133
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121345
122134
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121348,7 +122137,7 @@ var Run = class _Run {
121348
122137
  value: "wakeUp",
121349
122138
  configurable: true
121350
122139
  });
121351
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.7.1//Run#wakeUp");
122140
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.7.2//Run#wakeUp");
121352
122141
  (function(__wf_fn, __wf_id) {
121353
122142
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121354
122143
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121357,7 +122146,7 @@ var Run = class _Run {
121357
122146
  value: "cancel",
121358
122147
  configurable: true
121359
122148
  });
121360
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.7.1//Run#cancel");
122149
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.7.2//Run#cancel");
121361
122150
  (function(__wf_fn, __wf_id) {
121362
122151
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121363
122152
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121366,7 +122155,7 @@ var Run = class _Run {
121366
122155
  value: "delete",
121367
122156
  configurable: true
121368
122157
  });
121369
- })(Run.prototype["delete"], "step//@workflow/core/runtime/run@5.7.1//Run#delete");
122158
+ })(Run.prototype["delete"], "step//@workflow/core/runtime/run@5.7.2//Run#delete");
121370
122159
  (function(__wf_fn, __wf_id) {
121371
122160
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121372
122161
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121375,7 +122164,7 @@ var Run = class _Run {
121375
122164
  value: "readReturnValue",
121376
122165
  configurable: true
121377
122166
  });
121378
- })(Run.prototype["readReturnValue"], "step//@workflow/core/runtime/run@5.7.1//Run#readReturnValue");
122167
+ })(Run.prototype["readReturnValue"], "step//@workflow/core/runtime/run@5.7.2//Run#readReturnValue");
121379
122168
  (function(__wf_fn, __wf_id) {
121380
122169
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121381
122170
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121384,7 +122173,7 @@ var Run = class _Run {
121384
122173
  value: "getReadable",
121385
122174
  configurable: true
121386
122175
  });
121387
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.7.1//Run#getReadable");
122176
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.7.2//Run#getReadable");
121388
122177
  (function(__wf_fn, __wf_id) {
121389
122178
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121390
122179
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121393,7 +122182,7 @@ var Run = class _Run {
121393
122182
  value: "getWritable",
121394
122183
  configurable: true
121395
122184
  });
121396
- })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.7.1//Run#getWritable");
122185
+ })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.7.2//Run#getWritable");
121397
122186
  (function(__wf_fn, __wf_id) {
121398
122187
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121399
122188
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121402,7 +122191,7 @@ var Run = class _Run {
121402
122191
  value: "exists",
121403
122192
  configurable: true
121404
122193
  });
121405
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.7.1//Run#exists");
122194
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.7.2//Run#exists");
121406
122195
  (function(__wf_fn, __wf_id) {
121407
122196
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121408
122197
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121411,7 +122200,7 @@ var Run = class _Run {
121411
122200
  value: "status",
121412
122201
  configurable: true
121413
122202
  });
121414
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.7.1//Run#status");
122203
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.7.2//Run#status");
121415
122204
  (function(__wf_fn, __wf_id) {
121416
122205
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121417
122206
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121420,7 +122209,7 @@ var Run = class _Run {
121420
122209
  value: "workflowName",
121421
122210
  configurable: true
121422
122211
  });
121423
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.7.1//Run#workflowName");
122212
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.7.2//Run#workflowName");
121424
122213
  (function(__wf_fn, __wf_id) {
121425
122214
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121426
122215
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121429,7 +122218,7 @@ var Run = class _Run {
121429
122218
  value: "createdAt",
121430
122219
  configurable: true
121431
122220
  });
121432
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.7.1//Run#createdAt");
122221
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.7.2//Run#createdAt");
121433
122222
  (function(__wf_fn, __wf_id) {
121434
122223
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121435
122224
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121438,7 +122227,7 @@ var Run = class _Run {
121438
122227
  value: "startedAt",
121439
122228
  configurable: true
121440
122229
  });
121441
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.7.1//Run#startedAt");
122230
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.7.2//Run#startedAt");
121442
122231
  (function(__wf_fn, __wf_id) {
121443
122232
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121444
122233
  __wf_reg.set(__wf_id, __wf_fn);
@@ -121447,7 +122236,7 @@ var Run = class _Run {
121447
122236
  value: "completedAt",
121448
122237
  configurable: true
121449
122238
  });
121450
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.7.1//Run#completedAt");
122239
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.7.2//Run#completedAt");
121451
122240
  (function(__wf_cls, __wf_id) {
121452
122241
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121453
122242
  __wf_reg.set(__wf_id, __wf_cls);
@@ -121457,7 +122246,7 @@ var Run = class _Run {
121457
122246
  enumerable: false,
121458
122247
  configurable: false
121459
122248
  });
121460
- })(Run, "class//@workflow/core/runtime/run@5.7.1//Run");
122249
+ })(Run, "class//@workflow/core/runtime/run@5.7.2//Run");
121461
122250
 
121462
122251
  // ../workflow/dist/stdlib.js
121463
122252
  async function fetch2(...args) {