test(agents): add missing announce delivery regressions

This commit is contained in:
Peter Steinberger
2026-02-26 00:38:24 +00:00
parent 20c2db2103
commit aaeed3c4ea
5 changed files with 197 additions and 6 deletions

View File

@@ -47,10 +47,15 @@ function maybeBootstrapChannelPlugin(params: {
const autoEnabled = applyPluginAutoEnable({ config: cfg }).config;
const defaultAgentId = resolveDefaultAgentId(autoEnabled);
const workspaceDir = resolveAgentWorkspaceDir(autoEnabled, defaultAgentId);
loadOpenClawPlugins({
config: autoEnabled,
workspaceDir,
});
try {
loadOpenClawPlugins({
config: autoEnabled,
workspaceDir,
});
} catch {
// Allow a follow-up resolution attempt if bootstrap failed transiently.
bootstrapAttempts.delete(attemptKey);
}
}
export function resolveOutboundChannelPlugin(params: {

View File

@@ -28,8 +28,11 @@ import { createTestRegistry } from "../../test-utils/channel-plugins.js";
import { resolveOutboundTarget } from "./targets.js";
describe("resolveOutboundTarget channel resolution", () => {
let registrySeq = 0;
beforeEach(() => {
setActivePluginRegistry(createTestRegistry([]));
registrySeq += 1;
setActivePluginRegistry(createTestRegistry([]), `targets-test-${registrySeq}`);
mocks.getChannelPlugin.mockReset();
mocks.loadOpenClawPlugins.mockReset();
});
@@ -58,4 +61,43 @@ describe("resolveOutboundTarget channel resolution", () => {
expect(result).toEqual({ ok: true, to: "123456" });
expect(mocks.loadOpenClawPlugins).toHaveBeenCalledTimes(1);
});
it("retries bootstrap on subsequent resolve when the first bootstrap attempt fails", () => {
const telegramPlugin = {
id: "telegram",
meta: { label: "Telegram" },
config: {
listAccountIds: () => [],
resolveAccount: () => ({}),
},
};
mocks.getChannelPlugin
.mockReturnValueOnce(undefined)
.mockReturnValueOnce(undefined)
.mockReturnValueOnce(undefined)
.mockReturnValueOnce(telegramPlugin)
.mockReturnValue(telegramPlugin);
mocks.loadOpenClawPlugins
.mockImplementationOnce(() => {
throw new Error("bootstrap failed");
})
.mockImplementation(() => undefined);
const first = resolveOutboundTarget({
channel: "telegram",
to: "123456",
cfg: { channels: { telegram: { botToken: "test-token" } } },
mode: "explicit",
});
const second = resolveOutboundTarget({
channel: "telegram",
to: "123456",
cfg: { channels: { telegram: { botToken: "test-token" } } },
mode: "explicit",
});
expect(first.ok).toBe(false);
expect(second).toEqual({ ok: true, to: "123456" });
expect(mocks.loadOpenClawPlugins).toHaveBeenCalledTimes(2);
});
});