Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lib/agents/generalAgent/__tests__/getGeneralAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ describe("getGeneralAgent", () => {
it("returns a RoutingDecision object with required properties", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -98,6 +99,7 @@ describe("getGeneralAgent", () => {
it("returns a ToolLoopAgent instance", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -109,6 +111,7 @@ describe("getGeneralAgent", () => {
it("uses DEFAULT_MODEL when no model is specified", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -120,6 +123,7 @@ describe("getGeneralAgent", () => {
it("uses custom model when specified in body", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
model: "anthropic/claude-3-opus",
};
Expand All @@ -132,6 +136,7 @@ describe("getGeneralAgent", () => {
it("sets stopWhen to stepCountIs(111)", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -147,6 +152,7 @@ describe("getGeneralAgent", () => {
it("fetches account emails using accountId", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -165,6 +171,7 @@ describe("getGeneralAgent", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -180,6 +187,7 @@ describe("getGeneralAgent", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -195,6 +203,7 @@ describe("getGeneralAgent", () => {
it("fetches artist info when artistId is provided", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
artistId: "artist-456",
messages: [{ id: "1", role: "user", content: "Hello" }],
};
Expand All @@ -207,6 +216,7 @@ describe("getGeneralAgent", () => {
it("does not fetch artist info when artistId is not provided", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -223,6 +233,7 @@ describe("getGeneralAgent", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
artistId: "artist-456",
messages: [{ id: "1", role: "user", content: "Hello" }],
};
Expand All @@ -248,6 +259,7 @@ describe("getGeneralAgent", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
artistId: "artist-456",
messages: [{ id: "1", role: "user", content: "Hello" }],
};
Expand All @@ -265,6 +277,7 @@ describe("getGeneralAgent", () => {
it("calls getSystemPrompt with all required parameters", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
artistId: "artist-456",
roomId: "room-789",
messages: [{ id: "1", role: "user", content: "Hello" }],
Expand All @@ -276,6 +289,7 @@ describe("getGeneralAgent", () => {
roomId: "room-789",
artistId: "artist-456",
accountId: "account-123",
orgId: null,
email: "user@example.com",
artistInstruction: undefined,
knowledgeBaseText: undefined,
Expand All @@ -294,6 +308,7 @@ describe("getGeneralAgent", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand Down Expand Up @@ -333,6 +348,7 @@ describe("getGeneralAgent", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Edit these images" }],
};

Expand All @@ -349,6 +365,7 @@ describe("getGeneralAgent", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -362,6 +379,7 @@ describe("getGeneralAgent", () => {
it("calls setupToolsForRequest with body", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
excludeTools: ["dangerous_tool"],
};
Expand All @@ -377,6 +395,7 @@ describe("getGeneralAgent", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -390,6 +409,7 @@ describe("getGeneralAgent", () => {
it("creates ToolLoopAgent with model matching result model", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
model: "anthropic/claude-sonnet-4",
};
Expand All @@ -406,6 +426,7 @@ describe("getGeneralAgent", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -422,6 +443,7 @@ describe("getGeneralAgent", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -433,6 +455,7 @@ describe("getGeneralAgent", () => {
it("returns stopWhen in the routing decision", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand Down
3 changes: 2 additions & 1 deletion lib/agents/generalAgent/getGeneralAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getAccountWithDetails } from "@/lib/supabase/accounts/getAccountWithDet
* @returns The general agent
*/
export default async function getGeneralAgent(body: ChatRequestBody): Promise<RoutingDecision> {
const { accountId, messages, artistId, model: bodyModel } = body;
const { accountId, orgId, messages, artistId, model: bodyModel } = body;

const accountEmails = await selectAccountEmails({ accountIds: accountId });
const email = accountEmails[0]?.email || undefined;
Expand All @@ -37,6 +37,7 @@ export default async function getGeneralAgent(body: ChatRequestBody): Promise<Ro
roomId: body.roomId,
artistId,
accountId,
orgId,
email,
artistInstruction,
knowledgeBaseText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe("getGoogleSheetsTools", () => {
it("calls getConnectedAccount with accountId", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -72,6 +73,7 @@ describe("getGoogleSheetsTools", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Create a spreadsheet for me" }],
};

Expand All @@ -90,6 +92,7 @@ describe("getGoogleSheetsTools", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Test" }],
};

Expand All @@ -114,6 +117,7 @@ describe("getGoogleSheetsTools", () => {
it("returns Google Sheets tools from Composio", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -131,6 +135,7 @@ describe("getGoogleSheetsTools", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -152,6 +157,7 @@ describe("getGoogleSheetsTools", () => {
it("returns google_sheets_login tool", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -168,6 +174,7 @@ describe("getGoogleSheetsTools", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -185,6 +192,7 @@ describe("getGoogleSheetsTools", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand All @@ -200,6 +208,7 @@ describe("getGoogleSheetsTools", () => {

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

Expand Down
4 changes: 4 additions & 0 deletions lib/chat/__tests__/handleChatGenerate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ vi.mock("@/lib/accounts/validateOverrideAccountId", () => ({
validateOverrideAccountId: vi.fn(),
}));

vi.mock("@/lib/keys/getApiKeyDetails", () => ({
getApiKeyDetails: vi.fn(),
}));

vi.mock("@/lib/chat/setupChatRequest", () => ({
setupChatRequest: vi.fn(),
}));
Expand Down
4 changes: 4 additions & 0 deletions lib/chat/__tests__/handleChatStream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ vi.mock("@/lib/accounts/validateOverrideAccountId", () => ({
validateOverrideAccountId: vi.fn(),
}));

vi.mock("@/lib/keys/getApiKeyDetails", () => ({
getApiKeyDetails: vi.fn(),
}));

vi.mock("@/lib/chat/setupChatRequest", () => ({
setupChatRequest: vi.fn(),
}));
Expand Down
4 changes: 4 additions & 0 deletions lib/chat/__tests__/integration/chatEndToEnd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ vi.mock("@/lib/accounts/validateOverrideAccountId", () => ({
validateOverrideAccountId: vi.fn(),
}));

vi.mock("@/lib/keys/getApiKeyDetails", () => ({
getApiKeyDetails: vi.fn(),
}));

// Mock Supabase dependencies
vi.mock("@/lib/supabase/account_emails/selectAccountEmails", () => ({
default: vi.fn(),
Expand Down
Loading