From 9542ee0df3e2c551260b20fb4db71f8d74dff376 Mon Sep 17 00:00:00 2001 From: Sylvain Gougouzian Date: Mon, 13 Jul 2026 11:05:32 +0200 Subject: [PATCH] feat(types): add core TypeScript type definitions - Add interfaces for models, messages, state, DMR protocol - Add tool system types (ToolDefinition, ToolCall, ToolResult) - Add UI types (UIMode, Action, Step, AgentStep) --- src/types.ts | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/types.ts diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..58626e0 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,137 @@ +export interface ProjectConfig { + name: string; + lang: string; + framework: string; + database: string[]; + services: string[]; + port: number; +} + +export interface Model { + id: string; + name: string; + engine?: string; +} + +export interface Message { + role: "system" | "user" | "assistant"; + content: string; + timestamp?: number; +} + +export interface ThinkingState { + active: boolean; + content: string; + tokens: number; +} + +export interface Step { + id: string; + name: string; + status: "done" | "current" | "pending"; +} + +export interface AppState { + model: Model | null; + models: Model[]; + messages: Message[]; + steps: Step[]; + thinking: ThinkingState; + result: string; + prompt: string; + scrollOffset: number; + thinkingVisible: boolean; + streaming: boolean; + agentSteps: AgentStep[]; + toolCallsStreaming: Map; + uiMode: UIMode; + toolbarIndex: number; + paletteIndex: number; + suggestions: string[]; + suggestionIndex: number; +} + +export interface DMRChatRequest { + model: string; + messages: { role: string; content: string }[]; + stream: boolean; + temperature?: number; + max_tokens?: number; +} + +export interface DMRChatChunk { + choices: { + delta: { + content?: string; + reasoning_content?: string; + tool_calls?: { + id: string; + type: "function"; + function: { name: string; arguments: string }; + }[]; + }; + finish_reason: string | null; + }[]; +} + +export type ToolHandler = "shell" | "http" | "js" | "builtin"; + +export interface ToolParameter { + type: "string" | "number" | "boolean"; + description: string; + enum?: string[]; +} + +export interface ToolDefinition { + name: string; + description: string; + parameters: { + type: "object"; + properties: Record; + required: string[]; + }; + handler: ToolHandler; + command?: string; + url?: string; + method?: string; + script?: string; + sandbox?: boolean; + destructive?: boolean; +} + +export interface ToolCall { + id: string; + name: string; + arguments: Record; +} + +export interface ToolResult { + toolCallId: string; + name: string; + success: boolean; + result: string; +} + +export type StreamChunk = + | { type: "thinking"; text: string } + | { type: "content"; text: string } + | { type: "tool_call"; id: string; name: string; arguments: string }; + +export interface AgentStep { + id: string; + type: "tool_call" | "tool_result" | "thinking" | "content"; + name?: string; + arguments?: Record; + content?: string; + status: "running" | "done" | "error"; + timestamp: number; +} + +export type UIMode = "normal" | "palette" | "toolbar"; + +export interface Action { + id: string; + label: string; + shortcut?: string; + action: () => void; +} -- 2.51.2