diff --git a/src/plugin-sdk/index.ts b/src/plugin-sdk/index.ts index c4087394e75..7260e8d4798 100644 --- a/src/plugin-sdk/index.ts +++ b/src/plugin-sdk/index.ts @@ -67,7 +67,7 @@ export type { PluginRuntimeTaskFlows, PluginRuntimeTaskRuns, PluginRuntimeTasks, -} from "../plugins/runtime/runtime-tasks.js"; +} from "../plugins/runtime/runtime-tasks.types.js"; export type { TaskFlowDetail, TaskFlowView, diff --git a/src/plugins/runtime/runtime-tasks.ts b/src/plugins/runtime/runtime-tasks.ts index 6952d8dad6f..898a12458dc 100644 --- a/src/plugins/runtime/runtime-tasks.ts +++ b/src/plugins/runtime/runtime-tasks.ts @@ -1,4 +1,3 @@ -import type { OpenClawConfig } from "../../config/types.openclaw.js"; import { cancelTaskById, listTasksForFlowId } from "../../tasks/runtime-internal.js"; import { mapTaskFlowDetail, @@ -21,16 +20,23 @@ import { resolveTaskForLookupTokenForOwner, } from "../../tasks/task-owner-access.js"; import { normalizeDeliveryContext } from "../../utils/delivery-context.shared.js"; -import type { OpenClawPluginToolContext } from "../tool-types.js"; import type { PluginRuntimeTaskFlow } from "./runtime-taskflow.types.js"; import type { + BoundTaskFlowsRuntime, + BoundTaskRunsRuntime, + PluginRuntimeTaskFlows, + PluginRuntimeTaskRuns, + PluginRuntimeTasks, TaskFlowDetail, - TaskFlowView, - TaskRunAggregateSummary, TaskRunCancelResult, - TaskRunDetail, - TaskRunView, -} from "./task-domain-types.js"; +} from "./runtime-tasks.types.js"; +export type { + BoundTaskFlowsRuntime, + BoundTaskRunsRuntime, + PluginRuntimeTaskFlows, + PluginRuntimeTaskRuns, + PluginRuntimeTasks, +} from "./runtime-tasks.types.js"; function assertSessionKey(sessionKey: string | undefined, errorMessage: string): string { const normalized = sessionKey?.trim(); @@ -51,53 +57,6 @@ function mapCancelledTaskResult( }; } -export type BoundTaskRunsRuntime = { - readonly sessionKey: string; - readonly requesterOrigin?: ReturnType; - get: (taskId: string) => TaskRunDetail | undefined; - list: () => TaskRunView[]; - findLatest: () => TaskRunDetail | undefined; - resolve: (token: string) => TaskRunDetail | undefined; - cancel: (params: { taskId: string; cfg: OpenClawConfig }) => Promise; -}; - -export type PluginRuntimeTaskRuns = { - bindSession: (params: { - sessionKey: string; - requesterOrigin?: import("../../tasks/task-registry.types.js").TaskDeliveryState["requesterOrigin"]; - }) => BoundTaskRunsRuntime; - fromToolContext: ( - ctx: Pick, - ) => BoundTaskRunsRuntime; -}; - -export type BoundTaskFlowsRuntime = { - readonly sessionKey: string; - readonly requesterOrigin?: ReturnType; - get: (flowId: string) => TaskFlowDetail | undefined; - list: () => TaskFlowView[]; - findLatest: () => TaskFlowDetail | undefined; - resolve: (token: string) => TaskFlowDetail | undefined; - getTaskSummary: (flowId: string) => TaskRunAggregateSummary | undefined; -}; - -export type PluginRuntimeTaskFlows = { - bindSession: (params: { - sessionKey: string; - requesterOrigin?: import("../../tasks/task-registry.types.js").TaskDeliveryState["requesterOrigin"]; - }) => BoundTaskFlowsRuntime; - fromToolContext: ( - ctx: Pick, - ) => BoundTaskFlowsRuntime; -}; - -export type PluginRuntimeTasks = { - runs: PluginRuntimeTaskRuns; - flows: PluginRuntimeTaskFlows; - /** @deprecated Use runtime.tasks.flows for DTO-based TaskFlow access. */ - flow: PluginRuntimeTaskFlow; -}; - function createBoundTaskRunsRuntime(params: { sessionKey: string; requesterOrigin?: import("../../tasks/task-registry.types.js").TaskDeliveryState["requesterOrigin"]; diff --git a/src/plugins/runtime/runtime-tasks.types.ts b/src/plugins/runtime/runtime-tasks.types.ts new file mode 100644 index 00000000000..fcd032062cf --- /dev/null +++ b/src/plugins/runtime/runtime-tasks.types.ts @@ -0,0 +1,67 @@ +import type { OpenClawConfig } from "../../config/types.openclaw.js"; +import type { TaskDeliveryState } from "../../tasks/task-registry.types.js"; +import type { OpenClawPluginToolContext } from "../tool-types.js"; +import type { PluginRuntimeTaskFlow } from "./runtime-taskflow.types.js"; +import type { + TaskFlowDetail, + TaskFlowView, + TaskRunAggregateSummary, + TaskRunCancelResult, + TaskRunDetail, + TaskRunView, +} from "./task-domain-types.js"; +export type { + TaskFlowDetail, + TaskFlowView, + TaskRunAggregateSummary, + TaskRunCancelResult, + TaskRunDetail, + TaskRunView, +} from "./task-domain-types.js"; + +export type BoundTaskRunsRuntime = { + readonly sessionKey: string; + readonly requesterOrigin?: TaskDeliveryState["requesterOrigin"]; + get: (taskId: string) => TaskRunDetail | undefined; + list: () => TaskRunView[]; + findLatest: () => TaskRunDetail | undefined; + resolve: (token: string) => TaskRunDetail | undefined; + cancel: (params: { taskId: string; cfg: OpenClawConfig }) => Promise; +}; + +export type PluginRuntimeTaskRuns = { + bindSession: (params: { + sessionKey: string; + requesterOrigin?: TaskDeliveryState["requesterOrigin"]; + }) => BoundTaskRunsRuntime; + fromToolContext: ( + ctx: Pick, + ) => BoundTaskRunsRuntime; +}; + +export type BoundTaskFlowsRuntime = { + readonly sessionKey: string; + readonly requesterOrigin?: TaskDeliveryState["requesterOrigin"]; + get: (flowId: string) => TaskFlowDetail | undefined; + list: () => TaskFlowView[]; + findLatest: () => TaskFlowDetail | undefined; + resolve: (token: string) => TaskFlowDetail | undefined; + getTaskSummary: (flowId: string) => TaskRunAggregateSummary | undefined; +}; + +export type PluginRuntimeTaskFlows = { + bindSession: (params: { + sessionKey: string; + requesterOrigin?: TaskDeliveryState["requesterOrigin"]; + }) => BoundTaskFlowsRuntime; + fromToolContext: ( + ctx: Pick, + ) => BoundTaskFlowsRuntime; +}; + +export type PluginRuntimeTasks = { + runs: PluginRuntimeTaskRuns; + flows: PluginRuntimeTaskFlows; + /** @deprecated Use runtime.tasks.flows for DTO-based TaskFlow access. */ + flow: PluginRuntimeTaskFlow; +}; diff --git a/src/plugins/runtime/types-core.ts b/src/plugins/runtime/types-core.ts index 83bd238d997..703f8c5e9e1 100644 --- a/src/plugins/runtime/types-core.ts +++ b/src/plugins/runtime/types-core.ts @@ -10,6 +10,7 @@ import type { TextToSpeech, TextToSpeechTelephony, } from "../../plugin-sdk/tts-runtime.types.js"; +import type { PluginRuntimeTaskFlows, PluginRuntimeTaskRuns } from "./runtime-tasks.types.js"; export type { HeartbeatRunResult }; @@ -153,8 +154,8 @@ export type PluginRuntimeCore = { resolveStateDir: typeof import("../../config/paths.js").resolveStateDir; }; tasks: { - runs: import("./runtime-tasks.js").PluginRuntimeTaskRuns; - flows: import("./runtime-tasks.js").PluginRuntimeTaskFlows; + runs: PluginRuntimeTaskRuns; + flows: PluginRuntimeTaskFlows; /** @deprecated Use runtime.tasks.flows for DTO-based TaskFlow access. */ flow: import("./runtime-taskflow.types.js").PluginRuntimeTaskFlow; };