fix(FN-915): use getFusionDir() for agent storage location

- Add getFusionDir() method to TaskStore for resolving agent database path
- Update in-process-runtime to use getFusionDir() instead of hardcoded path
- Update dashboard routes AgentStore initialization to use getFusionDir()
- Add changeset for published package patch bump
This commit is contained in:
gsxdsm
2026-04-04 12:35:15 -07:00
parent fbda14717e
commit c32c4e6e83
5 changed files with 23 additions and 12 deletions

View File

@@ -2744,6 +2744,11 @@ ${stepsSection}`;
return this.rootDir;
}
/** Return the `.fusion` directory path (e.g. `/project/.fusion`). */
getFusionDir(): string {
return this.kbDir;
}
getTasksDir(): string {
return this.tasksDir;
}

View File

@@ -6273,7 +6273,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
const agents = await agentStore.listAgents(filter as { state?: "idle" | "active" | "paused" | "terminated"; role?: import("@fusion/core").AgentCapability });
@@ -6302,7 +6302,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
const agent = await agentStore.createAgent({ name, role: role as import("@fusion/core").AgentCapability, metadata });
@@ -6321,7 +6321,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
try {
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
const agents = await agentStore.listAgents();
@@ -6352,7 +6352,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
try {
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
const agent = await agentStore.getAgentDetail(req.params.id, 50);
@@ -6376,7 +6376,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
const agent = await agentStore.updateAgent(req.params.id, { name, role, metadata });
@@ -6405,7 +6405,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
const agent = await agentStore.updateAgentState(req.params.id, state as import("@fusion/core").AgentState);
@@ -6429,7 +6429,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
try {
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
await agentStore.deleteAgent(req.params.id);
@@ -6453,7 +6453,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
const event = await agentStore.recordHeartbeat(req.params.id, status as "ok" | "missed" | "recovered");
@@ -6478,7 +6478,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
const history = await agentStore.getHeartbeatHistory(req.params.id, limit);
@@ -6497,7 +6497,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
try {
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
const limit = typeof req.query.limit === "string" ? parseInt(req.query.limit, 10) : 20;
@@ -6520,7 +6520,7 @@ Output ONLY the prompt text (no markdown, no explanations).`;
try {
const scopedStore = await getScopedStore(req);
const { AgentStore } = await import("@fusion/core");
const agentStore = new AgentStore({ rootDir: scopedStore.getRootDir() });
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
await agentStore.init();
const run = await agentStore.getRunDetail(req.params.id, req.params.runId);

View File

@@ -13,6 +13,7 @@ vi.mock("@fusion/core", async () => {
TaskStore: vi.fn().mockImplementation(function(this: TaskStore, rootDir: string) {
const self = this as unknown as Record<string, unknown>;
self.getRootDir = () => rootDir;
self.getFusionDir = () => rootDir + "/.fusion";
self.init = vi.fn().mockResolvedValue(undefined);
self.listTasks = vi.fn().mockResolvedValue([]);
self.getSettings = vi.fn().mockResolvedValue({});

View File

@@ -208,7 +208,7 @@ export class InProcessRuntime
// 6. Initialize AgentStore and HeartbeatMonitor
try {
const { AgentStore: AgentStoreClass } = await import("@fusion/core");
this.agentStore = new AgentStoreClass({ rootDir: this.taskStore.getRootDir() });
this.agentStore = new AgentStoreClass({ rootDir: this.taskStore.getFusionDir() });
await this.agentStore.init();
this.heartbeatMonitor = new HeartbeatMonitor({