diff --git a/apps/web/package.json b/apps/web/package.json index 2ee8fe51a06a3..9f5c30275214c 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -27,6 +27,7 @@ "@dnd-kit/utilities": "^3.2.2", "@effect/atom-react": "catalog:", "@fontsource-variable/inter": "^5.3.0", + "@huggingface/transformers": "4.3.2", "@legendapp/list": "catalog:", "@noble/hashes": "catalog:", "@pierre/diffs": "catalog:", diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx index d7878cc29a165..f6fb3d60dc4bf 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -259,6 +259,11 @@ import { import { useMediaQuery } from "../../hooks/useMediaQuery"; import { useSoftwareKeyboardOpen } from "../../hooks/useSoftwareKeyboardOpen"; import { useStableCallback } from "../../hooks/useStableCallback"; +import { + isComposerVoiceInputAvailable, + useComposerVoiceInput, +} from "../../voiceInput/useComposerVoiceInput"; +import { ComposerVoiceInputButton } from "./ComposerVoiceInputButton"; import { usePanelAnimationSettings } from "../../panelAnimations"; import { readEnvironmentScope } from "../../state/session"; import type { ReviewCommentContext } from "../../reviewCommentContext"; @@ -1817,6 +1822,18 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) }; }; const readComposerSnapshotStable = useStableCallback(readComposerSnapshot); + const voiceInput = useComposerVoiceInput({ + ownerKey: composerDraftTargetKey, + readDraft: () => ({ + text: promptRef.current, + cursor: readComposerSnapshotStable().expandedCursor, + }), + commitDraft: (text, cursor) => { + // The controller only commits an insertion at the cursor it captured. + const start = cursor - (text.length - promptRef.current.length); + applyPromptReplacementStable(start, start, text.slice(start, cursor)); + }, + }); const resolveActiveComposerTrigger = (): { snapshot: { value: string; cursor: number; expandedCursor: number }; @@ -2045,6 +2062,12 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) dispatchMode?: ComposerDispatchMode, submissionIntent?: ComposerSubmissionIntent, ) => { + if (voiceInput.state.phase !== "idle") { + event?.preventDefault(); + // Enter while dictating finishes the recording instead of sending. + if (voiceInput.state.phase === "recording") voiceInput.stop(); + return; + } if ( noProviderAvailable || isSendDisabled || @@ -3085,6 +3108,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) focusComposer={focusComposer} /> ) : null; + const composerVoiceInputButton = isComposerVoiceInputAvailable ? ( + + ) : null; return (
- {composerAttachButton ?
{composerAttachButton}
: null} + {composerAttachButton || composerVoiceInputButton ? ( +
+ {composerAttachButton} + {composerVoiceInputButton} +
+ ) : null}
{ + const timer = setInterval(() => setSeconds((value) => value + 1), 1000); + return () => clearInterval(timer); + }, []); + return {formatElapsed(seconds)}; +} + +function VoiceInputStatus({ voiceInput }: { voiceInput: ComposerVoiceInput }) { + const { phase } = voiceInput.state; + if (phase === "idle" || phase === "error") return null; + return ( + + {phase === "preparing" ? ( + voiceInput.downloadProgress === null ? ( + "Starting…" + ) : ( + <> + Downloading speech model, one time only ·{" "} + {Math.round(voiceInput.downloadProgress * 100)}% + + ) + ) : phase === "recording" ? ( + <> + Listening · Enter to finish + + ) : ( + "Transcribing…" + )} + + ); +} + +export function ComposerVoiceInputButton({ voiceInput }: { voiceInput: ComposerVoiceInput }) { + const { phase } = voiceInput.state; + const label = voiceInputLabel(voiceInput); + return ( + <> + + event.preventDefault()} + onClick={voiceInput.toggle} + disabled={phase === "transcribing"} + aria-label={label} + aria-pressed={phase === "recording"} + /> + } + > + {phase === "preparing" || phase === "transcribing" ? ( + + ) : phase === "recording" ? ( + + ) : ( + + )} + + {label} + + + + ); +} diff --git a/apps/web/src/env.ts b/apps/web/src/env.ts index a0a28c5d7fd60..85d1db06e1c64 100644 --- a/apps/web/src/env.ts +++ b/apps/web/src/env.ts @@ -4,3 +4,7 @@ export const isElectron = typeof window !== "undefined" && window.desktopBridge export const isSecretsFeatureEnabled = ["1", "true"].includes( import.meta.env.T3CODE_FEATURE_SECRETS?.trim().toLowerCase() ?? "", ); + +export const isVoiceInputFeatureEnabled = ["1", "true"].includes( + import.meta.env.T3CODE_FEATURE_VOICE_INPUT?.trim().toLowerCase() ?? "", +); diff --git a/apps/web/src/vite-env.d.ts b/apps/web/src/vite-env.d.ts index 63f7cca9cbfc6..537fe7716b0e2 100644 --- a/apps/web/src/vite-env.d.ts +++ b/apps/web/src/vite-env.d.ts @@ -16,6 +16,7 @@ interface ImportMetaEnv { readonly VITE_RELAY_OTLP_TRACES_TOKEN: string; readonly T3CODE_DESKTOP_UPDATE_REPOSITORY: string; readonly T3CODE_FEATURE_SECRETS: string; + readonly T3CODE_FEATURE_VOICE_INPUT: string; readonly APP_VERSION: string; } diff --git a/apps/web/src/voiceInput/browserVoiceRecorder.ts b/apps/web/src/voiceInput/browserVoiceRecorder.ts new file mode 100644 index 0000000000000..11e0f9d61a971 --- /dev/null +++ b/apps/web/src/voiceInput/browserVoiceRecorder.ts @@ -0,0 +1,105 @@ +import type { VoiceRecorder, VoiceRecorderStatus } from "@t3tools/client-runtime/voice-input"; + +export function supportsBrowserVoiceRecording(): boolean { + return ( + typeof navigator !== "undefined" && + navigator.mediaDevices?.getUserMedia !== undefined && + typeof MediaRecorder !== "undefined" + ); +} + +/** Asks for the microphone without holding it open while the speech model loads. */ +export async function requestBrowserMicrophonePermission(): Promise<{ + readonly granted: boolean; + readonly canAskAgain: boolean; +}> { + try { + const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); + for (const track of stream.getTracks()) track.stop(); + return { granted: true, canAskAgain: true }; + } catch { + const status = await navigator.permissions + ?.query({ name: "microphone" as PermissionName }) + .catch(() => null); + return { granted: false, canAskAgain: status?.state !== "denied" }; + } +} + +/** Records into a blob URL; the controller revokes it through `deleteRecording`. */ +export class BrowserVoiceRecorder implements VoiceRecorder { + uri: string | null = null; + private readonly onStatus: (status: VoiceRecorderStatus) => void; + private stream: MediaStream | null = null; + private recorder: MediaRecorder | null = null; + private chunks: Blob[] = []; + private limitTimer: ReturnType | null = null; + private stopped: Promise | null = null; + + constructor(onStatus: (status: VoiceRecorderStatus) => void) { + this.onStatus = onStatus; + } + + async prepareToRecordAsync(): Promise { + this.uri = null; + this.chunks = []; + this.stopped = null; + this.stream = await navigator.mediaDevices.getUserMedia({ audio: true }); + const recorder = new MediaRecorder(this.stream); + recorder.addEventListener("dataavailable", (event) => this.chunks.push(event.data)); + recorder.addEventListener("error", () => + this.reportFailure("The microphone stopped recording."), + ); + for (const track of this.stream.getAudioTracks()) { + track.addEventListener("ended", () => this.reportFailure("The microphone was disconnected.")); + } + this.recorder = recorder; + } + + record(options: { readonly forDuration: number }): void { + this.recorder?.start(); + this.limitTimer = setTimeout(() => { + void this.stop().then(() => + this.onStatus({ isFinished: true, hasError: false, error: null, url: this.uri }), + ); + }, options.forDuration * 1000); + } + + stop(): Promise { + this.stopped ??= this.finish(); + return this.stopped.then(() => undefined); + } + + /** Stops the microphone without waiting for a recording; safe to call repeatedly. */ + release(): void { + if (this.limitTimer) clearTimeout(this.limitTimer); + this.limitTimer = null; + for (const track of this.stream?.getTracks() ?? []) track.stop(); + this.stream = null; + } + + private finish(): Promise { + const recorder = this.recorder; + if (!recorder || recorder.state === "inactive") { + this.release(); + return Promise.resolve(this.uri); + } + return new Promise((resolve) => { + recorder.addEventListener( + "stop", + () => { + this.release(); + this.uri = URL.createObjectURL(new Blob(this.chunks, { type: recorder.mimeType })); + this.chunks = []; + resolve(this.uri); + }, + { once: true }, + ); + recorder.stop(); + }); + } + + private reportFailure(error: string): void { + if (this.recorder?.state !== "recording") return; + this.onStatus({ isFinished: false, hasError: true, error, url: null }); + } +} diff --git a/apps/web/src/voiceInput/useComposerVoiceInput.ts b/apps/web/src/voiceInput/useComposerVoiceInput.ts new file mode 100644 index 0000000000000..deab432cf07df --- /dev/null +++ b/apps/web/src/voiceInput/useComposerVoiceInput.ts @@ -0,0 +1,102 @@ +import { VoiceInputController, type VoiceInputState } from "@t3tools/client-runtime/voice-input"; +import { useEffect, useState, useSyncExternalStore } from "react"; + +import { isVoiceInputFeatureEnabled } from "~/env"; +import { useStableCallback } from "~/hooks/useStableCallback"; +import { toastManager } from "~/components/ui/toast"; +import { + BrowserVoiceRecorder, + requestBrowserMicrophonePermission, + supportsBrowserVoiceRecording, +} from "./browserVoiceRecorder"; +import { + getWhisperModelDownloadProgress, + subscribeToWhisperModelDownload, + whisperTranscriber, +} from "./whisperTranscriber"; + +const IDLE_STATE: VoiceInputState = { phase: "idle", error: null, errorAction: null }; + +export const isComposerVoiceInputAvailable = + isVoiceInputFeatureEnabled && supportsBrowserVoiceRecording(); + +export type ComposerVoiceInput = { + readonly state: VoiceInputState; + /** Model download progress from 0 to 1 on first use, otherwise `null`. */ + readonly downloadProgress: number | null; + readonly toggle: () => void; + readonly stop: () => void; +}; + +/** + * Drives the shared voice controller against the web composer. `ownerKey` + * scopes a recording to one draft; switching drafts cancels it. + */ +export function useComposerVoiceInput(input: { + readonly ownerKey: string; + readonly readDraft: () => { readonly text: string; readonly cursor: number }; + readonly commitDraft: (text: string, cursor: number) => void; +}): ComposerVoiceInput { + const [state, setState] = useState(IDLE_STATE); + const downloadProgress = useSyncExternalStore( + subscribeToWhisperModelDownload, + getWhisperModelDownloadProgress, + ); + const readDraft = useStableCallback(() => { + const draft = input.readDraft(); + return { + ownerKey: input.ownerKey, + text: draft.text, + selection: { start: draft.cursor, end: draft.cursor }, + revision: 0, + }; + }); + const commitDraft = useStableCallback( + (text: string, selection: { readonly start: number; readonly end: number }) => + input.commitDraft(text, selection.start), + ); + const [controller] = useState(() => { + const recorder = new BrowserVoiceRecorder((status) => { + void created.handleRecorderStatus(status); + }); + const created: VoiceInputController = new VoiceInputController({ + recorder, + getTranscriber: () => whisperTranscriber, + requestPermission: requestBrowserMicrophonePermission, + configureRecording: async () => {}, + releaseRecording: async () => recorder.release(), + deleteRecording: (uri) => URL.revokeObjectURL(uri), + readDraft, + commitDraft, + onStateChange: (next) => { + // start() accepts the error phase, so the button can stay idle and retry. + if (next.phase === "error") { + if (next.error) toastManager.add({ type: "error", title: next.error }); + setState(IDLE_STATE); + return; + } + setState(next); + }, + }); + return created; + }); + + const { ownerKey } = input; + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- releases the microphone held for this draft + useEffect( + () => () => controller.dispose(), + // oxlint-disable-next-line react/exhaustive-effect-dependencies -- A recording belongs to one draft, so switching drafts stops it. + [controller, ownerKey], + ); + + return { + state, + downloadProgress, + toggle: () => { + if (state.phase === "recording") void controller.stop(); + else if (state.phase === "preparing") controller.cancel(); + else void controller.start(); + }, + stop: () => void controller.stop(), + }; +} diff --git a/apps/web/src/voiceInput/whisper.worker.ts b/apps/web/src/voiceInput/whisper.worker.ts new file mode 100644 index 0000000000000..a857138cb4f7e --- /dev/null +++ b/apps/web/src/voiceInput/whisper.worker.ts @@ -0,0 +1,64 @@ +import { + type AutomaticSpeechRecognitionPipeline, + type ProgressInfo, + pipeline, +} from "@huggingface/transformers"; + +export type WhisperWorkerRequest = + | { readonly type: "prepare"; readonly model: string } + | { readonly type: "transcribe"; readonly id: number; readonly audio: Float32Array }; + +export type WhisperWorkerResponse = + | { readonly type: "progress"; readonly loaded: number; readonly total: number } + | { readonly type: "ready" } + | { readonly type: "transcript"; readonly id: number; readonly text: string } + | { readonly type: "error"; readonly id: number | null; readonly message: string }; + +let recognizer: Promise | null = null; + +function post(message: WhisperWorkerResponse) { + self.postMessage(message, { transfer: [] }); +} + +function reportProgress(info: ProgressInfo) { + if (info.status !== "progress_total") return; + post({ type: "progress", loaded: info.loaded, total: info.total }); +} + +async function loadRecognizer(model: string) { + const webgpu = "gpu" in navigator && (await navigator.gpu?.requestAdapter()) != null; + return pipeline("automatic-speech-recognition", model, { + device: webgpu ? "webgpu" : "wasm", + // A full-precision encoder keeps WebGPU accurate; the decoder quantizes well. + dtype: webgpu ? { encoder_model: "fp32", decoder_model_merged: "q4" } : "q8", + progress_callback: reportProgress, + }); +} + +self.addEventListener("message", (event: MessageEvent) => { + const request = event.data; + if (request.type === "prepare") { + recognizer ??= loadRecognizer(request.model); + recognizer.then( + () => post({ type: "ready" }), + (error: unknown) => { + recognizer = null; + post({ type: "error", id: null, message: String(error) }); + }, + ); + return; + } + if (!recognizer) { + post({ type: "error", id: request.id, message: "The speech model is not loaded." }); + return; + } + void recognizer + .then((recognize) => recognize(request.audio, { chunk_length_s: 30, stride_length_s: 5 })) + .then( + (output) => { + const text = (Array.isArray(output) ? output : [output]).map((part) => part.text).join(""); + post({ type: "transcript", id: request.id, text: text.trim() }); + }, + (error: unknown) => post({ type: "error", id: request.id, message: String(error) }), + ); +}); diff --git a/apps/web/src/voiceInput/whisperTranscriber.ts b/apps/web/src/voiceInput/whisperTranscriber.ts new file mode 100644 index 0000000000000..da211e9701a08 --- /dev/null +++ b/apps/web/src/voiceInput/whisperTranscriber.ts @@ -0,0 +1,126 @@ +import { + VoiceTranscriptionError, + throwIfVoiceTranscriptionAborted, + type VoiceTranscriber, +} from "@t3tools/client-runtime/voice-input"; + +import type { WhisperWorkerRequest, WhisperWorkerResponse } from "./whisper.worker"; + +// Multilingual and about 100 MB on first use. The browser caches it, so later +// sessions load it from disk. Any Whisper ONNX export on Hugging Face works here. +const WHISPER_MODEL_ID = "onnx-community/whisper-base"; +const WHISPER_SAMPLE_RATE = 16_000; + +type PendingTranscript = { + readonly resolve: (text: string) => void; + readonly reject: (error: Error) => void; +}; + +let worker: Worker | null = null; +let ready: PromiseWithResolvers | null = null; +let nextRequestId = 0; +const pendingTranscripts = new Map(); +let downloadProgress: number | null = null; +const downloadListeners = new Set<() => void>(); + +export function subscribeToWhisperModelDownload(listener: () => void): () => void { + downloadListeners.add(listener); + return () => downloadListeners.delete(listener); +} + +/** Model download progress from 0 to 1, or `null` when nothing is downloading. */ +export function getWhisperModelDownloadProgress(): number | null { + return downloadProgress; +} + +function notifyDownload(fraction: number | null) { + // Downloads report thousands of byte updates; the composer only shows whole percents. + const rounded = fraction === null ? null : Math.floor(fraction * 100) / 100; + if (rounded === downloadProgress) return; + downloadProgress = rounded; + for (const listener of downloadListeners) listener(); +} + +function handleWorkerMessage(event: MessageEvent) { + const message = event.data; + switch (message.type) { + case "progress": + if (message.total > 0) notifyDownload(message.loaded / message.total); + return; + case "ready": + notifyDownload(null); + ready?.resolve(); + return; + case "transcript": + pendingTranscripts.get(message.id)?.resolve(message.text); + pendingTranscripts.delete(message.id); + return; + case "error": { + const error = new Error(message.message); + if (message.id === null) { + notifyDownload(null); + ready?.reject(error); + ready = null; + return; + } + pendingTranscripts.get(message.id)?.reject(error); + pendingTranscripts.delete(message.id); + } + } +} + +function postToWorker(request: WhisperWorkerRequest, transfer: Transferable[] = []) { + if (!worker) { + worker = new Worker(new URL("./whisper.worker.ts", import.meta.url), { type: "module" }); + worker.addEventListener("message", handleWorkerMessage); + } + worker.postMessage(request, transfer); +} + +async function decodeRecording(uri: string): Promise { + const bytes = await fetch(uri).then((response) => response.arrayBuffer()); + // Decoding through a 16 kHz context resamples to the rate Whisper expects. + const audio = await new OfflineAudioContext(1, 1, WHISPER_SAMPLE_RATE).decodeAudioData(bytes); + return audio.getChannelData(0).slice(); +} + +export const whisperTranscriber: VoiceTranscriber = { + prepare: async ({ signal }) => { + if (!ready) { + ready = Promise.withResolvers(); + postToWorker({ type: "prepare", model: WHISPER_MODEL_ID }); + } + try { + await ready.promise; + } catch (cause) { + throw new VoiceTranscriptionError("preparation-failed", "Could not load the speech model.", { + cause, + }); + } + throwIfVoiceTranscriptionAborted(signal); + return { + // Whisper detects the spoken language; the locale only steers spacing at the insertion point. + locale: navigator.language, + transcribe: async (uri, options) => { + try { + const audio = await decodeRecording(uri); + throwIfVoiceTranscriptionAborted(options.signal); + const id = ++nextRequestId; + const text = await new Promise((resolve, reject) => { + pendingTranscripts.set(id, { resolve, reject }); + postToWorker({ type: "transcribe", id, audio }, [audio.buffer]); + }); + throwIfVoiceTranscriptionAborted(options.signal); + return text; + } catch (cause) { + if (cause instanceof VoiceTranscriptionError) throw cause; + throw new VoiceTranscriptionError( + "transcription-failed", + "Could not transcribe this recording.", + { cause }, + ); + } + }, + }; + }, +}; diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index b9cd3ad6b5e47..16c501a4cff5c 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -7,7 +7,7 @@ "erasableSyntaxOnly": false, "verbatimModuleSyntax": false, "jsx": "react-jsx", - "lib": ["ES2023", "ESNext.Disposable", "DOM", "DOM.Iterable"], + "lib": ["ES2023", "ES2024.Promise", "ESNext.Disposable", "DOM", "DOM.Iterable"], "paths": { "~/*": ["./src/*"] }, diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index da07814b29f6a..755499efebe7e 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -50,6 +50,7 @@ const configuredDesktopUpdateRepository = process.env.GITHUB_REPOSITORY?.trim() || ""; const configuredFeatureSecrets = process.env.T3CODE_FEATURE_SECRETS?.trim() || ""; +const configuredFeatureVoiceInput = process.env.T3CODE_FEATURE_VOICE_INPUT?.trim() || ""; const configuredHostedAppUrl = (() => { const explicitHostedAppUrl = process.env.VITE_HOSTED_APP_URL?.trim(); if (explicitHostedAppUrl) { @@ -288,6 +289,7 @@ export default defineConfig(() => { include: [ "@clerk/clerk-js", "@clerk/react/internal", + "@huggingface/transformers", "@pierre/diffs", "@pierre/diffs/edit", "@pierre/diffs/react", @@ -318,6 +320,7 @@ export default defineConfig(() => { configuredDesktopUpdateRepository, ), "import.meta.env.T3CODE_FEATURE_SECRETS": JSON.stringify(configuredFeatureSecrets), + "import.meta.env.T3CODE_FEATURE_VOICE_INPUT": JSON.stringify(configuredFeatureVoiceInput), "import.meta.env.VITE_RELEASE_CHANNEL": JSON.stringify(configuredReleaseChannel), "import.meta.env.APP_VERSION": JSON.stringify(configuredAppVersion), }, diff --git a/patches/@huggingface__transformers@4.3.2.patch b/patches/@huggingface__transformers@4.3.2.patch new file mode 100644 index 0000000000000..2e308f3eac384 --- /dev/null +++ b/patches/@huggingface__transformers@4.3.2.patch @@ -0,0 +1,14 @@ +diff --git a/package.json b/package.json +--- a/package.json ++++ b/package.json +@@ -45,9 +45,7 @@ + "dependencies": { + "@huggingface/jinja": "^0.5.10", + "@huggingface/tokenizers": "^0.2.0", +- "onnxruntime-node": "1.30.0", +- "onnxruntime-web": "1.31.0-dev.20260914-8d85527a0", +- "sharp": "^0.35.4" ++ "onnxruntime-web": "1.31.0-dev.20260914-8d85527a0" + }, + "devDependencies": { + "@types/jest": "^30.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 196781c388b03..aaeeda42e8940 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -275,6 +275,9 @@ overrides: expo-sharing: 58.0.19 expo-widgets: 58.0.20 '@ff-labs/fff-node': 0.11.0 + '@huggingface/transformers': 4.3.2 + '@huggingface/transformers>onnxruntime-node': '-' + '@huggingface/transformers>sharp': '-' '@legendapp/list': 3.3.5 '@pierre/diffs': 1.6.1 '@react-native-ai/apple': 0.12.0 @@ -363,6 +366,7 @@ patchedDependencies: '@expo/metro-config@58.0.14': 90fa980e8b6480631fb2fbb04559834e3c612db40c550cd828f11be297d8d760 '@expo/ui@58.0.20': 64559cb60723e19a8a72256d4c78d1315d937a7af3b32d19860ea596f88736ce '@ff-labs/fff-node@0.11.0': cc71fcec015f4d39bc96ae2e2bf6b0ca678124c722c66a7841efce9d34b5983c + '@huggingface/transformers@4.3.2': d7084eadb2249ce1a32e613c823581674292c37ea7ec9174a7e6467abc3ea654 '@legendapp/list@3.3.5': 6cbdacd8c380d9a5afb9f73d4198dc2cc44be6ef28a955b1183c781469307896 '@muse-code/sdk@1.4.6': 7b495b607fc5d76b444c7c4d58821e839726a30e6f3c53564f0d59f2d5b42101 '@pierre/diffs@1.6.1': 4645364ddf113e48e8827f3b4966b3b1ff745317011e5a3d904e2d8672dee7dc @@ -1039,6 +1043,9 @@ importers: '@fontsource-variable/inter': specifier: ^5.3.0 version: 5.3.0 + '@huggingface/transformers': + specifier: 4.3.2 + version: 4.3.2(patch_hash=d7084eadb2249ce1a32e613c823581674292c37ea7ec9174a7e6467abc3ea654) '@legendapp/list': specifier: 3.3.5 version: 3.3.5(patch_hash=6cbdacd8c380d9a5afb9f73d4198dc2cc44be6ef28a955b1183c781469307896)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0) @@ -4323,6 +4330,16 @@ packages: peerDependencies: hono: ^4 + '@huggingface/jinja@0.5.11': + resolution: {integrity: sha512-YzEzwM5oQf4r0vs7ifWQ+yuVR1YkAHrjERQ+a8WRsStHHp4NRBg+NesjiFc+X2AFUpRvvrIeHDS1xFy9jY/IjQ==} + engines: {node: '>=18'} + + '@huggingface/tokenizers@0.2.0': + resolution: {integrity: sha512-LidMHe1FpcSYH4vcSjXooda34pC0M8m1gmDOv7SQi6Iv+ib1zX7J3sHBCC9/3FPCkn2k1b55FneVqMRxrr99pg==} + + '@huggingface/transformers@4.3.2': + resolution: {integrity: sha512-V3+dqf3iWlRYJ9I9GreM3zGQd0lAXnnoPeddmkOQYWAEE4l/+Fi6p7tx/qVUJlKQgLXGim2W76rTOzz+eC0i7g==} + '@iarna/toml@2.2.5': resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} @@ -5924,6 +5941,33 @@ packages: '@polka/url@1.0.0-next.29': resolution: {integrity: sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==} + '@protobufjs/aspromise@1.1.2': + resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} + + '@protobufjs/base64@1.1.2': + resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==} + + '@protobufjs/codegen@2.0.5': + resolution: {integrity: sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g==} + + '@protobufjs/eventemitter@1.1.1': + resolution: {integrity: sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg==} + + '@protobufjs/fetch@1.1.1': + resolution: {integrity: sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw==} + + '@protobufjs/float@1.0.2': + resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==} + + '@protobufjs/path@1.1.2': + resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==} + + '@protobufjs/pool@1.1.0': + resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==} + + '@protobufjs/utf8@1.1.2': + resolution: {integrity: sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==} + '@puppeteer/browsers@3.2.6': resolution: {integrity: sha512-MJP29gVoHznmqmwhH1tlZqzfeQ3aylTpSSa6WKZXtkwYUH02i9imBmWGTyZrbnAou5paX78SE4jMAUqnEPf8ug==} engines: {node: '>=22.12.0'} @@ -9037,6 +9081,9 @@ packages: resolution: {integrity: sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==} engines: {node: '>=6'} + flatbuffers@25.9.23: + resolution: {integrity: sha512-MI1qs7Lo4Syw0EOzUl0xjs2lsoeqFku44KpngfIduHBYvzm8h2+7K8YMQh1JtVVVrUvhLpNwqVi4DERegUJhPQ==} + flatted@3.4.4: resolution: {integrity: sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==} @@ -9206,6 +9253,9 @@ packages: resolution: {integrity: sha512-cQOsSMS/IrDz82PVyRDvf/Q1F/bRbBVjJlh+xYOkI1qw2bWRvWGiWc+m2O0d6l4Bt1fyY+8kzJ8JFWGJqNeDBg==} engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} + guid-typescript@1.0.9: + resolution: {integrity: sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ==} + h3@1.15.11: resolution: {integrity: sha512-L3THSe2MPeBwgIZVSH5zLdBBU90TOxarvhK9d04IDY2AmVS8j2Jz2LIWtwsGOU3lu2I5jCN7FNvVfY2+XyF+mg==} @@ -9726,6 +9776,9 @@ packages: long@4.0.0: resolution: {integrity: sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==} + long@5.3.2: + resolution: {integrity: sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==} + longest-streak@3.1.0: resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==} @@ -10338,6 +10391,12 @@ packages: oniguruma-to-es@4.3.6: resolution: {integrity: sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==} + onnxruntime-common@1.31.0-dev.20260911-2a43ec07e: + resolution: {integrity: sha512-gBuF6U32YErKIAt+yD7DeGBpjRxhJ1uJwako6ygjokSZULDU6Pd+KWComX8Tumk1hYVHRxjPj7mdMnD0ryAPOw==} + + onnxruntime-web@1.31.0-dev.20260914-8d85527a0: + resolution: {integrity: sha512-Iy7rtadoBgxS/LLvDr3QW38DB1PNXRnr0GJMcL0TAt7c9qjgVQl83UlGCVyeAnK2InpmW8Uc3PL8XIuqtDeF6g==} + open@8.4.2: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} engines: {node: '>=12'} @@ -10572,6 +10631,9 @@ packages: resolution: {integrity: sha512-emEcLuomt2j03vxD54giVB4SxTjnsqkU692xZOZXHDVoYyypEm+b3jpiTcc+Cf+myooc+/Ly0z01jqeNHVgJGw==} engines: {node: '>=16.0.0'} + platform@1.3.6: + resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==} + playwright-core@1.60.0: resolution: {integrity: sha512-9bW6zvX/m0lEbgTKJ6YppOKx8H3VOPBMOCFh2irXFOT4BbHgrx5hPjwJYLT40Lu+4qtD36qKc/Hn56StUW57IA==} engines: {node: '>=18'} @@ -10733,6 +10795,10 @@ packages: prosemirror-view@1.42.3: resolution: {integrity: sha512-oTN7EtH+CpwxU9NrwEYWd0UZ4JUx7l048l5A2Xppm4p/60isZYLnth9QVQmC3VRIvdrIWCxwZSd+Uz791G31/w==} + protobufjs@7.6.6: + resolution: {integrity: sha512-dYDWdjSl5RNb7SgPxGQcRU+GtvP7s2fpkrY0r432PcOIaZ0/rBcxEZnQN67iJhFuQiVw754JDoPruPCNdGsbjg==} + engines: {node: '>=12.0.0'} + proxy-addr@2.0.7: resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} engines: {node: '>= 0.10'} @@ -14433,6 +14499,16 @@ snapshots: dependencies: hono: 4.13.7 + '@huggingface/jinja@0.5.11': {} + + '@huggingface/tokenizers@0.2.0': {} + + '@huggingface/transformers@4.3.2(patch_hash=d7084eadb2249ce1a32e613c823581674292c37ea7ec9174a7e6467abc3ea654)': + dependencies: + '@huggingface/jinja': 0.5.11 + '@huggingface/tokenizers': 0.2.0 + onnxruntime-web: 1.31.0-dev.20260914-8d85527a0 + '@iarna/toml@2.2.5': {} '@img/colour@1.1.0': {} @@ -15481,6 +15557,26 @@ snapshots: '@polka/url@1.0.0-next.29': {} + '@protobufjs/aspromise@1.1.2': {} + + '@protobufjs/base64@1.1.2': {} + + '@protobufjs/codegen@2.0.5': {} + + '@protobufjs/eventemitter@1.1.1': {} + + '@protobufjs/fetch@1.1.1': + dependencies: + '@protobufjs/aspromise': 1.1.2 + + '@protobufjs/float@1.0.2': {} + + '@protobufjs/path@1.1.2': {} + + '@protobufjs/pool@1.1.0': {} + + '@protobufjs/utf8@1.1.2': {} + '@puppeteer/browsers@3.2.6(yauzl@3.4.0)': dependencies: modern-tar: 0.8.6 @@ -18799,6 +18895,8 @@ snapshots: dependencies: locate-path: 3.0.0 + flatbuffers@25.9.23: {} + flatted@3.4.4: {} flattie@1.1.1: {} @@ -18986,6 +19084,8 @@ snapshots: graphql@16.14.1: {} + guid-typescript@1.0.9: {} + h3@1.15.11: dependencies: cookie-es: 1.2.3 @@ -19542,6 +19642,8 @@ snapshots: long@4.0.0: {} + long@5.3.2: {} + longest-streak@3.1.0: {} loose-envify@1.4.0: @@ -20459,6 +20561,17 @@ snapshots: regex: 6.1.0 regex-recursion: 6.0.2 + onnxruntime-common@1.31.0-dev.20260911-2a43ec07e: {} + + onnxruntime-web@1.31.0-dev.20260914-8d85527a0: + dependencies: + flatbuffers: 25.9.23 + guid-typescript: 1.0.9 + long: 5.3.2 + onnxruntime-common: 1.31.0-dev.20260911-2a43ec07e + platform: 1.3.6 + protobufjs: 7.6.6 + open@8.4.2: dependencies: define-lazy-prop: 2.0.0 @@ -20798,6 +20911,8 @@ snapshots: pvutils: 1.1.5 tslib: 2.8.1 + platform@1.3.6: {} + playwright-core@1.60.0: {} playwright@1.60.0: @@ -20987,6 +21102,20 @@ snapshots: prosemirror-state: 1.4.4 prosemirror-transform: 1.12.1 + protobufjs@7.6.6: + dependencies: + '@protobufjs/aspromise': 1.1.2 + '@protobufjs/base64': 1.1.2 + '@protobufjs/codegen': 2.0.5 + '@protobufjs/eventemitter': 1.1.1 + '@protobufjs/fetch': 1.1.1 + '@protobufjs/float': 1.0.2 + '@protobufjs/path': 1.1.2 + '@protobufjs/pool': 1.1.0 + '@protobufjs/utf8': 1.1.2 + '@types/node': 24.12.4 + long: 5.3.2 + proxy-addr@2.0.7: dependencies: forwarded: 0.2.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index acd8c742f836a..48351bfa84d0b 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -23,6 +23,8 @@ allowBuilds: node-pty: true # Ships N-API prebuilds; its install script only rebuilds from source. objc-js: false + # Its postinstall only warns about protobufjs version schemes. + protobufjs: false "react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz": true sharp: true "@tsc-rs/typescript": true @@ -241,6 +243,11 @@ overrides: expo-sharing: 58.0.19 expo-widgets: 58.0.20 "@ff-labs/fff-node": 0.11.0 + "@huggingface/transformers": 4.3.2 + # The web client runs Whisper on onnxruntime-web; it never loads the Node runtime or sharp. + # The patch drops them from the manifest too, so license notices don't list them. + "@huggingface/transformers>onnxruntime-node": "-" + "@huggingface/transformers>sharp": "-" "@legendapp/list": 3.3.5 "@pierre/diffs": 1.6.1 "@react-native-ai/apple": 0.12.0 @@ -367,6 +374,8 @@ patchedDependencies: expo-sharing@58.0.19: patches/expo-sharing@58.0.19.patch expo-widgets@58.0.20: patches/expo-widgets@58.0.20.patch "@ff-labs/fff-node@0.11.0": patches/@ff-labs__fff-node@0.11.0.patch + # See the @huggingface/transformers overrides. + "@huggingface/transformers@4.3.2": patches/@huggingface__transformers@4.3.2.patch "@legendapp/list@3.3.5": patches/@legendapp__list@3.3.5.patch # Exports the dependency-light subpaths mobile and the web diff parser import, and keeps # measured wrapped-row heights above an edit (fileEditorVirtualization.test.ts). diff --git a/third-party-licenses.config.json b/third-party-licenses.config.json index e6d38a17e2d87..65f3c91484948 100644 --- a/third-party-licenses.config.json +++ b/third-party-licenses.config.json @@ -229,6 +229,35 @@ } ], "packageOverrides": [ + { + "name": "onnxruntime-web", + "version": "1.31.0-dev.20260914-8d85527a0", + "license": "MIT", + "sourceUrl": "https://github.com/microsoft/onnxruntime", + "generatedNotice": { + "licenseId": "MIT", + "copyrights": ["Copyright (c) Microsoft Corporation"] + } + }, + { + "name": "onnxruntime-common", + "version": "1.31.0-dev.20260911-2a43ec07e", + "license": "MIT", + "sourceUrl": "https://github.com/microsoft/onnxruntime", + "generatedNotice": { + "licenseId": "MIT", + "copyrights": ["Copyright (c) Microsoft Corporation"] + } + }, + { + "name": "guid-typescript", + "version": "1.0.9", + "license": "ISC", + "sourceUrl": "https://github.com/NicolasDeveloper/guid-typescript", + "generatedNotice": { + "licenseId": "ISC" + } + }, { "name": "entities", "version": "8.1.0",