mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-15 19:21:08 +00:00
fix(agents): split effective tool inventory types
This commit is contained in:
@@ -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 (
|
||||
|
||||
53
src/agents/tools-effective-inventory.types.ts
Normal file
53
src/agents/tools-effective-inventory.types.ts
Normal 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;
|
||||
};
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user