Files
openclaw/src/agents/openclaw-plugin-tools.ts
pgondhi987 f0c9978030 fix(feishu): enforce workspace-only localRoots in docx upload actions [AI-assisted] (#62369)
* fix: address issue

* docs(changelog): add feishu workspace-only docx entry

---------

Co-authored-by: Devin Robison <drobison@nvidia.com>
2026-04-07 10:35:03 -06:00

59 lines
1.9 KiB
TypeScript

import type { OpenClawConfig } from "../config/config.js";
import { resolvePluginTools } from "../plugins/tools.js";
import { getActiveSecretsRuntimeSnapshot } from "../secrets/runtime.js";
import { normalizeDeliveryContext } from "../utils/delivery-context.js";
import {
resolveOpenClawPluginToolInputs,
type OpenClawPluginToolOptions,
} from "./openclaw-tools.plugin-context.js";
import { applyPluginToolDeliveryDefaults } from "./plugin-tool-delivery-defaults.js";
import type { AnyAgentTool } from "./tools/common.js";
type ResolveOpenClawPluginToolsOptions = OpenClawPluginToolOptions & {
pluginToolAllowlist?: string[];
currentChannelId?: string;
currentThreadTs?: string;
currentMessageId?: string | number;
sandboxRoot?: string;
modelHasVision?: boolean;
modelProvider?: string;
allowMediaInvokeCommands?: boolean;
requesterAgentIdOverride?: string;
requireExplicitMessageTarget?: boolean;
disableMessageTool?: boolean;
disablePluginTools?: boolean;
};
export function resolveOpenClawPluginToolsForOptions(params: {
options?: ResolveOpenClawPluginToolsOptions;
resolvedConfig?: OpenClawConfig;
existingToolNames?: Set<string>;
}): AnyAgentTool[] {
if (params.options?.disablePluginTools) {
return [];
}
const runtimeSnapshot = getActiveSecretsRuntimeSnapshot();
const deliveryContext = normalizeDeliveryContext({
channel: params.options?.agentChannel,
to: params.options?.agentTo,
accountId: params.options?.agentAccountId,
threadId: params.options?.agentThreadId,
});
const pluginTools = resolvePluginTools({
...resolveOpenClawPluginToolInputs({
options: params.options,
resolvedConfig: params.resolvedConfig,
runtimeConfig: runtimeSnapshot?.config,
}),
existingToolNames: params.existingToolNames ?? new Set<string>(),
toolAllowlist: params.options?.pluginToolAllowlist,
});
return applyPluginToolDeliveryDefaults({
tools: pluginTools,
deliveryContext,
});
}