mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 07:57:39 +00:00
fix: guard channel tool listActions (#2859) (thanks @mbelinky)
This commit is contained in:
@@ -77,6 +77,7 @@ Status: beta.
|
|||||||
- macOS: auto-scroll to bottom when sending a new message while scrolled up. (#2471) Thanks @kennyklee.
|
- macOS: auto-scroll to bottom when sending a new message while scrolled up. (#2471) Thanks @kennyklee.
|
||||||
- Web UI: auto-expand the chat compose textarea while typing (with sensible max height). (#2950) Thanks @shivamraut101.
|
- Web UI: auto-expand the chat compose textarea while typing (with sensible max height). (#2950) Thanks @shivamraut101.
|
||||||
- Gateway: prevent crashes on transient network errors (fetch failures, timeouts, DNS). Added fatal error detection to only exit on truly critical errors. Fixes #2895, #2879, #2873. (#2980) Thanks @elliotsecops.
|
- Gateway: prevent crashes on transient network errors (fetch failures, timeouts, DNS). Added fatal error detection to only exit on truly critical errors. Fixes #2895, #2879, #2873. (#2980) Thanks @elliotsecops.
|
||||||
|
- Agents: guard channel tool listActions to avoid plugin crashes. (#2859) Thanks @mbelinky.
|
||||||
- Gateway: suppress AbortError and transient network errors in unhandled rejections. (#2451) Thanks @Glucksberg.
|
- Gateway: suppress AbortError and transient network errors in unhandled rejections. (#2451) Thanks @Glucksberg.
|
||||||
- TTS: keep /tts status replies on text-only commands and avoid duplicate block-stream audio. (#2451) Thanks @Glucksberg.
|
- TTS: keep /tts status replies on text-only commands and avoid duplicate block-stream audio. (#2451) Thanks @Glucksberg.
|
||||||
- Security: pin npm overrides to keep tar@7.5.4 for install toolchains.
|
- Security: pin npm overrides to keep tar@7.5.4 for install toolchains.
|
||||||
|
|||||||
53
src/agents/channel-tools.test.ts
Normal file
53
src/agents/channel-tools.test.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
|
import type { MoltbotConfig } from "../config/config.js";
|
||||||
|
import type { ChannelPlugin } from "../channels/plugins/types.js";
|
||||||
|
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||||
|
import { createTestRegistry } from "../test-utils/channel-plugins.js";
|
||||||
|
import { defaultRuntime } from "../runtime.js";
|
||||||
|
import { __testing, listAllChannelSupportedActions } from "./channel-tools.js";
|
||||||
|
|
||||||
|
describe("channel tools", () => {
|
||||||
|
const errorSpy = vi.spyOn(defaultRuntime, "error").mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const plugin: ChannelPlugin = {
|
||||||
|
id: "test",
|
||||||
|
meta: {
|
||||||
|
id: "test",
|
||||||
|
label: "Test",
|
||||||
|
selectionLabel: "Test",
|
||||||
|
docsPath: "/channels/test",
|
||||||
|
blurb: "test plugin",
|
||||||
|
},
|
||||||
|
capabilities: { chatTypes: ["direct"] },
|
||||||
|
config: {
|
||||||
|
listAccountIds: () => [],
|
||||||
|
resolveAccount: () => ({}),
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
listActions: () => {
|
||||||
|
throw new Error("boom");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
__testing.resetLoggedListActionErrors();
|
||||||
|
errorSpy.mockClear();
|
||||||
|
setActivePluginRegistry(createTestRegistry([{ pluginId: "test", source: "test", plugin }]));
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
setActivePluginRegistry(createTestRegistry([]));
|
||||||
|
errorSpy.mockClear();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("skips crashing plugins and logs once", () => {
|
||||||
|
const cfg = {} as MoltbotConfig;
|
||||||
|
expect(listAllChannelSupportedActions({ cfg })).toEqual([]);
|
||||||
|
expect(errorSpy).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
expect(listAllChannelSupportedActions({ cfg })).toEqual([]);
|
||||||
|
expect(errorSpy).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user