@mono-agent/tui 0.4.0 → 0.5.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 (124) hide show
  1. package/README.md +60 -10
  2. package/dist/bin/cli.d.ts +4 -1
  3. package/dist/bin/cli.d.ts.map +1 -1
  4. package/dist/bin/cli.js +36 -53
  5. package/dist/bin/cli.js.map +1 -1
  6. package/dist/bin/mono-agent-tui.js +21 -10
  7. package/dist/bin/mono-agent-tui.js.map +1 -1
  8. package/dist/config/pane.d.ts +9 -9
  9. package/dist/config/pane.d.ts.map +1 -1
  10. package/dist/config/pane.js +15 -196
  11. package/dist/config/pane.js.map +1 -1
  12. package/dist/data/instances.d.ts +48 -0
  13. package/dist/data/instances.d.ts.map +1 -0
  14. package/dist/data/instances.js +101 -0
  15. package/dist/data/instances.js.map +1 -0
  16. package/dist/data/replay.d.ts +68 -0
  17. package/dist/data/replay.d.ts.map +1 -0
  18. package/dist/data/replay.js +149 -0
  19. package/dist/data/replay.js.map +1 -0
  20. package/dist/index.d.ts +10 -10
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +5 -5
  23. package/dist/index.js.map +1 -1
  24. package/dist/remote/client.d.ts +44 -0
  25. package/dist/remote/client.d.ts.map +1 -0
  26. package/dist/remote/client.js +173 -0
  27. package/dist/remote/client.js.map +1 -0
  28. package/dist/runtime/start.d.ts +11 -18
  29. package/dist/runtime/start.d.ts.map +1 -1
  30. package/dist/runtime/start.js +19 -33
  31. package/dist/runtime/start.js.map +1 -1
  32. package/dist/ui/app.d.ts +142 -0
  33. package/dist/ui/app.d.ts.map +1 -0
  34. package/dist/ui/app.js +586 -0
  35. package/dist/ui/app.js.map +1 -0
  36. package/dist/ui/components/event-list.d.ts +60 -0
  37. package/dist/ui/components/event-list.d.ts.map +1 -0
  38. package/dist/ui/components/event-list.js +369 -0
  39. package/dist/ui/components/event-list.js.map +1 -0
  40. package/dist/ui/components/status-bar.d.ts +65 -0
  41. package/dist/ui/components/status-bar.d.ts.map +1 -0
  42. package/dist/ui/components/status-bar.js +126 -0
  43. package/dist/ui/components/status-bar.js.map +1 -0
  44. package/dist/ui/components/tool-panel.d.ts +30 -0
  45. package/dist/ui/components/tool-panel.d.ts.map +1 -0
  46. package/dist/ui/components/tool-panel.js +59 -0
  47. package/dist/ui/components/tool-panel.js.map +1 -0
  48. package/dist/ui/components/transcript-cells.d.ts +49 -0
  49. package/dist/ui/components/transcript-cells.d.ts.map +1 -0
  50. package/dist/ui/components/transcript-cells.js +110 -0
  51. package/dist/ui/components/transcript-cells.js.map +1 -0
  52. package/dist/ui/format.d.ts +29 -0
  53. package/dist/ui/format.d.ts.map +1 -0
  54. package/dist/ui/format.js +105 -0
  55. package/dist/ui/format.js.map +1 -0
  56. package/dist/ui/theme.d.ts +25 -0
  57. package/dist/ui/theme.d.ts.map +1 -0
  58. package/dist/ui/theme.js +62 -0
  59. package/dist/ui/theme.js.map +1 -0
  60. package/dist/ui/turn-presenter.d.ts +72 -0
  61. package/dist/ui/turn-presenter.d.ts.map +1 -0
  62. package/dist/ui/turn-presenter.js +334 -0
  63. package/dist/ui/turn-presenter.js.map +1 -0
  64. package/dist/ui/views/chat.d.ts +128 -0
  65. package/dist/ui/views/chat.d.ts.map +1 -0
  66. package/dist/ui/views/chat.js +313 -0
  67. package/dist/ui/views/chat.js.map +1 -0
  68. package/dist/ui/views/config.d.ts +23 -0
  69. package/dist/ui/views/config.d.ts.map +1 -0
  70. package/dist/ui/views/config.js +87 -0
  71. package/dist/ui/views/config.js.map +1 -0
  72. package/dist/ui/views/picker.d.ts +17 -0
  73. package/dist/ui/views/picker.d.ts.map +1 -0
  74. package/dist/ui/views/picker.js +57 -0
  75. package/dist/ui/views/picker.js.map +1 -0
  76. package/dist/ui/views/replay-detail.d.ts +60 -0
  77. package/dist/ui/views/replay-detail.d.ts.map +1 -0
  78. package/dist/ui/views/replay-detail.js +328 -0
  79. package/dist/ui/views/replay-detail.js.map +1 -0
  80. package/dist/ui/views/replay.d.ts +74 -0
  81. package/dist/ui/views/replay.d.ts.map +1 -0
  82. package/dist/ui/views/replay.js +460 -0
  83. package/dist/ui/views/replay.js.map +1 -0
  84. package/package.json +9 -12
  85. package/dist/agent/message-stream.d.ts +0 -52
  86. package/dist/agent/message-stream.d.ts.map +0 -1
  87. package/dist/agent/message-stream.js +0 -110
  88. package/dist/agent/message-stream.js.map +0 -1
  89. package/dist/components/ChatPane.d.ts +0 -20
  90. package/dist/components/ChatPane.d.ts.map +0 -1
  91. package/dist/components/ChatPane.js +0 -142
  92. package/dist/components/ChatPane.js.map +0 -1
  93. package/dist/components/ConfigPane.d.ts +0 -12
  94. package/dist/components/ConfigPane.d.ts.map +0 -1
  95. package/dist/components/ConfigPane.js +0 -70
  96. package/dist/components/ConfigPane.js.map +0 -1
  97. package/dist/components/HelpOverlay.d.ts +0 -6
  98. package/dist/components/HelpOverlay.d.ts.map +0 -1
  99. package/dist/components/HelpOverlay.js +0 -18
  100. package/dist/components/HelpOverlay.js.map +0 -1
  101. package/dist/components/HistoryPane.d.ts +0 -9
  102. package/dist/components/HistoryPane.d.ts.map +0 -1
  103. package/dist/components/HistoryPane.js +0 -125
  104. package/dist/components/HistoryPane.js.map +0 -1
  105. package/dist/components/StatusBar.d.ts +0 -10
  106. package/dist/components/StatusBar.d.ts.map +0 -1
  107. package/dist/components/StatusBar.js +0 -15
  108. package/dist/components/StatusBar.js.map +0 -1
  109. package/dist/components/TuiApp.d.ts +0 -29
  110. package/dist/components/TuiApp.d.ts.map +0 -1
  111. package/dist/components/TuiApp.js +0 -81
  112. package/dist/components/TuiApp.js.map +0 -1
  113. package/dist/components/primitives/Badge.d.ts +0 -8
  114. package/dist/components/primitives/Badge.d.ts.map +0 -1
  115. package/dist/components/primitives/Badge.js +0 -14
  116. package/dist/components/primitives/Badge.js.map +0 -1
  117. package/dist/components/primitives/Spinner.d.ts +0 -6
  118. package/dist/components/primitives/Spinner.d.ts.map +0 -1
  119. package/dist/components/primitives/Spinner.js +0 -8
  120. package/dist/components/primitives/Spinner.js.map +0 -1
  121. package/dist/components/primitives/TranscriptLine.d.ts +0 -10
  122. package/dist/components/primitives/TranscriptLine.d.ts.map +0 -1
  123. package/dist/components/primitives/TranscriptLine.js +0 -15
  124. package/dist/components/primitives/TranscriptLine.js.map +0 -1
