@runtypelabs/persona 4.22.0 → 4.23.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.
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-B_JdVK9o.d.cts → types-9Vxm-PPz.d.cts} +136 -6
- package/dist/animations/{types-B_JdVK9o.d.ts → types-9Vxm-PPz.d.ts} +136 -6
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/animations-extra.d.cts +136 -6
- package/dist/animations-extra.d.ts +136 -6
- package/dist/approval-ui.d.cts +148 -14
- package/dist/approval-ui.d.ts +148 -14
- package/dist/artifacts-ui.d.cts +148 -14
- package/dist/artifacts-ui.d.ts +148 -14
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/context-mentions.d.cts +148 -14
- package/dist/context-mentions.d.ts +148 -14
- package/dist/event-stream-view-GL3ADRY2.js +1 -0
- package/dist/event-stream-view.cjs +1 -1
- package/dist/event-stream-view.d.cts +148 -14
- package/dist/event-stream-view.d.ts +148 -14
- package/dist/event-stream-view.js +1 -1
- package/dist/forms-ui.d.cts +161 -23
- package/dist/forms-ui.d.ts +161 -23
- package/dist/history-view.d.cts +136 -6
- package/dist/history-view.d.ts +136 -6
- package/dist/index.cjs +67 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +172 -27
- package/dist/index.d.ts +172 -27
- package/dist/index.global.js +51 -51
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +67 -67
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js.map +1 -1
- package/dist/session-reconnect.d.cts +148 -14
- package/dist/session-reconnect.d.ts +148 -14
- package/dist/smart-dom-reader.d.cts +148 -14
- package/dist/smart-dom-reader.d.ts +148 -14
- package/dist/testing.cjs +3 -3
- package/dist/testing.d.cts +3 -4
- package/dist/testing.d.ts +3 -4
- package/dist/testing.js +3 -3
- package/dist/theme-editor-preview.cjs +71 -71
- package/dist/theme-editor-preview.d.cts +154 -14
- package/dist/theme-editor-preview.d.ts +154 -14
- package/dist/theme-editor-preview.js +48 -48
- package/dist/theme-editor.d.cts +148 -14
- package/dist/theme-editor.d.ts +148 -14
- package/dist/voice-runtime.d.cts +6 -2
- package/dist/voice-runtime.d.ts +6 -2
- package/package.json +1 -1
- package/src/ask-user-question-tool.ts +1 -1
- package/src/client-history-rest.test.ts +2 -1
- package/src/client-visitor-history.test.ts +106 -4
- package/src/client.composer-options.test.ts +1 -1
- package/src/client.interrupt.test.ts +2 -2
- package/src/client.test.ts +477 -915
- package/src/client.ts +134 -494
- package/src/client.unified-tools.test.ts +76 -0
- package/src/components/event-stream-badge-theming.test.ts +3 -0
- package/src/components/event-stream-view.test.ts +76 -76
- package/src/components/event-stream-view.ts +5 -0
- package/src/components/tool-bubble.test.ts +12 -0
- package/src/components/tool-bubble.ts +13 -2
- package/src/event-stream-view-bundle.test.ts +2 -2
- package/src/generated/runtype-openapi-contract.ts +129 -1
- package/src/internal/runtype-history-provider.test.ts +2 -2
- package/src/launcher-global.ts +1 -1
- package/src/session-history.test.ts +1 -1
- package/src/session.quote.test.ts +1 -1
- package/src/session.resubmit-from.test.ts +1 -1
- package/src/session.test.ts +5 -5
- package/src/session.ts +95 -36
- package/src/suggest-replies-tool.ts +1 -1
- package/src/testing/mock-stream.test.ts +37 -16
- package/src/testing/mock-stream.ts +14 -9
- package/src/types.ts +19 -14
- package/src/ui.ask-user-question-plugin.test.ts +7 -7
- package/src/ui.composer-defer-one.test.ts +6 -34
- package/src/ui.composer-draft-persistence.test.ts +1 -1
- package/src/ui.composer-quote.test.ts +1 -1
- package/src/ui.message-history-actions.test.ts +1 -1
- package/src/ui.streaming-coalescing.test.ts +10 -13
- package/src/ui.ts +80 -32
- package/src/ui.typing-indicator.test.ts +216 -0
- package/src/ui.voice-custom-provider.test.ts +211 -0
- package/src/utils/event-stream-buffer.test.ts +13 -13
- package/src/utils/event-stream-capture.test.ts +20 -20
- package/src/utils/throughput-tracker.test.ts +100 -142
- package/src/utils/throughput-tracker.ts +18 -132
- package/src/utils/voice-support.ts +18 -1
- package/src/voice/voice-turn-tracker.ts +18 -0
- package/src/webmcp-bridge.ts +1 -1
- package/dist/event-stream-view-FKWDY3UB.js +0 -1
- package/src/utils/__fixtures__/unified-translator.oracle.ts +0 -717
|
@@ -1694,6 +1694,11 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1694
1694
|
iteration?: number;
|
|
1695
1695
|
role: "user" | "assistant" | "system";
|
|
1696
1696
|
seq: number;
|
|
1697
|
+
subagent?: {
|
|
1698
|
+
agentName?: string;
|
|
1699
|
+
parentToolCallId?: string;
|
|
1700
|
+
toolName: string;
|
|
1701
|
+
};
|
|
1697
1702
|
turnIndex?: number;
|
|
1698
1703
|
type: "turn_start";
|
|
1699
1704
|
}) | ({
|
|
@@ -1728,12 +1733,61 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1728
1733
|
role: "user" | "assistant" | "system";
|
|
1729
1734
|
seq: number;
|
|
1730
1735
|
stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
|
|
1736
|
+
subagent?: {
|
|
1737
|
+
agentName?: string;
|
|
1738
|
+
parentToolCallId?: string;
|
|
1739
|
+
toolName: string;
|
|
1740
|
+
};
|
|
1731
1741
|
tokens?: {
|
|
1732
1742
|
input: number;
|
|
1733
1743
|
output: number;
|
|
1734
1744
|
};
|
|
1735
1745
|
type: "turn_complete";
|
|
1736
1746
|
}) | {
|
|
1747
|
+
executionId: string;
|
|
1748
|
+
id: string;
|
|
1749
|
+
iteration?: number;
|
|
1750
|
+
model?: string;
|
|
1751
|
+
ordinal: number;
|
|
1752
|
+
provider?: string;
|
|
1753
|
+
seq: number;
|
|
1754
|
+
startedAt?: string;
|
|
1755
|
+
stepId?: string;
|
|
1756
|
+
subagent?: {
|
|
1757
|
+
agentName?: string;
|
|
1758
|
+
parentToolCallId?: string;
|
|
1759
|
+
toolName: string;
|
|
1760
|
+
};
|
|
1761
|
+
turnId?: string;
|
|
1762
|
+
type: "model_call_start";
|
|
1763
|
+
} | {
|
|
1764
|
+
completedAt?: string;
|
|
1765
|
+
cost?: number;
|
|
1766
|
+
durationMs?: number;
|
|
1767
|
+
executionId: string;
|
|
1768
|
+
finishReason?: string;
|
|
1769
|
+
id: string;
|
|
1770
|
+
iteration?: number;
|
|
1771
|
+
model?: string;
|
|
1772
|
+
ordinal: number;
|
|
1773
|
+
provider?: string;
|
|
1774
|
+
responseModel?: string;
|
|
1775
|
+
seq: number;
|
|
1776
|
+
subagent?: {
|
|
1777
|
+
agentName?: string;
|
|
1778
|
+
parentToolCallId?: string;
|
|
1779
|
+
toolName: string;
|
|
1780
|
+
};
|
|
1781
|
+
success?: boolean;
|
|
1782
|
+
tokens?: {
|
|
1783
|
+
cacheRead?: number;
|
|
1784
|
+
cacheWrite?: number;
|
|
1785
|
+
input: number;
|
|
1786
|
+
output: number;
|
|
1787
|
+
};
|
|
1788
|
+
turnId?: string;
|
|
1789
|
+
type: "model_call_complete";
|
|
1790
|
+
} | {
|
|
1737
1791
|
executionId: string;
|
|
1738
1792
|
id: string;
|
|
1739
1793
|
index?: number;
|
|
@@ -1742,6 +1796,11 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1742
1796
|
seq: number;
|
|
1743
1797
|
startedAt?: string;
|
|
1744
1798
|
stepType?: string;
|
|
1799
|
+
subagent?: {
|
|
1800
|
+
agentName?: string;
|
|
1801
|
+
parentToolCallId?: string;
|
|
1802
|
+
toolName: string;
|
|
1803
|
+
};
|
|
1745
1804
|
totalSteps?: number;
|
|
1746
1805
|
type: "step_start";
|
|
1747
1806
|
} | ({
|
|
@@ -1769,6 +1828,11 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1769
1828
|
seq: number;
|
|
1770
1829
|
stepType?: string;
|
|
1771
1830
|
stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
|
|
1831
|
+
subagent?: {
|
|
1832
|
+
agentName?: string;
|
|
1833
|
+
parentToolCallId?: string;
|
|
1834
|
+
toolName: string;
|
|
1835
|
+
};
|
|
1772
1836
|
success?: boolean;
|
|
1773
1837
|
tokensUsed?: number;
|
|
1774
1838
|
type: "step_complete";
|
|
@@ -1791,6 +1855,11 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1791
1855
|
role?: "user" | "assistant" | "system";
|
|
1792
1856
|
seq: number;
|
|
1793
1857
|
stepId?: string;
|
|
1858
|
+
subagent?: {
|
|
1859
|
+
agentName?: string;
|
|
1860
|
+
parentToolCallId?: string;
|
|
1861
|
+
toolName: string;
|
|
1862
|
+
};
|
|
1794
1863
|
turnId?: string;
|
|
1795
1864
|
type: "text_start";
|
|
1796
1865
|
}) | {
|
|
@@ -1798,11 +1867,21 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1798
1867
|
executionId: string;
|
|
1799
1868
|
id: string;
|
|
1800
1869
|
seq: number;
|
|
1870
|
+
subagent?: {
|
|
1871
|
+
agentName?: string;
|
|
1872
|
+
parentToolCallId?: string;
|
|
1873
|
+
toolName: string;
|
|
1874
|
+
};
|
|
1801
1875
|
type: "text_delta";
|
|
1802
1876
|
} | {
|
|
1803
1877
|
executionId: string;
|
|
1804
1878
|
id: string;
|
|
1805
1879
|
seq: number;
|
|
1880
|
+
subagent?: {
|
|
1881
|
+
agentName?: string;
|
|
1882
|
+
parentToolCallId?: string;
|
|
1883
|
+
toolName: string;
|
|
1884
|
+
};
|
|
1806
1885
|
text?: string;
|
|
1807
1886
|
type: "text_complete";
|
|
1808
1887
|
} | ({
|
|
@@ -1811,18 +1890,33 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1811
1890
|
parentToolCallId?: string;
|
|
1812
1891
|
scope?: "turn" | "loop";
|
|
1813
1892
|
seq: number;
|
|
1893
|
+
subagent?: {
|
|
1894
|
+
agentName?: string;
|
|
1895
|
+
parentToolCallId?: string;
|
|
1896
|
+
toolName: string;
|
|
1897
|
+
};
|
|
1814
1898
|
type: "reasoning_start";
|
|
1815
1899
|
}) | {
|
|
1816
1900
|
delta: string;
|
|
1817
1901
|
executionId: string;
|
|
1818
1902
|
id: string;
|
|
1819
1903
|
seq: number;
|
|
1904
|
+
subagent?: {
|
|
1905
|
+
agentName?: string;
|
|
1906
|
+
parentToolCallId?: string;
|
|
1907
|
+
toolName: string;
|
|
1908
|
+
};
|
|
1820
1909
|
type: "reasoning_delta";
|
|
1821
1910
|
} | ({
|
|
1822
1911
|
executionId: string;
|
|
1823
1912
|
id: string;
|
|
1824
1913
|
scope?: "turn" | "loop";
|
|
1825
1914
|
seq: number;
|
|
1915
|
+
subagent?: {
|
|
1916
|
+
agentName?: string;
|
|
1917
|
+
parentToolCallId?: string;
|
|
1918
|
+
toolName: string;
|
|
1919
|
+
};
|
|
1826
1920
|
text?: string;
|
|
1827
1921
|
type: "reasoning_complete";
|
|
1828
1922
|
}) | ({
|
|
@@ -1915,6 +2009,11 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1915
2009
|
seq: number;
|
|
1916
2010
|
startedAt?: string;
|
|
1917
2011
|
stepId?: string;
|
|
2012
|
+
subagent?: {
|
|
2013
|
+
agentName?: string;
|
|
2014
|
+
parentToolCallId?: string;
|
|
2015
|
+
toolName: string;
|
|
2016
|
+
};
|
|
1918
2017
|
toolCallId: string;
|
|
1919
2018
|
toolName: string;
|
|
1920
2019
|
toolType: string;
|
|
@@ -1923,6 +2022,11 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1923
2022
|
delta: string;
|
|
1924
2023
|
executionId: string;
|
|
1925
2024
|
seq: number;
|
|
2025
|
+
subagent?: {
|
|
2026
|
+
agentName?: string;
|
|
2027
|
+
parentToolCallId?: string;
|
|
2028
|
+
toolName: string;
|
|
2029
|
+
};
|
|
1926
2030
|
toolCallId: string;
|
|
1927
2031
|
type: "tool_input_delta";
|
|
1928
2032
|
} | {
|
|
@@ -1930,6 +2034,11 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1930
2034
|
hiddenParameterNames?: Array<string>;
|
|
1931
2035
|
parameters: Record<string, unknown>;
|
|
1932
2036
|
seq: number;
|
|
2037
|
+
subagent?: {
|
|
2038
|
+
agentName?: string;
|
|
2039
|
+
parentToolCallId?: string;
|
|
2040
|
+
toolName: string;
|
|
2041
|
+
};
|
|
1933
2042
|
toolCallId: string;
|
|
1934
2043
|
toolName?: string;
|
|
1935
2044
|
type: "tool_input_complete";
|
|
@@ -1947,6 +2056,11 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
1947
2056
|
result?: unknown;
|
|
1948
2057
|
seq: number;
|
|
1949
2058
|
stepId?: string;
|
|
2059
|
+
subagent?: {
|
|
2060
|
+
agentName?: string;
|
|
2061
|
+
parentToolCallId?: string;
|
|
2062
|
+
toolName: string;
|
|
2063
|
+
};
|
|
1950
2064
|
success: boolean;
|
|
1951
2065
|
toolCallId: string;
|
|
1952
2066
|
toolCost?: number;
|
|
@@ -2026,6 +2140,19 @@ type RuntypeExecutionStreamEvent = ({
|
|
|
2026
2140
|
recoverable?: boolean;
|
|
2027
2141
|
seq: number;
|
|
2028
2142
|
type: "error";
|
|
2143
|
+
}) | ({
|
|
2144
|
+
epoch: number;
|
|
2145
|
+
executionId: string;
|
|
2146
|
+
kind: "compaction";
|
|
2147
|
+
outcome?: "ok" | "failed" | "gap" | "skipped";
|
|
2148
|
+
phase: "start" | "complete";
|
|
2149
|
+
reason: "threshold" | "overflow" | "manual" | "surface_policy" | "provider_mismatch";
|
|
2150
|
+
seq: number;
|
|
2151
|
+
strategy: "provider_native" | "summary";
|
|
2152
|
+
tier: number;
|
|
2153
|
+
tokensAfter?: number;
|
|
2154
|
+
tokensBefore?: number;
|
|
2155
|
+
type: "context_notice";
|
|
2029
2156
|
}) | {
|
|
2030
2157
|
executionId: string;
|
|
2031
2158
|
seq: number;
|
|
@@ -3085,15 +3212,15 @@ type AgentMessageMetadata = {
|
|
|
3085
3212
|
*/
|
|
3086
3213
|
parentStepId?: string;
|
|
3087
3214
|
/**
|
|
3088
|
-
* Set to `true` on a tool-variant message produced from
|
|
3215
|
+
* Set to `true` on a tool-variant message produced from an `await`
|
|
3089
3216
|
* event (`awaitReason: "local_tool_required"`). Signals to UI code that
|
|
3090
3217
|
* the tool call is a LOCAL tool and the server is paused waiting for a
|
|
3091
3218
|
* `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
|
|
3092
3219
|
*/
|
|
3093
3220
|
awaitingLocalTool?: boolean;
|
|
3094
3221
|
/**
|
|
3095
|
-
* The provider per-call id (`toolu_…`) carried on the `
|
|
3096
|
-
*
|
|
3222
|
+
* The provider per-call id (`toolu_…`) carried on the `await`
|
|
3223
|
+
* event for a LOCAL tool (core#3878). Present only when the
|
|
3097
3224
|
* server emits it. Two PARALLEL calls to the same tool in one turn share a
|
|
3098
3225
|
* `toolName` (and a collapsed `toolId`) but get DISTINCT `webMcpToolCallId`s,
|
|
3099
3226
|
* so this is the key the widget batches a single `/resume` on: preferred
|
|
@@ -5243,7 +5370,7 @@ type EventStreamConfig = {
|
|
|
5243
5370
|
/**
|
|
5244
5371
|
* Custom badge color mappings by event type prefix or exact type.
|
|
5245
5372
|
* Keys are matched as exact match first, then prefix match (keys ending with "_").
|
|
5246
|
-
* @example { "
|
|
5373
|
+
* @example { "execution_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
|
|
5247
5374
|
*/
|
|
5248
5375
|
badgeColors?: Record<string, EventStreamBadgeColor>;
|
|
5249
5376
|
/**
|
|
@@ -6664,9 +6791,13 @@ interface VoiceProvider {
|
|
|
6664
6791
|
* `isFinal=false` is a live interim update (user partials, or assistant deltas
|
|
6665
6792
|
* on providers that stream them); `isFinal=true` finalizes that role's text.
|
|
6666
6793
|
* On the realtime `runtype` path, interim updates fire for the `user` only and
|
|
6667
|
-
* the `assistant` arrives as a single final.
|
|
6794
|
+
* the `assistant` arrives as a single final. Providers with overlapping turns
|
|
6795
|
+
* must include the same turnId on user and assistant finals; without IDs,
|
|
6796
|
+
* providers must discard cancelled output before emitting the next user final.
|
|
6668
6797
|
*/
|
|
6669
|
-
onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean
|
|
6798
|
+
onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean, metadata?: {
|
|
6799
|
+
turnId?: string;
|
|
6800
|
+
}) => void): void;
|
|
6670
6801
|
/** Register a callback for per-turn latency metrics (realtime path). */
|
|
6671
6802
|
onMetrics?(callback: (metrics: VoiceMetrics) => void): void;
|
|
6672
6803
|
/**
|
|
@@ -8979,16 +9110,16 @@ type AgentWidgetConfig = {
|
|
|
8979
9110
|
*
|
|
8980
9111
|
* @example
|
|
8981
9112
|
* ```typescript
|
|
8982
|
-
* // For Runtype
|
|
9113
|
+
* // For a custom backend (Runtype unified events are handled natively)
|
|
8983
9114
|
* config: {
|
|
8984
9115
|
* parseSSEEvent: (data) => {
|
|
8985
|
-
* if (
|
|
8986
|
-
* return { text: data.
|
|
9116
|
+
* if (data.type === 'token' && typeof data.value === 'string') {
|
|
9117
|
+
* return { text: data.value };
|
|
8987
9118
|
* }
|
|
8988
|
-
* if (data.type === '
|
|
9119
|
+
* if (data.type === 'done') {
|
|
8989
9120
|
* return { done: true };
|
|
8990
9121
|
* }
|
|
8991
|
-
* if (data.type === '
|
|
9122
|
+
* if (data.type === 'failure') {
|
|
8992
9123
|
* return { error: data.error };
|
|
8993
9124
|
* }
|
|
8994
9125
|
* return null; // Ignore other events
|
|
@@ -9179,7 +9310,7 @@ type AgentWidgetReasoning = {
|
|
|
9179
9310
|
/**
|
|
9180
9311
|
* Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
|
|
9181
9312
|
* thinking; `"loop"` is a cross-iteration agent reflection (the fold that
|
|
9182
|
-
* replaced the legacy `agent_reflection` event).
|
|
9313
|
+
* replaced the legacy `agent_reflection` event). Optional when the stream does not specify a scope.
|
|
9183
9314
|
*/
|
|
9184
9315
|
scope?: "turn" | "loop";
|
|
9185
9316
|
startedAt?: number;
|
|
@@ -9193,6 +9324,9 @@ type AgentWidgetToolCall = {
|
|
|
9193
9324
|
args?: unknown;
|
|
9194
9325
|
chunks?: string[];
|
|
9195
9326
|
result?: unknown;
|
|
9327
|
+
/** Whether the tool succeeded; failure does not necessarily end the execution. */
|
|
9328
|
+
success?: boolean;
|
|
9329
|
+
error?: string;
|
|
9196
9330
|
duration?: number;
|
|
9197
9331
|
startedAt?: number;
|
|
9198
9332
|
completedAt?: number;
|
|
@@ -9223,7 +9357,7 @@ type AgentWidgetApproval = {
|
|
|
9223
9357
|
type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
|
|
9224
9358
|
/**
|
|
9225
9359
|
* Per-turn / per-step stop reason emitted by the runtime on
|
|
9226
|
-
* `
|
|
9360
|
+
* `turn_complete` and `step_complete` SSE events. The vocabulary is
|
|
9227
9361
|
* owned by the upstream Runtype API: do not extend without coordination.
|
|
9228
9362
|
*
|
|
9229
9363
|
* - `end_turn`: natural completion (no affordance needed)
|
|
@@ -9354,7 +9488,7 @@ type AgentWidgetMessage = {
|
|
|
9354
9488
|
*/
|
|
9355
9489
|
agentMetadata?: AgentMessageMetadata;
|
|
9356
9490
|
/**
|
|
9357
|
-
* Per-turn stop reason reported by the runtime on `
|
|
9491
|
+
* Per-turn stop reason reported by the runtime on `turn_complete`
|
|
9358
9492
|
* (agent-loop path) or the last `step_complete` for a prompt step
|
|
9359
9493
|
* (dispatch / flow path). Absent when the API did not report a value.
|
|
9360
9494
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var u=(t,e)=>{let r=document.createElement(t);return e&&(r.className=e),r};var me=[["path",{d:"M20 6 9 17l-5-5"}]];var Te=[["path",{d:"m6 9 6 6 6-6"}]];var Ae=[["path",{d:"m9 18 6-6-6-6"}]];var xe=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var ce=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}]];var Pe=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var he=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var I=(t,e=24,r="currentColor",o=2)=>{if(!Array.isArray(t))return null;let a=document.createElementNS("http://www.w3.org/2000/svg","svg");return a.setAttribute("width",String(e)),a.setAttribute("height",String(e)),a.setAttribute("viewBox","0 0 24 24"),a.setAttribute("fill","none"),a.setAttribute("stroke",r),a.setAttribute("stroke-width",String(o)),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),a.setAttribute("aria-hidden","true"),t.forEach(f=>{if(!Array.isArray(f)||f.length<2)return;let n=f[0],p=f[1];if(!p)return;let x=document.createElementNS("http://www.w3.org/2000/svg",n);Object.entries(p).forEach(([C,v])=>{C!=="stroke"&&x.setAttribute(C,String(v))}),a.appendChild(x)}),a};function Ze(t=!0){let e=t;return{isFollowing:()=>e,pause:()=>e?(e=!1,!0):!1,resume:()=>e?!1:(e=!0,!0)}}function dt(t){return Math.max(0,t.scrollHeight-t.clientHeight)}function $e(t,e){return dt(t)-t.scrollTop<=e}function Je(t){let{following:e,currentScrollTop:r,lastScrollTop:o,nearBottom:a,userScrollThreshold:f,isAutoScrolling:n=!1,pauseOnUpwardScroll:p=!1,pauseWhenAwayFromBottom:x=!0,resumeRequiresDownwardScroll:C=!1}=t,v=r-o;return n||Math.abs(v)<f?{action:"none",delta:v,nextLastScrollTop:r}:!e&&a&&(!C||v>0)?{action:"resume",delta:v,nextLastScrollTop:r}:e&&p&&v<0?{action:"pause",delta:v,nextLastScrollTop:r}:e&&x&&!a?{action:"pause",delta:v,nextLastScrollTop:r}:{action:"none",delta:v,nextLastScrollTop:r}}function je(t){let{following:e,deltaY:r,nearBottom:o=!1,resumeWhenNearBottom:a=!1}=t;return e&&r<0?"pause":!e&&a&&r>0&&o?"resume":"none"}function te(t,e){e&&e.split(/\s+/).forEach(r=>r&&t.classList.add(r))}var Be={flow_:{bg:"var(--persona-event-badge-flow-bg, #dcfce7)",text:"var(--persona-event-badge-flow-fg, #15803d)"},step_:{bg:"var(--persona-event-badge-step-bg, #f5f5f5)",text:"var(--persona-event-badge-step-fg, #0a0a0a)"},reasoning_:{bg:"var(--persona-event-badge-reasoning-bg, #fef9c3)",text:"var(--persona-event-badge-reasoning-fg, #a16207)"},tool_:{bg:"var(--persona-event-badge-tool-bg, #f3e8ff)",text:"var(--persona-event-badge-tool-fg, #6b21a8)"},agent_:{bg:"var(--persona-event-badge-agent-bg, #ccfbf1)",text:"var(--persona-event-badge-agent-fg, #115e59)"},error:{bg:"var(--persona-event-badge-error-bg, #fee2e2)",text:"var(--persona-event-badge-error-fg, #b91c1c)"}};Be.execution_error=Be.error;var pt={bg:"var(--persona-event-badge-default-bg, #f3f4f6)",text:"var(--persona-event-badge-default-fg, #4b5563)"},it=["flowName","stepName","reasoningText","text","name","tool","toolName"],mt=100;function Qe(t,e){if(e[t])return e[t];for(let r of Object.keys(e))if(r.endsWith("_")&&t.startsWith(r))return e[r]}function xt(t,e){return(e&&Qe(t,e))??Qe(t,Be)??pt}function ct(t){return/^#[0-9a-fA-F]{6}$/.test(t)?`${t}50`:`color-mix(in srgb, ${t} 31%, transparent)`}function ht(t,e){return`+${((t-e)/1e3).toFixed(3)}s`}function gt(t){let e=new Date(t),r=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0"),f=String(e.getMilliseconds()).padStart(3,"0");return`${r}:${o}:${a}.${f}`}function Ct(t,e){try{let r=JSON.parse(t);if(typeof r!="object"||r===null)return null;for(let o of e){let a=o.split("."),f=r;for(let n of a)if(f&&typeof f=="object"&&f!==null)f=f[n];else{f=void 0;break}if(typeof f=="string"&&f.trim())return f.trim()}}catch{}return null}function St(t){return navigator.clipboard?.writeText?navigator.clipboard.writeText(t):new Promise(e=>{let r=document.createElement("textarea");r.value=t,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r),e()})}function wt(t){let e;try{e=JSON.parse(t.payload)}catch{e=t.payload}return JSON.stringify({type:t.type,timestamp:new Date(t.timestamp).toISOString(),payload:e},null,2)}function bt(t){return t.tokensPerSecond===void 0||!Number.isFinite(t.tokensPerSecond)?"-- tok/s":`${t.tokensPerSecond.toFixed(1)} tok/s`}function yt(t){let e=[];return t.outputTokens!==void 0&&e.push(`${t.outputTokens.toLocaleString()} tok`),t.durationMs!==void 0&&e.push(`${(t.durationMs/1e3).toFixed(2)}s`),t.source&&e.push(t.source),e.join(" \xB7 ")}function vt(t,e,r){let o,a;try{a=JSON.parse(t.payload),o=JSON.stringify(a,null,2)}catch{a=t.payload,o=t.payload}let f=e.find(p=>p.renderEventStreamPayload);if(f?.renderEventStreamPayload&&r){let p=f.renderEventStreamPayload({event:t,config:r,defaultRenderer:()=>n(),parsedPayload:a});if(p)return p}return n();function n(){let p=u("div","persona-bg-persona-container persona-border-t persona-border-persona-divider persona-px-3 persona-py-2 persona-ml-4 persona-mr-3 persona-mb-1 persona-rounded-b persona-overflow-auto persona-max-h-[300px]"),x=u("pre","persona-m-0 persona-whitespace-pre-wrap persona-break-all persona-text-[11px] persona-text-persona-secondary persona-font-mono");return x.textContent=o,p.appendChild(x),p}}function Me(t,e,r,o,a,f,n,p){let x=a.has(t.id),C=u("div","persona-border-b persona-border-persona-divider persona-text-xs");te(C,o.classNames?.eventRow);let v=n.find(B=>B.renderEventStreamRow);if(v?.renderEventStreamRow&&p){let B=v.renderEventStreamRow({event:t,index:e,config:p,defaultRenderer:()=>W(),isExpanded:x,onToggleExpand:()=>f(t.id)});if(B)return C.appendChild(B),C}return C.appendChild(W()),C;function W(){let B=u("div",""),H=u("div","persona-flex persona-items-center persona-gap-2 persona-px-3 persona-py-3 hover:persona-bg-persona-container persona-cursor-pointer persona-group");H.setAttribute("data-event-id",t.id);let re=u("span","persona-flex-shrink-0 persona-text-persona-muted persona-w-4 persona-text-center persona-flex persona-items-center persona-justify-center"),L=I(x?Te:Ae,"14px","currentColor",2);L&&re.appendChild(L);let O=u("span","persona-text-[11px] persona-text-persona-muted persona-whitespace-nowrap persona-flex-shrink-0 persona-font-mono persona-w-[70px]"),b=o.timestampFormat??"relative";O.textContent=b==="relative"?ht(t.timestamp,r):gt(t.timestamp);let E=null;o.showSequenceNumbers!==!1&&(E=u("span","persona-text-[11px] persona-text-persona-muted persona-font-mono persona-flex-shrink-0 persona-w-[28px] persona-text-right"),E.textContent=String(e+1));let M=xt(t.type,o.badgeColors),R=u("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded persona-text-[11px] persona-font-mono persona-font-medium persona-whitespace-nowrap persona-flex-shrink-0 persona-border");R.style.backgroundColor=M.bg,R.style.color=M.text,R.style.borderColor=ct(M.text),R.textContent=t.type;let oe=o.descriptionFields??it,Q=Ct(t.payload,oe),V=null;Q&&(V=u("span","persona-text-[11px] persona-text-persona-secondary persona-truncate persona-min-w-0"),V.textContent=Q);let k=u("div","persona-flex-1 persona-min-w-0"),T=u("button","persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-flex-shrink-0 persona-border-none persona-bg-transparent persona-p-0"),ae=I(ce,"12px","currentColor",1.5);return ae&&T.appendChild(ae),T.addEventListener("click",async Y=>{Y.stopPropagation(),await St(wt(t)),T.innerHTML="";let q=I(me,"12px","currentColor",1.5);q&&T.appendChild(q),setTimeout(()=>{T.innerHTML="";let ee=I(ce,"12px","currentColor",1.5);ee&&T.appendChild(ee)},1500)}),H.appendChild(re),H.appendChild(O),E&&H.appendChild(E),H.appendChild(R),V&&H.appendChild(V),H.appendChild(k),H.appendChild(T),B.appendChild(H),x&&B.appendChild(vt(t,n,p)),B}}function Ye(t){let{buffer:e,getFullHistory:r,onClose:o,config:a,plugins:f=[],getThroughput:n}=t,p=t.renderIconByName??(()=>null),x=a?.features?.scrollToBottom,C=x?.enabled!==!1,v=x?.iconName??"arrow-down",W=x?.label??"",B=a?.features?.eventStream??{},H=f.find(L=>L.renderEventStreamView);if(H?.renderEventStreamView&&a){let L=H.renderEventStreamView({config:a,events:e.getAll(),defaultRenderer:()=>re().element,onClose:o});if(L)return{element:L,update:()=>{},destroy:()=>{}}}return re();function re(){let L=B.classNames,O=u("div","persona-event-stream-view persona-flex persona-flex-col persona-flex-1 persona-min-h-0");te(O,L?.panel);let b=[],E="",M="",R=null,oe=[],Q={},V=0,k=Ze(),T=0,ae=0,Y=!1,q=null,ee=!1,Ee=0,Z=new Set,U=new Map,Re="",Fe="",J=null,S,g,w,F,fe=null,N=null,G=null;function be(){let s=u("div","persona-event-toolbar persona-relative persona-flex persona-flex-col persona-flex-shrink-0"),l=u("div","persona-flex persona-items-center persona-gap-2 persona-px-4 persona-py-3 persona-pb-0 persona-border-persona-divider persona-bg-persona-surface persona-overflow-hidden");if(te(l,L?.headerBar),n){N=u("div","persona-relative persona-flex persona-items-center persona-gap-1.5 persona-whitespace-nowrap"),N.style.cursor="help",fe=u("span","persona-text-[11px] persona-font-mono persona-bg-persona-container persona-text-persona-muted persona-px-2 persona-py-0.5 persona-rounded persona-border persona-border-persona-border persona-tabular-nums"),fe.textContent="-- tok/s",G=u("div","persona-absolute persona-z-50 persona-whitespace-nowrap persona-rounded persona-border persona-border-persona-border persona-bg-persona-container persona-text-persona-primary persona-text-[11px] persona-font-mono persona-px-2 persona-py-1 persona-shadow"),G.style.display="none",G.style.pointerEvents="none";let K=N,de=G,ut=()=>{if(!de.textContent)return;let Xe=K.getBoundingClientRect(),Ke=s.getBoundingClientRect();de.style.left=`${Xe.left-Ke.left}px`,de.style.top=`${Xe.bottom-Ke.top+4}px`,de.style.display="block"},nt=()=>{de.style.display="none"};N.addEventListener("mouseenter",ut),N.addEventListener("mouseleave",nt),N.appendChild(fe)}let d=u("div","persona-flex-1");S=u("select","persona-text-xs persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded persona-px-2.5 persona-py-1 persona-text-persona-primary persona-cursor-pointer");let y=u("option","");y.value="",y.textContent="All events (0)",S.appendChild(y),g=u("button","persona-inline-flex persona-items-center persona-gap-1.5 persona-rounded persona-text-xs persona-text-persona-muted hover:persona-bg-persona-container hover:persona-text-persona-primary persona-cursor-pointer persona-border persona-border-persona-border persona-bg-persona-surface persona-flex-shrink-0 persona-px-2.5 persona-py-1"),g.type="button",g.title="Copy All";let _=I(xe,"12px","currentColor",1.5);_&&g.appendChild(_);let X=u("span","persona-event-copy-all persona-text-xs");X.textContent="Copy All",g.appendChild(X),N&&l.appendChild(N),l.appendChild(d),l.appendChild(S),l.appendChild(g);let i=u("div","persona-relative persona-px-4 persona-py-2.5 persona-border-b persona-border-persona-divider persona-bg-persona-surface");te(i,L?.searchBar);let m=I(Pe,"14px","var(--persona-muted, #9ca3af)",1.5),h=u("span","persona-absolute persona-left-6 persona-top-1/2 persona--translate-y-1/2 persona-pointer-events-none persona-flex persona-items-center");m&&h.appendChild(m),w=u("input","persona-text-sm persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded-md persona-pl-8 persona-pr-3 persona-py-1 persona-w-full persona-text-persona-primary"),te(w,L?.searchInput),w.type="text",w.placeholder="Search event payloads...",F=u("button","persona-absolute persona-right-5 persona-top-1/2 persona--translate-y-1/2 persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-0 persona-leading-none"),F.type="button",F.style.display="none";let P=I(he,"12px","currentColor",2);return P&&F.appendChild(P),i.appendChild(h),i.appendChild(w),i.appendChild(F),s.appendChild(l),s.appendChild(i),G&&s.appendChild(G),s}let ye,De=f.find(s=>s.renderEventStreamToolbar);De?.renderEventStreamToolbar&&a?ye=De.renderEventStreamToolbar({config:a,defaultRenderer:()=>be(),eventCount:e.getSize(),filteredCount:0,onFilterChange:l=>{E=l,ne(),$()},onSearchChange:l=>{M=l,ne(),$()}})??be():ye=be();let se=u("div","persona-text-xs persona-text-persona-muted persona-text-center persona-py-0.5 persona-px-4 persona-bg-persona-container persona-border-b persona-border-persona-divider persona-italic persona-flex-shrink-0");se.style.display="none";function ot(){if(!n||!fe||!N)return;let s=n(),l=bt(s);fe.textContent=l;let d=yt(s);G&&(G.textContent=d,d||(G.style.display="none")),N.setAttribute("aria-label",d?`Throughput: ${l}, ${d}`:`Throughput: ${l}`)}let pe=u("div","persona-flex-1 persona-min-h-0 persona-relative"),c=u("div","persona-event-stream-list persona-overflow-y-auto persona-min-h-0");c.style.height="100%";let A=u("div","persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-transform persona--translate-x-1/2 persona-cursor-pointer persona-z-10 persona-text-xs");te(A,L?.scrollIndicator),A.style.display="none",A.setAttribute("data-persona-scroll-to-bottom-has-label",W?"true":"false");let He=p(v,"14px","currentColor",2);He&&A.appendChild(He);let le=u("span","");le.textContent=W,A.appendChild(le);let ue=u("div","persona-flex persona-items-center persona-justify-center persona-h-full persona-text-sm persona-text-persona-muted");ue.style.display="none",pe.appendChild(c),pe.appendChild(ue),pe.appendChild(A),O.setAttribute("tabindex","0"),O.appendChild(ye),O.appendChild(se),O.appendChild(pe);function at(){let s=e.getAll(),l={};for(let i of s)l[i.type]=(l[i.type]||0)+1;let d=Object.keys(l).sort(),y=d.length!==oe.length||!d.every((i,m)=>i===oe[m]),z=!y&&d.some(i=>l[i]!==Q[i]),_=s.length!==Object.values(Q).reduce((i,m)=>i+m,0);if(!y&&!z&&!_||(oe=d,Q=l,!S))return;let X=S.value;if(S.options[0].textContent=`All events (${s.length})`,y){for(;S.options.length>1;)S.remove(1);for(let i of d){let m=u("option","");m.value=i,m.textContent=`${i} (${l[i]||0})`,S.appendChild(m)}X&&d.includes(X)?S.value=X:X&&(S.value="",E="")}else for(let i=1;i<S.options.length;i++){let m=S.options[i];m.textContent=`${m.value} (${l[m.value]||0})`}}function ft(){let s=e.getAll();if(E&&(s=s.filter(l=>l.type===E)),M){let l=M.toLowerCase();s=s.filter(d=>d.type.toLowerCase().includes(l)||d.payload.toLowerCase().includes(l))}return s}function ve(){return E!==""||M!==""}function ne(){V=0,T=0,k.resume(),A.style.display="none"}function ie(s){Z.has(s)?Z.delete(s):Z.add(s),J=s;let l=c.scrollTop,d=k.isFollowing();ee=!0,k.pause(),$(),c.scrollTop=l,d&&k.resume(),ee=!1}function Oe(){return $e(c,50)}function $(){ae=Date.now(),Y=!1,ot(),at();let s=e.getEvictedCount();s>0?(se.textContent=`${s.toLocaleString()} older events truncated`,se.style.display=""):se.style.display="none",b=ft();let l=b.length,d=e.getSize()>0;l===0&&d&&ve()?(ue.textContent=M?`No events matching '${M}'`:"No events matching filter",ue.style.display="",c.style.display="none"):(ue.style.display="none",c.style.display=""),g&&(g.title=ve()?`Copy Filtered (${l})`:"Copy All"),C&&!k.isFollowing()&&l>V&&(T+=l-V,le.textContent=W?`${W}${T>0?` (${T})`:""}`:"",A.style.display=""),V=l;let y=e.getAll(),z=y.length>0?y[0].timestamp:0,_=new Set(b.map(m=>m.id));for(let m of Z)_.has(m)||Z.delete(m);let X=E!==Re||M!==Fe,i=U.size===0&&b.length>0;if(X||i||b.length===0){c.innerHTML="",U.clear();let m=document.createDocumentFragment();for(let h=0;h<b.length;h++){let P=Me(b[h],h,z,B,Z,ie,f,a);U.set(b[h].id,P),m.appendChild(P)}c.appendChild(m),Re=E,Fe=M,J=null}else{if(J!==null){let h=U.get(J);if(h&&h.parentNode===c){let P=b.findIndex(K=>K.id===J);if(P>=0){let K=Me(b[P],P,z,B,Z,ie,f,a);c.insertBefore(K,h),h.remove(),U.set(J,K)}}J=null}let m=new Set(b.map(h=>h.id));for(let[h,P]of U)m.has(h)||(P.remove(),U.delete(h));for(let h=0;h<b.length;h++){let P=b[h];if(!U.has(P.id)){let K=Me(P,h,z,B,Z,ie,f,a);U.set(P.id,K),c.appendChild(K)}}}k.isFollowing()&&(c.scrollTop=c.scrollHeight)}function st(){if(Date.now()-ae>=mt){q!==null&&(cancelAnimationFrame(q),q=null),$();return}Y||(Y=!0,q=requestAnimationFrame(()=>{q=null,$()}))}let qe=(s,l)=>{if(!g)return;g.innerHTML="";let d=I(s,"12px","currentColor",1.5);d&&g.appendChild(d);let y=u("span","persona-text-xs");y.textContent="Copy All",g.appendChild(y),setTimeout(()=>{g.innerHTML="";let z=I(xe,"12px","currentColor",1.5);z&&g.appendChild(z);let _=u("span","persona-text-xs");_.textContent="Copy All",g.appendChild(_),g.disabled=!1},l)},Ue=async()=>{if(g){g.disabled=!0;try{let s;ve()?s=b:r?(s=await r(),s.length===0&&(s=e.getAll())):s=e.getAll();let l=s.map(d=>{try{return JSON.parse(d.payload)}catch{return d.payload}});await navigator.clipboard.writeText(JSON.stringify(l,null,2)),qe(me,1500)}catch{qe(he,1500)}}},Ne=()=>{S&&(E=S.value,ne(),$())},Ie=()=>{!w||!F||(F.style.display=w.value?"":"none",R&&clearTimeout(R),R=setTimeout(()=>{M=w.value,ne(),$()},150))},ke=()=>{!w||!F||(w.value="",M="",F.style.display="none",R&&clearTimeout(R),ne(),$())},We=()=>{if(ee)return;let s=c.scrollTop,{action:l,nextLastScrollTop:d}=Je({following:k.isFollowing(),currentScrollTop:s,lastScrollTop:Ee,nearBottom:Oe(),userScrollThreshold:1,resumeRequiresDownwardScroll:!0});Ee=d,l==="resume"?(k.resume(),T=0,A.style.display="none"):l==="pause"&&(k.pause(),C&&(le.textContent=W,A.style.display=""))},Ve=s=>{let l=je({following:k.isFollowing(),deltaY:s.deltaY,nearBottom:Oe(),resumeWhenNearBottom:!0});l==="pause"?(k.pause(),C&&(le.textContent=W,A.style.display="")):l==="resume"&&(k.resume(),T=0,A.style.display="none")},Ge=()=>{C&&(c.scrollTop=c.scrollHeight,k.resume(),T=0,A.style.display="none")},ze=s=>{let l=s.target;if(!l||l.closest("button"))return;let d=l.closest("[data-event-id]");if(!d)return;let y=d.getAttribute("data-event-id");y&&ie(y)},_e=s=>{if((s.metaKey||s.ctrlKey)&&s.key==="f"){s.preventDefault(),w?.focus(),w?.select();return}s.key==="Escape"&&(w&&document.activeElement===w?(ke(),w.blur(),O.focus()):o&&o())};g&&g.addEventListener("click",Ue),S&&S.addEventListener("change",Ne),w&&w.addEventListener("input",Ie),F&&F.addEventListener("click",ke),c.addEventListener("scroll",We),c.addEventListener("wheel",Ve,{passive:!0}),c.addEventListener("click",ze),A.addEventListener("click",Ge),O.addEventListener("keydown",_e);function lt(){R&&clearTimeout(R),q!==null&&(cancelAnimationFrame(q),q=null),Y=!1,U.clear(),g&&g.removeEventListener("click",Ue),S&&S.removeEventListener("change",Ne),w&&w.removeEventListener("input",Ie),F&&F.removeEventListener("click",ke),c.removeEventListener("scroll",We),c.removeEventListener("wheel",Ve),c.removeEventListener("click",ze),A.removeEventListener("click",Ge),O.removeEventListener("keydown",_e)}return{element:O,update:st,destroy:lt}}}var ge=class{constructor(e=2e3,r=null){this.head=0;this.count=0;this.totalCaptured=0;this.eventTypesSet=new Set;this.maxSize=e,this.buffer=new Array(e),this.store=r}push(e){this.buffer[this.head]=e,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.totalCaptured++,this.eventTypesSet.add(e.type),this.store?.put(e)}getAll(){return this.count===0?[]:this.count<this.maxSize?this.buffer.slice(0,this.count):[...this.buffer.slice(this.head,this.maxSize),...this.buffer.slice(0,this.head)]}async restore(){if(!this.store)return 0;let e=await this.store.getAll();if(e.length===0)return 0;let r=e.length>this.maxSize?e.slice(e.length-this.maxSize):e;for(let o of r)this.buffer[this.head]=o,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.eventTypesSet.add(o.type);return this.totalCaptured=e.length,r.length}getAllFromStore(){return this.store?this.store.getAll():Promise.resolve(this.getAll())}getRecent(e){let r=this.getAll();return e>=r.length?r:r.slice(r.length-e)}getSize(){return this.count}getTotalCaptured(){return this.totalCaptured}getEvictedCount(){return this.totalCaptured-this.count}clear(){this.buffer=new Array(this.maxSize),this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),this.store?.clear()}destroy(){this.buffer=[],this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),this.store?.destroy()}getEventTypes(){return Array.from(this.eventTypesSet)}};var Ce=class{constructor(e="persona-event-stream",r="events"){this.db=null;this.pendingWrites=[];this.flushScheduled=!1;this.isDestroyed=!1;this.dbName=e,this.storeName=r}open(){return new Promise((e,r)=>{try{let o=indexedDB.open(this.dbName,1);o.onupgradeneeded=()=>{let a=o.result;a.objectStoreNames.contains(this.storeName)||a.createObjectStore(this.storeName,{keyPath:"id"}).createIndex("timestamp","timestamp",{unique:!1})},o.onsuccess=()=>{this.db=o.result,e()},o.onerror=()=>{r(o.error)}}catch(o){r(o)}})}put(e){!this.db||this.isDestroyed||(this.pendingWrites.push(e),this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushWrites())))}putBatch(e){if(!(!this.db||this.isDestroyed||e.length===0))try{let o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let a of e)o.put(a)}catch{}}getAll(){return new Promise((e,r)=>{if(!this.db){e([]);return}try{let n=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).index("timestamp").getAll();n.onsuccess=()=>{e(n.result)},n.onerror=()=>{r(n.error)}}catch(o){r(o)}})}getCount(){return new Promise((e,r)=>{if(!this.db){e(0);return}try{let f=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).count();f.onsuccess=()=>{e(f.result)},f.onerror=()=>{r(f.error)}}catch(o){r(o)}})}clear(){return new Promise((e,r)=>{if(!this.db){e();return}this.pendingWrites=[];try{let f=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear();f.onsuccess=()=>{e()},f.onerror=()=>{r(f.error)}}catch(o){r(o)}})}close(){this.db&&(this.db.close(),this.db=null)}destroy(){return this.isDestroyed=!0,this.pendingWrites=[],this.close(),new Promise((e,r)=>{try{let o=indexedDB.deleteDatabase(this.dbName);o.onsuccess=()=>{e()},o.onerror=()=>{r(o.error)}}catch(o){r(o)}})}flushWrites(){if(this.flushScheduled=!1,!this.db||this.isDestroyed||this.pendingWrites.length===0)return;let e=this.pendingWrites;this.pendingWrites=[];try{let o=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let a of e)o.put(a)}catch{}}};var kt=new Set(["flow_start","flow_run_start","agent_start","dispatch_start","run_start"]),Tt=new Set(["step_start","execution_start"]),At=new Set(["step_delta","step_chunk","chunk","agent_turn_delta"]),Pt=new Set(["step_complete","agent_turn_complete"]),Mt=new Set(["flow_complete","agent_complete"]),et=new Set(["step_error","flow_error","agent_error","dispatch_error","error"]),rt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),D=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,j=(t,e)=>{let r=t[e];return rt(r)?r:void 0};function Le(t){return t>0?Math.max(1,Math.ceil(t/4)):0}function Se(t,e){if(!(t<=0||e===void 0||e<250))return t/(e/1e3)}function Bt(t,e){return typeof e.type=="string"?e.type:t}function Lt(t){return typeof t.text=="string"?t.text:typeof t.delta=="string"?t.delta:typeof t.content=="string"?t.content:typeof t.chunk=="string"?t.chunk:""}function Et(t,e){return t==="step_delta"||t==="step_chunk"?e.stepType!=="tool"&&e.executionType!=="context":t!=="agent_turn_delta"?!0:(typeof e.contentType=="string"?e.contentType:typeof e.content_type=="string"?e.content_type:void 0)==="text"}function tt(t){let e=j(t,"result"),r=[j(t,"tokens"),j(t,"totalTokens"),e?j(e,"tokens"):void 0,j(t,"usage"),e?j(e,"usage"):void 0];for(let o of r){if(!o)continue;let a=D(o.output)??D(o.outputTokens)??D(o.completionTokens);if(a!==void 0)return a}return D(t.outputTokens)??D(t.completionTokens)??(e?D(e.outputTokens)??D(e.completionTokens):void 0)}function Rt(t){let e=j(t,"result");return D(t.executionTime)??D(t.executionTimeMs)??D(t.execution_time)??D(t.duration)??(e?D(e.executionTime)??D(e.executionTimeMs):void 0)}function Ft(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var we=class{constructor(e=Ft){this.metric={status:"idle"};this.run=null;this.now=e}getMetric(){let e=this.run;if(e&&this.metric.status==="running"&&e.firstDeltaAt!==void 0&&this.metric.outputTokens!==void 0){let r=this.now()-e.firstDeltaAt;return{...this.metric,durationMs:r,tokensPerSecond:Se(this.metric.outputTokens,r)}}return this.metric}reset(){this.run=null,this.metric={status:"idle"}}startRun(e){this.run={startedAt:e,visibleCharCount:0,exactOutputTokens:0},this.metric={status:"running"}}processEvent(e,r){if(!rt(r)){et.has(e)&&this.run&&(this.run=null,this.metric={status:"error"});return}let o=Bt(e,r),a=this.now();if(kt.has(o)){this.startRun(a);return}if(Tt.has(o)){this.run||this.startRun(a);return}if(At.has(o)){if(!Et(o,r))return;let f=Lt(r);if(!f)return;this.run||this.startRun(a);let n=this.run;n.firstDeltaAt??(n.firstDeltaAt=a),n.visibleCharCount+=f.length;let p=n.exactOutputTokens+Le(n.visibleCharCount),x=a-n.firstDeltaAt;this.metric={status:"running",tokensPerSecond:Se(p,x),outputTokens:p,durationMs:x,source:n.exactOutputTokens>0?"usage":"estimate"};return}if(Pt.has(o)){if(!this.run)return;let f=this.run,n=tt(r);n!==void 0&&(f.exactOutputTokens+=n,f.visibleCharCount=0);let p=f.exactOutputTokens>0,x=f.exactOutputTokens+Le(f.visibleCharCount),C=this.resolveDuration(f,r,a);this.metric={status:"running",tokensPerSecond:Se(x,C),outputTokens:x,durationMs:C,source:p?"usage":"estimate"};return}if(Mt.has(o)){if(!this.run)return;let f=this.run,n=tt(r),p=n??f.exactOutputTokens+Le(f.visibleCharCount),x=n!==void 0||f.exactOutputTokens>0?"usage":"estimate",C=this.resolveDuration(f,r,a);this.metric={status:"complete",tokensPerSecond:Se(p,C),outputTokens:p,durationMs:C,source:x},this.run=null;return}if(et.has(o)){if(!this.run)return;this.run=null,this.metric={status:"error"}}}resolveDuration(e,r,o){let a=e.firstDeltaAt!==void 0?o-e.firstDeltaAt:void 0;return a!==void 0&&a>=250?a:Rt(r)??o-e.startedAt}};export{ge as EventStreamBuffer,Ce as EventStreamStore,we as ThroughputTracker,Ye as createEventStreamView};
|
|
1
|
+
var u=(t,e)=>{let r=document.createElement(t);return e&&(r.className=e),r};var ie=[["path",{d:"M20 6 9 17l-5-5"}]];var ke=[["path",{d:"m6 9 6 6 6-6"}]];var Te=[["path",{d:"m9 18 6-6-6-6"}]];var me=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var xe=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}]];var Ae=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var ce=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var N=(t,e=24,r="currentColor",a=2)=>{if(!Array.isArray(t))return null;let o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.setAttribute("width",String(e)),o.setAttribute("height",String(e)),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none"),o.setAttribute("stroke",r),o.setAttribute("stroke-width",String(a)),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),o.setAttribute("aria-hidden","true"),t.forEach(f=>{if(!Array.isArray(f)||f.length<2)return;let n=f[0],p=f[1];if(!p)return;let x=document.createElementNS("http://www.w3.org/2000/svg",n);Object.entries(p).forEach(([C,v])=>{C!=="stroke"&&x.setAttribute(C,String(v))}),o.appendChild(x)}),o};function Ke(t=!0){let e=t;return{isFollowing:()=>e,pause:()=>e?(e=!1,!0):!1,resume:()=>e?!1:(e=!0,!0)}}function nt(t){return Math.max(0,t.scrollHeight-t.clientHeight)}function _e(t,e){return nt(t)-t.scrollTop<=e}function Ze(t){let{following:e,currentScrollTop:r,lastScrollTop:a,nearBottom:o,userScrollThreshold:f,isAutoScrolling:n=!1,pauseOnUpwardScroll:p=!1,pauseWhenAwayFromBottom:x=!0,resumeRequiresDownwardScroll:C=!1}=t,v=r-a;return n||Math.abs(v)<f?{action:"none",delta:v,nextLastScrollTop:r}:!e&&o&&(!C||v>0)?{action:"resume",delta:v,nextLastScrollTop:r}:e&&p&&v<0?{action:"pause",delta:v,nextLastScrollTop:r}:e&&x&&!o?{action:"pause",delta:v,nextLastScrollTop:r}:{action:"none",delta:v,nextLastScrollTop:r}}function $e(t){let{following:e,deltaY:r,nearBottom:a=!1,resumeWhenNearBottom:o=!1}=t;return e&&r<0?"pause":!e&&o&&r>0&&a?"resume":"none"}function ee(t,e){e&&e.split(/\s+/).forEach(r=>r&&t.classList.add(r))}var _={flow_:{bg:"var(--persona-event-badge-flow-bg, #dcfce7)",text:"var(--persona-event-badge-flow-fg, #15803d)"},step_:{bg:"var(--persona-event-badge-step-bg, #f5f5f5)",text:"var(--persona-event-badge-step-fg, #0a0a0a)"},reasoning_:{bg:"var(--persona-event-badge-reasoning-bg, #fef9c3)",text:"var(--persona-event-badge-reasoning-fg, #a16207)"},tool_:{bg:"var(--persona-event-badge-tool-bg, #f3e8ff)",text:"var(--persona-event-badge-tool-fg, #6b21a8)"},agent_:{bg:"var(--persona-event-badge-agent-bg, #ccfbf1)",text:"var(--persona-event-badge-agent-fg, #115e59)"},error:{bg:"var(--persona-event-badge-error-bg, #fee2e2)",text:"var(--persona-event-badge-error-fg, #b91c1c)"}};_.execution_error=_.error;_.execution_=_.flow_;_.turn_=_.agent_;_.text_=_.agent_;var dt={bg:"var(--persona-event-badge-default-bg, #f3f4f6)",text:"var(--persona-event-badge-default-fg, #4b5563)"},pt=["flowName","stepName","reasoningText","text","name","tool","toolName"],it=100;function Je(t,e){if(e[t])return e[t];for(let r of Object.keys(e))if(r.endsWith("_")&&t.startsWith(r))return e[r]}function mt(t,e){return(e&&Je(t,e))??Je(t,_)??dt}function xt(t){return/^#[0-9a-fA-F]{6}$/.test(t)?`${t}50`:`color-mix(in srgb, ${t} 31%, transparent)`}function ct(t,e){return`+${((t-e)/1e3).toFixed(3)}s`}function ht(t){let e=new Date(t),r=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0"),f=String(e.getMilliseconds()).padStart(3,"0");return`${r}:${a}:${o}.${f}`}function gt(t,e){try{let r=JSON.parse(t);if(typeof r!="object"||r===null)return null;for(let a of e){let o=a.split("."),f=r;for(let n of o)if(f&&typeof f=="object"&&f!==null)f=f[n];else{f=void 0;break}if(typeof f=="string"&&f.trim())return f.trim()}}catch{}return null}function Ct(t){return navigator.clipboard?.writeText?navigator.clipboard.writeText(t):new Promise(e=>{let r=document.createElement("textarea");r.value=t,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r),e()})}function St(t){let e;try{e=JSON.parse(t.payload)}catch{e=t.payload}return JSON.stringify({type:t.type,timestamp:new Date(t.timestamp).toISOString(),payload:e},null,2)}function wt(t){return t.tokensPerSecond===void 0||!Number.isFinite(t.tokensPerSecond)?"-- tok/s":`${t.tokensPerSecond.toFixed(1)} tok/s`}function bt(t){let e=[];return t.outputTokens!==void 0&&e.push(`${t.outputTokens.toLocaleString()} tok`),t.durationMs!==void 0&&e.push(`${(t.durationMs/1e3).toFixed(2)}s`),t.source&&e.push(t.source),e.join(" \xB7 ")}function yt(t,e,r){let a,o;try{o=JSON.parse(t.payload),a=JSON.stringify(o,null,2)}catch{o=t.payload,a=t.payload}let f=e.find(p=>p.renderEventStreamPayload);if(f?.renderEventStreamPayload&&r){let p=f.renderEventStreamPayload({event:t,config:r,defaultRenderer:()=>n(),parsedPayload:o});if(p)return p}return n();function n(){let p=u("div","persona-bg-persona-container persona-border-t persona-border-persona-divider persona-px-3 persona-py-2 persona-ml-4 persona-mr-3 persona-mb-1 persona-rounded-b persona-overflow-auto persona-max-h-[300px]"),x=u("pre","persona-m-0 persona-whitespace-pre-wrap persona-break-all persona-text-[11px] persona-text-persona-secondary persona-font-mono");return x.textContent=a,p.appendChild(x),p}}function Pe(t,e,r,a,o,f,n,p){let x=o.has(t.id),C=u("div","persona-border-b persona-border-persona-divider persona-text-xs");ee(C,a.classNames?.eventRow);let v=n.find(B=>B.renderEventStreamRow);if(v?.renderEventStreamRow&&p){let B=v.renderEventStreamRow({event:t,index:e,config:p,defaultRenderer:()=>I(),isExpanded:x,onToggleExpand:()=>f(t.id)});if(B)return C.appendChild(B),C}return C.appendChild(I()),C;function I(){let B=u("div",""),D=u("div","persona-flex persona-items-center persona-gap-2 persona-px-3 persona-py-3 hover:persona-bg-persona-container persona-cursor-pointer persona-group");D.setAttribute("data-event-id",t.id);let te=u("span","persona-flex-shrink-0 persona-text-persona-muted persona-w-4 persona-text-center persona-flex persona-items-center persona-justify-center"),L=N(x?ke:Te,"14px","currentColor",2);L&&te.appendChild(L);let H=u("span","persona-text-[11px] persona-text-persona-muted persona-whitespace-nowrap persona-flex-shrink-0 persona-font-mono persona-w-[70px]"),b=a.timestampFormat??"relative";H.textContent=b==="relative"?ct(t.timestamp,r):ht(t.timestamp);let F=null;a.showSequenceNumbers!==!1&&(F=u("span","persona-text-[11px] persona-text-persona-muted persona-font-mono persona-flex-shrink-0 persona-w-[28px] persona-text-right"),F.textContent=String(e+1));let M=mt(t.type,a.badgeColors),R=u("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded persona-text-[11px] persona-font-mono persona-font-medium persona-whitespace-nowrap persona-flex-shrink-0 persona-border");R.style.backgroundColor=M.bg,R.style.color=M.text,R.style.borderColor=xt(M.text),R.textContent=t.type;let re=a.descriptionFields??pt,j=gt(t.payload,re),W=null;j&&(W=u("span","persona-text-[11px] persona-text-persona-secondary persona-truncate persona-min-w-0"),W.textContent=j);let k=u("div","persona-flex-1 persona-min-w-0"),T=u("button","persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-flex-shrink-0 persona-border-none persona-bg-transparent persona-p-0"),ae=N(xe,"12px","currentColor",1.5);return ae&&T.appendChild(ae),T.addEventListener("click",async Q=>{Q.stopPropagation(),await Ct(St(t)),T.innerHTML="";let q=N(ie,"12px","currentColor",1.5);q&&T.appendChild(q),setTimeout(()=>{T.innerHTML="";let Y=N(xe,"12px","currentColor",1.5);Y&&T.appendChild(Y)},1500)}),D.appendChild(te),D.appendChild(H),F&&D.appendChild(F),D.appendChild(R),W&&D.appendChild(W),D.appendChild(k),D.appendChild(T),B.appendChild(D),x&&B.appendChild(yt(t,n,p)),B}}function je(t){let{buffer:e,getFullHistory:r,onClose:a,config:o,plugins:f=[],getThroughput:n}=t,p=t.renderIconByName??(()=>null),x=o?.features?.scrollToBottom,C=x?.enabled!==!1,v=x?.iconName??"arrow-down",I=x?.label??"",B=o?.features?.eventStream??{},D=f.find(L=>L.renderEventStreamView);if(D?.renderEventStreamView&&o){let L=D.renderEventStreamView({config:o,events:e.getAll(),defaultRenderer:()=>te().element,onClose:a});if(L)return{element:L,update:()=>{},destroy:()=>{}}}return te();function te(){let L=B.classNames,H=u("div","persona-event-stream-view persona-flex persona-flex-col persona-flex-1 persona-min-h-0");ee(H,L?.panel);let b=[],F="",M="",R=null,re=[],j={},W=0,k=Ke(),T=0,ae=0,Q=!1,q=null,Y=!1,Be=0,Z=new Set,O=new Map,Le="",Fe="",J=null,S,g,w,E,oe=null,U=null,V=null;function we(){let s=u("div","persona-event-toolbar persona-relative persona-flex persona-flex-col persona-flex-shrink-0"),l=u("div","persona-flex persona-items-center persona-gap-2 persona-px-4 persona-py-3 persona-pb-0 persona-border-persona-divider persona-bg-persona-surface persona-overflow-hidden");if(ee(l,L?.headerBar),n){U=u("div","persona-relative persona-flex persona-items-center persona-gap-1.5 persona-whitespace-nowrap"),U.style.cursor="help",oe=u("span","persona-text-[11px] persona-font-mono persona-bg-persona-container persona-text-persona-muted persona-px-2 persona-py-0.5 persona-rounded persona-border persona-border-persona-border persona-tabular-nums"),oe.textContent="-- tok/s",V=u("div","persona-absolute persona-z-50 persona-whitespace-nowrap persona-rounded persona-border persona-border-persona-border persona-bg-persona-container persona-text-persona-primary persona-text-[11px] persona-font-mono persona-px-2 persona-py-1 persona-shadow"),V.style.display="none",V.style.pointerEvents="none";let K=U,ne=V,lt=()=>{if(!ne.textContent)return;let ze=K.getBoundingClientRect(),Xe=s.getBoundingClientRect();ne.style.left=`${ze.left-Xe.left}px`,ne.style.top=`${ze.bottom-Xe.top+4}px`,ne.style.display="block"},ut=()=>{ne.style.display="none"};U.addEventListener("mouseenter",lt),U.addEventListener("mouseleave",ut),U.appendChild(oe)}let d=u("div","persona-flex-1");S=u("select","persona-text-xs persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded persona-px-2.5 persona-py-1 persona-text-persona-primary persona-cursor-pointer");let y=u("option","");y.value="",y.textContent="All events (0)",S.appendChild(y),g=u("button","persona-inline-flex persona-items-center persona-gap-1.5 persona-rounded persona-text-xs persona-text-persona-muted hover:persona-bg-persona-container hover:persona-text-persona-primary persona-cursor-pointer persona-border persona-border-persona-border persona-bg-persona-surface persona-flex-shrink-0 persona-px-2.5 persona-py-1"),g.type="button",g.title="Copy All";let z=N(me,"12px","currentColor",1.5);z&&g.appendChild(z);let X=u("span","persona-event-copy-all persona-text-xs");X.textContent="Copy All",g.appendChild(X),U&&l.appendChild(U),l.appendChild(d),l.appendChild(S),l.appendChild(g);let i=u("div","persona-relative persona-px-4 persona-py-2.5 persona-border-b persona-border-persona-divider persona-bg-persona-surface");ee(i,L?.searchBar);let m=N(Ae,"14px","var(--persona-muted, #9ca3af)",1.5),h=u("span","persona-absolute persona-left-6 persona-top-1/2 persona--translate-y-1/2 persona-pointer-events-none persona-flex persona-items-center");m&&h.appendChild(m),w=u("input","persona-text-sm persona-bg-persona-surface persona-border persona-border-persona-border persona-rounded-md persona-pl-8 persona-pr-3 persona-py-1 persona-w-full persona-text-persona-primary"),ee(w,L?.searchInput),w.type="text",w.placeholder="Search event payloads...",E=u("button","persona-absolute persona-right-5 persona-top-1/2 persona--translate-y-1/2 persona-text-persona-muted hover:persona-text-persona-primary persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-0 persona-leading-none"),E.type="button",E.style.display="none";let P=N(ce,"12px","currentColor",2);return P&&E.appendChild(P),i.appendChild(h),i.appendChild(w),i.appendChild(E),s.appendChild(l),s.appendChild(i),V&&s.appendChild(V),s}let be,Re=f.find(s=>s.renderEventStreamToolbar);Re?.renderEventStreamToolbar&&o?be=Re.renderEventStreamToolbar({config:o,defaultRenderer:()=>we(),eventCount:e.getSize(),filteredCount:0,onFilterChange:l=>{F=l,ue(),$()},onSearchChange:l=>{M=l,ue(),$()}})??we():be=we();let fe=u("div","persona-text-xs persona-text-persona-muted persona-text-center persona-py-0.5 persona-px-4 persona-bg-persona-container persona-border-b persona-border-persona-divider persona-italic persona-flex-shrink-0");fe.style.display="none";function rt(){if(!n||!oe||!U)return;let s=n(),l=wt(s);oe.textContent=l;let d=bt(s);V&&(V.textContent=d,d||(V.style.display="none")),U.setAttribute("aria-label",d?`Throughput: ${l}, ${d}`:`Throughput: ${l}`)}let de=u("div","persona-flex-1 persona-min-h-0 persona-relative"),c=u("div","persona-event-stream-list persona-overflow-y-auto persona-min-h-0");c.style.height="100%";let A=u("div","persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-transform persona--translate-x-1/2 persona-cursor-pointer persona-z-10 persona-text-xs");ee(A,L?.scrollIndicator),A.style.display="none",A.setAttribute("data-persona-scroll-to-bottom-has-label",I?"true":"false");let Ee=p(v,"14px","currentColor",2);Ee&&A.appendChild(Ee);let se=u("span","");se.textContent=I,A.appendChild(se);let le=u("div","persona-flex persona-items-center persona-justify-center persona-h-full persona-text-sm persona-text-persona-muted");le.style.display="none",de.appendChild(c),de.appendChild(le),de.appendChild(A),H.setAttribute("tabindex","0"),H.appendChild(be),H.appendChild(fe),H.appendChild(de);function at(){let s=e.getAll(),l={};for(let i of s)l[i.type]=(l[i.type]||0)+1;let d=Object.keys(l).sort(),y=d.length!==re.length||!d.every((i,m)=>i===re[m]),G=!y&&d.some(i=>l[i]!==j[i]),z=s.length!==Object.values(j).reduce((i,m)=>i+m,0);if(!y&&!G&&!z||(re=d,j=l,!S))return;let X=S.value;if(S.options[0].textContent=`All events (${s.length})`,y){for(;S.options.length>1;)S.remove(1);for(let i of d){let m=u("option","");m.value=i,m.textContent=`${i} (${l[i]||0})`,S.appendChild(m)}X&&d.includes(X)?S.value=X:X&&(S.value="",F="")}else for(let i=1;i<S.options.length;i++){let m=S.options[i];m.textContent=`${m.value} (${l[m.value]||0})`}}function ot(){let s=e.getAll();if(F&&(s=s.filter(l=>l.type===F)),M){let l=M.toLowerCase();s=s.filter(d=>d.type.toLowerCase().includes(l)||d.payload.toLowerCase().includes(l))}return s}function ye(){return F!==""||M!==""}function ue(){W=0,T=0,k.resume(),A.style.display="none"}function pe(s){Z.has(s)?Z.delete(s):Z.add(s),J=s;let l=c.scrollTop,d=k.isFollowing();Y=!0,k.pause(),$(),c.scrollTop=l,d&&k.resume(),Y=!1}function De(){return _e(c,50)}function $(){ae=Date.now(),Q=!1,rt(),at();let s=e.getEvictedCount();s>0?(fe.textContent=`${s.toLocaleString()} older events truncated`,fe.style.display=""):fe.style.display="none",b=ot();let l=b.length,d=e.getSize()>0;l===0&&d&&ye()?(le.textContent=M?`No events matching '${M}'`:"No events matching filter",le.style.display="",c.style.display="none"):(le.style.display="none",c.style.display=""),g&&(g.title=ye()?`Copy Filtered (${l})`:"Copy All"),C&&!k.isFollowing()&&l>W&&(T+=l-W,se.textContent=I?`${I}${T>0?` (${T})`:""}`:"",A.style.display=""),W=l;let y=e.getAll(),G=y.length>0?y[0].timestamp:0,z=new Set(b.map(m=>m.id));for(let m of Z)z.has(m)||Z.delete(m);let X=F!==Le||M!==Fe,i=O.size===0&&b.length>0;if(X||i||b.length===0){c.innerHTML="",O.clear();let m=document.createDocumentFragment();for(let h=0;h<b.length;h++){let P=Pe(b[h],h,G,B,Z,pe,f,o);O.set(b[h].id,P),m.appendChild(P)}c.appendChild(m),Le=F,Fe=M,J=null}else{if(J!==null){let h=O.get(J);if(h&&h.parentNode===c){let P=b.findIndex(K=>K.id===J);if(P>=0){let K=Pe(b[P],P,G,B,Z,pe,f,o);c.insertBefore(K,h),h.remove(),O.set(J,K)}}J=null}let m=new Set(b.map(h=>h.id));for(let[h,P]of O)m.has(h)||(P.remove(),O.delete(h));for(let h=0;h<b.length;h++){let P=b[h];if(!O.has(P.id)){let K=Pe(P,h,G,B,Z,pe,f,o);O.set(P.id,K),c.appendChild(K)}}}k.isFollowing()&&(c.scrollTop=c.scrollHeight)}function ft(){if(Date.now()-ae>=it){q!==null&&(cancelAnimationFrame(q),q=null),$();return}Q||(Q=!0,q=requestAnimationFrame(()=>{q=null,$()}))}let He=(s,l)=>{if(!g)return;g.innerHTML="";let d=N(s,"12px","currentColor",1.5);d&&g.appendChild(d);let y=u("span","persona-text-xs");y.textContent="Copy All",g.appendChild(y),setTimeout(()=>{g.innerHTML="";let G=N(me,"12px","currentColor",1.5);G&&g.appendChild(G);let z=u("span","persona-text-xs");z.textContent="Copy All",g.appendChild(z),g.disabled=!1},l)},qe=async()=>{if(g){g.disabled=!0;try{let s;ye()?s=b:r?(s=await r(),s.length===0&&(s=e.getAll())):s=e.getAll();let l=s.map(d=>{try{return JSON.parse(d.payload)}catch{return d.payload}});await navigator.clipboard.writeText(JSON.stringify(l,null,2)),He(ie,1500)}catch{He(ce,1500)}}},Oe=()=>{S&&(F=S.value,ue(),$())},Ue=()=>{!w||!E||(E.style.display=w.value?"":"none",R&&clearTimeout(R),R=setTimeout(()=>{M=w.value,ue(),$()},150))},ve=()=>{!w||!E||(w.value="",M="",E.style.display="none",R&&clearTimeout(R),ue(),$())},Ne=()=>{if(Y)return;let s=c.scrollTop,{action:l,nextLastScrollTop:d}=Ze({following:k.isFollowing(),currentScrollTop:s,lastScrollTop:Be,nearBottom:De(),userScrollThreshold:1,resumeRequiresDownwardScroll:!0});Be=d,l==="resume"?(k.resume(),T=0,A.style.display="none"):l==="pause"&&(k.pause(),C&&(se.textContent=I,A.style.display=""))},Ie=s=>{let l=$e({following:k.isFollowing(),deltaY:s.deltaY,nearBottom:De(),resumeWhenNearBottom:!0});l==="pause"?(k.pause(),C&&(se.textContent=I,A.style.display="")):l==="resume"&&(k.resume(),T=0,A.style.display="none")},We=()=>{C&&(c.scrollTop=c.scrollHeight,k.resume(),T=0,A.style.display="none")},Ve=s=>{let l=s.target;if(!l||l.closest("button"))return;let d=l.closest("[data-event-id]");if(!d)return;let y=d.getAttribute("data-event-id");y&&pe(y)},Ge=s=>{if((s.metaKey||s.ctrlKey)&&s.key==="f"){s.preventDefault(),w?.focus(),w?.select();return}s.key==="Escape"&&(w&&document.activeElement===w?(ve(),w.blur(),H.focus()):a&&a())};g&&g.addEventListener("click",qe),S&&S.addEventListener("change",Oe),w&&w.addEventListener("input",Ue),E&&E.addEventListener("click",ve),c.addEventListener("scroll",Ne),c.addEventListener("wheel",Ie,{passive:!0}),c.addEventListener("click",Ve),A.addEventListener("click",We),H.addEventListener("keydown",Ge);function st(){R&&clearTimeout(R),q!==null&&(cancelAnimationFrame(q),q=null),Q=!1,O.clear(),g&&g.removeEventListener("click",qe),S&&S.removeEventListener("change",Oe),w&&w.removeEventListener("input",Ue),E&&E.removeEventListener("click",ve),c.removeEventListener("scroll",Ne),c.removeEventListener("wheel",Ie),c.removeEventListener("click",Ve),A.removeEventListener("click",We),H.removeEventListener("keydown",Ge)}return{element:H,update:ft,destroy:st}}}var he=class{constructor(e=2e3,r=null){this.head=0;this.count=0;this.totalCaptured=0;this.eventTypesSet=new Set;this.maxSize=e,this.buffer=new Array(e),this.store=r}push(e){this.buffer[this.head]=e,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.totalCaptured++,this.eventTypesSet.add(e.type),this.store?.put(e)}getAll(){return this.count===0?[]:this.count<this.maxSize?this.buffer.slice(0,this.count):[...this.buffer.slice(this.head,this.maxSize),...this.buffer.slice(0,this.head)]}async restore(){if(!this.store)return 0;let e=await this.store.getAll();if(e.length===0)return 0;let r=e.length>this.maxSize?e.slice(e.length-this.maxSize):e;for(let a of r)this.buffer[this.head]=a,this.head=(this.head+1)%this.maxSize,this.count<this.maxSize&&this.count++,this.eventTypesSet.add(a.type);return this.totalCaptured=e.length,r.length}getAllFromStore(){return this.store?this.store.getAll():Promise.resolve(this.getAll())}getRecent(e){let r=this.getAll();return e>=r.length?r:r.slice(r.length-e)}getSize(){return this.count}getTotalCaptured(){return this.totalCaptured}getEvictedCount(){return this.totalCaptured-this.count}clear(){this.buffer=new Array(this.maxSize),this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),this.store?.clear()}destroy(){this.buffer=[],this.head=0,this.count=0,this.totalCaptured=0,this.eventTypesSet.clear(),this.store?.destroy()}getEventTypes(){return Array.from(this.eventTypesSet)}};var ge=class{constructor(e="persona-event-stream",r="events"){this.db=null;this.pendingWrites=[];this.flushScheduled=!1;this.isDestroyed=!1;this.dbName=e,this.storeName=r}open(){return new Promise((e,r)=>{try{let a=indexedDB.open(this.dbName,1);a.onupgradeneeded=()=>{let o=a.result;o.objectStoreNames.contains(this.storeName)||o.createObjectStore(this.storeName,{keyPath:"id"}).createIndex("timestamp","timestamp",{unique:!1})},a.onsuccess=()=>{this.db=a.result,e()},a.onerror=()=>{r(a.error)}}catch(a){r(a)}})}put(e){!this.db||this.isDestroyed||(this.pendingWrites.push(e),this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushWrites())))}putBatch(e){if(!(!this.db||this.isDestroyed||e.length===0))try{let a=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let o of e)a.put(o)}catch{}}getAll(){return new Promise((e,r)=>{if(!this.db){e([]);return}try{let n=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).index("timestamp").getAll();n.onsuccess=()=>{e(n.result)},n.onerror=()=>{r(n.error)}}catch(a){r(a)}})}getCount(){return new Promise((e,r)=>{if(!this.db){e(0);return}try{let f=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).count();f.onsuccess=()=>{e(f.result)},f.onerror=()=>{r(f.error)}}catch(a){r(a)}})}clear(){return new Promise((e,r)=>{if(!this.db){e();return}this.pendingWrites=[];try{let f=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear();f.onsuccess=()=>{e()},f.onerror=()=>{r(f.error)}}catch(a){r(a)}})}close(){this.db&&(this.db.close(),this.db=null)}destroy(){return this.isDestroyed=!0,this.pendingWrites=[],this.close(),new Promise((e,r)=>{try{let a=indexedDB.deleteDatabase(this.dbName);a.onsuccess=()=>{e()},a.onerror=()=>{r(a.error)}}catch(a){r(a)}})}flushWrites(){if(this.flushScheduled=!1,!this.db||this.isDestroyed||this.pendingWrites.length===0)return;let e=this.pendingWrites;this.pendingWrites=[];try{let a=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName);for(let o of e)a.put(o)}catch{}}};var vt=new Set(["step_start","turn_start"]),kt=new Set(["step_complete","turn_complete"]),et=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),tt=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,Qe=(t,e)=>{let r=t[e];return et(r)?r:void 0};function Me(t){return t>0?Math.max(1,Math.ceil(t/4)):0}function Ce(t,e){if(!(t<=0||e===void 0||e<250))return t/(e/1e3)}function Tt(t,e){return typeof e.type=="string"?e.type:t}function Ye(t){let e=Qe(t,"tokens")??Qe(t,"totalTokens");return e?tt(e.output):void 0}function At(t){return tt(t.durationMs)}function Pt(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var Se=class{constructor(e=Pt){this.metric={status:"idle"};this.run=null;this.now=e}getMetric(){let e=this.run;if(e&&this.metric.status==="running"&&e.firstDeltaAt!==void 0&&this.metric.outputTokens!==void 0){let r=this.now()-e.firstDeltaAt;return{...this.metric,durationMs:r,tokensPerSecond:Ce(this.metric.outputTokens,r)}}return this.metric}reset(){this.run=null,this.metric={status:"idle"}}startRun(e){this.run={startedAt:e,visibleCharCount:0,exactOutputTokens:0},this.metric={status:"running"}}processEvent(e,r){if(!et(r)){e==="execution_error"&&this.run&&(this.run=null,this.metric={status:"error"});return}let a=Tt(e,r),o=this.now();if(a==="execution_start"){this.startRun(o);return}if(vt.has(a)){this.run||this.startRun(o);return}if(a==="text_delta"){let f=typeof r.delta=="string"?r.delta:"";if(!f)return;this.run||this.startRun(o);let n=this.run;n.firstDeltaAt??(n.firstDeltaAt=o),n.visibleCharCount+=f.length;let p=n.exactOutputTokens+Me(n.visibleCharCount),x=o-n.firstDeltaAt;this.metric={status:"running",tokensPerSecond:Ce(p,x),outputTokens:p,durationMs:x,source:n.exactOutputTokens>0?"usage":"estimate"};return}if(kt.has(a)){if(!this.run)return;let f=this.run,n=Ye(r);n!==void 0&&(f.exactOutputTokens+=n,f.visibleCharCount=0);let p=f.exactOutputTokens>0,x=f.exactOutputTokens+Me(f.visibleCharCount),C=this.resolveDuration(f,r,o);this.metric={status:"running",tokensPerSecond:Ce(x,C),outputTokens:x,durationMs:C,source:p?"usage":"estimate"};return}if(a==="execution_complete"){if(!this.run)return;let f=this.run,n=Ye(r),p=n??f.exactOutputTokens+Me(f.visibleCharCount),x=n!==void 0||f.exactOutputTokens>0?"usage":"estimate",C=this.resolveDuration(f,r,o);this.metric={status:"complete",tokensPerSecond:Ce(p,C),outputTokens:p,durationMs:C,source:x},this.run=null;return}if(a==="execution_error"||a==="error"&&r.recoverable===!1){if(!this.run)return;this.run=null,this.metric={status:"error"}}}resolveDuration(e,r,a){let o=e.firstDeltaAt!==void 0?a-e.firstDeltaAt:void 0;return o!==void 0&&o>=250?o:At(r)??a-e.startedAt}};export{he as EventStreamBuffer,ge as EventStreamStore,Se as ThroughputTracker,je as createEventStreamView};
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
lucide/dist/esm/icons/check.mjs:
|