@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.
|
@@ -21781,7 +21781,7 @@ var init_attributes2 = __esm({
|
|
|
21781
21781
|
function getOwnProperty2(object3, key) {
|
|
21782
21782
|
return Object.hasOwn(object3, key) ? object3[key] : void 0;
|
|
21783
21783
|
}
|
|
21784
|
-
function
|
|
21784
|
+
function isSealedNoopEvent2(event) {
|
|
21785
21785
|
return event.eventType === "noop";
|
|
21786
21786
|
}
|
|
21787
21787
|
function entityEventClass(eventType) {
|
|
@@ -21808,7 +21808,7 @@ var init_event_metadata2 = __esm({
|
|
|
21808
21808
|
"../world/dist/event-metadata.js"() {
|
|
21809
21809
|
"use strict";
|
|
21810
21810
|
__name(getOwnProperty2, "getOwnProperty");
|
|
21811
|
-
__name(
|
|
21811
|
+
__name(isSealedNoopEvent2, "isSealedNoopEvent");
|
|
21812
21812
|
ENTITY_EVENT_CLASS_BY_TYPE = {
|
|
21813
21813
|
attr_set: "attr_set",
|
|
21814
21814
|
step_created: "step_created",
|
|
@@ -24204,6 +24204,235 @@ var init_ulid2 = __esm({
|
|
|
24204
24204
|
}
|
|
24205
24205
|
});
|
|
24206
24206
|
|
|
24207
|
+
// ../world/dist/usage.js
|
|
24208
|
+
function spanOf2(eventType, workflowName) {
|
|
24209
|
+
if (eventType.startsWith("hook_"))
|
|
24210
|
+
return { kind: "hook", name: "hook" };
|
|
24211
|
+
if (eventType.startsWith("wait_"))
|
|
24212
|
+
return { kind: "wait", name: "sleep" };
|
|
24213
|
+
if (eventType.startsWith("run_"))
|
|
24214
|
+
return { kind: "run", name: workflowName };
|
|
24215
|
+
if (eventType === "attr_set") {
|
|
24216
|
+
return { kind: "attributes", name: "attributes" };
|
|
24217
|
+
}
|
|
24218
|
+
return { kind: "other", name: "other" };
|
|
24219
|
+
}
|
|
24220
|
+
function compareCodeUnits2(a, b) {
|
|
24221
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
24222
|
+
}
|
|
24223
|
+
function toCount2(value) {
|
|
24224
|
+
const n = Number(value);
|
|
24225
|
+
return Number.isFinite(n) && n > 0 ? n : 0;
|
|
24226
|
+
}
|
|
24227
|
+
function usageEntityOfEventType2(eventType) {
|
|
24228
|
+
if (isSealedNoopEvent2({ eventType }))
|
|
24229
|
+
return null;
|
|
24230
|
+
if (eventType.startsWith("step_"))
|
|
24231
|
+
return "step";
|
|
24232
|
+
if (eventType.startsWith("hook_"))
|
|
24233
|
+
return "hook";
|
|
24234
|
+
return "run";
|
|
24235
|
+
}
|
|
24236
|
+
function buildRunUsage2(input3) {
|
|
24237
|
+
const spans = /* @__PURE__ */ new Map();
|
|
24238
|
+
const byEntity = {
|
|
24239
|
+
run: 0,
|
|
24240
|
+
step: 0,
|
|
24241
|
+
hook: 0,
|
|
24242
|
+
stream: toCount2(input3.streamBytes)
|
|
24243
|
+
};
|
|
24244
|
+
let events = 0;
|
|
24245
|
+
let retries = 0;
|
|
24246
|
+
const add3 = /* @__PURE__ */ __name((kind, name, entity, count2, retryCount, bytes) => {
|
|
24247
|
+
if (count2 <= 0)
|
|
24248
|
+
return;
|
|
24249
|
+
const key = `${kind}\0${name}`;
|
|
24250
|
+
let span = spans.get(key);
|
|
24251
|
+
if (!span) {
|
|
24252
|
+
span = { kind, name, events: 0, share: 0, retries: 0, calls: 0 };
|
|
24253
|
+
spans.set(key, span);
|
|
24254
|
+
}
|
|
24255
|
+
span.events += count2;
|
|
24256
|
+
span.retries += retryCount;
|
|
24257
|
+
events += count2;
|
|
24258
|
+
retries += retryCount;
|
|
24259
|
+
byEntity[entity] += bytes;
|
|
24260
|
+
}, "add");
|
|
24261
|
+
const created = { hook: 0, wait: 0 };
|
|
24262
|
+
const hookGroups = input3.hookGroups;
|
|
24263
|
+
let hookEvents = 0;
|
|
24264
|
+
const runEvents = {
|
|
24265
|
+
events: 0,
|
|
24266
|
+
byType: { created: 0, started: 0, completed: 0, failed: 0, cancelled: 0 }
|
|
24267
|
+
};
|
|
24268
|
+
for (const group of input3.eventGroups) {
|
|
24269
|
+
const entity = usageEntityOfEventType2(group.eventType);
|
|
24270
|
+
if (!entity)
|
|
24271
|
+
continue;
|
|
24272
|
+
const runType = group.eventType.slice("run_".length);
|
|
24273
|
+
if (group.eventType.startsWith("run_") && RUN_USAGE_RUN_EVENT_TYPES2.includes(runType)) {
|
|
24274
|
+
runEvents.byType[runType] += toCount2(group.events);
|
|
24275
|
+
}
|
|
24276
|
+
if (group.eventType.startsWith("run_")) {
|
|
24277
|
+
runEvents.events += toCount2(group.events);
|
|
24278
|
+
}
|
|
24279
|
+
if (group.eventType === "hook_created")
|
|
24280
|
+
created.hook += toCount2(group.events);
|
|
24281
|
+
if (group.eventType === "wait_created")
|
|
24282
|
+
created.wait += toCount2(group.events);
|
|
24283
|
+
const { kind, name } = spanOf2(group.eventType, input3.workflowName);
|
|
24284
|
+
if (kind === "hook" && hookGroups) {
|
|
24285
|
+
hookEvents += toCount2(group.events);
|
|
24286
|
+
events += toCount2(group.events);
|
|
24287
|
+
byEntity[entity] += toCount2(group.bytes);
|
|
24288
|
+
continue;
|
|
24289
|
+
}
|
|
24290
|
+
add3(kind, name, entity, toCount2(group.events), 0, toCount2(group.bytes));
|
|
24291
|
+
}
|
|
24292
|
+
if (hookGroups) {
|
|
24293
|
+
let grouped = 0;
|
|
24294
|
+
for (const group of hookGroups) {
|
|
24295
|
+
const count2 = toCount2(group.events);
|
|
24296
|
+
if (count2 <= 0 || !group.hookId)
|
|
24297
|
+
continue;
|
|
24298
|
+
grouped += count2;
|
|
24299
|
+
spans.set(`hook\0${group.hookId}`, {
|
|
24300
|
+
kind: "hook",
|
|
24301
|
+
name: group.token || group.hookId,
|
|
24302
|
+
id: group.hookId,
|
|
24303
|
+
events: count2,
|
|
24304
|
+
share: 0,
|
|
24305
|
+
retries: 0,
|
|
24306
|
+
calls: 1
|
|
24307
|
+
});
|
|
24308
|
+
}
|
|
24309
|
+
if (hookEvents > grouped) {
|
|
24310
|
+
spans.set("hook\0", {
|
|
24311
|
+
kind: "hook",
|
|
24312
|
+
name: "hook",
|
|
24313
|
+
events: hookEvents - grouped,
|
|
24314
|
+
share: 0,
|
|
24315
|
+
retries: 0,
|
|
24316
|
+
calls: 0
|
|
24317
|
+
});
|
|
24318
|
+
}
|
|
24319
|
+
}
|
|
24320
|
+
const calls = {
|
|
24321
|
+
hook: toCount2(created.hook),
|
|
24322
|
+
wait: toCount2(input3.calls?.wait ?? created.wait)
|
|
24323
|
+
};
|
|
24324
|
+
const stepEvents = {
|
|
24325
|
+
steps: 0,
|
|
24326
|
+
events: 0,
|
|
24327
|
+
byType: {
|
|
24328
|
+
created: 0,
|
|
24329
|
+
started: 0,
|
|
24330
|
+
completed: 0,
|
|
24331
|
+
failed: 0,
|
|
24332
|
+
retrying: 0,
|
|
24333
|
+
other: 0
|
|
24334
|
+
}
|
|
24335
|
+
};
|
|
24336
|
+
let restarts = 0;
|
|
24337
|
+
for (const group of input3.stepGroups) {
|
|
24338
|
+
restarts += toCount2(group.restarts);
|
|
24339
|
+
const counts = {
|
|
24340
|
+
created: toCount2(group.created),
|
|
24341
|
+
started: toCount2(group.started),
|
|
24342
|
+
completed: toCount2(group.completed),
|
|
24343
|
+
failed: toCount2(group.failed),
|
|
24344
|
+
retrying: toCount2(group.retries)
|
|
24345
|
+
};
|
|
24346
|
+
const total = toCount2(group.events);
|
|
24347
|
+
if (total <= 0)
|
|
24348
|
+
continue;
|
|
24349
|
+
stepEvents.steps += toCount2(group.steps);
|
|
24350
|
+
stepEvents.events += total;
|
|
24351
|
+
let known = 0;
|
|
24352
|
+
for (const type of RUN_USAGE_STEP_EVENT_TYPES2) {
|
|
24353
|
+
stepEvents.byType[type] += counts[type];
|
|
24354
|
+
known += counts[type];
|
|
24355
|
+
}
|
|
24356
|
+
stepEvents.byType.other += Math.max(0, total - known);
|
|
24357
|
+
const name = group.stepName || UNKNOWN_STEP_NAME2;
|
|
24358
|
+
add3("step", name, "step", toCount2(group.events), toCount2(group.retries), toCount2(group.bytes));
|
|
24359
|
+
const span = spans.get(`step\0${name}`);
|
|
24360
|
+
if (span)
|
|
24361
|
+
span.calls += toCount2(group.steps);
|
|
24362
|
+
}
|
|
24363
|
+
for (const span of spans.values()) {
|
|
24364
|
+
if (span.kind === "run")
|
|
24365
|
+
span.calls = 1;
|
|
24366
|
+
if (span.kind === "hook" && !hookGroups)
|
|
24367
|
+
span.calls = calls.hook;
|
|
24368
|
+
if (span.kind === "wait")
|
|
24369
|
+
span.calls = calls.wait;
|
|
24370
|
+
if (span.kind === "attributes" || span.kind === "other") {
|
|
24371
|
+
span.calls = span.events;
|
|
24372
|
+
}
|
|
24373
|
+
}
|
|
24374
|
+
const eventsBySpan = [...spans.values()].map((span) => ({ ...span, share: events > 0 ? span.events / events : 0 })).sort((a, b) => b.events - a.events || compareCodeUnits2(a.name, b.name) || compareCodeUnits2(a.kind, b.kind) || compareCodeUnits2(a.id ?? "", b.id ?? ""));
|
|
24375
|
+
return {
|
|
24376
|
+
runId: input3.runId,
|
|
24377
|
+
status: input3.status,
|
|
24378
|
+
workflowName: input3.workflowName,
|
|
24379
|
+
billed: input3.billed === true,
|
|
24380
|
+
inProgress: !isTerminalWorkflowRunStatus2(input3.status),
|
|
24381
|
+
events,
|
|
24382
|
+
billableEvents: events,
|
|
24383
|
+
retries: { count: retries, events: retries + restarts },
|
|
24384
|
+
runEvents,
|
|
24385
|
+
stepEvents,
|
|
24386
|
+
eventsBySpan,
|
|
24387
|
+
dataWritten: dataWrittenOf2(input3, byEntity),
|
|
24388
|
+
dataPurged: input3.dataPurged === true,
|
|
24389
|
+
dataRetained: input3.dataRetained ?? null
|
|
24390
|
+
};
|
|
24391
|
+
}
|
|
24392
|
+
function dataWrittenOf2(input3, measured) {
|
|
24393
|
+
const saved = input3.dataPurged ? input3.savedDataWritten : void 0;
|
|
24394
|
+
const byEntity = saved ? {
|
|
24395
|
+
run: toCount2(saved.run),
|
|
24396
|
+
step: toCount2(saved.step),
|
|
24397
|
+
hook: toCount2(saved.hook),
|
|
24398
|
+
stream: toCount2(saved.stream)
|
|
24399
|
+
} : measured;
|
|
24400
|
+
return {
|
|
24401
|
+
bytes: byEntity.run + byEntity.step + byEntity.hook + byEntity.stream,
|
|
24402
|
+
byEntity,
|
|
24403
|
+
source: !input3.dataPurged ? "log" : saved ? "saved-at-purge" : "left-after-purge"
|
|
24404
|
+
};
|
|
24405
|
+
}
|
|
24406
|
+
var RUN_USAGE_RUN_EVENT_TYPES2, RUN_USAGE_STEP_EVENT_TYPES2, UNKNOWN_STEP_NAME2;
|
|
24407
|
+
var init_usage2 = __esm({
|
|
24408
|
+
"../world/dist/usage.js"() {
|
|
24409
|
+
"use strict";
|
|
24410
|
+
init_event_metadata2();
|
|
24411
|
+
init_runs3();
|
|
24412
|
+
RUN_USAGE_RUN_EVENT_TYPES2 = [
|
|
24413
|
+
"created",
|
|
24414
|
+
"started",
|
|
24415
|
+
"completed",
|
|
24416
|
+
"failed",
|
|
24417
|
+
"cancelled"
|
|
24418
|
+
];
|
|
24419
|
+
RUN_USAGE_STEP_EVENT_TYPES2 = [
|
|
24420
|
+
"created",
|
|
24421
|
+
"started",
|
|
24422
|
+
"completed",
|
|
24423
|
+
"failed",
|
|
24424
|
+
"retrying"
|
|
24425
|
+
];
|
|
24426
|
+
UNKNOWN_STEP_NAME2 = "(unknown step)";
|
|
24427
|
+
__name(spanOf2, "spanOf");
|
|
24428
|
+
__name(compareCodeUnits2, "compareCodeUnits");
|
|
24429
|
+
__name(toCount2, "toCount");
|
|
24430
|
+
__name(usageEntityOfEventType2, "usageEntityOfEventType");
|
|
24431
|
+
__name(buildRunUsage2, "buildRunUsage");
|
|
24432
|
+
__name(dataWrittenOf2, "dataWrittenOf");
|
|
24433
|
+
}
|
|
24434
|
+
});
|
|
24435
|
+
|
|
24207
24436
|
// ../world/dist/index.js
|
|
24208
24437
|
var init_dist10 = __esm({
|
|
24209
24438
|
"../world/dist/index.js"() {
|
|
@@ -24226,6 +24455,7 @@ var init_dist10 = __esm({
|
|
|
24226
24455
|
init_start_hook3();
|
|
24227
24456
|
init_steps3();
|
|
24228
24457
|
init_ulid2();
|
|
24458
|
+
init_usage2();
|
|
24229
24459
|
init_waits2();
|
|
24230
24460
|
}
|
|
24231
24461
|
});
|
|
@@ -57213,6 +57443,121 @@ var init_recovery_wake2 = __esm({
|
|
|
57213
57443
|
}
|
|
57214
57444
|
});
|
|
57215
57445
|
|
|
57446
|
+
// ../world-local/dist/storage/purged-usage.js
|
|
57447
|
+
function valueBytesSql2(path15) {
|
|
57448
|
+
const data3 = `CAST(json_extract(doc, '${path15}.data') AS BLOB)`;
|
|
57449
|
+
return `CASE WHEN json_extract(doc, '${path15}.__type') = 'Uint8Array'
|
|
57450
|
+
THEN length(${data3}) / 4 * 3 - (CASE WHEN substr(${data3}, -2) = X'3D3D' THEN 2 WHEN substr(${data3}, -1) = X'3D' THEN 1 ELSE 0 END)
|
|
57451
|
+
ELSE coalesce(length(CAST(doc -> '${path15}' AS BLOB)), 0) END`;
|
|
57452
|
+
}
|
|
57453
|
+
function measureStreamBytes2(db, runId) {
|
|
57454
|
+
return Number(db.get(STREAM_BYTES_SQL2, runId)?.bytes ?? 0);
|
|
57455
|
+
}
|
|
57456
|
+
function tableExists2(db) {
|
|
57457
|
+
return db.get("SELECT 1 AS one FROM sqlite_master WHERE type = 'table' AND name = ?", TABLE2) !== void 0;
|
|
57458
|
+
}
|
|
57459
|
+
function savePurgedUsage2(db, runId, usage) {
|
|
57460
|
+
db.run(CREATE_TABLE_SQL2);
|
|
57461
|
+
db.run(`INSERT INTO ${TABLE2}
|
|
57462
|
+
(run_id, seq, run_bytes, step_bytes, hook_bytes, stream_bytes)
|
|
57463
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
57464
|
+
ON CONFLICT (run_id) DO UPDATE SET
|
|
57465
|
+
seq = excluded.seq,
|
|
57466
|
+
run_bytes = excluded.run_bytes,
|
|
57467
|
+
step_bytes = excluded.step_bytes,
|
|
57468
|
+
hook_bytes = excluded.hook_bytes,
|
|
57469
|
+
stream_bytes = excluded.stream_bytes`, runId, usage.seq, usage.byEntity.run, usage.byEntity.step, usage.byEntity.hook, usage.byEntity.stream);
|
|
57470
|
+
}
|
|
57471
|
+
function readPurgedUsage2(db, runId) {
|
|
57472
|
+
if (!tableExists2(db))
|
|
57473
|
+
return null;
|
|
57474
|
+
const row = db.get(`SELECT seq, run_bytes, step_bytes, hook_bytes, stream_bytes
|
|
57475
|
+
FROM ${TABLE2} WHERE run_id = ?`, runId);
|
|
57476
|
+
if (!row)
|
|
57477
|
+
return null;
|
|
57478
|
+
return {
|
|
57479
|
+
seq: Number(row.seq),
|
|
57480
|
+
byEntity: {
|
|
57481
|
+
run: Number(row.run_bytes),
|
|
57482
|
+
step: Number(row.step_bytes),
|
|
57483
|
+
hook: Number(row.hook_bytes),
|
|
57484
|
+
stream: Number(row.stream_bytes)
|
|
57485
|
+
}
|
|
57486
|
+
};
|
|
57487
|
+
}
|
|
57488
|
+
function deletePurgedUsage2(db, where) {
|
|
57489
|
+
if (!tableExists2(db))
|
|
57490
|
+
return;
|
|
57491
|
+
if (!where) {
|
|
57492
|
+
db.run(`DELETE FROM ${TABLE2}`);
|
|
57493
|
+
return;
|
|
57494
|
+
}
|
|
57495
|
+
db.run(`DELETE FROM ${TABLE2} WHERE run_id IN (${where.runIdsSql})`, ...where.params);
|
|
57496
|
+
}
|
|
57497
|
+
var PAYLOAD_PATHS2, PAYLOAD_EVENT_TYPES2, PAYLOAD_BYTES_SQL2, STREAM_BYTES_SQL2, TABLE2, CREATE_TABLE_SQL2, EntityBytes2;
|
|
57498
|
+
var init_purged_usage2 = __esm({
|
|
57499
|
+
"../world-local/dist/storage/purged-usage.js"() {
|
|
57500
|
+
"use strict";
|
|
57501
|
+
init_dist10();
|
|
57502
|
+
PAYLOAD_PATHS2 = {
|
|
57503
|
+
// A dynamic run's code is kept on the run, not on its events, so it is
|
|
57504
|
+
// not here.
|
|
57505
|
+
run_created: ["$.eventData.input", "$.eventData.startHook.metadata"],
|
|
57506
|
+
run_started: ["$.eventData.input", "$.eventData.startHook.metadata"],
|
|
57507
|
+
run_completed: ["$.eventData.output"],
|
|
57508
|
+
run_failed: ["$.eventData.error"],
|
|
57509
|
+
step_created: ["$.eventData.input"],
|
|
57510
|
+
step_started: ["$.eventData.input"],
|
|
57511
|
+
step_completed: ["$.eventData.result"],
|
|
57512
|
+
step_failed: ["$.eventData.error"],
|
|
57513
|
+
step_retrying: ["$.eventData.error"],
|
|
57514
|
+
hook_created: ["$.eventData.metadata"],
|
|
57515
|
+
hook_received: ["$.eventData.payload"]
|
|
57516
|
+
};
|
|
57517
|
+
PAYLOAD_EVENT_TYPES2 = Object.keys(PAYLOAD_PATHS2);
|
|
57518
|
+
__name(valueBytesSql2, "valueBytesSql");
|
|
57519
|
+
PAYLOAD_BYTES_SQL2 = `(CASE event_type ${Object.entries(PAYLOAD_PATHS2).map(([eventType, paths]) => `WHEN '${eventType}' THEN ${paths.map((path15) => `(${valueBytesSql2(path15)})`).join(" + ")}`).join(" ")} ELSE 0 END)`;
|
|
57520
|
+
STREAM_BYTES_SQL2 = `
|
|
57521
|
+
SELECT COALESCE(SUM(length(data)), 0) AS bytes
|
|
57522
|
+
FROM stream_chunks
|
|
57523
|
+
WHERE run_id = ?
|
|
57524
|
+
`;
|
|
57525
|
+
__name(measureStreamBytes2, "measureStreamBytes");
|
|
57526
|
+
TABLE2 = "run_usage_purged";
|
|
57527
|
+
CREATE_TABLE_SQL2 = `
|
|
57528
|
+
CREATE TABLE IF NOT EXISTS ${TABLE2} (
|
|
57529
|
+
run_id TEXT PRIMARY KEY,
|
|
57530
|
+
-- The last log position the sizes below cover.
|
|
57531
|
+
seq INTEGER NOT NULL,
|
|
57532
|
+
run_bytes INTEGER NOT NULL,
|
|
57533
|
+
step_bytes INTEGER NOT NULL,
|
|
57534
|
+
hook_bytes INTEGER NOT NULL,
|
|
57535
|
+
stream_bytes INTEGER NOT NULL
|
|
57536
|
+
)
|
|
57537
|
+
`;
|
|
57538
|
+
EntityBytes2 = class {
|
|
57539
|
+
static {
|
|
57540
|
+
__name(this, "EntityBytes");
|
|
57541
|
+
}
|
|
57542
|
+
byEntity = {
|
|
57543
|
+
run: 0,
|
|
57544
|
+
step: 0,
|
|
57545
|
+
hook: 0,
|
|
57546
|
+
stream: 0
|
|
57547
|
+
};
|
|
57548
|
+
add(eventType, bytes) {
|
|
57549
|
+
const entity = usageEntityOfEventType2(eventType);
|
|
57550
|
+
if (entity)
|
|
57551
|
+
this.byEntity[entity] += Number(bytes) || 0;
|
|
57552
|
+
}
|
|
57553
|
+
};
|
|
57554
|
+
__name(tableExists2, "tableExists");
|
|
57555
|
+
__name(savePurgedUsage2, "savePurgedUsage");
|
|
57556
|
+
__name(readPurgedUsage2, "readPurgedUsage");
|
|
57557
|
+
__name(deletePurgedUsage2, "deletePurgedUsage");
|
|
57558
|
+
}
|
|
57559
|
+
});
|
|
57560
|
+
|
|
57216
57561
|
// ../world-local/dist/ids.js
|
|
57217
57562
|
function truncateForError2(value) {
|
|
57218
57563
|
const s = typeof value === "string" ? value : String(value);
|
|
@@ -57262,11 +57607,31 @@ function ranPurge2(run3) {
|
|
|
57262
57607
|
return true;
|
|
57263
57608
|
return run3.expiredAt !== void 0 && new Date(run3.expiredAt).getTime() <= Date.now();
|
|
57264
57609
|
}
|
|
57265
|
-
function purgeRunData2(db, runId) {
|
|
57610
|
+
function purgeRunData2(db, runId, { purgedBefore = false } = {}) {
|
|
57266
57611
|
for (const row of db.all("SELECT step_id, doc FROM steps WHERE run_id = ?", runId)) {
|
|
57267
57612
|
writeScrubbedStep2(db, runId, row.step_id, row.doc);
|
|
57268
57613
|
}
|
|
57269
|
-
|
|
57614
|
+
const saved = readPurgedUsage2(db, runId);
|
|
57615
|
+
const written = new EntityBytes2();
|
|
57616
|
+
let lastSeq = 0;
|
|
57617
|
+
const events = db.all(`SELECT seq, event_type, doc, ${PAYLOAD_BYTES_SQL2} AS bytes
|
|
57618
|
+
FROM events WHERE run_id = ?`, runId);
|
|
57619
|
+
for (const row of events) {
|
|
57620
|
+
lastSeq = Math.max(lastSeq, Number(row.seq));
|
|
57621
|
+
if (saved && Number(row.seq) <= saved.seq)
|
|
57622
|
+
continue;
|
|
57623
|
+
written.add(row.event_type, row.bytes);
|
|
57624
|
+
}
|
|
57625
|
+
written.byEntity.stream = measureStreamBytes2(db, runId);
|
|
57626
|
+
if (saved) {
|
|
57627
|
+
savePurgedUsage2(db, runId, {
|
|
57628
|
+
seq: lastSeq,
|
|
57629
|
+
byEntity: addBytes2(saved.byEntity, written.byEntity)
|
|
57630
|
+
});
|
|
57631
|
+
} else if (!purgedBefore) {
|
|
57632
|
+
savePurgedUsage2(db, runId, { seq: lastSeq, byEntity: written.byEntity });
|
|
57633
|
+
}
|
|
57634
|
+
for (const row of events) {
|
|
57270
57635
|
writeScrubbedEvent2(db, runId, row.seq, row.doc);
|
|
57271
57636
|
}
|
|
57272
57637
|
for (const row of db.all("SELECT hook_id, doc FROM hooks WHERE run_id = ?", runId)) {
|
|
@@ -57286,8 +57651,29 @@ function purgeLateStepWrite2(db, runId, stepId, seq) {
|
|
|
57286
57651
|
db.run("UPDATE steps SET doc = ? WHERE run_id = ? AND step_id = ?", encode8(step), runId, stepId);
|
|
57287
57652
|
}
|
|
57288
57653
|
const event = db.get("SELECT doc FROM events WHERE run_id = ? AND seq = ?", runId, seq);
|
|
57289
|
-
if (event)
|
|
57290
|
-
|
|
57654
|
+
if (!event)
|
|
57655
|
+
return;
|
|
57656
|
+
const saved = readPurgedUsage2(db, runId);
|
|
57657
|
+
if (saved && seq > saved.seq) {
|
|
57658
|
+
const written = new EntityBytes2();
|
|
57659
|
+
for (const row of db.all(`SELECT event_type, ${PAYLOAD_BYTES_SQL2} AS bytes
|
|
57660
|
+
FROM events WHERE run_id = ? AND seq > ? AND seq <= ?`, runId, saved.seq, seq)) {
|
|
57661
|
+
written.add(row.event_type, row.bytes);
|
|
57662
|
+
}
|
|
57663
|
+
savePurgedUsage2(db, runId, {
|
|
57664
|
+
seq,
|
|
57665
|
+
byEntity: addBytes2(saved.byEntity, written.byEntity)
|
|
57666
|
+
});
|
|
57667
|
+
}
|
|
57668
|
+
writeScrubbedEvent2(db, runId, seq, event.doc);
|
|
57669
|
+
}
|
|
57670
|
+
function addBytes2(a, b) {
|
|
57671
|
+
return {
|
|
57672
|
+
run: a.run + b.run,
|
|
57673
|
+
step: a.step + b.step,
|
|
57674
|
+
hook: a.hook + b.hook,
|
|
57675
|
+
stream: a.stream + b.stream
|
|
57676
|
+
};
|
|
57291
57677
|
}
|
|
57292
57678
|
function writeScrubbedStep2(db, runId, stepId, doc) {
|
|
57293
57679
|
const step = decode8(doc);
|
|
@@ -57325,10 +57711,12 @@ var init_run_retention2 = __esm({
|
|
|
57325
57711
|
"use strict";
|
|
57326
57712
|
init_dist10();
|
|
57327
57713
|
init_codec3();
|
|
57714
|
+
init_purged_usage2();
|
|
57328
57715
|
__name(purgesUserDataOnFinish3, "purgesUserDataOnFinish");
|
|
57329
57716
|
__name(ranPurge2, "ranPurge");
|
|
57330
57717
|
__name(purgeRunData2, "purgeRunData");
|
|
57331
57718
|
__name(purgeLateStepWrite2, "purgeLateStepWrite");
|
|
57719
|
+
__name(addBytes2, "addBytes");
|
|
57332
57720
|
__name(writeScrubbedStep2, "writeScrubbedStep");
|
|
57333
57721
|
__name(writeScrubbedEvent2, "writeScrubbedEvent");
|
|
57334
57722
|
__name(purgeRunStreams2, "purgeRunStreams");
|
|
@@ -57611,6 +57999,7 @@ var init_store2 = __esm({
|
|
|
57611
57999
|
eventsBetween(runId, afterSeq, beforeSeq) {
|
|
57612
58000
|
return this.db.all("SELECT doc FROM events WHERE run_id = ? AND seq > ? AND seq < ? ORDER BY seq", runId, afterSeq, beforeSeq).map((row) => decode8(row.doc));
|
|
57613
58001
|
}
|
|
58002
|
+
// A caller that rewrites a live run's events makes the usage cache stale (see usage-storage.ts).
|
|
57614
58003
|
rewriteEvent(event) {
|
|
57615
58004
|
const seq = eventIdToSlot2(event.eventId);
|
|
57616
58005
|
if (seq === null)
|
|
@@ -58816,7 +59205,7 @@ function createRunsStorage2(db, tag) {
|
|
|
58816
59205
|
const alreadyDeleted = run3.expiredAt !== void 0 && run3.expiredAt.getTime() <= now3.getTime();
|
|
58817
59206
|
if (!alreadyDeleted)
|
|
58818
59207
|
store.updateRun(withRunPayloadsPurged2(run3, now3));
|
|
58819
|
-
purgeRunData2(db, runId);
|
|
59208
|
+
purgeRunData2(db, runId, { purgedBefore: alreadyDeleted });
|
|
58820
59209
|
return { runId, outcome: alreadyDeleted ? "already_deleted" : "deleted" };
|
|
58821
59210
|
}
|
|
58822
59211
|
__name(deleteRunData, "deleteRunData");
|
|
@@ -59047,6 +59436,339 @@ var init_steps_storage2 = __esm({
|
|
|
59047
59436
|
}
|
|
59048
59437
|
});
|
|
59049
59438
|
|
|
59439
|
+
// ../world-local/dist/storage/usage-storage.js
|
|
59440
|
+
function countRange2(db, runId, counts, from, to) {
|
|
59441
|
+
if (to <= from)
|
|
59442
|
+
return;
|
|
59443
|
+
for (const row of db.all(EVENT_GROUPS_SQL2, runId, from, to)) {
|
|
59444
|
+
const entry = counts.eventTypes.get(row.event_type) ?? {
|
|
59445
|
+
events: 0,
|
|
59446
|
+
bytes: 0
|
|
59447
|
+
};
|
|
59448
|
+
entry.events += Number(row.events);
|
|
59449
|
+
entry.bytes += Number(row.bytes ?? 0);
|
|
59450
|
+
counts.eventTypes.set(row.event_type, entry);
|
|
59451
|
+
}
|
|
59452
|
+
for (const row of db.all(STEP_GROUPS_SQL2, runId, from, to)) {
|
|
59453
|
+
const stepId = row.correlation_id ?? "";
|
|
59454
|
+
let step = counts.steps.get(stepId);
|
|
59455
|
+
if (!step) {
|
|
59456
|
+
const name = row.correlation_id === null ? null : db.get(STEP_NAME_SQL2, runId, row.correlation_id)?.step_name ?? null;
|
|
59457
|
+
step = {
|
|
59458
|
+
name,
|
|
59459
|
+
events: 0,
|
|
59460
|
+
created: 0,
|
|
59461
|
+
started: 0,
|
|
59462
|
+
completed: 0,
|
|
59463
|
+
failed: 0,
|
|
59464
|
+
retries: 0,
|
|
59465
|
+
bytes: 0
|
|
59466
|
+
};
|
|
59467
|
+
counts.steps.set(stepId, step);
|
|
59468
|
+
}
|
|
59469
|
+
step.events += Number(row.events);
|
|
59470
|
+
step.created += Number(row.created);
|
|
59471
|
+
step.started += Number(row.started);
|
|
59472
|
+
step.completed += Number(row.completed);
|
|
59473
|
+
step.failed += Number(row.failed);
|
|
59474
|
+
step.retries += Number(row.retries);
|
|
59475
|
+
step.bytes += Number(row.bytes ?? 0);
|
|
59476
|
+
}
|
|
59477
|
+
for (const row of db.all(HOOK_GROUPS_SQL2, runId, from, to)) {
|
|
59478
|
+
let hook = counts.hooks.get(row.correlation_id);
|
|
59479
|
+
if (!hook) {
|
|
59480
|
+
hook = { token: hookToken2(db, runId, row.correlation_id), events: 0 };
|
|
59481
|
+
counts.hooks.set(row.correlation_id, hook);
|
|
59482
|
+
}
|
|
59483
|
+
hook.events += Number(row.events);
|
|
59484
|
+
}
|
|
59485
|
+
for (const row of db.all(WAIT_IDS_SQL2, runId, from, to)) {
|
|
59486
|
+
counts.waitIds.add(row.correlation_id);
|
|
59487
|
+
}
|
|
59488
|
+
counts.countedSeq = to;
|
|
59489
|
+
}
|
|
59490
|
+
function hookToken2(db, runId, hookId) {
|
|
59491
|
+
const created = db.get(HOOK_TOKEN_SQL2, runId, hookId);
|
|
59492
|
+
if (typeof created?.token === "string" && created.token)
|
|
59493
|
+
return created.token;
|
|
59494
|
+
const row = db.get(HOOK_ROW_TOKEN_SQL2, hookId);
|
|
59495
|
+
if (typeof row?.token === "string" && row.token)
|
|
59496
|
+
return row.token;
|
|
59497
|
+
let startHook;
|
|
59498
|
+
try {
|
|
59499
|
+
startHook = startHookId2(runId);
|
|
59500
|
+
} catch {
|
|
59501
|
+
return null;
|
|
59502
|
+
}
|
|
59503
|
+
if (hookId !== startHook)
|
|
59504
|
+
return null;
|
|
59505
|
+
const start3 = db.get(START_HOOK_TOKEN_SQL2, runId);
|
|
59506
|
+
return typeof start3?.token === "string" && start3.token ? start3.token : null;
|
|
59507
|
+
}
|
|
59508
|
+
function hookGroupsOf2(counts) {
|
|
59509
|
+
return [...counts.hooks].map(([hookId, hook]) => ({
|
|
59510
|
+
hookId,
|
|
59511
|
+
token: hook.token,
|
|
59512
|
+
events: hook.events
|
|
59513
|
+
}));
|
|
59514
|
+
}
|
|
59515
|
+
function eventGroupsOf2(counts) {
|
|
59516
|
+
return [...counts.eventTypes].map(([eventType, entry]) => ({
|
|
59517
|
+
eventType,
|
|
59518
|
+
events: entry.events,
|
|
59519
|
+
bytes: entry.bytes
|
|
59520
|
+
}));
|
|
59521
|
+
}
|
|
59522
|
+
function stepGroupsOf2(counts) {
|
|
59523
|
+
const byName = /* @__PURE__ */ new Map();
|
|
59524
|
+
for (const step of counts.steps.values()) {
|
|
59525
|
+
let group = byName.get(step.name);
|
|
59526
|
+
if (!group) {
|
|
59527
|
+
group = {
|
|
59528
|
+
stepName: step.name,
|
|
59529
|
+
steps: 0,
|
|
59530
|
+
events: 0,
|
|
59531
|
+
created: 0,
|
|
59532
|
+
started: 0,
|
|
59533
|
+
completed: 0,
|
|
59534
|
+
failed: 0,
|
|
59535
|
+
retries: 0,
|
|
59536
|
+
restarts: 0,
|
|
59537
|
+
bytes: 0
|
|
59538
|
+
};
|
|
59539
|
+
byName.set(step.name, group);
|
|
59540
|
+
}
|
|
59541
|
+
group.steps += 1;
|
|
59542
|
+
group.events += step.events;
|
|
59543
|
+
group.created += step.created;
|
|
59544
|
+
group.started += step.started;
|
|
59545
|
+
group.completed += step.completed;
|
|
59546
|
+
group.failed += step.failed;
|
|
59547
|
+
group.retries += step.retries;
|
|
59548
|
+
group.restarts += Math.min(step.retries, Math.max(0, step.started - 1));
|
|
59549
|
+
group.bytes += step.bytes;
|
|
59550
|
+
}
|
|
59551
|
+
return [...byName.values()];
|
|
59552
|
+
}
|
|
59553
|
+
function purgedDataWritten2(db, runId, streamBytes) {
|
|
59554
|
+
const saved = readPurgedUsage2(db, runId);
|
|
59555
|
+
if (!saved)
|
|
59556
|
+
return null;
|
|
59557
|
+
const late = new EntityBytes2();
|
|
59558
|
+
for (const row of db.all(EVENTS_AFTER_SQL2, runId, saved.seq)) {
|
|
59559
|
+
late.add(row.event_type, Number(row.bytes ?? 0));
|
|
59560
|
+
}
|
|
59561
|
+
return {
|
|
59562
|
+
run: saved.byEntity.run + late.byEntity.run,
|
|
59563
|
+
step: saved.byEntity.step + late.byEntity.step,
|
|
59564
|
+
hook: saved.byEntity.hook + late.byEntity.hook,
|
|
59565
|
+
stream: saved.byEntity.stream + streamBytes
|
|
59566
|
+
};
|
|
59567
|
+
}
|
|
59568
|
+
function createUsageStorage2(db, tag, options = {}) {
|
|
59569
|
+
const maxRuns = options.maxRuns ?? 64;
|
|
59570
|
+
const batchTargetMs = options.batchTargetMs ?? 10;
|
|
59571
|
+
const maxBatchRows = options.maxBatchRows ?? 4096;
|
|
59572
|
+
const initialBatchRows = options.initialBatchRows ?? 4;
|
|
59573
|
+
const cache = /* @__PURE__ */ new Map();
|
|
59574
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
59575
|
+
const remember = /* @__PURE__ */ __name((runId, counts) => {
|
|
59576
|
+
cache.delete(runId);
|
|
59577
|
+
cache.set(runId, counts);
|
|
59578
|
+
while (cache.size > maxRuns) {
|
|
59579
|
+
cache.delete(cache.keys().next().value);
|
|
59580
|
+
}
|
|
59581
|
+
}, "remember");
|
|
59582
|
+
const runRow = /* @__PURE__ */ __name((runId) => db.get(`SELECT status, workflow_name, seq FROM runs WHERE run_id = ? AND ${tagClause2("tag", tag)}`, runId, ...tagParams2(tag)), "runRow");
|
|
59583
|
+
async function countInBatches(runId, counts, target3) {
|
|
59584
|
+
let batchRows = initialBatchRows;
|
|
59585
|
+
while (counts.countedSeq < target3) {
|
|
59586
|
+
const end = Number(db.get(BATCH_END_SQL2, runId, counts.countedSeq, batchRows)?.seq ?? target3);
|
|
59587
|
+
const started = performance.now();
|
|
59588
|
+
countRange2(db, runId, counts, counts.countedSeq, Math.min(end, target3));
|
|
59589
|
+
const took = performance.now() - started;
|
|
59590
|
+
batchRows = Math.max(1, Math.min(maxBatchRows, batchRows * 2, Math.round(batchRows * batchTargetMs / Math.max(took, 0.1))));
|
|
59591
|
+
if (counts.countedSeq < target3) {
|
|
59592
|
+
await options.onBatch?.(runId, counts.countedSeq);
|
|
59593
|
+
await yieldToEventLoop2();
|
|
59594
|
+
}
|
|
59595
|
+
}
|
|
59596
|
+
}
|
|
59597
|
+
__name(countInBatches, "countInBatches");
|
|
59598
|
+
async function read5(runId) {
|
|
59599
|
+
const first = runRow(runId);
|
|
59600
|
+
if (!first) {
|
|
59601
|
+
cache.delete(runId);
|
|
59602
|
+
throw new WorkflowRunNotFoundError2(runId);
|
|
59603
|
+
}
|
|
59604
|
+
let counts = cache.get(runId) ?? newCounts2();
|
|
59605
|
+
if (Number(first.seq) < counts.countedSeq)
|
|
59606
|
+
counts = newCounts2();
|
|
59607
|
+
let readBeforeFinish = !isTerminalWorkflowRunStatus2(first.status) || counts.countedSeq > 0 && !counts.finished;
|
|
59608
|
+
await countInBatches(runId, counts, Number(first.seq));
|
|
59609
|
+
const snapshot = db.snapshot(() => {
|
|
59610
|
+
const run3 = runRow(runId);
|
|
59611
|
+
if (!run3)
|
|
59612
|
+
return null;
|
|
59613
|
+
const seq = Number(run3.seq);
|
|
59614
|
+
const finished = isTerminalWorkflowRunStatus2(run3.status);
|
|
59615
|
+
if (seq < counts.countedSeq) {
|
|
59616
|
+
counts = newCounts2();
|
|
59617
|
+
readBeforeFinish = !finished;
|
|
59618
|
+
}
|
|
59619
|
+
countRange2(db, runId, counts, counts.countedSeq, seq);
|
|
59620
|
+
const streamBytes = measureStreamBytes2(db, runId);
|
|
59621
|
+
const savedDataWritten = purgedDataWritten2(db, runId, streamBytes) ?? void 0;
|
|
59622
|
+
const dataPurged = savedDataWritten !== void 0 || finished && Number(db.get(PURGED_RUN_SQL2, runId)?.purged) === 1;
|
|
59623
|
+
if (dataPurged && readBeforeFinish && counts.countedSeq > 0) {
|
|
59624
|
+
options.onRecount?.(runId);
|
|
59625
|
+
counts = newCounts2();
|
|
59626
|
+
countRange2(db, runId, counts, 0, seq);
|
|
59627
|
+
}
|
|
59628
|
+
counts.finished = finished;
|
|
59629
|
+
return {
|
|
59630
|
+
run: run3,
|
|
59631
|
+
streamBytes,
|
|
59632
|
+
dataPurged,
|
|
59633
|
+
savedDataWritten
|
|
59634
|
+
};
|
|
59635
|
+
});
|
|
59636
|
+
if (!snapshot) {
|
|
59637
|
+
cache.delete(runId);
|
|
59638
|
+
throw new WorkflowRunNotFoundError2(runId);
|
|
59639
|
+
}
|
|
59640
|
+
remember(runId, counts);
|
|
59641
|
+
return buildRunUsage2({
|
|
59642
|
+
runId,
|
|
59643
|
+
status: snapshot.run.status,
|
|
59644
|
+
workflowName: snapshot.run.workflow_name,
|
|
59645
|
+
eventGroups: eventGroupsOf2(counts),
|
|
59646
|
+
stepGroups: stepGroupsOf2(counts),
|
|
59647
|
+
streamBytes: snapshot.streamBytes,
|
|
59648
|
+
dataPurged: snapshot.dataPurged,
|
|
59649
|
+
savedDataWritten: snapshot.savedDataWritten,
|
|
59650
|
+
hookGroups: hookGroupsOf2(counts),
|
|
59651
|
+
calls: { wait: counts.waitIds.size },
|
|
59652
|
+
// Local runs are not billed.
|
|
59653
|
+
billed: false,
|
|
59654
|
+
// world-local has no plan retention, so there is no Data Retained to
|
|
59655
|
+
// report: the UI and CLI hide it.
|
|
59656
|
+
dataRetained: null
|
|
59657
|
+
});
|
|
59658
|
+
}
|
|
59659
|
+
__name(read5, "read");
|
|
59660
|
+
return {
|
|
59661
|
+
async getRun(runId) {
|
|
59662
|
+
assertSafeEntityId2("runId", runId);
|
|
59663
|
+
const previous = inFlight.get(runId) ?? Promise.resolve();
|
|
59664
|
+
const current3 = previous.catch(() => {
|
|
59665
|
+
}).then(() => read5(runId));
|
|
59666
|
+
inFlight.set(runId, current3);
|
|
59667
|
+
try {
|
|
59668
|
+
return await current3;
|
|
59669
|
+
} finally {
|
|
59670
|
+
if (inFlight.get(runId) === current3)
|
|
59671
|
+
inFlight.delete(runId);
|
|
59672
|
+
}
|
|
59673
|
+
}
|
|
59674
|
+
};
|
|
59675
|
+
}
|
|
59676
|
+
var IS_STEP_EVENT2, EVENT_GROUPS_SQL2, STEP_GROUPS_SQL2, WAIT_IDS_SQL2, HOOK_GROUPS_SQL2, HOOK_TOKEN_SQL2, HOOK_ROW_TOKEN_SQL2, START_HOOK_TOKEN_SQL2, STEP_NAME_SQL2, BATCH_END_SQL2, EVENTS_AFTER_SQL2, PURGED_RUN_SQL2, newCounts2, yieldToEventLoop2;
|
|
59677
|
+
var init_usage_storage2 = __esm({
|
|
59678
|
+
"../world-local/dist/storage/usage-storage.js"() {
|
|
59679
|
+
"use strict";
|
|
59680
|
+
init_dist11();
|
|
59681
|
+
init_dist10();
|
|
59682
|
+
init_ids2();
|
|
59683
|
+
init_purged_usage2();
|
|
59684
|
+
init_store2();
|
|
59685
|
+
IS_STEP_EVENT2 = `event_type LIKE 'step\\_%' ESCAPE '\\'`;
|
|
59686
|
+
EVENT_GROUPS_SQL2 = `
|
|
59687
|
+
SELECT event_type,
|
|
59688
|
+
COUNT(*) AS events,
|
|
59689
|
+
SUM(${PAYLOAD_BYTES_SQL2}) AS bytes
|
|
59690
|
+
FROM events
|
|
59691
|
+
WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3 AND NOT (${IS_STEP_EVENT2})
|
|
59692
|
+
GROUP BY event_type
|
|
59693
|
+
`;
|
|
59694
|
+
STEP_GROUPS_SQL2 = `
|
|
59695
|
+
SELECT correlation_id,
|
|
59696
|
+
COUNT(*) AS events,
|
|
59697
|
+
SUM(event_type = 'step_created') AS created,
|
|
59698
|
+
SUM(event_type = 'step_started') AS started,
|
|
59699
|
+
SUM(event_type = 'step_completed') AS completed,
|
|
59700
|
+
SUM(event_type = 'step_failed') AS failed,
|
|
59701
|
+
SUM(event_type = 'step_retrying') AS retries,
|
|
59702
|
+
SUM(${PAYLOAD_BYTES_SQL2}) AS bytes
|
|
59703
|
+
FROM events
|
|
59704
|
+
WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3 AND ${IS_STEP_EVENT2}
|
|
59705
|
+
GROUP BY correlation_id
|
|
59706
|
+
`;
|
|
59707
|
+
WAIT_IDS_SQL2 = `
|
|
59708
|
+
SELECT DISTINCT correlation_id
|
|
59709
|
+
FROM events
|
|
59710
|
+
WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3
|
|
59711
|
+
AND correlation_id IS NOT NULL AND substr(event_type, 1, 5) = 'wait_'
|
|
59712
|
+
`;
|
|
59713
|
+
HOOK_GROUPS_SQL2 = `
|
|
59714
|
+
SELECT correlation_id, COUNT(*) AS events
|
|
59715
|
+
FROM events
|
|
59716
|
+
WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3
|
|
59717
|
+
AND correlation_id IS NOT NULL AND substr(event_type, 1, 5) = 'hook_'
|
|
59718
|
+
GROUP BY correlation_id
|
|
59719
|
+
`;
|
|
59720
|
+
HOOK_TOKEN_SQL2 = `
|
|
59721
|
+
SELECT json_extract(doc, '$.eventData.token') AS token
|
|
59722
|
+
FROM ${EVENTS_BY_CORRELATION2}
|
|
59723
|
+
WHERE run_id = ? AND correlation_id = ?
|
|
59724
|
+
AND event_type IN ('hook_created', 'hook_conflict')
|
|
59725
|
+
ORDER BY seq LIMIT 1
|
|
59726
|
+
`;
|
|
59727
|
+
HOOK_ROW_TOKEN_SQL2 = "SELECT token FROM hooks WHERE hook_id = ?";
|
|
59728
|
+
START_HOOK_TOKEN_SQL2 = `
|
|
59729
|
+
SELECT json_extract(doc, '$.eventData.startHook.token') AS token
|
|
59730
|
+
FROM events
|
|
59731
|
+
WHERE run_id = ? AND event_type = 'run_created'
|
|
59732
|
+
LIMIT 1
|
|
59733
|
+
`;
|
|
59734
|
+
STEP_NAME_SQL2 = `
|
|
59735
|
+
SELECT json_extract(doc, '$.stepName') AS step_name
|
|
59736
|
+
FROM steps WHERE run_id = ? AND step_id = ?
|
|
59737
|
+
`;
|
|
59738
|
+
BATCH_END_SQL2 = `
|
|
59739
|
+
SELECT MAX(seq) AS seq FROM (
|
|
59740
|
+
SELECT seq FROM events WHERE run_id = ? AND seq > ? ORDER BY seq LIMIT ?
|
|
59741
|
+
)
|
|
59742
|
+
`;
|
|
59743
|
+
EVENTS_AFTER_SQL2 = `
|
|
59744
|
+
SELECT event_type, SUM(${PAYLOAD_BYTES_SQL2}) AS bytes
|
|
59745
|
+
FROM events
|
|
59746
|
+
WHERE run_id = ? AND seq > ?
|
|
59747
|
+
GROUP BY event_type
|
|
59748
|
+
`;
|
|
59749
|
+
PURGED_RUN_SQL2 = `
|
|
59750
|
+
SELECT json_extract(doc, '$.expiredAt') IS NOT NULL AS purged
|
|
59751
|
+
FROM runs WHERE run_id = ?
|
|
59752
|
+
`;
|
|
59753
|
+
newCounts2 = /* @__PURE__ */ __name(() => ({
|
|
59754
|
+
countedSeq: 0,
|
|
59755
|
+
finished: false,
|
|
59756
|
+
eventTypes: /* @__PURE__ */ new Map(),
|
|
59757
|
+
steps: /* @__PURE__ */ new Map(),
|
|
59758
|
+
hooks: /* @__PURE__ */ new Map(),
|
|
59759
|
+
waitIds: /* @__PURE__ */ new Set()
|
|
59760
|
+
}), "newCounts");
|
|
59761
|
+
__name(countRange2, "countRange");
|
|
59762
|
+
__name(hookToken2, "hookToken");
|
|
59763
|
+
__name(hookGroupsOf2, "hookGroupsOf");
|
|
59764
|
+
__name(eventGroupsOf2, "eventGroupsOf");
|
|
59765
|
+
__name(stepGroupsOf2, "stepGroupsOf");
|
|
59766
|
+
__name(purgedDataWritten2, "purgedDataWritten");
|
|
59767
|
+
yieldToEventLoop2 = /* @__PURE__ */ __name(() => new Promise((resolve4) => setImmediate(resolve4)), "yieldToEventLoop");
|
|
59768
|
+
__name(createUsageStorage2, "createUsageStorage");
|
|
59769
|
+
}
|
|
59770
|
+
});
|
|
59771
|
+
|
|
59050
59772
|
// ../world-local/dist/storage/index.js
|
|
59051
59773
|
function createStorage3(basedir, tag) {
|
|
59052
59774
|
const db = databaseFor2(basedir);
|
|
@@ -59055,12 +59777,14 @@ function createStorage3(basedir, tag) {
|
|
|
59055
59777
|
const events = createEventsStorage2(db, tag);
|
|
59056
59778
|
const hooks = createHooksStorage2(db, tag);
|
|
59057
59779
|
const snapshots = createSnapshotsStorage3(db);
|
|
59780
|
+
const usage = createUsageStorage2(db, tag);
|
|
59058
59781
|
return {
|
|
59059
59782
|
runs: instrumentObject3("world.runs", runs),
|
|
59060
59783
|
steps: instrumentObject3("world.steps", steps),
|
|
59061
59784
|
events: instrumentObject3("world.events", events),
|
|
59062
59785
|
hooks: instrumentObject3("world.hooks", hooks),
|
|
59063
59786
|
experimental_snapshots: instrumentObject3("world.experimental_snapshots", snapshots),
|
|
59787
|
+
experimental_usage: instrumentObject3("world.experimental_usage", usage),
|
|
59064
59788
|
clearCache: /* @__PURE__ */ __name(() => {
|
|
59065
59789
|
}, "clearCache")
|
|
59066
59790
|
};
|
|
@@ -59075,6 +59799,7 @@ var init_storage4 = __esm({
|
|
|
59075
59799
|
init_runs_storage2();
|
|
59076
59800
|
init_snapshots_storage2();
|
|
59077
59801
|
init_steps_storage2();
|
|
59802
|
+
init_usage_storage2();
|
|
59078
59803
|
__name(createStorage3, "createStorage");
|
|
59079
59804
|
}
|
|
59080
59805
|
});
|
|
@@ -59481,9 +60206,11 @@ function createWorld4(args) {
|
|
|
59481
60206
|
]) {
|
|
59482
60207
|
db.run(`DELETE FROM ${table}`);
|
|
59483
60208
|
}
|
|
60209
|
+
deletePurgedUsage2(db);
|
|
59484
60210
|
return;
|
|
59485
60211
|
}
|
|
59486
60212
|
const runs = "SELECT run_id FROM runs WHERE tag = ?";
|
|
60213
|
+
deletePurgedUsage2(db, { runIdsSql: runs, params: [tag] });
|
|
59487
60214
|
for (const table of [
|
|
59488
60215
|
"events",
|
|
59489
60216
|
"steps",
|
|
@@ -59523,6 +60250,7 @@ var init_dist12 = __esm({
|
|
|
59523
60250
|
init_queue5();
|
|
59524
60251
|
init_queue_auth_key2();
|
|
59525
60252
|
init_recovery_wake2();
|
|
60253
|
+
init_purged_usage2();
|
|
59526
60254
|
init_storage5();
|
|
59527
60255
|
init_streamer3();
|
|
59528
60256
|
init_build_target_mismatch2();
|
|
@@ -63376,7 +64104,7 @@ var version6;
|
|
|
63376
64104
|
var init_version4 = __esm({
|
|
63377
64105
|
"../world-vercel/dist/version.js"() {
|
|
63378
64106
|
"use strict";
|
|
63379
|
-
version6 = "5.7.
|
|
64107
|
+
version6 = "5.7.2";
|
|
63380
64108
|
}
|
|
63381
64109
|
});
|
|
63382
64110
|
|
|
@@ -72209,17 +72937,17 @@ var require_exec2 = __commonJS({
|
|
|
72209
72937
|
var import_node_path11 = __toESM3(__require("node:path"));
|
|
72210
72938
|
var import_execa = __toESM3(require_execa2());
|
|
72211
72939
|
var import_envpath = require_envpath2();
|
|
72212
|
-
var
|
|
72940
|
+
var import_errors90 = require_errors5();
|
|
72213
72941
|
var import_lookup = require_lookup2();
|
|
72214
72942
|
async function execVercelCli2(args, options = {}) {
|
|
72215
72943
|
const cwd = import_node_path11.default.resolve(options.cwd ?? process.cwd());
|
|
72216
|
-
await (0,
|
|
72944
|
+
await (0, import_errors90.assertValidCwd)(cwd);
|
|
72217
72945
|
const env = mergeExecEnv(options.env);
|
|
72218
72946
|
const pathValue = (0, import_envpath.getEnvPath)(env);
|
|
72219
72947
|
try {
|
|
72220
72948
|
return await execResolvedVercelCli(args, options, cwd, env, pathValue);
|
|
72221
72949
|
} catch (error123) {
|
|
72222
|
-
if (error123 instanceof
|
|
72950
|
+
if (error123 instanceof import_errors90.VercelCliError && error123.code === "VERCEL_CLI_NOT_FOUND") {
|
|
72223
72951
|
(0, import_lookup.clearCachedCliInvocation)(cwd, pathValue);
|
|
72224
72952
|
return await execResolvedVercelCli(args, options, cwd, env, pathValue);
|
|
72225
72953
|
}
|
|
@@ -72251,16 +72979,16 @@ var require_exec2 = __commonJS({
|
|
|
72251
72979
|
);
|
|
72252
72980
|
return { stdout, stderr, invocation };
|
|
72253
72981
|
} catch (error123) {
|
|
72254
|
-
throw (0,
|
|
72982
|
+
throw (0, import_errors90.toVercelCliError)(invocation, error123);
|
|
72255
72983
|
}
|
|
72256
72984
|
}
|
|
72257
72985
|
__name(execResolvedVercelCli, "execResolvedVercelCli");
|
|
72258
72986
|
async function resolveInvocationOrThrow(cwd, pathValue) {
|
|
72259
72987
|
const resolution = await (0, import_lookup.resolveCachedCliInvocation)(cwd, pathValue);
|
|
72260
72988
|
if (!resolution.found) {
|
|
72261
|
-
throw new
|
|
72989
|
+
throw new import_errors90.VercelCliError({
|
|
72262
72990
|
code: "VERCEL_CLI_NOT_FOUND",
|
|
72263
|
-
message: (0,
|
|
72991
|
+
message: (0, import_errors90.getCliNotFoundMessage)(resolution.diagnostics)
|
|
72264
72992
|
});
|
|
72265
72993
|
}
|
|
72266
72994
|
return (0, import_lookup.toVercelCliInvocation)(resolution);
|
|
@@ -72314,13 +73042,13 @@ var require_dist6 = __commonJS({
|
|
|
72314
73042
|
var __toCommonJS = /* @__PURE__ */ __name((mod) => __copyProps3(__defProp3({}, "__esModule", { value: true }), mod), "__toCommonJS");
|
|
72315
73043
|
var src_exports = {};
|
|
72316
73044
|
__export3(src_exports, {
|
|
72317
|
-
VercelCliError: /* @__PURE__ */ __name(() =>
|
|
73045
|
+
VercelCliError: /* @__PURE__ */ __name(() => import_errors90.VercelCliError, "VercelCliError"),
|
|
72318
73046
|
clearVercelCliLookupCache: /* @__PURE__ */ __name(() => import_lookup.clearVercelCliLookupCache, "clearVercelCliLookupCache"),
|
|
72319
73047
|
execVercelCli: /* @__PURE__ */ __name(() => import_exec.execVercelCli, "execVercelCli"),
|
|
72320
73048
|
findVercelCli: /* @__PURE__ */ __name(() => import_lookup.findVercelCli, "findVercelCli")
|
|
72321
73049
|
});
|
|
72322
73050
|
module.exports = __toCommonJS(src_exports);
|
|
72323
|
-
var
|
|
73051
|
+
var import_errors90 = require_errors5();
|
|
72324
73052
|
var import_exec = require_exec2();
|
|
72325
73053
|
var import_lookup = require_lookup2();
|
|
72326
73054
|
}
|
|
@@ -104761,11 +105489,11 @@ function getWorkflowRunStreamId2(runId, namespace) {
|
|
|
104761
105489
|
function getAbortStreamId2(id) {
|
|
104762
105490
|
return `strm_${id}_system_abort`;
|
|
104763
105491
|
}
|
|
104764
|
-
function getAbortStreamIdFromToken(
|
|
104765
|
-
if (!
|
|
104766
|
-
throw new Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${
|
|
105492
|
+
function getAbortStreamIdFromToken(hookToken3) {
|
|
105493
|
+
if (!hookToken3.startsWith(ABORT_TOKEN_PREFIX)) {
|
|
105494
|
+
throw new Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${hookToken3}"`);
|
|
104767
105495
|
}
|
|
104768
|
-
return getAbortStreamId2(
|
|
105496
|
+
return getAbortStreamId2(hookToken3.slice(ABORT_TOKEN_PREFIX.length));
|
|
104769
105497
|
}
|
|
104770
105498
|
var ABORT_TOKEN_PREFIX;
|
|
104771
105499
|
var init_util6 = __esm({
|
|
@@ -105077,7 +105805,7 @@ var init_events_consumer2 = __esm({
|
|
|
105077
105805
|
while (true) {
|
|
105078
105806
|
this.drainParked();
|
|
105079
105807
|
const currentEvent = this.events[this.eventIndex] ?? null;
|
|
105080
|
-
if (currentEvent !== null &&
|
|
105808
|
+
if (currentEvent !== null && isSealedNoopEvent2(currentEvent)) {
|
|
105081
105809
|
this.skipSealedNoop(currentEvent);
|
|
105082
105810
|
continue;
|
|
105083
105811
|
}
|
|
@@ -105766,15 +106494,15 @@ function createCreateAbortController(ctx) {
|
|
|
105766
106494
|
constructor() {
|
|
105767
106495
|
const id = ctx.generateUlid();
|
|
105768
106496
|
const streamName = getAbortStreamId2(id);
|
|
105769
|
-
const
|
|
106497
|
+
const hookToken3 = `abrt_${id}`;
|
|
105770
106498
|
this[ABORT_STREAM_NAME2] = streamName;
|
|
105771
|
-
this[ABORT_HOOK_TOKEN2] =
|
|
105772
|
-
this.signal = new WorkflowAbortSignal2(streamName,
|
|
106499
|
+
this[ABORT_HOOK_TOKEN2] = hookToken3;
|
|
106500
|
+
this.signal = new WorkflowAbortSignal2(streamName, hookToken3);
|
|
105773
106501
|
const correlationId = mintHookCorrelationId(ctx.generateUlid, ctx.startHook);
|
|
105774
106502
|
ctx.invocationsQueue.set(correlationId, {
|
|
105775
106503
|
type: "hook",
|
|
105776
106504
|
correlationId,
|
|
105777
|
-
token:
|
|
106505
|
+
token: hookToken3,
|
|
105778
106506
|
isWebhook: false,
|
|
105779
106507
|
isSystem: true
|
|
105780
106508
|
});
|
|
@@ -105927,9 +106655,9 @@ var init_abort_controller2 = __esm({
|
|
|
105927
106655
|
handler.call(this);
|
|
105928
106656
|
}
|
|
105929
106657
|
}
|
|
105930
|
-
constructor(streamName,
|
|
106658
|
+
constructor(streamName, hookToken3) {
|
|
105931
106659
|
this[ABORT_STREAM_NAME2] = streamName;
|
|
105932
|
-
this[ABORT_HOOK_TOKEN2] =
|
|
106660
|
+
this[ABORT_HOOK_TOKEN2] = hookToken3;
|
|
105933
106661
|
}
|
|
105934
106662
|
/**
|
|
105935
106663
|
* @internal Sets aborted state and fires listeners.
|
|
@@ -106638,35 +107366,35 @@ function getAllBaseReducers2(global2 = globalThis) {
|
|
|
106638
107366
|
}
|
|
106639
107367
|
function reduceAbortWithListener2(signal, holder, global2, ops, runId, cryptoKey, framedAbortStreams) {
|
|
106640
107368
|
let streamName = holder[ABORT_STREAM_NAME2];
|
|
106641
|
-
let
|
|
107369
|
+
let hookToken3 = holder[ABORT_HOOK_TOKEN2];
|
|
106642
107370
|
if (!streamName) {
|
|
106643
107371
|
const id = (global2[STABLE_ULID2] || defaultUlid2)();
|
|
106644
107372
|
streamName = getAbortStreamId2(id);
|
|
106645
|
-
|
|
107373
|
+
hookToken3 = `abrt_${id}`;
|
|
106646
107374
|
holder[ABORT_STREAM_NAME2] = streamName;
|
|
106647
|
-
holder[ABORT_HOOK_TOKEN2] =
|
|
107375
|
+
holder[ABORT_HOOK_TOKEN2] = hookToken3;
|
|
106648
107376
|
if (holder.signal) {
|
|
106649
107377
|
holder.signal[ABORT_STREAM_NAME2] = streamName;
|
|
106650
|
-
holder.signal[ABORT_HOOK_TOKEN2] =
|
|
107378
|
+
holder.signal[ABORT_HOOK_TOKEN2] = hookToken3;
|
|
106651
107379
|
}
|
|
106652
107380
|
}
|
|
106653
107381
|
attachAbortListenerOnce2(signal, streamName, runId, cryptoKey, ops, framedAbortStreams);
|
|
106654
107382
|
return {
|
|
106655
107383
|
streamName,
|
|
106656
|
-
hookToken,
|
|
107384
|
+
hookToken: hookToken3,
|
|
106657
107385
|
aborted: signal.aborted,
|
|
106658
107386
|
reason: signal.aborted ? signal.reason : void 0
|
|
106659
107387
|
};
|
|
106660
107388
|
}
|
|
106661
107389
|
function reduceAbortBySymbol2(signal, holder) {
|
|
106662
107390
|
const streamName = holder[ABORT_STREAM_NAME2] ?? holder.signal?.[ABORT_STREAM_NAME2];
|
|
106663
|
-
const
|
|
107391
|
+
const hookToken3 = holder[ABORT_HOOK_TOKEN2] ?? holder.signal?.[ABORT_HOOK_TOKEN2];
|
|
106664
107392
|
if (!streamName) {
|
|
106665
107393
|
throw new Error("AbortController/AbortSignal stream name is not set");
|
|
106666
107394
|
}
|
|
106667
107395
|
return {
|
|
106668
107396
|
streamName,
|
|
106669
|
-
hookToken,
|
|
107397
|
+
hookToken: hookToken3,
|
|
106670
107398
|
aborted: signal.aborted,
|
|
106671
107399
|
reason: signal.aborted ? signal.reason : void 0
|
|
106672
107400
|
};
|
|
@@ -108532,7 +109260,7 @@ var version7;
|
|
|
108532
109260
|
var init_version5 = __esm({
|
|
108533
109261
|
"../core/dist/version.js"() {
|
|
108534
109262
|
"use strict";
|
|
108535
|
-
version7 = "5.7.
|
|
109263
|
+
version7 = "5.7.2";
|
|
108536
109264
|
}
|
|
108537
109265
|
});
|
|
108538
109266
|
|
|
@@ -108960,7 +109688,7 @@ async function loadWorkflowRunEvents(runId, afterCursor, options) {
|
|
|
108960
109688
|
appendUniqueEvents(loadedEvents, response.data, loadedEventIds);
|
|
108961
109689
|
if (eventLimit) {
|
|
108962
109690
|
for (let i3 = before; i3 < loadedEvents.length; i3++) {
|
|
108963
|
-
if (!
|
|
109691
|
+
if (!isSealedNoopEvent2(loadedEvents[i3]))
|
|
108964
109692
|
workflowEventCount++;
|
|
108965
109693
|
}
|
|
108966
109694
|
}
|
|
@@ -128176,7 +128904,7 @@ function createQuickJSSerde(vm, capturedRoot) {
|
|
|
128176
128904
|
const signal = ownSignal(value);
|
|
128177
128905
|
const holder = signal ?? value;
|
|
128178
128906
|
const streamName = ownSymbolString(value, "WORKFLOW_ABORT_STREAM_NAME") ?? ownSymbolString(holder, "WORKFLOW_ABORT_STREAM_NAME");
|
|
128179
|
-
const
|
|
128907
|
+
const hookToken3 = ownSymbolString(value, "WORKFLOW_ABORT_HOOK_TOKEN") ?? ownSymbolString(holder, "WORKFLOW_ABORT_HOOK_TOKEN");
|
|
128180
128908
|
if (!streamName) {
|
|
128181
128909
|
signal?.dispose();
|
|
128182
128910
|
throw new Error("AbortController/AbortSignal stream name is not set");
|
|
@@ -128187,7 +128915,7 @@ function createQuickJSSerde(vm, capturedRoot) {
|
|
|
128187
128915
|
signal.dispose();
|
|
128188
128916
|
return {
|
|
128189
128917
|
streamName,
|
|
128190
|
-
hookToken,
|
|
128918
|
+
hookToken: hookToken3,
|
|
128191
128919
|
aborted: aborted3,
|
|
128192
128920
|
reason: aborted3 ? reason : void 0
|
|
128193
128921
|
};
|
|
@@ -128755,12 +129483,12 @@ function createQuickJSSerde(vm, capturedRoot) {
|
|
|
128755
129483
|
}
|
|
128756
129484
|
try {
|
|
128757
129485
|
const streamName = own3(value, "streamName") ?? vm.undefined;
|
|
128758
|
-
const
|
|
128759
|
-
const signal = vm.construct(cls, streamName,
|
|
129486
|
+
const hookToken3 = own3(value, "hookToken") ?? vm.undefined;
|
|
129487
|
+
const signal = vm.construct(cls, streamName, hookToken3);
|
|
128760
129488
|
if (streamName !== vm.undefined)
|
|
128761
129489
|
streamName.dispose();
|
|
128762
|
-
if (
|
|
128763
|
-
|
|
129490
|
+
if (hookToken3 !== vm.undefined)
|
|
129491
|
+
hookToken3.dispose();
|
|
128764
129492
|
const aborted3 = own3(value, "aborted");
|
|
128765
129493
|
if (aborted3?.toBoolean()) {
|
|
128766
129494
|
const setAborted = chained(signal, "_setAborted");
|
|
@@ -128785,10 +129513,10 @@ function createQuickJSSerde(vm, capturedRoot) {
|
|
|
128785
129513
|
define2(controller, sym("WORKFLOW_ABORT_STREAM_NAME"), streamName);
|
|
128786
129514
|
if (streamName !== vm.undefined)
|
|
128787
129515
|
streamName.dispose();
|
|
128788
|
-
const
|
|
128789
|
-
define2(controller, sym("WORKFLOW_ABORT_HOOK_TOKEN"),
|
|
128790
|
-
if (
|
|
128791
|
-
|
|
129516
|
+
const hookToken3 = own3(value, "hookToken") ?? vm.undefined;
|
|
129517
|
+
define2(controller, sym("WORKFLOW_ABORT_HOOK_TOKEN"), hookToken3);
|
|
129518
|
+
if (hookToken3 !== vm.undefined)
|
|
129519
|
+
hookToken3.dispose();
|
|
128792
129520
|
const signal = reviveAbortSignal3(value);
|
|
128793
129521
|
define2(controller, "signal", signal);
|
|
128794
129522
|
signal.dispose();
|
|
@@ -130322,7 +131050,7 @@ async function processEvents(vm, serde, events, advanceClock, getLastUlid, inert
|
|
|
130322
131050
|
let resolved = false;
|
|
130323
131051
|
for (let index = 0; index < events.length; index++) {
|
|
130324
131052
|
const event = events[index];
|
|
130325
|
-
if (
|
|
131053
|
+
if (isSealedNoopEvent2(event))
|
|
130326
131054
|
continue;
|
|
130327
131055
|
advanceClock(+event.createdAt);
|
|
130328
131056
|
const cid = event.correlationId;
|
|
@@ -130754,7 +131482,7 @@ function beginTerminalInertBatch(vm, events, lastUlid) {
|
|
|
130754
131482
|
for (let index = 0; index < events.length; index++) {
|
|
130755
131483
|
const event = events[index];
|
|
130756
131484
|
const cid = event.correlationId;
|
|
130757
|
-
if (!cid ||
|
|
131485
|
+
if (!cid || isSealedNoopEvent2(event))
|
|
130758
131486
|
continue;
|
|
130759
131487
|
cids.add(cid);
|
|
130760
131488
|
if (firstTerminalIndex.has(cid))
|
|
@@ -135319,13 +136047,14 @@ function foldReadEvents(events, speculativeAt) {
|
|
|
135319
136047
|
let displaced = false;
|
|
135320
136048
|
for (const event of events) {
|
|
135321
136049
|
const speculative = speculativeAt(event.eventId);
|
|
135322
|
-
if (speculative
|
|
136050
|
+
if (speculative !== void 0) {
|
|
136051
|
+
if (!isSameWrite(speculative, event))
|
|
136052
|
+
displaced = true;
|
|
136053
|
+
} else if (!displaced) {
|
|
135323
136054
|
fold.push(event);
|
|
135324
|
-
} else if (!isSameWrite(speculative, event)) {
|
|
135325
|
-
displaced = true;
|
|
135326
136055
|
}
|
|
135327
136056
|
}
|
|
135328
|
-
return { fold, displaced };
|
|
136057
|
+
return { fold, displaced, complete: fold.length === events.length };
|
|
135329
136058
|
}
|
|
135330
136059
|
function settledOutcomeFold(input3) {
|
|
135331
136060
|
if (!input3.writtenAhead)
|
|
@@ -137222,7 +137951,7 @@ async function runQuickJSDelivery(params, afterTerminal) {
|
|
|
137222
137951
|
return written;
|
|
137223
137952
|
} : void 0;
|
|
137224
137953
|
let restoredEventCount = existingSnapshot?.metadata.eventCount ?? 0;
|
|
137225
|
-
const workflowEventCount = events.filter((event) => !
|
|
137954
|
+
const workflowEventCount = events.filter((event) => !isSealedNoopEvent2(event)).length;
|
|
137226
137955
|
if (maxEventsLimit !== void 0 && restoredEventCount + workflowEventCount >= maxEventsLimit) {
|
|
137227
137956
|
throw new MaxEventsExceededError(restoredEventCount + workflowEventCount, maxEventsLimit);
|
|
137228
137957
|
}
|
|
@@ -137375,7 +138104,7 @@ async function runQuickJSDelivery(params, afterTerminal) {
|
|
|
137375
138104
|
if (!event.eventId)
|
|
137376
138105
|
return;
|
|
137377
138106
|
seenEventIds.add(event.eventId);
|
|
137378
|
-
if (
|
|
138107
|
+
if (isSealedNoopEvent2(event))
|
|
137379
138108
|
seenNoopIds.add(event.eventId);
|
|
137380
138109
|
}, "noteSeenEvent");
|
|
137381
138110
|
for (const e of events) {
|
|
@@ -139031,7 +139760,7 @@ async function runSpec9Delivery(delivery) {
|
|
|
139031
139760
|
return continuation.handoff && result2 === void 0 ? { timeoutSeconds: 0 } : result2;
|
|
139032
139761
|
}
|
|
139033
139762
|
function countWorkflowEvents(events) {
|
|
139034
|
-
return events.reduce((n, e) =>
|
|
139763
|
+
return events.reduce((n, e) => isSealedNoopEvent2(e) ? n : n + 1, 0);
|
|
139035
139764
|
}
|
|
139036
139765
|
async function runDelivery2(delivery, continuation) {
|
|
139037
139766
|
const { workflowCode: workflowCode2, namespace, metadata, world, span, runLogger, workflowName, requestId, nextTraceCarrier, replayBudget, prefetchedRun, runSpecVersion } = delivery;
|
|
@@ -139256,13 +139985,13 @@ async function runDelivery2(delivery, continuation) {
|
|
|
139256
139985
|
}, "noteDisplacedSpeculation");
|
|
139257
139986
|
const foldReadIntoLog = /* @__PURE__ */ __name((events, cause) => {
|
|
139258
139987
|
assert9(log, "The event log is loaded to fold read events");
|
|
139259
|
-
const { fold, displaced } = foldReadEvents(events, speculativeEventAt);
|
|
139988
|
+
const { fold, displaced, complete } = foldReadEvents(events, speculativeEventAt);
|
|
139260
139989
|
if (displaced)
|
|
139261
139990
|
noteDisplacedSpeculation(cause);
|
|
139262
139991
|
for (const event of fold)
|
|
139263
139992
|
prepareReplayEvent(event);
|
|
139264
139993
|
indexOf(log.events).merge(fold);
|
|
139265
|
-
return
|
|
139994
|
+
return complete;
|
|
139266
139995
|
}, "foldReadIntoLog");
|
|
139267
139996
|
let logBehind = false;
|
|
139268
139997
|
const ownSlots = /* @__PURE__ */ new Set();
|
|
@@ -139957,7 +140686,7 @@ async function runDelivery2(delivery, continuation) {
|
|
|
139957
140686
|
}
|
|
139958
140687
|
assert9(run3, "Workflow run must be loaded before replay");
|
|
139959
140688
|
assert9(log, "The event log is loaded before replay");
|
|
139960
|
-
invocationStartedClean = log.events.every((e) => e.eventType === "run_created" || e.eventType === "run_started" || e.eventType === "attr_set" ||
|
|
140689
|
+
invocationStartedClean = log.events.every((e) => e.eventType === "run_created" || e.eventType === "run_started" || e.eventType === "attr_set" || isSealedNoopEvent2(e));
|
|
139961
140690
|
const runCreated = log.events.find(isRunCreationEvent2);
|
|
139962
140691
|
const createdInput = runCreated && "eventData" in runCreated ? runCreated.eventData?.input : void 0;
|
|
139963
140692
|
let runInputValue;
|
|
@@ -167009,6 +167738,10 @@ function getOwnProperty(object22, key) {
|
|
|
167009
167738
|
return Object.hasOwn(object22, key) ? object22[key] : void 0;
|
|
167010
167739
|
}
|
|
167011
167740
|
__name(getOwnProperty, "getOwnProperty");
|
|
167741
|
+
function isSealedNoopEvent(event) {
|
|
167742
|
+
return event.eventType === "noop";
|
|
167743
|
+
}
|
|
167744
|
+
__name(isSealedNoopEvent, "isSealedNoopEvent");
|
|
167012
167745
|
function getEventDataRefFields(eventType) {
|
|
167013
167746
|
return getOwnProperty(EVENT_DATA_REF_FIELDS_BY_EVENT_TYPE, eventType) ?? NO_EVENT_DATA_REF_FIELDS;
|
|
167014
167747
|
}
|
|
@@ -167023,6 +167756,7 @@ var init_event_metadata = __esm2({
|
|
|
167023
167756
|
"../world/dist/event-metadata.js"() {
|
|
167024
167757
|
"use strict";
|
|
167025
167758
|
__name2(getOwnProperty, "getOwnProperty");
|
|
167759
|
+
__name2(isSealedNoopEvent, "isSealedNoopEvent");
|
|
167026
167760
|
EVENT_DATA_REF_FIELDS_BY_EVENT_TYPE = {
|
|
167027
167761
|
run_created: [
|
|
167028
167762
|
"input"
|
|
@@ -169590,6 +170324,266 @@ var init_ulid = __esm2({
|
|
|
169590
170324
|
__name2(validateUlidTimestamp, "validateUlidTimestamp");
|
|
169591
170325
|
}
|
|
169592
170326
|
});
|
|
170327
|
+
function spanOf(eventType, workflowName) {
|
|
170328
|
+
if (eventType.startsWith("hook_")) return {
|
|
170329
|
+
kind: "hook",
|
|
170330
|
+
name: "hook"
|
|
170331
|
+
};
|
|
170332
|
+
if (eventType.startsWith("wait_")) return {
|
|
170333
|
+
kind: "wait",
|
|
170334
|
+
name: "sleep"
|
|
170335
|
+
};
|
|
170336
|
+
if (eventType.startsWith("run_")) return {
|
|
170337
|
+
kind: "run",
|
|
170338
|
+
name: workflowName
|
|
170339
|
+
};
|
|
170340
|
+
if (eventType === "attr_set") {
|
|
170341
|
+
return {
|
|
170342
|
+
kind: "attributes",
|
|
170343
|
+
name: "attributes"
|
|
170344
|
+
};
|
|
170345
|
+
}
|
|
170346
|
+
return {
|
|
170347
|
+
kind: "other",
|
|
170348
|
+
name: "other"
|
|
170349
|
+
};
|
|
170350
|
+
}
|
|
170351
|
+
__name(spanOf, "spanOf");
|
|
170352
|
+
function compareCodeUnits(a, b) {
|
|
170353
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
170354
|
+
}
|
|
170355
|
+
__name(compareCodeUnits, "compareCodeUnits");
|
|
170356
|
+
function toCount(value) {
|
|
170357
|
+
const n = Number(value);
|
|
170358
|
+
return Number.isFinite(n) && n > 0 ? n : 0;
|
|
170359
|
+
}
|
|
170360
|
+
__name(toCount, "toCount");
|
|
170361
|
+
function usageEntityOfEventType(eventType) {
|
|
170362
|
+
if (isSealedNoopEvent({
|
|
170363
|
+
eventType
|
|
170364
|
+
})) return null;
|
|
170365
|
+
if (eventType.startsWith("step_")) return "step";
|
|
170366
|
+
if (eventType.startsWith("hook_")) return "hook";
|
|
170367
|
+
return "run";
|
|
170368
|
+
}
|
|
170369
|
+
__name(usageEntityOfEventType, "usageEntityOfEventType");
|
|
170370
|
+
function buildRunUsage(input22) {
|
|
170371
|
+
const spans = /* @__PURE__ */ new Map();
|
|
170372
|
+
const byEntity = {
|
|
170373
|
+
run: 0,
|
|
170374
|
+
step: 0,
|
|
170375
|
+
hook: 0,
|
|
170376
|
+
stream: toCount(input22.streamBytes)
|
|
170377
|
+
};
|
|
170378
|
+
let events = 0;
|
|
170379
|
+
let retries = 0;
|
|
170380
|
+
const add3 = /* @__PURE__ */ __name2((kind, name, entity, count2, retryCount, bytes) => {
|
|
170381
|
+
if (count2 <= 0) return;
|
|
170382
|
+
const key = `${kind}\0${name}`;
|
|
170383
|
+
let span = spans.get(key);
|
|
170384
|
+
if (!span) {
|
|
170385
|
+
span = {
|
|
170386
|
+
kind,
|
|
170387
|
+
name,
|
|
170388
|
+
events: 0,
|
|
170389
|
+
share: 0,
|
|
170390
|
+
retries: 0,
|
|
170391
|
+
calls: 0
|
|
170392
|
+
};
|
|
170393
|
+
spans.set(key, span);
|
|
170394
|
+
}
|
|
170395
|
+
span.events += count2;
|
|
170396
|
+
span.retries += retryCount;
|
|
170397
|
+
events += count2;
|
|
170398
|
+
retries += retryCount;
|
|
170399
|
+
byEntity[entity] += bytes;
|
|
170400
|
+
}, "add");
|
|
170401
|
+
const created = {
|
|
170402
|
+
hook: 0,
|
|
170403
|
+
wait: 0
|
|
170404
|
+
};
|
|
170405
|
+
const hookGroups = input22.hookGroups;
|
|
170406
|
+
let hookEvents = 0;
|
|
170407
|
+
const runEvents = {
|
|
170408
|
+
events: 0,
|
|
170409
|
+
byType: {
|
|
170410
|
+
created: 0,
|
|
170411
|
+
started: 0,
|
|
170412
|
+
completed: 0,
|
|
170413
|
+
failed: 0,
|
|
170414
|
+
cancelled: 0
|
|
170415
|
+
}
|
|
170416
|
+
};
|
|
170417
|
+
for (const group of input22.eventGroups) {
|
|
170418
|
+
const entity = usageEntityOfEventType(group.eventType);
|
|
170419
|
+
if (!entity) continue;
|
|
170420
|
+
const runType = group.eventType.slice("run_".length);
|
|
170421
|
+
if (group.eventType.startsWith("run_") && RUN_USAGE_RUN_EVENT_TYPES.includes(runType)) {
|
|
170422
|
+
runEvents.byType[runType] += toCount(group.events);
|
|
170423
|
+
}
|
|
170424
|
+
if (group.eventType.startsWith("run_")) {
|
|
170425
|
+
runEvents.events += toCount(group.events);
|
|
170426
|
+
}
|
|
170427
|
+
if (group.eventType === "hook_created") created.hook += toCount(group.events);
|
|
170428
|
+
if (group.eventType === "wait_created") created.wait += toCount(group.events);
|
|
170429
|
+
const { kind, name } = spanOf(group.eventType, input22.workflowName);
|
|
170430
|
+
if (kind === "hook" && hookGroups) {
|
|
170431
|
+
hookEvents += toCount(group.events);
|
|
170432
|
+
events += toCount(group.events);
|
|
170433
|
+
byEntity[entity] += toCount(group.bytes);
|
|
170434
|
+
continue;
|
|
170435
|
+
}
|
|
170436
|
+
add3(kind, name, entity, toCount(group.events), 0, toCount(group.bytes));
|
|
170437
|
+
}
|
|
170438
|
+
if (hookGroups) {
|
|
170439
|
+
let grouped = 0;
|
|
170440
|
+
for (const group of hookGroups) {
|
|
170441
|
+
const count2 = toCount(group.events);
|
|
170442
|
+
if (count2 <= 0 || !group.hookId) continue;
|
|
170443
|
+
grouped += count2;
|
|
170444
|
+
spans.set(`hook\0${group.hookId}`, {
|
|
170445
|
+
kind: "hook",
|
|
170446
|
+
name: group.token || group.hookId,
|
|
170447
|
+
id: group.hookId,
|
|
170448
|
+
events: count2,
|
|
170449
|
+
share: 0,
|
|
170450
|
+
retries: 0,
|
|
170451
|
+
calls: 1
|
|
170452
|
+
});
|
|
170453
|
+
}
|
|
170454
|
+
if (hookEvents > grouped) {
|
|
170455
|
+
spans.set("hook\0", {
|
|
170456
|
+
kind: "hook",
|
|
170457
|
+
name: "hook",
|
|
170458
|
+
events: hookEvents - grouped,
|
|
170459
|
+
share: 0,
|
|
170460
|
+
retries: 0,
|
|
170461
|
+
calls: 0
|
|
170462
|
+
});
|
|
170463
|
+
}
|
|
170464
|
+
}
|
|
170465
|
+
const calls = {
|
|
170466
|
+
hook: toCount(created.hook),
|
|
170467
|
+
wait: toCount(input22.calls?.wait ?? created.wait)
|
|
170468
|
+
};
|
|
170469
|
+
const stepEvents = {
|
|
170470
|
+
steps: 0,
|
|
170471
|
+
events: 0,
|
|
170472
|
+
byType: {
|
|
170473
|
+
created: 0,
|
|
170474
|
+
started: 0,
|
|
170475
|
+
completed: 0,
|
|
170476
|
+
failed: 0,
|
|
170477
|
+
retrying: 0,
|
|
170478
|
+
other: 0
|
|
170479
|
+
}
|
|
170480
|
+
};
|
|
170481
|
+
let restarts = 0;
|
|
170482
|
+
for (const group of input22.stepGroups) {
|
|
170483
|
+
restarts += toCount(group.restarts);
|
|
170484
|
+
const counts = {
|
|
170485
|
+
created: toCount(group.created),
|
|
170486
|
+
started: toCount(group.started),
|
|
170487
|
+
completed: toCount(group.completed),
|
|
170488
|
+
failed: toCount(group.failed),
|
|
170489
|
+
retrying: toCount(group.retries)
|
|
170490
|
+
};
|
|
170491
|
+
const total = toCount(group.events);
|
|
170492
|
+
if (total <= 0) continue;
|
|
170493
|
+
stepEvents.steps += toCount(group.steps);
|
|
170494
|
+
stepEvents.events += total;
|
|
170495
|
+
let known = 0;
|
|
170496
|
+
for (const type of RUN_USAGE_STEP_EVENT_TYPES) {
|
|
170497
|
+
stepEvents.byType[type] += counts[type];
|
|
170498
|
+
known += counts[type];
|
|
170499
|
+
}
|
|
170500
|
+
stepEvents.byType.other += Math.max(0, total - known);
|
|
170501
|
+
const name = group.stepName || UNKNOWN_STEP_NAME;
|
|
170502
|
+
add3("step", name, "step", toCount(group.events), toCount(group.retries), toCount(group.bytes));
|
|
170503
|
+
const span = spans.get(`step\0${name}`);
|
|
170504
|
+
if (span) span.calls += toCount(group.steps);
|
|
170505
|
+
}
|
|
170506
|
+
for (const span of spans.values()) {
|
|
170507
|
+
if (span.kind === "run") span.calls = 1;
|
|
170508
|
+
if (span.kind === "hook" && !hookGroups) span.calls = calls.hook;
|
|
170509
|
+
if (span.kind === "wait") span.calls = calls.wait;
|
|
170510
|
+
if (span.kind === "attributes" || span.kind === "other") {
|
|
170511
|
+
span.calls = span.events;
|
|
170512
|
+
}
|
|
170513
|
+
}
|
|
170514
|
+
const eventsBySpan = [
|
|
170515
|
+
...spans.values()
|
|
170516
|
+
].map((span) => ({
|
|
170517
|
+
...span,
|
|
170518
|
+
share: events > 0 ? span.events / events : 0
|
|
170519
|
+
})).sort((a, b) => b.events - a.events || compareCodeUnits(a.name, b.name) || compareCodeUnits(a.kind, b.kind) || compareCodeUnits(a.id ?? "", b.id ?? ""));
|
|
170520
|
+
return {
|
|
170521
|
+
runId: input22.runId,
|
|
170522
|
+
status: input22.status,
|
|
170523
|
+
workflowName: input22.workflowName,
|
|
170524
|
+
billed: input22.billed === true,
|
|
170525
|
+
inProgress: !isTerminalWorkflowRunStatus(input22.status),
|
|
170526
|
+
events,
|
|
170527
|
+
billableEvents: events,
|
|
170528
|
+
retries: {
|
|
170529
|
+
count: retries,
|
|
170530
|
+
events: retries + restarts
|
|
170531
|
+
},
|
|
170532
|
+
runEvents,
|
|
170533
|
+
stepEvents,
|
|
170534
|
+
eventsBySpan,
|
|
170535
|
+
dataWritten: dataWrittenOf(input22, byEntity),
|
|
170536
|
+
dataPurged: input22.dataPurged === true,
|
|
170537
|
+
dataRetained: input22.dataRetained ?? null
|
|
170538
|
+
};
|
|
170539
|
+
}
|
|
170540
|
+
__name(buildRunUsage, "buildRunUsage");
|
|
170541
|
+
function dataWrittenOf(input22, measured) {
|
|
170542
|
+
const saved = input22.dataPurged ? input22.savedDataWritten : void 0;
|
|
170543
|
+
const byEntity = saved ? {
|
|
170544
|
+
run: toCount(saved.run),
|
|
170545
|
+
step: toCount(saved.step),
|
|
170546
|
+
hook: toCount(saved.hook),
|
|
170547
|
+
stream: toCount(saved.stream)
|
|
170548
|
+
} : measured;
|
|
170549
|
+
return {
|
|
170550
|
+
bytes: byEntity.run + byEntity.step + byEntity.hook + byEntity.stream,
|
|
170551
|
+
byEntity,
|
|
170552
|
+
source: !input22.dataPurged ? "log" : saved ? "saved-at-purge" : "left-after-purge"
|
|
170553
|
+
};
|
|
170554
|
+
}
|
|
170555
|
+
__name(dataWrittenOf, "dataWrittenOf");
|
|
170556
|
+
var RUN_USAGE_RUN_EVENT_TYPES;
|
|
170557
|
+
var RUN_USAGE_STEP_EVENT_TYPES;
|
|
170558
|
+
var UNKNOWN_STEP_NAME;
|
|
170559
|
+
var init_usage = __esm2({
|
|
170560
|
+
"../world/dist/usage.js"() {
|
|
170561
|
+
"use strict";
|
|
170562
|
+
init_event_metadata();
|
|
170563
|
+
init_runs();
|
|
170564
|
+
RUN_USAGE_RUN_EVENT_TYPES = [
|
|
170565
|
+
"created",
|
|
170566
|
+
"started",
|
|
170567
|
+
"completed",
|
|
170568
|
+
"failed",
|
|
170569
|
+
"cancelled"
|
|
170570
|
+
];
|
|
170571
|
+
RUN_USAGE_STEP_EVENT_TYPES = [
|
|
170572
|
+
"created",
|
|
170573
|
+
"started",
|
|
170574
|
+
"completed",
|
|
170575
|
+
"failed",
|
|
170576
|
+
"retrying"
|
|
170577
|
+
];
|
|
170578
|
+
UNKNOWN_STEP_NAME = "(unknown step)";
|
|
170579
|
+
__name2(spanOf, "spanOf");
|
|
170580
|
+
__name2(compareCodeUnits, "compareCodeUnits");
|
|
170581
|
+
__name2(toCount, "toCount");
|
|
170582
|
+
__name2(usageEntityOfEventType, "usageEntityOfEventType");
|
|
170583
|
+
__name2(buildRunUsage, "buildRunUsage");
|
|
170584
|
+
__name2(dataWrittenOf, "dataWrittenOf");
|
|
170585
|
+
}
|
|
170586
|
+
});
|
|
169593
170587
|
var init_dist4 = __esm2({
|
|
169594
170588
|
"../world/dist/index.js"() {
|
|
169595
170589
|
"use strict";
|
|
@@ -169611,6 +170605,7 @@ var init_dist4 = __esm2({
|
|
|
169611
170605
|
init_start_hook();
|
|
169612
170606
|
init_steps();
|
|
169613
170607
|
init_ulid();
|
|
170608
|
+
init_usage();
|
|
169614
170609
|
init_waits();
|
|
169615
170610
|
}
|
|
169616
170611
|
});
|
|
@@ -177924,9 +178919,9 @@ var init_abort_controller = __esm2({
|
|
|
177924
178919
|
handler.call(this);
|
|
177925
178920
|
}
|
|
177926
178921
|
}
|
|
177927
|
-
constructor(streamName,
|
|
178922
|
+
constructor(streamName, hookToken22) {
|
|
177928
178923
|
this[ABORT_STREAM_NAME] = streamName;
|
|
177929
|
-
this[ABORT_HOOK_TOKEN] =
|
|
178924
|
+
this[ABORT_HOOK_TOKEN] = hookToken22;
|
|
177930
178925
|
}
|
|
177931
178926
|
/**
|
|
177932
178927
|
* @internal Sets aborted state and fires listeners.
|
|
@@ -180260,7 +181255,7 @@ var version2;
|
|
|
180260
181255
|
var init_version = __esm2({
|
|
180261
181256
|
"../core/dist/version.js"() {
|
|
180262
181257
|
"use strict";
|
|
180263
|
-
version2 = "5.7.
|
|
181258
|
+
version2 = "5.7.2";
|
|
180264
181259
|
}
|
|
180265
181260
|
});
|
|
180266
181261
|
function safetyCheckDelayMs(index) {
|
|
@@ -211773,6 +212768,154 @@ var init_recovery_wake = __esm2({
|
|
|
211773
212768
|
__name2(backstopWakeDelaySeconds, "backstopWakeDelaySeconds");
|
|
211774
212769
|
}
|
|
211775
212770
|
});
|
|
212771
|
+
function valueBytesSql(path82) {
|
|
212772
|
+
const data22 = `CAST(json_extract(doc, '${path82}.data') AS BLOB)`;
|
|
212773
|
+
return `CASE WHEN json_extract(doc, '${path82}.__type') = 'Uint8Array'
|
|
212774
|
+
THEN length(${data22}) / 4 * 3 - (CASE WHEN substr(${data22}, -2) = X'3D3D' THEN 2 WHEN substr(${data22}, -1) = X'3D' THEN 1 ELSE 0 END)
|
|
212775
|
+
ELSE coalesce(length(CAST(doc -> '${path82}' AS BLOB)), 0) END`;
|
|
212776
|
+
}
|
|
212777
|
+
__name(valueBytesSql, "valueBytesSql");
|
|
212778
|
+
function measureStreamBytes(db, runId) {
|
|
212779
|
+
return Number(db.get(STREAM_BYTES_SQL, runId)?.bytes ?? 0);
|
|
212780
|
+
}
|
|
212781
|
+
__name(measureStreamBytes, "measureStreamBytes");
|
|
212782
|
+
function tableExists(db) {
|
|
212783
|
+
return db.get("SELECT 1 AS one FROM sqlite_master WHERE type = 'table' AND name = ?", TABLE) !== void 0;
|
|
212784
|
+
}
|
|
212785
|
+
__name(tableExists, "tableExists");
|
|
212786
|
+
function savePurgedUsage(db, runId, usage) {
|
|
212787
|
+
db.run(CREATE_TABLE_SQL);
|
|
212788
|
+
db.run(`INSERT INTO ${TABLE}
|
|
212789
|
+
(run_id, seq, run_bytes, step_bytes, hook_bytes, stream_bytes)
|
|
212790
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
212791
|
+
ON CONFLICT (run_id) DO UPDATE SET
|
|
212792
|
+
seq = excluded.seq,
|
|
212793
|
+
run_bytes = excluded.run_bytes,
|
|
212794
|
+
step_bytes = excluded.step_bytes,
|
|
212795
|
+
hook_bytes = excluded.hook_bytes,
|
|
212796
|
+
stream_bytes = excluded.stream_bytes`, runId, usage.seq, usage.byEntity.run, usage.byEntity.step, usage.byEntity.hook, usage.byEntity.stream);
|
|
212797
|
+
}
|
|
212798
|
+
__name(savePurgedUsage, "savePurgedUsage");
|
|
212799
|
+
function readPurgedUsage(db, runId) {
|
|
212800
|
+
if (!tableExists(db)) return null;
|
|
212801
|
+
const row = db.get(`SELECT seq, run_bytes, step_bytes, hook_bytes, stream_bytes
|
|
212802
|
+
FROM ${TABLE} WHERE run_id = ?`, runId);
|
|
212803
|
+
if (!row) return null;
|
|
212804
|
+
return {
|
|
212805
|
+
seq: Number(row.seq),
|
|
212806
|
+
byEntity: {
|
|
212807
|
+
run: Number(row.run_bytes),
|
|
212808
|
+
step: Number(row.step_bytes),
|
|
212809
|
+
hook: Number(row.hook_bytes),
|
|
212810
|
+
stream: Number(row.stream_bytes)
|
|
212811
|
+
}
|
|
212812
|
+
};
|
|
212813
|
+
}
|
|
212814
|
+
__name(readPurgedUsage, "readPurgedUsage");
|
|
212815
|
+
function deletePurgedUsage(db, where) {
|
|
212816
|
+
if (!tableExists(db)) return;
|
|
212817
|
+
if (!where) {
|
|
212818
|
+
db.run(`DELETE FROM ${TABLE}`);
|
|
212819
|
+
return;
|
|
212820
|
+
}
|
|
212821
|
+
db.run(`DELETE FROM ${TABLE} WHERE run_id IN (${where.runIdsSql})`, ...where.params);
|
|
212822
|
+
}
|
|
212823
|
+
__name(deletePurgedUsage, "deletePurgedUsage");
|
|
212824
|
+
var PAYLOAD_PATHS;
|
|
212825
|
+
var PAYLOAD_EVENT_TYPES;
|
|
212826
|
+
var PAYLOAD_BYTES_SQL;
|
|
212827
|
+
var STREAM_BYTES_SQL;
|
|
212828
|
+
var TABLE;
|
|
212829
|
+
var CREATE_TABLE_SQL;
|
|
212830
|
+
var EntityBytes;
|
|
212831
|
+
var init_purged_usage = __esm2({
|
|
212832
|
+
"../world-local/dist/storage/purged-usage.js"() {
|
|
212833
|
+
"use strict";
|
|
212834
|
+
init_dist4();
|
|
212835
|
+
PAYLOAD_PATHS = {
|
|
212836
|
+
// A dynamic run's code is kept on the run, not on its events, so it is
|
|
212837
|
+
// not here.
|
|
212838
|
+
run_created: [
|
|
212839
|
+
"$.eventData.input",
|
|
212840
|
+
"$.eventData.startHook.metadata"
|
|
212841
|
+
],
|
|
212842
|
+
run_started: [
|
|
212843
|
+
"$.eventData.input",
|
|
212844
|
+
"$.eventData.startHook.metadata"
|
|
212845
|
+
],
|
|
212846
|
+
run_completed: [
|
|
212847
|
+
"$.eventData.output"
|
|
212848
|
+
],
|
|
212849
|
+
run_failed: [
|
|
212850
|
+
"$.eventData.error"
|
|
212851
|
+
],
|
|
212852
|
+
step_created: [
|
|
212853
|
+
"$.eventData.input"
|
|
212854
|
+
],
|
|
212855
|
+
step_started: [
|
|
212856
|
+
"$.eventData.input"
|
|
212857
|
+
],
|
|
212858
|
+
step_completed: [
|
|
212859
|
+
"$.eventData.result"
|
|
212860
|
+
],
|
|
212861
|
+
step_failed: [
|
|
212862
|
+
"$.eventData.error"
|
|
212863
|
+
],
|
|
212864
|
+
step_retrying: [
|
|
212865
|
+
"$.eventData.error"
|
|
212866
|
+
],
|
|
212867
|
+
hook_created: [
|
|
212868
|
+
"$.eventData.metadata"
|
|
212869
|
+
],
|
|
212870
|
+
hook_received: [
|
|
212871
|
+
"$.eventData.payload"
|
|
212872
|
+
]
|
|
212873
|
+
};
|
|
212874
|
+
PAYLOAD_EVENT_TYPES = Object.keys(PAYLOAD_PATHS);
|
|
212875
|
+
__name2(valueBytesSql, "valueBytesSql");
|
|
212876
|
+
PAYLOAD_BYTES_SQL = `(CASE event_type ${Object.entries(PAYLOAD_PATHS).map(([eventType, paths]) => `WHEN '${eventType}' THEN ${paths.map((path82) => `(${valueBytesSql(path82)})`).join(" + ")}`).join(" ")} ELSE 0 END)`;
|
|
212877
|
+
STREAM_BYTES_SQL = `
|
|
212878
|
+
SELECT COALESCE(SUM(length(data)), 0) AS bytes
|
|
212879
|
+
FROM stream_chunks
|
|
212880
|
+
WHERE run_id = ?
|
|
212881
|
+
`;
|
|
212882
|
+
__name2(measureStreamBytes, "measureStreamBytes");
|
|
212883
|
+
TABLE = "run_usage_purged";
|
|
212884
|
+
CREATE_TABLE_SQL = `
|
|
212885
|
+
CREATE TABLE IF NOT EXISTS ${TABLE} (
|
|
212886
|
+
run_id TEXT PRIMARY KEY,
|
|
212887
|
+
-- The last log position the sizes below cover.
|
|
212888
|
+
seq INTEGER NOT NULL,
|
|
212889
|
+
run_bytes INTEGER NOT NULL,
|
|
212890
|
+
step_bytes INTEGER NOT NULL,
|
|
212891
|
+
hook_bytes INTEGER NOT NULL,
|
|
212892
|
+
stream_bytes INTEGER NOT NULL
|
|
212893
|
+
)
|
|
212894
|
+
`;
|
|
212895
|
+
EntityBytes = class {
|
|
212896
|
+
static {
|
|
212897
|
+
__name(this, "EntityBytes");
|
|
212898
|
+
}
|
|
212899
|
+
static {
|
|
212900
|
+
__name2(this, "EntityBytes");
|
|
212901
|
+
}
|
|
212902
|
+
byEntity = {
|
|
212903
|
+
run: 0,
|
|
212904
|
+
step: 0,
|
|
212905
|
+
hook: 0,
|
|
212906
|
+
stream: 0
|
|
212907
|
+
};
|
|
212908
|
+
add(eventType, bytes) {
|
|
212909
|
+
const entity = usageEntityOfEventType(eventType);
|
|
212910
|
+
if (entity) this.byEntity[entity] += Number(bytes) || 0;
|
|
212911
|
+
}
|
|
212912
|
+
};
|
|
212913
|
+
__name2(tableExists, "tableExists");
|
|
212914
|
+
__name2(savePurgedUsage, "savePurgedUsage");
|
|
212915
|
+
__name2(readPurgedUsage, "readPurgedUsage");
|
|
212916
|
+
__name2(deletePurgedUsage, "deletePurgedUsage");
|
|
212917
|
+
}
|
|
212918
|
+
});
|
|
211776
212919
|
function truncateForError(value) {
|
|
211777
212920
|
const s = typeof value === "string" ? value : String(value);
|
|
211778
212921
|
const MAX = 48;
|
|
@@ -211825,11 +212968,33 @@ function ranPurge(run22) {
|
|
|
211825
212968
|
return run22.expiredAt !== void 0 && new Date(run22.expiredAt).getTime() <= Date.now();
|
|
211826
212969
|
}
|
|
211827
212970
|
__name(ranPurge, "ranPurge");
|
|
211828
|
-
function purgeRunData(db, runId) {
|
|
212971
|
+
function purgeRunData(db, runId, { purgedBefore = false } = {}) {
|
|
211829
212972
|
for (const row of db.all("SELECT step_id, doc FROM steps WHERE run_id = ?", runId)) {
|
|
211830
212973
|
writeScrubbedStep(db, runId, row.step_id, row.doc);
|
|
211831
212974
|
}
|
|
211832
|
-
|
|
212975
|
+
const saved = readPurgedUsage(db, runId);
|
|
212976
|
+
const written = new EntityBytes();
|
|
212977
|
+
let lastSeq = 0;
|
|
212978
|
+
const events = db.all(`SELECT seq, event_type, doc, ${PAYLOAD_BYTES_SQL} AS bytes
|
|
212979
|
+
FROM events WHERE run_id = ?`, runId);
|
|
212980
|
+
for (const row of events) {
|
|
212981
|
+
lastSeq = Math.max(lastSeq, Number(row.seq));
|
|
212982
|
+
if (saved && Number(row.seq) <= saved.seq) continue;
|
|
212983
|
+
written.add(row.event_type, row.bytes);
|
|
212984
|
+
}
|
|
212985
|
+
written.byEntity.stream = measureStreamBytes(db, runId);
|
|
212986
|
+
if (saved) {
|
|
212987
|
+
savePurgedUsage(db, runId, {
|
|
212988
|
+
seq: lastSeq,
|
|
212989
|
+
byEntity: addBytes(saved.byEntity, written.byEntity)
|
|
212990
|
+
});
|
|
212991
|
+
} else if (!purgedBefore) {
|
|
212992
|
+
savePurgedUsage(db, runId, {
|
|
212993
|
+
seq: lastSeq,
|
|
212994
|
+
byEntity: written.byEntity
|
|
212995
|
+
});
|
|
212996
|
+
}
|
|
212997
|
+
for (const row of events) {
|
|
211833
212998
|
writeScrubbedEvent(db, runId, row.seq, row.doc);
|
|
211834
212999
|
}
|
|
211835
213000
|
for (const row of db.all("SELECT hook_id, doc FROM hooks WHERE run_id = ?", runId)) {
|
|
@@ -211850,9 +213015,31 @@ function purgeLateStepWrite(db, runId, stepId, seq) {
|
|
|
211850
213015
|
db.run("UPDATE steps SET doc = ? WHERE run_id = ? AND step_id = ?", encode3(step), runId, stepId);
|
|
211851
213016
|
}
|
|
211852
213017
|
const event = db.get("SELECT doc FROM events WHERE run_id = ? AND seq = ?", runId, seq);
|
|
211853
|
-
if (event)
|
|
213018
|
+
if (!event) return;
|
|
213019
|
+
const saved = readPurgedUsage(db, runId);
|
|
213020
|
+
if (saved && seq > saved.seq) {
|
|
213021
|
+
const written = new EntityBytes();
|
|
213022
|
+
for (const row of db.all(`SELECT event_type, ${PAYLOAD_BYTES_SQL} AS bytes
|
|
213023
|
+
FROM events WHERE run_id = ? AND seq > ? AND seq <= ?`, runId, saved.seq, seq)) {
|
|
213024
|
+
written.add(row.event_type, row.bytes);
|
|
213025
|
+
}
|
|
213026
|
+
savePurgedUsage(db, runId, {
|
|
213027
|
+
seq,
|
|
213028
|
+
byEntity: addBytes(saved.byEntity, written.byEntity)
|
|
213029
|
+
});
|
|
213030
|
+
}
|
|
213031
|
+
writeScrubbedEvent(db, runId, seq, event.doc);
|
|
211854
213032
|
}
|
|
211855
213033
|
__name(purgeLateStepWrite, "purgeLateStepWrite");
|
|
213034
|
+
function addBytes(a, b) {
|
|
213035
|
+
return {
|
|
213036
|
+
run: a.run + b.run,
|
|
213037
|
+
step: a.step + b.step,
|
|
213038
|
+
hook: a.hook + b.hook,
|
|
213039
|
+
stream: a.stream + b.stream
|
|
213040
|
+
};
|
|
213041
|
+
}
|
|
213042
|
+
__name(addBytes, "addBytes");
|
|
211856
213043
|
function writeScrubbedStep(db, runId, stepId, doc) {
|
|
211857
213044
|
const step = decode3(doc);
|
|
211858
213045
|
step.input = void 0;
|
|
@@ -211890,10 +213077,12 @@ var init_run_retention = __esm2({
|
|
|
211890
213077
|
"use strict";
|
|
211891
213078
|
init_dist4();
|
|
211892
213079
|
init_codec();
|
|
213080
|
+
init_purged_usage();
|
|
211893
213081
|
__name2(purgesUserDataOnFinish2, "purgesUserDataOnFinish");
|
|
211894
213082
|
__name2(ranPurge, "ranPurge");
|
|
211895
213083
|
__name2(purgeRunData, "purgeRunData");
|
|
211896
213084
|
__name2(purgeLateStepWrite, "purgeLateStepWrite");
|
|
213085
|
+
__name2(addBytes, "addBytes");
|
|
211897
213086
|
__name2(writeScrubbedStep, "writeScrubbedStep");
|
|
211898
213087
|
__name2(writeScrubbedEvent, "writeScrubbedEvent");
|
|
211899
213088
|
__name2(purgeRunStreams, "purgeRunStreams");
|
|
@@ -212199,6 +213388,7 @@ var init_store = __esm2({
|
|
|
212199
213388
|
eventsBetween(runId, afterSeq, beforeSeq) {
|
|
212200
213389
|
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));
|
|
212201
213390
|
}
|
|
213391
|
+
// A caller that rewrites a live run's events makes the usage cache stale (see usage-storage.ts).
|
|
212202
213392
|
rewriteEvent(event) {
|
|
212203
213393
|
const seq = eventIdToSlot(event.eventId);
|
|
212204
213394
|
if (seq === null) return;
|
|
@@ -213501,7 +214691,9 @@ function createRunsStorage(db, tag) {
|
|
|
213501
214691
|
const now22 = /* @__PURE__ */ new Date();
|
|
213502
214692
|
const alreadyDeleted = run22.expiredAt !== void 0 && run22.expiredAt.getTime() <= now22.getTime();
|
|
213503
214693
|
if (!alreadyDeleted) store.updateRun(withRunPayloadsPurged(run22, now22));
|
|
213504
|
-
purgeRunData(db, runId
|
|
214694
|
+
purgeRunData(db, runId, {
|
|
214695
|
+
purgedBefore: alreadyDeleted
|
|
214696
|
+
});
|
|
213505
214697
|
return {
|
|
213506
214698
|
runId,
|
|
213507
214699
|
outcome: alreadyDeleted ? "already_deleted" : "deleted"
|
|
@@ -213749,6 +214941,362 @@ var init_steps_storage = __esm2({
|
|
|
213749
214941
|
__name2(createStepsStorage, "createStepsStorage");
|
|
213750
214942
|
}
|
|
213751
214943
|
});
|
|
214944
|
+
function countRange(db, runId, counts, from, to) {
|
|
214945
|
+
if (to <= from) return;
|
|
214946
|
+
for (const row of db.all(EVENT_GROUPS_SQL, runId, from, to)) {
|
|
214947
|
+
const entry = counts.eventTypes.get(row.event_type) ?? {
|
|
214948
|
+
events: 0,
|
|
214949
|
+
bytes: 0
|
|
214950
|
+
};
|
|
214951
|
+
entry.events += Number(row.events);
|
|
214952
|
+
entry.bytes += Number(row.bytes ?? 0);
|
|
214953
|
+
counts.eventTypes.set(row.event_type, entry);
|
|
214954
|
+
}
|
|
214955
|
+
for (const row of db.all(STEP_GROUPS_SQL, runId, from, to)) {
|
|
214956
|
+
const stepId = row.correlation_id ?? "";
|
|
214957
|
+
let step = counts.steps.get(stepId);
|
|
214958
|
+
if (!step) {
|
|
214959
|
+
const name = row.correlation_id === null ? null : db.get(STEP_NAME_SQL, runId, row.correlation_id)?.step_name ?? null;
|
|
214960
|
+
step = {
|
|
214961
|
+
name,
|
|
214962
|
+
events: 0,
|
|
214963
|
+
created: 0,
|
|
214964
|
+
started: 0,
|
|
214965
|
+
completed: 0,
|
|
214966
|
+
failed: 0,
|
|
214967
|
+
retries: 0,
|
|
214968
|
+
bytes: 0
|
|
214969
|
+
};
|
|
214970
|
+
counts.steps.set(stepId, step);
|
|
214971
|
+
}
|
|
214972
|
+
step.events += Number(row.events);
|
|
214973
|
+
step.created += Number(row.created);
|
|
214974
|
+
step.started += Number(row.started);
|
|
214975
|
+
step.completed += Number(row.completed);
|
|
214976
|
+
step.failed += Number(row.failed);
|
|
214977
|
+
step.retries += Number(row.retries);
|
|
214978
|
+
step.bytes += Number(row.bytes ?? 0);
|
|
214979
|
+
}
|
|
214980
|
+
for (const row of db.all(HOOK_GROUPS_SQL, runId, from, to)) {
|
|
214981
|
+
let hook = counts.hooks.get(row.correlation_id);
|
|
214982
|
+
if (!hook) {
|
|
214983
|
+
hook = {
|
|
214984
|
+
token: hookToken(db, runId, row.correlation_id),
|
|
214985
|
+
events: 0
|
|
214986
|
+
};
|
|
214987
|
+
counts.hooks.set(row.correlation_id, hook);
|
|
214988
|
+
}
|
|
214989
|
+
hook.events += Number(row.events);
|
|
214990
|
+
}
|
|
214991
|
+
for (const row of db.all(WAIT_IDS_SQL, runId, from, to)) {
|
|
214992
|
+
counts.waitIds.add(row.correlation_id);
|
|
214993
|
+
}
|
|
214994
|
+
counts.countedSeq = to;
|
|
214995
|
+
}
|
|
214996
|
+
__name(countRange, "countRange");
|
|
214997
|
+
function hookToken(db, runId, hookId) {
|
|
214998
|
+
const created = db.get(HOOK_TOKEN_SQL, runId, hookId);
|
|
214999
|
+
if (typeof created?.token === "string" && created.token) return created.token;
|
|
215000
|
+
const row = db.get(HOOK_ROW_TOKEN_SQL, hookId);
|
|
215001
|
+
if (typeof row?.token === "string" && row.token) return row.token;
|
|
215002
|
+
let startHook;
|
|
215003
|
+
try {
|
|
215004
|
+
startHook = startHookId(runId);
|
|
215005
|
+
} catch {
|
|
215006
|
+
return null;
|
|
215007
|
+
}
|
|
215008
|
+
if (hookId !== startHook) return null;
|
|
215009
|
+
const start22 = db.get(START_HOOK_TOKEN_SQL, runId);
|
|
215010
|
+
return typeof start22?.token === "string" && start22.token ? start22.token : null;
|
|
215011
|
+
}
|
|
215012
|
+
__name(hookToken, "hookToken");
|
|
215013
|
+
function hookGroupsOf(counts) {
|
|
215014
|
+
return [
|
|
215015
|
+
...counts.hooks
|
|
215016
|
+
].map(([hookId, hook]) => ({
|
|
215017
|
+
hookId,
|
|
215018
|
+
token: hook.token,
|
|
215019
|
+
events: hook.events
|
|
215020
|
+
}));
|
|
215021
|
+
}
|
|
215022
|
+
__name(hookGroupsOf, "hookGroupsOf");
|
|
215023
|
+
function eventGroupsOf(counts) {
|
|
215024
|
+
return [
|
|
215025
|
+
...counts.eventTypes
|
|
215026
|
+
].map(([eventType, entry]) => ({
|
|
215027
|
+
eventType,
|
|
215028
|
+
events: entry.events,
|
|
215029
|
+
bytes: entry.bytes
|
|
215030
|
+
}));
|
|
215031
|
+
}
|
|
215032
|
+
__name(eventGroupsOf, "eventGroupsOf");
|
|
215033
|
+
function stepGroupsOf(counts) {
|
|
215034
|
+
const byName = /* @__PURE__ */ new Map();
|
|
215035
|
+
for (const step of counts.steps.values()) {
|
|
215036
|
+
let group = byName.get(step.name);
|
|
215037
|
+
if (!group) {
|
|
215038
|
+
group = {
|
|
215039
|
+
stepName: step.name,
|
|
215040
|
+
steps: 0,
|
|
215041
|
+
events: 0,
|
|
215042
|
+
created: 0,
|
|
215043
|
+
started: 0,
|
|
215044
|
+
completed: 0,
|
|
215045
|
+
failed: 0,
|
|
215046
|
+
retries: 0,
|
|
215047
|
+
restarts: 0,
|
|
215048
|
+
bytes: 0
|
|
215049
|
+
};
|
|
215050
|
+
byName.set(step.name, group);
|
|
215051
|
+
}
|
|
215052
|
+
group.steps += 1;
|
|
215053
|
+
group.events += step.events;
|
|
215054
|
+
group.created += step.created;
|
|
215055
|
+
group.started += step.started;
|
|
215056
|
+
group.completed += step.completed;
|
|
215057
|
+
group.failed += step.failed;
|
|
215058
|
+
group.retries += step.retries;
|
|
215059
|
+
group.restarts += Math.min(step.retries, Math.max(0, step.started - 1));
|
|
215060
|
+
group.bytes += step.bytes;
|
|
215061
|
+
}
|
|
215062
|
+
return [
|
|
215063
|
+
...byName.values()
|
|
215064
|
+
];
|
|
215065
|
+
}
|
|
215066
|
+
__name(stepGroupsOf, "stepGroupsOf");
|
|
215067
|
+
function purgedDataWritten(db, runId, streamBytes) {
|
|
215068
|
+
const saved = readPurgedUsage(db, runId);
|
|
215069
|
+
if (!saved) return null;
|
|
215070
|
+
const late = new EntityBytes();
|
|
215071
|
+
for (const row of db.all(EVENTS_AFTER_SQL, runId, saved.seq)) {
|
|
215072
|
+
late.add(row.event_type, Number(row.bytes ?? 0));
|
|
215073
|
+
}
|
|
215074
|
+
return {
|
|
215075
|
+
run: saved.byEntity.run + late.byEntity.run,
|
|
215076
|
+
step: saved.byEntity.step + late.byEntity.step,
|
|
215077
|
+
hook: saved.byEntity.hook + late.byEntity.hook,
|
|
215078
|
+
stream: saved.byEntity.stream + streamBytes
|
|
215079
|
+
};
|
|
215080
|
+
}
|
|
215081
|
+
__name(purgedDataWritten, "purgedDataWritten");
|
|
215082
|
+
function createUsageStorage(db, tag, options = {}) {
|
|
215083
|
+
const maxRuns = options.maxRuns ?? 64;
|
|
215084
|
+
const batchTargetMs = options.batchTargetMs ?? 10;
|
|
215085
|
+
const maxBatchRows = options.maxBatchRows ?? 4096;
|
|
215086
|
+
const initialBatchRows = options.initialBatchRows ?? 4;
|
|
215087
|
+
const cache = /* @__PURE__ */ new Map();
|
|
215088
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
215089
|
+
const remember = /* @__PURE__ */ __name2((runId, counts) => {
|
|
215090
|
+
cache.delete(runId);
|
|
215091
|
+
cache.set(runId, counts);
|
|
215092
|
+
while (cache.size > maxRuns) {
|
|
215093
|
+
cache.delete(cache.keys().next().value);
|
|
215094
|
+
}
|
|
215095
|
+
}, "remember");
|
|
215096
|
+
const runRow = /* @__PURE__ */ __name2((runId) => db.get(`SELECT status, workflow_name, seq FROM runs WHERE run_id = ? AND ${tagClause("tag", tag)}`, runId, ...tagParams(tag)), "runRow");
|
|
215097
|
+
async function countInBatches(runId, counts, target22) {
|
|
215098
|
+
let batchRows = initialBatchRows;
|
|
215099
|
+
while (counts.countedSeq < target22) {
|
|
215100
|
+
const end = Number(db.get(BATCH_END_SQL, runId, counts.countedSeq, batchRows)?.seq ?? target22);
|
|
215101
|
+
const started = performance.now();
|
|
215102
|
+
countRange(db, runId, counts, counts.countedSeq, Math.min(end, target22));
|
|
215103
|
+
const took = performance.now() - started;
|
|
215104
|
+
batchRows = Math.max(1, Math.min(maxBatchRows, batchRows * 2, Math.round(batchRows * batchTargetMs / Math.max(took, 0.1))));
|
|
215105
|
+
if (counts.countedSeq < target22) {
|
|
215106
|
+
await options.onBatch?.(runId, counts.countedSeq);
|
|
215107
|
+
await yieldToEventLoop();
|
|
215108
|
+
}
|
|
215109
|
+
}
|
|
215110
|
+
}
|
|
215111
|
+
__name(countInBatches, "countInBatches");
|
|
215112
|
+
__name2(countInBatches, "countInBatches");
|
|
215113
|
+
async function read32(runId) {
|
|
215114
|
+
const first = runRow(runId);
|
|
215115
|
+
if (!first) {
|
|
215116
|
+
cache.delete(runId);
|
|
215117
|
+
throw new WorkflowRunNotFoundError(runId);
|
|
215118
|
+
}
|
|
215119
|
+
let counts = cache.get(runId) ?? newCounts();
|
|
215120
|
+
if (Number(first.seq) < counts.countedSeq) counts = newCounts();
|
|
215121
|
+
let readBeforeFinish = !isTerminalWorkflowRunStatus(first.status) || counts.countedSeq > 0 && !counts.finished;
|
|
215122
|
+
await countInBatches(runId, counts, Number(first.seq));
|
|
215123
|
+
const snapshot = db.snapshot(() => {
|
|
215124
|
+
const run22 = runRow(runId);
|
|
215125
|
+
if (!run22) return null;
|
|
215126
|
+
const seq = Number(run22.seq);
|
|
215127
|
+
const finished = isTerminalWorkflowRunStatus(run22.status);
|
|
215128
|
+
if (seq < counts.countedSeq) {
|
|
215129
|
+
counts = newCounts();
|
|
215130
|
+
readBeforeFinish = !finished;
|
|
215131
|
+
}
|
|
215132
|
+
countRange(db, runId, counts, counts.countedSeq, seq);
|
|
215133
|
+
const streamBytes = measureStreamBytes(db, runId);
|
|
215134
|
+
const savedDataWritten = purgedDataWritten(db, runId, streamBytes) ?? void 0;
|
|
215135
|
+
const dataPurged = savedDataWritten !== void 0 || finished && Number(db.get(PURGED_RUN_SQL, runId)?.purged) === 1;
|
|
215136
|
+
if (dataPurged && readBeforeFinish && counts.countedSeq > 0) {
|
|
215137
|
+
options.onRecount?.(runId);
|
|
215138
|
+
counts = newCounts();
|
|
215139
|
+
countRange(db, runId, counts, 0, seq);
|
|
215140
|
+
}
|
|
215141
|
+
counts.finished = finished;
|
|
215142
|
+
return {
|
|
215143
|
+
run: run22,
|
|
215144
|
+
streamBytes,
|
|
215145
|
+
dataPurged,
|
|
215146
|
+
savedDataWritten
|
|
215147
|
+
};
|
|
215148
|
+
});
|
|
215149
|
+
if (!snapshot) {
|
|
215150
|
+
cache.delete(runId);
|
|
215151
|
+
throw new WorkflowRunNotFoundError(runId);
|
|
215152
|
+
}
|
|
215153
|
+
remember(runId, counts);
|
|
215154
|
+
return buildRunUsage({
|
|
215155
|
+
runId,
|
|
215156
|
+
status: snapshot.run.status,
|
|
215157
|
+
workflowName: snapshot.run.workflow_name,
|
|
215158
|
+
eventGroups: eventGroupsOf(counts),
|
|
215159
|
+
stepGroups: stepGroupsOf(counts),
|
|
215160
|
+
streamBytes: snapshot.streamBytes,
|
|
215161
|
+
dataPurged: snapshot.dataPurged,
|
|
215162
|
+
savedDataWritten: snapshot.savedDataWritten,
|
|
215163
|
+
hookGroups: hookGroupsOf(counts),
|
|
215164
|
+
calls: {
|
|
215165
|
+
wait: counts.waitIds.size
|
|
215166
|
+
},
|
|
215167
|
+
// Local runs are not billed.
|
|
215168
|
+
billed: false,
|
|
215169
|
+
// world-local has no plan retention, so there is no Data Retained to
|
|
215170
|
+
// report: the UI and CLI hide it.
|
|
215171
|
+
dataRetained: null
|
|
215172
|
+
});
|
|
215173
|
+
}
|
|
215174
|
+
__name(read32, "read3");
|
|
215175
|
+
__name2(read32, "read");
|
|
215176
|
+
return {
|
|
215177
|
+
async getRun(runId) {
|
|
215178
|
+
assertSafeEntityId("runId", runId);
|
|
215179
|
+
const previous = inFlight.get(runId) ?? Promise.resolve();
|
|
215180
|
+
const current22 = previous.catch(() => {
|
|
215181
|
+
}).then(() => read32(runId));
|
|
215182
|
+
inFlight.set(runId, current22);
|
|
215183
|
+
try {
|
|
215184
|
+
return await current22;
|
|
215185
|
+
} finally {
|
|
215186
|
+
if (inFlight.get(runId) === current22) inFlight.delete(runId);
|
|
215187
|
+
}
|
|
215188
|
+
}
|
|
215189
|
+
};
|
|
215190
|
+
}
|
|
215191
|
+
__name(createUsageStorage, "createUsageStorage");
|
|
215192
|
+
var IS_STEP_EVENT;
|
|
215193
|
+
var EVENT_GROUPS_SQL;
|
|
215194
|
+
var STEP_GROUPS_SQL;
|
|
215195
|
+
var WAIT_IDS_SQL;
|
|
215196
|
+
var HOOK_GROUPS_SQL;
|
|
215197
|
+
var HOOK_TOKEN_SQL;
|
|
215198
|
+
var HOOK_ROW_TOKEN_SQL;
|
|
215199
|
+
var START_HOOK_TOKEN_SQL;
|
|
215200
|
+
var STEP_NAME_SQL;
|
|
215201
|
+
var BATCH_END_SQL;
|
|
215202
|
+
var EVENTS_AFTER_SQL;
|
|
215203
|
+
var PURGED_RUN_SQL;
|
|
215204
|
+
var newCounts;
|
|
215205
|
+
var yieldToEventLoop;
|
|
215206
|
+
var init_usage_storage = __esm2({
|
|
215207
|
+
"../world-local/dist/storage/usage-storage.js"() {
|
|
215208
|
+
"use strict";
|
|
215209
|
+
init_dist2();
|
|
215210
|
+
init_dist4();
|
|
215211
|
+
init_ids();
|
|
215212
|
+
init_purged_usage();
|
|
215213
|
+
init_store();
|
|
215214
|
+
IS_STEP_EVENT = `event_type LIKE 'step\\_%' ESCAPE '\\'`;
|
|
215215
|
+
EVENT_GROUPS_SQL = `
|
|
215216
|
+
SELECT event_type,
|
|
215217
|
+
COUNT(*) AS events,
|
|
215218
|
+
SUM(${PAYLOAD_BYTES_SQL}) AS bytes
|
|
215219
|
+
FROM events
|
|
215220
|
+
WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3 AND NOT (${IS_STEP_EVENT})
|
|
215221
|
+
GROUP BY event_type
|
|
215222
|
+
`;
|
|
215223
|
+
STEP_GROUPS_SQL = `
|
|
215224
|
+
SELECT correlation_id,
|
|
215225
|
+
COUNT(*) AS events,
|
|
215226
|
+
SUM(event_type = 'step_created') AS created,
|
|
215227
|
+
SUM(event_type = 'step_started') AS started,
|
|
215228
|
+
SUM(event_type = 'step_completed') AS completed,
|
|
215229
|
+
SUM(event_type = 'step_failed') AS failed,
|
|
215230
|
+
SUM(event_type = 'step_retrying') AS retries,
|
|
215231
|
+
SUM(${PAYLOAD_BYTES_SQL}) AS bytes
|
|
215232
|
+
FROM events
|
|
215233
|
+
WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3 AND ${IS_STEP_EVENT}
|
|
215234
|
+
GROUP BY correlation_id
|
|
215235
|
+
`;
|
|
215236
|
+
WAIT_IDS_SQL = `
|
|
215237
|
+
SELECT DISTINCT correlation_id
|
|
215238
|
+
FROM events
|
|
215239
|
+
WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3
|
|
215240
|
+
AND correlation_id IS NOT NULL AND substr(event_type, 1, 5) = 'wait_'
|
|
215241
|
+
`;
|
|
215242
|
+
HOOK_GROUPS_SQL = `
|
|
215243
|
+
SELECT correlation_id, COUNT(*) AS events
|
|
215244
|
+
FROM events
|
|
215245
|
+
WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3
|
|
215246
|
+
AND correlation_id IS NOT NULL AND substr(event_type, 1, 5) = 'hook_'
|
|
215247
|
+
GROUP BY correlation_id
|
|
215248
|
+
`;
|
|
215249
|
+
HOOK_TOKEN_SQL = `
|
|
215250
|
+
SELECT json_extract(doc, '$.eventData.token') AS token
|
|
215251
|
+
FROM ${EVENTS_BY_CORRELATION}
|
|
215252
|
+
WHERE run_id = ? AND correlation_id = ?
|
|
215253
|
+
AND event_type IN ('hook_created', 'hook_conflict')
|
|
215254
|
+
ORDER BY seq LIMIT 1
|
|
215255
|
+
`;
|
|
215256
|
+
HOOK_ROW_TOKEN_SQL = "SELECT token FROM hooks WHERE hook_id = ?";
|
|
215257
|
+
START_HOOK_TOKEN_SQL = `
|
|
215258
|
+
SELECT json_extract(doc, '$.eventData.startHook.token') AS token
|
|
215259
|
+
FROM events
|
|
215260
|
+
WHERE run_id = ? AND event_type = 'run_created'
|
|
215261
|
+
LIMIT 1
|
|
215262
|
+
`;
|
|
215263
|
+
STEP_NAME_SQL = `
|
|
215264
|
+
SELECT json_extract(doc, '$.stepName') AS step_name
|
|
215265
|
+
FROM steps WHERE run_id = ? AND step_id = ?
|
|
215266
|
+
`;
|
|
215267
|
+
BATCH_END_SQL = `
|
|
215268
|
+
SELECT MAX(seq) AS seq FROM (
|
|
215269
|
+
SELECT seq FROM events WHERE run_id = ? AND seq > ? ORDER BY seq LIMIT ?
|
|
215270
|
+
)
|
|
215271
|
+
`;
|
|
215272
|
+
EVENTS_AFTER_SQL = `
|
|
215273
|
+
SELECT event_type, SUM(${PAYLOAD_BYTES_SQL}) AS bytes
|
|
215274
|
+
FROM events
|
|
215275
|
+
WHERE run_id = ? AND seq > ?
|
|
215276
|
+
GROUP BY event_type
|
|
215277
|
+
`;
|
|
215278
|
+
PURGED_RUN_SQL = `
|
|
215279
|
+
SELECT json_extract(doc, '$.expiredAt') IS NOT NULL AS purged
|
|
215280
|
+
FROM runs WHERE run_id = ?
|
|
215281
|
+
`;
|
|
215282
|
+
newCounts = /* @__PURE__ */ __name2(() => ({
|
|
215283
|
+
countedSeq: 0,
|
|
215284
|
+
finished: false,
|
|
215285
|
+
eventTypes: /* @__PURE__ */ new Map(),
|
|
215286
|
+
steps: /* @__PURE__ */ new Map(),
|
|
215287
|
+
hooks: /* @__PURE__ */ new Map(),
|
|
215288
|
+
waitIds: /* @__PURE__ */ new Set()
|
|
215289
|
+
}), "newCounts");
|
|
215290
|
+
__name2(countRange, "countRange");
|
|
215291
|
+
__name2(hookToken, "hookToken");
|
|
215292
|
+
__name2(hookGroupsOf, "hookGroupsOf");
|
|
215293
|
+
__name2(eventGroupsOf, "eventGroupsOf");
|
|
215294
|
+
__name2(stepGroupsOf, "stepGroupsOf");
|
|
215295
|
+
__name2(purgedDataWritten, "purgedDataWritten");
|
|
215296
|
+
yieldToEventLoop = /* @__PURE__ */ __name2(() => new Promise((resolve22) => setImmediate(resolve22)), "yieldToEventLoop");
|
|
215297
|
+
__name2(createUsageStorage, "createUsageStorage");
|
|
215298
|
+
}
|
|
215299
|
+
});
|
|
213752
215300
|
function createStorage(basedir, tag) {
|
|
213753
215301
|
const db = databaseFor(basedir);
|
|
213754
215302
|
const runs = createRunsStorage(db, tag);
|
|
@@ -213756,12 +215304,14 @@ function createStorage(basedir, tag) {
|
|
|
213756
215304
|
const events = createEventsStorage(db, tag);
|
|
213757
215305
|
const hooks = createHooksStorage(db, tag);
|
|
213758
215306
|
const snapshots = createSnapshotsStorage(db);
|
|
215307
|
+
const usage = createUsageStorage(db, tag);
|
|
213759
215308
|
return {
|
|
213760
215309
|
runs: instrumentObject("world.runs", runs),
|
|
213761
215310
|
steps: instrumentObject("world.steps", steps),
|
|
213762
215311
|
events: instrumentObject("world.events", events),
|
|
213763
215312
|
hooks: instrumentObject("world.hooks", hooks),
|
|
213764
215313
|
experimental_snapshots: instrumentObject("world.experimental_snapshots", snapshots),
|
|
215314
|
+
experimental_usage: instrumentObject("world.experimental_usage", usage),
|
|
213765
215315
|
clearCache: /* @__PURE__ */ __name2(() => {
|
|
213766
215316
|
}, "clearCache")
|
|
213767
215317
|
};
|
|
@@ -213777,6 +215327,7 @@ var init_storage = __esm2({
|
|
|
213777
215327
|
init_runs_storage();
|
|
213778
215328
|
init_snapshots_storage();
|
|
213779
215329
|
init_steps_storage();
|
|
215330
|
+
init_usage_storage();
|
|
213780
215331
|
__name2(createStorage, "createStorage");
|
|
213781
215332
|
}
|
|
213782
215333
|
});
|
|
@@ -214210,9 +215761,16 @@ function createWorld(args) {
|
|
|
214210
215761
|
]) {
|
|
214211
215762
|
db.run(`DELETE FROM ${table}`);
|
|
214212
215763
|
}
|
|
215764
|
+
deletePurgedUsage(db);
|
|
214213
215765
|
return;
|
|
214214
215766
|
}
|
|
214215
215767
|
const runs = "SELECT run_id FROM runs WHERE tag = ?";
|
|
215768
|
+
deletePurgedUsage(db, {
|
|
215769
|
+
runIdsSql: runs,
|
|
215770
|
+
params: [
|
|
215771
|
+
tag
|
|
215772
|
+
]
|
|
215773
|
+
});
|
|
214216
215774
|
for (const table of [
|
|
214217
215775
|
"events",
|
|
214218
215776
|
"steps",
|
|
@@ -214254,6 +215812,7 @@ var init_dist5 = __esm2({
|
|
|
214254
215812
|
init_queue2();
|
|
214255
215813
|
init_queue_auth_key();
|
|
214256
215814
|
init_recovery_wake();
|
|
215815
|
+
init_purged_usage();
|
|
214257
215816
|
init_storage2();
|
|
214258
215817
|
init_streamer();
|
|
214259
215818
|
init_build_target_mismatch();
|
|
@@ -218225,7 +219784,7 @@ var version3;
|
|
|
218225
219784
|
var init_version2 = __esm2({
|
|
218226
219785
|
"../world-vercel/dist/version.js"() {
|
|
218227
219786
|
"use strict";
|
|
218228
|
-
version3 = "5.7.
|
|
219787
|
+
version3 = "5.7.2";
|
|
218229
219788
|
}
|
|
218230
219789
|
});
|
|
218231
219790
|
function getQueueAgentOptions2() {
|
|
@@ -227304,17 +228863,17 @@ var require_exec = __commonJS2({
|
|
|
227304
228863
|
var import_node_path62 = __toESM22(__require2("node:path"));
|
|
227305
228864
|
var import_execa = __toESM22(require_execa());
|
|
227306
228865
|
var import_envpath = require_envpath();
|
|
227307
|
-
var
|
|
228866
|
+
var import_errors602 = require_errors2();
|
|
227308
228867
|
var import_lookup = require_lookup();
|
|
227309
228868
|
async function execVercelCli2(args, options = {}) {
|
|
227310
228869
|
const cwd = import_node_path62.default.resolve(options.cwd ?? process.cwd());
|
|
227311
|
-
await (0,
|
|
228870
|
+
await (0, import_errors602.assertValidCwd)(cwd);
|
|
227312
228871
|
const env = mergeExecEnv(options.env);
|
|
227313
228872
|
const pathValue = (0, import_envpath.getEnvPath)(env);
|
|
227314
228873
|
try {
|
|
227315
228874
|
return await execResolvedVercelCli(args, options, cwd, env, pathValue);
|
|
227316
228875
|
} catch (error622) {
|
|
227317
|
-
if (error622 instanceof
|
|
228876
|
+
if (error622 instanceof import_errors602.VercelCliError && error622.code === "VERCEL_CLI_NOT_FOUND") {
|
|
227318
228877
|
(0, import_lookup.clearCachedCliInvocation)(cwd, pathValue);
|
|
227319
228878
|
return await execResolvedVercelCli(args, options, cwd, env, pathValue);
|
|
227320
228879
|
}
|
|
@@ -227350,7 +228909,7 @@ var require_exec = __commonJS2({
|
|
|
227350
228909
|
invocation
|
|
227351
228910
|
};
|
|
227352
228911
|
} catch (error622) {
|
|
227353
|
-
throw (0,
|
|
228912
|
+
throw (0, import_errors602.toVercelCliError)(invocation, error622);
|
|
227354
228913
|
}
|
|
227355
228914
|
}
|
|
227356
228915
|
__name(execResolvedVercelCli, "execResolvedVercelCli");
|
|
@@ -227358,9 +228917,9 @@ var require_exec = __commonJS2({
|
|
|
227358
228917
|
async function resolveInvocationOrThrow(cwd, pathValue) {
|
|
227359
228918
|
const resolution = await (0, import_lookup.resolveCachedCliInvocation)(cwd, pathValue);
|
|
227360
228919
|
if (!resolution.found) {
|
|
227361
|
-
throw new
|
|
228920
|
+
throw new import_errors602.VercelCliError({
|
|
227362
228921
|
code: "VERCEL_CLI_NOT_FOUND",
|
|
227363
|
-
message: (0,
|
|
228922
|
+
message: (0, import_errors602.getCliNotFoundMessage)(resolution.diagnostics)
|
|
227364
228923
|
});
|
|
227365
228924
|
}
|
|
227366
228925
|
return (0, import_lookup.toVercelCliInvocation)(resolution);
|
|
@@ -227420,13 +228979,13 @@ var require_dist2 = __commonJS2({
|
|
|
227420
228979
|
}), mod), "__toCommonJS");
|
|
227421
228980
|
var src_exports = {};
|
|
227422
228981
|
__export22(src_exports, {
|
|
227423
|
-
VercelCliError: /* @__PURE__ */ __name2(() =>
|
|
228982
|
+
VercelCliError: /* @__PURE__ */ __name2(() => import_errors602.VercelCliError, "VercelCliError"),
|
|
227424
228983
|
clearVercelCliLookupCache: /* @__PURE__ */ __name2(() => import_lookup.clearVercelCliLookupCache, "clearVercelCliLookupCache"),
|
|
227425
228984
|
execVercelCli: /* @__PURE__ */ __name2(() => import_exec.execVercelCli, "execVercelCli"),
|
|
227426
228985
|
findVercelCli: /* @__PURE__ */ __name2(() => import_lookup.findVercelCli, "findVercelCli")
|
|
227427
228986
|
});
|
|
227428
228987
|
module.exports = __toCommonJS(src_exports);
|
|
227429
|
-
var
|
|
228988
|
+
var import_errors602 = require_errors2();
|
|
227430
228989
|
var import_exec = require_exec();
|
|
227431
228990
|
var import_lookup = require_lookup();
|
|
227432
228991
|
}
|
|
@@ -256489,22 +258048,22 @@ function getAllBaseReducers(global2 = globalThis) {
|
|
|
256489
258048
|
__name(getAllBaseReducers, "getAllBaseReducers");
|
|
256490
258049
|
function reduceAbortWithListener(signal, holder, global2, ops, runId, cryptoKey, framedAbortStreams) {
|
|
256491
258050
|
let streamName = holder[ABORT_STREAM_NAME];
|
|
256492
|
-
let
|
|
258051
|
+
let hookToken22 = holder[ABORT_HOOK_TOKEN];
|
|
256493
258052
|
if (!streamName) {
|
|
256494
258053
|
const id = (global2[STABLE_ULID] || defaultUlid)();
|
|
256495
258054
|
streamName = getAbortStreamId(id);
|
|
256496
|
-
|
|
258055
|
+
hookToken22 = `abrt_${id}`;
|
|
256497
258056
|
holder[ABORT_STREAM_NAME] = streamName;
|
|
256498
|
-
holder[ABORT_HOOK_TOKEN] =
|
|
258057
|
+
holder[ABORT_HOOK_TOKEN] = hookToken22;
|
|
256499
258058
|
if (holder.signal) {
|
|
256500
258059
|
holder.signal[ABORT_STREAM_NAME] = streamName;
|
|
256501
|
-
holder.signal[ABORT_HOOK_TOKEN] =
|
|
258060
|
+
holder.signal[ABORT_HOOK_TOKEN] = hookToken22;
|
|
256502
258061
|
}
|
|
256503
258062
|
}
|
|
256504
258063
|
attachAbortListenerOnce(signal, streamName, runId, cryptoKey, ops, framedAbortStreams);
|
|
256505
258064
|
return {
|
|
256506
258065
|
streamName,
|
|
256507
|
-
hookToken,
|
|
258066
|
+
hookToken: hookToken22,
|
|
256508
258067
|
aborted: signal.aborted,
|
|
256509
258068
|
reason: signal.aborted ? signal.reason : void 0
|
|
256510
258069
|
};
|
|
@@ -256512,13 +258071,13 @@ function reduceAbortWithListener(signal, holder, global2, ops, runId, cryptoKey,
|
|
|
256512
258071
|
__name(reduceAbortWithListener, "reduceAbortWithListener");
|
|
256513
258072
|
function reduceAbortBySymbol(signal, holder) {
|
|
256514
258073
|
const streamName = holder[ABORT_STREAM_NAME] ?? holder.signal?.[ABORT_STREAM_NAME];
|
|
256515
|
-
const
|
|
258074
|
+
const hookToken22 = holder[ABORT_HOOK_TOKEN] ?? holder.signal?.[ABORT_HOOK_TOKEN];
|
|
256516
258075
|
if (!streamName) {
|
|
256517
258076
|
throw new Error("AbortController/AbortSignal stream name is not set");
|
|
256518
258077
|
}
|
|
256519
258078
|
return {
|
|
256520
258079
|
streamName,
|
|
256521
|
-
hookToken,
|
|
258080
|
+
hookToken: hookToken22,
|
|
256522
258081
|
aborted: signal.aborted,
|
|
256523
258082
|
reason: signal.aborted ? signal.reason : void 0
|
|
256524
258083
|
};
|
|
@@ -266592,7 +268151,7 @@ __name2(start, "start");
|
|
|
266592
268151
|
value: "start",
|
|
266593
268152
|
configurable: true
|
|
266594
268153
|
});
|
|
266595
|
-
})(start, "step//@workflow/core/runtime/start@5.7.
|
|
268154
|
+
})(start, "step//@workflow/core/runtime/start@5.7.2//start");
|
|
266596
268155
|
function isSingleOrchestratorRun(run22) {
|
|
266597
268156
|
return (run22.specVersion ?? SPEC_VERSION_LEGACY) >= SPEC_VERSION_SINGLE_ORCHESTRATOR;
|
|
266598
268157
|
}
|
|
@@ -267369,7 +268928,7 @@ var Run = class _Run {
|
|
|
267369
268928
|
value: "readFinishedRunIds",
|
|
267370
268929
|
configurable: true
|
|
267371
268930
|
});
|
|
267372
|
-
})(Run.readFinishedRunIds, "step//@workflow/core/runtime/run@5.7.
|
|
268931
|
+
})(Run.readFinishedRunIds, "step//@workflow/core/runtime/run@5.7.2//Run.readFinishedRunIds");
|
|
267373
268932
|
(function(__wf_fn, __wf_id) {
|
|
267374
268933
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267375
268934
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267378,7 +268937,7 @@ var Run = class _Run {
|
|
|
267378
268937
|
value: "wakeUp",
|
|
267379
268938
|
configurable: true
|
|
267380
268939
|
});
|
|
267381
|
-
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.7.
|
|
268940
|
+
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.7.2//Run#wakeUp");
|
|
267382
268941
|
(function(__wf_fn, __wf_id) {
|
|
267383
268942
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267384
268943
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267387,7 +268946,7 @@ var Run = class _Run {
|
|
|
267387
268946
|
value: "cancel",
|
|
267388
268947
|
configurable: true
|
|
267389
268948
|
});
|
|
267390
|
-
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.7.
|
|
268949
|
+
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.7.2//Run#cancel");
|
|
267391
268950
|
(function(__wf_fn, __wf_id) {
|
|
267392
268951
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267393
268952
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267396,7 +268955,7 @@ var Run = class _Run {
|
|
|
267396
268955
|
value: "delete",
|
|
267397
268956
|
configurable: true
|
|
267398
268957
|
});
|
|
267399
|
-
})(Run.prototype["delete"], "step//@workflow/core/runtime/run@5.7.
|
|
268958
|
+
})(Run.prototype["delete"], "step//@workflow/core/runtime/run@5.7.2//Run#delete");
|
|
267400
268959
|
(function(__wf_fn, __wf_id) {
|
|
267401
268960
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267402
268961
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267405,7 +268964,7 @@ var Run = class _Run {
|
|
|
267405
268964
|
value: "readReturnValue",
|
|
267406
268965
|
configurable: true
|
|
267407
268966
|
});
|
|
267408
|
-
})(Run.prototype["readReturnValue"], "step//@workflow/core/runtime/run@5.7.
|
|
268967
|
+
})(Run.prototype["readReturnValue"], "step//@workflow/core/runtime/run@5.7.2//Run#readReturnValue");
|
|
267409
268968
|
(function(__wf_fn, __wf_id) {
|
|
267410
268969
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267411
268970
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267414,7 +268973,7 @@ var Run = class _Run {
|
|
|
267414
268973
|
value: "getReadable",
|
|
267415
268974
|
configurable: true
|
|
267416
268975
|
});
|
|
267417
|
-
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.7.
|
|
268976
|
+
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.7.2//Run#getReadable");
|
|
267418
268977
|
(function(__wf_fn, __wf_id) {
|
|
267419
268978
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267420
268979
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267423,7 +268982,7 @@ var Run = class _Run {
|
|
|
267423
268982
|
value: "getWritable",
|
|
267424
268983
|
configurable: true
|
|
267425
268984
|
});
|
|
267426
|
-
})(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.7.
|
|
268985
|
+
})(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.7.2//Run#getWritable");
|
|
267427
268986
|
(function(__wf_fn, __wf_id) {
|
|
267428
268987
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267429
268988
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267432,7 +268991,7 @@ var Run = class _Run {
|
|
|
267432
268991
|
value: "exists",
|
|
267433
268992
|
configurable: true
|
|
267434
268993
|
});
|
|
267435
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.7.
|
|
268994
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.7.2//Run#exists");
|
|
267436
268995
|
(function(__wf_fn, __wf_id) {
|
|
267437
268996
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267438
268997
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267441,7 +269000,7 @@ var Run = class _Run {
|
|
|
267441
269000
|
value: "status",
|
|
267442
269001
|
configurable: true
|
|
267443
269002
|
});
|
|
267444
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.7.
|
|
269003
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.7.2//Run#status");
|
|
267445
269004
|
(function(__wf_fn, __wf_id) {
|
|
267446
269005
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267447
269006
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267450,7 +269009,7 @@ var Run = class _Run {
|
|
|
267450
269009
|
value: "workflowName",
|
|
267451
269010
|
configurable: true
|
|
267452
269011
|
});
|
|
267453
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.7.
|
|
269012
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.7.2//Run#workflowName");
|
|
267454
269013
|
(function(__wf_fn, __wf_id) {
|
|
267455
269014
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267456
269015
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267459,7 +269018,7 @@ var Run = class _Run {
|
|
|
267459
269018
|
value: "createdAt",
|
|
267460
269019
|
configurable: true
|
|
267461
269020
|
});
|
|
267462
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.7.
|
|
269021
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.7.2//Run#createdAt");
|
|
267463
269022
|
(function(__wf_fn, __wf_id) {
|
|
267464
269023
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267465
269024
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267468,7 +269027,7 @@ var Run = class _Run {
|
|
|
267468
269027
|
value: "startedAt",
|
|
267469
269028
|
configurable: true
|
|
267470
269029
|
});
|
|
267471
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.7.
|
|
269030
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.7.2//Run#startedAt");
|
|
267472
269031
|
(function(__wf_fn, __wf_id) {
|
|
267473
269032
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267474
269033
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -267477,7 +269036,7 @@ var Run = class _Run {
|
|
|
267477
269036
|
value: "completedAt",
|
|
267478
269037
|
configurable: true
|
|
267479
269038
|
});
|
|
267480
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.7.
|
|
269039
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.7.2//Run#completedAt");
|
|
267481
269040
|
(function(__wf_cls, __wf_id) {
|
|
267482
269041
|
var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
267483
269042
|
__wf_reg.set(__wf_id, __wf_cls);
|
|
@@ -267487,7 +269046,7 @@ var Run = class _Run {
|
|
|
267487
269046
|
enumerable: false,
|
|
267488
269047
|
configurable: false
|
|
267489
269048
|
});
|
|
267490
|
-
})(Run, "class//@workflow/core/runtime/run@5.7.
|
|
269049
|
+
})(Run, "class//@workflow/core/runtime/run@5.7.2//Run");
|
|
267491
269050
|
async function fetch2(...args) {
|
|
267492
269051
|
return globalThis.fetch(...args);
|
|
267493
269052
|
}
|
|
@@ -270386,7 +271945,7 @@ async function runDelivery(delivery, inlineStepsInFlight, inlineRetryPublication
|
|
|
270386
271945
|
return;
|
|
270387
271946
|
}
|
|
270388
271947
|
if (maxEventsLimit !== void 0) {
|
|
270389
|
-
const workflowEventCount = eventLog.events.reduce((n, e) =>
|
|
271948
|
+
const workflowEventCount = eventLog.events.reduce((n, e) => isSealedNoopEvent2(e) ? n : n + 1, 0);
|
|
270390
271949
|
if (workflowEventCount >= maxEventsLimit) {
|
|
270391
271950
|
throw new MaxEventsExceededError(workflowEventCount, maxEventsLimit);
|
|
270392
271951
|
}
|
|
@@ -270398,7 +271957,7 @@ async function runDelivery(delivery, inlineStepsInFlight, inlineRetryPublication
|
|
|
270398
271957
|
isQuickJS: false
|
|
270399
271958
|
});
|
|
270400
271959
|
}
|
|
270401
|
-
invocationStartedClean ??= eventLog.events.every((e) => e.eventType === "run_created" || e.eventType === "run_started" || e.eventType === "attr_set" ||
|
|
271960
|
+
invocationStartedClean ??= eventLog.events.every((e) => e.eventType === "run_created" || e.eventType === "run_started" || e.eventType === "attr_set" || isSealedNoopEvent2(e));
|
|
270402
271961
|
runtimeLogger2.debug("Starting workflow execution", {
|
|
270403
271962
|
workflowRunId: runId,
|
|
270404
271963
|
loopIteration,
|
|
@@ -272687,14 +274246,14 @@ var Run = class _Run {
|
|
|
272687
274246
|
return this.getWritable();
|
|
272688
274247
|
}
|
|
272689
274248
|
};
|
|
272690
|
-
Run.readFinishedRunIds = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
272691
|
-
Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
272692
|
-
Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
272693
|
-
Run.prototype["delete"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
272694
|
-
Run.prototype["readReturnValue"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
272695
|
-
Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
272696
|
-
Run.prototype["getWritable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
272697
|
-
var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
274249
|
+
Run.readFinishedRunIds = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run.readFinishedRunIds");
|
|
274250
|
+
Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#wakeUp");
|
|
274251
|
+
Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#cancel");
|
|
274252
|
+
Run.prototype["delete"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#delete");
|
|
274253
|
+
Run.prototype["readReturnValue"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#readReturnValue");
|
|
274254
|
+
Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#getReadable");
|
|
274255
|
+
Run.prototype["getWritable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#getWritable");
|
|
274256
|
+
var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#exists");
|
|
272698
274257
|
Object.defineProperty(Run.prototype, "exists", {
|
|
272699
274258
|
get() {
|
|
272700
274259
|
return __step_Run$exists.call(this);
|
|
@@ -272702,7 +274261,7 @@ Object.defineProperty(Run.prototype, "exists", {
|
|
|
272702
274261
|
configurable: true,
|
|
272703
274262
|
enumerable: false
|
|
272704
274263
|
});
|
|
272705
|
-
var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
274264
|
+
var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#status");
|
|
272706
274265
|
Object.defineProperty(Run.prototype, "status", {
|
|
272707
274266
|
get() {
|
|
272708
274267
|
return __step_Run$status.call(this);
|
|
@@ -272710,7 +274269,7 @@ Object.defineProperty(Run.prototype, "status", {
|
|
|
272710
274269
|
configurable: true,
|
|
272711
274270
|
enumerable: false
|
|
272712
274271
|
});
|
|
272713
|
-
var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
274272
|
+
var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#workflowName");
|
|
272714
274273
|
Object.defineProperty(Run.prototype, "workflowName", {
|
|
272715
274274
|
get() {
|
|
272716
274275
|
return __step_Run$workflowName.call(this);
|
|
@@ -272718,7 +274277,7 @@ Object.defineProperty(Run.prototype, "workflowName", {
|
|
|
272718
274277
|
configurable: true,
|
|
272719
274278
|
enumerable: false
|
|
272720
274279
|
});
|
|
272721
|
-
var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
274280
|
+
var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#createdAt");
|
|
272722
274281
|
Object.defineProperty(Run.prototype, "createdAt", {
|
|
272723
274282
|
get() {
|
|
272724
274283
|
return __step_Run$createdAt.call(this);
|
|
@@ -272726,7 +274285,7 @@ Object.defineProperty(Run.prototype, "createdAt", {
|
|
|
272726
274285
|
configurable: true,
|
|
272727
274286
|
enumerable: false
|
|
272728
274287
|
});
|
|
272729
|
-
var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
274288
|
+
var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#startedAt");
|
|
272730
274289
|
Object.defineProperty(Run.prototype, "startedAt", {
|
|
272731
274290
|
get() {
|
|
272732
274291
|
return __step_Run$startedAt.call(this);
|
|
@@ -272734,7 +274293,7 @@ Object.defineProperty(Run.prototype, "startedAt", {
|
|
|
272734
274293
|
configurable: true,
|
|
272735
274294
|
enumerable: false
|
|
272736
274295
|
});
|
|
272737
|
-
var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.
|
|
274296
|
+
var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.2//Run#completedAt");
|
|
272738
274297
|
Object.defineProperty(Run.prototype, "completedAt", {
|
|
272739
274298
|
get() {
|
|
272740
274299
|
return __step_Run$completedAt.call(this);
|
|
@@ -272751,7 +274310,7 @@ Object.defineProperty(Run.prototype, "completedAt", {
|
|
|
272751
274310
|
enumerable: false,
|
|
272752
274311
|
configurable: false
|
|
272753
274312
|
});
|
|
272754
|
-
})(Run, "class//@workflow/core/runtime/run@5.7.
|
|
274313
|
+
})(Run, "class//@workflow/core/runtime/run@5.7.2//Run");
|
|
272755
274314
|
|
|
272756
274315
|
// ../core/dist/workflow/create-hook.js
|
|
272757
274316
|
aliasSerializationClass(RUN_CLASS_ID, Run);
|
|
@@ -296247,7 +297806,7 @@ var latestNoOpWarning = globalSingleton("@workflow/core//latestNoOpWarning", 1,
|
|
|
296247
297806
|
var probeMissWarning = globalSingleton("@workflow/core//crossDeploymentProbeMissWarning", 1, () => ({
|
|
296248
297807
|
warned: false
|
|
296249
297808
|
}));
|
|
296250
|
-
var start = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/start@5.7.
|
|
297809
|
+
var start = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/start@5.7.2//start");
|
|
296251
297810
|
|
|
296252
297811
|
// workflows/lineage.ts
|
|
296253
297812
|
var noop = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//./workflows/lineage//noop");
|