@@ -0,0 +1,48 @@
1
+ import type { TraceSourceListItem } from "@mono-agent/observability";
2
+ export type { TraceSourceListItem } from "@mono-agent/observability";
3
+ /** The default machine-wide registry dir every agent writes to unless overridden. */
4
+ export declare function defaultTraceRegistryDir(env?: Record<string, string | undefined>): string;
5
+ export interface DiscoverInstancesOptions {
6
+ readonly registryDir?: string;
7
+ /**
8
+ * Consult several registries at once (e.g. an agent's config-local registry
9
+ * plus the machine-wide global one) and merge by sourceId — the fresher
10
+ * heartbeat wins a duplicate, earlier dirs win ties. Takes precedence over
11
+ * the single `registryDir` when non-empty; repeated dirs are deduped.
12
+ */
13
+ readonly registryDirs?: readonly string[];
14
+ readonly staleAfterMs?: number;
15
+ readonly env?: Record<string, string | undefined>;
16
+ }
17
+ export interface DiscoveredInstance {
18
+ readonly source: TraceSourceListItem;
19
+ /** The operator-adapter TUI base URL published by the agent's tui channel, when running. */
20
+ readonly tuiBaseUrl?: string;
21
+ /** dirname(configPath): where replay/config data lives relative to. */
22
+ readonly agentDir?: string;
23
+ }
24
+ export interface DiscoverInstancesResult {
25
+ readonly instances: readonly DiscoveredInstance[];
26
+ /** First consulted registry — kept for callers that predate multi-registry discovery. */
27
+ readonly registryDir: string;
28
+ /** Every consulted registry, in precedence order (deduped, normalized). */
29
+ readonly registryDirs: readonly string[];
30
+ readonly warnings: readonly string[];
31
+ }
32
+ /**
33
+ * Discover mono-agent instances via one or more trace-source registries
34
+ * (merged by sourceId — fresher heartbeat wins a duplicate, so each instance
35
+ * carries its winning manifest's own absolute artifact/config paths). Stopped
36
+ * sources are filtered out; stale ones stay listed (marked by health) because
37
+ * a busy agent can miss heartbeats while remaining connectable.
38
+ */
39
+ export declare function discoverInstances(options?: DiscoverInstancesOptions): Promise<DiscoverInstancesResult>;
40
+ export declare function toInstance(source: TraceSourceListItem): DiscoveredInstance;
41
+ /**
42
+ * Best-effort apiKey resolution for a discovered agent: the registry never
43
+ * carries secrets, so read the agent's own config file (`tui.apiKey` /
44
+ * `MONO_AGENT_TUI_API_KEY` env of THIS process). Failures resolve undefined —
45
+ * a keyless connect against a keyed agent surfaces as 401 with a hint.
46
+ */
47
+ export declare function resolveInstanceApiKey(instance: DiscoveredInstance, env?: Record<string, string | undefined>): Promise<string | undefined>;
48
+ //# sourceMappingURL=instances.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instances.d.ts","sourceRoot":"","sources":["../../src/data/instances.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,qFAAqF;AACrF,wBAAgB,uBAAuB,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,MAAM,CAMrG;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,4FAA4F;IAC5F,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAClD,yFAAyF;IACzF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,uBAAuB,CAAC,CAmBlC;AAoBD,wBAAgB,UAAU,CAAC,MAAM,EAAE,mBAAmB,GAAG,kBAAkB,CAO1E;AAkBD;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,kBAAkB,EAC5B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAqB7B"}
@@ -0,0 +1,101 @@
1
+ import { homedir } from "node:os";
2
+ import { dirname, resolve } from "node:path";
3
+ import { listTraceSources, mergeTraceSources } from "@mono-agent/observability";
4
+ /** The default machine-wide registry dir every agent writes to unless overridden. */
5
+ export function defaultTraceRegistryDir(env = process.env) {
6
+ const override = env.MONO_AGENT_TRACE_REGISTRY_DIR?.trim();
7
+ if (override !== undefined && override.length > 0) {
8
+ return resolve(override);
9
+ }
10
+ return resolve(homedir(), ".mono-agent", "trace-sources");
11
+ }
12
+ /**
13
+ * Discover mono-agent instances via one or more trace-source registries
14
+ * (merged by sourceId — fresher heartbeat wins a duplicate, so each instance
15
+ * carries its winning manifest's own absolute artifact/config paths). Stopped
16
+ * sources are filtered out; stale ones stay listed (marked by health) because
17
+ * a busy agent can miss heartbeats while remaining connectable.
18
+ */
19
+ export async function discoverInstances(options = {}) {
20
+ const registryDirs = normalizeRegistryDirs(options);
21
+ const results = await Promise.all(registryDirs.map((registryDir) => listTraceSources({
22
+ registryDir,
23
+ ...(options.staleAfterMs === undefined ? {} : { staleAfterMs: options.staleAfterMs }),
24
+ })));
25
+ const instances = mergeTraceSources(...results.map((result) => result.sources))
26
+ .filter((source) => source.health !== "stopped")
27
+ .map((source) => toInstance(source));
28
+ return {
29
+ instances,
30
+ registryDir: registryDirs[0] ?? "",
31
+ registryDirs,
32
+ warnings: results.flatMap((result) => result.warnings),
33
+ };
34
+ }
35
+ /** Resolve + dedupe the requested registry list; `registryDirs` (when non-empty) beats the single `registryDir`. */
36
+ function normalizeRegistryDirs(options) {
37
+ const requested = options.registryDirs !== undefined && options.registryDirs.length > 0
38
+ ? options.registryDirs
39
+ : [options.registryDir ?? defaultTraceRegistryDir(options.env)];
40
+ const seen = new Set();
41
+ const dirs = [];
42
+ for (const dir of requested) {
43
+ const resolved = resolve(dir);
44
+ if (!seen.has(resolved)) {
45
+ seen.add(resolved);
46
+ dirs.push(resolved);
47
+ }
48
+ }
49
+ return dirs;
50
+ }
51
+ export function toInstance(source) {
52
+ const tuiBaseUrl = tuiBaseUrlFromMetadata(source.metadata);
53
+ return {
54
+ source,
55
+ ...(tuiBaseUrl === undefined ? {} : { tuiBaseUrl }),
56
+ ...(source.configPath === undefined ? {} : { agentDir: dirname(source.configPath) }),
57
+ };
58
+ }
59
+ function tuiBaseUrlFromMetadata(metadata) {
60
+ const channels = metadata?.channels;
61
+ if (typeof channels !== "object" || channels === null) {
62
+ return undefined;
63
+ }
64
+ const tui = channels.tui;
65
+ if (typeof tui !== "object" || tui === null) {
66
+ return undefined;
67
+ }
68
+ const record = tui;
69
+ if (record.kind !== "running") {
70
+ return undefined;
71
+ }
72
+ return typeof record.baseUrl === "string" && record.baseUrl.length > 0 ? record.baseUrl : undefined;
73
+ }
74
+ /**
75
+ * Best-effort apiKey resolution for a discovered agent: the registry never
76
+ * carries secrets, so read the agent's own config file (`tui.apiKey` /
77
+ * `MONO_AGENT_TUI_API_KEY` env of THIS process). Failures resolve undefined —
78
+ * a keyless connect against a keyed agent surfaces as 401 with a hint.
79
+ */
80
+ export async function resolveInstanceApiKey(instance, env = process.env) {
81
+ const fromEnv = env.MONO_AGENT_TUI_API_KEY?.trim();
82
+ if (fromEnv !== undefined && fromEnv.length > 0) {
83
+ return fromEnv;
84
+ }
85
+ const configPath = instance.source.configPath;
86
+ if (configPath === undefined) {
87
+ return undefined;
88
+ }
89
+ try {
90
+ const { readFile } = await import("node:fs/promises");
91
+ const parsed = JSON.parse(await readFile(configPath, "utf8"));
92
+ // Trim to match the adapter's own loader (normalizeOptionalString): the
93
+ // server compares against the trimmed key, so an untrimmed client 401s.
94
+ const apiKey = typeof parsed.tui?.apiKey === "string" ? parsed.tui.apiKey.trim() : undefined;
95
+ return apiKey !== undefined && apiKey.length > 0 ? apiKey : undefined;
96
+ }
97
+ catch {
98
+ return undefined;
99
+ }
100
+ }
101
+ //# sourceMappingURL=instances.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instances.js","sourceRoot":"","sources":["../../src/data/instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAKhF,qFAAqF;AACrF,MAAM,UAAU,uBAAuB,CAAC,MAA0C,OAAO,CAAC,GAAG;IAC3F,MAAM,QAAQ,GAAG,GAAG,CAAC,6BAA6B,EAAE,IAAI,EAAE,CAAC;IAC3D,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;AAC5D,CAAC;AAgCD;;;;;;GAMG;AACH,MAAM,CAAC,K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-0,0 +1,68 @@
1
+ import type { RecordedRunDetail, RecordedRunListItem, RecordedRunTimelineItem, RunArtifactScope, TimelineTurn } from "@mono-agent/observability";
2
+ export type { RecordedRunDetail, RecordedRunListItem, RecordedRunTimelineItem, TimelineTurn };
3
+ export interface ReplayRunListItem extends RecordedRunListItem {
4
+ /** `source` when persisted, else {@link deriveRunSource} on `conversationId`. */
5
+ readonly resolvedSource: string;
6
+ }
7
+ export interface ListReplayRunsOptions {
8
+ /** Display cap on the returned run list (default 200). */
9
+ readonly maxRuns?: number;
10
+ /** When set, keep only runs whose `resolvedSource` matches exactly. */
11
+ readonly sourceFilter?: string;
12
+ }
13
+ export interface ListReplayRunsResult {
14
+ readonly runs: readonly ReplayRunListItem[];
15
+ readonly warnings: readonly string[];
16
+ /** Total runs found in the artifact dir, independent of `sourceFilter`/`maxRuns`. */
17
+ readonly totalRuns: number;
18
+ }
19
+ /**
20
+ * Newest-first recorded runs read straight from the agent's artifact dir.
21
+ *
22
+ * @param options - Either a {@link ListReplayRunsOptions} object, or (legacy
23
+ * back-compat form, kept for published-API callers predating `sourceFilter`)
24
+ * a bare `number` treated as `{ maxRuns: number }`.
25
+ */
26
+ export declare function listReplayRuns(artifactDir: string, options?: number | ListReplayRunsOptions): Promise<ListReplayRunsResult>;
27
+ /** Per-item replay annotations layered onto the coalesced timeline. */
28
+ export interface ReplayTimelineItem extends RecordedRunTimelineItem {
29
+ /** `item.timestamp` parsed to epoch ms; undefined when absent/unparseable. */
30
+ readonly timestampMs?: number;
31
+ /**
32
+ * `timestampMs` minus the PREVIOUS timeline item's END (its `endTimestampMs`
33
+ * when parseable, else its own `timestampMs`) — anchoring on the previous
34
+ * item's end rather than its start matters for a coalesced group (e.g. a
35
+ * multi-chunk thinking block), whose start can be well before the moment it
36
+ * actually finished. Undefined for the first item, or when either side
37
+ * lacks a timestamp. Negative values (clock skew) are clamped to 0.
38
+ */
39
+ readonly deltaMs?: number;
40
+ /** Which {@link TimelineTurn.turnIndex} (from segmentTimelineTurns) this item belongs to. */
41
+ readonly turnIndex: number;
42
+ }
43
+ /** Fallback run-level model/effort/override metadata parsed from a `run_config` event. */
44
+ export interface ReplayRunConfig {
45
+ readonly model?: string;
46
+ readonly effort?: string;
47
+ readonly overridden?: boolean;
48
+ }
49
+ export interface ReplayRunDetail {
50
+ readonly detail: RecordedRunDetail;
51
+ /** Coalesced timeline: streamed assistant/thinking deltas merged into one item each. */
52
+ readonly timeline: readonly ReplayTimelineItem[];
53
+ /** Agent-loop turns segmented from `timeline` (see segmentTimelineTurns); durationMs clamped to >= 0. */
54
+ readonly turns: readonly TimelineTurn[];
55
+ /**
56
+ * The run's LAST `run_config` event, when the run emitted one. A run can
57
+ * double-fire this event on a session-resume-retry; the last one reflects
58
+ * the actually-used configuration.
59
+ */
60
+ readonly runConfig?: ReplayRunConfig;
61
+ /** Resolved effort: `detail.summary.effort` when present, else `runConfig?.effort`. */
62
+ readonly effort?: string;
63
+ }
64
+ export interface ReadReplayRunOptions {
65
+ readonly scope?: RunArtifactScope;
66
+ }
67
+ export declare function readReplayRun(artifactDir: string, runId: string, options?: ReadReplayRunOptions): Promise<ReplayRunDetail | undefined>;
68
+ //# sourceMappingURL=replay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/data/replay.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,iBAAiB,EAEjB,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,YAAY,EACb,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAC;AAkB9F,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;IAC5D,iFAAiF;IACjF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,qBAAqB;IACpC,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAA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AW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAED,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAsBtC"}
@@ -0,0 +1,149 @@
1
+ import { combineRecordedRunEvents, deriveRunSource, listRecordedRuns, readRecordedRun, segmentTimelineTurns, } from "@mono-agent/observability";
2
+ const DEFAULT_MAX_RUNS = 200;
3
+ // When `sourceFilter` narrows the result, we widen the underlying read past
4
+ // the display cap so a rare source isn't starved by a naive cap-then-filter
5
+ // ordering (a source with few runs could be entirely outside the top 200
6
+ // newest runs even though it has matches further back). Filtering happens
7
+ // AFTER this wider read and BEFORE the final `maxRuns` slice below.
8
+ const FILTERED_READ_CEILING = 500;
9
+ // observability's own default (~4096 bytes, see DEFAULT_MAX_STRING_BYTES in
10
+ // @mono-agent/observability/src/guards.ts) is tuned for compact summaries and
11
+ // guts tool/message payload expansion in the replay detail view. Replay needs
12
+ // to show the (redacted) payload in full for drill-down, so it asks for a
13
+ // much larger cap.
14
+ const REPLAY_MAX_STRING_BYTES = 32_768;
15
+ /**
16
+ * Newest-first recorded runs read straight from the agent's artifact dir.
17
+ *
18
+ * @param options - Either a {@link ListReplayRunsOptions} object, or (legacy
19
+ * back-compat form, kept for published-API callers predating `sourceFilter`)
20
+ * a bare `number` treated as `{ maxRuns: number }`.
21
+ */
22
+ export async function listReplayRuns(artifactDir, options = {}) {
23
+ const normalized = typeof options === "number" ? { maxRuns: options } : options;
24
+ const maxRuns = normalized.maxRuns ?? DEFAULT_MAX_RUNS;
25
+ // Fast path (no filter): read exactly what we'll show, same as before.
26
+ // Filtering path: read the wider ceiling so filtering doesn't get starved
27
+ // by a cap applied before we even know what matches.
28
+ const readCeiling = normalized.sourceFilter === undefined ? maxRuns : Math.max(maxRuns, FILTERED_READ_CEILING);
29
+ const scope = replayScopeForSourceFilter(normalized.sourceFilter);
30
+ const result = await listRecordedRuns({
31
+ artifactDir,
32
+ maxRuns: readCeiling,
33
+ ...(scope === undefined ? {} : { scope }),
34
+ });
35
+ const resolved = result.runs.map((run) => ({
36
+ ...run,
37
+ resolvedSource: run.source ?? deriveRunSource(run.conversationId),
38
+ }));
39
+ const filtered = normalized.sourceFilter === undefined
40
+ ? resolved
41
+ : resolved.filter((run) => run.resolvedSource === normalized.sourceFilter);
42
+ return {
43
+ runs: filtered.slice(0, maxRuns),
44
+ warnings: result.warnings,
45
+ totalRuns: result.totalRuns,
46
+ };
47
+ }
48
+ export async function readReplayRun(artifactDir, runId, options = {}) {
49
+ const scope = options.scope ?? "agent";
50
+ const detail = await readRecordedRun({
51
+ artifactDir,
52
+ maxStringBytes: REPLAY_MAX_STRING_BYTES,
53
+ scope,
54
+ }, runId);
55
+ if (detail === undefined) {
56
+ return undefined;
57
+ }
58
+ const coalesced = combineRecordedRunEvents(detail.events);
59
+ const turns = segmentTimelineTurns(coalesced).map(clampTurnDuration);
60
+ const timeline = annotateTimeline(coalesced, turns);
61
+ const runConfig = lastRunConfig(detail.events);
62
+ const effort = detail.summary.effort ?? runConfig?.effort;
63
+ return {
64
+ detail,
65
+ timeline,
66
+ turns,
67
+ ...(runConfig === undefined ? {} : { runConfig }),
68
+ ...(effort === undefined ? {} : { effort }),
69
+ };
70
+ }
71
+ function replayScopeForSourceFilter(sourceFilter) {
72
+ if (sourceFilter === "memory") {
73
+ return "memory";
74
+ }
75
+ return undefined;
76
+ }
77
+ /**
78
+ * `TimelineTurn.durationMs` is derived from raw event timestamps and can go
79
+ * negative under clock skew (e.g. a resumed session). We clamp to 0 rather
80
+ * than dropping to undefined: consumers treat `durationMs` as "elapsed time
81
+ * for this turn" and a defined-but-zero value is easier to render (e.g. in a
82
+ * duration column) than an extra undefined-check, at the cost of slightly
83
+ * under-reporting the (already-untrustworthy) skewed turn.
84
+ */
85
+ function clampTurnDuration(turn) {
86
+ if (turn.durationMs === undefined || turn.durationMs >= 0) {
87
+ return turn;
88
+ }
89
+ return { ...turn, durationMs: 0 };
90
+ }
91
+ function annotateTimeline(items, turns) {
92
+ const turnIndexByItem = buildTurnIndexLookup(turns, items.length);
93
+ // Anchored on the previous item's END (its own endTimestamp when parseable,
94
+ // else its timestamp) rather than its START — see the deltaMs doc comment.
95
+ let previousEndMs;
96
+ return items.map((item, index) => {
97
+ const timestampMs = parseTimestampMs(item.timestamp);
98
+ const endTimestampMs = parseTimestampMs(item.endTimestamp) ?? timestampMs;
99
+ const deltaMs = previousEndMs === undefined || timestampMs === undefined ? undefined : Math.max(0, timestampMs - previousEndMs);
100
+ previousEndMs = endTimestampMs;
101
+ return {
102
+ ...item,
103
+ ...(timestampMs === undefined ? {} : { timestampMs }),
104
+ ...(deltaMs === undefined ? {} : { deltaMs }),
105
+ turnIndex: turnIndexByItem[index] ?? 0,
106
+ };
107
+ });
108
+ }
109
+ function buildTurnIndexLookup(turns, itemCount) {
110
+ const lookup = new Array(itemCount).fill(0);
111
+ for (const turn of turns) {
112
+ for (let index = turn.startItemIndex; index <= turn.endItemIndex; index += 1) {
113
+ lookup[index] = turn.turnIndex;
114
+ }
115
+ }
116
+ return lookup;
117
+ }
118
+ function parseTimestampMs(timestamp) {
119
+ if (timestamp === undefined) {
120
+ return undefined;
121
+ }
122
+ const ms = Date.parse(timestamp);
123
+ return Number.isFinite(ms) ? ms : undefined;
124
+ }
125
+ /**
126
+ * Scan the run's RAW events (not the coalesced timeline) for `run_config`
127
+ * events and return the LAST one's fields. The harness can double-fire this
128
+ * event on a session-resume-retry within a single run; the last occurrence
129
+ * reflects the configuration actually used.
130
+ */
131
+ function lastRunConfig(events) {
132
+ let found;
133
+ for (const event of events) {
134
+ if (event.type !== "run_config" || !isRecord(event.payload)) {
135
+ continue;
136
+ }
137
+ const payload = event.payload;
138
+ found = {
139
+ ...(typeof payload.model === "string" ? { model: payload.model } : {}),
140
+ ...(typeof payload.effort === "string" ? { effort: payload.effort } : {}),
141
+ ...(typeof payload.overridden === "boolean" ? { overridden: payload.overridden } : {}),
142
+ };
143
+ }
144
+ return found;
145
+ }
146
+ function isRecord(value) {
147
+ return typeof value === "object" && value !== null && !Array.isArray(value);
148
+ }
149
+ //# sourceMappingURL=replay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.js","sourceRoot":"","sources":["../../src/data/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AAYnC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,4EAA4E;AAC5E,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,oEAAoE;AACpE,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC,4EAA4E;AAC5E,8EAA8E;AAC9E,8EAA8E;AAC9E,0EAA0E;AAC1E,mBAAmB;AACnB,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAqBvC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,WAAmB,EACnB,UAA0C,EAAE;IAE5C,MAAM,UAAU,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAChF,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,gBAAgB,CAAC;IACvD,uEAAuE;IACvE,0EAA0E;IAC1E,qDAAqD;IACrD,MAAM,WAAW,GAAG,UAAU,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;IAC/G,MAAM,KAAK,GAAG,0BAA0B,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAClE,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC;QACpC,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C;IACjC,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9C,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,MAAmC;IACxD,IAAI,KAAkC,CAAC;IACvC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5D,SAAS;QACX,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,KAAK,GAAG;YACN,GAAG,CAAC,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACtE,GAAG,CAAC,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzE,GAAG,CAAC,OAAO,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvF,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,18 +2,18 @@ export type { AgentMessageStreamLike, AgentRequestLike, AgentResponderLike, Agen
2
2
  export { TuiAgentCancelledError, isTuiAgentCancelledError, } from "./agent/responder.js";
