@goodandready/dsh-cron 0.3.42 → 0.3.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/lib/client.js +998 -3987
  2. package/lib/llm-ask.js +2 -1
  3. package/lib/routes/api-actions.js +36 -6
  4. package/lib/routes/api-item.js +1 -1
  5. package/lib/routes/api-webhook.js +2 -4
  6. package/lib/runtimes/runner-external.js +2 -3
  7. package/lib/runtimes/runner-session.js +385 -0
  8. package/lib/runtimes/runner-turn.js +255 -0
  9. package/lib/runtimes/runner.js +43 -616
  10. package/lib/scheduler/scheduler-execution.js +4 -1
  11. package/lib/scheduler/scheduler-lifecycle.js +65 -0
  12. package/lib/scheduler/scheduler-parser.js +261 -0
  13. package/lib/scheduler/scheduler.js +24 -319
  14. package/lib/store/store-archive.js +195 -0
  15. package/lib/store/store-io.js +331 -0
  16. package/lib/store/store-loader.js +165 -0
  17. package/lib/store/store-migration.js +38 -0
  18. package/lib/store/store-settings.js +126 -0
  19. package/lib/store/store-stats.js +55 -0
  20. package/lib/store/store.js +127 -810
  21. package/package.json +8 -6
  22. package/lib/client-src/00-open.js +0 -63
  23. package/lib/client-src/10-locales.js +0 -540
  24. package/lib/client-src/20-styles.js +0 -64
  25. package/lib/client-src/30-utils.js +0 -372
  26. package/lib/client-src/40-delivery-settings.js +0 -96
  27. package/lib/client-src/45-dag-graph-view.js +0 -287
  28. package/lib/client-src/46-live-logs-modal.js +0 -108
  29. package/lib/client-src/47-analytics-digest-modal.js +0 -166
  30. package/lib/client-src/48-timeline-heatmap-view.js +0 -176
  31. package/lib/client-src/50-cron-screen-state.js +0 -457
  32. package/lib/client-src/52-cron-screen-actions.js +0 -330
  33. package/lib/client-src/53-cron-screen-modal-actions.js +0 -677
  34. package/lib/client-src/54-cron-screen-analytics-actions.js +0 -68
  35. package/lib/client-src/55-cron-screen-view.js +0 -378
  36. package/lib/client-src/60-modal-task-form-head.js +0 -581
  37. package/lib/client-src/62-modal-task-form-tail.js +0 -563
  38. package/lib/client-src/65-modal-dialogs.js +0 -350
  39. package/lib/client-src/70-settings-card.js +0 -453
  40. package/lib/client-src/75-quick-action-bar.js +0 -146
  41. package/lib/client-src/80-sidebar-jobs.js +0 -200
  42. package/lib/client-src/90-close.js +0 -219
@@ -0,0 +1,55 @@
1
+ export function getTaskStats(store, id) {
2
+ const runs = store.history.get(id) || [];
3
+ const total = runs.length;
4
+ let success = 0;
5
+ let error = 0;
6
+ let timeout = 0;
7
+ const recentDurations = [];
8
+
9
+ for (let i = 0; i < runs.length; i++) {
10
+ const r = runs[i];
11
+ if (r.status === 'success') success++;
12
+ else if (r.status === 'error') error++;
13
+ else if (r.status === 'timeout') timeout++;
14
+
15
+ if (recentDurations.length < 10 && r.durationMs !== undefined) {
16
+ recentDurations.push({
17
+ at: r.at,
18
+ durationMs: r.durationMs,
19
+ status: r.status,
20
+ });
21
+ }
22
+ }
23
+
24
+ const successRate = total > 0 ? Number((success / total).toFixed(2)) : 1.0;
25
+ return {
26
+ totalRuns: total,
27
+ successRuns: success,
28
+ errorRuns: error,
29
+ timeoutRuns: timeout,
30
+ successRate,
31
+ recentDurations,
32
+ };
33
+ }
34
+
35
+ export function getAggregatedStats(store) {
36
+ let totalRuns = 0;
37
+ let totalTokens = 0;
38
+ let totalCostUsd = 0;
39
+ let activeTasks = 0;
40
+
41
+ for (const t of store.tasks.values()) {
42
+ if (t.status === 'active') activeTasks++;
43
+ totalTokens += (t.totalTokens || 0);
44
+ totalCostUsd += (t.totalCostUsd || 0);
45
+ const h = store.history.get(t.id) || [];
46
+ totalRuns += h.length;
47
+ }
48
+
49
+ return {
50
+ activeTasks,
51
+ totalRuns,
52
+ totalTokens,
53
+ totalCostUsd: Number(totalCostUsd.toFixed(4)),
54
+ };
55
+ }