mirror of https://github.com/openclaw/openclaw.git
Agents: scope cross-channel message discovery
This commit is contained in:
parent
b1c03715fb
commit
144b95ffce
|
|
@ -486,6 +486,49 @@ describe("message tool schema scoping", () => {
|
|||
expect(getToolProperties(unscopedTool).interactive).toBeUndefined();
|
||||
});
|
||||
|
||||
it("uses discovery account scope for other configured channel actions", () => {
|
||||
const currentPlugin = createChannelPlugin({
|
||||
id: "discord",
|
||||
label: "Discord",
|
||||
docsPath: "/channels/discord",
|
||||
blurb: "Discord test plugin.",
|
||||
actions: ["send"],
|
||||
});
|
||||
const scopedOtherPlugin = createChannelPlugin({
|
||||
id: "telegram",
|
||||
label: "Telegram",
|
||||
docsPath: "/channels/telegram",
|
||||
blurb: "Telegram test plugin.",
|
||||
actions: ["send"],
|
||||
});
|
||||
scopedOtherPlugin.actions = {
|
||||
...scopedOtherPlugin.actions,
|
||||
listActions: ({ accountId }) => (accountId === "ops" ? ["react"] : []),
|
||||
};
|
||||
|
||||
setActivePluginRegistry(
|
||||
createTestRegistry([
|
||||
{ pluginId: "discord", source: "test", plugin: currentPlugin },
|
||||
{ pluginId: "telegram", source: "test", plugin: scopedOtherPlugin },
|
||||
]),
|
||||
);
|
||||
|
||||
const scopedTool = createMessageTool({
|
||||
config: {} as never,
|
||||
currentChannelProvider: "discord",
|
||||
agentAccountId: "ops",
|
||||
});
|
||||
const unscopedTool = createMessageTool({
|
||||
config: {} as never,
|
||||
currentChannelProvider: "discord",
|
||||
});
|
||||
|
||||
expect(getActionEnum(getToolProperties(scopedTool))).toContain("react");
|
||||
expect(getActionEnum(getToolProperties(unscopedTool))).not.toContain("react");
|
||||
expect(scopedTool.description).toContain("telegram (react, send)");
|
||||
expect(unscopedTool.description).not.toContain("telegram (react, send)");
|
||||
});
|
||||
|
||||
it("routes full discovery context into plugin action discovery", () => {
|
||||
const seenContexts: Record<string, unknown>[] = [];
|
||||
const contextPlugin = createChannelPlugin({
|
||||
|
|
|
|||
|
|
@ -433,7 +433,18 @@ function resolveMessageToolSchemaActions(params: {
|
|||
if (plugin.id === currentChannel) {
|
||||
continue;
|
||||
}
|
||||
for (const action of listChannelSupportedActions({ cfg: params.cfg, channel: plugin.id })) {
|
||||
for (const action of listChannelSupportedActions({
|
||||
cfg: params.cfg,
|
||||
channel: plugin.id,
|
||||
currentChannelId: params.currentChannelId,
|
||||
currentThreadTs: params.currentThreadTs,
|
||||
currentMessageId: params.currentMessageId,
|
||||
accountId: params.currentAccountId,
|
||||
sessionKey: params.sessionKey,
|
||||
sessionId: params.sessionId,
|
||||
agentId: params.agentId,
|
||||
requesterSenderId: params.requesterSenderId,
|
||||
})) {
|
||||
allActions.add(action);
|
||||
}
|
||||
}
|
||||
|
|
@ -579,6 +590,14 @@ function buildMessageToolDescription(options?: {
|
|||
const actions = listChannelSupportedActions({
|
||||
cfg: resolvedOptions.config,
|
||||
channel: plugin.id,
|
||||
currentChannelId: resolvedOptions.currentChannelId,
|
||||
currentThreadTs: resolvedOptions.currentThreadTs,
|
||||
currentMessageId: resolvedOptions.currentMessageId,
|
||||
accountId: resolvedOptions.currentAccountId,
|
||||
sessionKey: resolvedOptions.sessionKey,
|
||||
sessionId: resolvedOptions.sessionId,
|
||||
agentId: resolvedOptions.agentId,
|
||||
requesterSenderId: resolvedOptions.requesterSenderId,
|
||||
});
|
||||
if (actions.length > 0) {
|
||||
const all = new Set(["send", ...actions]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue