From 44f02dbbc67f0af57b2930f54910f32dd97f03a4 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 11 Apr 2026 20:24:20 +0100 Subject: [PATCH] fix(agents): split effective tool inventory types --- src/agents/tools-effective-inventory.ts | 60 +++---------------- src/agents/tools-effective-inventory.types.ts | 53 ++++++++++++++++ .../reply/commands-info.tools.test.ts | 2 +- src/auto-reply/status.ts | 2 +- 4 files changed, 62 insertions(+), 55 deletions(-) create mode 100644 src/agents/tools-effective-inventory.types.ts diff --git a/src/agents/tools-effective-inventory.ts b/src/agents/tools-effective-inventory.ts index 406e02feed5..bb317a3242a 100644 --- a/src/agents/tools-effective-inventory.ts +++ b/src/agents/tools-effective-inventory.ts @@ -1,4 +1,3 @@ -import type { OpenClawConfig } from "../config/types.openclaw.js"; import { getPluginToolMeta } from "../plugins/tools.js"; import { normalizeLowercaseStringOrEmpty, @@ -11,60 +10,15 @@ import { createOpenClawCodingTools } from "./pi-tools.js"; import { resolveEffectiveToolPolicy } from "./pi-tools.policy.js"; import { summarizeToolDescriptionText } from "./tool-description-summary.js"; import { resolveToolDisplay } from "./tool-display.js"; +import type { + EffectiveToolInventoryEntry, + EffectiveToolInventoryGroup, + EffectiveToolInventoryResult, + EffectiveToolSource, + ResolveEffectiveToolInventoryParams, +} from "./tools-effective-inventory.types.js"; import type { AnyAgentTool } from "./tools/common.js"; -export type EffectiveToolSource = "core" | "plugin" | "channel"; - -export type EffectiveToolInventoryEntry = { - id: string; - label: string; - description: string; - rawDescription: string; - source: EffectiveToolSource; - pluginId?: string; - channelId?: string; -}; - -export type EffectiveToolInventoryGroup = { - id: EffectiveToolSource; - label: string; - source: EffectiveToolSource; - tools: EffectiveToolInventoryEntry[]; -}; - -export type EffectiveToolInventoryResult = { - agentId: string; - profile: string; - groups: EffectiveToolInventoryGroup[]; -}; - -export type ResolveEffectiveToolInventoryParams = { - cfg: OpenClawConfig; - agentId?: string; - sessionKey?: string; - workspaceDir?: string; - agentDir?: string; - messageProvider?: string; - senderIsOwner?: boolean; - senderId?: string | null; - senderName?: string | null; - senderUsername?: string | null; - senderE164?: string | null; - accountId?: string | null; - modelProvider?: string; - modelId?: string; - currentChannelId?: string; - currentThreadTs?: string; - currentMessageId?: string | number; - groupId?: string | null; - groupChannel?: string | null; - groupSpace?: string | null; - replyToMode?: "off" | "first" | "all" | "batched"; - modelHasVision?: boolean; - requireExplicitMessageTarget?: boolean; - disableMessageTool?: boolean; -}; - function resolveEffectiveToolLabel(tool: AnyAgentTool): string { const rawLabel = normalizeOptionalString(tool.label) ?? ""; if ( diff --git a/src/agents/tools-effective-inventory.types.ts b/src/agents/tools-effective-inventory.types.ts new file mode 100644 index 00000000000..afb389cdd17 --- /dev/null +++ b/src/agents/tools-effective-inventory.types.ts @@ -0,0 +1,53 @@ +import type { OpenClawConfig } from "../config/types.openclaw.js"; + +export type EffectiveToolSource = "core" | "plugin" | "channel"; + +export type EffectiveToolInventoryEntry = { + id: string; + label: string; + description: string; + rawDescription: string; + source: EffectiveToolSource; + pluginId?: string; + channelId?: string; +}; + +export type EffectiveToolInventoryGroup = { + id: EffectiveToolSource; + label: string; + source: EffectiveToolSource; + tools: EffectiveToolInventoryEntry[]; +}; + +export type EffectiveToolInventoryResult = { + agentId: string; + profile: string; + groups: EffectiveToolInventoryGroup[]; +}; + +export type ResolveEffectiveToolInventoryParams = { + cfg: OpenClawConfig; + agentId?: string; + sessionKey?: string; + workspaceDir?: string; + agentDir?: string; + messageProvider?: string; + senderIsOwner?: boolean; + senderId?: string | null; + senderName?: string | null; + senderUsername?: string | null; + senderE164?: string | null; + accountId?: string | null; + modelProvider?: string; + modelId?: string; + currentChannelId?: string; + currentThreadTs?: string; + currentMessageId?: string | number; + groupId?: string | null; + groupChannel?: string | null; + groupSpace?: string | null; + replyToMode?: "off" | "first" | "all" | "batched"; + modelHasVision?: boolean; + requireExplicitMessageTarget?: boolean; + disableMessageTool?: boolean; +}; diff --git a/src/auto-reply/reply/commands-info.tools.test.ts b/src/auto-reply/reply/commands-info.tools.test.ts index d99ae72d40c..f8fcdf08f4b 100644 --- a/src/auto-reply/reply/commands-info.tools.test.ts +++ b/src/auto-reply/reply/commands-info.tools.test.ts @@ -1,5 +1,5 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import type { EffectiveToolInventoryResult } from "../../agents/tools-effective-inventory.js"; +import type { EffectiveToolInventoryResult } from "../../agents/tools-effective-inventory.types.js"; import type { OpenClawConfig } from "../../config/config.js"; import { setActivePluginRegistry } from "../../plugins/runtime.js"; import { diff --git a/src/auto-reply/status.ts b/src/auto-reply/status.ts index 2518c636dfa..5a4c800b6ee 100644 --- a/src/auto-reply/status.ts +++ b/src/auto-reply/status.ts @@ -12,7 +12,7 @@ import { resolveOpenAITextVerbosity } from "../agents/pi-embedded-runner/openai- import { resolveSandboxRuntimeStatus } from "../agents/sandbox.js"; import { describeToolForVerbose } from "../agents/tool-description-summary.js"; import { normalizeToolName } from "../agents/tool-policy-shared.js"; -import type { EffectiveToolInventoryResult } from "../agents/tools-effective-inventory.js"; +import type { EffectiveToolInventoryResult } from "../agents/tools-effective-inventory.types.js"; import { resolveChannelModelOverride } from "../channels/model-overrides.js"; import { resolveMainSessionKey,