diff --git a/src/agents/models-config.providers.auth-aliases.test.ts b/src/agents/models-config.providers.auth-aliases.test.ts index ef2aa9a0c7c..a37eeacc93a 100644 --- a/src/agents/models-config.providers.auth-aliases.test.ts +++ b/src/agents/models-config.providers.auth-aliases.test.ts @@ -63,7 +63,7 @@ vi.mock("../plugins/manifest-registry.js", () => ({ })); vi.mock("../plugins/manifest-registry-installed.js", () => ({ loadPluginManifestRegistryForInstalledIndex: loadPluginManifestRegistry, - resolveInstalledManifestRegistryIndexFingerprint: () => "test-index", + resolveInstalledManifestRegistryIndexFingerprint: () => "test-installed-index", })); vi.mock("../plugins/plugin-registry.js", () => ({ loadPluginRegistrySnapshot: () => ({ plugins: [] }), diff --git a/src/agents/pi-embedded-runner/compact.hooks.test.ts b/src/agents/pi-embedded-runner/compact.hooks.test.ts index ab8d647a7b1..45de0f9c399 100644 --- a/src/agents/pi-embedded-runner/compact.hooks.test.ts +++ b/src/agents/pi-embedded-runner/compact.hooks.test.ts @@ -1328,13 +1328,6 @@ describe("compactEmbeddedPiSession hooks (ownsCompaction engine)", () => { sessionFile: TEST_SESSION_FILE, }, } as never); - rotateTranscriptAfterCompactionMock.mockResolvedValueOnce({ - rotated: true, - sessionId: "wrapper-rotated-session", - sessionFile: "/tmp/wrapper-rotated-session.jsonl", - leafId: "wrapper-rotated-leaf", - }); - const result = await compactEmbeddedPiSession( wrappedCompactionArgs({ config: { diff --git a/src/agents/sessions-spawn-hooks.test.ts b/src/agents/sessions-spawn-hooks.test.ts index e7c84265bfd..88d514de2ed 100644 --- a/src/agents/sessions-spawn-hooks.test.ts +++ b/src/agents/sessions-spawn-hooks.test.ts @@ -65,12 +65,12 @@ async function spawn(params?: { runTimeoutSeconds?: number; thread?: boolean; mode?: "run" | "session"; + context?: "isolated" | "fork"; agentSessionKey?: string; agentChannel?: string; agentAccountId?: string; agentTo?: string; agentThreadId?: string | number; - context?: "isolated"; }) { return await spawnSubagentDirect( { @@ -81,7 +81,7 @@ async function spawn(params?: { : {}), ...(params?.thread ? { thread: true } : {}), ...(params?.mode ? { mode: params.mode } : {}), - ...(params?.context ? { context: params.context } : {}), + context: params?.context ?? "isolated", }, { agentSessionKey: params?.agentSessionKey ?? "main", @@ -170,6 +170,9 @@ describe("sessions_spawn subagent lifecycle hooks", () => { session: { mainKey: "main", scope: "per-sender", + threadBindings: { + defaultSpawnContext: "isolated", + }, }, }); const store: Record> = {}; diff --git a/src/agents/subagent-spawn.thread-binding.test.ts b/src/agents/subagent-spawn.thread-binding.test.ts index 2dd23d02d3d..41fce53eea8 100644 --- a/src/agents/subagent-spawn.thread-binding.test.ts +++ b/src/agents/subagent-spawn.thread-binding.test.ts @@ -55,6 +55,11 @@ describe("spawnSubagentDirect thread binding delivery", () => { }, list: [{ id: "main", workspace: "/tmp/workspace-main" }], }, + session: { + threadBindings: { + defaultSpawnContext: "isolated", + }, + }, }); currentSessionBindingService = { listBySession: () => [] }; currentDeliveryTargetResolver = (params) => ({ diff --git a/src/agents/subagent-spawn.workspace.test.ts b/src/agents/subagent-spawn.workspace.test.ts index 828d6e0a42f..589c4808250 100644 --- a/src/agents/subagent-spawn.workspace.test.ts +++ b/src/agents/subagent-spawn.workspace.test.ts @@ -53,6 +53,11 @@ function createConfigOverride(overrides?: Record) { }, ], }, + session: { + threadBindings: { + defaultSpawnContext: "isolated", + }, + }, ...overrides, }); } diff --git a/src/commands/channel-setup/workspace-shadow-bypass.test.ts b/src/commands/channel-setup/workspace-shadow-bypass.test.ts index a3749cbd865..2ebc81f80a7 100644 --- a/src/commands/channel-setup/workspace-shadow-bypass.test.ts +++ b/src/commands/channel-setup/workspace-shadow-bypass.test.ts @@ -18,6 +18,7 @@ const listChannelPluginCatalogEntries = vi.hoisted(() => vi.fn((_opts?: unknown) const listChatChannels = vi.hoisted(() => vi.fn((): unknown[] => [])); const loadPluginManifestRegistry = vi.hoisted(() => vi.fn()); const loadPluginRegistrySnapshot = vi.hoisted(() => vi.fn()); +const loadPluginRegistrySnapshotWithMetadata = vi.hoisted(() => vi.fn()); const listPluginContributionIds = vi.hoisted(() => vi.fn((_params?: unknown): string[] => [])); const applyPluginAutoEnable = vi.hoisted(() => vi.fn(({ config }: { config: unknown }) => ({ @@ -44,11 +45,8 @@ vi.mock("../../plugins/plugin-registry.js", () => ({ loadPluginManifestRegistryForPluginRegistry: (...args: unknown[]) => loadPluginManifestRegistry(...args), loadPluginRegistrySnapshot: (...args: unknown[]) => loadPluginRegistrySnapshot(...args), - loadPluginRegistrySnapshotWithMetadata: (...args: unknown[]) => ({ - source: "derived", - snapshot: loadPluginRegistrySnapshot(...args), - diagnostics: [], - }), + loadPluginRegistrySnapshotWithMetadata: (...args: unknown[]) => + loadPluginRegistrySnapshotWithMetadata(...args), listPluginContributionIds: (...args: unknown[]) => listPluginContributionIds(...args), })); vi.mock("../../config/plugin-auto-enable.js", () => ({ @@ -78,6 +76,11 @@ beforeEach(() => { plugins: [], diagnostics: [], }); + loadPluginRegistrySnapshotWithMetadata.mockImplementation((...args: unknown[]) => ({ + snapshot: loadPluginRegistrySnapshot(...args), + source: "derived", + diagnostics: [], + })); listPluginContributionIds.mockReturnValue([]); listChatChannels.mockReturnValue([]); }); diff --git a/src/plugins/capability-provider-runtime.test.ts b/src/plugins/capability-provider-runtime.test.ts index 095dc561a29..1e99ab44df6 100644 --- a/src/plugins/capability-provider-runtime.test.ts +++ b/src/plugins/capability-provider-runtime.test.ts @@ -33,7 +33,9 @@ const mocks = vi.hoisted(() => ({ ), resolveInstalledManifestRegistryIndexFingerprint: vi.fn(() => "test-installed-index"), loadBundledCapabilityRuntimeRegistry: vi.fn(), - loadPluginRegistrySnapshot: vi.fn<() => { plugins: Array> }>(() => ({ + loadPluginRegistrySnapshot: vi.fn< + (_params?: unknown) => { plugins: Array> } + >(() => ({ plugins: [], })), withBundledPluginAllowlistCompat: vi.fn( @@ -65,13 +67,21 @@ vi.mock("./manifest-registry-installed.js", () => ({ mocks.resolveInstalledManifestRegistryIndexFingerprint, })); +vi.mock("./manifest-registry.js", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + loadPluginManifestRegistry: mocks.loadPluginManifestRegistry, + }; +}); + vi.mock("./plugin-registry.js", async (importOriginal) => { const actual = await importOriginal(); return { ...actual, loadPluginRegistrySnapshot: mocks.loadPluginRegistrySnapshot, loadPluginRegistrySnapshotWithMetadata: (params?: { index?: unknown }) => { - const snapshot = (params?.index ?? mocks.loadPluginRegistrySnapshot()) as { + const snapshot = (params?.index ?? mocks.loadPluginRegistrySnapshot(params)) as { plugins?: Array>; }; return { @@ -138,8 +148,6 @@ function expectBundledCompatLoadPath(params: { expect.objectContaining({ config: params.cfg, env: process.env, - includeDisabled: true, - index: expect.any(Object), }), ); expect(mocks.withBundledPluginEnablementCompat).toHaveBeenCalledWith({ @@ -1102,8 +1110,6 @@ describe("resolvePluginCapabilityProviders", () => { expect.objectContaining({ config: {}, env: process.env, - includeDisabled: true, - index: expect.any(Object), }), ); expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({ @@ -1230,8 +1236,6 @@ describe("resolvePluginCapabilityProviders", () => { expect.objectContaining({ config: cfg, env: process.env, - includeDisabled: true, - index: expect.any(Object), }), ); expect(mocks.withBundledPluginAllowlistCompat).toHaveBeenCalledWith({ @@ -1265,8 +1269,6 @@ describe("resolvePluginCapabilityProviders", () => { expect.objectContaining({ config: {}, env: process.env, - includeDisabled: true, - index: expect.any(Object), }), ); expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith(); diff --git a/src/plugins/migration-provider-runtime.test.ts b/src/plugins/migration-provider-runtime.test.ts index f152d030344..2495c56bc6e 100644 --- a/src/plugins/migration-provider-runtime.test.ts +++ b/src/plugins/migration-provider-runtime.test.ts @@ -33,7 +33,9 @@ const mocks = vi.hoisted(() => ({ loadPluginManifestRegistry: vi.fn<(params?: Record) => MockManifestRegistry>( () => createEmptyMockManifestRegistry(), ), - loadPluginRegistrySnapshot: vi.fn<() => MockPluginIndex>(() => createMockPluginIndex([])), + loadPluginRegistrySnapshot: vi.fn<(_params?: unknown) => MockPluginIndex>(() => + createMockPluginIndex([]), + ), loadPluginRegistrySnapshotWithMetadata: vi.fn((params?: { index?: MockPluginIndex }) => ({ source: params?.index ? "provided" : "derived", snapshot: params?.index ?? createMockPluginIndex([]), @@ -61,7 +63,7 @@ vi.mock("./plugin-registry.js", () => ({ vi.mock("./manifest-registry-installed.js", () => ({ loadPluginManifestRegistryForInstalledIndex: mocks.loadPluginManifestRegistry, - resolveInstalledManifestRegistryIndexFingerprint: () => "test-index", + resolveInstalledManifestRegistryIndexFingerprint: () => "test-installed-index", })); vi.mock("./bundled-compat.js", () => ({ diff --git a/src/plugins/web-fetch-providers.runtime.test.ts b/src/plugins/web-fetch-providers.runtime.test.ts index 7d80b69a36d..ff6ed2e3943 100644 --- a/src/plugins/web-fetch-providers.runtime.test.ts +++ b/src/plugins/web-fetch-providers.runtime.test.ts @@ -95,6 +95,18 @@ function createRuntimeWebFetchProvider() { describe("resolvePluginWebFetchProviders", () => { beforeAll(async () => { + vi.doMock("./plugin-registry.js", async () => { + const actual = + await vi.importActual("./plugin-registry.js"); + return { + ...actual, + loadPluginRegistrySnapshotWithMetadata: () => ({ + snapshot: { plugins: [], diagnostics: [] }, + source: "derived", + diagnostics: [], + }), + }; + }); loaderModule = await import("./loader.js"); manifestRegistryModule = await import("./manifest-registry.js"); webFetchProvidersSharedModule = await import("./web-fetch-providers.shared.js"); @@ -189,7 +201,7 @@ describe("resolvePluginWebFetchProviders", () => { workspaceDir: DEFAULT_WORKSPACE, env, onlyPluginIds: ["firecrawl"], - cache: false, + cache: true, activate: false, }); const registry = createEmptyPluginRegistry(); @@ -226,7 +238,7 @@ describe("resolvePluginWebFetchProviders", () => { workspaceDir: DEFAULT_WORKSPACE, env, onlyPluginIds: ["firecrawl"], - cache: false, + cache: true, activate: false, }); const registry = createEmptyPluginRegistry(); diff --git a/src/plugins/web-search-providers.runtime.test.ts b/src/plugins/web-search-providers.runtime.test.ts index 6ae9ea573b2..4ba4c07e6f4 100644 --- a/src/plugins/web-search-providers.runtime.test.ts +++ b/src/plugins/web-search-providers.runtime.test.ts @@ -304,7 +304,7 @@ function createActiveBraveRegistryFixture(params?: { workspaceDir: DEFAULT_WEB_SEARCH_WORKSPACE, env, onlyPluginIds: ["brave"], - cache: false, + cache: true, activate: false, }); const registry = createEmptyPluginRegistry(); @@ -326,6 +326,16 @@ describe("resolvePluginWebSearchProviders", () => { beforeAll(async () => { loadPluginManifestRegistryMock = vi.fn(); loadInstalledPluginManifestRegistryMock = vi.fn(); + vi.doMock("./manifest-registry.js", async () => { + const actual = + await vi.importActual("./manifest-registry.js"); + return { + ...actual, + loadPluginManifestRegistry: ( + ...args: Parameters + ) => loadPluginManifestRegistryMock(...args), + }; + }); vi.doMock("./plugin-registry.js", async () => { const actual = await vi.importActual("./plugin-registry.js");