

























@@ -461,7 +461,21 @@ describe("capability cli", () => {
461461}
462462463463function firstAudioTranscriptionCall() {
464-const calls = mocks.transcribeAudioFile.mock.calls as unknown as Array<[{ filePath?: string }]>;
464+const calls = mocks.transcribeAudioFile.mock.calls as unknown as Array<
465+[{ filePath?: string; language?: unknown; prompt?: unknown }]
466+>;
467+return calls[0]?.[0];
468+}
469+470+function firstTextToSpeechCall() {
471+const calls = mocks.textToSpeech.mock.calls as unknown as Array<[Record<string, unknown>]>;
472+return calls[0]?.[0];
473+}
474+475+function firstEmbeddingProviderCall() {
476+const calls = mocks.createEmbeddingProvider.mock.calls as unknown as Array<
477+[Record<string, unknown>]
478+>;
465479return calls[0]?.[0];
466480}
467481@@ -1692,13 +1706,10 @@ describe("capability cli", () => {
16921706],
16931707});
169417081695-expect(mocks.transcribeAudioFile).toHaveBeenCalledWith(
1696-expect.objectContaining({
1697-filePath: expect.stringMatching(/memo\.m4a$/),
1698-language: "en",
1699-prompt: "Focus on names",
1700-}),
1701-);
1709+const transcribeCall = firstAudioTranscriptionCall();
1710+expect(path.basename(transcribeCall?.filePath ?? "")).toBe("memo.m4a");
1711+expect(transcribeCall?.language).toBe("en");
1712+expect(transcribeCall?.prompt).toBe("Focus on names");
17021713});
1703171417041715it("uses request-scoped TTS overrides without mutating prefs", async () => {
@@ -1718,19 +1729,16 @@ describe("capability cli", () => {
17181729],
17191730});
172017311721-expect(mocks.textToSpeech).toHaveBeenCalledWith(
1722-expect.objectContaining({
1723-overrides: expect.objectContaining({
1724-provider: "openai",
1725-providerOverrides: expect.objectContaining({
1726-openai: expect.objectContaining({
1727-modelId: "gpt-4o-mini-tts",
1728-voiceId: "alloy",
1729-}),
1730-}),
1731-}),
1732-}),
1733-);
1732+const ttsCall = firstTextToSpeechCall();
1733+const overrides = ttsCall?.overrides as
1734+| {
1735+provider?: unknown;
1736+providerOverrides?: { openai?: { modelId?: unknown; voiceId?: unknown } };
1737+}
1738+| undefined;
1739+expect(overrides?.provider).toBe("openai");
1740+expect(overrides?.providerOverrides?.openai?.modelId).toBe("gpt-4o-mini-tts");
1741+expect(overrides?.providerOverrides?.openai?.voiceId).toBe("alloy");
17341742expect(mocks.setTtsProvider).not.toHaveBeenCalled();
17351743});
17361744@@ -1751,11 +1759,7 @@ describe("capability cli", () => {
17511759],
17521760});
175317611754-expect(mocks.textToSpeech).toHaveBeenCalledWith(
1755-expect.objectContaining({
1756-disableFallback: true,
1757-}),
1758-);
1762+expect(firstTextToSpeechCall()?.disableFallback).toBe(true);
17591763});
1760176417611765it("does not infer and forward a local provider guess for gateway TTS overrides", async () => {
@@ -1774,15 +1778,9 @@ describe("capability cli", () => {
17741778],
17751779});
177617801777-expect(mocks.callGateway).toHaveBeenCalledWith(
1778-expect.objectContaining({
1779-method: "tts.convert",
1780-params: expect.objectContaining({
1781-provider: undefined,
1782-voiceId: "alloy",
1783-}),
1784-}),
1785-);
1781+expect(firstGatewayCall()?.method).toBe("tts.convert");
1782+expect(firstGatewayCall()?.params?.provider).toBeUndefined();
1783+expect(firstGatewayCall()?.params?.voiceId).toBe("alloy");
17861784});
1787178517881786it("fails clearly when gateway TTS output is requested against a remote gateway", async () => {
@@ -1821,19 +1819,11 @@ describe("capability cli", () => {
18211819argv: ["capability", "embedding", "create", "--text", "hello", "--json"],
18221820});
182318211824-expect(mocks.createEmbeddingProvider).toHaveBeenCalledWith(
1825-expect.objectContaining({
1826-provider: "auto",
1827-fallback: "none",
1828-}),
1829-);
1830-expect(mocks.runtime.writeJson).toHaveBeenCalledWith(
1831-expect.objectContaining({
1832-capability: "embedding.create",
1833-provider: "openai",
1834-model: "text-embedding-3-small",
1835-}),
1836-);
1822+expect(firstEmbeddingProviderCall()?.provider).toBe("auto");
1823+expect(firstEmbeddingProviderCall()?.fallback).toBe("none");
1824+expect(firstJsonOutput()?.capability).toBe("embedding.create");
1825+expect(firstJsonOutput()?.provider).toBe("openai");
1826+expect(firstJsonOutput()?.model).toBe("text-embedding-3-small");
18371827});
1838182818391829it("derives the embedding provider from a provider/model override", async () => {
@@ -1851,13 +1841,9 @@ describe("capability cli", () => {
18511841],
18521842});
185318431854-expect(mocks.createEmbeddingProvider).toHaveBeenCalledWith(
1855-expect.objectContaining({
1856-provider: "openai",
1857-fallback: "none",
1858-model: "text-embedding-3-large",
1859-}),
1860-);
1844+expect(firstEmbeddingProviderCall()?.provider).toBe("openai");
1845+expect(firstEmbeddingProviderCall()?.fallback).toBe("none");
1846+expect(firstEmbeddingProviderCall()?.model).toBe("text-embedding-3-large");
18611847});
1862184818631849it("cleans provider auth profiles and usage stats on logout", async () => {
@@ -1906,15 +1892,15 @@ describe("capability cli", () => {
19061892argv: ["capability", "model", "auth", "logout", "--provider", "openai", "--json"],
19071893});
190818941909-expect(updatedStore).toMatchObject({
1910- profiles: {
1911- "anthropic:default": { id: "anthropic:default" },
1912-},
1913- order: {},
1914- lastGood: {},
1915- usageStats: {
1916- "anthropic:default": { errorCount: 3 },
1917-},
1895+expect(updatedStore).not.toBeNull();
1896+const storeSnapshot = updatedStore as unknown as Record<string, any>;
1897+expect(storeSnapshot.profiles).toEqual({
1898+"anthropic:default": { id: "anthropic:default" },
1899+});
1900+expect(storeSnapshot.order).toEqual({});
1901+expect(storeSnapshot.lastGood).toEqual({});
1902+expect(storeSnapshot.usageStats).toEqual({
1903+"anthropic:default": { errorCount: 3 },
19181904});
19191905expect(mocks.runtime.writeJson).toHaveBeenCalledWith({
19201906provider: "openai",
@@ -2022,11 +2008,10 @@ describe("capability cli", () => {
20222008argv: ["capability", "embedding", "providers", "--json"],
20232009});
202420102025-expect(mocks.registerBuiltInMemoryEmbeddingProviders).toHaveBeenCalledWith(
2026-expect.objectContaining({
2027-registerMemoryEmbeddingProvider: expect.any(Function),
2028-}),
2029-);
2011+const bootstrapArg = mocks.registerBuiltInMemoryEmbeddingProviders.mock.calls[0]?.[0] as
2012+| { registerMemoryEmbeddingProvider?: unknown }
2013+| undefined;
2014+expect(typeof bootstrapArg?.registerMemoryEmbeddingProvider).toBe("function");
20302015});
2031201620322017it("marks env-backed audio providers as configured", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。