mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:40:44 +00:00
fix(plugin-sdk): split runtime task contracts
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<typeof normalizeDeliveryContext>;
|
||||
get: (taskId: string) => TaskRunDetail | undefined;
|
||||
list: () => TaskRunView[];
|
||||
findLatest: () => TaskRunDetail | undefined;
|
||||
resolve: (token: string) => TaskRunDetail | undefined;
|
||||
cancel: (params: { taskId: string; cfg: OpenClawConfig }) => Promise<TaskRunCancelResult>;
|
||||
};
|
||||
|
||||
export type PluginRuntimeTaskRuns = {
|
||||
bindSession: (params: {
|
||||
sessionKey: string;
|
||||
requesterOrigin?: import("../../tasks/task-registry.types.js").TaskDeliveryState["requesterOrigin"];
|
||||
}) => BoundTaskRunsRuntime;
|
||||
fromToolContext: (
|
||||
ctx: Pick<OpenClawPluginToolContext, "sessionKey" | "deliveryContext">,
|
||||
) => BoundTaskRunsRuntime;
|
||||
};
|
||||
|
||||
export type BoundTaskFlowsRuntime = {
|
||||
readonly sessionKey: string;
|
||||
readonly requesterOrigin?: ReturnType<typeof normalizeDeliveryContext>;
|
||||
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<OpenClawPluginToolContext, "sessionKey" | "deliveryContext">,
|
||||
) => 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"];
|
||||
|
||||
67
src/plugins/runtime/runtime-tasks.types.ts
Normal file
67
src/plugins/runtime/runtime-tasks.types.ts
Normal file
@@ -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<TaskRunCancelResult>;
|
||||
};
|
||||
|
||||
export type PluginRuntimeTaskRuns = {
|
||||
bindSession: (params: {
|
||||
sessionKey: string;
|
||||
requesterOrigin?: TaskDeliveryState["requesterOrigin"];
|
||||
}) => BoundTaskRunsRuntime;
|
||||
fromToolContext: (
|
||||
ctx: Pick<OpenClawPluginToolContext, "sessionKey" | "deliveryContext">,
|
||||
) => 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<OpenClawPluginToolContext, "sessionKey" | "deliveryContext">,
|
||||
) => BoundTaskFlowsRuntime;
|
||||
};
|
||||
|
||||
export type PluginRuntimeTasks = {
|
||||
runs: PluginRuntimeTaskRuns;
|
||||
flows: PluginRuntimeTaskFlows;
|
||||
/** @deprecated Use runtime.tasks.flows for DTO-based TaskFlow access. */
|
||||
flow: PluginRuntimeTaskFlow;
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user