豆包复刻:原生安卓(Compose + 内嵌 Termux)+ Web / Windows
一个界面照着豆包抠的 AI 助手。主力是安卓端,完全离线自主:不依赖电脑、 不需要另外装 Termux。 安卓端 - 原生 Jetpack Compose,7 个页面,配色/圆角/间距对着真机截图量出来的 - 完整动效:抽屉滑入、页面切换、气泡淡入上移、面板底部升起、typing 三点、按钮回弹 - 内置 Termux:bash/apt/pkg 388 个命令、真 pty 终端; pty 不可用的 ROM 上自动降级成命令控制台 - APK 内嵌 CPython 3.13(Chaquopy),AI 内核跑在手机上 - 设备能力:定位 / 陀螺仪 / 加速度计 / 光线 / 电量 / 剪贴板 - 语音:朗读 + 语音输入,火山豆包音色 / OpenAI 兼容 / 设备自带三级引擎 AI 能力 - 10 家 OpenAI 兼容提供商:方舟 / OpenAI / DeepSeek / Kimi / 智谱 / 通义 / 硅基流动 / OpenRouter / 本地 Ollama / 自定义 - 思考强度按各家支持情况发不同字段(thinking / reasoning_effort / 不发), 认不出来的一律不发,避免给不支持的厂商发字段直接 400 - MCP 三种传输(http / stdio / inproc)、工具热加载、文件上传、权限模式 跨端 - 安卓走原生 Compose,Web / Windows 走 Lynx - Node 与 Python 两份内核接口逐字段一致,关键路径都有对拍脚本 自检脚本(都不需要真 Key) - verify-phone.mjs 设备端 24 项验收 - verify-speech.mjs 语音链路 31 项,两份内核各跑一遍 - parity-thinking.mjs 思考强度映射对拍 - probe-settings-wipe.mjs 设置防清空攻击测试 - mock-llm.mjs 假的 OpenAI + 火山语音服务 许可 MIT;第三方组件(Termux Apache-2.0、Chaquopy、Compose、LynxJS、Electron) 的授权见 LICENSE。
This commit is contained in:
132
app/src/types.ts
Normal file
132
app/src/types.ts
Normal file
@@ -0,0 +1,132 @@
|
||||
/** 与内核交互的数据类型 */
|
||||
|
||||
export interface Conversation {
|
||||
id: string;
|
||||
title: string;
|
||||
agentId?: string;
|
||||
pinned?: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
messageCount: number;
|
||||
/** 最后一条消息的预览(真实聊天记录) */
|
||||
preview?: string;
|
||||
}
|
||||
|
||||
export interface Attachment {
|
||||
id: string;
|
||||
name: string;
|
||||
size: number;
|
||||
mime?: string;
|
||||
url?: string;
|
||||
path?: string;
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
role: 'user' | 'assistant' | 'system' | 'tool';
|
||||
content: string;
|
||||
at?: string;
|
||||
attachments?: Attachment[];
|
||||
/** 该条回复的思维链(模型返回 reasoning 时才有) */
|
||||
reasoning?: string;
|
||||
/** 该条回复调用过的工具(用于在气泡下展示) */
|
||||
toolTrace?: ToolTrace[];
|
||||
pending?: boolean;
|
||||
error?: boolean;
|
||||
/** 本地反馈状态 */
|
||||
feedback?: 'up' | 'down' | null;
|
||||
}
|
||||
|
||||
export interface ToolTrace {
|
||||
id: string;
|
||||
name: string;
|
||||
args?: unknown;
|
||||
ok?: boolean;
|
||||
result?: string;
|
||||
}
|
||||
|
||||
export interface Security {
|
||||
mode: 'open' | 'restricted';
|
||||
allow: string[];
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
provider: string;
|
||||
baseUrl: string;
|
||||
model: string;
|
||||
apiKey: string;
|
||||
hasApiKey?: boolean;
|
||||
temperature: number;
|
||||
maxRounds: number;
|
||||
/** off / low / medium / high / auto */
|
||||
thinkingLevel: string;
|
||||
/** 额外的工具目录(安卓端可以指到手机上的目录) */
|
||||
toolsDir: string;
|
||||
systemPrompt: string;
|
||||
tools: { python: boolean; mcp: boolean };
|
||||
security: Security;
|
||||
pythonBin: string;
|
||||
nickname: string;
|
||||
doubaoId: string;
|
||||
activeAgentId: string;
|
||||
}
|
||||
|
||||
export interface Agent {
|
||||
id: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
tagline?: string;
|
||||
systemPrompt: string;
|
||||
builtin?: boolean;
|
||||
}
|
||||
|
||||
export interface ProviderPreset {
|
||||
label: string;
|
||||
baseUrl: string;
|
||||
apiKeyEnv: string;
|
||||
defaultModel: string;
|
||||
modelHint: string;
|
||||
docs: string;
|
||||
models: string[];
|
||||
}
|
||||
|
||||
export interface PythonTool {
|
||||
name: string;
|
||||
description: string;
|
||||
parameters: Record<string, unknown>;
|
||||
file: string;
|
||||
}
|
||||
|
||||
export interface McpServer {
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
transport: string;
|
||||
target: string;
|
||||
connected: boolean;
|
||||
error: string | null;
|
||||
tools: { name: string; description: string }[];
|
||||
}
|
||||
|
||||
export interface AppState {
|
||||
settings: Settings;
|
||||
provider: ProviderPreset;
|
||||
providers: Record<string, ProviderPreset>;
|
||||
python: { tools: PythonTool[]; errors: { file: string; error: string }[]; interpreter: string | null };
|
||||
mcp: McpServer[];
|
||||
conversations: Conversation[];
|
||||
agents: Agent[];
|
||||
toolNames: string[];
|
||||
suggestedAllow: string[];
|
||||
/** 内核所在平台:win32 / linux / android */
|
||||
platform?: string;
|
||||
shellKind?: string;
|
||||
}
|
||||
|
||||
export type StreamEvent =
|
||||
| { type: 'start'; provider: string; model: string; tools: number; mode?: string; thinkingLevel?: string; agent?: { id: string; name: string } | null }
|
||||
| { type: 'delta'; text: string; round: number }
|
||||
| { type: 'reasoning'; text: string; round: number }
|
||||
| { type: 'tool_call'; id: string; name: string; args: unknown }
|
||||
| { type: 'tool_result'; id: string; name: string; ok: boolean; result: string }
|
||||
| { type: 'done'; content: string; reasoning?: string; rounds: number; toolCalls: number; usage?: unknown }
|
||||
| { type: 'saved'; conversationId: string; title?: string }
|
||||
| { type: 'error'; message: string; hint?: string };
|
||||
Reference in New Issue
Block a user