mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:00:44 +00:00
refactor(plugin-sdk): add managed task flow runtime
This commit is contained in:
@@ -13,8 +13,8 @@ export default definePluginEntry({
|
||||
return null;
|
||||
}
|
||||
const taskFlow =
|
||||
api.runtime?.taskFlow && ctx.sessionKey
|
||||
? api.runtime.taskFlow.fromToolContext(ctx)
|
||||
api.runtime?.tasks.managedFlows && ctx.sessionKey
|
||||
? api.runtime.tasks.managedFlows.fromToolContext(ctx)
|
||||
: undefined;
|
||||
return createLobsterTool(api, { taskFlow }) as AnyAgentTool;
|
||||
}) as OpenClawPluginToolFactory,
|
||||
|
||||
@@ -12,7 +12,7 @@ type JsonLike =
|
||||
};
|
||||
|
||||
type BoundTaskFlow = ReturnType<
|
||||
NonNullable<OpenClawPluginApi["runtime"]>["taskFlow"]["bindSession"]
|
||||
NonNullable<OpenClawPluginApi["runtime"]>["tasks"]["managedFlows"]["bindSession"]
|
||||
>;
|
||||
|
||||
type FlowRecord = ReturnType<BoundTaskFlow["createManaged"]>;
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from "./lobster-taskflow.js";
|
||||
|
||||
type BoundTaskFlow = ReturnType<
|
||||
NonNullable<OpenClawPluginApi["runtime"]>["taskFlow"]["bindSession"]
|
||||
NonNullable<OpenClawPluginApi["runtime"]>["tasks"]["managedFlows"]["bindSession"]
|
||||
>;
|
||||
|
||||
type JsonLike =
|
||||
|
||||
@@ -2,7 +2,7 @@ import { vi } from "vitest";
|
||||
import type { OpenClawPluginApi } from "../runtime-api.js";
|
||||
|
||||
export type BoundTaskFlow = ReturnType<
|
||||
NonNullable<OpenClawPluginApi["runtime"]>["taskFlow"]["bindSession"]
|
||||
NonNullable<OpenClawPluginApi["runtime"]>["tasks"]["managedFlows"]["bindSession"]
|
||||
>;
|
||||
|
||||
export function createFakeTaskFlow(overrides?: Partial<BoundTaskFlow>): BoundTaskFlow {
|
||||
|
||||
@@ -14,8 +14,10 @@ function createApi(params?: {
|
||||
source: "test",
|
||||
pluginConfig: params?.pluginConfig ?? {},
|
||||
runtime: {
|
||||
taskFlow: {
|
||||
bindSession: vi.fn(({ sessionKey }: { sessionKey: string }) => ({ sessionKey })),
|
||||
tasks: {
|
||||
managedFlows: {
|
||||
bindSession: vi.fn(({ sessionKey }: { sessionKey: string }) => ({ sessionKey })),
|
||||
},
|
||||
},
|
||||
} as unknown as OpenClawPluginApi["runtime"],
|
||||
registerHttpRoute: params?.registerHttpRoute ?? vi.fn(),
|
||||
|
||||
@@ -17,7 +17,7 @@ function registerWebhookRoutes(api: OpenClawPluginApi): void {
|
||||
});
|
||||
|
||||
for (const route of routes) {
|
||||
const taskFlow = api.runtime.taskFlow.bindSession({
|
||||
const taskFlow = api.runtime.tasks.managedFlows.bindSession({
|
||||
sessionKey: route.sessionKey,
|
||||
});
|
||||
const target: TaskFlowWebhookTarget = {
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
} from "../runtime-api.js";
|
||||
import type { WebhookSecretInput } from "./config.js";
|
||||
|
||||
type BoundTaskFlowRuntime = ReturnType<PluginRuntime["taskFlow"]["bindSession"]>;
|
||||
type BoundTaskFlowRuntime = ReturnType<PluginRuntime["tasks"]["managedFlows"]["bindSession"]>;
|
||||
|
||||
type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user