fix(identity): 3 项根因级修复 — Agent ID 映射 + user_profile 读取 + 用户画像 fallback
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Issue 2: IdentityFile 枚举补全 UserProfile 变体 - get_file()/propose_change()/approve_proposal() 补全 match arm - identity_get_file/identity_propose_change Tauri 命令支持 user_profile Issue 1: Agent ID 映射机制 - 新增 resolveKernelAgentId() 工具函数 (带缓存) - ButlerPanel 使用 kernel UUID 替代 SaaS relay "1" 查询 VikingStorage Issue 3: 用户画像 fallback 注入 - build_system_prompt 改为 async,identity user_profile 为默认值时 从 VikingStorage preferences 路径查询最近 5 条记忆作为 fallback - intelligence_hooks 调用处同步加 .await Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -270,3 +270,42 @@ export function installAgentMethods(ClientClass: { prototype: KernelClient }): v
|
||||
return { clone };
|
||||
};
|
||||
}
|
||||
|
||||
// === Agent ID Resolution ===
|
||||
|
||||
/**
|
||||
* Cached kernel default agent UUID.
|
||||
* The conversationStore's DEFAULT_AGENT has id="1", but VikingStorage
|
||||
* stores data under kernel UUIDs. This cache bridges the gap.
|
||||
*/
|
||||
let _cachedDefaultKernelAgentId: string | null = null;
|
||||
|
||||
/**
|
||||
* Resolve an agent ID to the kernel's actual agent UUID.
|
||||
* - If already a UUID (8-4-4 hex pattern), return as-is.
|
||||
* - If "1" or undefined, query agent_list and cache the first kernel agent's UUID.
|
||||
* - Falls back to the original ID if kernel has no agents.
|
||||
*/
|
||||
export async function resolveKernelAgentId(agentId: string | undefined): Promise<string> {
|
||||
if (agentId && /^[0-9a-f]{8}-[0-9a-f]{4}-/.test(agentId)) {
|
||||
return agentId;
|
||||
}
|
||||
if (_cachedDefaultKernelAgentId) {
|
||||
return _cachedDefaultKernelAgentId;
|
||||
}
|
||||
try {
|
||||
const agents = await invoke<{ id: string }[]>('agent_list');
|
||||
if (agents.length > 0) {
|
||||
_cachedDefaultKernelAgentId = agents[0].id;
|
||||
return _cachedDefaultKernelAgentId;
|
||||
}
|
||||
} catch {
|
||||
// Kernel may not be available
|
||||
}
|
||||
return agentId || '1';
|
||||
}
|
||||
|
||||
/** Invalidate cache when kernel reconnects (new instance may have different UUIDs) */
|
||||
export function invalidateKernelAgentIdCache(): void {
|
||||
_cachedDefaultKernelAgentId = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user