@exaudeus/workrail 3.61.0 → 3.63.0

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.
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.writeStatsSummary = writeStatsSummary;
37
+ const fs = __importStar(require("fs/promises"));
38
+ const path = __importStar(require("path"));
39
+ const zod_1 = require("zod");
40
+ const ExecutionStatRecordSchema = zod_1.z.object({
41
+ sessionId: zod_1.z.string(),
42
+ workflowId: zod_1.z.string(),
43
+ startMs: zod_1.z.number(),
44
+ endMs: zod_1.z.number(),
45
+ durationMs: zod_1.z.number(),
46
+ outcome: zod_1.z.string(),
47
+ stepCount: zod_1.z.number(),
48
+ ts: zod_1.z.string(),
49
+ });
50
+ function percentile(sortedAsc, p) {
51
+ if (sortedAsc.length === 0)
52
+ return 0;
53
+ const idx = Math.ceil((p / 100) * sortedAsc.length) - 1;
54
+ return sortedAsc[Math.max(0, idx)];
55
+ }
56
+ function emptyStatsSummary() {
57
+ return {
58
+ version: 1,
59
+ generatedAt: new Date().toISOString(),
60
+ sessionCount: 0,
61
+ malformedLineCount: 0,
62
+ outcomeBreakdown: {},
63
+ durationMs: { avg: 0, min: 0, max: 0, p50: 0, p95: 0 },
64
+ stepCount: { avg: 0, min: 0, max: 0 },
65
+ byWorkflow: {},
66
+ oldestSessionTs: null,
67
+ newestSessionTs: null,
68
+ };
69
+ }
70
+ function aggregate(records, malformedLineCount) {
71
+ if (records.length === 0)
72
+ return { ...emptyStatsSummary(), malformedLineCount };
73
+ const durations = records.map((r) => r.durationMs).sort((a, b) => a - b);
74
+ const steps = records.map((r) => r.stepCount);
75
+ const outcomeBreakdown = {};
76
+ const byWorkflow = {};
77
+ let totalDuration = 0;
78
+ let totalSteps = 0;
79
+ let oldestTs = records[0].ts;
80
+ let newestTs = records[0].ts;
81
+ for (const r of records) {
82
+ outcomeBreakdown[r.outcome] = (outcomeBreakdown[r.outcome] ?? 0) + 1;
83
+ const wf = byWorkflow[r.workflowId] ?? { count: 0, successCount: 0, avgDurationMs: 0 };
84
+ const newCount = wf.count + 1;
85
+ const newAvgDuration = (wf.avgDurationMs * wf.count + r.durationMs) / newCount;
86
+ byWorkflow[r.workflowId] = {
87
+ count: newCount,
88
+ successCount: wf.successCount + (r.outcome === 'success' ? 1 : 0),
89
+ avgDurationMs: Math.round(newAvgDuration),
90
+ };
91
+ totalDuration += r.durationMs;
92
+ totalSteps += r.stepCount;
93
+ if (r.ts < oldestTs)
94
+ oldestTs = r.ts;
95
+ if (r.ts > newestTs)
96
+ newestTs = r.ts;
97
+ }
98
+ const n = records.length;
99
+ const minStep = steps.reduce((min, v) => (v < min ? v : min), Infinity);
100
+ const maxStep = steps.reduce((max, v) => (v > max ? v : max), -Infinity);
101
+ return {
102
+ version: 1,
103
+ generatedAt: new Date().toISOString(),
104
+ sessionCount: n,
105
+ malformedLineCount,
106
+ outcomeBreakdown,
107
+ durationMs: {
108
+ avg: Math.round(totalDuration / n),
109
+ min: durations[0],
110
+ max: durations[durations.length - 1],
111
+ p50: percentile(durations, 50),
112
+ p95: percentile(durations, 95),
113
+ },
114
+ stepCount: {
115
+ avg: Math.round((totalSteps / n) * 10) / 10,
116
+ min: minStep,
117
+ max: maxStep,
118
+ },
119
+ byWorkflow,
120
+ oldestSessionTs: oldestTs,
121
+ newestSessionTs: newestTs,
122
+ };
123
+ }
124
+ async function writeStatsSummary(statsDir) {
125
+ const jsonlPath = path.join(statsDir, 'execution-stats.jsonl');
126
+ const summaryPath = path.join(statsDir, 'stats-summary.json');
127
+ const tmpPath = `${summaryPath}.tmp`;
128
+ let content;
129
+ try {
130
+ content = await fs.readFile(jsonlPath, 'utf8');
131
+ }
132
+ catch (e) {
133
+ const code = e.code;
134
+ if (code === 'ENOENT') {
135
+ const empty = emptyStatsSummary();
136
+ await fs.mkdir(statsDir, { recursive: true });
137
+ await fs.writeFile(tmpPath, JSON.stringify(empty, null, 2), 'utf8');
138
+ await fs.rename(tmpPath, summaryPath);
139
+ return;
140
+ }
141
+ throw e;
142
+ }
143
+ const lines = content.split('\n').filter((l) => l.trim().length > 0);
144
+ const records = [];
145
+ let malformedLineCount = 0;
146
+ for (const line of lines) {
147
+ let parsed;
148
+ try {
149
+ parsed = JSON.parse(line);
150
+ }
151
+ catch {
152
+ malformedLineCount++;
153
+ continue;
154
+ }
155
+ const result = ExecutionStatRecordSchema.safeParse(parsed);
156
+ if (!result.success) {
157
+ malformedLineCount++;
158
+ continue;
159
+ }
160
+ records.push(result.data);
161
+ }
162
+ const summary = aggregate(records, malformedLineCount);
163
+ await fs.writeFile(tmpPath, JSON.stringify(summary, null, 2), 'utf8');
164
+ await fs.rename(tmpPath, summaryPath);
165
+ }
@@ -76,6 +76,7 @@ const index_js_2 = require("../v2/durable-core/ids/index.js");
76
76
  const node_outputs_js_1 = require("../v2/projections/node-outputs.js");
