skip dynamic imports
This commit is contained in:
parent
d55a13894f
commit
72da793664
2 changed files with 12 additions and 12 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { services } from "../services/index.js";
|
||||
import { serviceContainer } from "../services/ServiceContainer.js";
|
||||
import { executeSubAgent } from "../subagent/executor.js";
|
||||
import { getAgentNames, getSubagent } from "../subagent/get-agents.js";
|
||||
|
||||
|
|
@ -8,6 +9,11 @@ import { subagentTool } from "./subagent.js";
|
|||
|
||||
vi.mock("../subagent/get-agents.js");
|
||||
vi.mock("../subagent/executor.js");
|
||||
vi.mock("../services/ServiceContainer.js", () => ({
|
||||
serviceContainer: {
|
||||
get: vi.fn(),
|
||||
},
|
||||
}));
|
||||
vi.mock("../services/index.js", () => ({
|
||||
services: {
|
||||
chatHistory: {
|
||||
|
|
@ -22,12 +28,13 @@ describe("subagentTool", () => {
|
|||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.mocked(serviceContainer.get).mockResolvedValue(modelServiceState);
|
||||
});
|
||||
|
||||
it("preprocess throws when agent is not found", async () => {
|
||||
vi.mocked(getAgentNames).mockReturnValue(["code-agent"]);
|
||||
|
||||
const tool = subagentTool({ modelServiceState } as any);
|
||||
const tool = await subagentTool();
|
||||
|
||||
const args = {
|
||||
description: "Test task",
|
||||
|
|
@ -47,7 +54,7 @@ describe("subagentTool", () => {
|
|||
it("preprocess includes agent model name when agent exists", async () => {
|
||||
vi.mocked(getAgentNames).mockReturnValue(["code-agent"]);
|
||||
|
||||
const tool = subagentTool({ modelServiceState } as any);
|
||||
const tool = await subagentTool();
|
||||
|
||||
vi.mocked(getSubagent).mockReturnValue({
|
||||
model: { name: "test-model" },
|
||||
|
|
@ -83,12 +90,7 @@ describe("subagentTool", () => {
|
|||
response: "subagent-output",
|
||||
} as any);
|
||||
|
||||
const serviceContainer = {} as any;
|
||||
|
||||
const tool = subagentTool({
|
||||
modelServiceState,
|
||||
serviceContainer,
|
||||
} as any);
|
||||
const tool = await subagentTool();
|
||||
|
||||
const result = await tool.run(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { services } from "../services/index.js";
|
||||
import { serviceContainer } from "../services/ServiceContainer.js";
|
||||
import { ModelServiceState, SERVICE_NAMES } from "../services/types.js";
|
||||
import { executeSubAgent } from "../subagent/executor.js";
|
||||
import {
|
||||
generateSubagentToolDescription,
|
||||
getSubagent,
|
||||
|
|
@ -69,10 +71,6 @@ export const subagentTool = async (): Promise<Tool> => {
|
|||
throw new Error(`Unknown agent type: ${subagent_name}`);
|
||||
}
|
||||
|
||||
// Dynamically import to avoid circular dependency and passing repeated params
|
||||
const { executeSubAgent } = await import("../subagent/executor.js");
|
||||
const { services } = await import("../services/index.js");
|
||||
|
||||
const chatHistoryService = services.chatHistory;
|
||||
const parentSessionId = chatHistoryService.getSessionId();
|
||||
if (!parentSessionId) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue