feat(hub): support profileId in createAgent

- Add profileId option to createAgent() method
- Default to "default" profile for all agents
- Ensures every agent has an associated profile for memory and config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jiang Bohan 2026-02-03 18:25:48 +08:00
parent 6f6a4f82e4
commit 864d9166fc

View file

@ -128,7 +128,7 @@ export class Hub {
}
/** Create new Agent, or rebuild with existing ID */
createAgent(id?: string, options?: { persist?: boolean }): AsyncAgent {
createAgent(id?: string, options?: { persist?: boolean; profileId?: string }): AsyncAgent {
if (id) {
const existing = this.agents.get(id);
if (existing && !existing.closed) {
@ -136,7 +136,7 @@ export class Hub {
}
}
const agent = new AsyncAgent({ sessionId: id });
const agent = new AsyncAgent({ sessionId: id, profileId: options?.profileId ?? "default" });
this.agents.set(agent.sessionId, agent);
// Persist to agent store (skip during restore to avoid duplicates)