diff --git a/src/gateway/http-utils.request-context.test.ts b/src/gateway/http-utils.request-context.test.ts index 8624529706e..e5973f21c0b 100644 --- a/src/gateway/http-utils.request-context.test.ts +++ b/src/gateway/http-utils.request-context.test.ts @@ -141,6 +141,7 @@ describe("resolveOpenAiCompatibleHttpOperatorScopes", () => { "operator.write", "operator.approvals", "operator.pairing", + "operator.talk.secrets", ]); }); diff --git a/src/gateway/server.startup-matrix-migration.integration.test.ts b/src/gateway/server.startup-matrix-migration.integration.test.ts index afd858bfedb..e8c8d86662b 100644 --- a/src/gateway/server.startup-matrix-migration.integration.test.ts +++ b/src/gateway/server.startup-matrix-migration.integration.test.ts @@ -1,4 +1,8 @@ -import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; +import path from "node:path"; +import { describe, expect, it, vi } from "vitest"; +import { clearBundledPluginMetadataCache } from "../plugins/bundled-plugin-metadata.js"; +import { clearPluginDiscoveryCache } from "../plugins/discovery.js"; +import { clearPluginManifestRegistryCache } from "../plugins/manifest-registry.js"; const runChannelPluginStartupMaintenanceMock = vi.fn().mockResolvedValue(undefined); @@ -16,9 +20,16 @@ import { installGatewayTestHooks({ scope: "suite" }); describe("gateway startup channel maintenance wiring", () => { - let server: Awaited> | undefined; + it("runs startup channel maintenance with the resolved startup config", async () => { + const previousBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR; + const previousSkipChannels = process.env.OPENCLAW_SKIP_CHANNELS; + process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = path.resolve(process.cwd(), "extensions"); + process.env.OPENCLAW_SKIP_CHANNELS = "0"; + clearBundledPluginMetadataCache(); + clearPluginDiscoveryCache(); + clearPluginManifestRegistryCache(); + runChannelPluginStartupMaintenanceMock.mockClear(); - beforeAll(async () => { testState.channelsConfig = { matrix: { homeserver: "https://matrix.example.org", @@ -26,29 +37,42 @@ describe("gateway startup channel maintenance wiring", () => { accessToken: "tok-123", }, }; - server = await startGatewayServer(await getFreePort()); - }); - afterAll(async () => { - await server?.close(); - }); + let server: Awaited> | undefined; + try { + server = await startGatewayServer(await getFreePort()); - it("runs startup channel maintenance with the resolved startup config", () => { - expect(runChannelPluginStartupMaintenanceMock).toHaveBeenCalledTimes(1); - expect(runChannelPluginStartupMaintenanceMock).toHaveBeenCalledWith( - expect.objectContaining({ - cfg: expect.objectContaining({ - channels: expect.objectContaining({ - matrix: expect.objectContaining({ - homeserver: "https://matrix.example.org", - userId: "@bot:example.org", - accessToken: "tok-123", + expect(runChannelPluginStartupMaintenanceMock).toHaveBeenCalledTimes(1); + expect(runChannelPluginStartupMaintenanceMock).toHaveBeenCalledWith( + expect.objectContaining({ + cfg: expect.objectContaining({ + channels: expect.objectContaining({ + matrix: expect.objectContaining({ + homeserver: "https://matrix.example.org", + userId: "@bot:example.org", + accessToken: "tok-123", + }), }), }), + env: process.env, + log: expect.anything(), }), - env: process.env, - log: expect.anything(), - }), - ); + ); + } finally { + await server?.close(); + if (previousBundledPluginsDir === undefined) { + delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR; + } else { + process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = previousBundledPluginsDir; + } + if (previousSkipChannels === undefined) { + delete process.env.OPENCLAW_SKIP_CHANNELS; + } else { + process.env.OPENCLAW_SKIP_CHANNELS = previousSkipChannels; + } + clearBundledPluginMetadataCache(); + clearPluginDiscoveryCache(); + clearPluginManifestRegistryCache(); + } }); }); diff --git a/src/gateway/server.talk-config.test.ts b/src/gateway/server.talk-config.test.ts index b2affa2e8d4..30a761b0ee7 100644 --- a/src/gateway/server.talk-config.test.ts +++ b/src/gateway/server.talk-config.test.ts @@ -156,7 +156,7 @@ function expectElevenLabsTalkConfig( silenceTimeoutMs?: number; }, ) { - expect(talk?.provider).toBe(expected.provider); + expect(talk?.provider).toBe(expected.provider ?? "elevenlabs"); expect(talk?.providers?.elevenlabs?.voiceId).toBe(expected.voiceId); expect(talk?.resolved?.provider).toBe("elevenlabs"); expect(talk?.resolved?.config?.voiceId).toBe(expected.voiceId); diff --git a/src/gateway/test-helpers.mocks.ts b/src/gateway/test-helpers.mocks.ts index adac8f2a2ae..9a54abfb2ed 100644 --- a/src/gateway/test-helpers.mocks.ts +++ b/src/gateway/test-helpers.mocks.ts @@ -268,6 +268,9 @@ const createStubPluginRegistry = (): PluginRegistry => ({ ...(trimString(params.outputFormat) == null ? {} : { outputFormat: trimString(params.outputFormat) }), + ...(asNumber(params.latencyTier) == null + ? {} + : { latencyTier: asNumber(params.latencyTier) }), }), synthesize: async (req) => { const config = req.providerConfig as Record; @@ -282,7 +285,12 @@ const createStubPluginRegistry = (): PluginRegistry => ({ { method: "POST", headers: { "content-type": "application/json" }, - body: JSON.stringify({ text: req.text }), + body: JSON.stringify({ + text: req.text, + ...(asNumber(overrides.latencyTier) == null + ? {} + : { latency_optimization_level: asNumber(overrides.latencyTier) }), + }), }, "elevenlabs", );