chore: establish YCode replication baseline and TODO
This commit is contained in:
commit
6dc59f89ba
1118 files changed
+196002
No files matched your search
@@ -0,0 +1,169 @@
|
||||
/**
|
||||
* 主进程 / 渲染进程共享的类型与 IPC 契约。
|
||||
*
|
||||
* 已存 API Key 不返回渲染进程;用户可在模型表单编辑地址和新密钥。
|
||||
* 模型网络请求经由主进程网关或 OMP 子进程完成。
|
||||
*/
|
||||
|
||||
/** 会话内的一条消息(对外视图) */
|
||||
import type { ArtifactContent, ChatAttachment, ChatInteraction, PlanContent, TaskContent } from './conversation'
|
||||
|
||||
export interface ChatMessage {
|
||||
id: string
|
||||
role: 'user' | 'assistant'
|
||||
content: string
|
||||
/** 助手消息携带的工具调用记录 */
|
||||
tools?: ToolCallRecord[]
|
||||
/** 按事件顺序记录正文与工具位置;旧会话没有此字段时按兼容方式渲染。 */
|
||||
parts?: MessagePart[]
|
||||
attachments?: ChatAttachment[]
|
||||
resources?: string[]
|
||||
skills?: Array<{ id: string; name: string; uri: string }>
|
||||
/** Native-history reconstruction; never includes connector credentials. */
|
||||
capabilityContext?: string
|
||||
expertId?: string
|
||||
assistantDisplay?: import('./capabilities').ExpertBinding
|
||||
/** The model selected when this assistant turn started; kept with history. */
|
||||
modelId?: string
|
||||
modelName?: string
|
||||
interactions?: ChatInteraction[]
|
||||
requestId?: string
|
||||
planId?: string
|
||||
nativeEntryId?: string
|
||||
nativeSessionPath?: string
|
||||
feedback?: 'like' | 'dislike'
|
||||
interrupted?: boolean
|
||||
createdAt: number
|
||||
/** User-submit timestamp shared by the live timer and terminal turn duration. */
|
||||
turnStartedAt?: number
|
||||
/** Measured user-send to terminal-event duration, used by the source completed fold. */
|
||||
turnDurationMs?: number
|
||||
/** 本回合的终态 */
|
||||
status?: 'streaming' | 'done' | 'error' | 'cancelled'
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface ToolCallRecord {
|
||||
id: string
|
||||
name: string
|
||||
/** Human-readable action description supplied by the tool runtime, when available. */
|
||||
intent?: string
|
||||
/** 已解析的参数(原始 JSON 字符串的解析结果,解析失败则保留原文) */
|
||||
args: unknown
|
||||
argsRaw: string
|
||||
status: 'running' | 'ok' | 'error' | 'cancelled'
|
||||
/** 完整的文本输出;summary 仅供折叠态摘要,不能替代原文。 */
|
||||
output?: string
|
||||
/** 展示用摘要(截断后的结果) */
|
||||
summary?: string
|
||||
durationMs?: number
|
||||
/** Native structured result and renderer metadata are retained separately from text. */
|
||||
result?: unknown
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type MessagePart =
|
||||
| { type: 'text'; text: string }
|
||||
| { type: 'tool'; toolId: string }
|
||||
| { type: 'reasoning'; id: string; text: string; finished?: boolean }
|
||||
| { type: 'plan'; plan: PlanContent }
|
||||
| { type: 'task'; task: TaskContent }
|
||||
| { type: 'artifact'; artifact: ArtifactContent }
|
||||
| { type: 'image'; id: string; url: string; alt?: string }
|
||||
|
||||
/** 面向模型暴露的工具描述(OpenAI function tool 格式) */
|
||||
export interface ToolSpec {
|
||||
type: 'function'
|
||||
function: {
|
||||
name: string
|
||||
description: string
|
||||
parameters: Record<string, unknown>
|
||||
}
|
||||
}
|
||||
|
||||
/** 网关配置:一个 OpenAI 兼容的上游 */
|
||||
export interface GatewayConfig {
|
||||
speechBaseUrl?: string
|
||||
speechModel?: string
|
||||
/** 上游 baseUrl,例如 https://api.deepseek.com/v1 */
|
||||
baseUrl: string
|
||||
/** 模型名,例如 deepseek-chat */
|
||||
model: string
|
||||
/** API Key(仅存在于主进程) */
|
||||
apiKey: string
|
||||
/** 采样温度 */
|
||||
temperature: number
|
||||
/** 单回合最大工具轮次 */
|
||||
maxToolRounds: number
|
||||
authMode?: 'api-key' | 'none'
|
||||
maxOutputTokens?: number
|
||||
}
|
||||
|
||||
/** 渲染进程可见的配置视图(不含 apiKey) */
|
||||
export interface GatewayConfigView {
|
||||
speechBaseUrl?: string
|
||||
speechModel?: string
|
||||
baseUrl: string
|
||||
model: string
|
||||
temperature: number
|
||||
maxToolRounds: number
|
||||
/** 是否已配置 Key(不回传明文) */
|
||||
hasApiKey: boolean
|
||||
/** Key 来源:safeStorage 加密 / 明文降级 */
|
||||
keyStorage: 'encrypted' | 'plaintext' | 'none'
|
||||
}
|
||||
|
||||
/** 主进程 → 渲染进程的流式事件 */
|
||||
export type ChatEvent = { sessionId?: string; turnDurationMs?: number } & (
|
||||
| { runId: string; type: 'started'; messageId: string }
|
||||
| { runId: string; type: 'text'; delta: string }
|
||||
| { runId: string; type: 'part'; part: Exclude<MessagePart, { type: 'text' } | { type: 'tool' }> }
|
||||
| { runId: string; type: 'interaction'; interaction: ChatInteraction }
|
||||
| { runId: string; type: 'tool_call'; call: ToolCallRecord }
|
||||
| { runId: string; type: 'tool_result'; call: ToolCallRecord }
|
||||
| { runId: string; type: 'done'; content: string; tools: ToolCallRecord[] }
|
||||
| { runId: string; type: 'cancelled' }
|
||||
| { runId: string; type: 'error'; message: string }
|
||||
)
|
||||
|
||||
/** 一次会话的元信息 */
|
||||
export interface SessionMeta {
|
||||
id: string
|
||||
title: string
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
workspaceId?: string
|
||||
cwd?: string
|
||||
modelId?: string
|
||||
expertId?: string | null
|
||||
agentMode?: import('./conversation').AgentMode
|
||||
thinkingLevel?: import('./workspaces').ThinkingLevel
|
||||
}
|
||||
|
||||
/** 工作目录信息 */
|
||||
export interface WorkspaceInfo {
|
||||
root: string
|
||||
}
|
||||
|
||||
/** 无边框窗口状态 */
|
||||
export interface WindowState {
|
||||
maximized: boolean
|
||||
fullscreen: boolean
|
||||
}
|
||||
|
||||
/** 应用信息(关于对话框用) */
|
||||
export interface AppInfo {
|
||||
name: string
|
||||
version: string
|
||||
electron: string
|
||||
chrome: string
|
||||
node: string
|
||||
configDir: string
|
||||
/** OMP 内核状态(未探测到时 available 为 false) */
|
||||
omp: {
|
||||
available: boolean
|
||||
exePath: string | null
|
||||
profile: string
|
||||
model: string | null
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user