@runtypelabs/persona 4.25.0 → 4.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/dist/animations/glyph-cycle.d.cts +1 -1
  2. package/dist/animations/glyph-cycle.d.ts +1 -1
  3. package/dist/animations/{types-Db61aI9J.d.cts → types-BwKTZhg9.d.cts} +14 -0
  4. package/dist/animations/{types-Db61aI9J.d.ts → types-BwKTZhg9.d.ts} +14 -0
  5. package/dist/animations/wipe.d.cts +1 -1
  6. package/dist/animations/wipe.d.ts +1 -1
  7. package/dist/animations-extra.d.cts +14 -0
  8. package/dist/animations-extra.d.ts +14 -0
  9. package/dist/approval-ui-QAKWNFNM.js +1 -0
  10. package/dist/approval-ui.cjs +2 -2
  11. package/dist/approval-ui.d.cts +186 -8
  12. package/dist/approval-ui.d.ts +186 -8
  13. package/dist/approval-ui.js +2 -2
  14. package/dist/{artifacts-ui-IGB5YKLO.js → artifacts-ui-NJGMM27I.js} +1 -1
  15. package/dist/artifacts-ui.cjs +4 -4
  16. package/dist/artifacts-ui.d.cts +186 -8
  17. package/dist/artifacts-ui.d.ts +186 -8
  18. package/dist/artifacts-ui.js +5 -5
  19. package/dist/chunk-2ANTRKTV.js +1 -0
  20. package/dist/chunk-4HPTPUC6.js +1 -0
  21. package/dist/chunk-6V3MNEKB.js +1 -0
  22. package/dist/chunk-GKPCIQPB.js +1 -0
  23. package/dist/chunk-HGUCGM3K.js +9 -0
  24. package/dist/chunk-IO5VVUKP.js +3 -0
  25. package/dist/chunk-J4J3Y2P2.js +1 -0
  26. package/dist/chunk-K6HKIP5K.js +1 -0
  27. package/dist/chunk-K7NA7G7J.js +1 -0
  28. package/dist/chunk-MXUTS3LB.js +1 -0
  29. package/dist/chunk-PDPVORUF.js +1 -0
  30. package/dist/chunk-QRKGQPU7.js +1 -0
  31. package/dist/chunk-S6PBWE75.js +1 -0
  32. package/dist/chunk-T7QM7YMF.js +1 -0
  33. package/dist/chunk-TR2H475E.js +1 -0
  34. package/dist/chunk-UPO4GUFC.js +1 -0
  35. package/dist/chunk-ZC66NAIR.js +1 -0
  36. package/dist/client-history-GOZWBDA5.js +1 -0
  37. package/dist/client-history.js +1 -0
  38. package/dist/client-stream-42FOI3EC.js +4 -0
  39. package/dist/client-stream.js +5 -0
  40. package/dist/codegen.cjs +1 -1
  41. package/dist/codegen.js +1 -1
  42. package/dist/context-mentions-E7HJYWO6.js +161 -0
  43. package/dist/{context-mentions-inline-I2RDEBAK.js → context-mentions-inline-QVESLW55.js} +1 -1
  44. package/dist/context-mentions.cjs +7 -7
  45. package/dist/context-mentions.d.cts +186 -8
  46. package/dist/context-mentions.d.ts +186 -8
  47. package/dist/context-mentions.js +8 -8
  48. package/dist/event-stream-view-FOIJHFQO.js +1 -0
  49. package/dist/event-stream-view.cjs +1 -1
  50. package/dist/event-stream-view.d.cts +189 -31
  51. package/dist/event-stream-view.d.ts +189 -31
  52. package/dist/event-stream-view.js +1 -1
  53. package/dist/forms-ui.d.cts +227 -667
  54. package/dist/forms-ui.d.ts +227 -667
  55. package/dist/history-shell-QDQ44PSE.js +3 -0
  56. package/dist/history-shell.js +3 -0
  57. package/dist/{history-view-BD6OXLNA.js → history-view-NCFBI5GR.js} +2 -2
  58. package/dist/history-view.cjs +2 -2
  59. package/dist/history-view.d.cts +35 -1
  60. package/dist/history-view.d.ts +35 -1
  61. package/dist/history-view.js +2 -2
  62. package/dist/index.cjs +80 -74
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +233 -738
  65. package/dist/index.d.ts +233 -738
  66. package/dist/index.global.js +3 -215
  67. package/dist/index.global.js.map +1 -1
  68. package/dist/index.js +81 -75
  69. package/dist/index.js.map +1 -1
  70. package/dist/install.global.js +1 -1
  71. package/dist/install.global.js.map +1 -1
  72. package/dist/launcher.global.js +3 -67
  73. package/dist/launcher.global.js.map +1 -1
  74. package/dist/markdown-parsers.js +22 -22
  75. package/dist/runtype-tts-entry-NFBVWR7N.js +1 -0
  76. package/dist/runtype-tts.js +1 -1
  77. package/dist/session-actions-ISSKSI66.js +1 -0
  78. package/dist/session-actions.js +1 -0
  79. package/dist/session-reconnect.d.cts +186 -8
  80. package/dist/session-reconnect.d.ts +186 -8
  81. package/dist/smart-dom-reader.cjs +13 -13
  82. package/dist/smart-dom-reader.d.cts +186 -8
  83. package/dist/smart-dom-reader.d.ts +186 -8
  84. package/dist/smart-dom-reader.js +11 -11
  85. package/dist/theme-editor-preview.cjs +116 -98
  86. package/dist/theme-editor-preview.d.cts +188 -8
  87. package/dist/theme-editor-preview.d.ts +188 -8
  88. package/dist/theme-editor-preview.js +49 -54
  89. package/dist/theme-editor.cjs +2 -2
  90. package/dist/theme-editor.d.cts +187 -23
  91. package/dist/theme-editor.d.ts +187 -23
  92. package/dist/theme-editor.js +2 -2
  93. package/dist/theme-reference.d.cts +14 -0
  94. package/dist/theme-reference.d.ts +14 -0
  95. package/dist/ui-extras-entry-WAYFKVNW.js +3 -0
  96. package/dist/ui-extras.js +72 -0
  97. package/dist/voice-runtime-XLU6YK2N.js +17 -0
  98. package/dist/voice-runtime.cjs +17 -1
  99. package/dist/voice-runtime.d.cts +11656 -232
  100. package/dist/voice-runtime.d.ts +11656 -232
  101. package/dist/voice-runtime.js +17 -1
  102. package/dist/voice-worklet-player.cjs +19 -4
  103. package/dist/voice-worklet-player.d.cts +9 -10
  104. package/dist/voice-worklet-player.d.ts +9 -10
  105. package/dist/voice-worklet-player.js +19 -4
  106. package/dist/webmcp-polyfill.js +1 -1
  107. package/dist/webmcp-runtime-V6ZWW3PI.js +6 -0
  108. package/dist/webmcp-runtime.cjs +2 -2
  109. package/dist/webmcp-runtime.d.cts +1 -33
  110. package/dist/webmcp-runtime.d.ts +1 -33
  111. package/dist/webmcp-runtime.js +2 -2
  112. package/dist/widget.css +1 -1
  113. package/package.json +11 -5
  114. package/src/approval-paused-tool-settle.test.ts +325 -0
  115. package/src/client-approve.test.ts +311 -0
  116. package/src/client-history-eager.ts +9 -0
  117. package/src/client-history-loader.ts +23 -0
  118. package/src/client-history.ts +579 -0
  119. package/src/client-resume.ts +177 -0
  120. package/src/client-stream-eager.ts +12 -0
  121. package/src/client-stream-loader.ts +25 -0
  122. package/src/client-stream.ts +1880 -0
  123. package/src/client.test.ts +31 -1
  124. package/src/client.ts +293 -2607
  125. package/src/components/approval-actions.test.ts +27 -0
  126. package/src/components/approval-actions.ts +27 -3
  127. package/src/components/message-bubble.test.ts +19 -0
  128. package/src/components/message-bubble.ts +2 -0
  129. package/src/components/registry.ts +6 -6
  130. package/src/components/tool-bubble.test.ts +9 -0
  131. package/src/components/tool-bubble.ts +1 -0
  132. package/src/history-shell-bundle.test.ts +54 -0
  133. package/src/history-shell-eager.ts +12 -0
  134. package/src/history-shell-loader.ts +27 -0
  135. package/src/history-shell.ts +2362 -0
  136. package/src/history-view-loader.ts +2 -0
  137. package/src/history-view.ts +3 -0
  138. package/src/index-core.ts +6 -0
  139. package/src/index-global.ts +90 -248
  140. package/src/index.ts +13 -0
  141. package/src/install.ts +6 -4
  142. package/src/internal/runtype-history-provider.test.ts +1 -0
  143. package/src/internal/runtype-history-provider.ts +28 -13
  144. package/src/plugins/registry.ts +8 -8
  145. package/src/session-actions-chunk.test.ts +55 -0
  146. package/src/session-actions-eager.ts +11 -0
  147. package/src/session-actions-loader.ts +37 -0
  148. package/src/session-actions.ts +909 -0
  149. package/src/session-history.test.ts +3 -1
  150. package/src/session.ts +895 -1538
  151. package/src/session.voice.test.ts +1171 -5
  152. package/src/styles/widget.css +58 -0
  153. package/src/theme-editor/state.ts +91 -91
  154. package/src/types.ts +204 -5
  155. package/src/ui-ask-user-sheet.ts +382 -0
  156. package/src/ui-extras-eager.ts +10 -0
  157. package/src/ui-extras-entry.ts +9 -0
  158. package/src/ui-extras-loader.ts +26 -0
  159. package/src/ui.artifact-rail-resize.test.ts +2 -1
  160. package/src/ui.ask-user-chunk.test.ts +93 -0
  161. package/src/ui.history-chunk.test.ts +2 -1
  162. package/src/ui.history-config-provider.test.ts +2 -1
  163. package/src/ui.history-confirm-fallback.test.ts +142 -0
  164. package/src/ui.history-controller.test.ts +2 -1
  165. package/src/ui.history-lifecycle.test.ts +2 -1
  166. package/src/ui.history-render-hooks.test.ts +2 -1
  167. package/src/ui.history-shell.test.ts +2 -1
  168. package/src/ui.rail-overlay.test.ts +2 -1
  169. package/src/ui.rail-resize.test.ts +2 -1
  170. package/src/ui.rail-trigger-pending.test.ts +2 -1
  171. package/src/ui.ts +340 -2770
  172. package/src/utils/attachment-manager.ts +67 -67
  173. package/src/utils/constants.ts +3 -0
  174. package/src/utils/context-mention-controller.ts +323 -323
  175. package/src/utils/context-mention-manager.ts +40 -40
  176. package/src/utils/context-mention-orchestrator.ts +28 -0
  177. package/src/utils/event-stream-buffer.ts +50 -50
  178. package/src/utils/event-stream-store.ts +43 -43
  179. package/src/utils/throughput-tracker.ts +34 -34
  180. package/src/utils/virtual-scroller.ts +67 -67
  181. package/src/utils/visitor-store.test.ts +50 -0
  182. package/src/utils/visitor-store.ts +23 -5
  183. package/src/voice/__fixtures__/voice-wire/README.md +1 -0
  184. package/src/voice/__fixtures__/voice-wire/client/cancel.json +3 -0
  185. package/src/voice/__fixtures__/voice-wire/client/context.json +4 -0
  186. package/src/voice/__fixtures__/voice-wire/client/delegation_result.json +6 -0
  187. package/src/voice/__fixtures__/voice-wire/client/delegation_update.json +6 -0
  188. package/src/voice/__fixtures__/voice-wire/client/ping.json +3 -0
  189. package/src/voice/__fixtures__/voice-wire/client/playback_progress.json +5 -0
  190. package/src/voice/__fixtures__/voice-wire/client/start.json +3 -0
  191. package/src/voice/__fixtures__/voice-wire/server/artifact.json +11 -0
  192. package/src/voice/__fixtures__/voice-wire/server/attached.json +4 -0
  193. package/src/voice/__fixtures__/voice-wire/server/audio_clear.json +4 -0
  194. package/src/voice/__fixtures__/voice-wire/server/audio_end.json +3 -0
  195. package/src/voice/__fixtures__/voice-wire/server/delegation_cancelled.json +5 -0
  196. package/src/voice/__fixtures__/voice-wire/server/delegation_completed.json +8 -0
  197. package/src/voice/__fixtures__/voice-wire/server/delegation_started.json +15 -0
  198. package/src/voice/__fixtures__/voice-wire/server/error.json +6 -0
  199. package/src/voice/__fixtures__/voice-wire/server/metrics.json +10 -0
  200. package/src/voice/__fixtures__/voice-wire/server/pong.json +3 -0
  201. package/src/voice/__fixtures__/voice-wire/server/session_config.json +16 -0
  202. package/src/voice/__fixtures__/voice-wire/server/transcript_final.json +7 -0
  203. package/src/voice/__fixtures__/voice-wire/server/transcript_interim.json +4 -0
  204. package/src/voice/__fixtures__/voice-wire/server/transcript_partial.json +6 -0
  205. package/src/voice/__fixtures__/voice-wire/server/transcript_update.json +10 -0
  206. package/src/voice/__fixtures__/voice-wire/server/warning.json +5 -0
  207. package/src/voice/audio-playback-manager.test.ts +57 -0
  208. package/src/voice/audio-playback-manager.ts +120 -98
  209. package/src/voice/browser-voice-provider.ts +37 -37
  210. package/src/voice/fallback-speech-engine.ts +22 -16
  211. package/src/voice/keyed-voice-transcript.ts +314 -0
  212. package/src/voice/mic-state-styles.ts +182 -0
  213. package/src/voice/read-aloud-controller.ts +46 -44
  214. package/src/voice/runtype-speech-engine.ts +35 -33
  215. package/src/voice/runtype-voice-provider.ts +680 -189
  216. package/src/voice/session-voice-wiring.ts +266 -0
  217. package/src/voice/voice-delegation.test.ts +71 -0
  218. package/src/voice/voice-delegation.ts +364 -0
  219. package/src/voice/voice-turn-tracker.ts +6 -6
  220. package/src/voice/voice.test.ts +1060 -8
  221. package/src/voice/worklet-playback-engine.test.ts +81 -0
  222. package/src/voice/worklet-playback-engine.ts +21 -3
  223. package/src/voice-runtime-loader.ts +4 -1
  224. package/src/voice-runtime.ts +7 -0
  225. package/src/webmcp-runtime-entry.ts +41 -39
  226. package/dist/approval-ui-3NMYNXBD.js +0 -1
  227. package/dist/chunk-5EIIHQLQ.js +0 -1
  228. package/dist/chunk-7CO4T5KB.js +0 -1
  229. package/dist/chunk-EFJBUH5F.js +0 -1
  230. package/dist/chunk-R2TMIMDI.js +0 -3
  231. package/dist/chunk-UTVLOTWB.js +0 -9
  232. package/dist/context-mentions-45MODWOY.js +0 -161
  233. package/dist/event-stream-view-GL3ADRY2.js +0 -1
  234. package/dist/runtype-tts-entry-UJAEF7NZ.js +0 -1
  235. package/dist/voice-runtime-7DA7MJH4.js +0 -1
  236. package/dist/webmcp-runtime-JI7T4QYF.js +0 -6
