File size: 1,343 Bytes
25d91a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | // Defines plugin middleware contracts for agent tool results.
import type { AgentToolResult } from "../../packages/agent-core/src/types.js";
import type { PluginToolMatcher } from "./hook-types.js";
export type OpenClawAgentToolResult<TResult = unknown> = AgentToolResult<TResult>;
export type AgentToolResultMiddlewareRuntime = "openclaw" | "codex";
export type AgentToolResultMiddlewareEvent = {
threadId?: string;
turnId?: string;
toolCallId: string;
toolName: string;
args: Record<string, unknown>;
cwd?: string;
isError?: boolean;
result: OpenClawAgentToolResult;
};
export type AgentToolResultMiddlewareContext = {
runtime: AgentToolResultMiddlewareRuntime;
agentId?: string;
sessionId?: string;
sessionKey?: string;
runId?: string;
};
export type AgentToolResultMiddlewareResult = {
result: OpenClawAgentToolResult;
};
export type AgentToolResultMiddleware = (
event: AgentToolResultMiddlewareEvent,
ctx: AgentToolResultMiddlewareContext,
) => Promise<AgentToolResultMiddlewareResult | void> | AgentToolResultMiddlewareResult | void;
export type AgentToolResultMiddlewareOptions = {
matcher?: PluginToolMatcher;
runtimes?: AgentToolResultMiddlewareRuntime[];
};
export type AgentToolResultMiddlewareScope = {
matcher?: PluginToolMatcher;
runtimes: AgentToolResultMiddlewareRuntime[];
};
|