@tangle-network/agent-app 0.60.286 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/app-auth/index.js +2 -2
  2. package/dist/assistant/index.js +5 -6
  3. package/dist/assistant/index.js.map +1 -1
  4. package/dist/chat-react/index.js +1 -1
  5. package/dist/chat-routes/index.js +26 -21
  6. package/dist/chat-routes/index.js.map +1 -1
  7. package/dist/{chunk-BI5AZAOO.js → chunk-4P5NFBWX.js} +4 -4
  8. package/dist/{chunk-GDUT72VK.js → chunk-6OSJNJA2.js} +9 -4
  9. package/dist/chunk-6OSJNJA2.js.map +1 -0
  10. package/dist/{chunk-U77HPL3I.js → chunk-LO6VQ35O.js} +2 -2
  11. package/dist/{chunk-XTMRAE6I.js → chunk-UCCSJX64.js} +3 -5
  12. package/dist/chunk-UCCSJX64.js.map +1 -0
  13. package/dist/{chunk-7D5MHMCP.js → chunk-VJBFCNAU.js} +4 -4
  14. package/dist/design-canvas/index.js +3 -3
  15. package/dist/design-canvas-react/index.js +4 -4
  16. package/dist/launch-invariants/index.js +8 -8
  17. package/dist/openui/index.js +3 -3
  18. package/dist/platform/index.js +12 -12
  19. package/dist/profile/index.js +1 -1
  20. package/dist/runtime/index.js +3 -3
  21. package/dist/runtime/router-turn.js +2 -2
  22. package/dist/sequences/index.js +5 -5
  23. package/dist/settings-react/index.js +1 -1
  24. package/dist/skills/index.js +3 -3
  25. package/dist/skills-placement/box.js +1 -1
  26. package/dist/skills-placement/index.js +1 -1
  27. package/dist/stories/chat-controls/fixtures.d.ts +0 -3
  28. package/dist/theme/tokens.css +10 -6
  29. package/dist/trace/index.d.ts +2 -2
  30. package/dist/trace/index.js +4 -2
  31. package/dist/trace/index.js.map +1 -1
  32. package/dist/trace/mission-flow.d.ts +1 -1
  33. package/dist/turn-stream/index.js +3 -3
  34. package/dist/web-react/index.js +10 -16
  35. package/dist/web-react/mission-activity.d.ts +1 -3
  36. package/dist/work-product/index.js +10 -10
  37. package/package.json +2 -7
  38. package/dist/chunk-BLCYKYFV.js +0 -346
  39. package/dist/chunk-BLCYKYFV.js.map +0 -1
  40. package/dist/chunk-GDUT72VK.js.map +0 -1
  41. package/dist/chunk-XTMRAE6I.js.map +0 -1
  42. package/dist/stories/chat-controls/discovery-waterfall-fixture.d.ts +0 -3
  43. package/dist/trace/flow-types.d.ts +0 -32
  44. package/dist/web-react/flow-waterfall-model.d.ts +0 -22
  45. package/dist/web-react/flow-waterfall.css +0 -72
  46. package/dist/web-react/flow-waterfall.d.ts +0 -14
  47. package/dist/web-react/flow-waterfall.js +0 -7
  48. package/dist/web-react/flow-waterfall.js.map +0 -1
  49. /package/dist/{chunk-BI5AZAOO.js.map → chunk-4P5NFBWX.js.map} +0 -0
  50. /package/dist/{chunk-U77HPL3I.js.map → chunk-LO6VQ35O.js.map} +0 -0
  51. /package/dist/{chunk-7D5MHMCP.js.map → chunk-VJBFCNAU.js.map} +0 -0