@@ -0,0 +1,81 @@
1
+ // Drives the AudioWorklet processor source directly (no Web Audio): these tests
2
+ // assert what each render quantum outputs, which is where the prebuffer lives.
3
+ import { describe, it, expect } from "vitest";
4
+ import { WORKLET_SOURCE } from "./worklet-playback-engine";
5
+
6
+ type Processor = {
7
+ port: { onmessage: (e: { data: unknown }) => void; posted: unknown[] };
8
+ process(inputs: unknown, outputs: Float32Array[][]): boolean;
9
+ };
10
+
11
+ function createProcessor(waterlineSamples: number): Processor {
12
+ let ctor: (new (options: unknown) => Processor) | null = null;
13
+ class FakeAudioWorkletProcessor {
14
+ port = {
15
+ onmessage: (() => {}) as (e: { data: unknown }) => void,
16
+ posted: [] as unknown[],
17
+ postMessage(msg: unknown) {
18
+ this.posted.push(msg);
19
+ },
20
+ };
21
+ }
22
+ new Function("AudioWorkletProcessor", "registerProcessor", WORKLET_SOURCE)(
23
+ FakeAudioWorkletProcessor,
24
+ (_name: string, c: new (options: unknown) => Processor) => {
25
+ ctor = c;
26
+ },
27
+ );
28
+ return new ctor!({ processorOptions: { waterlineSamples } });
29
+ }
30
+
31
+ const QUANTUM = 128;
32
+ const send = (p: Processor, data: unknown) => p.port.onmessage({ data });
33
+ const push = (p: Processor, n: number) =>
34
+ send(p, { type: "push", samples: new Float32Array(n).fill(0.5) });
35
+ function render(p: Processor): Float32Array {
36
+ const out = new Float32Array(QUANTUM);
37
+ p.process([], [[out]]);
38
+ return out;
39
+ }
40
+ const audible = (out: Float32Array) => out.filter((v) => v !== 0).length;
41
+
42
+ describe("worklet PCM player processor", () => {
43
+ it("holds a tail below the waterline until eos when not continuous", () => {
44
+ const p = createProcessor(400);
45
+ push(p, 100);
46
+ for (let i = 0; i < 10; i++) expect(audible(render(p))).toBe(0);
47
+ send(p, { type: "eos" });
48
+ expect(audible(render(p))).toBe(100);
49
+ });
50
+
51
+ it("continuous mode releases a held tail after one waterline of quiet", () => {
52
+ const p = createProcessor(300);
53
+ send(p, { type: "continuous", enabled: true });
54
+ push(p, 100);
55
+ expect(audible(render(p))).toBe(0); // 128 quiet samples < 300
56
+ expect(audible(render(p))).toBe(0); // 256 < 300
57
+ expect(audible(render(p))).toBe(100); // 384 >= 300: tail plays
58
+ });
59
+
60
+ it("continuous mode keeps prebuffering while input keeps arriving, and stays usable", () => {
61
+ const p = createProcessor(300);
62
+ send(p, { type: "continuous", enabled: true });
63
+ push(p, 100);
64
+ render(p);
65
+ render(p);
66
+ push(p, 100); // new input restarts the quiet window
67
+ expect(audible(render(p))).toBe(0);
68
+ push(p, 200); // crosses the waterline
69
+ expect(audible(render(p))).toBe(QUANTUM);
70
+ render(p);
71
+ render(p);
72
+ expect(audible(render(p))).toBe(400 - 3 * QUANTUM); // drained; the processor waits again
73
+
74
+ push(p, 50); // the next reply's short burst still plays
75
+ render(p);
76
+ render(p);
77
+ expect(audible(render(p))).toBe(50);
78
+ // No eos was ever sent, so no drained message was posted.
79
+ expect(p.port.posted).not.toContainEqual({ type: "drained" });
80
+ });
81
+ });
@@ -28,7 +28,7 @@ const DEFAULT_PREBUFFER_MS = 150;
28
28
 
29
29
  // The worklet reads its waterline from `processorOptions.waterlineSamples`, so a
30
30
  // single registered processor serves any prebuffer size.
