Agents: add generic poll-vote action support

This commit is contained in:
Gustavo Madeira Santana
2026-03-04 11:34:29 -05:00
parent c8ebd48e0f
commit 76bfd9b5e6
4 changed files with 36 additions and 3 deletions

View File

@@ -148,7 +148,7 @@ describe("message tool schema scoping", () => {
label: "Discord",
docsPath: "/channels/discord",
blurb: "Discord test plugin.",
actions: ["send", "poll"],
actions: ["send", "poll", "poll-vote"],
});
afterEach(() => {
@@ -161,14 +161,14 @@ describe("message tool schema scoping", () => {
expectComponents: false,
expectButtons: true,
expectButtonStyle: true,
expectedActions: ["send", "react", "poll"],
expectedActions: ["send", "react", "poll", "poll-vote"],
},
{
provider: "discord",
expectComponents: true,
expectButtons: false,
expectButtonStyle: false,
expectedActions: ["send", "poll", "react"],
expectedActions: ["send", "poll", "poll-vote", "react"],
},
])(
"scopes schema fields for $provider",
@@ -209,6 +209,9 @@ describe("message tool schema scoping", () => {
for (const action of expectedActions) {
expect(actionEnum).toContain(action);
}
expect(properties.pollId).toBeDefined();
expect(properties.pollOptionIndex).toBeDefined();
expect(properties.pollOptionId).toBeDefined();
},
);
});

View File

@@ -277,6 +277,34 @@ function buildPollSchema() {
pollOption: Type.Optional(Type.Array(Type.String())),
pollDurationHours: Type.Optional(Type.Number()),
pollMulti: Type.Optional(Type.Boolean()),
pollId: Type.Optional(Type.String()),
pollOptionId: Type.Optional(
Type.String({
description: "Poll answer id to vote for. Use when the channel exposes stable answer ids.",
}),
),
pollOptionIds: Type.Optional(
Type.Array(
Type.String({
description:
"Poll answer ids to vote for in a multiselect poll. Use when the channel exposes stable answer ids.",
}),
),
),
pollOptionIndex: Type.Optional(
Type.Number({
description:
"1-based poll option number to vote for, matching the rendered numbered poll choices.",
}),
),
pollOptionIndexes: Type.Optional(
Type.Array(
Type.Number({
description:
"1-based poll option numbers to vote for in a multiselect poll, matching the rendered numbered poll choices.",
}),
),
),
};
}

View File

@@ -2,6 +2,7 @@ export const CHANNEL_MESSAGE_ACTION_NAMES = [
"send",
"broadcast",
"poll",
"poll-vote",
"react",
"reactions",
"read",

View File

@@ -7,6 +7,7 @@ export const MESSAGE_ACTION_TARGET_MODE: Record<ChannelMessageActionName, Messag
send: "to",
broadcast: "none",
poll: "to",
"poll-vote": "to",
react: "to",
reactions: "to",
read: "to",