77
77
  const assert_never_js_1 = require("../runtime/assert-never.js");
78
78
  const session_recovery_policy_js_1 = require("./session-recovery-policy.js");
79
+ const stats_summary_js_1 = require("./stats-summary.js");
79
80
  const execAsync = (0, node_util_1.promisify)(node_child_process_1.exec);
80
81
  const execFileAsync = (0, node_util_1.promisify)(node_child_process_1.execFile);
81
82
  const BASH_TIMEOUT_MS = 5 * 60 * 1000;
@@ -1905,6 +1906,7 @@ async function runWorkflow(trigger, ctx, apiKey, daemonRegistry, emitter, steerR
1905
1906
  stepCount: stepAdvanceCount,
1906
1907
  ts: new Date().toISOString(),
1907
1908
  }) + '\n', 'utf8'))
1909
+ .then(() => { (0, stats_summary_js_1.writeStatsSummary)(statsDir).catch(() => { }); })
1908
1910
  .catch(() => { });
1909
1911
  }
1910
1912
  if (stuckReason !== null) {
@@ -238,8 +238,8 @@
238
238
  "bytes": 31
239
239
  },
240
240
  "cli-worktrain.js": {
241
- "sha256": "40de773bda9fde4e321b76f848af7486489750afb95ff6fb0438f0838c4eda7a",
242
- "bytes": 58701
241
+ "sha256": "c5ae39d3352b323aa1bedb560d37ec3ded94a74e4176ef2126e38c8d1380d9b4",
242
+ "bytes": 58959
243
243
  },
244
244
  "cli.d.ts": {
245
245
  "sha256": "43e818adf60173644896298637f47b01d5819b17eda46eaa32d0c7d64724d012",
@@ -462,8 +462,8 @@
462
462
  "bytes": 506
463
463
  },
464
464
  "config/config-file.js": {
465
- "sha256": "0cc52af9582758062c0de48ec44d34bf4d012a4831d5075543a40b79125aa7e2",
466
- "bytes": 7170
465
+ "sha256": "238bdf28fbc3ad9054ae7f905104cade74aae2da94f963859311dc81e35e5e93",
466
+ "bytes": 7204
467
467
  },
468
468
  "config/feature-flags.d.ts": {
469
469
  "sha256": "49cdf81a9c4f31eca560af5257c569143d2138ec996468b949f9807b7ad7802e",
@@ -473,16 +473,16 @@
473
473
  "sha256": "5fe866e54f796975dec5d8ba9983aefd86074db212d3fccd64eed04bc9f0b3da",
474
474
  "bytes": 8011
475
475
  },
476
+ "console-ui/assets/index--iTwSwxZ.js": {
477
+ "sha256": "0fd3455198e67edc403ca0a8f4df4292ad532b5e2cc6e8a1dea7926ca67d4e81",
478
+ "bytes": 760528
479
+ },
476
480
  "console-ui/assets/index-DGj8EsFR.css": {
477
481
  "sha256": "3bdb55ec0957928e0ebbb86a7d6b36d28f7ba7d5c0f3e236fd8f2e2aacee2fa4",
478
482
  "bytes": 60631
479
483
  },
