fix(agents): split effective tool inventory types

This commit is contained in:
Vincent Koc
2026-04-11 20:24:20 +01:00
parent f1c4e2f11d
commit 44f02dbbc6
4 changed files with 62 additions and 55 deletions

View File

@@ -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 (

View File

@@ -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;
};

View File

@@ -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 {

View File

@@ -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,