feat: 升级至 v0.3.15 — MiMo 多模态 + 工作空间数据库继承 + 引导窗口上下文配置 + TS 错误修复

- feat(mimo): 适配器支持图片输入,将 images 转为 OpenAI 兼容 content parts 数组
- feat(workspace): 切换工作空间时支持继承数据库 agent.db(SQLite backup API 原子导出,自动 checkpoint WAL)
- feat(onboarding): 引导弹窗 LLM 配置加上下文长度字段(DeepSeek/Agnes=1000000、MiMo=131072、Ollama=null)
- fix(types): 修复 16 个 TypeScript 编译错误(setConfigLoaded 接口声明、10 个 IPC 返回类型加 error 字段、MUI TextField readOnly slot 迁移)
- chore(workspace): 移除死代码 traces 目录(trace 数据实际存储于数据库 sessions.metadata 字段,traces 目录从未被任何代码读写)
- docs(mimo): API 文档补充多模态输入章节和 curl/Python 代码示例
- chore: 版本号 0.3.14 → 0.3.15
This commit is contained in:
2026-07-21 21:05:50 +08:00
parent c0a26ce053
commit 516d8a728f
12 changed files with 318 additions and 33 deletions
+47 -1
View File
@@ -20,9 +20,24 @@ export function OnboardingWizard(): React.JSX.Element | null {
const [apiKey, setApiKey] = useState('');
const [showKey, setShowKey] = useState(false);
const [workspacePath, setWorkspacePath] = useState('');
// 上下文窗口(联动 Provider:ollama 可空=由模型决定;其他 provider 默认值见 DEFAULT_CTX
const [contextWindow, setContextWindow] = useState<number | null>(null);
if (onboardingCompleted) return null;
// 各 Provider 上下文窗口默认值(与 SettingsModal 保持一致)
// ollama 返回 null(由模型决定),其他 provider 返回正整数
const DEFAULT_CTX: Record<string, number | null> = {
deepseek: 1_000_000,
agnes: 1_000_000,
mimo: 131_072,
ollama: null,
};
// 上下文窗口校验:ollama 允许空,最小 512;其他 provider 最小 4096
const ctxMin = provider === 'ollama' ? 512 : 4096;
const ctxError =
contextWindow != null && (!Number.isFinite(contextWindow) || contextWindow < ctxMin);
const handleNext = async () => {
if (step < STEPS.length - 1) { setStep(step + 1); return; }
try {
@@ -39,6 +54,14 @@ export function OnboardingWizard(): React.JSX.Element | null {
if (model.trim()) entries.push({ key: 'llm.model', value: model.trim() });
if (apiKey.trim()) entries.push({ key: 'llm.apiKey', value: apiKey.trim() });
if (workspacePath.trim()) entries.push({ key: 'workspace.path', value: workspacePath.trim() });
// 上下文窗口:根据 Provider 落库到对应 key
// - ollama: ollama.numCtx(允许 null=由模型决定)
// - deepseek/agnes/mimo: {provider}.contextWindow(必须有值且 >= 4096
if (provider === 'ollama') {
entries.push({ key: 'ollama.numCtx', value: contextWindow });
} else if (provider && contextWindow != null && contextWindow >= 4096) {
entries.push({ key: `${provider}.contextWindow`, value: contextWindow });
}
entries.push({ key: 'onboarding.completed', value: true });
const r = await window.metona.config.setBatch(entries);
@@ -48,6 +71,10 @@ export function OnboardingWizard(): React.JSX.Element | null {
return;
}
useAgentStore.getState().setProvider(provider.trim() || 'deepseek', model.trim() || '');
// 同步 contextWindow 到 Agent Store(与 SettingsModal 行为一致)
if (contextWindow != null && contextWindow >= ctxMin) {
useAgentStore.setState({ contextWindow });
}
// P1-6 修复: Onboarding 完成后标记配置已加载
useAgentStore.getState().setConfigLoaded(true);
}
@@ -81,7 +108,12 @@ export function OnboardingWizard(): React.JSX.Element | null {
<Typography variant="body2" sx={{ color: 'text.secondary', mb: 2 }}> Provider API Base URL </Typography>
<Stack spacing={2}>
<FormControl size="small"><InputLabel>Provider</InputLabel>
<Select value={provider} label="Provider" onChange={(e) => setProvider(e.target.value)}>
<Select value={provider} label="Provider" onChange={(e) => {
const v = e.target.value;
setProvider(v);
// 联动默认上下文窗口(与 SettingsModal 默认值一致)
setContextWindow(DEFAULT_CTX[v] ?? null);
}}>
<MenuItem value="deepseek">DeepSeek</MenuItem>
<MenuItem value="agnes">Agnes AI</MenuItem>
<MenuItem value="mimo">MiMo ()</MenuItem>
@@ -93,6 +125,20 @@ export function OnboardingWizard(): React.JSX.Element | null {
<TextField size="small" label="API Key" type={showKey ? 'text' : 'password'} value={apiKey} onChange={(e) => setApiKey(e.target.value)} placeholder="sk-...(本地模型可留空)"
slotProps={{ input: { endAdornment: <InputAdornment position="end"><IconButton size="small" onClick={() => setShowKey(!showKey)}>{showKey ? <EyeOff size={14} /> : <Eye size={14} />}</IconButton></InputAdornment> } }}
/>
<TextField
size="small"
label={provider === 'ollama' ? '上下文长度 (num_ctx)' : '上下文窗口 (contextWindow)'}
type="number"
value={contextWindow ?? ''}
onChange={(e) => {
const v = e.target.value;
setContextWindow(v === '' ? null : Number(v));
}}
placeholder={provider === 'ollama' ? '默认由模型决定(如 2048、4096、128000' : '如 64000、128000、1000000'}
slotProps={{ htmlInput: { min: ctxMin, step: ctxMin } }}
error={ctxError}
helperText={ctxError ? `最小值为 ${ctxMin}` : (provider === 'ollama' ? ' ' : '用于上下文压缩判断,不传给 API')}
/>
</Stack>
</Box>
)}
+19 -3
View File
@@ -116,6 +116,8 @@ function WorkspaceSettings() {
const [checkResult, setCheckResult] = useState<MetonaWorkspaceCheckResult | null>(null);
const [checking, setChecking] = useState(false);
const [inheritSoul, setInheritSoul] = useState(true);
// 数据库继承:默认勾选(历史会话/消息/记忆/Trace 丢失不可逆,默认带过去更安全)
const [inheritDatabase, setInheritDatabase] = useState(true);
const [applying, setApplying] = useState(false);
const [showRestartDialog, setShowRestartDialog] = useState(false);
@@ -145,9 +147,12 @@ function WorkspaceSettings() {
if (!pendingPath || !checkResult?.valid) return;
setApplying(true);
try {
// 如果勾选了继承文件,从旧工作空间复制到新工作空间v0.3.14: 仅 SOUL.md
// 如果勾选了继承文件,从旧工作空间复制到新工作空间
// - SOUL.md: Agent 身份定义
// - .metona/agent.db: 数据库(会话/消息/记忆/Trace),后端白名单校验
const filesToInherit: string[] = [];
if (inheritSoul) filesToInherit.push('SOUL.md');
if (inheritDatabase) filesToInherit.push('.metona/agent.db');
if (filesToInherit.length > 0 && currentPath) {
try {
@@ -260,6 +265,18 @@ function WorkspaceSettings() {
control={<Checkbox size="small" checked={inheritSoul} onChange={(e) => setInheritSoul(e.target.checked)} />}
label={<Typography variant="caption">SOUL.md</Typography>}
/>
{/* 数据库继承:仅在新工作空间(空目录)时显示,避免覆盖已有工作空间的数据 */}
{checkResult.isNewWorkspace && (
<>
<FormControlLabel
control={<Checkbox size="small" checked={inheritDatabase} onChange={(e) => setInheritDatabase(e.target.checked)} />}
label={<Typography variant="caption"> agent.db///Trace </Typography>}
/>
<Typography variant="caption" sx={{ color: 'text.disabled', fontSize: 10, pl: 3 }}>
SQLite backup API
</Typography>
</>
)}
<Typography variant="caption" sx={{ color: 'text.disabled', fontSize: 10, pl: 3 }}>
MEMORY.md
</Typography>
@@ -1288,8 +1305,7 @@ function LogsSettings() {
fullWidth
value={logFilePath}
placeholder={logPathLoading ? '正在获取路径...' : '路径不可用'}
readOnly
slotProps={{ input: { sx: { fontSize: 11, fontFamily: 'monospace' } } }}
slotProps={{ input: { readOnly: true, sx: { fontSize: 11, fontFamily: 'monospace' } } }}
/>
<Stack direction="row" spacing={1} sx={{ mt: 1 }}>
<Button
+2 -2
View File
@@ -3,8 +3,8 @@
*
* 展示当前工作空间的:
* - 根路径(可在文件管理器中打开)
* - 4 个核心文件(SOUL/AGENTS/MEMORY/USERS):状态、大小、修改时间、内容预览
* - 自动目录(logs/traces/.metona):存在性和文件数
* - 2 个核心文件(SOUL/MEMORY):状态、大小、修改时间、内容预览
* - 自动目录(logs/.metona):存在性和文件数
*
* Agent 完成任务后自动刷新(thinking/executing → idle)。
*/
+2
View File
@@ -124,6 +124,8 @@ interface AgentState {
updateLastAssistantMessage: (delta: string) => void;
setAgentStatus: (status: AgentStatus) => void;
setStreaming: (streaming: boolean) => void;
// P1-6 修复: 配置加载完成标志的 setter
setConfigLoaded: (loaded: boolean) => void;
setCurrentRunId: (runId: string | null) => void;
addTraceStep: (step: TraceStep) => void;
updateTraceStep: (iteration: number, updates: Partial<TraceStep>) => void;
+10 -10
View File
@@ -85,8 +85,8 @@ interface MetonaSessionInfo {
interface MetonaSessionsAPI {
list: () => Promise<MetonaSessionInfo[]>;
create: (title?: string) => Promise<MetonaSessionInfo>;
rename: (sessionId: string, title: string) => Promise<{ success: boolean }>;
delete: (sessionId: string) => Promise<{ success: boolean }>;
rename: (sessionId: string, title: string) => Promise<{ success: boolean; error?: string }>;
delete: (sessionId: string) => Promise<{ success: boolean; error?: string }>;
getMessages: (sessionId: string) => Promise<Array<{
id: string;
role: string;
@@ -98,8 +98,8 @@ interface MetonaSessionsAPI {
iteration?: number;
timestamp: number;
}>>;
pin: (sessionId: string, pinned: boolean) => Promise<{ success: boolean }>;
archive: (sessionId: string, archived: boolean) => Promise<{ success: boolean }>;
pin: (sessionId: string, pinned: boolean) => Promise<{ success: boolean; error?: string }>;
archive: (sessionId: string, archived: boolean) => Promise<{ success: boolean; error?: string }>;
deleteMessage: (messageId: string) => Promise<{ success: boolean }>;
clearMessages: (sessionId: string) => Promise<{ success: boolean }>;
saveTrace: (sessionId: string, data: { traceSteps: unknown[]; tokenUsage: unknown }) => Promise<{ success: boolean }>;
@@ -126,9 +126,9 @@ interface MetonaMCPServerStatus {
interface MetonaMCPAPI {
listServers: () => Promise<MetonaMCPServerStatus[]>;
addServer: (config: MetonaMCPServerConfig) => Promise<{ success: boolean }>;
removeServer: (name: string) => Promise<{ success: boolean }>;
toggleServer: (name: string, enabled: boolean) => Promise<{ success: boolean }>;
addServer: (config: MetonaMCPServerConfig) => Promise<{ success: boolean; error?: string }>;
removeServer: (name: string) => Promise<{ success: boolean; error?: string }>;
toggleServer: (name: string, enabled: boolean) => Promise<{ success: boolean; error?: string }>;
}
// ===== Memory API =====
@@ -161,9 +161,9 @@ interface MetonaMemoryAPI {
interface MetonaConfigAPI {
get: (key: string) => Promise<unknown>;
set: (key: string, value: unknown) => Promise<{ success: boolean }>;
set: (key: string, value: unknown) => Promise<{ success: boolean; error?: string }>;
// v0.3.9: 批量保存配置,避免串行保存中间态触发 reloadAdapter 失败
setBatch: (entries: Array<{ key: string; value: unknown }>) => Promise<{ success: boolean }>;
setBatch: (entries: Array<{ key: string; value: unknown }>) => Promise<{ success: boolean; error?: string }>;
}
// ===== App API =====
@@ -247,7 +247,7 @@ interface MetonaToolInfo {
interface MetonaToolsAPI {
list: () => Promise<MetonaToolInfo[]>;
toggle: (toolName: string, enabled: boolean) => Promise<{ success: boolean }>;
toggle: (toolName: string, enabled: boolean) => Promise<{ success: boolean; error?: string }>;
}
// ===== SearXNG API =====