@igorjpimenta/manifold 0.0.0-bootstrap.1 → 0.0.0-stage

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 (210) hide show
  1. package/README.md +2 -1583
  2. package/package.json +4 -49
  3. package/.migrations/ops/0000_futuristic_karma.sql +0 -111
  4. package/.migrations/ops/0001_low_maximus.sql +0 -7
  5. package/.migrations/ops/meta/0000_snapshot.json +0 -763
  6. package/.migrations/ops/meta/0001_snapshot.json +0 -173
  7. package/.migrations/ops/meta/_journal.json +0 -20
  8. package/.migrations/runtime/0000_real_boomer.sql +0 -180
  9. package/.migrations/runtime/0001_hot_dakota_north.sql +0 -2
  10. package/.migrations/runtime/0002_breezy_vertigo.sql +0 -8
  11. package/.migrations/runtime/0003_dashing_jack_flag.sql +0 -5
  12. package/.migrations/runtime/0004_panoramic_ego.sql +0 -1
  13. package/.migrations/runtime/0005_tidy_ben_grimm.sql +0 -10
  14. package/.migrations/runtime/0006_wet_nightmare.sql +0 -57
  15. package/.migrations/runtime/0007_ambiguous_chronomancer.sql +0 -8
  16. package/.migrations/runtime/0008_wealthy_thundra.sql +0 -301
  17. package/.migrations/runtime/0009_lying_shocker.sql +0 -96
  18. package/.migrations/runtime/0010_solid_phantom_reporter.sql +0 -160
  19. package/.migrations/runtime/0011_windy_demogoblin.sql +0 -175
  20. package/.migrations/runtime/0012_restore_harness_fks.sql +0 -103
  21. package/.migrations/runtime/meta/0000_snapshot.json +0 -1181
  22. package/.migrations/runtime/meta/0001_snapshot.json +0 -1209
  23. package/.migrations/runtime/meta/0002_snapshot.json +0 -1261
  24. package/.migrations/runtime/meta/0003_snapshot.json +0 -1292
  25. package/.migrations/runtime/meta/0004_snapshot.json +0 -1240
  26. package/.migrations/runtime/meta/0006_snapshot.json +0 -1310
  27. package/.migrations/runtime/meta/0007_snapshot.json +0 -1362
  28. package/.migrations/runtime/meta/0008_snapshot.json +0 -1742
  29. package/.migrations/runtime/meta/0009_snapshot.json +0 -2413
  30. package/.migrations/runtime/meta/0010_snapshot.json +0 -2562
  31. package/.migrations/runtime/meta/0011_snapshot.json +0 -2812
  32. package/.migrations/runtime/meta/0012_snapshot.json +0 -2812
  33. package/.migrations/runtime/meta/_journal.json +0 -97
  34. package/RELEASING.md +0 -89
  35. package/agent/fleet.js +0 -100
  36. package/bin/cli.js +0 -854
  37. package/bin/manifold.js +0 -4
  38. package/boot/flow-revival.js +0 -536
  39. package/budget/index.js +0 -495
  40. package/budget/lib.js +0 -59
  41. package/dashboard/cost.js +0 -528
  42. package/dashboard/dist/assets/index-CUfp63sj.css +0 -1
  43. package/dashboard/dist/assets/index-Qy9JMpma.js +0 -371
  44. package/dashboard/dist/index.html +0 -13
  45. package/dashboard/event-log.js +0 -267
  46. package/dashboard/index.html +0 -12
  47. package/dashboard/package-lock.json +0 -2877
  48. package/dashboard/package.json +0 -37
  49. package/dashboard/pipeline-graph.js +0 -131
  50. package/dashboard/postcss.config.js +0 -6
  51. package/dashboard/search.js +0 -183
  52. package/dashboard/server.js +0 -1015
  53. package/dashboard/src/App.tsx +0 -42
  54. package/dashboard/src/api/client.ts +0 -118
  55. package/dashboard/src/api/types.ts +0 -510
  56. package/dashboard/src/api/ws.tsx +0 -112
  57. package/dashboard/src/components/CancelButton.tsx +0 -63
  58. package/dashboard/src/components/ClickToCopy.tsx +0 -68
  59. package/dashboard/src/components/CopyButton.tsx +0 -61
  60. package/dashboard/src/components/DailyCostTrend.tsx +0 -85
  61. package/dashboard/src/components/DailyTimeTrend.tsx +0 -94
  62. package/dashboard/src/components/Funnel.tsx +0 -149
  63. package/dashboard/src/components/GateForm.tsx +0 -158
  64. package/dashboard/src/components/GraphView.tsx +0 -302
  65. package/dashboard/src/components/GroupPathsSummary.tsx +0 -47
  66. package/dashboard/src/components/Histogram.tsx +0 -292
  67. package/dashboard/src/components/Layout.tsx +0 -28
  68. package/dashboard/src/components/NeedsAttention.tsx +0 -98
  69. package/dashboard/src/components/NodeContextCard.tsx +0 -132
  70. package/dashboard/src/components/PathTrail.tsx +0 -35
  71. package/dashboard/src/components/PipelineCostBreakdown.tsx +0 -277
  72. package/dashboard/src/components/RerunButton.tsx +0 -46
  73. package/dashboard/src/components/RunComparison.tsx +0 -53
  74. package/dashboard/src/components/Sparkline.tsx +0 -94
  75. package/dashboard/src/components/StatStrip.tsx +0 -147
  76. package/dashboard/src/components/StateTree.tsx +0 -84
  77. package/dashboard/src/components/StatusBadge.tsx +0 -18
  78. package/dashboard/src/components/SubflowPathPills.tsx +0 -38
  79. package/dashboard/src/components/SubflowSummary.tsx +0 -24
  80. package/dashboard/src/components/SubflowsCard.tsx +0 -327
  81. package/dashboard/src/components/TodayStrip.tsx +0 -86
  82. package/dashboard/src/components/TranscriptPane.tsx +0 -99
  83. package/dashboard/src/components/TranscriptRow.tsx +0 -69
  84. package/dashboard/src/components/ui/badge.tsx +0 -38
  85. package/dashboard/src/components/ui/button.tsx +0 -28
  86. package/dashboard/src/components/ui/card.tsx +0 -42
  87. package/dashboard/src/components/ui/skeleton.tsx +0 -9
  88. package/dashboard/src/components/ui/table.tsx +0 -62
  89. package/dashboard/src/index.css +0 -26
  90. package/dashboard/src/lib/anomaly.ts +0 -42
  91. package/dashboard/src/lib/format.ts +0 -30
  92. package/dashboard/src/lib/step-history.ts +0 -13
  93. package/dashboard/src/lib/subflow.ts +0 -154
  94. package/dashboard/src/lib/use-click-outside.ts +0 -28
  95. package/dashboard/src/lib/use-ignored-clusters.ts +0 -67
  96. package/dashboard/src/lib/utils.ts +0 -6
  97. package/dashboard/src/main.tsx +0 -10
  98. package/dashboard/src/types/shims.d.ts +0 -4
  99. package/dashboard/src/views/Home.tsx +0 -478
  100. package/dashboard/src/views/PipelineDetail.tsx +0 -1185
  101. package/dashboard/src/views/PipelinesList.tsx +0 -111
  102. package/dashboard/src/views/RunDetail.tsx +0 -248
  103. package/dashboard/src/views/Search.tsx +0 -196
  104. package/dashboard/stats.js +0 -668
  105. package/dashboard/tailwind.config.ts +0 -43
  106. package/dashboard/tree-stats.js +0 -12
  107. package/dashboard/tsconfig.json +0 -25
  108. package/dashboard/views.js +0 -231
  109. package/dashboard/vite.config.ts +0 -34
  110. package/drizzle.config.js +0 -12
  111. package/drizzle.config.ops.js +0 -12
  112. package/elevation.js +0 -116
  113. package/engine/admission-promotion-resume.js +0 -127
  114. package/engine/agent-dispatch.js +0 -64
  115. package/engine/child-resume-trigger.js +0 -315
  116. package/engine/executor-budget.js +0 -87
  117. package/engine/executor-cancel.js +0 -83
  118. package/engine/executor-errors.js +0 -122
  119. package/engine/executor-helpers.js +0 -254
  120. package/engine/executor-nodes.js +0 -292
  121. package/engine/executor-persist.js +0 -212
  122. package/engine/executor-subflow-children.js +0 -275
  123. package/engine/executor.js +0 -1013
  124. package/engine/global-concurrency.js +0 -33
  125. package/engine/loader.js +0 -528
  126. package/engine/needs-resolver.js +0 -229
  127. package/engine/pipelines-watcher.js +0 -133
  128. package/engine/result-replay.js +0 -34
  129. package/engine/revival-messages.js +0 -11
  130. package/engine/spawn-child.js +0 -55
  131. package/engine/wait-for-flow-settlement.js +0 -109
  132. package/events/catalog.js +0 -26
  133. package/events/emit.js +0 -44
  134. package/events/kinds.js +0 -118
  135. package/events/serve-ws.js +0 -74
  136. package/events/stream.js +0 -35
  137. package/events/ws-dialog.js +0 -257
  138. package/events/ws-frame.js +0 -194
  139. package/events/ws-run-events.js +0 -70
  140. package/events.js +0 -32
  141. package/gates/gate-resolver.js +0 -576
  142. package/gates/paused-flows.js +0 -55
  143. package/graphql/columns.js +0 -67
  144. package/graphql/schema.js +0 -333
  145. package/index.js +0 -49
  146. package/mcp/http.js +0 -159
  147. package/mcp/identity.js +0 -94
  148. package/mcp/stdio.js +0 -80
  149. package/mcp/tools.js +0 -245
  150. package/mcp/wire-ops.js +0 -178
  151. package/routes/bearer-auth.js +0 -57
  152. package/routes/discuss-audio.js +0 -87
  153. package/routes/discuss-component.js +0 -39
  154. package/routes/discuss-draft.js +0 -159
  155. package/routes/discuss-helpers.js +0 -20
  156. package/routes/discuss.js +0 -848
  157. package/routes/failures.js +0 -104
  158. package/routes/graphql.js +0 -61
  159. package/routes/health.js +0 -54
  160. package/routes/operator-discuss.js +0 -193
  161. package/routes/operator-resume.js +0 -32
  162. package/routes/operator-retry.js +0 -301
  163. package/routes/operator.js +0 -539
  164. package/routes/pipelines.js +0 -118
  165. package/routes/runs.js +0 -1129
  166. package/scripts/ci/import-check.mjs +0 -50
  167. package/scripts/link-core-self.mjs +0 -31
  168. package/scripts/with-guard.sh +0 -24
  169. package/server/app.js +0 -503
  170. package/server/registry.js +0 -53
  171. package/server/serve.js +0 -163
  172. package/state/admission-queue-store.js +0 -325
  173. package/state/attribution-registries.js +0 -102
  174. package/state/batch-writer.js +0 -162
  175. package/state/db-guard.js +0 -63
  176. package/state/db-health.js +0 -27
  177. package/state/db.js +0 -122
  178. package/state/discuss-store.js +0 -299
  179. package/state/failure-store.js +0 -427
  180. package/state/migrate.js +0 -104
  181. package/state/node-cost.js +0 -67
  182. package/state/node-executions.js +0 -775
  183. package/state/node-health-store.js +0 -124
  184. package/state/ops-merge.js +0 -93
  185. package/state/paths.js +0 -146
  186. package/state/pipeline-dirs.js +0 -99
  187. package/state/pipeline-registry.js +0 -449
  188. package/state/run-store.js +0 -697
  189. package/state/schema.js +0 -438
  190. package/state/schema.ops.js +0 -44
  191. package/state/session-index.js +0 -177
  192. package/state/session-keys.js +0 -39
  193. package/state/state-store.js +0 -311
  194. package/state/subflow-state.js +0 -126
  195. package/state/tool-handoff.js +0 -169
  196. package/telemetry/budget-alert.js +0 -353
  197. package/telemetry/cli.js +0 -331
  198. package/telemetry/grammar.js +0 -119
  199. package/telemetry/http-budget.js +0 -132
  200. package/telemetry/http-cost.js +0 -670
  201. package/telemetry/http-helpers.js +0 -134
  202. package/telemetry/http-tree.js +0 -349
  203. package/telemetry/http.js +0 -44
  204. package/telemetry/index.js +0 -307
  205. package/telemetry/ingest.js +0 -134
  206. package/telemetry/labels.js +0 -115
  207. package/telemetry/pricer.js +0 -77
  208. package/telemetry/resolver.js +0 -314
  209. package/telemetry/store.js +0 -147
  210. package/utils/run-patch.js +0 -43