3
3
  export type { CreateInMemoryTuiHistoryOptions, TuiHistoryMessage, TuiHistoryRole, TuiHistoryStatus, TuiHistoryStore, } from "./agent/history.js";
4
4
  export { createInMemoryTuiHistory } from "./agent/history.js";
5
- export type { TuiInkMessageStreamOptions, TuiStreamState, } from "./agent/message-stream.js";
6
- export { TuiInkMessageStream } from "./agent/message-stream.js";
7
- export type { ChatPaneProps } from "./components/ChatPane.js";
8
- export { ChatPane } from "./components/ChatPane.js";
9
- export type { HistoryPaneProps } from "./components/HistoryPane.js";
10
- export { HistoryPane } from "./components/HistoryPane.js";
11
- export type { ConfigPaneProps } from "./components/ConfigPane.js";
12
- export { ConfigPane } from "./components/ConfigPane.js";
13
5
  export type { BuildTuiConfigSummaryInput, TuiConfigFieldSource, TuiConfigFieldSummary, TuiConfigSummarySection, } from "./config/pane.js";
14
6
  export { buildTuiConfigSummary } from "./config/pane.js";
15
- export type { TuiAppConfigPaneOptions, TuiAppLogger, TuiAppProps, TuiPaneId, } from "./components/TuiApp.js";
16
- export { TuiApp } from "./components/TuiApp.js";
7
+ export { RemoteAgentResponder, RemoteAgentResponderError } from "./remote/client.js";
8
+ export type { RemoteAgentResponderOptions } from "./remote/client.js";
9
+ export { defaultTraceRegistryDir, discoverInstances, resolveInstanceApiKey, toInstance, } from "./data/instances.js";
10
+ export type { DiscoverInstancesOptions, DiscoveredInstance, TraceSourceListItem, } from "./data/instances.js";
11
+ export { listReplayRuns, readReplayRun } from "./data/replay.js";
12
+ export type { ListReplayRunsOptions, ListReplayRunsResult, ReplayRunConfig, ReplayRunDetail, ReplayRunListItem, ReplayTimelineItem, TimelineTurn, } from "./data/replay.js";
13
+ export { TurnPresenter } from "./ui/turn-presenter.js";
14
+ export type { TurnPresenterOptions } from "./ui/turn-presenter.js";
15
+ export { MonoAgentTuiApp } from "./ui/app.js";
16
+ export type { MonoAgentTuiAppOptions, TuiAppLogger, TuiViewId } from "./ui/app.js";
17
17
  export type { StartMonoAgentTuiHandle, StartMonoAgentTuiOptions, } from "./runtime/start.js";
