mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix: align tool execute arg parsing for hooks
This commit is contained in:
@@ -39,6 +39,7 @@ Docs: https://docs.openclaw.ai
|
||||
- iOS/Location: restore the significant location monitor implementation (service hooks + protocol surface + ATS key alignment) after merge drift so iOS builds compile again. (#18260) Thanks @ngutman.
|
||||
- Discord/Telegram: make per-account message action gates effective for both action listing and execution, and preserve top-level gate restrictions when account overrides only specify a subset of `actions` keys (account key -> base key -> default fallback). (#18494)
|
||||
- Telegram: keep DM-topic replies and draft previews in the originating private-chat topic by preserving positive `message_thread_id` values for DM threads. (#18586) Thanks @sebslight.
|
||||
- Telegram: preserve private-chat topic `message_thread_id` on outbound sends (message/sticker/poll), keep thread-not-found retry fallback, and avoid masking `chat not found` routing errors. (#18993) Thanks @obviyus.
|
||||
- Discord: prevent duplicate media delivery when the model uses the `message send` tool with media, by skipping media extraction from messaging tool results since the tool already sent the message directly. (#18270)
|
||||
- Telegram: keep draft-stream preview replies attached to the user message for `replyToMode: "all"` in groups and DMs, preserving threaded reply context from preview through finalization. (#17880) Thanks @yinghaosang.
|
||||
- Telegram: prevent streaming final replies from being overwritten by later final/error payloads, and suppress fallback tool-error warnings when a recovered assistant answer already exists after tool calls. (#17883) Thanks @Marvae and @obviyus.
|
||||
|
||||
@@ -17,22 +17,21 @@ import {
|
||||
import { normalizeToolName } from "./tool-policy.js";
|
||||
import { jsonResult } from "./tools/common.js";
|
||||
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
type AnyAgentTool = AgentTool<any, unknown>;
|
||||
type AnyAgentTool = AgentTool;
|
||||
|
||||
type ToolExecuteArgsCurrent = [
|
||||
string,
|
||||
unknown,
|
||||
AbortSignal | undefined,
|
||||
AgentToolUpdateCallback<unknown> | undefined,
|
||||
unknown,
|
||||
AbortSignal | undefined,
|
||||
];
|
||||
type ToolExecuteArgsLegacy = [
|
||||
string,
|
||||
unknown,
|
||||
AbortSignal | undefined,
|
||||
AgentToolUpdateCallback<unknown> | undefined,
|
||||
unknown,
|
||||
AbortSignal | undefined,
|
||||
];
|
||||
type ToolExecuteArgs = ToolDefinition["execute"] extends (...args: infer P) => unknown
|
||||
? P
|
||||
@@ -45,8 +44,11 @@ function isAbortSignal(value: unknown): value is AbortSignal {
|
||||
|
||||
function isLegacyToolExecuteArgs(args: ToolExecuteArgsAny): args is ToolExecuteArgsLegacy {
|
||||
const third = args[2];
|
||||
const fourth = args[3];
|
||||
return isAbortSignal(third) || typeof fourth === "function";
|
||||
const fifth = args[4];
|
||||
if (typeof third === "function") {
|
||||
return true;
|
||||
}
|
||||
return isAbortSignal(fifth);
|
||||
}
|
||||
|
||||
function describeToolExecutionError(err: unknown): {
|
||||
@@ -67,7 +69,7 @@ function splitToolExecuteArgs(args: ToolExecuteArgsAny): {
|
||||
signal: AbortSignal | undefined;
|
||||
} {
|
||||
if (isLegacyToolExecuteArgs(args)) {
|
||||
const [toolCallId, params, signal, onUpdate] = args;
|
||||
const [toolCallId, params, onUpdate, _ctx, signal] = args;
|
||||
return {
|
||||
toolCallId,
|
||||
params,
|
||||
@@ -75,7 +77,7 @@ function splitToolExecuteArgs(args: ToolExecuteArgsAny): {
|
||||
signal,
|
||||
};
|
||||
}
|
||||
const [toolCallId, params, onUpdate, _ctx, signal] = args;
|
||||
const [toolCallId, params, signal, onUpdate] = args;
|
||||
return {
|
||||
toolCallId,
|
||||
params,
|
||||
@@ -199,8 +201,7 @@ export function toClientToolDefinitions(
|
||||
name: func.name,
|
||||
label: func.name,
|
||||
description: func.description ?? "",
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
parameters: func.parameters as any,
|
||||
parameters: func.parameters as ToolDefinition["parameters"],
|
||||
execute: async (...args: ToolExecuteArgs): Promise<AgentToolResult<unknown>> => {
|
||||
const { toolCallId, params } = splitToolExecuteArgs(args);
|
||||
const outcome = await runBeforeToolCallHook({
|
||||
|
||||
Reference in New Issue
Block a user