relocate copilot types

This commit is contained in:
Ramnique Singh 2025-08-23 10:58:38 +05:30
parent 6fc6abc2bc
commit 531f9feea6
9 changed files with 9 additions and 9 deletions

View file

@ -2,7 +2,7 @@ import z from "zod";
import { createOpenAI } from "@ai-sdk/openai";
import { generateObject, streamText, tool } from "ai";
import { Workflow, WorkflowTool } from "@/app/lib/types/workflow_types";
import { CopilotChatContext, CopilotMessage, DataSourceSchemaForCopilot } from "./types";
import { CopilotChatContext, CopilotMessage, DataSourceSchemaForCopilot } from "../../../entities/models/copilot";
import { PrefixLogger } from "@/app/lib/utils";
import zodToJsonSchema from "zod-to-json-schema";
import { COPILOT_INSTRUCTIONS_EDIT_AGENT } from "./copilot_edit_agent";

View file

@ -1,71 +0,0 @@
import { z } from "zod";
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({
id: true,
name: true,
description: true,
data: true,
});
export const CopilotUserMessage = z.object({
role: z.literal('user'),
content: z.string(),
});
export const CopilotAssistantMessageTextPart = z.object({
type: z.literal("text"),
content: z.string(),
});
export const CopilotAssistantMessageActionPart = z.object({
type: z.literal("action"),
content: z.object({
config_type: z.enum(['tool', 'agent', 'prompt', 'pipeline', 'start_agent']),
action: z.enum(['create_new', 'edit', 'delete']),
name: z.string(),
change_description: z.string(),
config_changes: z.record(z.string(), z.unknown()),
error: z.string().optional(),
})
});
export const CopilotAssistantMessage = z.object({
role: z.literal('assistant'),
content: z.string(),
});
export const CopilotMessage = z.union([CopilotUserMessage, CopilotAssistantMessage]);
export const CopilotChatContext = z.union([
z.object({
type: z.literal('chat'),
messages: z.array(Message),
}),
z.object({
type: z.literal('agent'),
name: z.string(),
}),
z.object({
type: z.literal('tool'),
name: z.string(),
}),
z.object({
type: z.literal('prompt'),
name: z.string(),
}),
]);
export const CopilotAPIRequest = z.object({
projectId: z.string(),
messages: z.array(CopilotMessage),
workflow: Workflow,
context: CopilotChatContext.nullable(),
dataSources: z.array(DataSourceSchemaForCopilot).optional(),
});
export const CopilotAPIResponse = z.union([
z.object({
response: z.string(),
}),
z.object({
error: z.string(),
}),
]);