480
- "console-ui/assets/index-DZpicVbF.js": {
481
- "sha256": "63e1eb6134d4bf95c279e646796f6fac09d3d206f72c5e07bcc944fcaf3a108c",
482
- "bytes": 760528
483
- },
484
484
  "console-ui/index.html": {
485
- "sha256": "ebdc97ab0d0b277f907b8e840e3e4036949de791bd202d5032788d38177c0c8e",
485
+ "sha256": "3862bde6c9f8bdbe2d52b4a3e16071343c92a984f867b724989d84f631a74786",
486
486
  "bytes": 417
487
487
  },
488
488
  "console/standalone-console.d.ts": {
@@ -645,13 +645,21 @@
645
645
  "sha256": "d7c425a03d9a39994a2a961470a892bc8c5936b697b6a59fa161d19d72825015",
646
646
  "bytes": 1512
647
647
  },
648
+ "daemon/stats-summary.d.ts": {
649
+ "sha256": "2136d6f7345fe54c2b881757aa26062dbd1ed54d75e0df5feecd4c0588571c6b",
650
+ "bytes": 76
651
+ },
652
+ "daemon/stats-summary.js": {
653
+ "sha256": "485b7407433f7246af41b6895dd8973efeb05228a9791f327e1dbc581a5c7ef8",
654
+ "bytes": 5921
655
+ },
648
656
  "daemon/workflow-runner.d.ts": {
649
657
  "sha256": "784dea8d1b86c162bd025706273e07e622cef8bfeeee5c465e09b92f1552dfbd",
650
658
  "bytes": 8114
651
659
  },
652
660
  "daemon/workflow-runner.js": {
653
- "sha256": "a12c7aeda1d3e8942d1fc70bbbdfe82ac3dc16de6f8500784a314325defa028b",
654
- "bytes": 101260
661
+ "sha256": "2718b3dcf42846c3aec5ae6533c377bf58c0dc1c9f450d0cc016649296ae39af",
662
+ "bytes": 101417
655
663
  },
656
664
  "di/container.d.ts": {
657
665
  "sha256": "003bb7fb7478d627524b9b1e76bd0a963a243794a687ff233b96dc0e33a06d9f",
@@ -2334,8 +2342,8 @@
2334
2342
  "bytes": 3397
2335
2343
  },
2336
2344
  "v2/durable-core/schemas/export-bundle/index.d.ts": {
2337
- "sha256": "9432b699d0cdc1db78d37181d8a6f72c669a5c2be7db7a915a44c783b0cb70c5",
2338
- "bytes": 544060
2345
+ "sha256": "fbfe9402f6c1d33a09c59e837273a215004e4097c55944a1d4ee9c0e1701a12d",
2346
+ "bytes": 541500
2339
2347
  },
2340
2348
  "v2/durable-core/schemas/export-bundle/index.js": {
2341
2349
  "sha256": "6e3566b2d05ea6302bbf4d311b8ec3e94725a8523834efe7670a79e7bd7dc40d",
@@ -2390,12 +2398,12 @@
2390
2398
  "bytes": 2138
2391
2399
  },
2392
2400
  "v2/durable-core/schemas/session/events.d.ts": {
2393
- "sha256": "452cb4e020188c0699e5a3bc083a0c66ebdfe5f8506d41fb9f556cd6e3631bb9",
2394
- "bytes": 82692
2401
+ "sha256": "03acab288311da5c383e28af92e7a9995d3d85ea88f1ad3c259366465ebdcc78",
2402
+ "bytes": 81995
2395
2403
  },
2396
2404
  "v2/durable-core/schemas/session/events.js": {
2397
- "sha256": "92246ae89fd3af24571c3909cf56a9e27ff1dcc15d7ea774e60fef75d1a03841",
2398
- "bytes": 13013
2405
+ "sha256": "f67d047d2e22e55ef32cfeb74c01aa43f952424a1a8af426918276835951bc24",
2406
+ "bytes": 13002
2399
2407
  },
2400
2408
  "v2/durable-core/schemas/session/gaps.d.ts": {
2401
2409
  "sha256": "85d17b865a1ebe9deaa0c99d69039c514b217362715c6697b0bc5908cbf9fff0",