@@ -1,84 +0,0 @@
1
- // Collapsible state-inspector. Recursive <details> trees so cytoscape's
2
- // "click a node, scroll the matching state slot into view" affordance still
3
- // works via [data-state-key] selectors.
4
-
5
- import { useState } from "react";
6
- import { cn } from "@/lib/utils";
7
-
8
- export function StateTree({ value, label, defaultOpen = false }: { value: unknown; label: string; defaultOpen?: boolean }) {
9
- return <TreeNode value={value} label={label} defaultOpen={defaultOpen} />;
10
- }
11
-
12
- function TreeNode({ value, label, defaultOpen = false }: { value: unknown; label: string; defaultOpen?: boolean }) {
13
- const [open, setOpen] = useState<boolean>(defaultOpen);
14
-
15
- if (value === null || value === undefined) {
16
- return <div className="font-mono text-fg-dim text-xs"><span>{label}:</span> null</div>;
17
- }
18
- if (Array.isArray(value)) {
19
- return (
20
- <details
21
- open={open}
22
- data-state-key={label}
23
- // React onToggle bubbles up the synthetic-event tree, so a nested
24
- // <details> closing triggers this listener too. Ignore events that
25
- // didn't originate on this element; otherwise the parent collapses
26
- // whenever any descendant toggles.
27
- onToggle={(e) => {
28
- if (e.target !== e.currentTarget) return;
29
- setOpen((e.currentTarget as HTMLDetailsElement).open);
30
- }}
31
- className="my-0.5"
32
- >
33
- <summary className="cursor-pointer select-none text-fg-dim font-mono text-xs hover:text-fg">
34
- <span>{label}</span> <span className="text-fg-dim">[{value.length}]</span>
35
- </summary>
36
- {open && (
37
- <div className="ml-[14px] border-l border-border pl-2">
38
- {value.slice(0, 50).map((v, i) => (
39
- <TreeNode key={i} value={v} label={String(i)} />
40
- ))}
41
- {value.length > 50 && <div className="text-fg-dim font-mono">… {value.length - 50} more</div>}
42
- </div>
43
- )}
44
- </details>
45
- );
46
- }
47
- if (typeof value === "object") {
48
- const keys = Object.keys(value as object);
49
- return (
50
- <details
51
- open={open}
52
- data-state-key={label}
53
- // React onToggle bubbles up the synthetic-event tree, so a nested
54
- // <details> closing triggers this listener too. Ignore events that
55
- // didn't originate on this element; otherwise the parent collapses
56
- // whenever any descendant toggles.
57
- onToggle={(e) => {
58
- if (e.target !== e.currentTarget) return;
59
- setOpen((e.currentTarget as HTMLDetailsElement).open);
60
- }}
61
- className="my-0.5"
62
- >
63
- <summary className="cursor-pointer select-none text-fg-dim font-mono text-xs hover:text-fg">
64
- <span>{label}</span> <span className="text-fg-dim">{`{${keys.length}}`}</span>
65
- </summary>
66
- {open && (
67
- <div className="ml-[14px] border-l border-border pl-2">
68
- {keys.map((k) => (
69
- <TreeNode key={k} value={(value as Record<string, unknown>)[k]} label={k} />
70
- ))}
71
- </div>
72
- )}
73
- </details>
74
- );
75
- }
76
- // Primitive
77
- const text = typeof value === "string" ? `"${value}"` : String(value);
78
- const short = text.length > 200 ? text.slice(0, 197) + "…" : text;
79
- return (
80
- <div className="font-mono text-xs" title={text}>
81
- <span className="text-fg-dim">{label}:</span> <span className={cn(typeof value === "string" ? "text-fg" : "text-fg")}>{short}</span>
82
- </div>
83
- );
84
- }
@@ -1,18 +0,0 @@
1
- import { Badge } from "./ui/badge";
2
- import type { RunStatus } from "@/api/types";
3
-
4
- // "waiting" is never actually written anywhere (confirmed repo-wide) — gate
5
- // pauses are always persisted as "blocked".
6
- const VARIANTS: Record<string, "running" | "blocked" | "succeeded" | "failed" | "cancelled" | "default"> = {
7
- running: "running",
8
- blocked: "blocked",
9
- succeeded: "succeeded",
10
- failed: "failed",
11
- cancelled: "cancelled",
12
- skipped: "cancelled",
13
- };
14
-
15
- export function StatusBadge({ status }: { status: RunStatus | null | undefined }) {
16
- const v = (status && VARIANTS[status]) || "default";
17
- return <Badge variant={v}>{status ?? "?"}</Badge>;
18
- }
@@ -1,38 +0,0 @@
1
- // Per-subflow trajectory rendered as pills with ❯ separators. Same visual
2
- // language as the top-level PathTrail. Distinguishes outcomes per sub-step.
3
-
4
- import { Badge } from "./ui/badge";
5
- import type { SubflowData } from "@/api/types";
6
-
7
- export function SubflowPathPills({ subflow, subSteps }: { subflow: SubflowData | null | undefined; subSteps: string[] }) {
8
- if (!subflow) return <span className="text-fg-dim">—</span>;
9
- const pills: { label: string; variant: "succeeded" | "failed" | "cancelled" | "waiting"; suffix?: string; title?: string }[] = [];
10
- for (const step of subSteps) {
11
- const d = subflow.data?.[step];
12
- if (d) {
13
- let variant: "succeeded" | "failed" | "cancelled" = "succeeded";
14
- let suffix: string | undefined;
15
- if (d._error) variant = "failed";
16
- else if (step === "GATE" && d.decision && d.decision !== "approve") {
17
- variant = "cancelled";
18
- suffix = " ✗";
19
- } else if (step === "SUBMIT" && d.ok === false) variant = "failed";
20
- let title = "";
21
- try { title = JSON.stringify(d).slice(0, 200); } catch { /* swallow */ }
22
- pills.push({ label: step, variant, suffix, title });
23
- } else if (subflow.awaiting?.subNodeId === step) {
24
- pills.push({ label: step, variant: "waiting", suffix: " ⏳", title: `subflow awaiting decision at ${step}` });
25
- }
26
- }
27
- if (pills.length === 0) return <span className="text-fg-dim">—</span>;
28
- return (
29
- <div className="flex flex-wrap items-center gap-0.5">
30
- {pills.map((p, i) => (
31
- <span key={i} className="flex items-center gap-0.5">
32
- <Badge variant={p.variant} size="sm" title={p.title}>{p.label}{p.suffix ?? ""}</Badge>
33
- {i < pills.length - 1 && <span className="text-fg-dim text-[10px] mx-0.5">❯</span>}
34
- </span>
35
- ))}
36
- </div>
37
- );
38
- }
@@ -1,24 +0,0 @@
1
- // Compact stacked-bar + total for the home runs table "subflows" column.
2
-
3
- import type { ParallelGroupSummary } from "@/api/types";
4
-
5
- export function SubflowSummary({ groups }: { groups: ParallelGroupSummary[] | null }) {
6
- if (!groups || groups.length === 0) return <span className="text-fg-dim">—</span>;
7
- let total = 0, done = 0, awaiting = 0, failed = 0, running = 0;
8
- for (const g of groups) { total += g.total; done += g.done; awaiting += g.awaiting; failed += g.failed; running += g.running; }
9
- const pct = (n: number) => total > 0 ? `${(n / total * 100).toFixed(1)}%` : "0%";
10
- const tooltip = groups.map((g) =>
11
- `${g.groupId}: ${g.total} · ${g.done} done · ${g.awaiting} awaiting · ${g.failed} failed · ${g.running} running`
12
- ).join(" | ");
13
- return (
14
- <div className="flex items-center min-w-[100px]" title={tooltip}>
15
- <div className="flex h-1.5 flex-1 rounded-[3px] overflow-hidden bg-bg-elev2">
16
- <span className="bg-status-blue" style={{ width: pct(done) }} />
17
- <span className="bg-status-green" style={{ width: pct(running) }} />
18
- <span className="bg-status-red" style={{ width: pct(failed) }} />
19
- <span className="bg-status-grey" style={{ width: pct(awaiting) }} />
20
- </div>
21
- <span className="ml-1.5 font-mono text-[11px] text-fg-dim">{done}/{total}</span>
22
- </div>
23
- );
24
- }
@@ -1,327 +0,0 @@
1
- // Per-group view on the run-detail page, one group per kind:"subflow" node
2
- // that produced subflows. Shows the group header (counts), aggregated
3
- // paths summary, sub-step funnel bars, and a sorted table of subflows
4
- // with their actual trajectories as pills. Each subflow row is clickable →
5
- // expands inline to show per-sub-step outputs, errors, and the
6
- // transcripts belonging to that subflow.
7
- //
8
- // Subflow data comes from GET /api/runs/:flowId/subflows (flow_branches,
9
- // not stateJson — subflow data hasn't lived on stateJson since the
10
- // branch-store migration), fetched by RunDetail and passed down.
11
-
12
- import { Fragment, useState } from "react";
13
- import { Card, CardHeader } from "./ui/card";
14
- import { Badge } from "./ui/badge";
15
- import { Table, THead, TBody, TR, TH, TD } from "./ui/table";
16
- import { SubflowPathPills } from "./SubflowPathPills";
17
- import { GroupPathsSummary } from "./GroupPathsSummary";
18
- import { TranscriptRow } from "./TranscriptRow";
19
- import { StateTree } from "./StateTree";
20
- import { badgeVariantForSubflow, subflowStatus, inferSubStepOrder, statusRank } from "@/lib/subflow";
21
- import { formatTime } from "@/lib/format";
22
- import type { SubflowData, Pipeline, Transcript } from "@/api/types";
23
-
24
- interface SubflowsCardProps {
25
- subflows: Record<string, Record<string, SubflowData>> | null;
26
- pipeline: Pipeline | null;
27
- /** Lifted from RunDetail; null while loading, [] when fetched. */
28
- transcripts: Transcript[] | null;
29
- }
30
-
31
- export function SubflowsCard({ subflows, pipeline, transcripts }: SubflowsCardProps) {
32
- const parallel = subflows;
33
- if (!parallel || typeof parallel !== "object" || Object.keys(parallel).length === 0) return null;
34
-
35
- let totalSubflows = 0;
36
- const groups = Object.entries(parallel);
37
- for (const [, b] of groups) totalSubflows += b ? Object.keys(b).length : 0;
38
-
39
- return (
40
- <Card>
41
- <CardHeader>
42
- <h3 className="text-sm font-semibold m-0">subflows</h3>
43
- <span className="text-fg-dim font-mono text-xs">
44
- {totalSubflows} total across {groups.length} group(s)
45
- </span>
46
- </CardHeader>
47
- {groups.map(([groupId, subflows]) => (
48
- <GroupSection
49
- key={groupId}
50
- groupId={groupId}
51
- subflows={subflows ?? {}}
52
- pipeline={pipeline}
53
- transcripts={transcripts}
54
- />
55
- ))}
56
- </Card>
57
- );
58
- }
59
-
60
- function GroupSection({
61
- groupId,
62
- subflows,
63
- pipeline,
64
- transcripts,
65
- }: {
66
- groupId: string;
67
- subflows: Record<string, SubflowData>;
68
- pipeline: Pipeline | null;
69
- transcripts: Transcript[] | null;
70
- }) {
71
- const [openSubflowId, setOpenSubflowId] = useState<string | null>(null);
72
- const [openTranscriptKey, setOpenTranscriptKey] = useState<string | null>(null);
73
- const entries = Object.entries(subflows);
74
- if (entries.length === 0) return null;
75
- const subflowArr = entries.map(([_, b]) => b);
76
- const pipelineNode = pipeline?.nodes.find((n) => n.id === groupId);
77
- const subSteps = inferSubStepOrder(pipelineNode, subflowArr);
78
-
79
- const doneCount = entries.filter(([_, b]) => b?.step === "__end__" && !b?.failedAt).length;
80
- const failedCount = entries.filter(([_, b]) => b?.failedAt).length;
81
- const awaitingCount = entries.filter(([_, b]) => b?.awaiting).length;
82
- const runningCount = entries.length - doneCount - failedCount - awaitingCount;
83
-
84
- type FunnelRow = { key: string; label: string; count: number };
85
- const reachedCounts: FunnelRow[] = subSteps.map((step) => ({
86
- key: step,
87
- label: step,
88
- count: entries.filter(([_, b]) => stepReached(b, step, subSteps)).length,
89
- }));
90
-
91
- const sorted = [...entries].sort(([_, a], [__, b]) => statusRank(a) - statusRank(b));
92
-
93
- return (
94
- <div className="mb-[18px]">
95
- <CardHeader className="mb-2">
96
- <h3 className="text-[13px] font-semibold font-mono m-0">{groupId}</h3>
97
- <span className="text-fg-dim font-mono text-xs">
98
- {entries.length} subflow{entries.length === 1 ? "" : "s"} · {doneCount} done · {awaitingCount} awaiting · {failedCount} failed · {runningCount} running
99
- </span>
100
- </CardHeader>
101
-
102
- <GroupPathsSummary entries={entries} subSteps={subSteps} />
103
-
104
- {/* Single grid container: per-row layout is label | bar | count. */}
105
- <div className="grid grid-cols-[200px_1fr_40px] gap-x-2.5 gap-y-1 font-mono text-xs mb-3">
106
- {reachedCounts.map((s) => {
107
- const barWidth = `${(s.count / Math.max(1, entries.length) * 100).toFixed(1)}%`;
108
- return (
109
- <Fragment key={s.key}>
110
- <span className="text-fg-dim">{s.label}</span>
111
- <div className="relative h-3 bg-bg-elev2 rounded-[2px] overflow-hidden">
112
- <div
113
- className="absolute top-0 left-0 bottom-0"
114
- style={{
115
- width: barWidth,
116
- background: "linear-gradient(90deg, #1f6feb, #58a6ff)",
117
- }}
118
- />
119
- </div>
120
- <span className="text-right text-fg-dim">{s.count}</span>
121
- </Fragment>
122
- );
123
- })}
124
- </div>
125
-
126
- {/*
127
- Mobile-first card list (<sm). The desktop table's 6 columns
128
- clipped error + updated off-screen at 390px and the path pill
129
- column was unreadable. Card layout puts status + truncated id
130
- on row 1, path pills wrap to row 2, updated + error on row 3.
131
- The whole card is the tap-target — drops the arrow indicator.
132
- */}
133
- <div className="sm:hidden flex flex-col gap-1.5 text-xs">
134
- {sorted.map(([bid, b]) => {
135
- const status = subflowStatus(b);
136
- const data = b?.data ?? {};
137
- const errorBit = b?.failedAt
138
- ? (b.errorEntries?.[b.errorEntries.length - 1]?.message ?? "").slice(0, 80)
139
- : (data.DRAFT?._error ? `DRAFT: ${String(data.DRAFT._error).slice(0, 80)}` : "");
140
- const display = bid.length > 32 ? bid.slice(0, 29) + "…" : bid;
141
- const isOpen = openSubflowId === bid;
142
- return (
143
- <div
144
- key={bid}
145
- className="rounded border border-border bg-bg-elev2/30"
146
- >
147
- <button
148
- type="button"
149
- onClick={() => { setOpenSubflowId(isOpen ? null : bid); setOpenTranscriptKey(null); }}
150
- className="block w-full text-left px-2.5 py-2 hover:bg-bg-elev2"
151
- aria-expanded={isOpen}
152
- >
153
- <div className="flex items-center gap-2">
154
- <Badge variant={badgeVariantForSubflow(status)}>{status}</Badge>
155
- <span className="font-mono truncate flex-1" title={bid}>{display}</span>
156
- <span className="text-[10px] text-fg-dim shrink-0">{formatTime(b?.updatedAt ?? null)}</span>
157
- <span className="text-[10px] text-fg-dim">{isOpen ? "▾" : "▸"}</span>
158
- </div>
159
- <div className="mt-1.5">
160
- <SubflowPathPills subflow={b} subSteps={subSteps} />
161
- </div>
162
- {errorBit && (
163
- <div className="mt-1 text-fg-dim text-[11px] break-words">{errorBit}</div>
164
- )}
165
- </button>
166
- {isOpen && (
167
- <SubflowDetail
168
- subflowId={bid}
169
- subflow={b}
170
- groupId={groupId}
171
- transcripts={transcripts}
172
- openTranscriptKey={openTranscriptKey}
173
- onToggleTranscript={(k) => setOpenTranscriptKey(openTranscriptKey === k ? null : k)}
174
- />
175
- )}
176
- </div>
177
- );
178
- })}
179
- </div>
180
- <div className="hidden sm:block">
181
- <Table className="text-xs">
182
- <THead>
183
- <TR>
184
- <TH className="w-4"></TH>
185
- <TH>subflow</TH>
186
- <TH>path</TH>
187
- <TH>status</TH>
188
- <TH>updated</TH>
189
- <TH>error</TH>
190
- </TR>
191
- </THead>
192
- <TBody>
193
- {sorted.map(([bid, b]) => {
194
- const status = subflowStatus(b);
195
- const data = b?.data ?? {};
196
- const errorBit = b?.failedAt
197
- ? (b.errorEntries?.[b.errorEntries.length - 1]?.message ?? "").slice(0, 60)
198
- : (data.DRAFT?._error ? `DRAFT: ${String(data.DRAFT._error).slice(0, 60)}` : "");
199
- const display = bid.length > 28 ? bid.slice(0, 25) + "…" : bid;
200
- const isOpen = openSubflowId === bid;
201
- return (
202
- <Fragment key={bid}>
203
- <TR
204
- className="cursor-pointer hover:bg-bg-elev2"
205
- onClick={() => { setOpenSubflowId(isOpen ? null : bid); setOpenTranscriptKey(null); }}
206
- >
207
- <TD className="text-fg-dim font-mono">{isOpen ? "▾" : "▸"}</TD>
208
- <TD className="font-mono text-xs" title={bid}>{display}</TD>
209
- <TD><SubflowPathPills subflow={b} subSteps={subSteps} /></TD>
210
- <TD><Badge variant={badgeVariantForSubflow(status)}>{status}</Badge></TD>
211
- <TD className="text-fg-dim font-mono">{formatTime(b?.updatedAt ?? null)}</TD>
212
- <TD className="text-fg-dim text-xs">{errorBit}</TD>
213
- </TR>
214
- {isOpen && (
215
- <TR>
216
- <TD colSpan={6} className="!p-0">
217
- <SubflowDetail
218
- subflowId={bid}
219
- subflow={b}
220
- groupId={groupId}
221
- transcripts={transcripts}
222
- openTranscriptKey={openTranscriptKey}
223
- onToggleTranscript={(k) => setOpenTranscriptKey(openTranscriptKey === k ? null : k)}
224
- />
225
- </TD>
226
- </TR>
227
- )}
228
- </Fragment>
229
- );
230
- })}
231
- </TBody>
232
- </Table>
233
- </div>
234
- </div>
235
- );
236
- }
237
-
238
- function SubflowDetail({
239
- subflowId,
240
- subflow,
241
- groupId,
242
- transcripts,
243
- openTranscriptKey,
244
- onToggleTranscript,
245
- }: {
246
- subflowId: string;
247
- subflow: SubflowData | undefined;
248
- groupId: string;
249
- transcripts: Transcript[] | null;
250
- openTranscriptKey: string | null;
251
- onToggleTranscript: (session: string) => void;
252
- }) {
253
- const data = subflow?.data ?? {};
254
- const dataEntries = Object.entries(data);
255
- const errors = subflow?.errorEntries ?? [];
256
- // Match transcripts whose itemKey is this subflow's id. The session
257
- // tail is `<nodeId>-<itemKey>`, parsed by the server; nodes inside a
258
- // subflow use `<parentId>.<childId>` so we also accept transcripts
259
- // whose nodeId starts with `${groupId.toLowerCase()}.` — belt and
260
- // suspenders for casing skew between source and runtime.
261
- const subflowTranscripts = (transcripts ?? []).filter(
262
- (t) => t.itemKey === subflowId,
263
- );
264
-
265
- return (
266
- <div className="border-t border-border bg-bg-elev2/20 px-3 py-3 grid gap-3">
267
- <div>
268
- <div className="text-fg-dim text-[11px] uppercase tracking-[0.5px] mb-1.5">sub-step outputs</div>
269
- {dataEntries.length === 0
270
- ? <div className="text-fg-dim italic text-xs">(no sub-step data yet)</div>
271
- : (
272
- <div className="grid gap-0.5">
273
- {dataEntries.map(([step, result]) => (
274
- <StateTree key={step} value={result} label={step} />
275
- ))}
276
- </div>
277
- )}
278
- </div>
279
-
280
- {errors.length > 0 && (
281
- <div>
282
- <div className="text-fg-dim text-[11px] uppercase tracking-[0.5px] mb-1.5">errors</div>
283
- <div className="grid gap-1">
284
- {errors.map((e, i) => (
285
- <pre key={i} className="text-xs text-status-red whitespace-pre-wrap break-words bg-bg-elev2/40 rounded p-2">
286
- {e.nodeId}: {e.message}
287
- </pre>
288
- ))}
289
- </div>
290
- </div>
291
- )}
292
-
293
- <div>
294
- <div className="text-fg-dim text-[11px] uppercase tracking-[0.5px] mb-1.5">
295
- transcripts {subflowTranscripts.length > 0 && <span className="text-fg-dim normal-case tracking-normal">· {subflowTranscripts.length} session{subflowTranscripts.length === 1 ? "" : "s"}</span>}
296
- </div>
297
- {transcripts === null
298
- ? <div className="text-fg-dim italic text-xs">loading…</div>
299
- : subflowTranscripts.length === 0
300
- ? <div className="text-fg-dim italic text-xs">no subagent sessions matched (itemKey={subflowId}, group={groupId})</div>
301
- : (
302
- <div className="grid gap-1.5">
303
- {subflowTranscripts.map((t) => (
304
- <TranscriptRow
305
- key={t.session}
306
- transcript={t}
307
- isOpen={openTranscriptKey === t.session}
308
- onToggle={() => onToggleTranscript(t.session)}
309
- hideItemKey
310
- />
311
- ))}
312
- </div>
313
- )}
314
- </div>
315
- </div>
316
- );
317
- }
318
-
319
-
320
- function stepReached(b: SubflowData | undefined, target: string, allSteps: string[]): boolean {
321
- if (!b) return false;
322
- if (b.data && target in b.data) return true;
323
- if (b.step === "__end__") return b.data ? target in b.data : false;
324
- const curIdx = allSteps.indexOf(b.step ?? "");
325
- const tgtIdx = allSteps.indexOf(target);
326
- return curIdx >= 0 && tgtIdx >= 0 && curIdx >= tgtIdx;
327
- }
@@ -1,86 +0,0 @@
1
- // Last-24h activity strip — compact "is anything on fire right now?"
2
- // glance. Used at the home overview (cross-pipeline) and at each
3
- // pipeline-detail page (pipeline-scoped). The parent computes the
4
- // scope-specific values; this component is pure presentation, so the
5
- // same UI serves both surfaces.
6
-
7
- import { Skeleton } from "@/components/ui/skeleton";
8
- import { cn } from "@/lib/utils";
9
-
10
- export const DAY_MS = 86_400_000;
11
-
12
- export type Last24hRuns = { total: number; ok: number; failed: number; active: number };
13
-
14
- export function TodayStrip({
15
- runs,
16
- newFailures,
17
- spent,
18
- loading,
19
- className,
20
- }: {
21
- runs: Last24hRuns;
22
- /** Count of failure clusters whose most-recent failure landed in the window. */
23
- newFailures: number;
24
- /** { value, title? }: estimated spend in the window + an optional
25
- * tooltip explaining how the estimate was derived. */
26
- spent: { value: number; title?: string };
27
- loading?: boolean;
28
- /** Extra classes merged onto the outer container — lets parents
29
- * tweak spacing per-view (the pipeline-detail page needs a bottom
30
- * margin before StatStrip; the home doesn't since its sibling h2
31
- * already provides mt-6). */
32
- className?: string;
33
- }) {
34
- if (loading) {
35
- return (
36
- <div className={cn("bg-bg-elev border border-border rounded-md px-3 py-2 mt-3 flex items-center gap-4", className)}>
37
- <Skeleton className="h-3 w-12" />
38
- <Skeleton className="h-3 w-20" />
39
- <Skeleton className="h-3 w-32" />
40
- <Skeleton className="h-3 w-24" />
41
- </div>
42
- );
43
- }
44
- return (
45
- <div className={cn("bg-bg-elev border border-border rounded-md px-3 py-2 mt-3 flex items-center gap-4 flex-wrap font-mono text-xs", className)}>
46
- <span className="text-fg-dim uppercase tracking-[0.5px] text-[11px]">last 24h</span>
47
- <span
48
- className={runs.total === 0 ? "text-fg-dim" : "text-fg"}
49
- title={`${runs.ok} ok · ${runs.failed} fail · ${runs.active} active`}
50
- >
51
- <span className="tabular-nums">{runs.total}</span> run{runs.total === 1 ? "" : "s"}
52
- </span>
53
- <span className={newFailures === 0 ? "text-fg-dim" : "text-status-red"}>
54
- <span className="tabular-nums">{newFailures}</span> new failure cluster{newFailures === 1 ? "" : "s"}
55
- </span>
56
- <span
57
- className={spent.value === 0 ? "text-fg-dim" : "text-fg"}
58
- title={spent.title}
59
- >
60
- <span className="tabular-nums">~${spent.value.toFixed(2)}</span> spent
61
- </span>
62
- </div>
63
- );
64
- }
65
-
66
- // Estimated last-24h spend from a perDay (UTC-calendar-day buckets)
67
- // array. Today's bucket falls fully inside the window; yesterday's
68
- // overlaps by (24 − hoursIntoUtcDay)/24, so add that proportional
69
- // slice. Returns { value, title } shaped for the strip's spent prop.
70
- export function estimateLast24hSpent(perDay: { day: string; cost: number }[]): { value: number; title: string } {
71
- const now = Date.now();
72
- const nowDate = new Date(now);
73
- const utcMidnight = Date.UTC(nowDate.getUTCFullYear(), nowDate.getUTCMonth(), nowDate.getUTCDate());
74
- const hoursIntoUtcDay = (now - utcMidnight) / 3_600_000;
75
- const yesterdayShare = Math.max(0, Math.min(1, (24 - hoursIntoUtcDay) / 24));
76
- const utcDayKey = (d: Date) =>
77
- `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, "0")}-${String(d.getUTCDate()).padStart(2, "0")}`;
78
- const todayKey = utcDayKey(nowDate);
79
- const yesterdayKey = utcDayKey(new Date(now - DAY_MS));
80
- const todayCost = perDay.find((d) => d.day === todayKey)?.cost ?? 0;
81
- const yesterdayCost = perDay.find((d) => d.day === yesterdayKey)?.cost ?? 0;
82
- return {
83
- value: todayCost + yesterdayCost * yesterdayShare,
84
- title: `≈ today's UTC bucket ($${todayCost.toFixed(2)}) + ${Math.round(yesterdayShare * 100)}% of yesterday's ($${yesterdayCost.toFixed(2)})`,
85
- };
86
- }