@raybase/agent-ui 0.0.1 → 0.3.2

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.
@@ -0,0 +1,333 @@
1
+ // Models with heavy math and reasoning post-training — the GLM, DeepSeek, Qwen
2
+ // and Kimi families among them — carry LaTeX into ordinary prose: "you moved
3
+ // from a weekly check-in $\rightarrow$ a daily one". Core renders agent markdown
4
+ // with react-markdown and remark-gfm and no math plugin, so the source shows
5
+ // through verbatim and the reader sees `$\rightarrow$` where the model meant
6
+ // `→`. This normalizes it back to the Unicode the model was reaching for.
7
+ //
8
+ // It is deliberately NOT a math renderer. KaTeX would be a quarter of a
9
+ // megabyte of payload and a stylesheet to solve a punctuation problem, and a
10
+ // half-streamed `$\right` would flash as a parse error while the rest of the
11
+ // turn arrives. So anything that looks like real mathematics — superscripts,
12
+ // subscripted variables, fractions — is rejected and left exactly as it renders
13
+ // today, rather than lossily flattened into something that reads wrong.
14
+ //
15
+ // Running as a remark plugin over mdast `text` nodes buys two correctness
16
+ // properties for free. `inlineCode` and `code` are distinct node types, so a
17
+ // `$\alpha$` inside backticks is never touched — no markdown re-scanning of our
18
+ // own. And CommonMark has already resolved backslash escapes by this point,
19
+ // which is why there is no handling for `\(…\)` or `\[…\]` delimiters here:
20
+ // `\(` is an escaped ASCII punctuation mark, so it reaches us as a bare `(`
21
+ // and only the command inside survives, where the bare-command pass picks it
22
+ // up. LaTeX's own escapes (`\%`, `\_`, `\&`) are resolved by that same rule
23
+ // before the plugin runs, so LATEX_SPAN_ESCAPES below is inert on this path;
24
+ // it is there because `normalizeLatexProse` is exported and correct on raw,
25
+ // unparsed text too.
26
+ /**
27
+ * LaTeX commands that show up in prose, mapped to the character they stand in
28
+ * for. Symbols only: no layout, no structure, nothing whose meaning depends on
29
+ * an argument. A command that is missing here is not a failure mode — it makes
30
+ * its whole span ineligible, and the span renders as it does today.
31
+ */
32
+ export const latexProseSymbols = {
33
+ // Arrows — overwhelmingly the common case in prose.
34
+ "\\rightarrow": "→",
35
+ "\\to": "→",
36
+ "\\longrightarrow": "⟶",
37
+ "\\leftarrow": "←",
38
+ "\\gets": "←",
39
+ "\\longleftarrow": "⟵",
40
+ "\\leftrightarrow": "↔",
41
+ "\\Rightarrow": "⇒",
42
+ "\\implies": "⇒",
43
+ "\\Leftarrow": "⇐",
44
+ "\\Leftrightarrow": "⇔",
45
+ "\\iff": "⇔",
46
+ "\\uparrow": "↑",
47
+ "\\downarrow": "↓",
48
+ "\\mapsto": "↦",
49
+ // Relations.
50
+ "\\le": "≤",
51
+ "\\leq": "≤",
52
+ "\\ge": "≥",
53
+ "\\geq": "≥",
54
+ "\\ne": "≠",
55
+ "\\neq": "≠",
56
+ "\\approx": "≈",
57
+ "\\sim": "∼",
58
+ "\\simeq": "≃",
59
+ "\\cong": "≅",
60
+ "\\equiv": "≡",
61
+ "\\propto": "∝",
62
+ "\\ll": "≪",
63
+ "\\gg": "≫",
64
+ // Operators.
65
+ "\\times": "×",
66
+ "\\div": "÷",
67
+ "\\pm": "±",
68
+ "\\mp": "∓",
69
+ "\\cdot": "·",
70
+ "\\ast": "*",
71
+ "\\circ": "∘",
72
+ "\\bullet": "•",
73
+ "\\oplus": "⊕",
74
+ "\\otimes": "⊗",
75
+ // Sets and logic.
76
+ "\\in": "∈",
77
+ "\\notin": "∉",
78
+ "\\subset": "⊂",
79
+ "\\subseteq": "⊆",
80
+ "\\supset": "⊃",
81
+ "\\supseteq": "⊇",
82
+ "\\cup": "∪",
83
+ "\\cap": "∩",
84
+ "\\emptyset": "∅",
85
+ "\\varnothing": "∅",
86
+ "\\forall": "∀",
87
+ "\\exists": "∃",
88
+ "\\neg": "¬",
89
+ "\\lnot": "¬",
90
+ "\\land": "∧",
91
+ "\\wedge": "∧",
92
+ "\\lor": "∨",
93
+ "\\vee": "∨",
94
+ "\\therefore": "∴",
95
+ "\\because": "∵",
96
+ // Miscellaneous symbols.
97
+ "\\infty": "∞",
98
+ "\\ldots": "…",
99
+ "\\dots": "…",
100
+ "\\cdots": "⋯",
101
+ // Not `\deg`: that is the polynomial-degree operator, not the symbol.
102
+ "\\degree": "°",
103
+ "\\prime": "′",
104
+ "\\star": "★",
105
+ "\\dagger": "†",
106
+ "\\partial": "∂",
107
+ "\\nabla": "∇",
108
+ "\\angle": "∠",
109
+ "\\perp": "⊥",
110
+ "\\parallel": "∥",
111
+ // Not `\sqrt`: its argument is its meaning, and a bare `√` loses the scope.
112
+ "\\sum": "∑",
113
+ "\\prod": "∏",
114
+ "\\int": "∫",
115
+ "\\pounds": "£",
116
+ "\\euro": "€",
117
+ "\\copyright": "©",
118
+ "\\checkmark": "✓",
119
+ // Greek, lower case.
120
+ "\\alpha": "α",
121
+ "\\beta": "β",
122
+ "\\gamma": "γ",
123
+ "\\delta": "δ",
124
+ "\\epsilon": "ε",
125
+ "\\varepsilon": "ε",
126
+ "\\zeta": "ζ",
127
+ "\\eta": "η",
128
+ "\\theta": "θ",
129
+ "\\iota": "ι",
130
+ "\\kappa": "κ",
131
+ "\\lambda": "λ",
132
+ "\\mu": "μ",
133
+ "\\nu": "ν",
134
+ "\\xi": "ξ",
135
+ "\\pi": "π",
136
+ "\\rho": "ρ",
137
+ "\\sigma": "σ",
138
+ "\\tau": "τ",
139
+ "\\upsilon": "υ",
140
+ "\\phi": "φ",
141
+ "\\varphi": "φ",
142
+ "\\chi": "χ",
143
+ "\\psi": "ψ",
144
+ "\\omega": "ω",
145
+ // Greek, upper case.
146
+ "\\Gamma": "Γ",
147
+ "\\Delta": "Δ",
148
+ "\\Theta": "Θ",
149
+ "\\Lambda": "Λ",
150
+ "\\Xi": "Ξ",
151
+ "\\Pi": "Π",
152
+ "\\Sigma": "Σ",
153
+ "\\Upsilon": "Υ",
154
+ "\\Phi": "Φ",
155
+ "\\Psi": "Ψ",
156
+ "\\Omega": "Ω",
157
+ // Spacing and grouping. These carry no glyph, so they are dropped or
158
+ // flattened to a single space inside a span, and skipped entirely by the
159
+ // bare-command pass — deleting a stray `\right` from running prose would be
160
+ // a silent edit, not a repair.
161
+ "\\left": "",
162
+ "\\right": "",
163
+ "\\quad": " ",
164
+ "\\qquad": " ",
165
+ "\\,": " ",
166
+ "\\;": " ",
167
+ "\\:": " ",
168
+ "\\ ": " ",
169
+ "\\!": ""
170
+ };
171
+ // `\text{…}` and its typographic cousins survive round-trips from math mode
172
+ // into prose. Only a brace-free, backslash-free argument is unwrapped, so a
173
+ // nested construct still fails the span outright.
174
+ const TEXT_WRAPPER = /\\(?:text|textbf|textit|textrm|mathrm|mathit|mathbf|mathsf)\{([^{}\\]*)\}/g;
175
+ // A command is either a maximal run of letters — greedy, so `\rightarrow` is
176
+ // never mistaken for `\right` followed by "arrow" — or one of the single
177
+ // punctuation spacing commands.
178
+ const LATEX_COMMAND = /^\\(?:[A-Za-z]+|[,;:!%_&#{} ])/;
179
+ // Characters LaTeX requires be escaped. Inside a span these stand for
180
+ // themselves, and they are handled here rather than in the symbol table
181
+ // because the bare-command pass must never touch them: CommonMark has already
182
+ // resolved `\%` and `\_` in running prose, and re-resolving them would corrupt
183
+ // text the markdown parser deliberately left alone.
184
+ const LATEX_SPAN_ESCAPES = {
185
+ "\\%": "%",
186
+ "\\_": "_",
187
+ "\\&": "&",
188
+ "\\#": "#",
189
+ "\\{": "{",
190
+ "\\}": "}"
191
+ };
192
+ // What is allowed to sit between commands inside a convertible span. Notably
193
+ // absent: `^`, `_`, `{`, `}` and `&`. Those mark genuine mathematics or
194
+ // structure that Unicode substitution would misrepresent, so their presence
195
+ // rejects the span.
196
+ const PLAIN_SPAN_CHAR = /[A-Za-z0-9\s.,;:!?'"()[\]|/+*=<>%-]/;
197
+ /**
198
+ * Normalize LaTeX-in-prose artifacts in a single run of text.
199
+ *
200
+ * Two passes: `$…$` spans that are entirely made of known commands and plain
201
+ * characters, then bare commands written without delimiters. Everything else
202
+ * is returned untouched.
203
+ */
204
+ export function normalizeLatexProse(text) {
205
+ // Every conversion this function performs requires a backslash, so text
206
+ // without one — the overwhelming majority of agent output — costs one scan.
207
+ if (!text.includes("\\"))
208
+ return text;
209
+ // Chunks are collected rather than concatenated because the bare-command pass
210
+ // must not reach inside a `$…$` span it already declined to convert. Half
211
+ // converting a rejected span ("$\\sum_{i=0}^{n}$" losing only its `\\sum`)
212
+ // leaves output strictly worse than the artifact it was trying to repair.
213
+ const chunks = [];
214
+ let index = 0;
215
+ let search = 0;
216
+ while (search < text.length) {
217
+ const open = text.indexOf("$", search);
218
+ if (open === -1)
219
+ break;
220
+ const close = text.indexOf("$", open + 1);
221
+ if (close === -1)
222
+ break;
223
+ // Pandoc's rule for TeX dollars: an opener has a non-space character
224
+ // right after it, and a closer has one right before it and no digit right
225
+ // after it. A dollar sign that fails is currency, not a delimiter, and
226
+ // stays in the running text: "$100 \to $200" is two prices and an arrow,
227
+ // never a span reading "100 \to ".
228
+ if (!opensMathSpan(text, open)) {
229
+ search = open + 1;
230
+ continue;
231
+ }
232
+ if (!closesMathSpan(text, close)) {
233
+ search = close;
234
+ continue;
235
+ }
236
+ chunks.push({ text: text.slice(index, open), bare: true });
237
+ const inner = text.slice(open + 1, close);
238
+ const converted = inner.includes("\n") ? null : convertMathSpan(inner);
239
+ if (converted === null) {
240
+ // Not a span we understand — "$x^2$", or "from $30 to $40/mo" where the
241
+ // closer is a price of its own. Keep the opener and the contents verbatim, then resume *at* the closing
242
+ // `$` rather than past it, so that character stays available to open a
243
+ // real span later in the line.
244
+ chunks.push({ text: text.slice(open, close), bare: false });
245
+ index = search = close;
246
+ continue;
247
+ }
248
+ chunks.push({ text: converted, bare: false });
249
+ index = search = close + 1;
250
+ }
251
+ chunks.push({ text: text.slice(index), bare: true });
252
+ return chunks.map((chunk) => (chunk.bare ? convertBareCommands(chunk.text) : chunk.text)).join("");
253
+ }
254
+ function opensMathSpan(text, open) {
255
+ const next = text[open + 1];
256
+ return next !== undefined && !/\s/.test(next);
257
+ }
258
+ function closesMathSpan(text, close) {
259
+ return !/\s/.test(text[close - 1]) && !/[0-9]/.test(text[close + 1] ?? "");
260
+ }
261
+ /**
262
+ * Convert the inside of a `$…$` span, or return null to leave the span alone.
263
+ */
264
+ function convertMathSpan(source) {
265
+ const unwrapped = source.replace(TEXT_WRAPPER, "$1");
266
+ let out = "";
267
+ let commands = 0;
268
+ let index = 0;
269
+ while (index < unwrapped.length) {
270
+ const char = unwrapped[index];
271
+ if (char === "\\") {
272
+ const match = LATEX_COMMAND.exec(unwrapped.slice(index));
273
+ if (!match)
274
+ return null;
275
+ const replacement = LATEX_SPAN_ESCAPES[match[0]] ?? latexProseSymbols[match[0]];
276
+ if (replacement === undefined)
277
+ return null;
278
+ out += replacement;
279
+ commands += 1;
280
+ index += match[0].length;
281
+ continue;
282
+ }
283
+ if (!PLAIN_SPAN_CHAR.test(char))
284
+ return null;
285
+ out += char;
286
+ index += 1;
287
+ }
288
+ // A span has to contain at least one command to be a math span at all.
289
+ // Without this, any two dollar signs in a sentence would swallow the words
290
+ // between them.
291
+ if (commands === 0)
292
+ return null;
293
+ return out.replace(/\s{2,}/g, " ").trim();
294
+ }
295
+ /**
296
+ * Replace commands written without `$` delimiters. The leading-character guard
297
+ * keeps a Windows path (`C:\times`) or an escaped backslash from being read as
298
+ * a command, and the trailing guard leaves a command with an argument or
299
+ * limits attached (`\sum_{i=0}^{n}`, `\alpha_1`) as the mathematics it is.
300
+ */
301
+ function convertBareCommands(text) {
302
+ if (!text.includes("\\"))
303
+ return text;
304
+ return text.replace(/(^|[^A-Za-z0-9:/\\])\\([A-Za-z]+)(?![A-Za-z{[_^])/g, (whole, prefix, name) => {
305
+ const replacement = latexProseSymbols["\\" + name];
306
+ // Falsy covers the spacing and grouping entries, which map to "" or a
307
+ // space: outside a span those are not artifacts to repair.
308
+ if (!replacement || !replacement.trim())
309
+ return whole;
310
+ return prefix + replacement;
311
+ });
312
+ }
313
+ /**
314
+ * Remark plugin form, for `RaybaseAgentMarkdown`'s plugin list.
315
+ */
316
+ export function remarkRaybaseLatexProse() {
317
+ return (tree) => {
318
+ normalizeTextNodes(tree);
319
+ };
320
+ }
321
+ function normalizeTextNodes(node) {
322
+ if (node.type === "text" && typeof node.value === "string") {
323
+ node.value = normalizeLatexProse(node.value);
324
+ return;
325
+ }
326
+ // `code` and `inlineCode` hold their source in `value` too, and are skipped
327
+ // by this check for exactly that reason.
328
+ if (!Array.isArray(node.children))
329
+ return;
330
+ for (const child of node.children)
331
+ normalizeTextNodes(child);
332
+ }
333
+ //# sourceMappingURL=latex-prose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latex-prose.js","sourceRoot":"","sources":["../src/latex-prose.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,6EAA6E;AAC7E,iFAAiF;AACjF,6EAA6E;AAC7E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,wEAAwE;AACxE,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,gFAAgF;AAChF,wEAAwE;AACxE,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,gFAAgF;AAChF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,qBAAqB;AAQrB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA2B;IACvD,oDAAoD;IACpD,cAAc,EAAE,GAAG;IACnB,MAAM,EAAE,GAAG;IACX,kBAAkB,EAAE,GAAG;IACvB,aAAa,EAAE,GAAG;IAClB,QAAQ,EAAE,GAAG;IACb,iBAAiB,EAAE,GAAG;IACtB,kBAAkB,EAAE,GAAG;IACvB,cAAc,EAAE,GAAG;IACnB,WAAW,EAAE,GAAG;IAChB,aAAa,EAAE,GAAG;IAClB,kBAAkB,EAAE,GAAG;IACvB,OAAO,EAAE,GAAG;IACZ,WAAW,EAAE,GAAG;IAChB,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,GAAG;IAEf,aAAa;IACb,MAAM,EAAE,GAA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AAW,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;YAAE,OAAO,KAAK,CAAC;QACtD,OAAO,MAAM,GAAG,WAAW,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,CAAC,IAAe,EAAQ,EAAE;QAC/B,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAe;IACzC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3D,IAAI,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7C,OAAO;IACT,CAAC;IACD,4EAA4E;IAC5E,yCAAyC;IACzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO;IAC1C,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ;QAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,19 @@
1
+ export declare const defaultVoiceNoteMaxSeconds = 300;
2
+ export declare const voiceNoteSampleRate = 16000;
3
+ export type VoiceRecording = {
4
+ bytes: Uint8Array;
5
+ durationSeconds: number;
6
+ mediaType: "audio/wav";
7
+ };
8
+ export type VoiceRecorder = {
9
+ start(): Promise<void>;
10
+ stop(): Promise<VoiceRecording>;
11
+ cancel(): void;
12
+ };
13
+ export declare function isVoiceRecordingSupported(): boolean;
14
+ export declare function createVoiceRecorder(input?: {
15
+ maxSeconds?: number;
16
+ }): VoiceRecorder;
17
+ export declare function downsampleLinear(samples: Float32Array, fromRate: number, toRate: number): Float32Array;
18
+ export declare function encodeWavPcm16(samples: Float32Array, sampleRate: number): Uint8Array;
19
+ //# sourceMappingURL=voice-recorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-recorder.d.ts","sourceRoot":"","sources":["../src/voice-recorder.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAE1C,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,WAAW,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;IAChC,MAAM,IAAI,IAAI,CAAC;CAChB,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,OAAO,CAMnD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,aAAa,CA2DtF;AAaD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAatG;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAwBpF"}
@@ -0,0 +1,121 @@
1
+ // Dependency-free microphone capture for voice notes. Browsers produce mono
2
+ // 16 kHz 16-bit PCM WAV so uploads and Workers AI transcription use one
3
+ // predictable format instead of depending on MediaRecorder codec support.
4
+ export const defaultVoiceNoteMaxSeconds = 300;
5
+ export const voiceNoteSampleRate = 16_000;
6
+ export function isVoiceRecordingSupported() {
7
+ return (typeof navigator !== "undefined"
8
+ && typeof navigator.mediaDevices?.getUserMedia === "function"
9
+ && typeof globalThis.AudioContext === "function");
10
+ }
11
+ export function createVoiceRecorder(input = {}) {
12
+ const maxSeconds = input.maxSeconds ?? defaultVoiceNoteMaxSeconds;
13
+ let stream = null;
14
+ let context = null;
15
+ let processor = null;
16
+ let source = null;
17
+ let chunks = [];
18
+ let startedAt = 0;
19
+ function teardown() {
20
+ processor?.disconnect();
21
+ source?.disconnect();
22
+ for (const track of stream?.getTracks() ?? [])
23
+ track.stop();
24
+ void context?.close().catch(() => { });
25
+ processor = null;
26
+ source = null;
27
+ stream = null;
28
+ context = null;
29
+ }
30
+ return {
31
+ async start() {
32
+ stream = await navigator.mediaDevices.getUserMedia({
33
+ audio: { echoCancellation: true, noiseSuppression: true }
34
+ });
35
+ context = new AudioContext();
36
+ source = context.createMediaStreamSource(stream);
37
+ // ScriptProcessorNode remains broadly supported and avoids shipping an
38
+ // AudioWorklet module solely for short voice-note capture.
39
+ processor = context.createScriptProcessor(4096, 1, 1);
40
+ chunks = [];
41
+ processor.onaudioprocess = (event) => {
42
+ chunks.push(new Float32Array(event.inputBuffer.getChannelData(0)));
43
+ };
44
+ source.connect(processor);
45
+ processor.connect(context.destination);
46
+ startedAt = Date.now();
47
+ },
48
+ async stop() {
49
+ const sampleRate = context?.sampleRate ?? voiceNoteSampleRate;
50
+ teardown();
51
+ const durationSeconds = Math.min(Math.max(0, (Date.now() - startedAt) / 1000), maxSeconds);
52
+ const samples = concatFloat32(chunks);
53
+ chunks = [];
54
+ const downsampled = downsampleLinear(samples, sampleRate, voiceNoteSampleRate);
55
+ return {
56
+ bytes: encodeWavPcm16(downsampled, voiceNoteSampleRate),
57
+ durationSeconds,
58
+ mediaType: "audio/wav"
59
+ };
60
+ },
61
+ cancel() {
62
+ teardown();
63
+ chunks = [];
64
+ }
65
+ };
66
+ }
67
+ function concatFloat32(chunks) {
68
+ const total = chunks.reduce((length, chunk) => length + chunk.length, 0);
69
+ const output = new Float32Array(total);
70
+ let offset = 0;
71
+ for (const chunk of chunks) {
72
+ output.set(chunk, offset);
73
+ offset += chunk.length;
74
+ }
75
+ return output;
76
+ }
77
+ export function downsampleLinear(samples, fromRate, toRate) {
78
+ if (fromRate === toRate || samples.length === 0)
79
+ return samples;
80
+ const ratio = fromRate / toRate;
81
+ const length = Math.max(1, Math.floor(samples.length / ratio));
82
+ const output = new Float32Array(length);
83
+ for (let index = 0; index < length; index++) {
84
+ const position = index * ratio;
85
+ const left = Math.floor(position);
86
+ const right = Math.min(left + 1, samples.length - 1);
87
+ const fraction = position - left;
88
+ output[index] = samples[left] * (1 - fraction) + samples[right] * fraction;
89
+ }
90
+ return output;
91
+ }
92
+ export function encodeWavPcm16(samples, sampleRate) {
93
+ const dataBytes = samples.length * 2;
94
+ const buffer = new ArrayBuffer(44 + dataBytes);
95
+ const view = new DataView(buffer);
96
+ writeAscii(view, 0, "RIFF");
97
+ view.setUint32(4, 36 + dataBytes, true);
98
+ writeAscii(view, 8, "WAVE");
99
+ writeAscii(view, 12, "fmt ");
100
+ view.setUint32(16, 16, true);
101
+ view.setUint16(20, 1, true);
102
+ view.setUint16(22, 1, true);
103
+ view.setUint32(24, sampleRate, true);
104
+ view.setUint32(28, sampleRate * 2, true);
105
+ view.setUint16(32, 2, true);
106
+ view.setUint16(34, 16, true);
107
+ writeAscii(view, 36, "data");
108
+ view.setUint32(40, dataBytes, true);
109
+ let offset = 44;
110
+ for (const sampleValue of samples) {
111
+ const sample = Math.max(-1, Math.min(1, sampleValue));
112
+ view.setInt16(offset, sample < 0 ? sample * 0x8000 : sample * 0x7fff, true);
113
+ offset += 2;
114
+ }
115
+ return new Uint8Array(buffer);
116
+ }
117
+ function writeAscii(view, offset, value) {
118
+ for (let index = 0; index < value.length; index++)
119
+ view.setUint8(offset + index, value.charCodeAt(index));
120
+ }
121
+ //# sourceMappingURL=voice-recorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-recorder.js","sourceRoot":"","sources":["../src/voice-recorder.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,wEAAwE;AACxE,0EAA0E;AAE1E,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAC9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAc1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M,CAAC,CAAC;IAC7B,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACpC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,WAAW,IAAI,OAAO,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5E,MAAM,IAAI,CAAC,CAAC;IACd,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,UAAU,CAAC,IAAc,EAAE,MAAc,EAAE,KAAa;IAC/D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE;QAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5G,CAAC"}
package/package.json CHANGED
@@ -1,16 +1,51 @@
1
1
  {
2
2
  "name": "@raybase/agent-ui",
3
- "version": "0.0.1",
4
- "description": "Reserved for Raybase. Nothing is released under this name yet.",
5
- "license": "UNLICENSED",
3
+ "version": "0.3.2",
4
+ "description": "Agent UI runtime adapter for Raybase Agent conversations.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "peerDependencies": {
19
+ "@assistant-ui/react": "^0.11.0",
20
+ "lucide-react": "^1.18.0",
21
+ "react": "^18.3.0 || ^19.0.0",
22
+ "react-dom": "^18.3.0 || ^19.0.0",
23
+ "@raybase/core": "0.3.3"
24
+ },
25
+ "devDependencies": {
26
+ "@assistant-ui/react": "^0.11.29",
27
+ "@types/react": "^18.3.27",
28
+ "@types/react-dom": "^18.3.7",
29
+ "lucide-react": "1.18.0",
30
+ "react": "^18.3.1",
31
+ "react-dom": "^18.3.1",
32
+ "typescript": "^5.8.3",
33
+ "@raybase/core": "0.3.3"
34
+ },
35
+ "dependencies": {
36
+ "react-markdown": "^10.1.0",
37
+ "remark-gfm": "^4.0.1"
38
+ },
6
39
  "repository": {
7
40
  "type": "git",
8
- "url": "git+https://github.com/raybasedev/raybase.git"
41
+ "url": "git+https://github.com/raybasedev/raybase.git",
42
+ "directory": "packages/agent-ui"
9
43
  },
10
44
  "publishConfig": {
11
45
  "access": "public"
12
46
  },
13
- "files": [
14
- "README.md"
15
- ]
16
- }
47
+ "scripts": {
48
+ "build": "tsc -p tsconfig.json",
49
+ "check": "tsc -p tsconfig.json --noEmit"
50
+ }
51
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # @raybase/agent-ui
2
-
3
- This name is reserved for Raybase. Nothing is released under it yet, and this package holds no code.