openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
88 lines (87 loc) • 3.87 kB
JavaScript
import { r as isAutomationsToolName } from "./automations-tool-name-DNRDs0aJ.mjs";
import { b as describeAgentsWaitTool, y as describeAgentsListTool } from "./tool-catalog-C1ALpCJD.mjs";
import { r as finalizeAgentToolAvailability } from "./agent-tool-availability-ecKW8hOH.mjs";
import { a as copyAgentToolMetadata } from "./agent-tool-metadata-nrQgRaqv.mjs";
import { n as describeExecTool, r as describeProcessTool, t as EXEC_AUTO_REVIEW_GUIDANCE } from "./bash-tools.descriptions-CjRLwO0Y.mjs";
//#region src/agents/agent-tools.deferred-followup.ts
function replaceDescription(e, t) {
const n = {
...e,
description: t
};
return copyAgentToolMetadata(e, n);
}
const TOOL_FOLLOWUPS = [
[
"gateway",
"openclaw",
"Use runtime-owned actions.",
"Use runtime-owned actions. Other system changes: use openclaw tool."
],
[
"sessions_search",
"sessions_history",
"Search visible past sessions for matching user and assistant text.",
"Search visible past sessions for matching user and assistant text. Follow up with sessions_history using a returned sessionKey, sessionId, and messageId for neighboring context."
],
[
"conversations_send",
"conversations_list",
"through a conversationRef.",
"through a conversationRef from conversations_list."
],
[
"sessions_spawn",
"agents_list",
"configured agent;",
"configured agent (see agents_list);"
],
[
"nodes",
"exec",
"fs.listDir returns sub-directories only)",
"fs.listDir returns sub-directories only; use the exec tool with host=node to list files)"
]
];
function describeAvailableTool(e, t) {
let n = e.description;
for (const [r, i, a, o] of TOOL_FOLLOWUPS) if (r === e.name && t.has(i)) n = n.replace(a, o);
if (e.name === "sessions_send") {
const e = ["conversations_send", "conversations_turn"].filter((e) => t.has(e));
if (t.has("conversations_list") && e.length > 0) {
const t = `For an exact external destination, use \`conversations_list\` plus ${e.map((e) => `\`${e}\``).join("/")}.`;
n = n.replace(/ (?=Thread chats rejected:|Missing configured-agent main created\.)/, ` ${t} `);
}
}
if (e.name === "sessions_spawn") {
const e = ["subagents", "sessions_history"].filter((e) => t.has(e));
if (e.length > 0) {
const t = e.map((e) => `\`${e}\``).join("/");
n = n.replace("No spawn for quick lookup/single read.", `No spawn for quick lookup/single read. Check spawns via ${t}.`);
}
if (t.has("subagents")) n = n.replace("After spawn, do non-overlap work; follow the receipt's completion mode.", "After spawn, do non-overlap work; follow the receipt's completion mode. When diagnosing a missing result from an announcing child, use `subagents` to inspect execution and delivery status. Recover existing results or follow up within the still-authorized task; respect intentional cancellation and never loop-poll.");
}
return n;
}
/** Return tools with cross-tool guidance adjusted for the tools that survived filtering. */
function applyToolAvailabilityDescriptions(e) {
finalizeAgentToolAvailability(e);
const t = new Set(e.map((e) => e.name));
const n = e.some((e) => isAutomationsToolName(e.name));
const r = t.has("process");
const i = t.has("sessions_spawn");
return e.map((e) => {
if (e.name === "exec") return replaceDescription(e, describeExecTool({
hasCronTool: n,
hasProcessTool: r,
autoReview: e.description.includes(EXEC_AUTO_REVIEW_GUIDANCE)
}));
if (e.name === "process") return replaceDescription(e, describeProcessTool({ hasCronTool: n }));
if (e.name === "agents_list") return replaceDescription(e, describeAgentsListTool(i));
if (e.name === "agents_wait") return replaceDescription(e, describeAgentsWaitTool(i));
const a = describeAvailableTool(e, t);
return a === e.description ? e : replaceDescription(e, a);
});
}
//#endregion
export { applyToolAvailabilityDescriptions as t };