@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,84 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
}
|