refactor(FN-2161): standardize on createFnAgent naming

- Rename engine export and call sites to use createFnAgent consistently across runtime flows
- Update core lazy engine loader and dashboard agent-generation/planning/chat paths to reference createFnAgent
- Refresh affected unit and integration tests, including renaming pi-create-kb-agent.test.ts to pi-create-fn-agent.test.ts
- Update AGENTS.md documentation references to match the new createFnAgent name
This commit is contained in:
Fusion
2026-04-19 17:50:41 -07:00
committed by gsxdsm
parent 0df3234349
commit 6714f7654b
58 changed files with 425 additions and 425 deletions

View File

@@ -1,5 +1,5 @@
/**
* Shared lazy loader for `@fusion/engine`'s `createKbAgent`.
* Shared lazy loader for `@fusion/engine`'s `createFnAgent`.
*
* @fusion/engine must be imported dynamically (not statically) so that:
* - core can be consumed in test environments where engine isn't resolvable
@@ -12,17 +12,17 @@
// Engine exports a function type we intentionally don't pull in here — importing
// the type would reintroduce the static resolution this module is designed to avoid.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type CreateKbAgent = any;
type CreateFnAgent = any;
let createKbAgent: CreateKbAgent | undefined;
let createFnAgent: CreateFnAgent | undefined;
async function initEngine(): Promise<void> {
try {
const engineModule = "@fusion/engine";
const engine = await import(/* @vite-ignore */ engineModule);
createKbAgent = engine.createKbAgent;
createFnAgent = engine.createFnAgent;
} catch {
createKbAgent = undefined;
createFnAgent = undefined;
}
}
@@ -36,10 +36,10 @@ export interface AgentMessage {
const engineReady: Promise<void> = initEngine();
/**
* Returns `createKbAgent` from `@fusion/engine`, or `undefined` if the engine
* Returns `createFnAgent` from `@fusion/engine`, or `undefined` if the engine
* could not be loaded (typical in tests or when engine isn't installed).
*/
export async function getKbAgent(): Promise<CreateKbAgent> {
export async function getKbAgent(): Promise<CreateFnAgent> {
await engineReady;
return createKbAgent;
return createFnAgent;
}