refactor(tasks): move task-flow ownership under tasks

This commit is contained in:
Vincent Koc
2026-04-02 21:36:56 +09:00
parent 0f45630d19
commit 6f91f87f3b
8 changed files with 139 additions and 44 deletions

View File

@@ -190,12 +190,13 @@ describe("plugin runtime command execution", () => {
},
},
{
name: "exposes runtime.taskFlow binding helpers",
name: "exposes runtime.tasks.flow as the canonical TaskFlow runtime and keeps runtime.taskFlow as an alias",
assert: (runtime: ReturnType<typeof createPluginRuntime>) => {
expectFunctionKeys(runtime.taskFlow as Record<string, unknown>, [
expectFunctionKeys(runtime.tasks.flow as Record<string, unknown>, [
"bindSession",
"fromToolContext",
]);
expect(runtime.taskFlow).toBe(runtime.tasks.flow);
},
},
{

View File

@@ -184,6 +184,7 @@ export type CreatePluginRuntimeOptions = {
export function createPluginRuntime(_options: CreatePluginRuntimeOptions = {}): PluginRuntime {
const mediaUnderstanding = createRuntimeMediaUnderstandingFacade();
const taskFlow = createRuntimeTaskFlow();
const runtime = {
// Sourced from the shared OpenClaw version resolver (#52899) so plugins
// always see the same version the CLI reports, avoiding API-version drift.
@@ -204,7 +205,10 @@ export function createPluginRuntime(_options: CreatePluginRuntimeOptions = {}):
events: createRuntimeEvents(),
logging: createRuntimeLogging(),
state: { resolveStateDir },
taskFlow: createRuntimeTaskFlow(),
tasks: {
flow: taskFlow,
},
taskFlow,
} satisfies Omit<
PluginRuntime,
"tts" | "mediaUnderstanding" | "stt" | "modelAuth" | "imageGeneration"

View File

@@ -103,6 +103,9 @@ export type PluginRuntimeCore = {
state: {
resolveStateDir: typeof import("../../config/paths.js").resolveStateDir;
};
tasks: {
flow: import("./runtime-taskflow.js").PluginRuntimeTaskFlow;
};
taskFlow: import("./runtime-taskflow.js").PluginRuntimeTaskFlow;
modelAuth: {
/** Resolve auth for a model. Only provider/model and optional cfg are used. */