fix: land broadcast groups (#547) (thanks @pasogott)
This commit is contained in:
@@ -808,6 +808,41 @@ describe("talk.voiceAliases", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("broadcast", () => {
|
||||
it("accepts a broadcast peer map with strategy", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
const res = validateConfigObject({
|
||||
agents: {
|
||||
list: [{ id: "alfred" }, { id: "baerbel" }],
|
||||
},
|
||||
broadcast: {
|
||||
strategy: "parallel",
|
||||
"120363403215116621@g.us": ["alfred", "baerbel"],
|
||||
},
|
||||
});
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects invalid broadcast strategy", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
const res = validateConfigObject({
|
||||
broadcast: { strategy: "nope" },
|
||||
});
|
||||
expect(res.ok).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects non-array broadcast entries", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
const res = validateConfigObject({
|
||||
broadcast: { "120363403215116621@g.us": 123 },
|
||||
});
|
||||
expect(res.ok).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("legacy config detection", () => {
|
||||
it("rejects routing.allowFrom", async () => {
|
||||
vi.resetModules();
|
||||
|
||||
@@ -946,6 +946,19 @@ export type AgentBinding = {
|
||||
};
|
||||
};
|
||||
|
||||
export type BroadcastStrategy = "parallel" | "sequential";
|
||||
|
||||
export type BroadcastConfig = {
|
||||
/** Default processing strategy for broadcast peers. */
|
||||
strategy?: BroadcastStrategy;
|
||||
/**
|
||||
* Map peer IDs to arrays of agent IDs that should ALL process messages.
|
||||
*
|
||||
* Note: the index signature includes `undefined` so `strategy?: ...` remains type-safe.
|
||||
*/
|
||||
[peerId: string]: string[] | BroadcastStrategy | undefined;
|
||||
};
|
||||
|
||||
export type AudioConfig = {
|
||||
transcription?: {
|
||||
// Optional CLI to turn inbound audio into text; templated args, must output transcript to stdout.
|
||||
@@ -1373,6 +1386,7 @@ export type ClawdbotConfig = {
|
||||
agents?: AgentsConfig;
|
||||
tools?: ToolsConfig;
|
||||
bindings?: AgentBinding[];
|
||||
broadcast?: BroadcastConfig;
|
||||
audio?: AudioConfig;
|
||||
messages?: MessagesConfig;
|
||||
commands?: CommandsConfig;
|
||||
|
||||
@@ -842,6 +842,15 @@ const BindingsSchema = z
|
||||
)
|
||||
.optional();
|
||||
|
||||
const BroadcastStrategySchema = z.enum(["parallel", "sequential"]);
|
||||
|
||||
const BroadcastSchema = z
|
||||
.object({
|
||||
strategy: BroadcastStrategySchema.optional(),
|
||||
})
|
||||
.catchall(z.array(z.string()))
|
||||
.optional();
|
||||
|
||||
const AudioSchema = z
|
||||
.object({
|
||||
transcription: TranscribeAudioSchema,
|
||||
@@ -1188,6 +1197,7 @@ export const ClawdbotSchema = z.object({
|
||||
agents: AgentsSchema,
|
||||
tools: ToolsSchema,
|
||||
bindings: BindingsSchema,
|
||||
broadcast: BroadcastSchema,
|
||||
audio: AudioSchema,
|
||||
messages: MessagesSchema,
|
||||
commands: CommandsSchema,
|
||||
|
||||
Reference in New Issue
Block a user