31
- const WORKLET_SOURCE = `
31
+ export const WORKLET_SOURCE = `
32
32
  class PersonaPcmPlayerProcessor extends AudioWorkletProcessor {
33
33
  constructor(options) {
34
34
  super()
@@ -47,9 +47,16 @@ class PersonaPcmPlayerProcessor extends AudioWorkletProcessor {
47
47
  // consumer can flip UI from loading→playing only when audio is truly audible.
48
48
  // A mid-reply underrun re-buffers (waiting=true) but must NOT re-signal.
49
49
  this.startedSignaled = false
50
+ // Continuous (speech-to-speech) streams never send eos, so a tail held below
51
+ // the waterline is released once input has been quiet for one waterline.
52
+ this.continuous = false
53
+ this.idle = 0
50
54
  this.port.onmessage = (e) => {
51
55
  const msg = e.data
52
- if (msg.type === 'push') {
56
+ if (msg.type === 'continuous') {
57
+ this.continuous = msg.enabled
58
+ } else if (msg.type === 'push') {
59
+ this.idle = 0
53
60
  this.eosSeen = false
54
61
  this.chunks.push(msg.samples)
55
62
  this.buffered += msg.samples.length
@@ -85,7 +92,15 @@ class PersonaPcmPlayerProcessor extends AudioWorkletProcessor {
85
92
  }
86
93
  process(inputs, outputs) {
87
94
  const out = outputs[0][0]
88
- if (!out || this.waiting) return true // outputs are pre-zeroed: silence
95
+ if (!out) return true
96
+ if (this.waiting) {
97
+ // outputs are pre-zeroed: silence while (re)buffering
98
+ if (!this.continuous || this.buffered === 0) return true
99
+ this.idle += out.length
100
+ if (this.idle < this.waterline) return true
101
+ this.waiting = false
102
+ this.signalStarted()
103
+ }
89
104
  let i = 0
90
105
  while (i < out.length && this.buffered > 0) {
91
106
  const chunk = this.chunks[0]
@@ -219,6 +234,9 @@ export async function createPcmStreamPlayer(
219
234
  if (samples.length === 0) return;
220
235
  node.port.postMessage({ type: "push", samples }, [samples.buffer]);
221
236
  },
237
+ setContinuousMode(enabled: boolean) {
238
+ node.port.postMessage({ type: "continuous", enabled });
239
+ },
222
240
  markStreamEnd() {
223
241
  node.port.postMessage({ type: "eos" });
224
242
  },
@@ -7,7 +7,7 @@ import { createChunkLoader } from "./utils/chunk-loader";
7
7
  */
8
8
  export type VoiceRuntimeModule = typeof import("./voice-runtime");
9
9
 
10
- const { setLoader, load } = createChunkLoader<VoiceRuntimeModule>({
10
+ const { setLoader, load, getSync } = createChunkLoader<VoiceRuntimeModule>({
11
11
  fallbackImport: () => import("@runtypelabs/persona/voice-runtime"),
12
12
  });
13
13
 
@@ -16,3 +16,6 @@ export const setVoiceRuntimeLoader = setLoader;
16
16
 
17
17
  /** Load the voice provider runtime. Memoized; retries after rejection. */
18
18
  export const loadVoiceRuntime = load;
19
+
20
+ /** Synchronous access once loaded; null before that. */
21
+ export const getVoiceRuntimeSync = getSync;
@@ -17,3 +17,10 @@ export {
17
17
  } from "./voice/voice-factory";
18
18
  export { RuntypeVoiceProvider } from "./voice/runtype-voice-provider";
19
19
  export { BrowserVoiceProvider } from "./voice/browser-voice-provider";
20
+ export { KeyedVoiceTranscript } from "./voice/keyed-voice-transcript";
21
+ export { createVoiceSessionBridge } from "./voice/voice-delegation";
22
+ // Internal: the session's provider wiring (`setupVoice` calls it once this
23
+ // chunk resolves), kept here so voice-free pages never download it.
24
+ export { wireSessionVoice } from "./voice/session-voice-wiring";
25
+ // Internal: mic-button styling for session-voice states (recording/processing/speaking).
26
+ export { createMicStateStyles } from "./voice/mic-state-styles";
@@ -56,26 +56,28 @@ const log = {
56
56
  };
57
57
 
58
58
  export class WebMcpBridge {
59
- private confirmHandler: WebMcpConfirmHandler | null;
60
- private readonly timeoutMs: number;
59
+ #confirmHandler: WebMcpConfirmHandler | null;
60
+ readonly #timeoutMs: number;
61
61
 
62
62
  /** `true` once the polyfill has been (idempotently) installed. */
63
- private installed = false;
63
+ #installed = false;
64
64
  /** Memoizes the one-shot async install so concurrent callers share it. */
65
- private readyPromise: Promise<void> | null = null;
65
+ #readyPromise: Promise<void> | null = null;
66
66
  /**
67
67
  * Warn-once latch for a present-but-incompatible `document.modelContext`
68
68
  * (some other / older WebMCP polyfill squatting the global). `getModelContext`
69
69
  * is hit on every snapshot + execute, so we log the diagnostic only once.
70
70
  */
71
- private incompatibleContextWarned = false;
71
+ #incompatibleContextWarned = false;
72
72
 
73
+ readonly #deps: WebMcpBridgeDeps;
73
74
  constructor(
74
75
  private readonly config: AgentWidgetWebMcpConfig,
75
- private readonly deps: WebMcpBridgeDeps,
76
+ deps: WebMcpBridgeDeps,
76
77
  ) {
77
- this.confirmHandler = config.onConfirm ?? null;
78
- this.timeoutMs = DEFAULT_TOOL_TIMEOUT_MS;
78
+ this.#deps = deps;
79
+ this.#confirmHandler = config.onConfirm ?? null;
80
+ this.#timeoutMs = DEFAULT_TOOL_TIMEOUT_MS;
79
81
  }
80
82
 
81
83
  /**
@@ -84,7 +86,7 @@ export class WebMcpBridge {
84
86
  * lifecycle constructs the client before the panel renders).
85
87
  */
86
88
  public setConfirmHandler(handler: WebMcpConfirmHandler | null): void {
87
- this.confirmHandler = handler;
89
+ this.#confirmHandler = handler;
88
90
  }
89
91
 
90
92
  /**
@@ -99,8 +101,8 @@ export class WebMcpBridge {
99
101
  */
100
102
  public isOperational(): boolean {
101
103
  if (this.config.enabled !== true) return false;
102
- if (!this.installed) return false;
103
- return this.getModelContext() !== null;
104
+ if (!this.#installed) return false;
105
+ return this.#getModelContext() !== null;
104
106
  }
105
107
 
106
108
  /**
@@ -111,10 +113,10 @@ export class WebMcpBridge {
111
113
  * builders in `client.ts` already `await`, so this adds no new ceremony.
112
114
  */
113
115
  public async snapshotForDispatch(): Promise<ClientToolDefinition[]> {
114
- await this.ensureReady();
116
+ await this.#ensureReady();
115
117
  if (this.config.enabled !== true) return [];
116
118
 
117
- const mc = this.getModelContext();
119
+ const mc = this.#getModelContext();
118
120
  if (!mc) return [];
119
121
 
120
122
  let infos: ModelContextToolInfo[];
@@ -124,12 +126,12 @@ export class WebMcpBridge {
124
126
  log.warn("getTools() threw: shipping an empty WebMCP snapshot.", err);
125
127
  return [];
126
128
  }
127
- this.deps.recordToolDisplayTitles(infos);
129
+ this.#deps.recordToolDisplayTitles(infos);
128
130
 
129
131
  const pageOrigin = typeof location !== "undefined" ? location.origin : "";
130
132
 
131
133
  return infos
132
- .filter((info) => this.passesClientAllowlist(info.name))
134
+ .filter((info) => this.#passesClientAllowlist(info.name))
133
135
  .map<ClientToolDefinition>((info) => {
134
136
  const annotations = pickAnnotations(info.annotations);
135
137
  const def: ClientToolDefinition = {
@@ -175,14 +177,14 @@ export class WebMcpBridge {
175
177
  args: unknown,
176
178
  signal?: AbortSignal,
177
179
  ): Promise<WebMcpToolResult> {
178
- await this.ensureReady();
180
+ await this.#ensureReady();
179
181
  if (this.config.enabled !== true) {
180
182
  return errorResult(
181
183
  "WebMCP is not enabled on this widget.",
182
184
  );
183
185
  }
184
186
 
185
- const mc = this.getModelContext();
187
+ const mc = this.#getModelContext();
186
188
  if (!mc) {
187
189
  // Distinguish "no modelContext at all" from "present but incompatible"
188
190
  // (a foreign/older polyfill squatting document.modelContext) so the
@@ -207,7 +209,7 @@ export class WebMcpBridge {
207
209
  const message = err instanceof Error ? err.message : String(err);
208
210
  return errorResult(`Failed to read WebMCP registry: ${message}`);
209
211
  }
210
- this.deps.recordToolDisplayTitles(infos);
212
+ this.#deps.recordToolDisplayTitles(infos);
211
213
  const info = infos.find((candidate) => candidate.name === bareName);
212
214
 
213
215
  if (!info) {
@@ -222,7 +224,7 @@ export class WebMcpBridge {
222
224
  // history, a server bug, or a page that re-registered a previously-hidden
223
225
  // tool. The server is the trust boundary; this is a defense-in-depth
224
226
  // convenience check to keep us symmetric with the snapshot.
225
- if (!this.passesClientAllowlist(bareName)) {
227
+ if (!this.#passesClientAllowlist(bareName)) {
226
228
  return errorResult(
227
229
  `WebMCP tool not allowed by client allowlist: ${bareName}`,
228
230
  );
@@ -236,7 +238,7 @@ export class WebMcpBridge {
236
238
 
237
239
  // Confirm-by-default gate. Every `webmcp:*` call routes through here,
238
240
  // regardless of `annotations.readOnlyHint`.
239
- const displayTitle = this.deps.getToolDisplayTitle(bareName);
241
+ const displayTitle = this.#deps.getToolDisplayTitle(bareName);
240
242
  const gateInfo: WebMcpConfirmInfo = {
241
243
  toolName: bareName,
242
244
  args,
@@ -244,7 +246,7 @@ export class WebMcpBridge {
244
246
  ...(displayTitle ? { title: displayTitle } : {}),
245
247
  reason: "gate",
246
248
  };
247
- if (!(await this.requestConfirm(gateInfo))) {
249
+ if (!(await this.#requestConfirm(gateInfo))) {
248
250
  return errorResult("User declined the tool call.");
249
251
  }
250
252
 
@@ -265,7 +267,7 @@ export class WebMcpBridge {
265
267
  const timer = setTimeout(() => {
266
268
  timedOut = true;
267
269
  controller.abort();
268
- }, this.timeoutMs);
270
+ }, this.#timeoutMs);
269
271
  const onAbort = () => controller.abort();
270
272
  if (signal) {
271
273
  if (signal.aborted) controller.abort();
@@ -280,7 +282,7 @@ export class WebMcpBridge {
280
282
  } catch (err) {
281
283
  if (timedOut) {
282
284
  return errorResult(
283
- `WebMCP tool '${bareName}' timed out after ${this.timeoutMs}ms`,
285
+ `WebMCP tool '${bareName}' timed out after ${this.#timeoutMs}ms`,
284
286
  );
285
287
  }
286
288
  if (signal?.aborted) {
@@ -305,36 +307,36 @@ export class WebMcpBridge {
305
307
  * registers tools at load before Persona's first dispatch needs the global to
306
308
  * already exist.
307
309
  */
308
- private ensureReady(): Promise<void> {
310
+ #ensureReady(): Promise<void> {
309
311
  if (this.config.enabled !== true) return Promise.resolve();
310
- if (!this.readyPromise) {
311
- this.readyPromise = this.install();
312
+ if (!this.#readyPromise) {
313
+ this.#readyPromise = this.#install();
312
314
  }
313
- return this.readyPromise;
315
+ return this.#readyPromise;
314
316
  }
315
317
 
316
- private async install(): Promise<void> {
318
+ async #install(): Promise<void> {
317
319
  try {
318
320
  // A compatible registry is already on the page (the host installed the
319
321
  // polyfill, or a native impl): initialize would no-op against it, so
320
322
  // skip loading the module entirely. Pages that register tools before
321
323
  // Persona's first dispatch always land here, because registering
322
324
  // requires `document.modelContext` to exist.
323
- if (this.getModelContext()) {
324
- this.installed = true;
325
+ if (this.#getModelContext()) {
326
+ this.#installed = true;
325
327
  return;
326
328
  }
327
- const mod = await this.deps.loadPolyfill();
329
+ const mod = await this.#deps.loadPolyfill();
328
330
  // Idempotent: no-ops if `document.modelContext` already exists (native or
329
331
  // a prior install by the host page).
330
332
  mod.initializeWebMCPPolyfill();
331
- this.installed = true;
333
+ this.#installed = true;
332
334
  } catch (err) {
333
335
  log.warn(
334
336
  "Failed to load @mcp-b/webmcp-polyfill: WebMCP consumption disabled.",
335
337
  err,
336
338
  );
337
- this.installed = false;
339
+ this.#installed = false;
338
340
  }
339
341
  }
340
342
 
@@ -342,7 +344,7 @@ export class WebMcpBridge {
342
344
  * Read the consumer surface off `document.modelContext`, returning `null`
343
345
  * when it is absent or doesn't expose the producer-preview API we rely on.
344
346
  */
345
- private getModelContext(): ModelContextCoreLike | null {
347
+ #getModelContext(): ModelContextCoreLike | null {
346
348
  if (typeof document === "undefined") return null;
347
349
  const mc = (document as Document & { modelContext?: unknown }).modelContext;
348
350
  if (!mc || typeof mc !== "object") {
@@ -362,8 +364,8 @@ export class WebMcpBridge {
362
364
  // draft) installed the global first: which `@mcp-b/webmcp-polyfill`
363
365
  // correctly declines to overwrite. Warn once so integrators understand
364
366
  // why WebMCP is inert instead of seeing a silent no-op.
365
- if (!this.incompatibleContextWarned) {
366
- this.incompatibleContextWarned = true;
367
+ if (!this.#incompatibleContextWarned) {
368
+ this.#incompatibleContextWarned = true;
367
369
  log.warn(
368
370
  "document.modelContext is present but does not expose getTools()/executeTool(): " +
369
371
  "WebMCP consumption is disabled. Another (incompatible or older) WebMCP polyfill " +
@@ -376,8 +378,8 @@ export class WebMcpBridge {
376
378
  return mc as ModelContextCoreLike;
377
379
  }
378
380
 
379
- private async requestConfirm(info: WebMcpConfirmInfo): Promise<boolean> {
380
- const handler = this.confirmHandler ?? defaultBrowserConfirmHandler;
381
+ async #requestConfirm(info: WebMcpConfirmInfo): Promise<boolean> {
382
+ const handler = this.#confirmHandler ?? defaultBrowserConfirmHandler;
381
383
  try {
382
384
  return await handler(info);
383
385
  } catch (err) {
@@ -389,7 +391,7 @@ export class WebMcpBridge {
389
391
  }
390
392
  }
391
393
 
392
- private passesClientAllowlist(toolName: string): boolean {
394
+ #passesClientAllowlist(toolName: string): boolean {
393
395
  const list = this.config.allowlist;
394
396
  if (!list || list.length === 0) return true;
395
397
  return list.some((pattern) => matchesGlob(toolName, pattern));
@@ -1 +0,0 @@
1
- import{a as E,g as I}from"./chunk-NQLDCJAP.js";import{a as C}from"./chunk-7NQ4ZTHF.js";import{b as q,c as $}from"./chunk-Q735PSZL.js";import{a}from"./chunk-76IELU7F.js";var R=()=>{},z=t=>{R=t.webMcpToolTitle},S=t=>R(t);import{ChevronDown as Y,ChevronUp as ee,ShieldAlert as te,ShieldCheck as K,ShieldX as _}from"lucide";var B=t=>{let s=(t.startsWith(E)?t.slice(E.length):t).replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_\-\s.]+/).filter(Boolean);if(s.length===0)return t;let o=s.join(" ").toLowerCase();return o.charAt(0).toUpperCase()+o.slice(1)},F=t=>t?.approval!==!1?t?.approval:void 0,X=(t,n,s)=>{let o=F(s)?.detailsDisplay??"collapsed";return n.get(t)??o==="expanded"},j=(t,n,s)=>{let o=F(s);t.setAttribute("aria-expanded",n?"true":"false");let e=t.querySelector("[data-approval-details-label]");e&&(e.textContent=n?o?.hideDetailsLabel??"Hide details":o?.showDetailsLabel??"Show details");let m=t.querySelector("[data-approval-details-chevron]");if(m){m.innerHTML="";let c=C(n?ee:Y,14,"currentColor",2);c&&m.appendChild(c)}},V=(t,n,s,o=new Map)=>{let e=n.querySelector('button[data-bubble-type="approval"]'),m=n.querySelector("[data-approval-details]");if(!e||!m)return;let c=X(t,o,s);j(e,c,s),m.style.display=c?"":"none"};var Z=(t,n,s=new Map)=>{let o=t.approval,e=n?.approval!==!1?n?.approval:void 0,m=o?.status==="pending",c=a("div",["persona-approval-bubble","persona-w-full","persona-rounded-2xl","persona-border","persona-shadow-sm","persona-overflow-hidden"].join(" "));if(c.id=`bubble-${t.id}`,c.setAttribute("data-message-id",t.id),c.style.backgroundColor=e?.backgroundColor??"var(--persona-approval-bg)",c.style.borderColor=e?.borderColor??"var(--persona-approval-border)",c.style.boxShadow=e?.shadow!==void 0?e.shadow.trim()===""?"none":e.shadow:"var(--persona-approval-shadow)",!o)return c;let h=a("div","persona-flex persona-items-start persona-gap-3 persona-px-4 persona-py-3"),i=a("div","persona-flex-shrink-0 persona-mt-0.5");i.setAttribute("data-approval-icon","true");let f=o.status==="denied"?_:o.status==="timeout"?te:K,A=o.status==="approved"?"var(--persona-feedback-success, var(--persona-palette-colors-success-600))":o.status==="denied"?"var(--persona-feedback-error, var(--persona-palette-colors-error-600))":o.status==="timeout"?"var(--persona-feedback-warning, var(--persona-palette-colors-warning-600))":e?.titleColor??"currentColor",T=C(f,20,A,2);T&&i.appendChild(T);let b=a("div","persona-flex-1 persona-min-w-0"),g=a("div","persona-flex persona-items-center persona-gap-2"),M=a("span","persona-text-sm persona-font-medium persona-text-persona-primary");if(e?.titleColor&&(M.style.color=e.titleColor),M.textContent=e?.title??"Approval Required",g.appendChild(M),!m){let p=a("span","persona-inline-flex persona-items-center persona-px-2 persona-py-0.5 persona-rounded-full persona-text-xs persona-font-medium");p.setAttribute("data-approval-status",o.status),o.status==="approved"?(p.style.backgroundColor="var(--persona-palette-colors-success-100)",p.style.color="var(--persona-palette-colors-success-700)",p.textContent="Approved"):o.status==="denied"?(p.style.backgroundColor="var(--persona-palette-colors-error-100)",p.style.color="var(--persona-palette-colors-error-700)",p.textContent="Denied"):o.status==="timeout"&&(p.style.backgroundColor="var(--persona-palette-colors-warning-100)",p.style.color="var(--persona-palette-colors-warning-700)",p.textContent="Timeout"),g.appendChild(p)}b.appendChild(g);let v=o.toolType==="webmcp"||o.toolName.startsWith(E)?S(o.toolName):void 0,P=e?.formatDescription?.({toolName:o.toolName,toolType:o.toolType,description:o.description,parameters:o.parameters,...v?{displayTitle:v}:{},...o.reason?{reason:o.reason}:{}}),D=!o.toolName,H=P||(D?o.description:`The assistant wants to use \u201C${v??B(o.toolName)}\u201D.`),x=a("p","persona-text-sm persona-mt-0.5 persona-text-persona-muted");if(x.setAttribute("data-approval-summary","true"),e?.descriptionColor&&(x.style.color=e.descriptionColor),x.textContent=H,b.appendChild(x),o.reason){let p=a("p","persona-text-sm persona-mt-1 persona-text-persona-muted");p.setAttribute("data-approval-reason","true"),e?.reasonColor?p.style.color=e.reasonColor:e?.descriptionColor&&(p.style.color=e.descriptionColor);let r=a("span","persona-font-medium");r.textContent=`${e?.reasonLabel??"Agent's stated reason:"} `,p.appendChild(r),p.appendChild(document.createTextNode(o.reason)),b.appendChild(p)}let W=e?.detailsDisplay??"collapsed",L=!!o.description&&!D,N=L||!!o.parameters;if(W!=="hidden"&&N){let p=X(t.id,s,n),r=a("button","persona-inline-flex persona-items-center persona-gap-1 persona-mt-1 persona-p-0 persona-border-none persona-bg-transparent persona-text-xs persona-font-medium persona-cursor-pointer persona-text-persona-muted");r.type="button",r.setAttribute("data-expand-header","true"),r.setAttribute("data-bubble-type","approval"),e?.descriptionColor&&(r.style.color=e.descriptionColor);let l=a("span");l.setAttribute("data-approval-details-label","true");let y=a("span","persona-inline-flex persona-items-center");y.setAttribute("data-approval-details-chevron","true"),r.append(l,y),j(r,p,n),b.appendChild(r);let u=a("div");if(u.setAttribute("data-approval-details","true"),u.style.display=p?"":"none",L){let d=a("p","persona-text-sm persona-mt-1 persona-text-persona-muted");e?.descriptionColor&&(d.style.color=e.descriptionColor),d.textContent=o.description,u.appendChild(d)}if(o.parameters){let d=a("pre","persona-mt-2 persona-text-xs persona-p-2 persona-rounded persona-overflow-x-auto persona-max-h-32 persona-bg-persona-container persona-text-persona-primary");e?.parameterBackgroundColor&&(d.style.backgroundColor=e.parameterBackgroundColor),e?.parameterTextColor&&(d.style.color=e.parameterTextColor),d.style.fontSize="0.75rem",d.style.lineHeight="1rem",d.textContent=I(o.parameters),u.appendChild(d)}b.appendChild(u)}if(m){let p=a("div","persona-flex persona-gap-2 persona-mt-2");p.setAttribute("data-approval-buttons","true");let r=a("button","persona-inline-flex persona-items-center persona-px-3 persona-py-1.5 persona-rounded-md persona-text-xs persona-font-medium persona-border-none persona-cursor-pointer");r.type="button",r.style.backgroundColor=e?.approveButtonColor??"var(--persona-approval-approve-bg)",r.style.color=e?.approveButtonTextColor??"var(--persona-button-primary-fg)",r.setAttribute("data-approval-action","approve");let l=C(K,14,e?.approveButtonTextColor??"var(--persona-button-primary-fg)",2);l&&(l.style.marginRight="4px",r.appendChild(l));let y=document.createTextNode(e?.approveLabel??"Approve");r.appendChild(y);let u=a("button","persona-inline-flex persona-items-center persona-px-3 persona-py-1.5 persona-rounded-md persona-text-xs persona-font-medium persona-cursor-pointer");u.type="button",u.style.backgroundColor=e?.denyButtonColor??"transparent",u.style.color=e?.denyButtonTextColor??"var(--persona-feedback-error, var(--persona-palette-colors-error-600))",u.style.border=`1px solid ${e?.denyButtonTextColor?e.denyButtonTextColor:"var(--persona-palette-colors-error-200)"}`,u.setAttribute("data-approval-action","deny");let d=C(_,14,e?.denyButtonTextColor??"var(--persona-feedback-error, var(--persona-palette-colors-error-600))",2);d&&(d.style.marginRight="4px",u.appendChild(d));let k=document.createTextNode(e?.denyLabel??"Deny");u.appendChild(k),p.append(r,u),b.appendChild(p)}return h.append(i,b),c.appendChild(h),c};import{Ban as oe,ChevronDown as G,ShieldCheck as ne}from"lucide";var re=()=>({keyHandlers:new Map,popovers:new Map,pendingOrder:[],latestPendingApprovalId:null}),J=(t,n)=>{let s=t.keyHandlers.get(n);s&&(document.removeEventListener("keydown",s),t.keyHandlers.delete(n));let o=t.popovers.get(n);o&&(o.destroy(),t.popovers.delete(n))},w=(t,n)=>{J(t,n);let s=t.pendingOrder.indexOf(n);s!==-1&&t.pendingOrder.splice(s,1),t.latestPendingApprovalId===n&&(t.latestPendingApprovalId=t.pendingOrder.length?t.pendingOrder[t.pendingOrder.length-1]:null)},ae=t=>t?.approval!==!1?t?.approval:void 0,se=(t,n,s)=>{let o=s?.detailsDisplay??"collapsed";return n.get(t)??o==="expanded"},U=t=>{let n=a("span","persona-approval-kbd");return n.textContent=t,n},pe=(t,n)=>{let s=a("span","persona-approval-title");n?.titleColor&&(s.style.color=n.titleColor);let e=t.toolType==="webmcp"||t.toolName.startsWith(E)?S(t.toolName):void 0,m=n?.formatDescription?.({toolName:t.toolName,toolType:t.toolType,description:t.description??"",parameters:t.parameters,...e?{displayTitle:e}:{},...t.reason?{reason:t.reason}:{}});if(m)return s.textContent=m,s;let c=e??B(t.toolName),h=t.toolType&&t.toolType!=="webmcp"?t.toolType:null;s.append("The assistant wants to use ");let i=document.createElement("strong");if(i.textContent=c,s.appendChild(i),h){s.append(" from ");let f=document.createElement("strong");f.textContent=h,s.appendChild(f)}return s},le=t=>{let n=a("div","persona-approval-resolved"),s=C(oe,15,"currentColor",2);s&&n.appendChild(s);let o=a("span","persona-approval-resolved-name");return o.textContent=t.toolName?B(t.toolName):"Tool",n.append(o,document.createTextNode(t.status==="timeout"?" timed out":" denied")),n},ie=(t,n,s,o,e,m,c,h)=>{let i=a("div","persona-approval-card persona-shadow-sm");i.id=`bubble-${s.id}`,i.setAttribute("data-message-id",s.id),i.setAttribute("data-bubble-type","approval"),e?.backgroundColor&&(i.style.background=e.backgroundColor),e?.borderColor&&(i.style.borderColor=e.borderColor),e?.shadow!==void 0&&(i.style.boxShadow=e.shadow.trim()===""?"none":e.shadow);let f=e?.detailsDisplay??"collapsed",A=!!o.description&&f!=="hidden",T=o.parameters!=null&&f!=="hidden",b=A||T,g=b&&se(s.id,n,e),M=e?.showDetailsLabel??"Show details",O=e?.hideDetailsLabel??"Hide details",v=a("button","persona-approval-head");v.type="button",b?(v.setAttribute("data-action","toggle-params"),v.setAttribute("aria-expanded",g?"true":"false"),v.setAttribute("aria-label",g?O:M)):v.setAttribute("data-static","true");let P=a("span","persona-approval-logo"),D=C(ne,16,"currentColor",2);D&&P.appendChild(D),v.appendChild(P);let H=pe(o,e);if(b){let r=a("span","persona-approval-toggle");r.setAttribute("aria-hidden","true");let l=C(G,14,"currentColor",2);l&&r.appendChild(l),H.append(" "),H.appendChild(r)}v.appendChild(H),i.appendChild(v);let x=a("div","persona-approval-body");if(b){let r=a("div","persona-approval-details");if(r.setAttribute("data-role","params"),r.hidden=!g,A){let l=a("p","persona-approval-desc");e?.descriptionColor&&(l.style.color=e.descriptionColor),l.textContent=o.description,r.appendChild(l)}if(T){let l=a("pre","persona-approval-params");e?.parameterBackgroundColor&&(l.style.background=e.parameterBackgroundColor),e?.parameterTextColor&&(l.style.color=e.parameterTextColor),l.textContent=I(o.parameters),r.appendChild(l)}x.appendChild(r)}if(o.reason){let r=a("p","persona-approval-reason");e?.reasonColor?r.style.color=e.reasonColor:e?.descriptionColor&&(r.style.color=e.descriptionColor);let l=a("span","persona-approval-reason-label");l.textContent=`${e?.reasonLabel??"Agent's stated reason:"} `,r.append(l,document.createTextNode(o.reason)),x.appendChild(r)}let W=a("div","persona-approval-actions"),L=null,N=r=>{e?.approveButtonColor&&(r.style.background=e.approveButtonColor),e?.approveButtonTextColor&&(r.style.color=e.approveButtonTextColor)},p=a("button","persona-approval-deny");if(p.type="button",p.setAttribute("data-action","deny"),e?.denyButtonColor&&(p.style.background=e.denyButtonColor),e?.denyButtonTextColor&&(p.style.color=e.denyButtonTextColor),p.append(e?.denyLabel??"Deny"),h){let r=a("div","persona-approval-split"),l=a("button","persona-approval-primary");l.type="button",l.setAttribute("data-action","always"),N(l),l.append(e?.approveLabel??"Always allow",U("\u23CE"));let y=a("button","persona-approval-caret");y.type="button",y.setAttribute("data-action","toggle-menu"),y.setAttribute("aria-label","More options"),N(y);let u=C(G,15,"currentColor",2);u&&y.appendChild(u),r.append(l,y),W.append(r,p),p.append(U("Esc"));let d=a("div","persona-approval-menu"),k=a("button","persona-approval-menu-item");k.type="button",k.append("Allow once",U("\u2318\u23CE")),d.appendChild(k),L=q({anchor:r,content:d,placement:"bottom-start",matchAnchorWidth:!0}),t.popovers.set(s.id,L),k.addEventListener("click",()=>{w(t,s.id),m()})}else{let r=a("button","persona-approval-primary persona-approval-primary--solo");r.type="button",r.setAttribute("data-action","allow"),N(r),r.append(e?.approveLabel??"Allow"),W.append(r,p)}return x.appendChild(W),i.appendChild(x),i.addEventListener("click",r=>{let l=r.target instanceof Element?r.target.closest("[data-action]"):null;if(!l)return;let y=l.getAttribute("data-action");if(y==="toggle-params"){let u=i.querySelector('[data-role="params"]');if(u){let d=u.hidden;u.hidden=!d,v.setAttribute("aria-expanded",d?"true":"false"),v.setAttribute("aria-label",d?O:M),n.set(s.id,d)}return}if(y==="toggle-menu"){L?.toggle();return}if(y==="always"){w(t,s.id),m({remember:!0});return}if(y==="allow"){w(t,s.id),m();return}if(y==="deny"){w(t,s.id),c();return}}),i},Q=(t=new Map)=>{let n=re();return{plugin:{id:"persona-built-in-approval",renderApproval:({message:e,approve:m,deny:c,config:h})=>{let i=e?.approval;if(!i)return null;let f=ae(h);if(i.status!=="pending"){if(w(n,e.id),i.status==="approved"){let b=document.createElement("div");return b.style.display="none",b}return le(i)}J(n,e.id);let A=f?.enableAlwaysAllow===!0,T=ie(n,t,e,i,f,m,c,A);if(A){n.pendingOrder.includes(e.id)||n.pendingOrder.push(e.id),n.latestPendingApprovalId=n.pendingOrder[n.pendingOrder.length-1];let b=g=>{$(g)||e.id===n.latestPendingApprovalId&&(g.key!=="Escape"&&g.key!=="Enter"||(g.preventDefault(),g.stopImmediatePropagation(),w(n,e.id),g.key==="Escape"?c():g.metaKey||g.ctrlKey?m():m({remember:!0})))};n.keyHandlers.set(e.id,b),document.addEventListener("keydown",b)}return T}},teardown:()=>{for(let e of[...n.keyHandlers.keys(),...n.popovers.keys()])w(n,e);n.latestPendingApprovalId=null}}};export{Z as createApprovalBubble,Q as createBuiltInApprovalPlugin,B as humanizeToolName,z as initApprovalUi,V as updateApprovalDetailsUI};
@@ -1 +0,0 @@
1
- var a=class{constructor(e=24e3,t={}){this.ctx=null;this.nextStartTime=0;this.activeSources=[];this.finishedCallbacks=[];this.startedCallbacks=[];this.playing=!1;this.streamEnded=!1;this.pendingCount=0;this.started=!1;this.userPaused=!1;this.pendingBuffers=[];this.pendingSamples=0;this.remainder=null;this.sampleRate=e;let i=Math.max(0,t.prebufferMs??0);this.waterlineSamples=Math.round(e*i/1e3),this.buffering=this.waterlineSamples>0}ensureContext(){if(!this.ctx){let t=typeof window<"u"?window:void 0;if(!t)throw new Error("AudioPlaybackManager requires a browser environment");let i=t.AudioContext||t.webkitAudioContext;this.ctx=new i({sampleRate:this.sampleRate})}let e=this.ctx;return e.state==="suspended"&&!this.userPaused&&e.resume(),e}enqueue(e){if(e.length===0)return;let t=e;if(this.remainder){let s=new Uint8Array(this.remainder.length+e.length);s.set(this.remainder),s.set(e,this.remainder.length),t=s,this.remainder=null}if(t.length%2!==0&&(this.remainder=new Uint8Array([t[t.length-1]]),t=t.subarray(0,t.length-1)),t.length===0)return;let i=this.pcmToFloat32(t);i.length!==0&&(this.buffering?(this.pendingBuffers.push(i),this.pendingSamples+=i.length,this.pendingSamples>=this.waterlineSamples&&this.releaseBuffer()):this.scheduleSamples(i))}markStreamEnd(){this.pendingBuffers.length>0&&this.releaseBuffer(),this.streamEnded=!0,this.checkFinished()}flush(){for(let e of this.activeSources)try{e.stop(),e.disconnect()}catch{}this.activeSources=[],this.pendingCount=0,this.nextStartTime=0,this.playing=!1,this.streamEnded=!1,this.finishedCallbacks=[],this.startedCallbacks=[],this.remainder=null,this.pendingBuffers=[],this.pendingSamples=0,this.buffering=this.waterlineSamples>0,this.started=!1}isPlaying(){return this.playing}onFinished(e){this.finishedCallbacks.push(e)}onStarted(e){this.startedCallbacks.push(e)}pause(){this.userPaused=!0,this.ctx&&this.ctx.state==="running"&&this.ctx.suspend()}resume(){this.userPaused=!1,this.ctx&&this.ctx.state==="suspended"&&this.ctx.resume()}async destroy(){this.flush(),this.ctx&&(await this.ctx.close(),this.ctx=null)}releaseBuffer(){this.buffering=!1;let e=this.pendingBuffers;this.pendingBuffers=[],this.pendingSamples=0;for(let t of e)this.scheduleSamples(t)}scheduleSamples(e){if(e.length===0)return;let t=this.ensureContext(),i=t.createBuffer(1,e.length,this.sampleRate);i.getChannelData(0).set(e);let s=t.createBufferSource();s.buffer=i,s.connect(t.destination);let n=t.currentTime;if(this.nextStartTime===0?this.nextStartTime=n:this.nextStartTime<n&&(this.nextStartTime=n,this.waterlineSamples>0&&(this.buffering=!0)),s.start(this.nextStartTime),this.nextStartTime+=i.duration,this.activeSources.push(s),this.pendingCount++,this.playing=!0,!this.started){this.started=!0;let r=this.startedCallbacks.slice();this.startedCallbacks=[];for(let h of r)h()}s.onended=()=>{let r=this.activeSources.indexOf(s);r!==-1&&this.activeSources.splice(r,1),this.pendingCount--,this.checkFinished()}}checkFinished(){if(this.streamEnded&&this.pendingCount<=0&&this.pendingBuffers.length===0){this.playing=!1,this.streamEnded=!1;let e=this.finishedCallbacks.slice();this.finishedCallbacks=[];for(let t of e)t()}}pcmToFloat32(e){let t=Math.floor(e.length/2),i=new Float32Array(t),s=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let n=0;n<t;n++){let r=s.getInt16(n*2,!0);i[n]=r/32768}return i}};export{a};
@@ -1 +0,0 @@
1
- import{a as I}from"./chunk-7NQ4ZTHF.js";import{a as f,d as z}from"./chunk-76IELU7F.js";var A=o=>{let{fallbackImport:e,resetOnSetLoader:n=!1}=o,t=null,r=null,s=null;return{setLoader:a=>{t=a,n&&(r=null,s=null)},load:()=>r?Promise.resolve(r):s||(s=(t??e)().then(d=>(r=d,d)).catch(d=>{throw s=null,d}),s),provide:a=>{r=a},getSync:()=>r}};var{setLoader:U,load:G}=A({fallbackImport:()=>import("./icons-extra-UKCDOG7Q.js")}),dt=U,F=G;var{setLoader:gt,load:$,provide:V,getSync:T}=A({fallbackImport:()=>import("./markdown-parsers-entry-NVFT3TE6.js")}),E=new Set,W=()=>{let o=[...E];E.clear();for(let e of o)try{e()}catch{}};var mt=()=>{let o=T();return o?Promise.resolve(o):$().then(e=>(W(),e))},ft=o=>T()?()=>{}:(E.add(o),()=>{E.delete(o)}),bt=o=>{V(o),W()},L=T;var X=o=>{if(!o)return;let e={},n=o;if(n.heading){let t=n.heading;e.heading=(r,s,l)=>t({type:"heading",raw:l,depth:s,text:r,tokens:[]})}if(n.code){let t=n.code;e.code=(r,s,l)=>t({type:"code",raw:"",text:r,lang:s,escaped:l})}if(n.blockquote){let t=n.blockquote;e.blockquote=r=>t({type:"blockquote",raw:"",text:r,tokens:[]})}if(n.table){let t=n.table;e.table=(r,s)=>t({type:"table",raw:"",header:[],rows:[],align:[],headerHtml:r,bodyHtml:s})}if(n.link){let t=n.link;e.link=(r,s,l)=>t({type:"link",raw:"",href:r,title:s??null,text:l,tokens:[]})}if(n.image){let t=n.image;e.image=(r,s,l)=>t({type:"image",raw:"",href:r,title:s??null,text:l})}if(n.list){let t=n.list;e.list=(r,s,l)=>t({type:"list",raw:"",ordered:s,start:l,loose:!1,items:[],itemsHtml:r})}if(n.listitem){let t=n.listitem;e.listitem=(r,s,l)=>t({type:"list_item",raw:"",task:s,checked:l,loose:!1,text:r,tokens:[]})}if(n.paragraph){let t=n.paragraph;e.paragraph=r=>t({type:"paragraph",raw:"",text:r,tokens:[]})}if(n.codespan){let t=n.codespan;e.codespan=r=>t({type:"codespan",raw:"",text:r})}if(n.strong){let t=n.strong;e.strong=r=>t({type:"strong",raw:"",text:r,tokens:[]})}if(n.em){let t=n.em;e.em=r=>t({type:"em",raw:"",text:r,tokens:[]})}if(n.del){let t=n.del;e.del=r=>t({type:"del",raw:"",text:r,tokens:[]})}if(n.html){let t=n.html;e.html=r=>t({type:"html",raw:r,text:r})}if(n.text){let t=n.text;e.text=r=>t({type:"text",raw:r,text:r})}if(n.checkbox){let t=n.checkbox;e.checkbox=r=>t({checked:r})}return n.hr&&(e.hr=n.hr),n.br&&(e.br=n.br),e},R=o=>{let e=null;return n=>{let t=L();if(!t)return P(n);if(!e){let{Marked:r}=t,s=o?.markedOptions;e=new r({gfm:s?.gfm??!0,breaks:s?.breaks??!0,pedantic:s?.pedantic,silent:s?.silent});let l=X(o?.renderer);l&&e.use({renderer:l})}return e.parse(n)}},vt=o=>o?R({markedOptions:o.options,renderer:o.renderer}):R(),kt=R();var P=o=>o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");var Y={ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","hr","div","span","ul","ol","li","dl","dt","dd","strong","em","b","i","u","s","del","ins","mark","small","sub","sup","abbr","kbd","var","samp","code","a","img","blockquote","pre","details","summary","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","input","label","select","option","textarea","button"],ALLOWED_ATTR:["href","src","alt","title","target","rel","loading","width","height","colspan","rowspan","scope","class","id","type","name","value","placeholder","disabled","checked","for","aria-label","aria-hidden","aria-expanded","role","tabindex","data-tv-form","data-message-id","data-persona-component-directive","data-preserve-animation","data-persona-instance"]},Z=/^data:image\/(?:png|jpe?g|gif|webp|bmp|x-icon|avif)/i,J=()=>{let o=null;return e=>{let n=L();if(!n)return P(e);if(!o){let{DOMPurify:t}=n;o=t(typeof window<"u"?window:void 0),o.addHook("uponSanitizeAttribute",(r,s)=>{if(s.attrName==="src"||s.attrName==="href"){let l=s.attrValue;l.toLowerCase().startsWith("data:")&&!Z.test(l)&&(s.attrValue="",s.keepAttr=!1)}})}return o.sanitize(e,Y)}},Mt=o=>o===!1?null:typeof o=="function"?o:J();import{Activity as K,ArrowDown as Q,ArrowLeft as ee,ArrowRight as te,ArrowUp as ne,ArrowUpRight as oe,AtSign as re,Bot as ie,Check as se,ChevronDown as ae,ChevronLeft as le,ChevronRight as ce,ChevronUp as de,Clipboard as pe,ClipboardCopy as ue,CodeXml as ge,Copy as me,Download as fe,Ellipsis as be,EllipsisVertical as he,ExternalLink as ye,Eye as ve,File as ke,FileCode as we,FileSpreadsheet as xe,FileText as Ce,History as Me,ImagePlus as Ae,Loader as Ee,LoaderCircle as Le,Maximize as Se,Menu as Oe,MessageSquare as Ie,Mic as Te,Minimize as Re,Minus as Pe,PanelLeft as Ne,Paperclip as De,Pencil as He,Plus as _e,Quote as Be,RefreshCw as ze,Search as Fe,Send as We,ShieldAlert as qe,ShieldCheck as je,ShieldX as Ue,Square as Ge,Star as $e,ThumbsDown as Ve,ThumbsUp as Xe,Trash as Ye,Trash2 as Ze,Upload as Je,Volume2 as Ke,X as Qe}from"lucide";var et={activity:K,"arrow-down":Q,"arrow-up":ne,"arrow-up-right":oe,bot:ie,"chevron-down":ae,"chevron-up":de,"chevron-right":ce,"chevron-left":le,check:se,clipboard:pe,"clipboard-copy":ue,"code-xml":ge,copy:me,file:ke,"file-code":we,"file-spreadsheet":xe,"file-text":Ce,"image-plus":Ae,loader:Ee,"loader-circle":Le,mic:Te,paperclip:De,quote:Be,"refresh-cw":ze,search:Fe,send:We,"shield-alert":qe,"shield-check":je,"shield-x":Ue,square:Ge,"thumbs-down":Ve,"thumbs-up":Xe,upload:Je,"volume-2":Ke,x:Qe,"at-sign":re,"arrow-left":ee,"arrow-right":te,"external-link":ye,ellipsis:be,"ellipsis-vertical":he,menu:Oe,"panel-left":Ne,plus:_e,minus:Pe,pencil:He,trash:Ye,"trash-2":Ze,download:fe,maximize:Se,minimize:Re,"message-square":Ie,star:$e,eye:ve,history:Me},tt=["user","mail","phone","calendar","clock","building","map-pin","lock","key","credit-card","hash","globe","link","circle-check","circle-x","triangle-alert","info","ban","shield","house","pen-line","save","share","funnel","settings","rotate-cw","shopping-cart","shopping-bag","package","truck","tag","gift","receipt","wallet","store","dollar-sign","percent","play","pause","volume-x","camera","image","film","headphones","message-circle","bell","heart","eye-off","bookmark","calendar-days","timer","folder","folder-open","files","chart-column","sparkles","zap","sun","moon","flag","lightbulb","monitor","smartphone"],S=new Map(Object.entries(et)),k=new Set,N=!1,O=new Set,nt=o=>{let e=[...O];o&&O.clear();for(let n of e)try{n()}catch{}},Ot=o=>N?()=>{}:(O.add(o),()=>{O.delete(o)}),ot=()=>{let o=0;for(let e of[...k]){let n=S.get(e.name);if(!n)continue;k.delete(e),o++;let t=I(n,e.size,e.color,e.strokeWidth);if(t)for(e.el.removeAttribute("data-persona-icon-pending");t.firstChild;)e.el.appendChild(t.firstChild)}return o};var D=!1,rt=()=>{F().then(o=>{if(!N){for(let[e,n]of Object.entries(o.EXTRA_LUCIDE_ICONS))S.has(e)||S.set(e,n);N=!0,ot(),nt(!0)}}).catch(o=>{D=!0,console.warn("[Persona] Failed to load the icons-extra chunk",o)})},it=(o,e,n)=>{let t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.setAttribute("width",String(o)),t.setAttribute("height",String(o)),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke",e),t.setAttribute("stroke-width",String(n)),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true"),t.setAttribute("data-persona-icon-pending","true"),t},w=(o,e=24,n="currentColor",t=2)=>{let r=S.get(o);if(r)return I(r,e,n,t);if(tt.includes(o)){D&&(D=!1);let s=it(e,n,t);if(k.size>=500){let l=k.values().next().value;l&&k.delete(l)}return k.add({el:s,name:o,size:e,color:n,strokeWidth:t}),rt(),s}return console.warn(`Lucide icon "${o}" is not in the Persona registry. Register it via registerIcons(), or add it to packages/widget/src/utils/icons.ts (see docs/icon-registry-shortlist.md).`),null};var Tt={idle:"Online",connecting:"Connecting\u2026",connected:"Streaming\u2026",error:"Offline",paused:"Connection lost\u2026",resuming:"Reconnecting\u2026"},st=1e5,q=st+1;function H(o){let{items:e,onSelect:n,anchor:t,position:r="bottom-left",portal:s,onOpenChange:l}=o,c=f("div","persona-dropdown-menu persona-hidden");c.setAttribute("role","menu"),c.setAttribute("data-persona-theme-zone","dropdown"),s?(c.style.position="fixed",c.style.zIndex=String(q)):(c.style.position="absolute",c.style.top="100%",c.style.marginTop="4px",r==="bottom-right"?c.style.right="0":c.style.left="0");for(let p of e){if(p.dividerBefore){let b=document.createElement("hr");c.appendChild(b)}let m=document.createElement("button");if(m.type="button",m.setAttribute("role","menuitem"),m.setAttribute("data-dropdown-item-id",p.id),p.destructive&&m.setAttribute("data-destructive",""),p.icon){let b=w(p.icon,16,"currentColor",1.5);b&&m.appendChild(b)}let y=document.createElement("span");y.textContent=p.label,m.appendChild(y),m.addEventListener("click",b=>{b.stopPropagation(),d(),n(p.id)}),c.appendChild(m)}let u=null;function i(){if(!s)return;let p=t.getBoundingClientRect();c.style.top=`${p.bottom+4}px`,r==="bottom-right"?(c.style.right=`${window.innerWidth-p.right}px`,c.style.left="auto"):(c.style.left=`${p.left}px`,c.style.right="auto")}function a(){let p=c.classList.contains("persona-hidden");i(),c.classList.remove("persona-hidden"),p&&l?.(!0),requestAnimationFrame(()=>{let m=y=>{!c.contains(y.target)&&!t.contains(y.target)&&d()};document.addEventListener("click",m,!0),u=()=>document.removeEventListener("click",m,!0)})}function d(){let p=!c.classList.contains("persona-hidden");c.classList.add("persona-hidden"),u?.(),u=null,p&&l?.(!1)}function g(){c.classList.contains("persona-hidden")?a():d()}function h(){d(),c.remove()}return s&&s.appendChild(c),{element:c,show:a,hide:d,toggle:g,destroy:h}}function _(o){let{icon:e,label:n,size:t,strokeWidth:r,className:s,chromeless:l,onClick:c,aria:u}=o,i=f("button",z(!l&&"persona-icon-btn",s));i.type="button",i.setAttribute("aria-label",n),i.title=n;let a=w(e,t??16,"currentColor",r??2);if(a&&i.appendChild(a),c&&i.addEventListener("click",c),u)for(let[d,g]of Object.entries(u))i.setAttribute(d,g);return i}function at(o){let{icon:e,label:n,variant:t="default",size:r="sm",iconSize:s,className:l,onClick:c,aria:u}=o,i="persona-label-btn";t!=="default"&&(i+=" persona-label-btn--"+t),i+=" persona-label-btn--"+r,l&&(i+=" "+l);let a=f("button",i);if(a.type="button",a.setAttribute("aria-label",n),e){let g=w(e,s??14,"currentColor",2);g&&a.appendChild(g)}let d=f("span");if(d.textContent=n,a.appendChild(d),c&&a.addEventListener("click",c),u)for(let[g,h]of Object.entries(u))a.setAttribute(g,h);return a}function Ft(o){let{items:e,selectedId:n,onSelect:t,className:r}=o,s=f("div","persona-toggle-group"+(r?" "+r:""));s.setAttribute("role","group");let l=n,c=[];function u(){for(let a of c)a.btn.setAttribute("aria-pressed",a.id===l?"true":"false")}for(let a of e){let d;a.icon?d=_({icon:a.icon,label:a.label,className:a.className,onClick:()=>{l=a.id,u(),t(a.id)}}):(d=f("button","persona-icon-btn"+(a.className?" "+a.className:"")),d.type="button",d.setAttribute("aria-label",a.label),d.title=a.label,d.textContent=a.label,d.addEventListener("click",()=>{l=a.id,u(),t(a.id)})),d.setAttribute("aria-pressed",a.id===l?"true":"false"),c.push({id:a.id,btn:d}),s.appendChild(d)}function i(a){l=a,u()}return{element:s,setSelected:i}}function Wt(o){let{label:e,icon:n,iconSize:t,iconOnly:r,menuItems:s,onSelect:l,onPrimary:c,position:u="bottom-left",portal:i,chevronLabel:a="More options",chevronIconSize:d,className:g,primaryClassName:h,chevronClassName:p}=o,m=f("div","persona-split-btn"+(g?" "+g:"")),y={label:e,className:"persona-split-btn-primary"+(h?" "+h:""),onClick:c},b=r&&n?_({...y,icon:n,size:t??14}):at({...y,icon:n,iconSize:t??14}),C=_({icon:"chevron-down",label:a,size:d??14,className:"persona-split-btn-chevron"+(p?" "+p:""),aria:{"aria-haspopup":"true","aria-expanded":"false"}});m.append(b,C);let v=null,x=()=>{if(v)return v;let M=(typeof i=="function"?i():i)??void 0;return v=H({items:s,onSelect:l,anchor:m,position:u,portal:M,onOpenChange:j=>{C.setAttribute("aria-expanded",j?"true":"false")}}),M||m.appendChild(v.element),v};return m.isConnected?x():requestAnimationFrame(()=>{v||x()}),C.addEventListener("click",M=>{M.stopPropagation(),x().toggle()}),{element:m,primaryButton:b,chevronButton:C,openMenu:()=>x().show(),closeMenu:()=>v?.hide(),toggleMenu:()=>x().toggle(),destroy:()=>{v?.destroy(),m.remove()}}}function qt(o){let{label:e,icon:n="chevron-down",menuItems:t,onSelect:r,position:s="bottom-left",portal:l,className:c,hover:u}=o,i=f("div","persona-combo-btn"+(c?" "+c:""));i.style.position="relative",i.style.display="inline-flex",i.style.alignItems="center",i.style.cursor="pointer",i.setAttribute("role","button"),i.setAttribute("tabindex","0"),i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded","false"),i.setAttribute("aria-label",e);let a=f("span","persona-combo-btn-label");a.textContent=e,i.appendChild(a);let d=w(n,14,"currentColor",2);d&&(d.style.marginLeft="4px",d.style.opacity="0.6",i.appendChild(d)),u&&(i.style.borderRadius=u.borderRadius??"10px",i.style.padding=u.padding??"6px 4px 6px 12px",i.style.border="1px solid transparent",i.style.transition="background-color 0.15s ease, border-color 0.15s ease",i.addEventListener("mouseenter",()=>{i.style.backgroundColor=u.background??"",i.style.borderColor=u.border??""}),i.addEventListener("mouseleave",()=>{i.style.backgroundColor="",i.style.borderColor="transparent"}));let g=H({items:t,onSelect:p=>{i.setAttribute("aria-expanded","false"),r(p)},anchor:i,position:s,portal:l});l||i.appendChild(g.element);let h=()=>i.getAttribute("data-persona-menu-locked")==="true";return i.addEventListener("click",p=>{if(p.stopPropagation(),h())return;let m=!g.element.classList.contains("persona-hidden");i.setAttribute("aria-expanded",m?"false":"true"),g.toggle()}),i.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),i.click())}),{element:i,setLabel:p=>{a.textContent=p,i.setAttribute("aria-label",p)},open:()=>{i.setAttribute("aria-expanded","true"),g.show()},close:()=>{i.setAttribute("aria-expanded","false"),g.hide()},toggle:()=>{let p=!g.element.classList.contains("persona-hidden");i.setAttribute("aria-expanded",p?"false":"true"),g.toggle()},destroy:()=>{g.destroy(),i.remove()}}}var B=class{constructor(){this.components=new Map;this.options=new Map}register(e,n,t){this.components.has(e)&&console.warn(`[ComponentRegistry] Component "${e}" is already registered. Overwriting.`),this.components.set(e,n),t?this.options.set(e,t):this.options.delete(e)}unregister(e){this.components.delete(e),this.options.delete(e)}get(e){return this.components.get(e)}has(e){return this.components.has(e)}getOptions(e){return this.options.get(e)}getAllNames(){return Array.from(this.components.keys())}clear(){this.components.clear(),this.options.clear()}registerAll(e){Object.entries(e).forEach(([n,t])=>{this.register(n,t)})}},Ut=new B;var Vt=(o,e,n)=>{let t=n;for(let r of e){let s=f("span","persona-tool-char");s.style.setProperty("--char-index",String(t)),s.textContent=r===" "?"\xA0":r,o.appendChild(s),t++}return t};export{A as a,dt as b,F as c,Ot as d,w as e,mt as f,ft as g,bt as h,L as i,vt as j,P as k,Mt as l,Tt as m,st as n,q as o,H as p,_ as q,at as r,Ft as s,Wt as t,qt as u,Vt as v,Ut as w};
@@ -1 +0,0 @@
1
- var i=class extends Error{constructor(o,r,e){super(r),this.name="HistoryProviderError",this.code=o,e?.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=e.retryAfterSeconds)}};function a(t){return t instanceof i}var s=["viewTitle","openHistoryLabel","openHistoryBusyLabel","newConversationLabel","expandLabel","collapseLabel","resizeLabel","showEarlierMessagesLabel","openConversationLoadingLabel","openConversationErrorTitle","openConversationRetryLabel","openConversationBackLabel","confirmCancelLabel","deleteConversationConfirmTitle","deleteConversationConfirm","deleteConversationConfirmLabel","clearHistoryConfirmTitle","clearHistoryConfirm","clearHistoryVerifiedConfirm","clearHistoryConfirmLabel","resetIdentityConfirmTitle","resetIdentityConfirm","resetIdentityConfirmLabel","conversationDeletedNotice","identityResetNotice","identityResetUnconfirmedNotice"],n={viewTitle:"Messages",openHistoryLabel:"Messages",openHistoryBusyLabel:"Messages, available once the reply finishes",newConversationLabel:"New conversation",expandLabel:"Expand conversation list",collapseLabel:"Collapse conversation list",resizeLabel:"Resize conversation list",showEarlierMessagesLabel:"Show earlier messages",openConversationLoadingLabel:"Loading conversation",openConversationErrorTitle:"Could not open the conversation.",openConversationRetryLabel:"Try again",openConversationBackLabel:"Back to messages",confirmCancelLabel:"Cancel",deleteConversationConfirmTitle:"Delete conversation",deleteConversationConfirm:"Delete this conversation? This cannot be undone.",deleteConversationConfirmLabel:"Delete",clearHistoryConfirmTitle:"Delete all conversations",clearHistoryConfirm:"Delete all conversations for this assistant on this browser? This cannot be undone.",clearHistoryVerifiedConfirm:"Delete all conversations for this assistant and signed-in user? This cannot be undone.",clearHistoryConfirmLabel:"Delete all",resetIdentityConfirmTitle:"Forget this device",resetIdentityConfirm:"Forget this device? All Persona data stored in this browser is cleared. Records are not deleted elsewhere.",resetIdentityConfirmLabel:"Forget this device",conversationDeletedNotice:"That conversation was deleted. You are now in a new conversation.",identityResetNotice:"This device was forgotten.",identityResetUnconfirmedNotice:"This device was cleared here, but the server could not confirm it."};function d(t){if(!t)return n;let o={...n};for(let r of s){let e=t[r];typeof e=="string"&&e.length>0&&(o[r]=e)}return o}export{i as a,a as b,n as c,d};
@@ -1,3 +0,0 @@
1
- function l(e){e&&(typeof e.requestSubmit=="function"?e.requestSubmit():e.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0})))}function p(e){let r=()=>{e.dispatchEvent(new Event("input",{bubbles:!0}))};return{element:e,getValue:()=>e.value,getLogicalText:()=>e.value,getSelection:()=>({start:e.selectionStart??0,end:e.selectionEnd??0}),setSelection:(n,t=n)=>{e.setSelectionRange(n,t)},setValueWithCaret:(n,t)=>{e.value=n,e.setSelectionRange(t,t)},setValue:n=>{e.value=n,e.setSelectionRange(n.length,n.length),r(),e.focus()},submit:()=>l(e.form),dispatchInput:r,focus:()=>e.focus()}}var u=/\s/;function g(e,r,n){if(n==="input-start")return r===0;let t=r>0?e[r-1]:"";return n==="line-start"?t===""||t===`
2
- `:t===""||u.test(t)}function c(e,r,n="@",t="anywhere",o=!1){if(!n||r<=0||r>e.length)return null;let i=r-1;for(;i>=0;){let s=e[i];if(s===n)return g(e,i,t)?{triggerIndex:i,query:e.slice(i+1,r)}:null;if(s===`
3
- `||s==="\uFFFC"||!o&&u.test(s))return null;i--}return null}function a(e,r,n){for(let t of n){let o=c(e,r,t.trigger,t.position??"anywhere",t.allowSpaces??!1);if(o)return{channel:t,match:o}}return null}function d(e){return e?e!=="insertFromPaste"&&e!=="insertFromDrop":!0}function f(e,r,n){return{value:e.slice(0,r.triggerIndex)+e.slice(n),caret:r.triggerIndex}}export{l as a,p as b,a as c,d,f as e};
@@ -1,9 +0,0 @@
1
- import{c as i}from"./chunk-76IELU7F.js";function s(e){let t=0;for(let o of e.split(`
2
- `)){let n=/^ {0,3}(`+)/.exec(o);n&&n[1].length>t&&(t=n[1].length)}return t}function r(e,t){let o="`".repeat(Math.max(3,s(t)+1));return`${o}${e}
3
- ${t}
4
- ${o}`}function a(e,t,o){return t.includes("</document_content>")?r(e,t):`<document index="${o+1}">
5
- <source>${e}</source>
6
- <document_content>
7
- ${t}
8
- </document_content>
9
- </document>`}function c(e,t,o="fenced"){if(typeof o=="function")try{return o(e,t)}catch(n){return console.warn("[persona] contextMentions.llmFormat threw; falling back to the fenced format for this mention",n),r(e.label,e.text)}return o==="document"?a(e.label,e.text,t):r(e.label,e.text)}var l="[data-persona-composer-chip-row]";function m(e){e.style.display=e.childElementCount>0?"flex":"none"}function g(e){let t=e.querySelector(l);if(t)return t;let o=i("div",{className:"persona-composer-chip-row",attrs:{"data-persona-composer-chip-row":""}});o.style.display="none";let n=e.querySelector("[data-persona-composer-quote], [data-persona-composer-pending]");return n?.parentElement===e?e.insertBefore(o,n):e.appendChild(o),o}function f(e){let t={trigger:e.trigger??"@",position:e.triggerPosition??"anywhere",allowSpaces:!1,sources:Array.isArray(e.sources)?e.sources:[],searchPlaceholder:e.searchPlaceholder,showButton:e.showButton!==!1,buttonIconName:e.buttonIconName,buttonTooltipText:e.buttonTooltipText},o=(e.triggers??[]).map(n=>({trigger:n.trigger,position:n.triggerPosition??"anywhere",allowSpaces:n.allowSpaces??!1,sources:Array.isArray(n.sources)?n.sources:[],searchPlaceholder:n.searchPlaceholder,showButton:n.showButton===!0,buttonIconName:n.buttonIconName,buttonTooltipText:n.buttonTooltipText}));return[t,...o]}export{r as a,c as b,l as c,m as d,g as e,f};