@igorjpimenta/manifold 0.0.0-bootstrap.1
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/.migrations/ops/0000_futuristic_karma.sql +111 -0
- package/.migrations/ops/0001_low_maximus.sql +7 -0
- package/.migrations/ops/meta/0000_snapshot.json +763 -0
- package/.migrations/ops/meta/0001_snapshot.json +173 -0
- package/.migrations/ops/meta/_journal.json +20 -0
- package/.migrations/runtime/0000_real_boomer.sql +180 -0
- package/.migrations/runtime/0001_hot_dakota_north.sql +2 -0
- package/.migrations/runtime/0002_breezy_vertigo.sql +8 -0
- package/.migrations/runtime/0003_dashing_jack_flag.sql +5 -0
- package/.migrations/runtime/0004_panoramic_ego.sql +1 -0
- package/.migrations/runtime/0005_tidy_ben_grimm.sql +10 -0
- package/.migrations/runtime/0006_wet_nightmare.sql +57 -0
- package/.migrations/runtime/0007_ambiguous_chronomancer.sql +8 -0
- package/.migrations/runtime/0008_wealthy_thundra.sql +301 -0
- package/.migrations/runtime/0009_lying_shocker.sql +96 -0
- package/.migrations/runtime/0010_solid_phantom_reporter.sql +160 -0
- package/.migrations/runtime/0011_windy_demogoblin.sql +175 -0
- package/.migrations/runtime/0012_restore_harness_fks.sql +103 -0
- package/.migrations/runtime/meta/0000_snapshot.json +1181 -0
- package/.migrations/runtime/meta/0001_snapshot.json +1209 -0
- package/.migrations/runtime/meta/0002_snapshot.json +1261 -0
- package/.migrations/runtime/meta/0003_snapshot.json +1292 -0
- package/.migrations/runtime/meta/0004_snapshot.json +1240 -0
- package/.migrations/runtime/meta/0006_snapshot.json +1310 -0
- package/.migrations/runtime/meta/0007_snapshot.json +1362 -0
- package/.migrations/runtime/meta/0008_snapshot.json +1742 -0
- package/.migrations/runtime/meta/0009_snapshot.json +2413 -0
- package/.migrations/runtime/meta/0010_snapshot.json +2562 -0
- package/.migrations/runtime/meta/0011_snapshot.json +2812 -0
- package/.migrations/runtime/meta/0012_snapshot.json +2812 -0
- package/.migrations/runtime/meta/_journal.json +97 -0
- package/README.md +1584 -0
- package/RELEASING.md +89 -0
- package/agent/fleet.js +100 -0
- package/bin/cli.js +854 -0
- package/bin/manifold.js +4 -0
- package/boot/flow-revival.js +536 -0
- package/budget/index.js +495 -0
- package/budget/lib.js +59 -0
- package/dashboard/cost.js +528 -0
- package/dashboard/dist/assets/index-CUfp63sj.css +1 -0
- package/dashboard/dist/assets/index-Qy9JMpma.js +371 -0
- package/dashboard/dist/index.html +13 -0
- package/dashboard/event-log.js +267 -0
- package/dashboard/index.html +12 -0
- package/dashboard/package-lock.json +2877 -0
- package/dashboard/package.json +37 -0
- package/dashboard/pipeline-graph.js +131 -0
- package/dashboard/postcss.config.js +6 -0
- package/dashboard/search.js +183 -0
- package/dashboard/server.js +1015 -0
- package/dashboard/src/App.tsx +42 -0
- package/dashboard/src/api/client.ts +118 -0
- package/dashboard/src/api/types.ts +510 -0
- package/dashboard/src/api/ws.tsx +112 -0
- package/dashboard/src/components/CancelButton.tsx +63 -0
- package/dashboard/src/components/ClickToCopy.tsx +68 -0
- package/dashboard/src/components/CopyButton.tsx +61 -0
- package/dashboard/src/components/DailyCostTrend.tsx +85 -0
- package/dashboard/src/components/DailyTimeTrend.tsx +94 -0
- package/dashboard/src/components/Funnel.tsx +149 -0
- package/dashboard/src/components/GateForm.tsx +158 -0
- package/dashboard/src/components/GraphView.tsx +302 -0
- package/dashboard/src/components/GroupPathsSummary.tsx +47 -0
- package/dashboard/src/components/Histogram.tsx +292 -0
- package/dashboard/src/components/Layout.tsx +28 -0
- package/dashboard/src/components/NeedsAttention.tsx +98 -0
- package/dashboard/src/components/NodeContextCard.tsx +132 -0
- package/dashboard/src/components/PathTrail.tsx +35 -0
- package/dashboard/src/components/PipelineCostBreakdown.tsx +277 -0
- package/dashboard/src/components/RerunButton.tsx +46 -0
- package/dashboard/src/components/RunComparison.tsx +53 -0
- package/dashboard/src/components/Sparkline.tsx +94 -0
- package/dashboard/src/components/StatStrip.tsx +147 -0
- package/dashboard/src/components/StateTree.tsx +84 -0
- package/dashboard/src/components/StatusBadge.tsx +18 -0
- package/dashboard/src/components/SubflowPathPills.tsx +38 -0
- package/dashboard/src/components/SubflowSummary.tsx +24 -0
- package/dashboard/src/components/SubflowsCard.tsx +327 -0
- package/dashboard/src/components/TodayStrip.tsx +86 -0
- package/dashboard/src/components/TranscriptPane.tsx +99 -0
- package/dashboard/src/components/TranscriptRow.tsx +69 -0
- package/dashboard/src/components/ui/badge.tsx +38 -0
- package/dashboard/src/components/ui/button.tsx +28 -0
- package/dashboard/src/components/ui/card.tsx +42 -0
- package/dashboard/src/components/ui/skeleton.tsx +9 -0
- package/dashboard/src/components/ui/table.tsx +62 -0
- package/dashboard/src/index.css +26 -0
- package/dashboard/src/lib/anomaly.ts +42 -0
- package/dashboard/src/lib/format.ts +30 -0
- package/dashboard/src/lib/step-history.ts +13 -0
- package/dashboard/src/lib/subflow.ts +154 -0
- package/dashboard/src/lib/use-click-outside.ts +28 -0
- package/dashboard/src/lib/use-ignored-clusters.ts +67 -0
- package/dashboard/src/lib/utils.ts +6 -0
- package/dashboard/src/main.tsx +10 -0
- package/dashboard/src/types/shims.d.ts +4 -0
- package/dashboard/src/views/Home.tsx +478 -0
- package/dashboard/src/views/PipelineDetail.tsx +1185 -0
- package/dashboard/src/views/PipelinesList.tsx +111 -0
- package/dashboard/src/views/RunDetail.tsx +248 -0
- package/dashboard/src/views/Search.tsx +196 -0
- package/dashboard/stats.js +668 -0
- package/dashboard/tailwind.config.ts +43 -0
- package/dashboard/tree-stats.js +12 -0
- package/dashboard/tsconfig.json +25 -0
- package/dashboard/views.js +231 -0
- package/dashboard/vite.config.ts +34 -0
- package/drizzle.config.js +12 -0
- package/drizzle.config.ops.js +12 -0
- package/elevation.js +116 -0
- package/engine/admission-promotion-resume.js +127 -0
- package/engine/agent-dispatch.js +64 -0
- package/engine/child-resume-trigger.js +315 -0
- package/engine/executor-budget.js +87 -0
- package/engine/executor-cancel.js +83 -0
- package/engine/executor-errors.js +122 -0
- package/engine/executor-helpers.js +254 -0
- package/engine/executor-nodes.js +292 -0
- package/engine/executor-persist.js +212 -0
- package/engine/executor-subflow-children.js +275 -0
- package/engine/executor.js +1013 -0
- package/engine/global-concurrency.js +33 -0
- package/engine/loader.js +528 -0
- package/engine/needs-resolver.js +229 -0
- package/engine/pipelines-watcher.js +133 -0
- package/engine/result-replay.js +34 -0
- package/engine/revival-messages.js +11 -0
- package/engine/spawn-child.js +55 -0
- package/engine/wait-for-flow-settlement.js +109 -0
- package/events/catalog.js +26 -0
- package/events/emit.js +44 -0
- package/events/kinds.js +118 -0
- package/events/serve-ws.js +74 -0
- package/events/stream.js +35 -0
- package/events/ws-dialog.js +257 -0
- package/events/ws-frame.js +194 -0
- package/events/ws-run-events.js +70 -0
- package/events.js +32 -0
- package/gates/gate-resolver.js +576 -0
- package/gates/paused-flows.js +55 -0
- package/graphql/columns.js +67 -0
- package/graphql/schema.js +333 -0
- package/index.js +49 -0
- package/mcp/http.js +159 -0
- package/mcp/identity.js +94 -0
- package/mcp/stdio.js +80 -0
- package/mcp/tools.js +245 -0
- package/mcp/wire-ops.js +178 -0
- package/package.json +51 -0
- package/routes/bearer-auth.js +57 -0
- package/routes/discuss-audio.js +87 -0
- package/routes/discuss-component.js +39 -0
- package/routes/discuss-draft.js +159 -0
- package/routes/discuss-helpers.js +20 -0
- package/routes/discuss.js +848 -0
- package/routes/failures.js +104 -0
- package/routes/graphql.js +61 -0
- package/routes/health.js +54 -0
- package/routes/operator-discuss.js +193 -0
- package/routes/operator-resume.js +32 -0
- package/routes/operator-retry.js +301 -0
- package/routes/operator.js +539 -0
- package/routes/pipelines.js +118 -0
- package/routes/runs.js +1129 -0
- package/scripts/ci/import-check.mjs +50 -0
- package/scripts/link-core-self.mjs +31 -0
- package/scripts/with-guard.sh +24 -0
- package/server/app.js +503 -0
- package/server/registry.js +53 -0
- package/server/serve.js +163 -0
- package/state/admission-queue-store.js +325 -0
- package/state/attribution-registries.js +102 -0
- package/state/batch-writer.js +162 -0
- package/state/db-guard.js +63 -0
- package/state/db-health.js +27 -0
- package/state/db.js +122 -0
- package/state/discuss-store.js +299 -0
- package/state/failure-store.js +427 -0
- package/state/migrate.js +104 -0
- package/state/node-cost.js +67 -0
- package/state/node-executions.js +775 -0
- package/state/node-health-store.js +124 -0
- package/state/ops-merge.js +93 -0
- package/state/paths.js +146 -0
- package/state/pipeline-dirs.js +99 -0
- package/state/pipeline-registry.js +449 -0
- package/state/run-store.js +697 -0
- package/state/schema.js +438 -0
- package/state/schema.ops.js +44 -0
- package/state/session-index.js +177 -0
- package/state/session-keys.js +39 -0
- package/state/state-store.js +311 -0
- package/state/subflow-state.js +126 -0
- package/state/tool-handoff.js +169 -0
- package/telemetry/budget-alert.js +353 -0
- package/telemetry/cli.js +331 -0
- package/telemetry/grammar.js +119 -0
- package/telemetry/http-budget.js +132 -0
- package/telemetry/http-cost.js +670 -0
- package/telemetry/http-helpers.js +134 -0
- package/telemetry/http-tree.js +349 -0
- package/telemetry/http.js +44 -0
- package/telemetry/index.js +307 -0
- package/telemetry/ingest.js +134 -0
- package/telemetry/labels.js +115 -0
- package/telemetry/pricer.js +77 -0
- package/telemetry/resolver.js +314 -0
- package/telemetry/store.js +147 -0
- package/utils/run-patch.js +43 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>Manifold Dashboard</title>
|
|
7
|
+
<script type="module" crossorigin src="/graph/assets/index-Qy9JMpma.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/graph/assets/index-CUfp63sj.css">
|
|
9
|
+
</head>
|
|
10
|
+
<body class="bg-bg text-fg">
|
|
11
|
+
<div id="root"></div>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
// event-log.js — synthesise a flow-change event stream for the dashboard.
|
|
2
|
+
//
|
|
3
|
+
// Driven by flowStateEmitter (state-store.js fires after every write) so
|
|
4
|
+
// each change lands within a single process.nextTick — no polling lag.
|
|
5
|
+
// Emits (canonical kinds):
|
|
6
|
+
// - run.created : first time we see a flowId
|
|
7
|
+
// - run.updated : revision advanced; carries {prevStep, currStep, prevStatus, currStatus, stateKeysAdded, stateKeysRemoved}
|
|
8
|
+
// - run.ended : status moved to a terminal state
|
|
9
|
+
//
|
|
10
|
+
// stateKeysAdded/stateKeysRemoved: diffed off which node_ids have a
|
|
11
|
+
// flow_node_invocations row for this flow (nodeExecutionsStore.
|
|
12
|
+
// listVisitedNodeIdsByFlow, same store method dashboard/stats.js's
|
|
13
|
+
// funnel-visit check uses), not off Object.keys(stateJson) — a raw
|
|
14
|
+
// key-diff goes silent for node dispatches that never grow state_json.
|
|
15
|
+
// Node-invocation existence is the better signal anyway: it fires the
|
|
16
|
+
// instant a node is dispatched, not only once its output merges into
|
|
17
|
+
// state_json.
|
|
18
|
+
//
|
|
19
|
+
// Each event is delivered to live WS subscribers AND appended to a per-flow
|
|
20
|
+
// ring buffer (cap 256 events) so the run-detail page can replay history on
|
|
21
|
+
// first load.
|
|
22
|
+
//
|
|
23
|
+
// When `dbPath` is supplied (wired from index.js), events are also written to a
|
|
24
|
+
// `flow_events` SQLite table so history survives gateway restarts. getEventsFor()
|
|
25
|
+
// falls back to SQL when the in-memory buffer is empty (cold read after restart).
|
|
26
|
+
|
|
27
|
+
import { mkdirSync } from "node:fs";
|
|
28
|
+
import { openDb } from "../state/db.js";
|
|
29
|
+
import { enqueueRaw } from "../state/batch-writer.js";
|
|
30
|
+
import { randomUUID } from "node:crypto";
|
|
31
|
+
import path from "node:path";
|
|
32
|
+
import os from "node:os";
|
|
33
|
+
import { flowStateEmitter } from "../events.js";
|
|
34
|
+
import { migrateDatabase, RUNTIME_MIGRATIONS_FOLDER } from "../state/migrate.js";
|
|
35
|
+
|
|
36
|
+
const DEFAULT_EVENTS_DB_PATH = path.join(os.homedir(), ".openclaw", "runtime.sqlite");
|
|
37
|
+
|
|
38
|
+
async function openEventsDb(dbPath, logger) {
|
|
39
|
+
try {
|
|
40
|
+
mkdirSync(path.dirname(dbPath), { recursive: true });
|
|
41
|
+
await migrateDatabase({ dbPath, migrationsFolder: RUNTIME_MIGRATIONS_FOLDER });
|
|
42
|
+
const { client } = await openDb(dbPath);
|
|
43
|
+
return client;
|
|
44
|
+
} catch (err) {
|
|
45
|
+
logger?.warn?.(`manifold event-log: failed to open events DB: ${err?.message ?? err}`);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const RING_CAP = 256;
|
|
51
|
+
|
|
52
|
+
const INSERT_SQL = `INSERT OR IGNORE INTO flow_events (id, flow_id, event_type, prev_step, curr_step, prev_status, curr_status, wait_kind, occurred_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`;
|
|
53
|
+
|
|
54
|
+
export function createEventBus({ store, nodeExecutionsStore, logger, dbPath = DEFAULT_EVENTS_DB_PATH }) {
|
|
55
|
+
let _client = null;
|
|
56
|
+
if (dbPath) openEventsDb(dbPath, logger).then(c => { _client = c; });
|
|
57
|
+
// Map<flowId, { revision, status, lastStep, stateKeys: Set<string>, terminal: boolean }>
|
|
58
|
+
const last = new Map();
|
|
59
|
+
|
|
60
|
+
// Map<flowId, Event[]> (ring buffer per flow)
|
|
61
|
+
const buffers = new Map();
|
|
62
|
+
|
|
63
|
+
// Set<(event) => void>
|
|
64
|
+
const subscribers = new Set();
|
|
65
|
+
|
|
66
|
+
let running = false;
|
|
67
|
+
// Bound listener stored so we can remove it on stop().
|
|
68
|
+
let changeListener = null;
|
|
69
|
+
|
|
70
|
+
function emit(event) {
|
|
71
|
+
const list = buffers.get(event.flowId) ?? [];
|
|
72
|
+
list.push(event);
|
|
73
|
+
if (list.length > RING_CAP) list.splice(0, list.length - RING_CAP);
|
|
74
|
+
buffers.set(event.flowId, list);
|
|
75
|
+
// Persist to SQLite so history survives restarts (best-effort, fire-and-
|
|
76
|
+
// forget — errors already swallowed, nothing re-reads the row in the
|
|
77
|
+
// same call). Routed through batch-writer's enqueueRaw rather than a
|
|
78
|
+
// bare client.execute(): this fires on every run.created/run.updated/
|
|
79
|
+
// run.ended transition anywhere in the system — the single
|
|
80
|
+
// highest-frequency write in the app — so an unretried write here both
|
|
81
|
+
// risked silently dropping history rows under SQLITE_BUSY contention
|
|
82
|
+
// and meant every one of those transitions issued its own individual
|
|
83
|
+
// round-trip instead of coalescing. enqueueRaw resolves its own shared
|
|
84
|
+
// connection via dbPath independently of this bus's own `_client` (used
|
|
85
|
+
// only for reads/close below), so this needs no dependency on `_client`
|
|
86
|
+
// having resolved yet either.
|
|
87
|
+
if (dbPath && event.flowId && event.kind) {
|
|
88
|
+
enqueueRaw(dbPath, INSERT_SQL, [randomUUID(), event.flowId, event.kind, event.prevStep ?? null, event.currStep ?? null, event.prevStatus ?? null, event.currStatus ?? null, event.waitKind ?? null, event.at ?? Date.now()]);
|
|
89
|
+
}
|
|
90
|
+
for (const cb of subscribers) {
|
|
91
|
+
try { cb(event); } catch (err) {
|
|
92
|
+
logger?.warn?.(`manifold dashboard event-bus subscriber error: ${err?.message ?? err}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function visitedNodeIdSet(flowId) {
|
|
98
|
+
try {
|
|
99
|
+
const map = await nodeExecutionsStore?.listVisitedNodeIdsByFlow?.([flowId]);
|
|
100
|
+
return map?.get(flowId) ?? new Set();
|
|
101
|
+
} catch {
|
|
102
|
+
return new Set();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function diffKeys(prevSet, currSet) {
|
|
107
|
+
const added = [];
|
|
108
|
+
const removed = [];
|
|
109
|
+
for (const k of currSet) if (!prevSet.has(k)) added.push(k);
|
|
110
|
+
for (const k of prevSet) if (!currSet.has(k)) removed.push(k);
|
|
111
|
+
return { added, removed };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Terminal set matches the WS run listener exactly (succeeded, failed,
|
|
115
|
+
// cancelled, skipped) — the two streams must agree on what "ended" means
|
|
116
|
+
// or the dashboard and companion clients diverge on skipped runs.
|
|
117
|
+
function isTerminal(status) {
|
|
118
|
+
return status === "succeeded" || status === "failed" || status === "cancelled" || status === "skipped";
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Process a single flow row — diff against last snapshot and emit if changed.
|
|
122
|
+
async function tickOne(row) {
|
|
123
|
+
const prev = last.get(row.flowId);
|
|
124
|
+
const currKeys = await visitedNodeIdSet(row.flowId);
|
|
125
|
+
if (!prev) {
|
|
126
|
+
last.set(row.flowId, {
|
|
127
|
+
revision: row.revision,
|
|
128
|
+
status: row.status,
|
|
129
|
+
lastStep: row.lastStep,
|
|
130
|
+
stateKeys: currKeys,
|
|
131
|
+
terminal: isTerminal(row.status),
|
|
132
|
+
});
|
|
133
|
+
emit({
|
|
134
|
+
flowId: row.flowId,
|
|
135
|
+
kind: "run.created",
|
|
136
|
+
at: row.createdAt ?? Date.now(),
|
|
137
|
+
status: row.status,
|
|
138
|
+
lastStep: row.lastStep,
|
|
139
|
+
pipelineId: row.stateJson?.pipelineId ?? null,
|
|
140
|
+
});
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (prev.revision === row.revision) return;
|
|
144
|
+
const { added, removed } = diffKeys(prev.stateKeys, currKeys);
|
|
145
|
+
emit({
|
|
146
|
+
kind: "run.updated",
|
|
147
|
+
flowId: row.flowId,
|
|
148
|
+
at: row.updatedAt ?? Date.now(),
|
|
149
|
+
prevStatus: prev.status,
|
|
150
|
+
currStatus: row.status,
|
|
151
|
+
prevStep: prev.lastStep,
|
|
152
|
+
currStep: row.lastStep,
|
|
153
|
+
revision: row.revision,
|
|
154
|
+
stateKeysAdded: added,
|
|
155
|
+
stateKeysRemoved: removed,
|
|
156
|
+
waitKind: row.waitJson?.kind ?? null,
|
|
157
|
+
});
|
|
158
|
+
if (!prev.terminal && isTerminal(row.status)) {
|
|
159
|
+
emit({
|
|
160
|
+
kind: "run.ended",
|
|
161
|
+
flowId: row.flowId,
|
|
162
|
+
at: row.endedAt ?? row.updatedAt ?? Date.now(),
|
|
163
|
+
status: row.status,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
last.set(row.flowId, {
|
|
167
|
+
revision: row.revision,
|
|
168
|
+
status: row.status,
|
|
169
|
+
lastStep: row.lastStep,
|
|
170
|
+
stateKeys: currKeys,
|
|
171
|
+
terminal: isTerminal(row.status),
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
async start() {
|
|
177
|
+
if (running) return;
|
|
178
|
+
running = true;
|
|
179
|
+
// Prime the snapshot without emitting flow_created for pre-existing rows.
|
|
180
|
+
// One batched listVisitedNodeIdsByFlow() call for every row instead of
|
|
181
|
+
// one query per flow — same batching rationale as stats.js's Phase 3a
|
|
182
|
+
// tree-summary fix.
|
|
183
|
+
try {
|
|
184
|
+
const rows = await store.list();
|
|
185
|
+
const visitedByFlow = (await nodeExecutionsStore?.listVisitedNodeIdsByFlow?.(rows.map((r) => r.flowId))) ?? new Map();
|
|
186
|
+
for (const row of rows) {
|
|
187
|
+
last.set(row.flowId, {
|
|
188
|
+
revision: row.revision,
|
|
189
|
+
status: row.status,
|
|
190
|
+
lastStep: row.lastStep,
|
|
191
|
+
stateKeys: visitedByFlow.get(row.flowId) ?? new Set(),
|
|
192
|
+
terminal: isTerminal(row.status),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
} catch (err) {
|
|
196
|
+
logger?.warn?.(`manifold dashboard event-bus prime failed: ${err?.message ?? err}`);
|
|
197
|
+
}
|
|
198
|
+
// Subscribe to trigger events from state-store — fires within a
|
|
199
|
+
// process.nextTick after each write, replacing the 1 Hz poll.
|
|
200
|
+
changeListener = async (flowId) => {
|
|
201
|
+
if (!running || !flowId) return;
|
|
202
|
+
let row;
|
|
203
|
+
try { row = await store.get(flowId); } catch { return; }
|
|
204
|
+
if (row) {
|
|
205
|
+
await tickOne(row);
|
|
206
|
+
} else {
|
|
207
|
+
// Flow was deleted — prune from tracking (rare; test-run cleanup).
|
|
208
|
+
last.delete(flowId);
|
|
209
|
+
buffers.delete(flowId);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
flowStateEmitter.on("change", changeListener);
|
|
213
|
+
},
|
|
214
|
+
stop() {
|
|
215
|
+
running = false;
|
|
216
|
+
if (changeListener) {
|
|
217
|
+
flowStateEmitter.off("change", changeListener);
|
|
218
|
+
changeListener = null;
|
|
219
|
+
}
|
|
220
|
+
subscribers.clear();
|
|
221
|
+
try { _client?.close?.(); } catch { /* ignore */ }
|
|
222
|
+
},
|
|
223
|
+
subscribe(cb) {
|
|
224
|
+
subscribers.add(cb);
|
|
225
|
+
return () => subscribers.delete(cb);
|
|
226
|
+
},
|
|
227
|
+
async getEventsFor(flowId) {
|
|
228
|
+
const inMemory = buffers.get(flowId);
|
|
229
|
+
if (inMemory && inMemory.length > 0) return [...inMemory];
|
|
230
|
+
// Fall back to SQLite after a restart when the ring buffer is cold.
|
|
231
|
+
if (!_client) return [];
|
|
232
|
+
try {
|
|
233
|
+
const { rows } = await _client.execute({
|
|
234
|
+
sql: "SELECT * FROM flow_events WHERE flow_id = ? ORDER BY occurred_at ASC LIMIT 500",
|
|
235
|
+
args: [flowId],
|
|
236
|
+
});
|
|
237
|
+
return rows.map((r) => ({
|
|
238
|
+
// event_type stores the canonical kind outright; no read-time
|
|
239
|
+
// translation — pre-break rows are out of scope by design.
|
|
240
|
+
kind: r.event_type,
|
|
241
|
+
flowId: r.flow_id,
|
|
242
|
+
at: r.occurred_at,
|
|
243
|
+
prevStep: r.prev_step ?? undefined,
|
|
244
|
+
currStep: r.curr_step ?? undefined,
|
|
245
|
+
prevStatus: r.prev_status ?? undefined,
|
|
246
|
+
currStatus: r.curr_status ?? undefined,
|
|
247
|
+
waitKind: r.wait_kind ?? undefined,
|
|
248
|
+
}));
|
|
249
|
+
} catch {
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
// Push a non-flow event straight to live subscribers without ring-buffering
|
|
254
|
+
// it. Used for pipelines_changed and any other "side-channel" notification
|
|
255
|
+
// the dashboard wants to surface live.
|
|
256
|
+
broadcast(event) {
|
|
257
|
+
for (const cb of subscribers) {
|
|
258
|
+
try { cb(event); } catch (err) {
|
|
259
|
+
logger?.warn?.(`manifold dashboard event-bus broadcast error: ${err?.message ?? err}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
snapshot() {
|
|
264
|
+
return { tracked: last.size, subscribers: subscribers.size, buffered: [...buffers.values()].reduce((a, b) => a + b.length, 0) };
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>Manifold Dashboard</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body class="bg-bg text-fg">
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|