@jive-sh/workflow-platform 0.7.0 → 1.1.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.
- package/README.md +70 -435
- package/component/_generated/api.ts +72 -0
- package/component/_generated/component.ts +629 -0
- package/component/_generated/dataModel.ts +60 -0
- package/component/_generated/server.ts +169 -0
- package/component/convex.config.ts +3 -0
- package/component/engine.ts +756 -0
- package/component/errors.ts +66 -0
- package/component/events.ts +17 -0
- package/component/notes.ts +19 -0
- package/component/places.ts +136 -0
- package/component/retention.ts +205 -0
- package/component/runEngine.ts +25 -0
- package/component/schema.ts +135 -0
- package/component/steps.ts +188 -0
- package/component/store.ts +513 -0
- package/component/tasks.ts +290 -0
- package/component/worker.ts +109 -0
- package/component/workflows.ts +83 -0
- package/dist/definition/agent-runner.js +9 -0
- package/dist/definition/agent-runner.js.map +1 -0
- package/dist/definition/file-store.js +9 -0
- package/dist/definition/file-store.js.map +1 -0
- package/dist/definition/program-build.js +10 -0
- package/dist/definition/program-build.js.map +1 -0
- package/dist/definition/step.js +1 -0
- package/dist/definition/step.js.map +1 -0
- package/dist/definition/task-schema.js +5 -0
- package/dist/definition/task-schema.js.map +1 -0
- package/dist/definition/tasks.js +9 -0
- package/dist/definition/tasks.js.map +1 -0
- package/dist/definition/workflow.js +117 -0
- package/dist/definition/workflow.js.map +1 -0
- package/dist/graph.js +310 -9
- package/dist/graph.js.map +1 -1
- package/dist/index.js +7 -196
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
- package/src/definition/agent-runner.ts +59 -0
- package/src/definition/file-store.ts +20 -0
- package/src/definition/program-build.ts +30 -0
- package/src/definition/step.ts +106 -0
- package/src/definition/task-schema.ts +15 -0
- package/src/definition/tasks.ts +43 -0
- package/src/definition/workflow.ts +262 -0
- package/src/graph.ts +352 -19
- package/src/index.ts +8 -238
- package/worker/directory-file-store.ts +42 -0
- package/worker/index.ts +12 -0
- package/worker/platform-client.ts +144 -0
- package/worker/step-meter.ts +80 -0
- package/worker/worker-tasks.ts +27 -0
- package/worker/worker.test.ts +200 -0
- package/worker/worker.ts +240 -0
- package/dist/budget-states.js +0 -30
- package/dist/budget-states.js.map +0 -1
- package/dist/cpu-limit/limiter.js +0 -839
- package/dist/cpu-limit/limiter.js.map +0 -1
- package/dist/cpu-limit/use.js +0 -139
- package/dist/cpu-limit/use.js.map +0 -1
- package/dist/dashboard/agent-usage.js +0 -25
- package/dist/dashboard/agent-usage.js.map +0 -1
- package/dist/dashboard/dashboard.css +0 -148
- package/dist/dashboard/drilldown.js +0 -47
- package/dist/dashboard/drilldown.js.map +0 -1
- package/dist/dashboard/queue-lines.js +0 -44
- package/dist/dashboard/queue-lines.js.map +0 -1
- package/dist/dashboard/queue-table.js +0 -16
- package/dist/dashboard/queue-table.js.map +0 -1
- package/dist/dashboard/run-doing-words.js +0 -29
- package/dist/dashboard/run-doing-words.js.map +0 -1
- package/dist/dashboard/setting-words.js +0 -18
- package/dist/dashboard/setting-words.js.map +0 -1
- package/dist/dashboard/spending-words.js +0 -24
- package/dist/dashboard/spending-words.js.map +0 -1
- package/dist/failure.js +0 -35
- package/dist/failure.js.map +0 -1
- package/dist/keep-running.js +0 -79
- package/dist/keep-running.js.map +0 -1
- package/dist/outside-failure.js +0 -31
- package/dist/outside-failure.js.map +0 -1
- package/dist/pick-wakes.js +0 -125
- package/dist/pick-wakes.js.map +0 -1
- package/dist/project.js +0 -1
- package/dist/project.js.map +0 -1
- package/dist/queue-counts.js +0 -51
- package/dist/queue-counts.js.map +0 -1
- package/dist/reasons.js +0 -33
- package/dist/reasons.js.map +0 -1
- package/dist/retention.js +0 -59
- package/dist/retention.js.map +0 -1
- package/dist/settings.js +0 -88
- package/dist/settings.js.map +0 -1
- package/dist/spending-limit.js +0 -82
- package/dist/spending-limit.js.map +0 -1
- package/dist/step-files.js +0 -200
- package/dist/step-files.js.map +0 -1
- package/dist/step-meter.js +0 -97
- package/dist/step-meter.js.map +0 -1
- package/dist/step-times.js +0 -114
- package/dist/step-times.js.map +0 -1
- package/dist/step-usage.js +0 -19
- package/dist/step-usage.js.map +0 -1
- package/dist/steps.js +0 -1205
- package/dist/steps.js.map +0 -1
- package/dist/storage/agent-claims.js +0 -3
- package/dist/storage/agent-claims.js.map +0 -1
- package/dist/storage/budgets.js +0 -121
- package/dist/storage/budgets.js.map +0 -1
- package/dist/storage/engine-records.js +0 -91
- package/dist/storage/engine-records.js.map +0 -1
- package/dist/storage/engine-storage.js +0 -67
- package/dist/storage/engine-storage.js.map +0 -1
- package/dist/storage/input-records.js +0 -12
- package/dist/storage/input-records.js.map +0 -1
- package/dist/storage/move-store.js +0 -251
- package/dist/storage/move-store.js.map +0 -1
- package/dist/storage/sqlite-store.js +0 -901
- package/dist/storage/sqlite-store.js.map +0 -1
- package/dist/storage/step-records.js +0 -11
- package/dist/storage/step-records.js.map +0 -1
- package/dist/storage/storage-error.js +0 -19
- package/dist/storage/storage-error.js.map +0 -1
- package/dist/storage/task-store.js +0 -30
- package/dist/storage/task-store.js.map +0 -1
- package/dist/system-workflows.js +0 -54
- package/dist/system-workflows.js.map +0 -1
- package/dist/tasks.js +0 -500
- package/dist/tasks.js.map +0 -1
- package/dist/views/format.js +0 -37
- package/dist/views/format.js.map +0 -1
- package/dist/views/runs-now.js +0 -117
- package/dist/views/runs-now.js.map +0 -1
- package/dist/views/step-funnel.js +0 -98
- package/dist/views/step-funnel.js.map +0 -1
- package/dist/views/step-graph.js +0 -39
- package/dist/views/step-graph.js.map +0 -1
- package/dist/views/workflows-view.js +0 -236
- package/dist/views/workflows-view.js.map +0 -1
- package/src/budget-states.ts +0 -54
- package/src/cpu-limit/limiter.ts +0 -935
- package/src/cpu-limit/use.ts +0 -166
- package/src/dashboard/agent-usage-line.tsx +0 -28
- package/src/dashboard/agent-usage.ts +0 -48
- package/src/dashboard/dashboard.css +0 -148
- package/src/dashboard/drilldown.ts +0 -70
- package/src/dashboard/index.tsx +0 -4
- package/src/dashboard/limits-and-runs.tsx +0 -191
- package/src/dashboard/machine-controls.tsx +0 -53
- package/src/dashboard/queue-bar.tsx +0 -62
- package/src/dashboard/queue-chart.tsx +0 -149
- package/src/dashboard/queue-lines.ts +0 -87
- package/src/dashboard/queue-table.ts +0 -37
- package/src/dashboard/run-doing-words.ts +0 -41
- package/src/dashboard/setting-words.ts +0 -30
- package/src/dashboard/spending-limit-control.tsx +0 -47
- package/src/dashboard/spending-words.ts +0 -32
- package/src/dashboard/time-distribution.tsx +0 -61
- package/src/dashboard/workflow-dag.tsx +0 -322
- package/src/dashboard/workflow-drilldown.tsx +0 -31
- package/src/dashboard/workflows-dashboard.tsx +0 -532
- package/src/failure.ts +0 -36
- package/src/keep-running.ts +0 -85
- package/src/outside-failure.ts +0 -39
- package/src/pick-wakes.ts +0 -182
- package/src/project.ts +0 -127
- package/src/queue-counts.ts +0 -64
- package/src/reasons.ts +0 -30
- package/src/retention.ts +0 -90
- package/src/settings.ts +0 -171
- package/src/spending-limit.ts +0 -139
- package/src/step-files.ts +0 -208
- package/src/step-meter.ts +0 -120
- package/src/step-times.ts +0 -151
- package/src/step-usage.ts +0 -23
- package/src/steps.ts +0 -1616
- package/src/storage/agent-claims.ts +0 -63
- package/src/storage/budgets.ts +0 -152
- package/src/storage/engine-records.ts +0 -119
- package/src/storage/engine-storage.ts +0 -82
- package/src/storage/input-records.ts +0 -43
- package/src/storage/move-store.ts +0 -265
- package/src/storage/sqlite-store.ts +0 -1022
- package/src/storage/step-records.ts +0 -358
- package/src/storage/storage-error.ts +0 -35
- package/src/storage/task-store.ts +0 -235
- package/src/system-workflows.ts +0 -70
- package/src/tasks.ts +0 -586
- package/src/views/format.ts +0 -40
- package/src/views/runs-now.ts +0 -188
- package/src/views/step-funnel.ts +0 -163
- package/src/views/step-graph.ts +0 -77
- package/src/views/workflows-view.ts +0 -484
- package/src/workflow-dag.test.tsx +0 -89
- package/src/workflow-page.test.tsx +0 -170
package/dist/views/runs-now.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { isMadeOfWorkflows } from '../steps';
|
|
2
|
-
const sum = (xs, f) => xs.reduce((a, x) => a + f(x), 0);
|
|
3
|
-
/** The order `doing` lists its kinds in: runs holding an agent first, then other steps, then no step. */
|
|
4
|
-
export const RUN_DOING_ORDER = ['holding an agent', 'in a step', 'waiting at a step', 'between steps', 'not started'];
|
|
5
|
-
/**
|
|
6
|
-
* The agents a run holds: its own claim, the claims of the runs under it (each names the run at its top, which reaches a run
|
|
7
|
-
* whose sub-workflow step's record a restart closed while it waited), or the run its open sub-workflow step started, at any
|
|
8
|
-
* depth; 0 for none.
|
|
9
|
-
*/
|
|
10
|
-
const agentsHeld = (run, newest, claimed, depth = 0) => {
|
|
11
|
-
const own = claimed.get(run);
|
|
12
|
-
if (own !== undefined)
|
|
13
|
-
return own;
|
|
14
|
-
const r = newest.get(run);
|
|
15
|
-
return r === undefined || r.ended !== null || r.childRun === undefined || r.childRun === null || depth > 8 ? 0 : agentsHeld(r.childRun, newest, claimed, depth + 1);
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* What a run whose newest record is `r` is doing (`RunDoing`), once it holds no agent. A sub-workflow step's record is read
|
|
19
|
-
* through to the run it started: a run inside a sub-workflow's step read as in that step, on the page of the workflow above.
|
|
20
|
-
*/
|
|
21
|
-
const doingOf = (r, newest, depth = 0) => {
|
|
22
|
-
if (r.ended !== null)
|
|
23
|
-
return { kind: 'between steps' };
|
|
24
|
-
const under = r.childRun === undefined || r.childRun === null || depth > 8 ? undefined : newest.get(r.childRun);
|
|
25
|
-
if (under !== undefined)
|
|
26
|
-
return doingOf(under, newest, depth + 1);
|
|
27
|
-
return r.waiting === null ? { kind: 'in a step', step: r.step } : { kind: 'waiting at a step', step: r.step };
|
|
28
|
-
};
|
|
29
|
-
/** Counts that do the same thing added together, in `RUN_DOING_ORDER`, a kind's steps in the order first counted. */
|
|
30
|
-
const addUpDoing = (counts) => {
|
|
31
|
-
const keyOf = (d) => ('step' in d ? `${d.kind}\u0000${d.step}` : d.kind);
|
|
32
|
-
const added = new Map();
|
|
33
|
-
for (const c of counts)
|
|
34
|
-
added.set(keyOf(c.doing), { doing: c.doing, runs: (added.get(keyOf(c.doing))?.runs ?? 0) + c.runs });
|
|
35
|
-
return [...added.values()].filter((c) => c.runs > 0).sort((a, b) => RUN_DOING_ORDER.indexOf(a.doing.kind) - RUN_DOING_ORDER.indexOf(b.doing.kind));
|
|
36
|
-
};
|
|
37
|
-
const workflowRunsNow = (d, runs, newest, claimed) => {
|
|
38
|
-
const records = runs.flatMap((run) => {
|
|
39
|
-
const r = newest.get(run);
|
|
40
|
-
return r === undefined ? [] : [r];
|
|
41
|
-
});
|
|
42
|
-
const held = runs.map((run) => agentsHeld(run, newest, claimed));
|
|
43
|
-
const doing = addUpDoing([
|
|
44
|
-
...runs.map((run, i) => {
|
|
45
|
-
const r = newest.get(run);
|
|
46
|
-
return { doing: held[i] > 0 ? { kind: 'holding an agent' } : r === undefined ? { kind: 'not started' } : doingOf(r, newest), runs: 1 };
|
|
47
|
-
}),
|
|
48
|
-
]);
|
|
49
|
-
const declared = d.steps().map((s) => ({ name: s.name, agent: s.runs === 'agentic' }));
|
|
50
|
-
const undeclared = [...new Set(records.map((r) => r.step))].filter((name) => !declared.some((s) => s.name === name))
|
|
51
|
-
.map((name) => ({ name, agent: records.some((r) => r.step === name && r.agent === 1) }));
|
|
52
|
-
const steps = [...declared, ...undeclared].map((s) => {
|
|
53
|
-
const on = records.filter((r) => r.step === s.name);
|
|
54
|
-
const waiting = on.flatMap((r) => (r.ended === null ? [] : [r.ended]));
|
|
55
|
-
return {
|
|
56
|
-
step: s.name, agent: s.agent,
|
|
57
|
-
inStep: on.length - waiting.length,
|
|
58
|
-
waitingAfter: waiting.length,
|
|
59
|
-
waitingSince: waiting.length === 0 ? null : Math.min(...waiting),
|
|
60
|
-
waitingOn: on.find((r) => r.ended === null && r.waiting !== null)?.waiting ?? null,
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
return {
|
|
64
|
-
workflow: d.name,
|
|
65
|
-
runs: runs.length,
|
|
66
|
-
doing,
|
|
67
|
-
onAgents: sum(held, (n) => n),
|
|
68
|
-
notStarted: runs.length - records.length,
|
|
69
|
-
steps,
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Every workflow, in the order declared, running or not, then each workflow no file defines now that a run is of: each run
|
|
74
|
-
* counted once, on its own workflow. One made of workflows has no runs of its own (`steps.ts` `isMadeOfWorkflows`): its runs
|
|
75
|
-
* and agents are its steps', added up, at every depth, and each of its step's rows is that workflow's runs.
|
|
76
|
-
*/
|
|
77
|
-
export const runsNow = (input) => {
|
|
78
|
-
const newest = new Map(input.newest.map((r) => [r.run, r]));
|
|
79
|
-
// Each claim counts for its own run and for the run at its top, which holds it for the work below it.
|
|
80
|
-
const claimed = new Map();
|
|
81
|
-
for (const c of input.claims) {
|
|
82
|
-
claimed.set(c.run, (claimed.get(c.run) ?? 0) + c.agents);
|
|
83
|
-
if (c.top !== undefined && c.top.run !== c.run)
|
|
84
|
-
claimed.set(c.top.run, (claimed.get(c.top.run) ?? 0) + c.agents);
|
|
85
|
-
}
|
|
86
|
-
const names = new Set(input.declared.map((d) => d.name));
|
|
87
|
-
const all = [
|
|
88
|
-
...input.declared,
|
|
89
|
-
...[...new Set(input.unfinished.map((u) => u.workflow))].filter((w) => !names.has(w)).map((name) => ({ name, steps: () => [] })),
|
|
90
|
-
];
|
|
91
|
-
const byName = new Map(all.map((d) => [d.name, d]));
|
|
92
|
-
const counted = new Map();
|
|
93
|
-
const runsOf = (d, depth = 0) => {
|
|
94
|
-
const known = counted.get(d.name);
|
|
95
|
-
if (known !== undefined)
|
|
96
|
-
return known;
|
|
97
|
-
if (!isMadeOfWorkflows(d) || depth > 8) {
|
|
98
|
-
const own = workflowRunsNow(d, input.unfinished.filter((u) => u.workflow === d.name).map((u) => u.run), newest, claimed);
|
|
99
|
-
counted.set(d.name, own);
|
|
100
|
-
return own;
|
|
101
|
-
}
|
|
102
|
-
const under = d.steps().map((s) => ({ step: s.name, runs: s.workflow === undefined || byName.get(s.workflow) === undefined ? null : runsOf(byName.get(s.workflow), depth + 1) }));
|
|
103
|
-
const doing = addUpDoing(under.flatMap((u) => u.runs?.doing ?? []));
|
|
104
|
-
const made = {
|
|
105
|
-
workflow: d.name,
|
|
106
|
-
runs: sum(under, (u) => u.runs?.runs ?? 0),
|
|
107
|
-
doing,
|
|
108
|
-
onAgents: sum(under, (u) => u.runs?.onAgents ?? 0),
|
|
109
|
-
notStarted: 0,
|
|
110
|
-
steps: under.map((u) => ({ step: u.step, agent: false, inStep: u.runs?.runs ?? 0, waitingAfter: 0, waitingSince: null, waitingOn: null })),
|
|
111
|
-
};
|
|
112
|
-
counted.set(d.name, made);
|
|
113
|
-
return made;
|
|
114
|
-
};
|
|
115
|
-
return all.map((d) => runsOf(d));
|
|
116
|
-
};
|
|
117
|
-
//# sourceMappingURL=runs-now.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runs-now.js","sourceRoot":"","sources":["../../../../src/views/runs-now.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAwB,MAAM,UAAU,CAAC;AAuDnE,MAAM,GAAG,GAAG,CAAI,EAAoB,EAAE,CAAmB,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE/F,yGAAyG;AACzG,MAAM,CAAC,MAAM,eAAe,GAAoC,CAAC,kBAAkB,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;AAEvJ;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,MAA6C,EAAE,OAAoC,EAAE,KAAK,GAAG,CAAC,EAAU,EAAE;IACzI,MAAM,GAAG,GAAG,OAAO,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E,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;SACxJ,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IACF,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { oneLine } from '../reasons';
|
|
2
|
-
/** The windows the page offers: the last hour, and the last day. */
|
|
3
|
-
export const FUNNEL_WINDOW_HOURS = [1, 24];
|
|
4
|
-
/** Reasons listed under the step most runs stopped at; the rest are counted together. */
|
|
5
|
-
export const TOP_STOP_REASONS = 3;
|
|
6
|
-
/** The commonest of a run's item outcomes, so a batch run gives one reason. */
|
|
7
|
-
const commonest = (xs) => {
|
|
8
|
-
const counts = new Map();
|
|
9
|
-
for (const x of xs)
|
|
10
|
-
counts.set(x, (counts.get(x) ?? 0) + 1);
|
|
11
|
-
return [...counts.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0][0];
|
|
12
|
-
};
|
|
13
|
-
/** Why a run stopped where it did: its item's outcome first, then the reason its last step recorded (`reasons.ts`). */
|
|
14
|
-
const stopReason = (last, outcomes) => {
|
|
15
|
-
if (last.outcome === 'failure')
|
|
16
|
-
return last.error === null ? last.reason ?? 'its step failed with no error recorded' : oneLine(last.error);
|
|
17
|
-
if (outcomes.length > 0)
|
|
18
|
-
return oneLine(commonest(outcomes.map((o) => o.outcome)));
|
|
19
|
-
if (last.reason !== null && last.reason !== 'succeeded')
|
|
20
|
-
return last.reason;
|
|
21
|
-
if (last.scope === 'nothing')
|
|
22
|
-
return 'found nothing to work on';
|
|
23
|
-
if (last.outcome === 'interrupted')
|
|
24
|
-
return 'interrupted';
|
|
25
|
-
if (last.ended === null)
|
|
26
|
-
return 'ended during the step, with no end recorded';
|
|
27
|
-
return 'ended with no outcome recorded';
|
|
28
|
-
};
|
|
29
|
-
/** Rows by their run, each run's in the order given. */
|
|
30
|
-
const groupBy = (rows) => {
|
|
31
|
-
const out = new Map();
|
|
32
|
-
for (const r of rows) {
|
|
33
|
-
const list = out.get(r.run);
|
|
34
|
-
if (list === undefined)
|
|
35
|
-
out.set(r.run, [r]);
|
|
36
|
-
else
|
|
37
|
-
list.push(r);
|
|
38
|
-
}
|
|
39
|
-
return out;
|
|
40
|
-
};
|
|
41
|
-
const median = (xs) => {
|
|
42
|
-
if (xs.length === 0)
|
|
43
|
-
return null;
|
|
44
|
-
const sorted = [...xs].sort((a, b) => a - b);
|
|
45
|
-
const mid = Math.floor(sorted.length / 2);
|
|
46
|
-
return sorted.length % 2 === 1 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
47
|
-
};
|
|
48
|
-
/** One workflow's funnel over the `hours` before `now`, from its records in that window or a wider one. */
|
|
49
|
-
export const stepFunnel = (input) => {
|
|
50
|
-
// Records are read after `now` was fixed: what started later is outside the window the page states.
|
|
51
|
-
const byRun = groupBy(input.records.filter((r) => r.started <= input.now));
|
|
52
|
-
const runs = [...byRun.entries()].filter(([, rs]) => Math.min(...rs.map((r) => r.started)) >= input.since);
|
|
53
|
-
const outcomesOf = groupBy(input.outcomes);
|
|
54
|
-
const ends = runs.filter(([run]) => !input.unfinished.has(run)).map(([run, rs]) => {
|
|
55
|
-
const last = rs[rs.length - 1];
|
|
56
|
-
const theirs = outcomesOf.get(run) ?? [];
|
|
57
|
-
const finished = input.declaration.item === null ? last.outcome === 'success' : theirs.some((o) => o.finished === 1);
|
|
58
|
-
return { step: last.step, finished, reason: finished ? null : stopReason(last, theirs) };
|
|
59
|
-
});
|
|
60
|
-
const declared = input.declaration.steps().map((s) => ({ name: s.name, agent: s.runs === 'agentic' }));
|
|
61
|
-
const undeclared = [...new Set(runs.flatMap(([, rs]) => rs.map((r) => r.step)))].filter((name) => !declared.some((s) => s.name === name))
|
|
62
|
-
.map((name) => ({ name, agent: runs.some(([, rs]) => rs.some((r) => r.step === name && r.agent === 1)) }));
|
|
63
|
-
const counted = [...declared, ...undeclared].map((s) => {
|
|
64
|
-
const timed = runs.flatMap(([, rs]) => {
|
|
65
|
-
const ended = rs.filter((r) => r.step === s.name && r.ended !== null);
|
|
66
|
-
return ended.length === 0 ? [] : [ended.reduce((a, r) => a + (r.ended - r.started), 0)];
|
|
67
|
-
});
|
|
68
|
-
return {
|
|
69
|
-
step: s.name, agent: s.agent,
|
|
70
|
-
reached: runs.filter(([, rs]) => rs.some((r) => r.step === s.name)).length,
|
|
71
|
-
stopped: ends.filter((e) => e.step === s.name && !e.finished).length,
|
|
72
|
-
finished: ends.filter((e) => e.step === s.name && e.finished).length,
|
|
73
|
-
medianSeconds: median(timed),
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
const steps = counted.map((s, i) => ({
|
|
77
|
-
...s,
|
|
78
|
-
noneGotPast: i < declared.length - 1 && s.reached > 0 && s.stopped === s.reached && counted[i + 1].reached === 0,
|
|
79
|
-
}));
|
|
80
|
-
const most = steps.reduce((best, s) => (s.stopped > 0 && (best === null || s.stopped > best.stopped) ? s : best), null);
|
|
81
|
-
const mostStopped = most === null ? null : (() => {
|
|
82
|
-
const counts = new Map();
|
|
83
|
-
for (const e of ends)
|
|
84
|
-
if (e.step === most.step && e.reason !== null)
|
|
85
|
-
counts.set(e.reason, (counts.get(e.reason) ?? 0) + 1);
|
|
86
|
-
const reasons = [...counts.entries()].map(([reason, n]) => ({ reason, runs: n })).sort((a, b) => b.runs - a.runs || a.reason.localeCompare(b.reason));
|
|
87
|
-
const top = reasons.slice(0, TOP_STOP_REASONS);
|
|
88
|
-
return { step: most.step, stopped: most.stopped, reasons: top, otherRuns: most.stopped - top.reduce((a, r) => a + r.runs, 0) };
|
|
89
|
-
})();
|
|
90
|
-
return {
|
|
91
|
-
hours: input.hours, since: input.since, now: input.now,
|
|
92
|
-
runs: runs.length,
|
|
93
|
-
going: runs.filter(([run]) => input.unfinished.has(run)).length,
|
|
94
|
-
steps,
|
|
95
|
-
mostStopped,
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
//# sourceMappingURL=step-funnel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"step-funnel.js","sourceRoot":"","sources":["../../../../src/views/step-funnel.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA0CrC,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,EAAE,EAAE,CAAU,CAAC;AAEpD,yFAAyF;AACzF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAIlC,+EAA+E;AAC/E,MAAM,SAAS,GAAG,CAAC,EAAyB,EAAU,EAAE;IACtD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE;QAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC;AAC9F,CAAC,CAAC;AAEF,uHAAuH;AACvH,MAAM,UAAU,GAAG,CAAC,IAAsB,EAAE,QAAsC,EAAU,EAAE;IAC5F,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAA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C,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;QAC/D,KAAK;QACL,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/views/step-graph.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { A_STEP_FAILS, isRetry, RUN_ENDS, RUN_STARTS } from '../graph';
|
|
2
|
-
/** The graph of a workflow that declares none: the run's start, each step in the order declared, the run's end. Pure. */
|
|
3
|
-
export const inOrder = (steps) => {
|
|
4
|
-
const names = [RUN_STARTS, ...steps.map((s) => s.name), RUN_ENDS];
|
|
5
|
-
return names.slice(1).map((to, i) => ({ from: names[i], to, when: '' }));
|
|
6
|
-
};
|
|
7
|
-
export const workflowGraphs = (input) => input.declared.map((d) => {
|
|
8
|
-
const graph = d.graph?.() ?? inOrder(d.steps());
|
|
9
|
-
const runs = new Map(graph.map((e) => [`${e.from}\u0000${e.to}`, 0]));
|
|
10
|
-
const undeclared = new Map();
|
|
11
|
-
const count = (from, failed, to, n) => {
|
|
12
|
-
if (isRetry({ step: from, failed }, to))
|
|
13
|
-
return;
|
|
14
|
-
const exact = `${from}\u0000${to}`;
|
|
15
|
-
const onFailure = `${A_STEP_FAILS}\u0000${to}`;
|
|
16
|
-
const key = runs.has(exact) ? exact : failed && runs.has(onFailure) ? onFailure : null;
|
|
17
|
-
if (key !== null) {
|
|
18
|
-
runs.set(key, (runs.get(key) ?? 0) + n);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const shown = { from: failed ? `${from} (failed)` : from, to };
|
|
22
|
-
const k = `${shown.from}\u0000${to}`;
|
|
23
|
-
undeclared.set(k, { ...shown, runs: (undeclared.get(k)?.runs ?? 0) + n });
|
|
24
|
-
};
|
|
25
|
-
for (const e of input.taken)
|
|
26
|
-
if (e.workflow === d.name)
|
|
27
|
-
count(e.from ?? RUN_STARTS, e.fromFailed, e.to, e.runs);
|
|
28
|
-
for (const l of input.lasts)
|
|
29
|
-
if (l.workflow === d.name && !input.going.has(l.run))
|
|
30
|
-
count(l.step, l.failed, RUN_ENDS, 1);
|
|
31
|
-
return {
|
|
32
|
-
workflow: d.name,
|
|
33
|
-
declared: d.graph !== undefined,
|
|
34
|
-
steps: d.steps().map((s) => ({ name: s.name, runs: s.runs, description: s.description, workflow: s.workflow ?? null })),
|
|
35
|
-
edges: graph.map((e) => ({ ...e, runs: runs.get(`${e.from}\u0000${e.to}`) ?? 0 })),
|
|
36
|
-
undeclared: [...undeclared.values()].sort((a, b) => b.runs - a.runs),
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=step-graph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"step-graph.js","sourceRoot":"","sources":["../../../../src/views/step-graph.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAiB,MAAM,UAAU,CAAC;AA+BtF,yHAAyH;AACzH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAA+C,EAA2B,EAAE;IAClG,MAAM,KAAK,GAAG,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAM9B,EAAgC,EAAE,CACjC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAA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C,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClF,UAAU,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;KACrE,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A PROJECT'S WORKFLOWS AS ITS DASHBOARD SHOWS THEM, READ FROM THE RECORDS AT EACH REQUEST, in two readings:
|
|
3
|
-
*
|
|
4
|
-
* every workflow what it is, its steps with their kinds, its limits, and its tasks by status with their history
|
|
5
|
-
* (`buildWorkflowsView`): what a page shows before a workflow is opened, a few small readings.
|
|
6
|
-
* one workflow its steps and their cost over a window, its step graph with the window's runs on it, and where its
|
|
7
|
-
* runs stopped and why (`buildWorkflowFigures`): read from its own records when a page opens it.
|
|
8
|
-
*
|
|
9
|
-
* Built whole and stored by a job every 5 minutes, the two were one view: 5.7 s of reading on a busy machine, 4.4 s of it
|
|
10
|
-
* three scans of every step record for figures only an opened workflow shows, and a page up to 5 minutes old (2026-11-17).
|
|
11
|
-
* Built from the declarations and the stores alone, so any project's workflows read the same; a project adds its own
|
|
12
|
-
* panels beside it. Where its runs are now (`runs-now.ts`) is read at each request too.
|
|
13
|
-
*/
|
|
14
|
-
import { isMadeOfWorkflows, startedAsSteps, stepKindOf, stepUsesAnAgent, tasksAreRuns } from '../steps';
|
|
15
|
-
import { appSetting, stepSetting, storedAt, workflowSetting } from '../settings';
|
|
16
|
-
import { Effect } from 'effect';
|
|
17
|
-
import { QUEUED_NEEDING_AN_AGENT } from '../queue-counts';
|
|
18
|
-
import { TASK_STATUSES } from '../tasks';
|
|
19
|
-
import { stepFunnel } from './step-funnel';
|
|
20
|
-
import { workflowGraphs } from './step-graph';
|
|
21
|
-
/** How long the queues' history reaches back. */
|
|
22
|
-
export const QUEUE_HISTORY_DAYS = 7;
|
|
23
|
-
const medianOf = (xs) => {
|
|
24
|
-
const sorted = [...xs].sort((a, b) => a - b);
|
|
25
|
-
const mid = Math.floor(sorted.length / 2);
|
|
26
|
-
return sorted.length % 2 === 1 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
27
|
-
};
|
|
28
|
-
/** A workflow's ended runs as their costs: the median run, figure by figure, and the costliest. Pure. */
|
|
29
|
-
export const runCostsOf = (costs) => {
|
|
30
|
-
const ended = costs.filter((c) => !c.going);
|
|
31
|
-
if (ended.length === 0)
|
|
32
|
-
return { runs: 0, median: null, costliest: null };
|
|
33
|
-
const costliest = ended.reduce((a, b) => (b.cpuSeconds > a.cpuSeconds ? b : a));
|
|
34
|
-
return {
|
|
35
|
-
runs: ended.length,
|
|
36
|
-
median: {
|
|
37
|
-
seconds: medianOf(ended.map((c) => c.seconds)), tokens: medianOf(ended.map((c) => c.tokens)), cpuSeconds: medianOf(ended.map((c) => c.cpuSeconds)),
|
|
38
|
-
childCpuSeconds: medianOf(ended.map((c) => c.childCpuSeconds)), compiles: medianOf(ended.map((c) => c.compiles)),
|
|
39
|
-
},
|
|
40
|
-
costliest: { run: costliest.run, started: costliest.started, seconds: costliest.seconds, tokens: costliest.tokens, cpuSeconds: costliest.cpuSeconds, compiles: costliest.compiles },
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
/** Endings listed per step; the rest are added up as one. */
|
|
44
|
-
export const ENDINGS_LISTED = 4;
|
|
45
|
-
/** A step's records as their endings, commonest first. Pure. */
|
|
46
|
-
export const endingsOf = (records) => {
|
|
47
|
-
const counts = new Map();
|
|
48
|
-
for (const r of records) {
|
|
49
|
-
const outcome = r.outcome ?? 'going';
|
|
50
|
-
const reason = r.reason ?? (r.outcome === null ? 'still going' : 'no reason recorded');
|
|
51
|
-
const key = `${outcome}\u0000${reason}`;
|
|
52
|
-
const was = counts.get(key);
|
|
53
|
-
counts.set(key, { outcome, reason, records: (was?.records ?? 0) + 1 });
|
|
54
|
-
}
|
|
55
|
-
const all = [...counts.values()].sort((a, b) => b.records - a.records || a.reason.localeCompare(b.reason));
|
|
56
|
-
const rest = all.slice(ENDINGS_LISTED).reduce((n, e) => n + e.records, 0);
|
|
57
|
-
return [...all.slice(0, ENDINGS_LISTED), ...(rest === 0 ? [] : [{ outcome: 'other', reason: `${all.length - ENDINGS_LISTED} other endings`, records: rest }])];
|
|
58
|
-
};
|
|
59
|
-
/** A window's yield from its counts. Pure. */
|
|
60
|
-
export const yieldOf = (r) => ({
|
|
61
|
-
...r,
|
|
62
|
-
perRun: r.runs === 0 ? null : r.finished / r.runs,
|
|
63
|
-
perMillionTokens: r.tokens === 0 ? null : (r.finished * 1_000_000) / r.tokens,
|
|
64
|
-
perCompile: r.compiles === 0 ? null : r.finished / r.compiles,
|
|
65
|
-
});
|
|
66
|
-
const NO_COST = { calls: 0, failed: 0, open: 0, seconds: 0, inputTokens: 0, outputTokens: 0, cpuSeconds: 0, compiles: 0, items: 0 };
|
|
67
|
-
const addCosts = (a, b) => ({
|
|
68
|
-
calls: a.calls + b.calls, failed: a.failed + b.failed, open: a.open + b.open, seconds: a.seconds + b.seconds,
|
|
69
|
-
inputTokens: a.inputTokens + b.inputTokens, outputTokens: a.outputTokens + b.outputTokens, cpuSeconds: a.cpuSeconds + b.cpuSeconds,
|
|
70
|
-
compiles: a.compiles + b.compiles, items: a.items + b.items,
|
|
71
|
-
});
|
|
72
|
-
/** One step's rows (one per run, step and subject) as its cost. Pure. */
|
|
73
|
-
export const costOf = (rows) => rows.length === 0 ? null : {
|
|
74
|
-
calls: rows.reduce((n, r) => n + r.calls, 0),
|
|
75
|
-
failed: rows.reduce((n, r) => n + r.failed, 0),
|
|
76
|
-
open: rows.reduce((n, r) => n + r.open, 0),
|
|
77
|
-
seconds: rows.reduce((n, r) => n + r.ms, 0) / 1000,
|
|
78
|
-
inputTokens: rows.reduce((n, r) => n + (r.fresh ?? 0) + (r.cache_write ?? 0) + (r.cache_read ?? 0), 0),
|
|
79
|
-
outputTokens: rows.reduce((n, r) => n + (r.output ?? 0), 0),
|
|
80
|
-
cpuSeconds: rows.reduce((n, r) => n + r.cpu_seconds, 0),
|
|
81
|
-
compiles: rows.reduce((n, r) => n + (r.compiles ?? 0), 0),
|
|
82
|
-
items: new Set(rows.flatMap((r) => (r.subject === null ? [] : [r.subject.toLowerCase()]))).size,
|
|
83
|
-
};
|
|
84
|
-
const noTasks = () => Object.fromEntries(TASK_STATUSES.map((s) => [s, 0]));
|
|
85
|
-
/**
|
|
86
|
-
* The names a count was recorded under before 2026-11-19, when a task stood in one of six buckets, and the status each is
|
|
87
|
-
* part of now. `queued` and `done` kept their names.
|
|
88
|
-
*/
|
|
89
|
-
const RECORDED_BEFORE = { running: 'in progress', waiting: 'blocked', stuck: 'blocked', held: 'blocked' };
|
|
90
|
-
/**
|
|
91
|
-
* THE RECORDED COUNTS (`queueCountsSince`, oldest first) AS THE FOUR STATUSES: a row for each status of each workflow where
|
|
92
|
-
* its count moved. A count recorded under an older name is part of its status until the workflow has a count under the
|
|
93
|
-
* four, which replaces it; one recorded under an older name after that (by code still running as the newer began) is
|
|
94
|
-
* not read. Pure.
|
|
95
|
-
*/
|
|
96
|
-
export const historyByStatus = (recorded) => {
|
|
97
|
-
const raw = new Map();
|
|
98
|
-
const countedByStatus = new Set();
|
|
99
|
-
const last = new Map();
|
|
100
|
-
const out = [];
|
|
101
|
-
recorded.forEach((row, i) => {
|
|
102
|
-
const counts = raw.get(row.workflow) ?? new Map();
|
|
103
|
-
raw.set(row.workflow, counts);
|
|
104
|
-
const olderName = RECORDED_BEFORE[row.bucket] !== undefined;
|
|
105
|
-
if (!olderName && (row.bucket === 'in progress' || row.bucket === 'blocked') && !countedByStatus.has(row.workflow)) {
|
|
106
|
-
countedByStatus.add(row.workflow);
|
|
107
|
-
for (const older of Object.keys(RECORDED_BEFORE))
|
|
108
|
-
counts.delete(older);
|
|
109
|
-
}
|
|
110
|
-
if (!(olderName && countedByStatus.has(row.workflow)))
|
|
111
|
-
counts.set(row.bucket, row.tasks);
|
|
112
|
-
// Every row of one moment is one count of the workflow: its statuses are read once all of them are in.
|
|
113
|
-
const next = recorded[i + 1];
|
|
114
|
-
if (next !== undefined && next.workflow === row.workflow && next.at === row.at)
|
|
115
|
-
return;
|
|
116
|
-
for (const status of TASK_STATUSES) {
|
|
117
|
-
const tasks = [...counts].reduce((sum, [name, n]) => sum + (name === status || RECORDED_BEFORE[name] === status ? n : 0), 0);
|
|
118
|
-
const key = `${row.workflow}\u0000${status}`;
|
|
119
|
-
if (last.get(key) !== tasks)
|
|
120
|
-
out.push({ at: row.at, workflow: row.workflow, bucket: status, tasks });
|
|
121
|
-
last.set(key, tasks);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
return out;
|
|
125
|
-
};
|
|
126
|
-
/** Each queue's newest count of queued tasks marked as needing an agent, from the recorded counts (oldest first). Pure. */
|
|
127
|
-
export const queuedNeedingAnAgentNow = (recorded) => new Map(recorded.filter((row) => row.bucket === QUEUED_NEEDING_AN_AGENT).map((row) => [row.workflow, row.tasks]));
|
|
128
|
-
/** Each queue's newest count from its history by status (`historyByStatus`), a status never counted at 0. Pure. */
|
|
129
|
-
export const queuesNow = (history) => {
|
|
130
|
-
const queues = new Map();
|
|
131
|
-
for (const row of history) {
|
|
132
|
-
const queue = queues.get(row.workflow) ?? noTasks();
|
|
133
|
-
if (TASK_STATUSES.includes(row.bucket))
|
|
134
|
-
queue[row.bucket] = row.tasks;
|
|
135
|
-
queues.set(row.workflow, queue);
|
|
136
|
-
}
|
|
137
|
-
return queues;
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* EVERY WORKFLOW AS A PAGE SHOWS IT BEFORE ONE IS OPENED, READ AT THE REQUEST: the declarations, the limits, each queue's
|
|
141
|
-
* counts as last counted and their history. A few small readings of the store, so a
|
|
142
|
-
* page load needs no stored copy of it. `limitsOf` is none where no store is read.
|
|
143
|
-
*/
|
|
144
|
-
export const buildWorkflowsView = (input) => Effect.gen(function* () {
|
|
145
|
-
// A step's settings as its workflow `of` holds it; a sub-workflow's are what its workflow's own steps inherit.
|
|
146
|
-
const tree = { declared: input.declared, app: input.app, stored: input.stored };
|
|
147
|
-
const storedHere = (level) => ({ days: storedAt(input.stored, level, 'retentionDays') !== null, atLeastRuns: storedAt(input.stored, level, 'keepAtLeastRuns') !== null });
|
|
148
|
-
const settingOf = (of, s, name) => (s.workflow === undefined ? stepSetting(tree, { workflow: of, step: s.name, name }) : workflowSetting(tree, { workflow: s.workflow, name }));
|
|
149
|
-
const stepSummary = (of) => (s) => ({
|
|
150
|
-
name: s.name, kind: stepKindOf(s), runs: s.runs, description: s.description, workflow: s.workflow ?? null,
|
|
151
|
-
retention: { days: settingOf(of, s, 'retentionDays'), atLeastRuns: settingOf(of, s, 'keepAtLeastRuns'), storedHere: storedHere({ kind: 'step', workflow: of, step: s.name }) },
|
|
152
|
-
model: stepUsesAnAgent(s) ? settingOf(of, s, 'model') : null,
|
|
153
|
-
});
|
|
154
|
-
// A workflow a run of another starts as a step has no runs or limits of its own; one on its own trigger has both.
|
|
155
|
-
const usedAsAStep = startedAsSteps(input.declared);
|
|
156
|
-
const anyStep = new Set(input.declared.flatMap((d) => d.steps().flatMap((s) => (s.workflow === undefined ? [] : [s.workflow]))));
|
|
157
|
-
const recordedCounts = yield* input.taskStore.queueCountsSince(input.now - QUEUE_HISTORY_DAYS * 86_400);
|
|
158
|
-
const queueHistory = historyByStatus(recordedCounts);
|
|
159
|
-
const queues = queuesNow(queueHistory);
|
|
160
|
-
const needingAnAgent = queuedNeedingAnAgentNow(recordedCounts);
|
|
161
|
-
const workflowView = (d) => ({
|
|
162
|
-
name: d.name, steps: d.steps().map(stepSummary(d.name)),
|
|
163
|
-
description: d.description, source: { ...d.source, line: input.locate(d.source) }, item: d.item, finishedWord: d.finishedWord,
|
|
164
|
-
usesAgents: d.steps().some(stepUsesAnAgent),
|
|
165
|
-
// A workflow used as a step has no limit of its own to show: its starts are its parent's steps (`defineSubWorkflow`).
|
|
166
|
-
limits: usedAsAStep.has(d.name) || isMadeOfWorkflows(d) ? null : input.limitsOf(d.name),
|
|
167
|
-
// A workflow with no item has tasks where they are its runs (`steps.ts` `tasksAreRuns`): counted from its first run on.
|
|
168
|
-
queue: d.item === null && !tasksAreRuns(d, input.declared) ? null : queues.get(d.name) ?? noTasks(),
|
|
169
|
-
queuedNeedingAnAgent: d.item === null || !d.steps().some(stepUsesAnAgent) ? null : needingAnAgent.get(d.name) ?? 0,
|
|
170
|
-
startsOn: usedAsAStep.has(d.name) ? { kind: 'a step', of: input.declared.filter((p) => p.steps().some((s) => s.workflow === d.name)).map((p) => p.name) }
|
|
171
|
-
: isMadeOfWorkflows(d) ? { kind: 'its steps', mainStep: d.steps().find((s) => s.name === d.mainStep)?.workflow ?? null }
|
|
172
|
-
: d.pending !== undefined || d.items !== undefined ? { kind: 'queue' } : d.inputs !== undefined ? { kind: 'inputs', says: d.inputs.says } : { kind: 'timer or request' },
|
|
173
|
-
system: d.system === true,
|
|
174
|
-
retention: { days: workflowSetting(tree, { workflow: d.name, name: 'retentionDays' }), atLeastRuns: workflowSetting(tree, { workflow: d.name, name: 'keepAtLeastRuns' }), storedHere: storedHere({ kind: 'workflow', workflow: d.name }) },
|
|
175
|
-
});
|
|
176
|
-
return {
|
|
177
|
-
at: input.now,
|
|
178
|
-
top: ((top) => ({ name: input.top, description: top?.description ?? `${input.top} is not declared`, steps: top?.steps().map(stepSummary(input.top)) ?? [] }))(input.declared.find((d) => d.name === input.top)),
|
|
179
|
-
outermost: input.declared.filter((d) => d.name !== input.top && !anyStep.has(d.name) && d.system !== true).map((d) => d.name),
|
|
180
|
-
system: input.declared.filter((d) => d.system === true).map((d) => d.name),
|
|
181
|
-
workflows: input.declared.map(workflowView),
|
|
182
|
-
queueHistory,
|
|
183
|
-
spending: input.spending,
|
|
184
|
-
appRetention: { days: appSetting(tree, 'retentionDays'), atLeastRuns: appSetting(tree, 'keepAtLeastRuns'), storedHere: storedHere({ kind: 'app' }) },
|
|
185
|
-
};
|
|
186
|
-
});
|
|
187
|
-
/**
|
|
188
|
-
* ONE WORKFLOW'S FIGURES OVER THE `hours` BEFORE `now`, READ FROM ITS OWN RECORDS when a page opens it: each step's cost and
|
|
189
|
-
* endings, its step graph with the runs on each edge, where its runs stopped, what a run costs, and what its runs gave
|
|
190
|
-
* against the window before.
|
|
191
|
-
*/
|
|
192
|
-
export const buildWorkflowFigures = (input) => Effect.gen(function* () {
|
|
193
|
-
const d = input.declaration;
|
|
194
|
-
const since = input.now - input.hours * 3600;
|
|
195
|
-
const before = since - input.hours * 3600;
|
|
196
|
-
const own = yield* input.records.stepRunsSince(since, d.name);
|
|
197
|
-
// The window before, for the trend: its records are those since its start, less the window's own.
|
|
198
|
-
const ownBoth = yield* input.records.stepRunsSince(before, d.name);
|
|
199
|
-
const funnelRecords = yield* input.records.funnelRecordsSince(since, d.name);
|
|
200
|
-
const funnelBoth = yield* input.records.funnelRecordsSince(before, d.name);
|
|
201
|
-
const finishedNow = yield* input.records.runOutcomesSince(since, d.name);
|
|
202
|
-
const finishedBoth = yield* input.records.runOutcomesSince(before, d.name);
|
|
203
|
-
const runCosts = yield* input.records.runCostsSince(since, d.name);
|
|
204
|
-
const moves = yield* input.records.stepEdgesSince(since, d.name);
|
|
205
|
-
const going = new Set((yield* input.engine.unfinishedRuns()).map((u) => u.run));
|
|
206
|
-
const link = (s) => ({ ...s, line: input.locate(s) });
|
|
207
|
-
const declaredSteps = d.steps();
|
|
208
|
-
const onlyInRecords = [...new Set(own.map((r) => r.step))].filter((s) => !declaredSteps.some((x) => x.name === s));
|
|
209
|
-
const steps = [
|
|
210
|
-
...declaredSteps.map((s) => ({ name: s.name, runs: s.runs, description: s.description, source: link(s.source), declared: true, cost: costOf(own.filter((r) => r.step === s.name)), endings: endingsOf(funnelRecords.records.filter((r) => r.step === s.name)) })),
|
|
211
|
-
...onlyInRecords.map((name) => ({ name, runs: own.some((r) => r.step === name && r.agent === 1) ? 'agentic' : null, description: 'no longer declared', source: link(d.source), declared: false, cost: costOf(own.filter((r) => r.step === name)), endings: endingsOf(funnelRecords.records.filter((r) => r.step === name)) })),
|
|
212
|
-
];
|
|
213
|
-
const funnel = stepFunnel({ declaration: d, records: funnelRecords.records, outcomes: funnelRecords.outcomes, unfinished: going, hours: input.hours, since, now: input.now });
|
|
214
|
-
const funnelBefore = stepFunnel({ declaration: d, records: funnelBoth.records, outcomes: funnelBoth.outcomes, unfinished: going, hours: input.hours, since: before, now: since });
|
|
215
|
-
const costNow = costOf(own) ?? NO_COST;
|
|
216
|
-
const costBoth = costOf(ownBoth) ?? NO_COST;
|
|
217
|
-
const finished = (outcomes) => outcomes.filter((o) => o.finished === 1).length;
|
|
218
|
-
return {
|
|
219
|
-
workflow: d.name, at: input.now, hours: input.hours, since,
|
|
220
|
-
steps,
|
|
221
|
-
total: steps.reduce((t, s) => (s.cost === null ? t : addCosts(t, s.cost)), NO_COST),
|
|
222
|
-
graph: workflowGraphs({ declared: [d], taken: moves.edges, lasts: moves.lasts, going })[0],
|
|
223
|
-
funnel,
|
|
224
|
-
runCosts: runCostsOf(runCosts),
|
|
225
|
-
...(yield* input.reasons),
|
|
226
|
-
passingThrough: yield* Effect.forEach(input.asAStepOf ?? [], (p) => Effect.map(input.records.stepRunsSince(since, p.workflow), (rows) => ({ ...p, cost: costOf(rows.filter((r) => r.step === p.step)) }))),
|
|
227
|
-
yields: {
|
|
228
|
-
now: yieldOf({ runs: funnel.runs, finished: finished(finishedNow), tokens: costNow.inputTokens + costNow.outputTokens, compiles: costNow.compiles }),
|
|
229
|
-
before: yieldOf({
|
|
230
|
-
runs: funnelBefore.runs, finished: finished(finishedBoth) - finished(finishedNow),
|
|
231
|
-
tokens: costBoth.inputTokens + costBoth.outputTokens - (costNow.inputTokens + costNow.outputTokens), compiles: costBoth.compiles - costNow.compiles,
|
|
232
|
-
}),
|
|
233
|
-
},
|
|
234
|
-
};
|
|
235
|
-
});
|
|
236
|
-
//# sourceMappingURL=workflows-view.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflows-view.js","sourceRoot":"","sources":["../../../../src/views/workflows-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAgG,MAAM,UAAU,CAAC;AACtM,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAA0I,MAAM,aAAa,CAAC;AAczN,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAuC,MAAM,UAAU,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAsB,MAAM,cAAc,CAAC;AAmBlE,iDAAiD;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AA6DpC,MAAM,QAAQ,GAAG,CAAC,EAAyB,EAAU,EAAE;IACrD,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAE,GAAG,MAAM,CAAC,GAAG,CAAE,CAAC,G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E,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;YACpJ,MAAM,EAAE,OAAO,CAAC;gBACd,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC;gBACjF,MAAM,EAAE,QAAQ,CAAC,WAAW,GAAG,QAAQ,CAAC,YAAY,GAAG,CAAC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ;aACpJ,CAAC;SACH;KACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/src/budget-states.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/** WHAT EACH BUDGETED WORKFLOW'S LIMITS ASK FOR AGAINST WHAT IT HAS, for a dashboard and the route that sets a limit. Pure. */
|
|
2
|
-
import { runLimit, type WorkflowBudgetRow } from './storage/budgets';
|
|
3
|
-
|
|
4
|
-
export interface WorkflowBudgetState {
|
|
5
|
-
readonly workflow: string;
|
|
6
|
-
/** Its agents' limit. */
|
|
7
|
-
readonly budget: number;
|
|
8
|
-
/** Its run limit in force: the one set, or the default (`runLimit`). */
|
|
9
|
-
readonly runs: number;
|
|
10
|
-
/** When a limit last changed, unix seconds. */
|
|
11
|
-
readonly changedAt: number;
|
|
12
|
-
/** Its unfinished runs, whichever step they are on, a run waiting for an item included. */
|
|
13
|
-
readonly running: number;
|
|
14
|
-
/** Its declared work. */
|
|
15
|
-
readonly items: number;
|
|
16
|
-
/** When its newest unfinished run started; null with none running. */
|
|
17
|
-
readonly newestStart: number | null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const workflowBudgetStates = (
|
|
21
|
-
workflows: ReadonlyArray<{ readonly name: string }>,
|
|
22
|
-
budgets: ReadonlyArray<WorkflowBudgetRow>,
|
|
23
|
-
work: ReadonlyArray<{ readonly workflow: string; readonly items: number }>,
|
|
24
|
-
assigned: ReadonlyArray<{ readonly workflow: string; readonly started: number }>,
|
|
25
|
-
): ReadonlyArray<WorkflowBudgetState> =>
|
|
26
|
-
workflows.map((w) => {
|
|
27
|
-
const row = budgets.find((b) => b.workflow === w.name);
|
|
28
|
-
const runs = assigned.filter((a) => a.workflow === w.name);
|
|
29
|
-
const limits = { agents: row?.budget ?? 0, runs: row?.runs ?? null };
|
|
30
|
-
return {
|
|
31
|
-
workflow: w.name, budget: limits.agents, runs: runLimit(limits),
|
|
32
|
-
changedAt: row?.changed_at ?? 0, running: runs.length,
|
|
33
|
-
items: work.find((x) => x.workflow === w.name)?.items ?? 0,
|
|
34
|
-
newestStart: runs.length === 0 ? null : Math.max(...runs.map((r) => r.started)),
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
/** Fewer runs going than its run limit: a run with nothing to pick waits for an item, so work or none, it is a fault. */
|
|
39
|
-
export const belowBudget = (w: Pick<WorkflowBudgetState, 'runs' | 'running'>): boolean => w.running < w.runs;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Whether the trigger started a run above the run limit. Every run going now had started by the newest one's start, so that
|
|
43
|
-
* many were going then; if the limit was already this one, that start went over it. Runs above a limit lowered after they
|
|
44
|
-
* started are finishing their call, and end before the next.
|
|
45
|
-
*/
|
|
46
|
-
export const startedAboveBudget = (w: Pick<WorkflowBudgetState, 'runs' | 'running' | 'newestStart' | 'changedAt'>): boolean =>
|
|
47
|
-
w.running > w.runs && w.newestStart !== null && w.newestStart > w.changedAt;
|
|
48
|
-
|
|
49
|
-
/** Why the route refuses a limit, with its status; null when it takes it. `budgeted` is every workflow with limits. */
|
|
50
|
-
export const budgetRefusal = (workflow: string | null, asked: string, budget: unknown, budgeted: ReadonlyArray<string>): { readonly status: number; readonly error: string } | null => {
|
|
51
|
-
if (workflow === null) return { status: 404, error: `no workflow ${asked}` };
|
|
52
|
-
if (!budgeted.includes(workflow)) return { status: 409, error: `${workflow} has no agent step and no list of work, so it has no budget` };
|
|
53
|
-
return typeof budget === 'number' && Number.isInteger(budget) && budget >= 0 ? null : { status: 400, error: 'budget must be a whole number, 0 or more' };
|
|
54
|
-
};
|