@@ -5,12 +5,12 @@ import {
5
5
  import {
6
6
  DEFAULT_TANGLE_ROUTER_BASE_URL
7
7
  } from "./chunk-D6UJEOZQ.js";
8
- import {
9
- turnTraceId
10
- } from "./chunk-ORQD4AUO.js";
11
8
  import {
12
9
  normalizeModelId
13
10
  } from "./chunk-AMUXRAUO.js";
11
+ import {
12
+ turnTraceId
13
+ } from "./chunk-ORQD4AUO.js";
14
14
 
15
15
  // src/runtime/loop.ts
16
16
  import {
@@ -982,4 +982,4 @@ export {
982
982
  composeRouterTurnPrompt,
983
983
  runRouterTurn
984
984
  };
985
- //# sourceMappingURL=chunk-7D5MHMCP.js.map
985
+ //# sourceMappingURL=chunk-VJBFCNAU.js.map
@@ -37,13 +37,13 @@ import {
37
37
  validateSceneOperations,
38
38
  validateSlotValue
39
39
  } from "../chunk-ZWJ3SZ2G.js";
40
- import "../chunk-CQGEGPY7.js";
41
- import "../chunk-RN4WPTBH.js";
42
- import "../chunk-WP2GYFZ4.js";
43
40
  import {
44
41
  buildScopedMcpServerEntry,
45
42
  createMcpToolHandler
46
43
  } from "../chunk-6A7MYOUI.js";
44
+ import "../chunk-CQGEGPY7.js";
45
+ import "../chunk-RN4WPTBH.js";
46
+ import "../chunk-WP2GYFZ4.js";
47
47
  import "../chunk-TXD5HXLE.js";
48
48
  import "../chunk-6Z7TZVKZ.js";
49
49
  import "../chunk-57XPEL7X.js";
@@ -41,6 +41,10 @@ import {
41
41
  formatRulerLabel,
42
42
  selectTickStep
43
43
  } from "../chunk-NHYRIM4I.js";
44
+ import {
45
+ DesignCanvasChromeLazy,
46
+ DesignCanvasLazy
47
+ } from "../chunk-PDD5A43Y.js";
44
48
  import "../chunk-ZN5J47UX.js";
45
49
  import {
46
50
  DEFAULT_INSERT_TEMPLATES,
@@ -83,10 +87,6 @@ import {
83
87
  setPagePropsCommand,
84
88
  ungroupElementCommand
85
89
  } from "../chunk-BTKI4XMM.js";
86
- import {
87
- DesignCanvasChromeLazy,
88
- DesignCanvasLazy
89
- } from "../chunk-PDD5A43Y.js";
90
90
  import {
91
91
  assertSceneMediaSrc,
92
92
  bleedAwareExportBounds,
@@ -1,3 +1,11 @@
1
+ import {
2
+ D1_MAX_BOUND_PARAMETERS,
3
+ SIZED_READ_BYTES,
4
+ SIZED_READ_COMPOSITE_ROWS,
5
+ SIZED_READ_ROWS,
6
+ readInSizedBatches,
7
+ sizedBatches
8
+ } from "../chunk-5UQJ7F3P.js";
1
9
  import {
2
10
  DEFAULT_LIMIT_BUDGETS,
3
11
  LIMIT_RESOURCES,
@@ -20,14 +28,6 @@ import {
20
28
  LAUNCH_INVARIANT_IDS,
21
29
  describeVerdict
22
30
  } from "../chunk-LRYY3OX7.js";
23
- import {
24
- D1_MAX_BOUND_PARAMETERS,
25
- SIZED_READ_BYTES,
26
- SIZED_READ_COMPOSITE_ROWS,
27
- SIZED_READ_ROWS,
28
- readInSizedBatches,
29
- sizedBatches
30
- } from "../chunk-5UQJ7F3P.js";
31
31
  import "../chunk-CD2LQXY6.js";
32
32
  import "../chunk-F2VX6TTJ.js";
33
33
  import {
@@ -1,10 +1,10 @@
1
- import {
2
- parseJsonObjectBody
3
- } from "../chunk-WP2GYFZ4.js";
4
1
  import {
5
2
  OPENUI_INPUT_KINDS,
6
3
  OPENUI_INTERACTIVE_AUTHORING_GUIDE
7
4
  } from "../chunk-UGWQLQDS.js";
5
+ import {
6
+ parseJsonObjectBody
7
+ } from "../chunk-WP2GYFZ4.js";
8
8
  import "../chunk-TXD5HXLE.js";
9
9
 
10
10
  // src/openui/segments.ts
@@ -1,11 +1,3 @@
1
- import {
2
- PLATFORM_AGENT_KEY_PROVISIONER,
3
- PLATFORM_KEY_PREFIX,
4
- agentOperatorScopes,
5
- createApiKeyRequestAuth,
6
- createPlatformAgentKeyVerifier,
7
- platformKeyRefusal
8
- } from "../chunk-XB4KZVUV.js";
9
1
  import {
10
2
  TangleSsoAccountConflictError,
11
3
  TangleSsoUserCreateError,
@@ -21,21 +13,29 @@ import {
21
13
  resolveTangleSsoAccount,
22
14
  signSessionCookieValue,
23
15
  verifySignedSsoState
24
- } from "../chunk-BI5AZAOO.js";
16
+ } from "../chunk-4P5NFBWX.js";
17
+ import {
18
+ PLATFORM_AGENT_KEY_PROVISIONER,
19
+ PLATFORM_KEY_PREFIX,
20
+ agentOperatorScopes,
21
+ createApiKeyRequestAuth,
22
+ createPlatformAgentKeyVerifier,
23
+ platformKeyRefusal
24
+ } from "../chunk-XB4KZVUV.js";
25
25
  import {
26
26
  assertWorkspaceKeyCryptoUsable
27
27
  } from "../chunk-VGS2NXLB.js";
28
28
  import {
29
29
  createWarmCache
30
30
  } from "../chunk-F4TUZYMX.js";
31
+ import {
32
+ resolveTangleExecutionEnvironment
33
+ } from "../chunk-D6UJEOZQ.js";
31
34
  import "../chunk-CQGEGPY7.js";
32
35
  import "../chunk-RN4WPTBH.js";
33
36
  import {
34
37
  parseJsonObjectBody
35
38
  } from "../chunk-WP2GYFZ4.js";
36
- import {
37
- resolveTangleExecutionEnvironment
38
- } from "../chunk-D6UJEOZQ.js";
39
39
  import {
40
40
  sha256Hex
41
41
  } from "../chunk-HY57QRRW.js";
@@ -32,10 +32,10 @@ import {
32
32
  skillMountPath,
33
33
  skillRefs
34
34
  } from "../chunk-TXUAGSFR.js";
35
+ import "../chunk-LTWJYNEC.js";
35
36
  import {
36
37
  parseSkillFrontmatter
37
38
  } from "../chunk-PV33JZKV.js";
38
- import "../chunk-LTWJYNEC.js";
39
39
  import {
40
40
  sha256Hex
41
41
  } from "../chunk-HY57QRRW.js";
@@ -2,7 +2,7 @@ import {
2
2
  ProtectedModelSettlementError,
3
3
  createRouterProtectedModelPort,
4
4
  runProtectedRouterTurn
5
- } from "../chunk-U77HPL3I.js";
5
+ } from "../chunk-LO6VQ35O.js";
6
6
  import {
7
7
  DURABLE_HOP_BUDGET_MS,
8
8
  asksForLanguage,
@@ -26,7 +26,7 @@ import {
26
26
  turnKnowledgeInstructions,
27
27
  workspaceKnowledgeForTurn,
28
28
  workspaceTurnCheckpoints
29
- } from "../chunk-7D5MHMCP.js";
29
+ } from "../chunk-VJBFCNAU.js";
30
30
  import "../chunk-UFQM46NV.js";
31
31
  import {
32
32
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
@@ -43,7 +43,6 @@ import {
43
43
  tangleExecutionKeyHttpError,
44
44
  trimOrNull
45
45
  } from "../chunk-D6UJEOZQ.js";
46
- import "../chunk-ORQD4AUO.js";
47
46
  import {
48
47
  MAX_RECOMMENDED_MODELS,
49
48
  __resetCatalogCache,
@@ -55,6 +54,7 @@ import {
55
54
  resolveCatalogModelId,
56
55
  sortModelsByFreshness
57
56
  } from "../chunk-AMUXRAUO.js";
57
+ import "../chunk-ORQD4AUO.js";
58
58
 
59
59
  // src/runtime/certified-delivery.ts
60
60
  import {
@@ -13,11 +13,11 @@ import {
13
13
  turnKnowledgeInstructions,
14
14
  workspaceKnowledgeForTurn,
15
15
  workspaceTurnCheckpoints
16
- } from "../chunk-7D5MHMCP.js";
16
+ } from "../chunk-VJBFCNAU.js";
17
17
  import "../chunk-UFQM46NV.js";
18
18
  import "../chunk-D6UJEOZQ.js";
19
- import "../chunk-ORQD4AUO.js";
20
19
  import "../chunk-AMUXRAUO.js";
20
+ import "../chunk-ORQD4AUO.js";
21
21
  export {
22
22
  DURABLE_HOP_BUDGET_MS,
23
23
  asksForLanguage,
@@ -16,16 +16,16 @@ import {
16
16
  requireEnum,
17
17
  requireString
18
18
  } from "../chunk-NMZUW6VJ.js";
19
- import "../chunk-CQGEGPY7.js";
20
- import "../chunk-RN4WPTBH.js";
21
- import {
22
- assertMediaUrl
23
- } from "../chunk-WP2GYFZ4.js";
24
19
  import {
25
20
  MCP_PROTOCOL_VERSIONS,
26
21
  buildScopedMcpServerEntry,
27
22
  createMcpToolHandler
28
23
  } from "../chunk-6A7MYOUI.js";
24
+ import "../chunk-CQGEGPY7.js";
25
+ import "../chunk-RN4WPTBH.js";
26
+ import {
27
+ assertMediaUrl
28
+ } from "../chunk-WP2GYFZ4.js";
29
29
  import "../chunk-TXD5HXLE.js";
30
30
  import "../chunk-6Z7TZVKZ.js";
31
31
  import "../chunk-57XPEL7X.js";
@@ -21,12 +21,12 @@ import {
21
21
  useBrowserLayoutEffect,
22
22
  usePopover
23
23
  } from "../chunk-R4X5474U.js";
24
- import "../chunk-RASGKEAL.js";
25
24
  import {
26
25
  confirmWrite,
27
26
  rejectWrite,
28
27
  useConfirmedMutation
29
28
  } from "../chunk-AVP5SNIG.js";
29
+ import "../chunk-RASGKEAL.js";
30
30
  import {
31
31
  useWorkspaceExport
32
32
  } from "../chunk-EZFBGW23.js";
@@ -13,9 +13,6 @@ import {
13
13
  skillMountPath,
14
14
  skillRefs
15
15
  } from "../chunk-TXUAGSFR.js";
16
- import {
17
- parseSkillFrontmatter
18
- } from "../chunk-PV33JZKV.js";
19
16
  import {
20
17
  MAX_MARKETPLACE_ENTRIES,
21
18
  createInMemoryMarketplaceStore,
@@ -29,6 +26,9 @@ import {
29
26
  validateMarketplaceCatalog,
30
27
  validateMarketplaceSkill
31
28
  } from "../chunk-LTWJYNEC.js";
29
+ import {
30
+ parseSkillFrontmatter
31
+ } from "../chunk-PV33JZKV.js";
32
32
  export {
33
33
  MAX_MARKETPLACE_ENTRIES,
34
34
  assertSkillDeliveryDisjoint,
@@ -7,8 +7,8 @@ import {
7
7
  } from "../chunk-MDRH3SDA.js";
8
8
  import "../chunk-FPNZMIAW.js";
9
9
  import "../chunk-TXUAGSFR.js";
10
- import "../chunk-PV33JZKV.js";
11
10
  import "../chunk-LTWJYNEC.js";
11
+ import "../chunk-PV33JZKV.js";
12
12
  import {
13
13
  sha256Hex
14
14
  } from "../chunk-HY57QRRW.js";
@@ -7,8 +7,8 @@ import {
7
7
  } from "../chunk-MDRH3SDA.js";
8
8
  import "../chunk-FPNZMIAW.js";
9
9
  import "../chunk-TXUAGSFR.js";
10
- import "../chunk-PV33JZKV.js";
11
10
  import "../chunk-LTWJYNEC.js";
11
+ import "../chunk-PV33JZKV.js";
12
12
  export {
13
13
  composeSkillsForHarness,
14
14
  resolveSkillDir,
@@ -13,7 +13,6 @@ import { type ReactNode } from 'react';
13
13
  import type { Decorator } from '@storybook/react';
14
14
  import type { AgentActivityPage, CatalogModel, ChatAttachmentPart, ChatEmptyDoor, ChatInteraction, ComposerFile, SubmitInteractionAnswer, ToolRunRecord, WorkProductCardProps } from '../../web-react';
15
15
  import type { StepAgentActivity } from '../../missions/agent-activity';
16
- import type { FlowTrace } from '../../trace';
17
16
  import type { ChatPlan } from '../../plans';
18
17
  import type { WorkProductPersistedPart } from '../../work-product/types';
19
18
  import type { ProductSeatOffer } from '../../platform/billing';
@@ -81,8 +80,6 @@ export declare const fetchActivityEmpty: () => Promise<AgentActivityPage>;
81
80
  export declare const fetchActivityError: () => Promise<AgentActivityPage>;
82
81
  /** Never settles — the refresh spinner holds. */
83
82
  export declare const fetchActivityHangs: () => Promise<AgentActivityPage>;
84
- export declare const posterFlowTrace: FlowTrace;
85
- export declare const failedFlowTrace: FlowTrace;
86
83
  /**
87
84
  * Clicks the first button inside its subtree on mount — the trick that renders
88
85
  * a popover-driven control (ModelPicker, EffortPicker, the lane's "timeline"
@@ -2058,6 +2058,10 @@
2058
2058
  }
2059
2059
  /* Standalone surface: consumes Brand/Agent App tokens; no Tailwind build required. */
2060
2060
  .fw-root {
2061
+ --waterfall-bar-height: 1rem;
2062
+ --waterfall-bar-radius: .125rem;
2063
+ --waterfall-duration-width: 100%;
2064
+ --intel-waterfall-track: var(--fw-well);
2061
2065
  --fw-text: var(--text-primary, hsl(var(--foreground)));
2062
2066
  --fw-muted: var(--text-muted, hsl(var(--muted-foreground)));
2063
2067
  --fw-surface: var(--bg-card, hsl(var(--background)));
@@ -2089,12 +2093,12 @@
2089
2093
  .fw-root .fw-legend { display: flex; flex-wrap: wrap; gap: .25rem .75rem; padding: .5rem .75rem; border-bottom: 1px solid var(--fw-border); color: var(--fw-muted); font-size: .75rem; }
2090
2094
  .fw-root .fw-legend-item { display: inline-flex; align-items: center; gap: .25rem; }
2091
2095
  .fw-root .fw-dot { width: .375rem; height: .375rem; border-radius: 50%; }
2092
- .fw-root .fw-orchestrator { background: var(--fw-muted); }
2093
- .fw-root .fw-model { background: var(--chart-accent, hsl(var(--primary))); }
2094
- .fw-root .fw-tool { background: var(--status-cold, hsl(var(--accent))); }
2095
- .fw-root .fw-waiting { background: var(--status-stopped, hsl(var(--warning-strong))); }
2096
- .fw-root .fw-handoff { background: var(--status-running, hsl(var(--success))); }
2097
- .fw-root .fw-failed { background: var(--status-error, hsl(var(--destructive))); }
2096
+ .fw-root .fw-orchestrator { --fw-bar-color: var(--fw-muted); background: var(--fw-bar-color); }
2097
+ .fw-root .fw-model { --fw-bar-color: var(--chart-accent, hsl(var(--primary))); background: var(--fw-bar-color); }
2098
+ .fw-root .fw-tool { --fw-bar-color: var(--status-cold, hsl(var(--accent))); background: var(--fw-bar-color); }
2099
+ .fw-root .fw-waiting { --fw-bar-color: var(--status-stopped, hsl(var(--warning-strong))); background: var(--fw-bar-color); }
2100
+ .fw-root .fw-handoff { --fw-bar-color: var(--status-running, hsl(var(--success))); background: var(--fw-bar-color); }
2101
+ .fw-root .fw-failed { --fw-bar-color: var(--status-error, hsl(var(--destructive))); background: var(--fw-bar-color); }
2098
2102
  .fw-root .fw-branches { display: flex; gap: .5rem; padding: .5rem .75rem 0; }
2099
2103
  .fw-root .fw-timeline { overflow-x: auto; padding: .75rem; }
2100
2104
  .fw-root .fw-track { min-width: 480px; }
@@ -14,9 +14,9 @@
14
14
  * carry `approx: true` to keep reports honest about that.
15
15
  */
16
16
  export * from './mission-trace';
17
- export * from './flow-types';
17
+ export type { FlowSpan, FlowTrace } from '@tangle-network/charts';
18
18
  export * from './mission-flow';
19
- import type { FlowTrace } from './flow-types';
19
+ import type { FlowTrace } from '@tangle-network/charts';
20
20
  /** Represent a timed event with a timestamp and associated event data */
21
21
  export interface TimedEvent {
22
22
  /** ms since turn start (`_t` stamped by pumpBufferedTurn). */
@@ -3,7 +3,7 @@ import {
3
3
  delegationActivityToFlowSpans,
4
4
  loopTraceEventsToFlowSpans,
5
5
  stepActivityFlowTrace
6
- } from "../chunk-GDUT72VK.js";
6
+ } from "../chunk-6OSJNJA2.js";
7
7
 
8
8
  // src/trace/mission-trace.ts
9
9
  function createMissionTraceContext(missionId) {
@@ -106,6 +106,7 @@ function buildFlowTrace(events, opts) {
106
106
  const id = String(event.toolCallId ?? inner.toolCallId ?? "");
107
107
  const open = openCalls.get(id);
108
108
  if (open) {
109
+ const ok = (event.outcome ?? inner.outcome)?.ok;
109
110
  spans.push({
110
111
  kind: "tool",
111
112
  id,
@@ -115,7 +116,8 @@ function buildFlowTrace(events, opts) {
115
116
  startMs: open.lastDeltaT,
116
117
  endMs: t,
117
118
  approx: true,
118
- meta: { ok: (event.outcome ?? inner.outcome)?.ok }
119
+ status: ok === false ? "failed" : "done",
120
+ meta: { ok }
119
121
  });
120
122
  openCalls.delete(id);
121
123
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/trace/mission-trace.ts","../../src/trace/index.ts"],"sourcesContent":["/**\n * Mission trace context — mint + thread the trace ids that join a mission's\n * step attempts and its delegated agent runs into ONE trace tree.\n *\n * ID formats are byte-compatible with agent-runtime's trace propagation\n * (`readTraceContextFromEnv` / OTLP export): 32 lowercase hex chars for a\n * trace id (16 bytes), 16 for a span id (8 bytes). The env pair from\n * {@link traceEnv} is exactly what agent-runtime's MCP subprocess reads at\n * startup (`TRACE_ID` + `PARENT_SPAN_ID`), so a delegation dispatched with it\n * parents its loop→round→iteration spans under the mission's step span.\n *\n * Pure functions, no deps. Ids are DETERMINISTIC when a key is supplied\n * (missionId / step-attempt seed) so a crashed driver re-mints the identical\n * context on re-dispatch and the re-run joins the same trace instead of\n * forking a new one; without a key they are random.\n */\n\nexport interface MissionTraceContext {\n /** 32-hex trace id shared by every span in the mission's tree. */\n traceId: string\n /** 16-hex span id of the mission root — the parent of every step span. */\n rootSpanId: string\n}\n\n/** Define context information for a step span including trace, span, and parent span identifiers */\nexport interface StepSpanContext {\n traceId: string\n /** 16-hex span id of this step attempt (or any nested unit of work). */\n spanId: string\n /** The span this one nests under. */\n parentSpanId: string\n}\n\n/**\n * Mint a mission's trace context. With `missionId` the ids are a pure\n * function of it; omitted, both ids are random.\n */\nexport function createMissionTraceContext(missionId?: string): MissionTraceContext {\n if (missionId !== undefined && missionId !== '') {\n return {\n traceId: hex64(fnv1a64(`mission-trace:${missionId}`)) + hex64(fnv1a64(`mission-trace:2:${missionId}`)),\n rootSpanId: hex64(fnv1a64(`mission-root-span:${missionId}`)),\n }\n }\n return { traceId: randomHex(16), rootSpanId: randomHex(8) }\n}\n\n/**\n * Derive a child span context under `parent` — one per step attempt (seed\n * e.g. `\"${stepId}#${attempt}\"`), or nested under another step span. With a\n * seed the span id is deterministic for the same parent + seed; omitted, it\n * is random.\n */\nexport function childSpanContext(\n parent: MissionTraceContext | StepSpanContext,\n seed?: string,\n): StepSpanContext {\n const parentSpanId = 'rootSpanId' in parent ? parent.rootSpanId : parent.spanId\n const spanId =\n seed !== undefined && seed !== ''\n ? hex64(fnv1a64(`span:${parent.traceId}:${parentSpanId}:${seed}`))\n : randomHex(8)\n return { traceId: parent.traceId, spanId, parentSpanId }\n}\n\n/**\n * The env pair a delegation subprocess inherits — agent-runtime's\n * `readTraceContextFromEnv` reads exactly these names. `PARENT_SPAN_ID` is\n * the span the dispatched work nests under: the root for a mission context,\n * the step-attempt span for a step context.\n */\nexport function traceEnv(ctx: MissionTraceContext | StepSpanContext): {\n TRACE_ID: string\n PARENT_SPAN_ID: string\n} {\n return {\n TRACE_ID: ctx.traceId,\n PARENT_SPAN_ID: 'rootSpanId' in ctx ? ctx.rootSpanId : ctx.spanId,\n }\n}\n\n// FNV-1a 64-bit over UTF-16 code units — a stable, dependency-free digest for\n// deterministic ids. Not cryptographic; trace ids only need uniqueness within\n// a tenant's missions, not unforgeability.\nconst FNV_OFFSET = 0xcbf29ce484222325n\nconst FNV_PRIME = 0x100000001b3n\nconst MASK_64 = 0xffffffffffffffffn\n\nfunction fnv1a64(input: string): bigint {\n let hash = FNV_OFFSET\n for (let i = 0; i < input.length; i++) {\n hash ^= BigInt(input.charCodeAt(i))\n hash = (hash * FNV_PRIME) & MASK_64\n }\n return hash\n}\n\nfunction hex64(value: bigint): string {\n return value.toString(16).padStart(16, '0')\n}\n\nfunction randomHex(byteLength: number): string {\n const bytes = new Uint8Array(byteLength)\n globalThis.crypto.getRandomValues(bytes)\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n}\n","/**\n * `@tangle-network/agent-app/trace` — flow observability for agent turns.\n *\n * The turn buffer stamps `_t` (ms since turn start) on every event, so any\n * live stream OR any historical turn replayed from a TurnEventStore can be\n * reconstructed into a span trace: pipeline overhead, model segments (with\n * thinking TTFT), tool executions, token usage, and cost. Renderers turn\n * traces and multi-run samples into ASCII waterfalls and histograms — the\n * default artifact for \"how did this run actually behave\" questions across\n * evals, hill-climbs, and production debugging.\n *\n * Span boundaries derived from a buffered stream are quantized by the\n * pump's flush window and the reader's poll cadence (~100–400ms); spans\n * carry `approx: true` to keep reports honest about that.\n */\n\nexport * from './mission-trace'\nexport * from './flow-types'\nexport * from './mission-flow'\n\nimport type { FlowSpan, FlowTrace } from './flow-types'\n\n/** Represent a timed event with a timestamp and associated event data */\nexport interface TimedEvent {\n /** ms since turn start (`_t` stamped by pumpBufferedTurn). */\n t: number\n event: Record<string, unknown>\n}\n\n/** Parse stored turn-event lines (JSON strings with `_t`) into TimedEvents. */\nexport function timedEventsFromLines(lines: string[]): TimedEvent[] {\n const out: TimedEvent[] = []\n for (const line of lines) {\n try {\n const parsed = JSON.parse(line) as Record<string, unknown>\n if (typeof parsed._t === 'number') out.push({ t: parsed._t, event: parsed })\n } catch {\n /* skip torn lines */\n }\n }\n return out.sort((a, b) => a.t - b.t)\n}\n\nfunction innerOf(e: Record<string, unknown>): Record<string, unknown> {\n return (e.kind === 'event' ? (e.event as Record<string, unknown>) : e) ?? {}\n}\n\n/**\n * Derive a span trace from timestamped turn events. Model segments are runs\n * of text/reasoning deltas; a tool span opens at the last delta before its\n * tool_call emission and closes at the matching tool_result.\n */\nexport function buildFlowTrace(\n events: TimedEvent[],\n opts?: { pricing?: { prompt?: string | number; completion?: string | number }; running?: boolean },\n): FlowTrace {\n const spans: FlowSpan[] = []\n let promptTokens = 0\n let completionTokens = 0\n let toolCalls = 0\n\n const first = events[0]?.t ?? 0\n if (first > 0) {\n spans.push({ kind: 'pipeline', name: 'dispatch → first event', startMs: 0, endMs: first })\n }\n\n let segStart: number | null = null\n let segEnd = 0\n let segKinds = new Set<string>()\n let lastDeltaT = first\n const openCalls = new Map<string, { name: string; emitT: number; lastDeltaT: number }>()\n\n const closeSegment = () => {\n if (segStart !== null) {\n spans.push({\n kind: 'model',\n name: segKinds.has('reasoning') ? 'model turn (reasoning + text)' : 'model turn',\n startMs: segStart,\n endMs: segEnd,\n approx: true,\n })\n segStart = null\n segKinds = new Set()\n }\n }\n\n for (const { t, event } of events) {\n const inner = innerOf(event)\n const type = String(event.kind === 'tool_result' ? 'tool_result' : (inner.type ?? ''))\n\n if (type === 'text' || type === 'reasoning') {\n if (segStart === null) segStart = t\n segEnd = t\n segKinds.add(type)\n lastDeltaT = t\n } else if (type === 'tool_call') {\n closeSegment()\n toolCalls++\n const call = (inner.call ?? inner) as Record<string, unknown>\n const id = String(call.toolCallId ?? `call_${toolCalls}`)\n openCalls.set(id, { name: String(call.toolName ?? 'tool'), emitT: t, lastDeltaT })\n } else if (type === 'tool_result') {\n const id = String(event.toolCallId ?? inner.toolCallId ?? '')\n const open = openCalls.get(id)\n if (open) {\n spans.push({\n kind: 'tool',\n id: id,\n name: open.name,\n // Execution happens between the end of the model turn that emitted\n // the call and the result landing in the buffer.\n startMs: open.lastDeltaT,\n endMs: t,\n approx: true,\n meta: { ok: ((event.outcome ?? inner.outcome) as { ok?: boolean } | undefined)?.ok },\n })\n openCalls.delete(id)\n }\n } else if (type === 'usage') {\n const u = (inner.usage ?? {}) as { promptTokens?: number; completionTokens?: number }\n promptTokens += u.promptTokens ?? 0\n completionTokens += u.completionTokens ?? 0\n }\n }\n closeSegment()\n\n const totalMs = events.length ? events[events.length - 1]!.t : 0\n for (const [id, open] of openCalls) {\n spans.push({ id, kind: 'tool', name: open.name, startMs: open.lastDeltaT,\n endMs: totalMs, status: opts?.running ? 'running' : undefined, approx: true })\n }\n if (opts?.running && spans.at(-1)?.kind === 'model') spans.at(-1)!.status = 'running'\n const trace: FlowTrace = { spans, totalMs, promptTokens, completionTokens, toolCalls }\n const p = opts?.pricing\n if (p && (p.prompt != null || p.completion != null)) {\n trace.costUsd = promptTokens * Number(p.prompt ?? 0) + completionTokens * Number(p.completion ?? 0)\n }\n return trace\n}\n\nconst fmtS = (ms: number) => `${(ms / 1000).toFixed(1)}s`\n\n/** ASCII waterfall cascade — the default artifact for explaining a flow. */\nexport function renderWaterfall(trace: FlowTrace, opts?: { width?: number }): string {\n const width = opts?.width ?? 40\n const scale = trace.totalMs > 0 ? width / trace.totalMs : 0\n const lines: string[] = []\n const spans = [...trace.spans].sort((a, b) => a.startMs - b.startMs)\n for (let i = 0; i < spans.length; i++) {\n const s = spans[i]!\n const offset = Math.round(s.startMs * scale)\n const len = Math.max(1, Math.round((s.endMs - s.startMs) * scale))\n const bar = ' '.repeat(offset) + (s.kind === 'tool' ? '▓' : s.kind === 'pipeline' ? '░' : '█').repeat(len)\n const branch = i === spans.length - 1 ? '└─' : '├─'\n const dur = `${fmtS(s.endMs - s.startMs)}${s.approx ? '~' : ''}`\n lines.push(`${fmtS(s.startMs).padStart(7)} ${branch} ${bar.padEnd(width + 2)} ${s.name} (${dur})`)\n }\n const cost = trace.costUsd != null ? ` $${trace.costUsd.toFixed(trace.costUsd < 0.01 ? 6 : 4)}` : ''\n lines.push(\n `${fmtS(trace.totalMs).padStart(7)} ── total · ${trace.promptTokens}p + ${trace.completionTokens}c tok · ${trace.toolCalls} tool calls${cost}`,\n )\n return lines.join('\\n')\n}\n\n/** Summarize key statistics of a numerical distribution including count, min, percentiles, and max */\nexport interface DistributionSummary {\n n: number\n min: number\n p50: number\n p90: number\n max: number\n}\n\n/** Summarize numeric values into a distribution summary including count, min, median, 90th percentile, and max */\nexport function summarize(values: number[]): DistributionSummary {\n const sorted = [...values].sort((a, b) => a - b)\n const q = (p: number) => sorted[Math.min(sorted.length - 1, Math.floor(p * sorted.length))] ?? 0\n return { n: sorted.length, min: sorted[0] ?? 0, p50: q(0.5), p90: q(0.9), max: sorted[sorted.length - 1] ?? 0 }\n}\n\n/** ASCII histogram for multi-run samples (eval latencies, costs, scores). */\nexport function renderHistogram(\n values: number[],\n opts?: { buckets?: number; width?: number; unit?: string; format?: (v: number) => string },\n): string {\n if (!values.length) return '(no samples)'\n const buckets = opts?.buckets ?? 6\n const width = opts?.width ?? 24\n const fmt = opts?.format ?? ((v: number) => `${Math.round(v)}${opts?.unit ?? ''}`)\n const s = summarize(values)\n const lo = s.min\n const hi = s.max === s.min ? s.min + 1 : s.max\n const counts = new Array<number>(buckets).fill(0)\n for (const v of values) {\n counts[Math.min(buckets - 1, Math.floor(((v - lo) / (hi - lo)) * buckets))]!++\n }\n const maxCount = Math.max(...counts)\n const lines = [\n `n=${s.n} min=${fmt(s.min)} p50=${fmt(s.p50)} p90=${fmt(s.p90)} max=${fmt(s.max)}`,\n ]\n for (let i = 0; i < buckets; i++) {\n const a = lo + ((hi - lo) * i) / buckets\n const b = lo + ((hi - lo) * (i + 1)) / buckets\n const bar = '█'.repeat(Math.max(counts[i]! > 0 ? 1 : 0, Math.round((counts[i]! / maxCount) * width)))\n lines.push(`${fmt(a).padStart(8)}-${fmt(b).padEnd(8)} ${bar} ${counts[i]}`)\n }\n return lines.join('\\n')\n}\n"],"mappings":";;;;;;;;AAqCO,SAAS,0BAA0B,WAAyC;AACjF,MAAI,cAAc,UAAa,cAAc,IAAI;AAC/C,WAAO;AAAA,MACL,SAAS,MAAM,QAAQ,iBAAiB,SAAS,EAAE,CAAC,IAAI,MAAM,QAAQ,mBAAmB,SAAS,EAAE,CAAC;AAAA,MACrG,YAAY,MAAM,QAAQ,qBAAqB,SAAS,EAAE,CAAC;AAAA,IAC7D;AAAA,EACF;AACA,SAAO,EAAE,SAAS,UAAU,EAAE,GAAG,YAAY,UAAU,CAAC,EAAE;AAC5D;AAQO,SAAS,iBACd,QACA,MACiB;AACjB,QAAM,eAAe,gBAAgB,SAAS,OAAO,aAAa,OAAO;AACzE,QAAM,SACJ,SAAS,UAAa,SAAS,KAC3B,MAAM,QAAQ,QAAQ,OAAO,OAAO,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC,IAC/D,UAAU,CAAC;AACjB,SAAO,EAAE,SAAS,OAAO,SAAS,QAAQ,aAAa;AACzD;AAQO,SAAS,SAAS,KAGvB;AACA,SAAO;AAAA,IACL,UAAU,IAAI;AAAA,IACd,gBAAgB,gBAAgB,MAAM,IAAI,aAAa,IAAI;AAAA,EAC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AM,KAAK,IAAI;AACxB;","names":[]}
1
+ {"version":3,"sources":["../../src/trace/mission-trace.ts","../../src/trace/index.ts"],"sourcesContent":["/**\n * Mission trace context — mint + thread the trace ids that join a mission's\n * step attempts and its delegated agent runs into ONE trace tree.\n *\n * ID formats are byte-compatible with agent-runtime's trace propagation\n * (`readTraceContextFromEnv` / OTLP export): 32 lowercase hex chars for a\n * trace id (16 bytes), 16 for a span id (8 bytes). The env pair from\n * {@link traceEnv} is exactly what agent-runtime's MCP subprocess reads at\n * startup (`TRACE_ID` + `PARENT_SPAN_ID`), so a delegation dispatched with it\n * parents its loop→round→iteration spans under the mission's step span.\n *\n * Pure functions, no deps. Ids are DETERMINISTIC when a key is supplied\n * (missionId / step-attempt seed) so a crashed driver re-mints the identical\n * context on re-dispatch and the re-run joins the same trace instead of\n * forking a new one; without a key they are random.\n */\n\nexport interface MissionTraceContext {\n /** 32-hex trace id shared by every span in the mission's tree. */\n traceId: string\n /** 16-hex span id of the mission root — the parent of every step span. */\n rootSpanId: string\n}\n\n/** Define context information for a step span including trace, span, and parent span identifiers */\nexport interface StepSpanContext {\n traceId: string\n /** 16-hex span id of this step attempt (or any nested unit of work). */\n spanId: string\n /** The span this one nests under. */\n parentSpanId: string\n}\n\n/**\n * Mint a mission's trace context. With `missionId` the ids are a pure\n * function of it; omitted, both ids are random.\n */\nexport function createMissionTraceContext(missionId?: string): MissionTraceContext {\n if (missionId !== undefined && missionId !== '') {\n return {\n traceId: hex64(fnv1a64(`mission-trace:${missionId}`)) + hex64(fnv1a64(`mission-trace:2:${missionId}`)),\n rootSpanId: hex64(fnv1a64(`mission-root-span:${missionId}`)),\n }\n }\n return { traceId: randomHex(16), rootSpanId: randomHex(8) }\n}\n\n/**\n * Derive a child span context under `parent` — one per step attempt (seed\n * e.g. `\"${stepId}#${attempt}\"`), or nested under another step span. With a\n * seed the span id is deterministic for the same parent + seed; omitted, it\n * is random.\n */\nexport function childSpanContext(\n parent: MissionTraceContext | StepSpanContext,\n seed?: string,\n): StepSpanContext {\n const parentSpanId = 'rootSpanId' in parent ? parent.rootSpanId : parent.spanId\n const spanId =\n seed !== undefined && seed !== ''\n ? hex64(fnv1a64(`span:${parent.traceId}:${parentSpanId}:${seed}`))\n : randomHex(8)\n return { traceId: parent.traceId, spanId, parentSpanId }\n}\n\n/**\n * The env pair a delegation subprocess inherits — agent-runtime's\n * `readTraceContextFromEnv` reads exactly these names. `PARENT_SPAN_ID` is\n * the span the dispatched work nests under: the root for a mission context,\n * the step-attempt span for a step context.\n */\nexport function traceEnv(ctx: MissionTraceContext | StepSpanContext): {\n TRACE_ID: string\n PARENT_SPAN_ID: string\n} {\n return {\n TRACE_ID: ctx.traceId,\n PARENT_SPAN_ID: 'rootSpanId' in ctx ? ctx.rootSpanId : ctx.spanId,\n }\n}\n\n// FNV-1a 64-bit over UTF-16 code units — a stable, dependency-free digest for\n// deterministic ids. Not cryptographic; trace ids only need uniqueness within\n// a tenant's missions, not unforgeability.\nconst FNV_OFFSET = 0xcbf29ce484222325n\nconst FNV_PRIME = 0x100000001b3n\nconst MASK_64 = 0xffffffffffffffffn\n\nfunction fnv1a64(input: string): bigint {\n let hash = FNV_OFFSET\n for (let i = 0; i < input.length; i++) {\n hash ^= BigInt(input.charCodeAt(i))\n hash = (hash * FNV_PRIME) & MASK_64\n }\n return hash\n}\n\nfunction hex64(value: bigint): string {\n return value.toString(16).padStart(16, '0')\n}\n\nfunction randomHex(byteLength: number): string {\n const bytes = new Uint8Array(byteLength)\n globalThis.crypto.getRandomValues(bytes)\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n}\n","/**\n * `@tangle-network/agent-app/trace` — flow observability for agent turns.\n *\n * The turn buffer stamps `_t` (ms since turn start) on every event, so any\n * live stream OR any historical turn replayed from a TurnEventStore can be\n * reconstructed into a span trace: pipeline overhead, model segments (with\n * thinking TTFT), tool executions, token usage, and cost. Renderers turn\n * traces and multi-run samples into ASCII waterfalls and histograms — the\n * default artifact for \"how did this run actually behave\" questions across\n * evals, hill-climbs, and production debugging.\n *\n * Span boundaries derived from a buffered stream are quantized by the\n * pump's flush window and the reader's poll cadence (~100–400ms); spans\n * carry `approx: true` to keep reports honest about that.\n */\n\nexport * from './mission-trace'\nexport type { FlowSpan, FlowTrace } from '@tangle-network/charts'\nexport * from './mission-flow'\n\nimport type { FlowSpan, FlowTrace } from '@tangle-network/charts'\n\n/** Represent a timed event with a timestamp and associated event data */\nexport interface TimedEvent {\n /** ms since turn start (`_t` stamped by pumpBufferedTurn). */\n t: number\n event: Record<string, unknown>\n}\n\n/** Parse stored turn-event lines (JSON strings with `_t`) into TimedEvents. */\nexport function timedEventsFromLines(lines: string[]): TimedEvent[] {\n const out: TimedEvent[] = []\n for (const line of lines) {\n try {\n const parsed = JSON.parse(line) as Record<string, unknown>\n if (typeof parsed._t === 'number') out.push({ t: parsed._t, event: parsed })\n } catch {\n /* skip torn lines */\n }\n }\n return out.sort((a, b) => a.t - b.t)\n}\n\nfunction innerOf(e: Record<string, unknown>): Record<string, unknown> {\n return (e.kind === 'event' ? (e.event as Record<string, unknown>) : e) ?? {}\n}\n\n/**\n * Derive a span trace from timestamped turn events. Model segments are runs\n * of text/reasoning deltas; a tool span opens at the last delta before its\n * tool_call emission and closes at the matching tool_result.\n */\nexport function buildFlowTrace(\n events: TimedEvent[],\n opts?: { pricing?: { prompt?: string | number; completion?: string | number }; running?: boolean },\n): FlowTrace {\n const spans: FlowSpan[] = []\n let promptTokens = 0\n let completionTokens = 0\n let toolCalls = 0\n\n const first = events[0]?.t ?? 0\n if (first > 0) {\n spans.push({ kind: 'pipeline', name: 'dispatch → first event', startMs: 0, endMs: first })\n }\n\n let segStart: number | null = null\n let segEnd = 0\n let segKinds = new Set<string>()\n let lastDeltaT = first\n const openCalls = new Map<string, { name: string; emitT: number; lastDeltaT: number }>()\n\n const closeSegment = () => {\n if (segStart !== null) {\n spans.push({\n kind: 'model',\n name: segKinds.has('reasoning') ? 'model turn (reasoning + text)' : 'model turn',\n startMs: segStart,\n endMs: segEnd,\n approx: true,\n })\n segStart = null\n segKinds = new Set()\n }\n }\n\n for (const { t, event } of events) {\n const inner = innerOf(event)\n const type = String(event.kind === 'tool_result' ? 'tool_result' : (inner.type ?? ''))\n\n if (type === 'text' || type === 'reasoning') {\n if (segStart === null) segStart = t\n segEnd = t\n segKinds.add(type)\n lastDeltaT = t\n } else if (type === 'tool_call') {\n closeSegment()\n toolCalls++\n const call = (inner.call ?? inner) as Record<string, unknown>\n const id = String(call.toolCallId ?? `call_${toolCalls}`)\n openCalls.set(id, { name: String(call.toolName ?? 'tool'), emitT: t, lastDeltaT })\n } else if (type === 'tool_result') {\n const id = String(event.toolCallId ?? inner.toolCallId ?? '')\n const open = openCalls.get(id)\n if (open) {\n const ok = ((event.outcome ?? inner.outcome) as { ok?: boolean } | undefined)?.ok\n spans.push({\n kind: 'tool',\n id: id,\n name: open.name,\n // Execution happens between the end of the model turn that emitted\n // the call and the result landing in the buffer.\n startMs: open.lastDeltaT,\n endMs: t,\n approx: true,\n status: ok === false ? 'failed' : 'done',\n meta: { ok },\n })\n openCalls.delete(id)\n }\n } else if (type === 'usage') {\n const u = (inner.usage ?? {}) as { promptTokens?: number; completionTokens?: number }\n promptTokens += u.promptTokens ?? 0\n completionTokens += u.completionTokens ?? 0\n }\n }\n closeSegment()\n\n const totalMs = events.length ? events[events.length - 1]!.t : 0\n for (const [id, open] of openCalls) {\n spans.push({ id, kind: 'tool', name: open.name, startMs: open.lastDeltaT,\n endMs: totalMs, status: opts?.running ? 'running' : undefined, approx: true })\n }\n if (opts?.running && spans.at(-1)?.kind === 'model') spans.at(-1)!.status = 'running'\n const trace: FlowTrace = { spans, totalMs, promptTokens, completionTokens, toolCalls }\n const p = opts?.pricing\n if (p && (p.prompt != null || p.completion != null)) {\n trace.costUsd = promptTokens * Number(p.prompt ?? 0) + completionTokens * Number(p.completion ?? 0)\n }\n return trace\n}\n\nconst fmtS = (ms: number) => `${(ms / 1000).toFixed(1)}s`\n\n/** ASCII waterfall cascade — the default artifact for explaining a flow. */\nexport function renderWaterfall(trace: FlowTrace, opts?: { width?: number }): string {\n const width = opts?.width ?? 40\n const scale = trace.totalMs > 0 ? width / trace.totalMs : 0\n const lines: string[] = []\n const spans = [...trace.spans].sort((a, b) => a.startMs - b.startMs)\n for (let i = 0; i < spans.length; i++) {\n const s = spans[i]!\n const offset = Math.round(s.startMs * scale)\n const len = Math.max(1, Math.round((s.endMs - s.startMs) * scale))\n const bar = ' '.repeat(offset) + (s.kind === 'tool' ? '▓' : s.kind === 'pipeline' ? '░' : '█').repeat(len)\n const branch = i === spans.length - 1 ? '└─' : '├─'\n const dur = `${fmtS(s.endMs - s.startMs)}${s.approx ? '~' : ''}`\n lines.push(`${fmtS(s.startMs).padStart(7)} ${branch} ${bar.padEnd(width + 2)} ${s.name} (${dur})`)\n }\n const cost = trace.costUsd != null ? ` $${trace.costUsd.toFixed(trace.costUsd < 0.01 ? 6 : 4)}` : ''\n lines.push(\n `${fmtS(trace.totalMs).padStart(7)} ── total · ${trace.promptTokens}p + ${trace.completionTokens}c tok · ${trace.toolCalls} tool calls${cost}`,\n )\n return lines.join('\\n')\n}\n\n/** Summarize key statistics of a numerical distribution including count, min, percentiles, and max */\nexport interface DistributionSummary {\n n: number\n min: number\n p50: number\n p90: number\n max: number\n}\n\n/** Summarize numeric values into a distribution summary including count, min, median, 90th percentile, and max */\nexport function summarize(values: number[]): DistributionSummary {\n const sorted = [...values].sort((a, b) => a - b)\n const q = (p: number) => sorted[Math.min(sorted.length - 1, Math.floor(p * sorted.length))] ?? 0\n return { n: sorted.length, min: sorted[0] ?? 0, p50: q(0.5), p90: q(0.9), max: sorted[sorted.length - 1] ?? 0 }\n}\n\n/** ASCII histogram for multi-run samples (eval latencies, costs, scores). */\nexport function renderHistogram(\n values: number[],\n opts?: { buckets?: number; width?: number; unit?: string; format?: (v: number) => string },\n): string {\n if (!values.length) return '(no samples)'\n const buckets = opts?.buckets ?? 6\n const width = opts?.width ?? 24\n const fmt = opts?.format ?? ((v: number) => `${Math.round(v)}${opts?.unit ?? ''}`)\n const s = summarize(values)\n const lo = s.min\n const hi = s.max === s.min ? s.min + 1 : s.max\n const counts = new Array<number>(buckets).fill(0)\n for (const v of values) {\n counts[Math.min(buckets - 1, Math.floor(((v - lo) / (hi - lo)) * buckets))]!++\n }\n const maxCount = Math.max(...counts)\n const lines = [\n `n=${s.n} min=${fmt(s.min)} p50=${fmt(s.p50)} p90=${fmt(s.p90)} max=${fmt(s.max)}`,\n ]\n for (let i = 0; i < buckets; i++) {\n const a = lo + ((hi - lo) * i) / buckets\n const b = lo + ((hi - lo) * (i + 1)) / buckets\n const bar = '█'.repeat(Math.max(counts[i]! > 0 ? 1 : 0, Math.round((counts[i]! / maxCount) * width)))\n lines.push(`${fmt(a).padStart(8)}-${fmt(b).padEnd(8)} ${bar} ${counts[i]}`)\n }\n return lines.join('\\n')\n}\n"],"mappings":";;;;;;;;AAqCO,SAAS,0BAA0B,WAAyC;AACjF,MAAI,cAAc,UAAa,cAAc,IAAI;AAC/C,WAAO;AAAA,MACL,SAAS,MAAM,QAAQ,iBAAiB,SAAS,EAAE,CAAC,IAAI,MAAM,QAAQ,mBAAmB,SAAS,EAAE,CAAC;AAAA,MACrG,YAAY,MAAM,QAAQ,qBAAqB,SAAS,EAAE,CAAC;AAAA,IAC7D;AAAA,EACF;AACA,SAAO,EAAE,SAAS,UAAU,EAAE,GAAG,YAAY,UAAU,CAAC,EAAE;AAC5D;AAQO,SAAS,iBACd,QACA,MACiB;AACjB,QAAM,eAAe,gBAAgB,SAAS,OAAO,aAAa,OAAO;AACzE,QAAM,SACJ,SAAS,UAAa,SAAS,KAC3B,MAAM,QAAQ,QAAQ,OAAO,OAAO,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC,IAC/D,UAAU,CAAC;AACjB,SAAO,EAAE,SAAS,OAAO,SAAS,QAAQ,aAAa;AACzD;AAQO,SAAS,SAAS,KAGvB;AACA,SAAO;AA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AE,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE;AAAA,EAC5E;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
@@ -18,7 +18,7 @@
18
18
  * agent-runtime peer.
19
19
  */
20
20
  import type { StepAgentActivity } from '../missions/agent-activity';
21
- import type { FlowSpan, FlowTrace } from './flow-types';
21
+ import type { FlowSpan, FlowTrace } from '@tangle-network/charts';
22
22
  /** Structural mirror of agent-runtime's `LoopTraceEvent` — same fields, no
23
23
  * import, so journals parsed from JSON feed straight in. */
24
24
  export interface LoopTraceEventLike {
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  reconcileStaleTurnLock
3
3
  } from "../chunk-CCVWR33L.js";
4
- import {
5
- DEFAULT_RUNNING_TURN_LEASE_MS
6
- } from "../chunk-ISP6ZH3G.js";
7
4
  import {
8
5
  base64UrlEncodeText,
9
6
  constantTimeEqual,
10
7
  hmacSha256Base64Url
11
8
  } from "../chunk-S5SRJJQG.js";
9
+ import {
10
+ DEFAULT_RUNNING_TURN_LEASE_MS
11
+ } from "../chunk-ISP6ZH3G.js";
12
12
 
13
13
  // src/turn-stream/core.ts
14
14
  var TURN_STREAM_TOKEN_TTL_MS = 6e4;
@@ -144,18 +144,14 @@ import {
144
144
  withoutRecordGridCreated,
145
145
  withoutRecordGridRemoved,
146
146
  withoutRecordGridUpdate
147
- } from "../chunk-XTMRAE6I.js";
147
+ } from "../chunk-UCCSJX64.js";
148
148
  import {
149
149
  useInfiniteScroll
150
150
  } from "../chunk-BDEBQ4WO.js";
151
151
  import {
152
152
  MENTION_PILL_CLASS
153
153
  } from "../chunk-3HUFJ5LO.js";
154
- import {
155
- tabTerminalConnectionId,
156
- useSandboxTerminalConnection
157
- } from "../chunk-E4AY62T2.js";
158
- import "../chunk-GDUT72VK.js";
154
+ import "../chunk-6OSJNJA2.js";
159
155
  import {
160
156
  AGENT_PROFILE_EDITOR_SECTIONS,
161
157
  AgentProfileEditor,
@@ -230,15 +226,19 @@ import {
230
226
  usePending,
231
227
  usePopover
232
228
  } from "../chunk-R4X5474U.js";
233
- import "../chunk-SJWIZT7B.js";
234
229
  import {
235
- ProviderLogo
236
- } from "../chunk-RASGKEAL.js";
230
+ tabTerminalConnectionId,
231
+ useSandboxTerminalConnection
232
+ } from "../chunk-E4AY62T2.js";
233
+ import "../chunk-SJWIZT7B.js";
237
234
  import {
238
235
  ReviewFeedbackForm
239
236
  } from "../chunk-ATQQCG4I.js";
240
237
  import "../chunk-WSEXFTN4.js";
241
238
  import "../chunk-AVP5SNIG.js";
239
+ import {
240
+ ProviderLogo
241
+ } from "../chunk-RASGKEAL.js";
242
242
  import "../chunk-FQYAJYPW.js";
243
243
  import {
244
244
  ALLOWED_ATTACHMENT_SNIFFED_MIMES,
@@ -246,6 +246,7 @@ import {
246
246
  OOXML_SNIFFED_MIMES
247
247
  } from "../chunk-IUVDR3KJ.js";
248
248
  import "../chunk-B7CL7ENS.js";
249
+ import "../chunk-AMUXRAUO.js";
249
250
  import {
250
251
  attachmentInputToPart,
251
252
  attachmentKindForMime,
@@ -306,15 +307,10 @@ import {
306
307
  questionInteractionContentSignature,
307
308
  stampInteractionAnswers
308
309
  } from "../chunk-6VQCFJWP.js";
309
- import "../chunk-AMUXRAUO.js";
310
310
  import "../chunk-FPNZMIAW.js";
311
311
  import "../chunk-PV33JZKV.js";
312
312
  import "../chunk-TXD5HXLE.js";
313
313
  import "../chunk-WL7PZK7Q.js";
314
- import {
315
- FlowWaterfall,
316
- waterfallLayout
317
- } from "../chunk-BLCYKYFV.js";
318
314
  export {
319
315
  AGENT_PROFILE_EDITOR_SECTIONS,
320
316
  ALLOWED_ATTACHMENT_SNIFFED_MIMES,
@@ -358,7 +354,6 @@ export {
358
354
  EntryComposer,
359
355
  EvidenceLineageTable,
360
356
  ExceptionList,
361
- FlowWaterfall,
362
357
  HarnessGlyph,
363
358
  HarnessPicker,
364
359
  INDEX_REFRESH_AFTER_MS,
@@ -567,7 +562,6 @@ export {
567
562
  useWorkspacePrewarmHandle,
568
563
  validateRecordGridCell,
569
564
  validateRecordGridRow,
570
- waterfallLayout,
571
565
  weakerProvenanceStanding,
572
566
  withRecordGridCreated,
573
567
  withRecordGridRemoved,
@@ -8,7 +8,7 @@
8
8
  * - {@link AgentActivityPanel}: the standalone cross-context surface — every
9
9
  * delegation a workspace ran, regardless of which mission (if any) spawned
10
10
  * it — behind a `fetchActivity` data port with cursor + refresh.
11
- * - {@link FlowWaterfall}: the web counterpart of `/trace`'s ASCII
11
+ * - charts FlowWaterfall: the web counterpart of `/trace`'s ASCII
12
12
  * `renderWaterfall` (which stays CLI) — proportional bars over a FlowTrace.
13
13
  *
14
14
  * Same styling contract as the rest of `/web-react`: Tailwind classes against
@@ -44,8 +44,6 @@ export interface AgentActivityPage {
44
44
  * snapshots of in-flight runs replace stale ones), newest `startedAt` first.
45
45
  */
46
46
  export declare function mergeActivityPages(existing: AgentActivityRecord[], incoming: AgentActivityRecord[]): AgentActivityRecord[];
47
- export { waterfallLayout, type WaterfallRow } from './flow-waterfall-model';
48
- export { FlowWaterfall, type FlowWaterfallProps } from './flow-waterfall';
49
47
  export interface MissionActivityLaneProps {
50
48
  /** The step's delegated-run snapshot (`MissionStepState.agentActivity`). */
51
49
  activity: StepAgentActivity[];
@@ -2,16 +2,6 @@ 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";
15
5
  import {
16
6
  artifactAgreementErrorDetail,
17
7
  canonicalizeValue,
@@ -31,6 +21,16 @@ import "../chunk-UGWQLQDS.js";
31
21
  import {
32
22
  ToolInputError
33
23
  } 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 = {