refactor: update goose2 credential management behind provider-scoped ACP/core API (#8887)
Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com> Co-authored-by: morgmart <98432065+morgmart@users.noreply.github.com>
This commit is contained in:
@@ -2,11 +2,13 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import {
|
||||
cancelDictationLocalModelDownload,
|
||||
deleteDictationLocalModel,
|
||||
deleteDictationProviderSecret,
|
||||
downloadDictationLocalModel,
|
||||
getDictationConfig,
|
||||
getDictationLocalModelDownloadProgress,
|
||||
listDictationLocalModels,
|
||||
saveDictationModelSelection,
|
||||
saveDictationProviderSecret,
|
||||
transcribeDictation,
|
||||
} from "../dictation";
|
||||
import { getClient } from "../acpConnection";
|
||||
@@ -67,6 +69,23 @@ describe("dictation SDK wiring", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("saveDictationProviderSecret calls GooseSecretUpsert", async () => {
|
||||
client.goose.GooseSecretUpsert = vi.fn().mockResolvedValue({});
|
||||
await saveDictationProviderSecret("groq", "gsk-test", "GROQ_API_KEY");
|
||||
expect(client.goose.GooseSecretUpsert).toHaveBeenCalledWith({
|
||||
key: "GROQ_API_KEY",
|
||||
value: "gsk-test",
|
||||
});
|
||||
});
|
||||
|
||||
it("deleteDictationProviderSecret calls GooseSecretRemove", async () => {
|
||||
client.goose.GooseSecretRemove = vi.fn().mockResolvedValue({});
|
||||
await deleteDictationProviderSecret("groq", "GROQ_API_KEY");
|
||||
expect(client.goose.GooseSecretRemove).toHaveBeenCalledWith({
|
||||
key: "GROQ_API_KEY",
|
||||
});
|
||||
});
|
||||
|
||||
it("listDictationLocalModels returns the models array", async () => {
|
||||
client.goose.GooseDictationModelsList = vi.fn().mockResolvedValue({
|
||||
models: [
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import type {
|
||||
DictationDownloadProgress,
|
||||
DictationProvider,
|
||||
@@ -48,22 +47,19 @@ export async function saveDictationProviderSecret(
|
||||
if (!configKey) {
|
||||
throw new Error("No config key for this provider");
|
||||
}
|
||||
return invoke("save_provider_field", { key: configKey, value });
|
||||
const client = await getClient();
|
||||
await client.goose.GooseSecretUpsert({ key: configKey, value });
|
||||
}
|
||||
|
||||
export async function deleteDictationProviderSecret(
|
||||
provider: DictationProvider,
|
||||
_configKey?: string,
|
||||
_provider: DictationProvider,
|
||||
configKey?: string,
|
||||
): Promise<void> {
|
||||
const providerIdMap: Record<string, string> = {
|
||||
groq: "dictation_groq",
|
||||
elevenlabs: "dictation_elevenlabs",
|
||||
};
|
||||
const providerId = providerIdMap[provider];
|
||||
if (!providerId) {
|
||||
if (!configKey) {
|
||||
throw new Error("Cannot delete secrets for this provider");
|
||||
}
|
||||
return invoke("delete_provider_config", { providerId });
|
||||
const client = await getClient();
|
||||
await client.goose.GooseSecretRemove({ key: configKey });
|
||||
}
|
||||
|
||||
export async function listDictationLocalModels(): Promise<
|
||||
|
||||
@@ -220,9 +220,10 @@
|
||||
"signInLabel": "Sign in to {{name}}",
|
||||
"status": {
|
||||
"checking": "Checking...",
|
||||
"inProgress": "Setup in progress",
|
||||
"setupFailed": "Setup failed"
|
||||
},
|
||||
"title": "Agents"
|
||||
"title": "Agent harnesses"
|
||||
},
|
||||
"description": "Connect agents and AI models to use with Goose",
|
||||
"disconnect": "Disconnect",
|
||||
@@ -251,10 +252,11 @@
|
||||
"oauthTerminal": "Run `goose configure` in your terminal to finish sign-in."
|
||||
}
|
||||
},
|
||||
"checkingStatus": "Checking provider status...",
|
||||
"title": "Models"
|
||||
},
|
||||
"restartButton": "Restart now",
|
||||
"restartMessage": "Restart to apply credential changes.",
|
||||
"loadingModels": "Loading models...",
|
||||
"modelRefreshWarning": "Credentials saved. Model refresh needs attention: {{message}}",
|
||||
"saved": "Saved",
|
||||
"showFewer": "Show fewer",
|
||||
"showMore": "Show {{count}} more providers",
|
||||
|
||||
@@ -220,9 +220,10 @@
|
||||
"signInLabel": "Iniciar sesión en {{name}}",
|
||||
"status": {
|
||||
"checking": "Comprobando...",
|
||||
"inProgress": "Configuración en curso",
|
||||
"setupFailed": "La configuración falló"
|
||||
},
|
||||
"title": "Agentes"
|
||||
"title": "Arneses de agentes"
|
||||
},
|
||||
"description": "Conecta agentes y modelos de IA para usar con Goose",
|
||||
"disconnect": "Desconectar",
|
||||
@@ -251,10 +252,11 @@
|
||||
"oauthTerminal": "Ejecuta `goose configure` en tu terminal para terminar de iniciar sesión."
|
||||
}
|
||||
},
|
||||
"checkingStatus": "Comprobando estado del proveedor...",
|
||||
"title": "Modelos"
|
||||
},
|
||||
"restartButton": "Reiniciar ahora",
|
||||
"restartMessage": "Reinicia para aplicar los cambios de credenciales.",
|
||||
"loadingModels": "Cargando modelos...",
|
||||
"modelRefreshWarning": "Credenciales guardadas. La actualización de modelos necesita atención: {{message}}",
|
||||
"saved": "Guardado",
|
||||
"showFewer": "Mostrar menos",
|
||||
"showMore": "Mostrar {{count}} proveedores más",
|
||||
|
||||
Reference in New Issue
Block a user