18
18
  export { startMonoAgentTui } from "./runtime/start.js";
19
19
  export { TUI_PACKAGE_VERSION } from "./runtime/version.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,+BAA+B,EAC/B,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,YAAY,EACV,0BAA0B,EAC1B,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,YAAY,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,YAAY,EACV,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,SAAS,GACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,Y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AAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,sBAAsB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnF,YAAY,EACV,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  export { TuiAgentCancelledError, isTuiAgentCancelledError, } from "./agent/responder.js";
2
2
  export { createInMemoryTuiHistory } from "./agent/history.js";
3
- export { TuiInkMessageStream } from "./agent/message-stream.js";
4
- export { ChatPane } from "./components/ChatPane.js";
5
- export { HistoryPane } from "./components/HistoryPane.js";
6
- export { ConfigPane } from "./components/ConfigPane.js";
7
3
  export { buildTuiConfigSummary } from "./config/pane.js";
8
- export { TuiApp } from "./components/TuiApp.js";
4
+ export { RemoteAgentResponder, RemoteAgentResponderError } from "./remote/client.js";
5
+ export { defaultTraceRegistryDir, discoverInstances, resolveInstanceApiKey, toInstance, } from "./data/instances.js";
6
+ export { listReplayRuns, readReplayRun } from "./data/replay.js";
7
+ export { TurnPresenter } from "./ui/turn-presenter.js";
8
+ export { MonoAgentTuiApp } from "./ui/app.js";
9
9
  export { startMonoAgentTui } from "./runtime/start.js";
