@tangle-network/agent-app 0.60.282 → 0.60.283
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/dist/app-auth/index.js +2 -2
- package/dist/assistant/index.js +6 -5
- package/dist/assistant/index.js.map +1 -1
- package/dist/chat-react/index.js +1 -1
- package/dist/chat-routes/index.js +18 -18
- package/dist/chunk-276PF4R6.js +342 -0
- package/dist/chunk-276PF4R6.js.map +1 -0
- package/dist/{chunk-VJBFCNAU.js → chunk-7D5MHMCP.js} +4 -4
- package/dist/{chunk-4P5NFBWX.js → chunk-BI5AZAOO.js} +4 -4
- package/dist/{chunk-FBVLEGEG.js → chunk-GDUT72VK.js} +34 -6
- package/dist/chunk-GDUT72VK.js.map +1 -0
- package/dist/{chunk-LO6VQ35O.js → chunk-U77HPL3I.js} +2 -2
- package/dist/{chunk-YI2XZCTP.js → chunk-WEUCLHAP.js} +5 -48
- package/dist/chunk-WEUCLHAP.js.map +1 -0
- package/dist/design-canvas/index.js +3 -3
- package/dist/design-canvas-react/index.js +4 -4
- package/dist/launch-invariants/index.js +8 -8
- package/dist/openui/index.js +3 -3
- package/dist/platform/index.js +12 -12
- package/dist/profile/index.js +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/router-turn.js +2 -2
- package/dist/sequences/index.js +5 -5
- package/dist/settings-react/index.js +1 -1
- package/dist/skills/index.js +3 -3
- package/dist/skills-placement/box.js +1 -1
- package/dist/skills-placement/index.js +1 -1
- package/dist/stories/chat-controls/discovery-waterfall-fixture.d.ts +3 -0
- package/dist/theme/tokens.css +72 -0
- package/dist/trace/flow-types.d.ts +9 -1
- package/dist/trace/index.d.ts +1 -0
- package/dist/trace/index.js +14 -1
- package/dist/trace/index.js.map +1 -1
- package/dist/trace/mission-flow.d.ts +2 -3
- package/dist/turn-stream/index.js +3 -3
- package/dist/web-react/flow-waterfall-model.d.ts +22 -0
- package/dist/web-react/flow-waterfall.css +72 -0
- package/dist/web-react/flow-waterfall.d.ts +14 -0
- package/dist/web-react/flow-waterfall.js +7 -0
- package/dist/web-react/flow-waterfall.js.map +1 -0
- package/dist/web-react/index.js +14 -12
- package/dist/web-react/mission-activity.d.ts +2 -20
- package/dist/work-product/index.js +10 -10
- package/package.json +14 -7
- package/dist/chunk-FBVLEGEG.js.map +0 -1
- package/dist/chunk-YI2XZCTP.js.map +0 -1
- /package/dist/{chunk-VJBFCNAU.js.map → chunk-7D5MHMCP.js.map} +0 -0
- /package/dist/{chunk-4P5NFBWX.js.map → chunk-BI5AZAOO.js.map} +0 -0
- /package/dist/{chunk-LO6VQ35O.js.map → chunk-U77HPL3I.js.map} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FlowTrace } from '../trace/flow-types';
|
|
2
|
+
export interface FlowWaterfallProps {
|
|
3
|
+
trace: FlowTrace;
|
|
4
|
+
/** Extend running spans between incoming snapshots. Inferred from span status by default. */
|
|
5
|
+
live?: boolean;
|
|
6
|
+
/** Epoch-ms origin when the producer supplies one; otherwise advance from the latest snapshot. */
|
|
7
|
+
startedAt?: number;
|
|
8
|
+
/** Accessible name also distinguishes multiple waterfalls on one page. */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** Fold all branches on first mount for large traces; search still reveals matches. */
|
|
11
|
+
defaultCollapsed?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Shared trace inspector. Data remains producer-owned; playback only clips its presentation. */
|
|
14
|
+
export declare function FlowWaterfall({ trace, live, startedAt, label, defaultCollapsed }: FlowWaterfallProps): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/web-react/index.js
CHANGED
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
DurablePlanCard,
|
|
22
22
|
DurablePlanClientError,
|
|
23
23
|
EMPTY_RECORD_GRID_OVERLAY,
|
|
24
|
-
FlowWaterfall,
|
|
25
24
|
INDEX_REFRESH_AFTER_MS,
|
|
26
25
|
INTERACTION_SUBMIT_TIMEOUT_MESSAGE,
|
|
27
26
|
INTERACTION_SUBMIT_TIMEOUT_MS,
|
|
@@ -137,7 +136,6 @@ import {
|
|
|
137
136
|
useThinkingSeconds,
|
|
138
137
|
validateRecordGridCell,
|
|
139
138
|
validateRecordGridRow,
|
|
140
|
-
waterfallLayout,
|
|
141
139
|
weakerProvenanceStanding,
|
|
142
140
|
withRecordGridCreated,
|
|
143
141
|
withRecordGridRemoved,
|
|
@@ -146,14 +144,18 @@ import {
|
|
|
146
144
|
withoutRecordGridCreated,
|
|
147
145
|
withoutRecordGridRemoved,
|
|
148
146
|
withoutRecordGridUpdate
|
|
149
|
-
} from "../chunk-
|
|
147
|
+
} from "../chunk-WEUCLHAP.js";
|
|
150
148
|
import {
|
|
151
149
|
useInfiniteScroll
|
|
152
150
|
} from "../chunk-BDEBQ4WO.js";
|
|
153
151
|
import {
|
|
154
152
|
MENTION_PILL_CLASS
|
|
155
153
|
} from "../chunk-3HUFJ5LO.js";
|
|
156
|
-
import
|
|
154
|
+
import {
|
|
155
|
+
tabTerminalConnectionId,
|
|
156
|
+
useSandboxTerminalConnection
|
|
157
|
+
} from "../chunk-E4AY62T2.js";
|
|
158
|
+
import "../chunk-GDUT72VK.js";
|
|
157
159
|
import {
|
|
158
160
|
AGENT_PROFILE_EDITOR_SECTIONS,
|
|
159
161
|
AgentProfileEditor,
|
|
@@ -228,19 +230,15 @@ import {
|
|
|
228
230
|
usePending,
|
|
229
231
|
usePopover
|
|
230
232
|
} from "../chunk-R4X5474U.js";
|
|
231
|
-
import {
|
|
232
|
-
tabTerminalConnectionId,
|
|
233
|
-
useSandboxTerminalConnection
|
|
234
|
-
} from "../chunk-E4AY62T2.js";
|
|
235
233
|
import "../chunk-SJWIZT7B.js";
|
|
234
|
+
import {
|
|
235
|
+
ProviderLogo
|
|
236
|
+
} from "../chunk-RASGKEAL.js";
|
|
236
237
|
import {
|
|
237
238
|
ReviewFeedbackForm
|
|
238
239
|
} from "../chunk-ATQQCG4I.js";
|
|
239
240
|
import "../chunk-WSEXFTN4.js";
|
|
240
241
|
import "../chunk-AVP5SNIG.js";
|
|
241
|
-
import {
|
|
242
|
-
ProviderLogo
|
|
243
|
-
} from "../chunk-RASGKEAL.js";
|
|
244
242
|
import "../chunk-FQYAJYPW.js";
|
|
245
243
|
import {
|
|
246
244
|
ALLOWED_ATTACHMENT_SNIFFED_MIMES,
|
|
@@ -248,7 +246,6 @@ import {
|
|
|
248
246
|
OOXML_SNIFFED_MIMES
|
|
249
247
|
} from "../chunk-IUVDR3KJ.js";
|
|
250
248
|
import "../chunk-B7CL7ENS.js";
|
|
251
|
-
import "../chunk-AMUXRAUO.js";
|
|
252
249
|
import {
|
|
253
250
|
attachmentInputToPart,
|
|
254
251
|
attachmentKindForMime,
|
|
@@ -309,10 +306,15 @@ import {
|
|
|
309
306
|
questionInteractionContentSignature,
|
|
310
307
|
stampInteractionAnswers
|
|
311
308
|
} from "../chunk-6VQCFJWP.js";
|
|
309
|
+
import "../chunk-AMUXRAUO.js";
|
|
312
310
|
import "../chunk-FPNZMIAW.js";
|
|
313
311
|
import "../chunk-PV33JZKV.js";
|
|
314
312
|
import "../chunk-TXD5HXLE.js";
|
|
315
313
|
import "../chunk-WL7PZK7Q.js";
|
|
314
|
+
import {
|
|
315
|
+
FlowWaterfall,
|
|
316
|
+
waterfallLayout
|
|
317
|
+
} from "../chunk-276PF4R6.js";
|
|
316
318
|
export {
|
|
317
319
|
AGENT_PROFILE_EDITOR_SECTIONS,
|
|
318
320
|
ALLOWED_ATTACHMENT_SNIFFED_MIMES,
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { type ReactNode } from 'react';
|
|
19
19
|
import type { StepAgentActivity } from '../missions/agent-activity';
|
|
20
|
-
import type { FlowTrace } from '../trace/index';
|
|
21
20
|
export type ActivityTone = 'live' | 'ok' | 'error' | 'neutral';
|
|
22
21
|
/** Map a delegation status (free-form string on the wire) to a render tone. */
|
|
23
22
|
export declare function activityTone(status: string): ActivityTone;
|
|
@@ -45,25 +44,8 @@ export interface AgentActivityPage {
|
|
|
45
44
|
* snapshots of in-flight runs replace stale ones), newest `startedAt` first.
|
|
46
45
|
*/
|
|
47
46
|
export declare function mergeActivityPages(existing: AgentActivityRecord[], incoming: AgentActivityRecord[]): AgentActivityRecord[];
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
kind: 'pipeline' | 'model' | 'tool';
|
|
51
|
-
/** Bar geometry as percentages of the trace's total span. */
|
|
52
|
-
offsetPct: number;
|
|
53
|
-
widthPct: number;
|
|
54
|
-
durationLabel: string;
|
|
55
|
-
approx: boolean;
|
|
56
|
-
/** False only when the span's meta carries an explicit failure. */
|
|
57
|
-
ok: boolean;
|
|
58
|
-
}
|
|
59
|
-
/** Project a FlowTrace into proportional bar geometry for {@link FlowWaterfall}. */
|
|
60
|
-
export declare function waterfallLayout(trace: FlowTrace): WaterfallRow[];
|
|
61
|
-
export interface FlowWaterfallProps {
|
|
62
|
-
trace: FlowTrace;
|
|
63
|
-
}
|
|
64
|
-
/** Compact proportional waterfall over a FlowTrace — span name, bar, duration
|
|
65
|
-
* per row; total + cost in the footer. */
|
|
66
|
-
export declare function FlowWaterfall({ trace }: FlowWaterfallProps): import("react").JSX.Element | null;
|
|
47
|
+
export { waterfallLayout, type WaterfallRow } from './flow-waterfall-model';
|
|
48
|
+
export { FlowWaterfall, type FlowWaterfallProps } from './flow-waterfall';
|
|
67
49
|
export interface MissionActivityLaneProps {
|
|
68
50
|
/** The step's delegated-run snapshot (`MissionStepState.agentActivity`). */
|
|
69
51
|
activity: StepAgentActivity[];
|
|
@@ -2,6 +2,16 @@ import {
|
|
|
2
2
|
parseReviewQueueItem,
|
|
3
3
|
projectReviewQueue
|
|
4
4
|
} from "../chunk-GEYACSFW.js";
|
|
5
|
+
import {
|
|
6
|
+
isWorkProductStatus,
|
|
7
|
+
parseAgentCheckInput,
|
|
8
|
+
parseArtifactInput,
|
|
9
|
+
parseEvidenceInput,
|
|
10
|
+
parseExceptionInput,
|
|
11
|
+
persistedPartToWorkProduct,
|
|
12
|
+
unresolvedBlockingExceptions,
|
|
13
|
+
workProductToPersistedPart
|
|
14
|
+
} from "../chunk-ZVEEWGDK.js";
|
|
5
15
|
import {
|
|
6
16
|
artifactAgreementErrorDetail,
|
|
7
17
|
canonicalizeValue,
|
|
@@ -21,16 +31,6 @@ import "../chunk-UGWQLQDS.js";
|
|
|
21
31
|
import {
|
|
22
32
|
ToolInputError
|
|
23
33
|
} from "../chunk-WSQFNMIA.js";
|
|
24
|
-
import {
|
|
25
|
-
isWorkProductStatus,
|
|
26
|
-
parseAgentCheckInput,
|
|
27
|
-
parseArtifactInput,
|
|
28
|
-
parseEvidenceInput,
|
|
29
|
-
parseExceptionInput,
|
|
30
|
-
persistedPartToWorkProduct,
|
|
31
|
-
unresolvedBlockingExceptions,
|
|
32
|
-
workProductToPersistedPart
|
|
33
|
-
} from "../chunk-ZVEEWGDK.js";
|
|
34
34
|
|
|
35
35
|
// src/work-product/service.ts
|
|
36
36
|
var WORK_PRODUCT_TRANSITIONS = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-app",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.283",
|
|
4
4
|
"packageManager": "pnpm@11.24.0",
|
|
5
5
|
"description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
|
|
6
6
|
"keywords": [
|
|
@@ -736,6 +736,12 @@
|
|
|
736
736
|
"import": "./dist/theme/dom.js",
|
|
737
737
|
"default": "./dist/theme/dom.js"
|
|
738
738
|
},
|
|
739
|
+
"./web-react/flow-waterfall": {
|
|
740
|
+
"types": "./dist/web-react/flow-waterfall.d.ts",
|
|
741
|
+
"import": "./dist/web-react/flow-waterfall.js",
|
|
742
|
+
"default": "./dist/web-react/flow-waterfall.js"
|
|
743
|
+
},
|
|
744
|
+
"./web-react/flow-waterfall.css": "./dist/web-react/flow-waterfall.css",
|
|
739
745
|
"./web-react/document": {
|
|
740
746
|
"types": "./dist/web-react/document.d.ts",
|
|
741
747
|
"import": "./dist/web-react/document.js",
|
|
@@ -784,7 +790,7 @@
|
|
|
784
790
|
"storybook": "storybook dev -p 6006",
|
|
785
791
|
"build-storybook": "storybook build",
|
|
786
792
|
"adopt:sync": "node scripts/adopt-sync.mjs",
|
|
787
|
-
"test:eval-compat": "vitest run --config vitest.eval-compat.config.ts && AGENT_EVAL_COMPAT=agent-eval-0211 vitest run --config vitest.eval-compat.config.ts && AGENT_EVAL_COMPAT=agent-eval-0217 vitest run --config vitest.eval-compat.config.ts"
|
|
793
|
+
"test:eval-compat": "vitest run --config vitest.eval-compat.config.ts && AGENT_EVAL_COMPAT=agent-eval-0211 vitest run --config vitest.eval-compat.config.ts && AGENT_EVAL_COMPAT=agent-eval-0217 vitest run --config vitest.eval-compat.config.ts && AGENT_EVAL_COMPAT=agent-eval-0218 vitest run --config vitest.eval-compat.config.ts"
|
|
788
794
|
},
|
|
789
795
|
"devDependencies": {
|
|
790
796
|
"zod": "4.4.3",
|
|
@@ -796,13 +802,13 @@
|
|
|
796
802
|
"@storybook/react-vite": "^10.5.10",
|
|
797
803
|
"@tailwindcss/postcss": "^4.3.3",
|
|
798
804
|
"@tangle-network/agent-docs": "0.2.1",
|
|
799
|
-
"@tangle-network/agent-eval": "0.
|
|
805
|
+
"@tangle-network/agent-eval": "0.220.1",
|
|
800
806
|
"@tangle-network/agent-gateway": "0.11.4",
|
|
801
807
|
"@tangle-network/agent-integrations": "0.75.4",
|
|
802
808
|
"@tangle-network/agent-interface": "5.7.0",
|
|
803
|
-
"@tangle-network/agent-knowledge": "22.0.
|
|
809
|
+
"@tangle-network/agent-knowledge": "22.0.13",
|
|
804
810
|
"@tangle-network/agent-profile-materialize": "0.27.1",
|
|
805
|
-
"@tangle-network/agent-runtime": "0.343.
|
|
811
|
+
"@tangle-network/agent-runtime": "0.343.4",
|
|
806
812
|
"@tangle-network/brand": "1.26.2",
|
|
807
813
|
"@tangle-network/hub-sdk": "0.30.14",
|
|
808
814
|
"@tangle-network/sandbox": "0.64.12",
|
|
@@ -865,13 +871,14 @@
|
|
|
865
871
|
"nanostores": "1.5.4",
|
|
866
872
|
"agent-eval-0204": "npm:@tangle-network/agent-eval@0.204.0",
|
|
867
873
|
"agent-eval-0211": "npm:@tangle-network/agent-eval@0.211.2",
|
|
868
|
-
"agent-eval-0217": "npm:@tangle-network/agent-eval@0.217.1"
|
|
874
|
+
"agent-eval-0217": "npm:@tangle-network/agent-eval@0.217.1",
|
|
875
|
+
"agent-eval-0218": "npm:@tangle-network/agent-eval@0.218.1"
|
|
869
876
|
},
|
|
870
877
|
"peerDependencies": {
|
|
871
878
|
"@better-auth/oauth-provider": ">=1.7.2",
|
|
872
879
|
"@firecrawl/pdf-inspector-wasm": ">=0.1.3",
|
|
873
880
|
"@huggingface/transformers": ">=3",
|
|
874
|
-
"@tangle-network/agent-eval": ">=0.199.0 <0.205.0 || >=0.205.1 <0.206.0 || >=0.209.1 <0.210.0 || >=0.211.2 <0.212.0 || >=0.213.0 <0.216.0 || >=0.217.1 <0.219.0",
|
|
881
|
+
"@tangle-network/agent-eval": ">=0.199.0 <0.205.0 || >=0.205.1 <0.206.0 || >=0.209.1 <0.210.0 || >=0.211.2 <0.212.0 || >=0.213.0 <0.216.0 || >=0.217.1 <0.219.0 || >=0.220.0 <0.221.0",
|
|
875
882
|
"@tangle-network/agent-integrations": ">=0.54.2 <0.58.0 || >=0.59.0 <0.61.0 || >=0.66.0 <0.67.0 || >=0.67.0 <0.68.0 || >=0.68.0 <0.69.0 || >=0.69.0 <0.70.0 || >=0.70.0 <0.71.0 || >=0.75.0 <0.76.0",
|
|
876
883
|
"@tangle-network/agent-interface": "^2.13.0 || ^3.0.0 || ^5.2.0",
|
|
877
884
|
"@tangle-network/agent-knowledge": "^17.1.2 || ^18.0.0 || ^19.0.1 || ^20.0.0 || ^22.0.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/trace/mission-flow.ts"],"sourcesContent":["/**\n * Delegation → FlowSpan converters — render what a mission's delegated agent\n * runs actually did as ONE FlowTrace, drawable by the existing\n * `renderWaterfall` (or any viewer that consumes FlowSpans).\n *\n * Two fidelities, one tree:\n * - COARSE: `delegationActivityToFlowSpans` draws one 'tool' span per\n * delegation from the StepAgentActivity snapshot (startedAt/durationMs) —\n * available live, from the step's journaled lane.\n * - FINE: `loopTraceEventsToFlowSpans` reconstructs agent-runtime's\n * loop → round → iteration hierarchy from the LoopTraceEvent journal a\n * delegation persists. FlowSpans carry no parent ids, so nesting rides the\n * span NAME (`loop ▸ round 0 ▸ iter 1 (coder)`), matching how the ASCII\n * waterfall reads.\n *\n * `composeMissionFlowTrace` lays a whole mission out: one 'pipeline' span per\n * step, each step's delegations beneath it. Pure data transforms — the\n * structural `LoopTraceEventLike` keeps this module free of the optional\n * agent-runtime peer.\n */\n\nimport type { StepAgentActivity } from '../missions/agent-activity'\nimport type { FlowSpan, FlowTrace } from './flow-types'\n\n/** Structural mirror of agent-runtime's `LoopTraceEvent` — same fields, no\n * import, so journals parsed from JSON feed straight in. */\nexport interface LoopTraceEventLike {\n kind: string\n runId: string\n /** Epoch ms. */\n timestamp: number\n payload: object\n}\n\nconst num = (v: unknown): number | undefined =>\n typeof v === 'number' && Number.isFinite(v) ? v : undefined\nconst str = (v: unknown): string | undefined =>\n typeof v === 'string' && v.length > 0 ? v : undefined\nconst rec = (v: unknown): Record<string, unknown> =>\n v && typeof v === 'object' ? (v as Record<string, unknown>) : {}\n\n/** Statuses that mean the delegation is still producing wall time. */\nconst LIVE_DELEGATION_STATUSES = new Set(['pending', 'running'])\n\n/**\n * One 'tool' FlowSpan per delegation, positioned relative to `turnStartMs`\n * (the epoch-ms origin of the trace — usually the step or mission start).\n * A row whose `startedAt` does not parse cannot be placed on a timeline and\n * is omitted from the WATERFALL (it stays in the lane itself). A run without\n * `durationMs` is still in flight: its span extends to `opts.nowMs` when\n * given, else renders as a point — `approx` flags both.\n */\nexport function delegationActivityToFlowSpans(\n activity: StepAgentActivity[],\n turnStartMs: number,\n opts?: { nowMs?: number },\n): FlowSpan[] {\n const spans: FlowSpan[] = []\n for (const run of activity) {\n const startedAt = Date.parse(run.startedAt)\n if (!Number.isFinite(startedAt)) continue\n const startMs = startedAt - turnStartMs\n const live = LIVE_DELEGATION_STATUSES.has(run.status)\n const endMs =\n run.durationMs !== undefined\n ? startMs + run.durationMs\n : live && opts?.nowMs !== undefined\n ? opts.nowMs - turnStartMs\n : startMs\n spans.push({\n kind: 'tool',\n name: `${run.tool} — ${run.detail}`,\n startMs,\n endMs: Math.max(endMs, startMs),\n ...(run.durationMs === undefined ? { approx: true } : {}),\n meta: {\n taskId: run.taskId,\n status: run.status,\n ...(run.costUsd !== undefined ? { costUsd: run.costUsd } : {}),\n ...(run.iteration !== undefined ? { iteration: run.iteration } : {}),\n ...(run.phase !== undefined ? { phase: run.phase } : {}),\n ...(run.traceId !== undefined ? { traceId: run.traceId } : {}),\n ...(run.spanId !== undefined ? { spanId: run.spanId } : {}),\n },\n })\n }\n return spans\n}\n\n/**\n * Reconstruct one delegation's loop → round → iteration tree from its\n * journaled LoopTraceEvents, as FlowSpans relative to `loop.started` (or the\n * first event). Mirrors agent-runtime's `buildLoopOtelSpans` topology:\n * rounds open on `loop.plan` and flush on the next plan / `loop.decision` /\n * `loop.ended`; iterations span `loop.iteration.started` → `.ended`.\n */\nexport function loopTraceEventsToFlowSpans(events: LoopTraceEventLike[]): FlowSpan[] {\n if (events.length === 0) return []\n const ordered = [...events].sort((a, b) => a.timestamp - b.timestamp)\n const started = ordered.find((e) => e.kind === 'loop.started')\n const ended = ordered.find((e) => e.kind === 'loop.ended')\n const origin = started?.timestamp ?? ordered[0]!.timestamp\n const rootEnd = ended?.timestamp ?? ordered[ordered.length - 1]!.timestamp\n const t = (epochMs: number) => epochMs - origin\n\n const spans: FlowSpan[] = []\n const sp = rec(started?.payload)\n const ep = rec(ended?.payload)\n spans.push({\n kind: 'pipeline',\n name: 'loop',\n startMs: 0,\n endMs: t(rootEnd),\n meta: {\n runId: ordered[0]!.runId,\n ...(str(sp.driver) !== undefined ? { driver: str(sp.driver) } : {}),\n ...(num(ep.totalCostUsd) !== undefined ? { costUsd: num(ep.totalCostUsd) } : {}),\n ...(num(ep.winnerIterationIndex) !== undefined\n ? { winnerIterationIndex: num(ep.winnerIterationIndex) }\n : {}),\n ...(num(ep.iterations) !== undefined ? { iterations: num(ep.iterations) } : {}),\n },\n })\n\n const iterStart = new Map<number, number>()\n let round: { index: number; startMs: number; meta: Record<string, unknown>; moveKind: string } | undefined\n const flushRound = (endEpochMs: number) => {\n if (!round) return\n spans.push({\n kind: 'pipeline',\n name: `loop ▸ round ${round.index} (${round.moveKind})`,\n startMs: round.startMs,\n endMs: t(endEpochMs),\n meta: round.meta,\n })\n round = undefined\n }\n\n for (const e of ordered) {\n const p = rec(e.payload)\n switch (e.kind) {\n case 'loop.plan': {\n flushRound(e.timestamp)\n const index = num(p.roundIndex) ?? 0\n round = {\n index,\n startMs: t(e.timestamp),\n moveKind: str(p.moveKind) ?? 'unknown',\n meta: {\n roundIndex: index,\n moveKind: str(p.moveKind) ?? 'unknown',\n width: num(p.plannedCount) ?? 0,\n ...(str(p.rationale) !== undefined ? { rationale: str(p.rationale) } : {}),\n ...(num(p.parentIndex) !== undefined ? { parentIndex: num(p.parentIndex) } : {}),\n },\n }\n break\n }\n case 'loop.iteration.started': {\n const idx = num(p.iterationIndex)\n if (idx !== undefined) iterStart.set(idx, e.timestamp)\n break\n }\n case 'loop.iteration.ended': {\n const idx = num(p.iterationIndex) ?? 0\n const startEpoch = iterStart.get(idx) ?? e.timestamp\n const error = str(p.error)\n const verdict = rec(p.verdict)\n const tokens = rec(p.tokenUsage)\n const roundLabel = round ? `round ${round.index} ▸ ` : ''\n spans.push({\n kind: 'model',\n name: `loop ▸ ${roundLabel}iter ${idx} (${str(p.agentRunName) ?? 'agent'})`,\n startMs: t(startEpoch),\n endMs: t(e.timestamp),\n meta: {\n iterationIndex: idx,\n ok: error === undefined,\n ...(error !== undefined ? { error } : {}),\n ...(num(p.costUsd) !== undefined ? { costUsd: num(p.costUsd) } : {}),\n ...(typeof verdict.valid === 'boolean' ? { verdictValid: verdict.valid } : {}),\n ...(num(verdict.score) !== undefined ? { verdictScore: num(verdict.score) } : {}),\n ...(num(tokens.input) !== undefined ? { inputTokens: num(tokens.input) } : {}),\n ...(num(tokens.output) !== undefined ? { outputTokens: num(tokens.output) } : {}),\n },\n })\n break\n }\n case 'loop.decision': {\n if (round) {\n const decision = str(p.decision)\n if (decision !== undefined) round.meta.decision = decision\n flushRound(e.timestamp)\n }\n break\n }\n }\n }\n flushRound(rootEnd)\n return spans\n}\n\n/**\n * A single step's activity lane as its own FlowTrace — what a per-step\n * drill-in renders. Origin defaults to the earliest delegation start so the\n * waterfall begins at the lane's first run.\n */\nexport function stepActivityFlowTrace(\n activity: StepAgentActivity[],\n opts?: { startedAt?: number; nowMs?: number },\n): FlowTrace {\n let origin = opts?.startedAt\n if (origin === undefined) {\n for (const run of activity) {\n const parsed = Date.parse(run.startedAt)\n if (Number.isFinite(parsed) && (origin === undefined || parsed < origin)) origin = parsed\n }\n }\n const spans = delegationActivityToFlowSpans(\n activity,\n origin ?? 0,\n opts?.nowMs !== undefined ? { nowMs: opts.nowMs } : undefined,\n )\n let costUsd: number | undefined\n for (const span of spans) {\n const c = num(rec(span.meta).costUsd)\n if (c !== undefined) costUsd = (costUsd ?? 0) + c\n }\n return {\n spans,\n totalMs: spans.reduce((max, s) => Math.max(max, s.endMs), 0),\n promptTokens: 0,\n completionTokens: 0,\n ...(costUsd !== undefined ? { costUsd } : {}),\n toolCalls: spans.length,\n }\n}\n\n/** Define a step in a mission flow with id, intent, optional status, start time, and duration */\nexport interface MissionFlowStep {\n id: string\n intent: string\n status?: string\n /** Epoch ms the step attempt started. Absent → laid out sequentially after\n * the previous step (missions run steps in order), `approx` flagged. */\n startedAt?: number\n durationMs?: number\n}\n\n/**\n * Compose a mission-wide FlowTrace: one 'pipeline' span per step, the step's\n * delegated runs ('tool' spans, from `activity[stepId]`) beneath it. A step\n * span always covers its delegations' extent. Cost is the sum of delegation\n * `costUsd`; token counts are not knowable from the activity lane and stay 0.\n */\nexport function composeMissionFlowTrace(input: {\n steps: MissionFlowStep[]\n /** Delegated-run snapshots keyed by step id (the step's `agentActivity`). */\n activity?: Record<string, StepAgentActivity[]>\n /** Epoch-ms origin. Default: the earliest known step/delegation start. */\n startedAt?: number\n}): FlowTrace {\n const activity = input.activity ?? {}\n\n const startCandidates: number[] = []\n if (input.startedAt !== undefined) startCandidates.push(input.startedAt)\n else {\n for (const step of input.steps) {\n if (step.startedAt !== undefined) startCandidates.push(step.startedAt)\n }\n for (const runs of Object.values(activity)) {\n for (const run of runs) {\n const parsed = Date.parse(run.startedAt)\n if (Number.isFinite(parsed)) startCandidates.push(parsed)\n }\n }\n }\n const origin = startCandidates.length > 0 ? Math.min(...startCandidates) : 0\n\n const spans: FlowSpan[] = []\n let costUsd: number | undefined\n let toolCalls = 0\n let cursorMs = 0\n\n for (const step of input.steps) {\n const inferred = step.startedAt === undefined\n const startMs = inferred ? cursorMs : step.startedAt! - origin\n const runSpans = delegationActivityToFlowSpans(activity[step.id] ?? [], origin)\n const runExtent = runSpans.reduce((max, s) => Math.max(max, s.endMs), startMs)\n const endMs = Math.max(step.durationMs !== undefined ? startMs + step.durationMs : startMs, runExtent)\n\n spans.push({\n kind: 'pipeline',\n name: step.intent,\n startMs,\n endMs,\n ...(inferred || step.durationMs === undefined ? { approx: true } : {}),\n meta: { stepId: step.id, ...(step.status !== undefined ? { status: step.status } : {}) },\n })\n for (const span of runSpans) {\n spans.push({ ...span, name: `${step.intent} ▸ ${span.name}` })\n toolCalls++\n const c = num(rec(span.meta).costUsd)\n if (c !== undefined) costUsd = (costUsd ?? 0) + c\n }\n cursorMs = endMs\n }\n\n return {\n spans,\n totalMs: spans.reduce((max, s) => Math.max(max, s.endMs), 0),\n promptTokens: 0,\n completionTokens: 0,\n ...(costUsd !== undefined ? { costUsd } : {}),\n toolCalls,\n }\n}\n"],"mappings":";AAkCA,IAAM,MAAM,CAAC,MACX,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAAI,IAAI;AACpD,IAAM,MAAM,CAAC,MACX,OAAO,MAAM,YAAY,EAAE,SAAS,IAAI,IAAI;AAC9C,IAAM,MAAM,CAAC,MACX,KAAK,OAAO,MAAM,WAAY,IAAgC,CAAC;AAGjE,IAAM,2BAA2B,oBAAI,IAAI,CAAC,WAAW,SAAS,CAAC;AAUxD,SAAS,8BACd,UACA,aACA,MACY;AACZ,QAAM,QAAoB,CAAC;AAC3B,aAAW,OAAO,UAAU;AAC1B,UAAM,YAAY,KAAK,MAAM,IAAI,SAAS;AAC1C,QAAI,CAAC,OAAO,SAAS,SAAS,EAAG;AACjC,UAAM,UAAU,YAAY;AAC5B,UAAM,OAAO,yBAAyB,IAAI,IAAI,MAAM;AACpD,UAAM,QACJ,IAAI,eAAe,SACf,UAAU,IAAI,aACd,QAAQ,MAAM,UAAU,SACtB,KAAK,QAAQ,cACb;AACR,UAAM,KAAK;AAAA,MACT,MAAM;AAAA,MACN,MAAM,GAAG,IAAI,IAAI,WAAM,IAAI,MAAM;AAAA,MACjC;AAAA,MACA,OAAO,KAAK,IAAI,OAAO,OAAO;AAAA,MAC9B,GAAI,IAAI,eAAe,SAAY,EAAE,QAAQ,KAAK,IAAI,CAAC;AAAA,MACvD,MAAM;AAAA,QACJ,QAAQ,IAAI;AAAA,QACZ,QAAQ,IAAI;AAAA,QACZ,GAAI,IAAI,YAAY,SAAY,EAAE,SAAS,IAAI,QAAQ,IAAI,CAAC;AAAA,QAC5D,GAAI,IAAI,cAAc,SAAY,EAAE,WAAW,IAAI,UAAU,IAAI,CAAC;AAAA,QAClE,GAAI,IAAI,UAAU,S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