CoolFace
Apppublic

Leon4gr45/builder

sourceHugging Facemitupdated 2d agoView on Hugging Face
0likes
types.ts96 linesDownload Raw Back to server-generate
1// lib/server-generate/types.ts2import type { MultiAgentOrchestrator } from '@/lib/llm/multi-agent-orchestrator';3import type { VirtualFileSystem } from '@/lib/vfs';4import type { ProviderId } from '@/lib/llm/providers/types';5 6/** Passed to MultiAgentOrchestrator when running server-side */7export interface ServerOrchestratorContext {8  apiBaseUrl: string;9  vfs: VirtualFileSystem;10  config: ServerGenerationParams;11  onEvent: (event: string, data: Record<string, unknown>) => void;12  /** Paths mutated since last flush — populated by VFS mutation proxy */13  dirtyPaths: Set<string>;14}15 16/** All config the server needs from the client to run generation */17export interface ServerGenerationParams {18  provider: ProviderId;19  model: string;20  apiKey: string;21  providerBaseUrl?: string;22  temperature?: number;23  maxTokens?: number;24  reasoningEnabled?: boolean;25  compactionEnabled?: boolean;26  compactionLimit?: number;27  debugStreamEnabled?: boolean;28  modelPricing?: Record<string, { prompt: number; completion: number }>;29  cachedModels?: Array<{ id: string; name: string; context_length?: number }>;30}31 32/** Server-side task state */33export interface ServerTask {34  taskId: string;35  projectId: string;36  sessionId: string;37  workspaceId?: string;38  status: 'running' | 'paused' | 'stopping' | 'completed' | 'failed' | 'cancelled';39  startedAt: number;40  orchestrator: MultiAgentOrchestrator | null;41  buildDeferred: boolean;42  /** Resolve function for pending build delegation */43  pendingBuildResolve: ((result: BuildResult) => void) | null;44  /** Metadata for client display (shelf) */45  prompt?: string;46  model?: string;47  projectName?: string;48}49 50export interface BuildResult {51  success: boolean;52  errors?: string[];53}54 55/** SSE event envelope */56export interface SSEEvent {57  id: number;58  event: string;59  data: Record<string, unknown> & { sourceProjectId: string };60  buffered: boolean; // false for delta events (not stored in replay buffer)61}62 63/** Start generation request body */64export interface StartGenerationRequest {65  projectId: string;66  prompt: string;67  model: string;68  apiKey: string;69  workspaceId?: string;70  projectName?: string;71  providerConfig?: { baseUrl?: string; provider?: ProviderId };72  permissionMode?: 'auto' | 'ask' | 'custom';73  permissionOverrides?: Record<string, 'ask' | 'allow'>;74  conversationHistory: unknown[];75  executeOptions?: {76    images?: Array<{ data: string; mediaType: string }>;77    focusContext?: { domPath: string; snippet: string };78    semanticBlocks?: Array<{ name: string; domPath: string; position: string; description: string }>;79    displayPrompt?: string;80  };81  generationParams: Omit<ServerGenerationParams, 'provider' | 'model' | 'apiKey' | 'providerBaseUrl'>;82}83 84/** Batch file fetch request */85export interface FileFetchRequest {86  taskId: string;87  paths: string[];88}89 90/** Batch file fetch response item */91export interface FileFetchResponseItem {92  path: string;93  content: string;94  binary: boolean;95}96