10
10
  export { TUI_PACKAGE_VERSION } from "./runtime/version.js";
11
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAS9B,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAM9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAQxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAQzD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAMhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAS9B,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAQ9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAGrF,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,GACX,MAAM,qBAAqB,CAAC;AAO7B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAWjE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAO9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { type AgentMessageStream, type AgentRequestBase, type AgentResponder, type AgentResponse } from "@mono-agent/agent-contracts";
2
+ export interface RemoteAgentResponderOptions {
3
+ /** The running agent's operator-adapter TUI base URL, e.g. http://127.0.0.1:52341/tui */
4
+ readonly baseUrl: string;
5
+ readonly apiKey?: string;
6
+ readonly fetchImpl?: typeof fetch;
7
+ }
8
+ export declare class RemoteAgentResponderError extends Error {
9
+ readonly code?: string;
10
+ constructor(message: string, code?: string);
11
+ }
12
+ /**
13
+ * AgentResponder over the operator-adapter TUI NDJSON wire: one POST per turn, each
14
+ * received frame replayed onto the local AgentMessageStream in order. Because
15
+ * it implements the same contract as an in-process responder, every UI surface
16
+ * works identically in embedded (`--responder`) and remote (`mono-agent tui`)
17
+ * modes.
18
+ */
19
+ export declare class RemoteAgentResponder implements AgentResponder {
20
+ private readonly baseUrl;
21
+ private readonly apiKey;
22
+ private readonly fetchImpl;
23
+ constructor(options: RemoteAgentResponderOptions);
24
+ private headers;
25
+ /** Probe GET /v1/info; throws RemoteAgentResponderError when unreachable/unauthorized. */
26
+ info(): Promise<{
27
+ schema: number;
28
+ pid?: number;
29
+ label?: string;
30
+ model?: string;
31
+ effort?: string;
32
+ models?: readonly string[];
33
+ modelOptions?: Record<string, {
34
+ effortLevels?: readonly string[];
35
+ reasoning?: boolean;
36
+ reasoningMode?: string;
37
+ label?: string;
38
+ }>;
39
+ }>;
40
+ respond(request: AgentRequestBase, stream: AgentMessageStream): Promise<AgentResponse>;
41
+ cancel(conversationId: string): void;
42
+ private request;
43
+ }
44
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/remote/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,2BAA2B;IAC1C,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC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