惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
H
Help Net Security
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
博客园 - 叶小钗
Y
Y Combinator Blog
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
C
Check Point Blog
Recent Announcements
Recent Announcements
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
美团技术团队
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
B
Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor(tools): share inventory presentation helpers · o...
vincentkoc · 2026-06-22 · via Recent Commits to openclaw:main

@@ -3,53 +3,32 @@

33

* runtime-compatible tools plus warnings for tools quarantined by schema

44

* policy, with plugin/channel ownership preserved.

55

*/

6-

import {

7-

normalizeLowercaseStringOrEmpty,

8-

normalizeOptionalString,

9-

} from "@openclaw/normalization-core/string-coerce";

6+

import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";

107

import type { OpenClawConfig } from "../config/types.openclaw.js";

118

import type { ProviderRuntimeModel } from "../plugins/provider-runtime-model.types.js";

129

import { getActivePluginRegistry } from "../plugins/runtime.js";

1310

import { buildPluginToolMetadataKey, getPluginToolMeta } from "../plugins/tools.js";

1411

import { getChannelAgentToolMeta } from "./channel-tools.js";

1512

import { normalizeAgentRuntimeTools } from "./runtime-plan/tools.js";

16-

import { summarizeToolDescriptionText } from "./tool-description-summary.js";

17-

import { resolveToolDisplay } from "./tool-display.js";

1813

import {

1914

filterProviderNormalizableTools,

2015

filterRuntimeCompatibleTools,

2116

type RuntimeToolSchemaDiagnostic,

2217

} from "./tool-schema-projection.js";

2318

import { buildEffectiveToolInventoryGroups } from "./tools-effective-inventory-groups.js";

19+

import {

20+

disambiguateEffectiveToolLabels,

21+

resolveEffectiveToolLabel,

22+

resolveEffectiveToolRawDescription,

23+

summarizeEffectiveToolDescription,

24+

} from "./tools-effective-inventory-shared.js";

2425

import type {

2526

EffectiveToolInventoryEntry,

2627

EffectiveToolInventoryNotice,

2728

EffectiveToolSource,

2829

} from "./tools-effective-inventory.types.js";

2930

import type { AnyAgentTool } from "./tools/common.js";

303131-

function resolveEffectiveToolLabel(tool: AnyAgentTool): string {

32-

const rawLabel = normalizeOptionalString(tool.label) ?? "";

33-

if (

34-

rawLabel &&

35-

normalizeLowercaseStringOrEmpty(rawLabel) !== normalizeLowercaseStringOrEmpty(tool.name)

36-

) {

37-

return rawLabel;

38-

}

39-

return resolveToolDisplay({ name: tool.name }).title;

40-

}

41-42-

function resolveRawToolDescription(tool: AnyAgentTool): string {

43-

return normalizeOptionalString(tool.description) ?? "";

44-

}

45-46-

function summarizeToolDescription(tool: AnyAgentTool): string {

47-

return summarizeToolDescriptionText({

48-

rawDescription: resolveRawToolDescription(tool),

49-

displaySummary: tool.displaySummary,

50-

});

51-

}

52-5332

// Tool metadata may be attached to the normalized tool or the raw fallback

5433

// before schema projection. Check both so owner attribution survives cloning.

5534

function resolveEffectiveToolSource(

@@ -150,22 +129,6 @@ function buildReadableRawToolsByName(

150129

return toolsByName;

151130

}

152131153-

// Duplicate labels are ambiguous in inventory UIs; add the owner/id only where

154-

// needed so unique entries keep their concise display names.

155-

function disambiguateLabels(entries: EffectiveToolInventoryEntry[]): EffectiveToolInventoryEntry[] {

156-

const counts = new Map<string, number>();

157-

for (const entry of entries) {

158-

counts.set(entry.label, (counts.get(entry.label) ?? 0) + 1);

159-

}

160-

return entries.map((entry) => {

161-

if ((counts.get(entry.label) ?? 0) < 2) {

162-

return entry;

163-

}

164-

const suffix = entry.pluginId ?? entry.channelId ?? entry.id;

165-

return { ...entry, label: `${entry.label} (${suffix})` };

166-

});

167-

}

168-169132

/** Builds effective inventory entries from already runtime-compatible tools. */

170133

export function buildEffectiveToolInventoryEntries(

171134

tools: readonly AnyAgentTool[],

@@ -180,7 +143,7 @@ export function buildEffectiveToolInventoryEntries(

180143

]),

181144

);

182145183-

return disambiguateLabels(

146+

return disambiguateEffectiveToolLabels(

184147

tools

185148

.map((tool) => {

186149

const source = resolveEffectiveToolSource(tool, rawToolsByName.get(tool.name));

@@ -193,18 +156,20 @@ export function buildEffectiveToolInventoryEntries(

193156

label:

194157

normalizeOptionalString(metadata?.displayName) ?? resolveEffectiveToolLabel(tool),

195158

description:

196-

normalizeOptionalString(metadata?.description) ?? summarizeToolDescription(tool),

159+

normalizeOptionalString(metadata?.description) ??

160+

summarizeEffectiveToolDescription(tool),

197161

rawDescription:

198162

normalizeOptionalString(metadata?.description) ??

199-

resolveRawToolDescription(tool) ??

200-

summarizeToolDescription(tool),

163+

resolveEffectiveToolRawDescription(tool) ??

164+

summarizeEffectiveToolDescription(tool),

201165

...(metadata?.risk ? { risk: metadata.risk } : {}),

202166

...(metadata?.tags ? { tags: metadata.tags } : {}),

203167

},

204168

source,

205169

) satisfies EffectiveToolInventoryEntry;

206170

})

207171

.toSorted((a, b) => a.label.localeCompare(b.label)),

172+

(entry) => entry.pluginId ?? entry.channelId ?? entry.id,

208173

);

209174

}

210175