feat(FN-3767): add task runtime env injection into executor commands via pl
Adds executor runtime environment support to the plugin system, enabling plugins to contribute environment variables that get injected into executor commands. The implementation includes new plugin types (`ExecutorRuntimeEnvPlugin`), aggregation in the plugin runner, thread-through into executor com Fusion-Task-Id: FN-3767
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, expectTypeOf, it } from "vitest";
|
||||
import type {
|
||||
FusionPlugin,
|
||||
PluginPromptContributions,
|
||||
PluginPromptSurface,
|
||||
PluginSetupCheckResult,
|
||||
ExecutorRuntimeEnvContribution,
|
||||
ExecutorRuntimeTaskContext,
|
||||
PluginSetupHooks,
|
||||
PluginSetupManifest,
|
||||
PluginSkillContribution,
|
||||
@@ -129,6 +131,28 @@ describe("plugin contribution type constraints", () => {
|
||||
expect(byPlugin["fusion-plugin-agent-browser"]?.contributions).toHaveLength(5);
|
||||
});
|
||||
|
||||
it("accepts executor runtime env contribution shape and hook typing", () => {
|
||||
const contribution: ExecutorRuntimeEnvContribution = {
|
||||
pathPrepend: ["/tmp/bin"],
|
||||
env: { SERVICE_TOKEN: "redacted" },
|
||||
description: "runtime contribution",
|
||||
};
|
||||
|
||||
const plugin: FusionPlugin = {
|
||||
manifest: { id: "plugin-runtime-env", name: "Runtime Env", version: "1.0.0" },
|
||||
state: "installed",
|
||||
hooks: {},
|
||||
executorRuntimeEnv: (taskCtx: ExecutorRuntimeTaskContext) => ({
|
||||
pathPrepend: [taskCtx.worktreePath],
|
||||
env: { TASK_ID: taskCtx.taskId },
|
||||
}),
|
||||
};
|
||||
|
||||
expect(contribution.pathPrepend?.[0]).toBe("/tmp/bin");
|
||||
expectTypeOf(contribution.env).toEqualTypeOf<Record<string, string> | undefined>();
|
||||
expectTypeOf(plugin.executorRuntimeEnv).toBeFunction();
|
||||
});
|
||||
|
||||
it("compile-time rejects invalid prompt surfaces", () => {
|
||||
const validSurface: PluginPromptSurface = "triage";
|
||||
expect(validSurface).toBe("triage");
|
||||
|
||||
@@ -229,6 +229,9 @@ export type {
|
||||
PluginPromptSurface,
|
||||
PluginPromptContribution,
|
||||
PluginPromptContributions,
|
||||
ExecutorRuntimeTaskContext,
|
||||
ExecutorRuntimeEnvContribution,
|
||||
PluginExecutorRuntimeEnvHook,
|
||||
PluginSetupStatus,
|
||||
PluginSetupCheckResult,
|
||||
PluginSetupHooks,
|
||||
|
||||
@@ -581,6 +581,24 @@ export interface PluginPromptContributions {
|
||||
enabledByDefault?: boolean;
|
||||
}
|
||||
|
||||
export interface ExecutorRuntimeTaskContext {
|
||||
taskId: string;
|
||||
worktreePath: string;
|
||||
rootDir: string;
|
||||
branch?: string;
|
||||
}
|
||||
|
||||
export interface ExecutorRuntimeEnvContribution {
|
||||
pathPrepend?: string[];
|
||||
env?: Record<string, string>;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export type PluginExecutorRuntimeEnvHook = (
|
||||
taskCtx: ExecutorRuntimeTaskContext,
|
||||
ctx: PluginContext,
|
||||
) => Promise<ExecutorRuntimeEnvContribution> | ExecutorRuntimeEnvContribution;
|
||||
|
||||
export type PluginSetupStatus = "not-installed" | "installing" | "installed" | "error";
|
||||
|
||||
export interface PluginSetupCheckResult {
|
||||
@@ -678,6 +696,8 @@ export interface FusionPlugin {
|
||||
manifest: PluginSetupManifest;
|
||||
hooks: PluginSetupHooks;
|
||||
};
|
||||
/** Plugin-contributed executor runtime env for task-scoped subprocesses. */
|
||||
executorRuntimeEnv?: PluginExecutorRuntimeEnvHook;
|
||||
}
|
||||
|
||||
// ── Plugin Installation ───────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user