diff --git a/apps/rowboat/app/actions/copilot.actions.ts b/apps/rowboat/app/actions/copilot.actions.ts index 06634353..5dc6c897 100644 --- a/apps/rowboat/app/actions/copilot.actions.ts +++ b/apps/rowboat/app/actions/copilot.actions.ts @@ -3,7 +3,7 @@ import { CopilotAPIRequest, CopilotChatContext, CopilotMessage, DataSourceSchemaForCopilot, -} from "../lib/types/copilot_types"; +} from "../../src/application/lib/copilot/types"; import { Workflow} from "../lib/types/workflow_types"; import { z } from 'zod'; @@ -11,7 +11,7 @@ import { projectAuthCheck } from "./project.actions"; import { redisClient } from "../lib/redis"; import { authorizeUserAction, logUsage } from "./billing.actions"; import { USE_BILLING } from "../lib/feature_flags"; -import { getEditAgentInstructionsResponse } from "../lib/copilot/copilot"; +import { getEditAgentInstructionsResponse } from "../../src/application/lib/copilot/copilot"; import { container } from "@/di/container"; import { IUsageQuotaPolicy } from "@/src/application/policies/usage-quota.policy.interface"; import { UsageTracker } from "../lib/billing"; diff --git a/apps/rowboat/app/api/copilot-stream-response/[streamId]/route.ts b/apps/rowboat/app/api/copilot-stream-response/[streamId]/route.ts index 10d1fc66..6f1a78c6 100644 --- a/apps/rowboat/app/api/copilot-stream-response/[streamId]/route.ts +++ b/apps/rowboat/app/api/copilot-stream-response/[streamId]/route.ts @@ -1,8 +1,8 @@ import { getCustomerIdForProject, logUsage, UsageTracker } from "@/app/lib/billing"; import { USE_BILLING } from "@/app/lib/feature_flags"; import { redisClient } from "@/app/lib/redis"; -import { CopilotAPIRequest } from "@/app/lib/types/copilot_types"; -import { streamMultiAgentResponse } from "@/app/lib/copilot/copilot"; +import { CopilotAPIRequest } from "@/src/application/lib/copilot/types"; +import { streamMultiAgentResponse } from "@/src/application/lib/copilot/copilot"; export async function GET(request: Request, props: { params: Promise<{ streamId: string }> }) { const params = await props.params; diff --git a/apps/rowboat/app/api/twilio/inbound_call/route.ts b/apps/rowboat/app/api/twilio/inbound_call/route.ts index 4ab8514e..443d40c9 100644 --- a/apps/rowboat/app/api/twilio/inbound_call/route.ts +++ b/apps/rowboat/app/api/twilio/inbound_call/route.ts @@ -1,4 +1,4 @@ -import { getResponse } from "@/app/lib/agents"; +import { getResponse } from "@/src/application/lib/agents-runtime/agents"; import { twilioConfigsCollection, twilioInboundCallsCollection } from "@/app/lib/mongodb"; import { PrefixLogger } from "@/app/lib/utils"; import VoiceResponse from "twilio/lib/twiml/VoiceResponse"; diff --git a/apps/rowboat/app/api/twilio/turn/[callSid]/route.ts b/apps/rowboat/app/api/twilio/turn/[callSid]/route.ts index 5048c16d..1ae9c449 100644 --- a/apps/rowboat/app/api/twilio/turn/[callSid]/route.ts +++ b/apps/rowboat/app/api/twilio/turn/[callSid]/route.ts @@ -1,4 +1,4 @@ -import { getResponse } from "@/app/lib/agents"; +import { getResponse } from "@/src/application/lib/agents-runtime/agents"; import { twilioInboundCallsCollection } from "@/app/lib/mongodb"; import { PrefixLogger } from "@/app/lib/utils"; import VoiceResponse from "twilio/lib/twiml/VoiceResponse"; diff --git a/apps/rowboat/app/api/widget/v1/chats/[chatId]/turn/route.ts b/apps/rowboat/app/api/widget/v1/chats/[chatId]/turn/route.ts index d6b0d04e..ced88e8b 100644 --- a/apps/rowboat/app/api/widget/v1/chats/[chatId]/turn/route.ts +++ b/apps/rowboat/app/api/widget/v1/chats/[chatId]/turn/route.ts @@ -7,7 +7,7 @@ import { authCheck } from "../../../utils"; import { PrefixLogger } from "../../../../../../lib/utils"; import { authorize, getCustomerIdForProject, logUsage } from "@/app/lib/billing"; import { USE_BILLING } from "@/app/lib/feature_flags"; -import { getResponse } from "@/app/lib/agents"; +import { getResponse } from "@/src/application/lib/agents-runtime/agents"; import { Message, AssistantMessage, AssistantMessageWithToolCalls, ToolMessage } from "@/app/lib/types/types"; import { IUsageQuotaPolicy } from "@/src/application/policies/usage-quota.policy.interface"; import { container } from "@/di/container"; diff --git a/apps/rowboat/app/lib/constants/klavis.ts b/apps/rowboat/app/lib/constants/klavis.ts deleted file mode 100644 index 14a912f3..00000000 --- a/apps/rowboat/app/lib/constants/klavis.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Server name to URL parameter mapping -export const SERVER_URL_PARAMS: Record = { - 'Google Calendar': 'gcalendar', - 'Google Drive': 'gdrive', - 'Google Docs': 'gdocs', - 'Google Sheets': 'gsheets', - 'Gmail': 'gmail', - 'GitHub': 'github', - 'Slack': 'slack', - 'Jira': 'jira', - 'Notion': 'notion', - 'Supabase': 'supabase', - 'WordPress': 'wordpress', - 'Asana': 'asana', - 'Close': 'close', - 'Confluence': 'confluence', - 'Salesforce': 'salesforce', - 'Linear': 'linear', - 'Attio': 'attio' -}; - -// Server name to environment variable mapping for client IDs -export const SERVER_CLIENT_ID_MAP: Record = { - 'GitHub': process.env.KLAVIS_GITHUB_CLIENT_ID, - 'Google Calendar': process.env.KLAVIS_GOOGLE_CLIENT_ID, - 'Google Drive': process.env.KLAVIS_GOOGLE_CLIENT_ID, - 'Google Docs': process.env.KLAVIS_GOOGLE_CLIENT_ID, - 'Google Sheets': process.env.KLAVIS_GOOGLE_CLIENT_ID, - 'Gmail': process.env.KLAVIS_GOOGLE_CLIENT_ID, - 'Slack': process.env.KLAVIS_SLACK_ID, -}; \ No newline at end of file diff --git a/apps/rowboat/app/projects/[projectId]/copilot/app.tsx b/apps/rowboat/app/projects/[projectId]/copilot/app.tsx index ed2b28bf..859aea90 100644 --- a/apps/rowboat/app/projects/[projectId]/copilot/app.tsx +++ b/apps/rowboat/app/projects/[projectId]/copilot/app.tsx @@ -2,8 +2,8 @@ import { Button } from "@/components/ui/button"; import { Dropdown, DropdownItem, DropdownMenu, DropdownSection, DropdownTrigger, Spinner, Tooltip } from "@heroui/react"; import { useRef, useState, createContext, useContext, useCallback, forwardRef, useImperativeHandle, useEffect, Ref } from "react"; -import { CopilotChatContext } from "../../../lib/types/copilot_types"; -import { CopilotMessage } from "../../../lib/types/copilot_types"; +import { CopilotChatContext } from "../../../../src/application/lib/copilot/types"; +import { CopilotMessage } from "../../../../src/application/lib/copilot/types"; import { Workflow } from "@/app/lib/types/workflow_types"; import { DataSource } from "@/src/entities/models/data-source"; import { z } from "zod"; diff --git a/apps/rowboat/app/projects/[projectId]/copilot/components/actions.tsx b/apps/rowboat/app/projects/[projectId]/copilot/components/actions.tsx index 9cb095a7..9f1c3bdc 100644 --- a/apps/rowboat/app/projects/[projectId]/copilot/components/actions.tsx +++ b/apps/rowboat/app/projects/[projectId]/copilot/components/actions.tsx @@ -2,7 +2,7 @@ import { createContext, useContext, useRef, useState } from "react"; import clsx from "clsx"; import { z } from "zod"; -import { CopilotAssistantMessageActionPart } from "../../../../lib/types/copilot_types"; +import { CopilotAssistantMessageActionPart } from "../../../../../src/application/lib/copilot/types"; import { Workflow } from "../../../../lib/types/workflow_types"; import { PreviewModalProvider, usePreviewModal } from '../../workflow/preview-modal'; import { getAppliedChangeKey } from "../app"; diff --git a/apps/rowboat/app/projects/[projectId]/copilot/components/messages.tsx b/apps/rowboat/app/projects/[projectId]/copilot/components/messages.tsx index a22f4870..54fcf160 100644 --- a/apps/rowboat/app/projects/[projectId]/copilot/components/messages.tsx +++ b/apps/rowboat/app/projects/[projectId]/copilot/components/messages.tsx @@ -5,7 +5,7 @@ import { z } from "zod"; import { Workflow} from "@/app/lib/types/workflow_types"; import MarkdownContent from "@/app/lib/components/markdown-content"; import { MessageSquareIcon, EllipsisIcon, XIcon, CheckCheckIcon, ChevronDown, ChevronUp } from "lucide-react"; -import { CopilotMessage, CopilotAssistantMessage, CopilotAssistantMessageActionPart } from "@/app/lib/types/copilot_types"; +import { CopilotMessage, CopilotAssistantMessage, CopilotAssistantMessageActionPart } from "@/src/application/lib/copilot/types"; import { Action, StreamingAction } from './actions'; import { useParsedBlocks } from "../use-parsed-blocks"; import { validateConfigChanges } from "@/app/lib/client_utils"; diff --git a/apps/rowboat/app/projects/[projectId]/copilot/use-copilot.tsx b/apps/rowboat/app/projects/[projectId]/copilot/use-copilot.tsx index b35d98ec..70e6da1b 100644 --- a/apps/rowboat/app/projects/[projectId]/copilot/use-copilot.tsx +++ b/apps/rowboat/app/projects/[projectId]/copilot/use-copilot.tsx @@ -1,6 +1,6 @@ import { useCallback, useRef, useState } from "react"; import { getCopilotResponseStream } from "@/app/actions/copilot.actions"; -import { CopilotMessage } from "@/app/lib/types/copilot_types"; +import { CopilotMessage } from "@/src/application/lib/copilot/types"; import { Workflow } from "@/app/lib/types/workflow_types"; import { DataSource } from "@/src/entities/models/data-source"; import { z } from "zod"; diff --git a/apps/rowboat/app/projects/[projectId]/entities/agent_config.tsx b/apps/rowboat/app/projects/[projectId]/entities/agent_config.tsx index 69876b9d..46caca79 100644 --- a/apps/rowboat/app/projects/[projectId]/entities/agent_config.tsx +++ b/apps/rowboat/app/projects/[projectId]/entities/agent_config.tsx @@ -7,7 +7,7 @@ import { useState, useEffect, useRef } from "react"; import { usePreviewModal } from "../workflow/preview-modal"; import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Select, SelectItem, Chip, SelectSection } from "@heroui/react"; import { PreviewModalProvider } from "../workflow/preview-modal"; -import { CopilotMessage } from "@/app/lib/types/copilot_types"; +import { CopilotMessage } from "@/src/application/lib/copilot/types"; import { getCopilotAgentInstructions } from "@/app/actions/copilot.actions"; import { Dropdown as CustomDropdown } from "../../../lib/components/dropdown"; import { createAtMentions } from "../../../lib/components/atmentions"; diff --git a/apps/rowboat/app/lib/agent-handoffs.ts b/apps/rowboat/src/application/lib/agents-runtime/agent-handoffs.ts similarity index 98% rename from apps/rowboat/app/lib/agent-handoffs.ts rename to apps/rowboat/src/application/lib/agents-runtime/agent-handoffs.ts index 72bb6861..f85926d5 100644 --- a/apps/rowboat/app/lib/agent-handoffs.ts +++ b/apps/rowboat/src/application/lib/agents-runtime/agent-handoffs.ts @@ -1,10 +1,8 @@ // Agent handoffs using OpenAI Agents SDK native capabilities import { Agent, handoff, Handoff } from "@openai/agents"; import { z } from "zod"; -import { PrefixLogger } from "./utils"; -import { - WorkflowAgent -} from "./types/workflow_types"; +import { PrefixLogger } from "@/app/lib/utils"; +import { WorkflowAgent } from "@/app/lib/types/workflow_types"; import { HandoffContext, PipelineContext, diff --git a/apps/rowboat/app/lib/agent-tools.ts b/apps/rowboat/src/application/lib/agents-runtime/agent-tools.ts similarity index 97% rename from apps/rowboat/app/lib/agent-tools.ts rename to apps/rowboat/src/application/lib/agents-runtime/agent-tools.ts index 81eecf21..c55f70ac 100644 --- a/apps/rowboat/app/lib/agent-tools.ts +++ b/apps/rowboat/src/application/lib/agents-runtime/agent-tools.ts @@ -3,18 +3,18 @@ import { tool, Tool } from "@openai/agents"; import { createOpenAI } from "@ai-sdk/openai"; import { embed, generateText } from "ai"; import { z } from "zod"; -import { composio } from "../../src/application/lib/composio/composio"; +import { composio } from "@/src/application/lib/composio/composio"; import { SignJWT } from "jose"; import crypto from "crypto"; // Internal dependencies -import { embeddingModel } from '../lib/embedding'; -import { getMcpClient } from "./mcp"; -import { qdrantClient } from '../lib/qdrant'; -import { EmbeddingRecord } from "./types/datasource_types"; -import { WorkflowAgent, WorkflowTool } from "./types/workflow_types"; -import { PrefixLogger } from "./utils"; -import { UsageTracker } from "./billing"; +import { embeddingModel } from "@/app/lib/embedding"; +import { getMcpClient } from "@/app/lib/mcp"; +import { qdrantClient } from "@/app/lib/qdrant"; +import { EmbeddingRecord } from "@/app/lib/types/datasource_types"; +import { WorkflowAgent, WorkflowTool } from "@/app/lib/types/workflow_types"; +import { PrefixLogger } from "@/app/lib/utils"; +import { UsageTracker } from "@/app/lib/billing"; import { DataSource } from "@/src/entities/models/data-source"; import { IDataSourcesRepository } from "@/src/application/repositories/data-sources.repository.interface"; import { IDataSourceDocsRepository } from "@/src/application/repositories/data-source-docs.repository.interface"; diff --git a/apps/rowboat/app/lib/agent_instructions.ts b/apps/rowboat/src/application/lib/agents-runtime/agent_instructions.ts similarity index 100% rename from apps/rowboat/app/lib/agent_instructions.ts rename to apps/rowboat/src/application/lib/agents-runtime/agent_instructions.ts diff --git a/apps/rowboat/app/lib/agents.ts b/apps/rowboat/src/application/lib/agents-runtime/agents.ts similarity index 99% rename from apps/rowboat/app/lib/agents.ts rename to apps/rowboat/src/application/lib/agents-runtime/agents.ts index f8e272e3..1a11a06a 100644 --- a/apps/rowboat/app/lib/agents.ts +++ b/apps/rowboat/src/application/lib/agents-runtime/agents.ts @@ -8,11 +8,11 @@ import crypto from "crypto"; // Internal dependencies import { createTools, createRagTool } from "./agent-tools"; -import { ConnectedEntity, sanitizeTextWithMentions, Workflow, WorkflowAgent, WorkflowPipeline, WorkflowPrompt, WorkflowTool } from "./types/workflow_types"; +import { ConnectedEntity, sanitizeTextWithMentions, Workflow, WorkflowAgent, WorkflowPipeline, WorkflowPrompt, WorkflowTool } from "@/app/lib/types/workflow_types"; import { CHILD_TRANSFER_RELATED_INSTRUCTIONS, CONVERSATION_TYPE_INSTRUCTIONS, PIPELINE_TYPE_INSTRUCTIONS, RAG_INSTRUCTIONS, TASK_TYPE_INSTRUCTIONS } from "./agent_instructions"; -import { PrefixLogger } from "./utils"; -import { Message, AssistantMessage, AssistantMessageWithToolCalls, ToolMessage } from "./types/types"; -import { UsageTracker } from "./billing"; +import { PrefixLogger } from "@/app/lib/utils"; +import { Message, AssistantMessage, AssistantMessageWithToolCalls, ToolMessage } from "@/app/lib/types/types"; +import { UsageTracker } from "@/app/lib/billing"; // Native handoff support import { createAgentHandoff, getSchemaForAgent, createContextFilterForAgent } from "./agent-handoffs"; diff --git a/apps/rowboat/app/lib/pipeline-state-manager.ts b/apps/rowboat/src/application/lib/agents-runtime/pipeline-state-manager.ts similarity index 98% rename from apps/rowboat/app/lib/pipeline-state-manager.ts rename to apps/rowboat/src/application/lib/agents-runtime/pipeline-state-manager.ts index 32a474e8..162a8f28 100644 --- a/apps/rowboat/app/lib/pipeline-state-manager.ts +++ b/apps/rowboat/src/application/lib/agents-runtime/pipeline-state-manager.ts @@ -1,9 +1,9 @@ // Pipeline State Manager for handling complex pipeline execution flow import { Agent } from "@openai/agents"; import { z } from "zod"; -import { WorkflowPipeline, WorkflowAgent } from "./types/workflow_types"; +import { WorkflowPipeline, WorkflowAgent } from "@/app/lib/types/workflow_types"; import { PipelineExecutionState } from "./agents"; -import { PrefixLogger } from "./utils"; +import { PrefixLogger } from "@/app/lib/utils"; import { createPipelineHandoff } from "./agent-handoffs"; export interface PipelineExecutionResult { diff --git a/apps/rowboat/src/application/lib/composio/composio.ts b/apps/rowboat/src/application/lib/composio/composio.ts index 995100eb..0b3e8a19 100644 --- a/apps/rowboat/src/application/lib/composio/composio.ts +++ b/apps/rowboat/src/application/lib/composio/composio.ts @@ -1,5 +1,5 @@ import { z } from "zod"; -import { PrefixLogger } from "../../../../app/lib/utils"; +import { PrefixLogger } from "@/app/lib/utils"; import { Composio } from "@composio/core"; import { ZAuthConfig, ZConnectedAccount, ZCreateAuthConfigRequest, ZCreateAuthConfigResponse, ZCreateConnectedAccountRequest, ZCreateConnectedAccountResponse, ZDeleteOperationResponse, ZErrorResponse, ZGetToolkitResponse, ZListResponse, ZTool, ZToolkit, ZTriggerType } from "./types"; diff --git a/apps/rowboat/app/lib/copilot/copilot.ts b/apps/rowboat/src/application/lib/copilot/copilot.ts similarity index 97% rename from apps/rowboat/app/lib/copilot/copilot.ts rename to apps/rowboat/src/application/lib/copilot/copilot.ts index decfde1d..4a60fe94 100644 --- a/apps/rowboat/app/lib/copilot/copilot.ts +++ b/apps/rowboat/src/application/lib/copilot/copilot.ts @@ -1,17 +1,17 @@ import z from "zod"; import { createOpenAI } from "@ai-sdk/openai"; import { generateObject, streamText, tool } from "ai"; -import { Workflow, WorkflowTool } from "../types/workflow_types"; -import { CopilotChatContext, CopilotMessage, DataSourceSchemaForCopilot } from "../types/copilot_types"; -import { PrefixLogger } from "../utils"; +import { Workflow, WorkflowTool } from "@/app/lib/types/workflow_types"; +import { CopilotChatContext, CopilotMessage, DataSourceSchemaForCopilot } from "./types"; +import { PrefixLogger } from "@/app/lib/utils"; import zodToJsonSchema from "zod-to-json-schema"; import { COPILOT_INSTRUCTIONS_EDIT_AGENT } from "./copilot_edit_agent"; import { COPILOT_INSTRUCTIONS_MULTI_AGENT } from "./copilot_multi_agent"; import { COPILOT_MULTI_AGENT_EXAMPLE_1 } from "./example_multi_agent_1"; import { CURRENT_WORKFLOW_PROMPT } from "./current_workflow"; -import { USE_COMPOSIO_TOOLS } from "../feature_flags"; -import { composio, getTool } from "../../../src/application/lib/composio/composio"; -import { UsageTracker } from "../billing"; +import { USE_COMPOSIO_TOOLS } from "@/app/lib/feature_flags"; +import { composio, getTool } from "../composio/composio"; +import { UsageTracker } from "@/app/lib/billing"; const PROVIDER_API_KEY = process.env.PROVIDER_API_KEY || process.env.OPENAI_API_KEY || ''; const PROVIDER_BASE_URL = process.env.PROVIDER_BASE_URL || undefined; diff --git a/apps/rowboat/app/lib/copilot/copilot_edit_agent.ts b/apps/rowboat/src/application/lib/copilot/copilot_edit_agent.ts similarity index 100% rename from apps/rowboat/app/lib/copilot/copilot_edit_agent.ts rename to apps/rowboat/src/application/lib/copilot/copilot_edit_agent.ts diff --git a/apps/rowboat/app/lib/copilot/copilot_multi_agent.ts b/apps/rowboat/src/application/lib/copilot/copilot_multi_agent.ts similarity index 100% rename from apps/rowboat/app/lib/copilot/copilot_multi_agent.ts rename to apps/rowboat/src/application/lib/copilot/copilot_multi_agent.ts diff --git a/apps/rowboat/app/lib/copilot/current_workflow.ts b/apps/rowboat/src/application/lib/copilot/current_workflow.ts similarity index 100% rename from apps/rowboat/app/lib/copilot/current_workflow.ts rename to apps/rowboat/src/application/lib/copilot/current_workflow.ts diff --git a/apps/rowboat/app/lib/copilot/example_multi_agent_1.ts b/apps/rowboat/src/application/lib/copilot/example_multi_agent_1.ts similarity index 100% rename from apps/rowboat/app/lib/copilot/example_multi_agent_1.ts rename to apps/rowboat/src/application/lib/copilot/example_multi_agent_1.ts diff --git a/apps/rowboat/app/lib/types/copilot_types.ts b/apps/rowboat/src/application/lib/copilot/types.ts similarity index 94% rename from apps/rowboat/app/lib/types/copilot_types.ts rename to apps/rowboat/src/application/lib/copilot/types.ts index 7758a620..5d42b0e8 100644 --- a/apps/rowboat/app/lib/types/copilot_types.ts +++ b/apps/rowboat/src/application/lib/copilot/types.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -import { Workflow } from "./workflow_types"; -import { Message } from "./types"; +import { Workflow } from "@/app/lib/types/workflow_types"; +import { Message } from "@/app/lib/types/types"; import { DataSource } from "@/src/entities/models/data-source"; export const DataSourceSchemaForCopilot = DataSource.pick({ diff --git a/apps/rowboat/src/application/use-cases/conversations/run-conversation-turn.use-case.ts b/apps/rowboat/src/application/use-cases/conversations/run-conversation-turn.use-case.ts index e26bd10f..d8b05aed 100644 --- a/apps/rowboat/src/application/use-cases/conversations/run-conversation-turn.use-case.ts +++ b/apps/rowboat/src/application/use-cases/conversations/run-conversation-turn.use-case.ts @@ -3,7 +3,7 @@ import { USE_BILLING } from "@/app/lib/feature_flags"; import { authorize, getCustomerIdForProject, logUsage, UsageTracker } from "@/app/lib/billing"; import { NotFoundError } from '@/src/entities/errors/common'; import { IConversationsRepository } from "@/src/application/repositories/conversations.repository.interface"; -import { streamResponse } from "@/app/lib/agents"; +import { streamResponse } from "@/src/application/lib/agents-runtime/agents"; import { z } from "zod"; import { Message } from "@/app/lib/types/types"; import { IUsageQuotaPolicy } from '../../policies/usage-quota.policy.interface';