feat(FN-3612): preserve fusion context in hermes runtime skill forwarding

Merges five commits implementing centralized runtime skill forwarding that preserves Fusion context across the Hermes runtime layer. The engine's `agent-runtime` and `agent-session-helpers` were updated to forward skills at runtime, with `runtime-adapter.ts` and its types extended to carry context.

Fusion-Task-Id: FN-3612
This commit is contained in:
Fusion
2026-05-06 12:57:21 -07:00
committed by gsxdsm
parent 884b91dfc2
commit 2ca67c02f2
9 changed files with 121 additions and 7 deletions

View File

@@ -8,6 +8,7 @@
*/
import type { AgentRuntimeOptions } from "./agent-runtime.js";
import type { SkillSelectionContext } from "./skill-resolver.js";
import type { PluginRunner } from "./plugin-runner.js";
import type { AgentSession } from "@mariozechner/pi-coding-agent";
import { resolveRuntime, buildRuntimeResolutionContext, type SessionPurpose } from "./runtime-resolution.js";
@@ -17,6 +18,16 @@ import { promptWithFallback, describeModel } from "./pi.js";
/** Logger for agent session helpers */
const sessionLog = createLogger("agent-session");
function extractSkillNamesFromSelection(skillSelection: SkillSelectionContext | undefined): string[] {
if (!skillSelection || !Array.isArray(skillSelection.requestedSkillNames)) {
return [];
}
return skillSelection.requestedSkillNames
.map((name) => (typeof name === "string" ? name.trim() : ""))
.filter((name) => name.length > 0);
}
/**
* Options for creating an agent session with runtime resolution.
*/
@@ -115,7 +126,17 @@ export function extractRuntimeModel(
export async function createResolvedAgentSession(
options: ResolvedSessionOptions,
): Promise<ResolvedSessionResult> {
const { sessionPurpose, pluginRunner, runtimeHint, ...runtimeOptions } = options;
const { sessionPurpose, pluginRunner, runtimeHint, ...runtimeOptionsRaw } = options;
const skillNamesFromSelection = extractSkillNamesFromSelection(runtimeOptionsRaw.skillSelection);
const mergedSkillNames = runtimeOptionsRaw.skills && runtimeOptionsRaw.skills.length > 0
? runtimeOptionsRaw.skills
: skillNamesFromSelection;
const runtimeOptions: AgentRuntimeOptions = {
...runtimeOptionsRaw,
...(mergedSkillNames.length > 0 ? { skills: mergedSkillNames } : {}),
};
// Build the resolution context
const context = buildRuntimeResolutionContext(sessionPurpose, pluginRunner, runtimeHint);