Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

Merge branch 'main' into feat/managed-enterprise-ai

Gabriel Stein897e8613913a
diff --cc src/helpers/audioManager.js
index 077ef14f4,71f1f6fbb..3b31ff803
--- a/src/helpers/audioManager.js
+++ b/src/helpers/audioManager.js
@@@ -129,10 -124,8 +125,9 @@@ function resolveReasoningRoute
voiceAgentRequested,
translationRequested
) {
+ const cleanup = selectResolvedLLMConfig(settings, "dictationCleanup");
- const translation = selectResolvedLLMConfig(settings, "dictationTranslation");
const cleanupReachable =
- !!settings.useCleanupModel && (!!settings.cleanupModel?.trim() || isCloudCleanupMode());
+ !!settings.useCleanupModel && (!!cleanup.model?.trim() || isCloudCleanupMode());
const agent = resolveDictationAgentInference(settings, {
isCloudAgent: isCloudDictationAgentMode(),
});
@@@ -168,27 -154,13 +156,16 @@@
);
}
if (kind === "translation") {
- const provider = isCloudTranslation ? "openwhispr" : translation.provider?.trim() || undefined;
- const isCustomTranslation = translation.mode === "providers" && provider === "custom";
return {
kind: "translation",
- model: translation.model?.trim() || "",
+ model: translation.model,
cleanupReachable,
- cleanupConfig: { disableThinking: settings.cleanupDisableThinking },
+ cleanupConfig: {
+ inferenceScope: /** @type {const} */ ("dictationCleanup"),
+ disableThinking: settings.cleanupDisableThinking,
+ },
config: {
- inferenceScope: /** @type {const} */ ("dictationTranslation"),
- provider,
- language: settings.translationTargetLanguage,
- lanUrl: isSelfHostedTranslation ? translation.remoteUrl : undefined,
- baseUrl: isCustomTranslation ? translation.cloudBaseUrl || undefined : undefined,
- customApiKey:
- isCustomTranslation || isSelfHostedTranslation
- ? settings.translationCustomApiKey || undefined
- : undefined,
- disableThinking: settings.translationDisableThinking,
+ ...translation.config,
systemPrompt: resolvePrompt("translate", {
agentName,
targetLanguageLabel: getLanguageLabel(settings.translationTargetLanguage),
diff --cc src/helpers/dictationAgentInference.js
index 30a959c1a,3ddb01ecd..ce0e8f38e
--- a/src/helpers/dictationAgentInference.js
+++ b/src/helpers/dictationAgentInference.js
@@@ -2,7 -3,7 +3,8 @@@ import
resolveDictationAgentProvider,
resolveDictationAgentReachability,
} from "./dictationRouting.js";
+ import { isProviderValidForMode } from "../models/ModelRegistry";
+import { getManagedScopeResolution } from "../stores/enterpriseIdentityStore";
// The dictation agent's inference scope, shared by the dictation route in
// audioManager and the Prompt Studio test tab so a prompt test hits the same
@@@ -12,18 -13,6 +14,19 @@@
// missing one as its cleanup path, which echoes the input back instead of
// running the instruction.
export function resolveDictationAgentInference(settings, { isCloudAgent = false } = {}) {
+ const managed = getManagedScopeResolution("dictationAgent", settings.enterpriseSetupMode);
+ if (managed.kind === "managed") {
+ return {
+ reachable: settings.useDictationAgent,
+ model: managed.model,
++ displayProvider: managed.provider,
+ config: {
+ inferenceScope: /** @type {const} */ ("dictationAgent"),
+ provider: managed.provider,
+ disableThinking: settings.dictationAgentDisableThinking,
+ },
+ };
+ }
const model = settings.dictationAgentModel?.trim() || "";
const isSelfHosted =
settings.dictationAgentMode === "self-hosted" && !!settings.dictationAgentRemoteUrl?.trim();
@@@ -42,8 -37,11 +51,12 @@@
isSelfHostedAgent: isSelfHosted,
}),
model,
+ displayProvider: resolveDictationAgentDisplayProvider({
+ dictationAgentMode: settings.dictationAgentMode,
+ dictationAgentProvider: providerForMode,
+ }),
config: {
+ inferenceScope: /** @type {const} */ ("dictationAgent"),
provider,
lanUrl: isSelfHosted ? settings.dictationAgentRemoteUrl : undefined,
baseUrl: isCustom ? settings.dictationAgentCloudBaseUrl || undefined : undefined,
diff --cc src/helpers/dictationTranslationInference.js
index 000000000,a41fadee7..e2e5c558c
mode 000000,100644..100644
--- a/src/helpers/dictationTranslationInference.js
+++ b/src/helpers/dictationTranslationInference.js
@@@ -1,0 -1,51 +1,70 @@@
+ import {
+ resolveDictationTranslationReachability,
+ resolveTranslationDisplayProvider,
+ resolveTranslationProviderId,
+ } from "./dictationRouting.js";
+ import { isProviderValidForMode } from "../models/ModelRegistry";
++import { getManagedScopeResolution } from "../stores/enterpriseIdentityStore";
+
+ // Shared by live dictation and Prompt Studio so both translation entry points
+ // use the same provider, endpoint, and credentials.
+ export function resolveDictationTranslationInference(
+ settings,
+ { isCloudTranslation = false } = {}
+ ) {
++ const managed = getManagedScopeResolution("dictationTranslation", settings.enterpriseSetupMode);
++ if (managed.kind === "managed") {
++ return {
++ reachable: Boolean(
++ settings.useDictationTranslation && settings.translationTargetLanguage?.trim()
++ ),
++ model: managed.model,
++ displayProvider: managed.provider,
++ config: {
++ inferenceScope: /** @type {const} */ ("dictationTranslation"),
++ provider: managed.provider,
++ language: settings.translationTargetLanguage,
++ disableThinking: settings.translationDisableThinking,
++ },
++ };
++ }
++
+ const mode = settings.translationMode;
+ const model = settings.translationModel?.trim() || "";
+ const storedProvider = settings.translationProvider?.trim() || "";
+ const providerForMode = isProviderValidForMode(storedProvider, mode) ? storedProvider : undefined;
+ const provider = resolveTranslationProviderId({
+ isCloudTranslation,
+ translationMode: mode,
+ translationProvider: providerForMode,
+ });
+ const isSelfHosted = mode === "self-hosted" && !!settings.translationRemoteUrl?.trim();
+ const isCustom = mode === "providers" && provider === "custom";
+
+ return {
+ reachable: resolveDictationTranslationReachability({
+ useDictationTranslation: settings.useDictationTranslation,
+ translationTargetLanguage: settings.translationTargetLanguage,
+ translationMode: mode,
+ translationProvider: provider,
+ translationModel: model,
+ isCloudTranslation,
+ isSelfHostedTranslation: isSelfHosted,
+ }),
+ model,
+ displayProvider: resolveTranslationDisplayProvider({
+ translationMode: mode,
+ translationProvider: providerForMode,
+ }),
+ config: {
++ inferenceScope: /** @type {const} */ ("dictationTranslation"),
+ provider,
+ language: settings.translationTargetLanguage,
+ lanUrl: isSelfHosted ? settings.translationRemoteUrl : undefined,
+ baseUrl: isCustom ? settings.translationCloudBaseUrl || undefined : undefined,
+ customApiKey:
+ isCustom || isSelfHosted ? settings.translationCustomApiKey || undefined : undefined,
+ disableThinking: settings.translationDisableThinking,
+ },
+ };
+ }
diff --cc test/helpers/dictationTranslationInference.test.js
index 000000000,24b5f9a75..b4c787b35
mode 000000,100644..100644
--- a/test/helpers/dictationTranslationInference.test.js
+++ b/test/helpers/dictationTranslationInference.test.js
@@@ -1,0 -1,170 +1,232 @@@
+ const test = require("node:test");
+ const assert = require("node:assert/strict");
+
+ const load = () => import("../../src/helpers/dictationTranslationInference.js");
+
+ const baseSettings = {
+ useDictationTranslation: true,
+ translationTargetLanguage: "es",
+ translationMode: "providers",
+ translationProvider: "openai",
+ translationModel: "gpt-5-mini",
+ translationRemoteUrl: "",
+ translationCloudBaseUrl: "",
+ translationCustomApiKey: "",
+ translationDisableThinking: true,
+ };
+
+ test("providers mode keeps its explicit provider and translation settings", async () => {
+ const { resolveDictationTranslationInference } = await load();
+
+ const result = resolveDictationTranslationInference(baseSettings);
+
+ assert.equal(result.reachable, true);
+ assert.equal(result.model, "gpt-5-mini");
+ assert.equal(result.config.provider, "openai");
+ assert.equal(result.config.language, "es");
+ assert.equal(result.config.disableThinking, true);
+ });
+
+ test("local mode routes to llama.cpp with an empty stored provider", async () => {
+ const { resolveDictationTranslationInference } = await load();
+
+ const result = resolveDictationTranslationInference({
+ ...baseSettings,
+ translationMode: "local",
+ translationProvider: "",
+ translationModel: "qwen2.5-coder",
+ });
+
+ assert.equal(result.reachable, true);
+ assert.equal(result.displayProvider, "local");
+ assert.equal(result.config.provider, "local");
+ });
+
+ test("local mode ignores a stale cloud provider", async () => {
+ const { resolveDictationTranslationInference } = await load();
+
+ const result = resolveDictationTranslationInference({
+ ...baseSettings,
+ translationMode: "local",
+ translationProvider: "openai",
+ translationModel: "qwen2.5-coder",
+ });
+
+ assert.equal(result.config.provider, "local");
+ });
+
+ test("self-hosted mode routes only through its configured endpoint", async () => {
+ const { resolveDictationTranslationInference } = await load();
+
+ const result = resolveDictationTranslationInference({
+ ...baseSettings,
+ translationMode: "self-hosted",
+ translationProvider: "openai",
+ translationModel: "",
+ translationRemoteUrl: "http://127.0.0.1:8080/v1",
+ translationCustomApiKey: "lan-key",
+ });
+
+ assert.equal(result.reachable, true);
+ assert.equal(result.displayProvider, "self-hosted");
+ assert.equal(result.config.provider, undefined);
+ assert.equal(result.config.lanUrl, "http://127.0.0.1:8080/v1");
+ assert.equal(result.config.customApiKey, "lan-key");
+ });
+
+ test("self-hosted mode without an endpoint never falls through to cloud inference", async () => {
+ const { resolveDictationTranslationInference } = await load();
+
+ const result = resolveDictationTranslationInference({
+ ...baseSettings,
+ translationMode: "self-hosted",
+ translationProvider: "openai",
+ translationRemoteUrl: "",
+ });
+
+ assert.equal(result.reachable, false);
+ assert.equal(result.config.provider, undefined);
+ assert.equal(result.config.lanUrl, undefined);
+ });
+
+ test("available managed mode resolves OpenWhispr without requiring a model", async () => {
+ const { resolveDictationTranslationInference } = await load();
+
+ const result = resolveDictationTranslationInference(
+ {
+ ...baseSettings,
+ translationMode: "openwhispr",
+ translationModel: "",
+ },
+ { isCloudTranslation: true }
+ );
+
+ assert.equal(result.reachable, true);
+ assert.equal(result.displayProvider, "openwhispr");
+ assert.equal(result.config.provider, "openwhispr");
+ });
+
+ test("managed mode never falls through to a stale provider when signed out", async () => {
+ const { resolveDictationTranslationInference } = await load();
+
+ const result = resolveDictationTranslationInference({
+ ...baseSettings,
+ translationMode: "openwhispr",
+ translationProvider: "openai",
+ });
+
+ assert.equal(result.reachable, false);
+ assert.equal(result.displayProvider, "openwhispr");
+ assert.equal(result.config.provider, undefined);
+ });
+
+ test("provider mode rejects a stale local catalog provider", async () => {
+ const { resolveDictationTranslationInference } = await load();
+
+ const result = resolveDictationTranslationInference({
+ ...baseSettings,
+ translationProvider: "qwen",
+ translationModel: "qwen2.5-coder",
+ });
+
+ assert.equal(result.reachable, false);
+ assert.equal(result.displayProvider, "none");
+ assert.equal(result.config.provider, undefined);
+ });
+
+ test("custom provider credentials stay scoped to custom mode", async () => {
+ const { resolveDictationTranslationInference } = await load();
+
+ const custom = resolveDictationTranslationInference({
+ ...baseSettings,
+ translationProvider: "custom",
+ translationCloudBaseUrl: "https://example.test/v1",
+ translationCustomApiKey: "secret",
+ });
+ const openai = resolveDictationTranslationInference({
+ ...baseSettings,
+ translationCloudBaseUrl: "https://example.test/v1",
+ translationCustomApiKey: "secret",
+ });
+
+ assert.equal(custom.config.baseUrl, "https://example.test/v1");
+ assert.equal(custom.config.customApiKey, "secret");
+ assert.equal(openai.config.baseUrl, undefined);
+ assert.equal(openai.config.customApiKey, undefined);
+ });
+
+ test("enterprise mode without a provider fails closed", async () => {
+ const { resolveDictationTranslationInference } = await load();
+
+ const result = resolveDictationTranslationInference({
+ ...baseSettings,
+ translationMode: "enterprise",
+ translationProvider: "",
+ translationModel: "anthropic.claude-sonnet-4",
+ });
+
+ assert.equal(result.reachable, false);
+ assert.equal(result.config.provider, undefined);
+ });
++
++test("managed enterprise access supplies the provider and model, ignoring manual settings", async (t) => {
++ const { resolveDictationTranslationInference } = await load();
++ const { useEnterpriseIdentityStore } = await import(
++ "../../src/stores/enterpriseIdentityStore.ts"
++ );
++
++ const scopes = [
++ "dictationCleanup",
++ "dictationAgent",
++ "noteFormatting",
++ "chatIntelligence",
++ "dictationTranslation",
++ ];
++ useEnterpriseIdentityStore.setState({
++ status: "ready",
++ config: {
++ workspaceId: "workspace-a",
++ version: 1,
++ identity: {
++ issuer: "https://api.example.com/enterprise-identity",
++ jwksUri: "https://api.example.com/enterprise-identity/jwks.json",
++ subject: "workspace:workspace-a",
++ audiences: { bedrock: "sts.amazonaws.com", azure: "api://AzureADTokenExchange" },
++ },
++ providers: [
++ {
++ provider: "bedrock",
++ mode: "managed_required",
++ allowManualSetup: false,
++ config: {
++ roleArn: "arn:aws:iam::123456789012:role/OpenWhispr",
++ region: "us-east-1",
++ allowedModels: ["managed-model"],
++ scopeDefaults: Object.fromEntries(scopes.map((scope) => [scope, "managed-model"])),
++ },
++ version: 1,
++ updatedAt: "2026-08-10T00:00:00.000Z",
++ },
++ ],
++ },
++ });
++ t.after(() => useEnterpriseIdentityStore.setState({ status: "idle", config: null }));
++
++ // A stale self-hosted endpoint and key must not leak into a managed request.
++ const result = resolveDictationTranslationInference({
++ ...baseSettings,
++ enterpriseSetupMode: "auto",
++ translationMode: "self-hosted",
++ translationRemoteUrl: "http://192.0.2.1:8080",
++ translationCustomApiKey: "secret",
++ });
++
++ assert.equal(result.reachable, true);
++ assert.equal(result.model, "managed-model");
++ assert.equal(result.displayProvider, "bedrock");
++ assert.equal(result.config.provider, "bedrock");
++ assert.equal(result.config.inferenceScope, "dictationTranslation");
++ assert.equal(result.config.language, "es");
++ assert.equal(result.config.lanUrl, undefined);
++ assert.equal(result.config.customApiKey, undefined);
++});