AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(zoom,notion,discord): stop AI update actions resetting settings the agent didn't mention (#17000)
Odai Ahmad2f262684ac28
diff --git a/bun.lock b/bun.lockindex b86ec9d7bd2..2ad8c6be9e7 100644--- a/bun.lock+++ b/bun.lock@@ -2712,7 +2712,7 @@},"packages/pieces/community/discord": {"name": "@activepieces/piece-discord",- "version": "0.8.1",+ "version": "0.8.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2723,6 +2723,7 @@},"devDependencies": {"tslib": "2.6.2",+ "vitest": "3.2.6",},},"packages/pieces/community/discourse": {@@ -6563,7 +6564,7 @@},"packages/pieces/community/notion": {"name": "@activepieces/piece-notion",- "version": "0.8.2",+ "version": "0.8.3","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10519,7 +10520,7 @@},"packages/pieces/community/zoom": {"name": "@activepieces/piece-zoom",- "version": "0.9.1",+ "version": "0.9.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",diff --git a/packages/pieces/community/discord/package.json b/packages/pieces/community/discord/package.jsonindex 77abc9fa926..161108a164f 100644--- a/packages/pieces/community/discord/package.json+++ b/packages/pieces/community/discord/package.json@@ -1,12 +1,13 @@{"name": "@activepieces/piece-discord",- "version": "0.8.1",+ "version": "0.8.2","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {"build": "tsc -p tsconfig.lib.json && cp package.json dist/","bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",- "lint": "eslint 'src/**/*.ts'"+ "lint": "eslint 'src/**/*.ts'",+ "test": "vitest run"},"dependencies": {"@activepieces/pieces-common": "workspace:*",@@ -17,6 +18,7 @@"@activepieces/core-utils": "workspace:*"},"devDependencies": {- "tslib": "2.6.2"+ "tslib": "2.6.2",+ "vitest": "3.2.6"}}diff --git a/packages/pieces/community/discord/src/lib/actions/ai-update-role.ts b/packages/pieces/community/discord/src/lib/actions/ai-update-role.tsindex a426c8042d2..738d451c04f 100644--- a/packages/pieces/community/discord/src/lib/actions/ai-update-role.ts+++ b/packages/pieces/community/discord/src/lib/actions/ai-update-role.ts@@ -7,6 +7,29 @@ import {import { discordAuth } from '../auth';import { discordRoleActionOutputSchema } from '../output-schemas';+function resolveTriState(value: unknown): boolean | undefined {+ if (typeof value === 'boolean') {+ return value;+ }+ if (typeof value !== 'string') {+ return undefined;+ }+ const normalized = value.trim().toLowerCase();+ if (normalized === 'yes' || normalized === 'true') {+ return true;+ }+ if (normalized === 'no' || normalized === 'false') {+ return false;+ }+ return undefined;+}++const triStateOptions = [+ { label: 'Yes', value: 'yes' },+ { label: 'No', value: 'no' },+ { label: 'Leave unchanged', value: 'unchanged' },+];+export const discordUpdateRole = createAction({auth: discordAuth,name: 'discord_update_role',@@ -16,7 +39,7 @@ export const discordUpdateRole = createAction({audience: 'ai',aiMetadata: {description:- 'Updates a role by guild ID and role ID (PATCH /guilds/{guild_id}/roles/{role_id}) — name, color, hoist, and mentionable only; it deliberately does NOT touch the permissions bitfield. Resolve role IDs with List Roles. Idempotent: setting the same values yields the same state. Requires Manage Roles permission.',+ 'Updates a role by guild ID and role ID (PATCH /guilds/{guild_id}/roles/{role_id}) — name, color, hoist, and mentionable only; it deliberately does NOT touch the permissions bitfield. Resolve role IDs with List Roles. Idempotent: setting the same values yields the same state. Only the fields you provide are changed; omitted fields (or Leave unchanged) stay as they are. Requires Manage Roles permission.',idempotent: true,},outputSchema: discordRoleActionOutputSchema,@@ -42,15 +65,19 @@ export const discordUpdateRole = createAction({'New role color as an integer RGB value (e.g. 3447003). Leave empty to keep the current color.',required: false,}),- hoist: Property.Checkbox({+ hoist: Property.StaticDropdown({displayName: 'Display Separately',- description: 'Whether members with this role show separately in the sidebar.',+ description:+ 'Show members separately in the sidebar. Leave unchanged to keep it.',required: false,+ options: { options: triStateOptions },}),- mentionable: Property.Checkbox({+ mentionable: Property.StaticDropdown({displayName: 'Mentionable',- description: 'Whether the role can be mentioned by other members.',+ description:+ 'Let members mention this role. Leave unchanged to keep it.',required: false,+ options: { options: triStateOptions },}),reason: Property.ShortText({displayName: 'Reason',@@ -66,11 +93,13 @@ export const discordUpdateRole = createAction({if (configValue.propsValue.color !== undefined && configValue.propsValue.color !== null) {body['color'] = configValue.propsValue.color;}- if (configValue.propsValue.hoist !== undefined) {- body['hoist'] = configValue.propsValue.hoist;+ const hoist = resolveTriState(configValue.propsValue.hoist);+ if (hoist !== undefined) {+ body['hoist'] = hoist;}- if (configValue.propsValue.mentionable !== undefined) {- body['mentionable'] = configValue.propsValue.mentionable;+ const mentionable = resolveTriState(configValue.propsValue.mentionable);+ if (mentionable !== undefined) {+ body['mentionable'] = mentionable;}const request: HttpRequest<any> = {diff --git a/packages/pieces/community/discord/test/ai-update-role.test.ts b/packages/pieces/community/discord/test/ai-update-role.test.tsnew file mode 100644index 00000000000..0c1246719ea--- /dev/null+++ b/packages/pieces/community/discord/test/ai-update-role.test.ts@@ -0,0 +1,53 @@+import { describe, expect, it, vi, beforeEach } from 'vitest';+import { httpClient } from '@activepieces/pieces-common';+import { discordUpdateRole } from '../src/lib/actions/ai-update-role';++vi.mock('@activepieces/pieces-common', async (importOriginal) => {+ const actual = await importOriginal<typeof import('@activepieces/pieces-common')>();+ return {+ ...actual,+ httpClient: { sendRequest: vi.fn() },+ };+});++const sendRequest = vi.mocked(httpClient.sendRequest);++async function runWith(props: Record<string, unknown>) {+ const ctx = {+ auth: { secret_text: 'token' },+ propsValue: { guild_id: '1', role_id: '2', ...props },+ };+ await Reflect.apply(discordUpdateRole.run, discordUpdateRole, [ctx]);+ const request = sendRequest.mock.calls[0][0];+ return request.body;+}++describe('discord_update_role tri-state fields', () => {+ beforeEach(() => {+ sendRequest.mockReset();+ sendRequest.mockResolvedValue({ status: 200, headers: {}, body: { id: '2', name: 'r' } });+ });++ it.each([+ ['yes', true],+ ['no', false],+ ['true', true],+ ['false', false],+ [' TRUE ', true],+ [true, true],+ [false, false],+ ])('sends %s as %s', async (input, expected) => {+ const body = await runWith({ hoist: input, mentionable: input });+ expect(body).toEqual({ hoist: expected, mentionable: expected });+ });++ it.each([['unchanged'], [undefined], [null], ['']])('omits fields for %s', async (input) => {+ const body = await runWith({ hoist: input, mentionable: input });+ expect(body).toEqual({});+ });++ it('rename sends neither hoist nor mentionable', async () => {+ const body = await runWith({ name: 'New name' });+ expect(body).toEqual({ name: 'New name' });+ });+});diff --git a/packages/pieces/community/discord/vitest.config.ts b/packages/pieces/community/discord/vitest.config.tsnew file mode 100644index 00000000000..1bd3d1e5fe7--- /dev/null+++ b/packages/pieces/community/discord/vitest.config.ts@@ -0,0 +1,19 @@+import path from 'path'+import { defineConfig } from 'vitest/config'++const repoRoot = path.resolve(__dirname, '../../../..')++export default defineConfig({+ test: {+ globals: true,+ environment: 'node',+ },+ resolve: {+ alias: {+ '@activepieces/pieces-framework': path.resolve(repoRoot, 'packages/pieces/framework/src/index.ts'),+ '@activepieces/pieces-common': path.resolve(repoRoot, 'packages/pieces/common/src/index.ts'),+ '@activepieces/core-piece-types': path.resolve(repoRoot, 'packages/core/piece-types/src/index.ts'),+ '@activepieces/core-utils': path.resolve(repoRoot, 'packages/core/utils/src/index.ts'),+ },+ },+})diff --git a/packages/pieces/community/notion/package.json b/packages/pieces/community/notion/package.jsonindex d4194ac8af2..07c3de72a7a 100644--- a/packages/pieces/community/notion/package.json+++ b/packages/pieces/community/notion/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-notion",- "version": "0.8.2",+ "version": "0.8.3","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","dependencies": {diff --git a/packages/pieces/community/notion/src/lib/actions/notion-update-block.ts b/packages/pieces/community/notion/src/lib/actions/notion-update-block.tsindex 39df0b7361c..643070353e0 100644--- a/packages/pieces/community/notion/src/lib/actions/notion-update-block.ts+++ b/packages/pieces/community/notion/src/lib/actions/notion-update-block.ts@@ -32,6 +32,27 @@ function toRichText(content: string): Array<{ text: { content: string } }> {return chunks.length > 0 ? chunks : [{ text: { content: '' } }];}+function isLegacyBoolean(value: unknown): value is boolean {+ return typeof value === 'boolean';+}++function resolveChecked(value: unknown): boolean | undefined {+ if (isLegacyBoolean(value)) {+ return value;+ }+ if (typeof value !== 'string') {+ return undefined;+ }+ const normalized = value.trim().toLowerCase();+ if (normalized === 'yes' || normalized === 'true') {+ return true;+ }+ if (normalized === 'no' || normalized === 'false') {+ return false;+ }+ return undefined;+}+export const notionUpdateBlock = createAction({auth: notionAuth,name: 'notion_update_block',@@ -41,7 +62,7 @@ export const notionUpdateBlock = createAction({audience: 'ai',aiMetadata: {description:- "Replaces the text content of a single existing block by id (resolve via notion_get_block_children). Use to edit one block's text in place; to add new blocks use notion_append_to_page. Safe to retry — re-applying the same content converges. The block_type must match the actual block's type; text is split at Notion's 2000-char-per-object cap. For to_do blocks also set checked; for code blocks set language.",+ "Replaces the text content of a single existing block by id (resolve via notion_get_block_children). Use to edit one block's text in place; to add new blocks use notion_append_to_page. Safe to retry — re-applying the same content converges. The block_type must match the actual block's type; text is split at Notion's 2000-char-per-object cap. For to_do blocks set checked to yes/no only to change the state; omit it (or 'unchanged') to keep the current state. For code blocks set language only to change it; omit it to keep the current language.",idempotent: true,},outputSchema: notionUpdateBlockActionOutputSchema,@@ -79,11 +100,19 @@ export const notionUpdateBlock = createAction({],},}),- checked: Property.Checkbox({+ checked: Property.StaticDropdown<string>({displayName: 'Checked',description:- 'For to_do blocks only: whether the checkbox is checked. Ignored for other block types.',+ 'To-do blocks only: tick, untick, or leave the checkbox unchanged.',required: false,+ defaultValue: 'unchanged',+ options: {+ options: [+ { label: 'Yes', value: 'yes' },+ { label: 'No', value: 'no' },+ { label: 'Leave unchanged', value: 'unchanged' },+ ],+ },}),language: Property.ShortText({displayName: 'Language',@@ -107,15 +136,14 @@ export const notionUpdateBlock = createAction({notionVersion: '2022-02-22',});- const body: Record<string, any> = {+ const checkedState = resolveChecked(checked);+ const body: Record<string, unknown> = {rich_text: toRichText(content),+ ...(type === 'to_do' && checkedState !== undefined+ ? { checked: checkedState }+ : {}),+ ...(type === 'code' && language ? { language } : {}),};- if (type === 'to_do') {- body['checked'] = checked ?? false;- }- if (type === 'code') {- body['language'] = language ?? 'plain text';- }try {return await notion.blocks.update({diff --git a/packages/pieces/community/notion/test/notion-update-block.test.ts b/packages/pieces/community/notion/test/notion-update-block.test.tsnew file mode 100644index 00000000000..0e9fe35d627--- /dev/null+++ b/packages/pieces/community/notion/test/notion-update-block.test.ts@@ -0,0 +1,92 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';++const update = vi.fn();++vi.mock('@notionhq/client', () => ({+ Client: vi.fn().mockImplementation(() => ({ blocks: { update } })),+}));++import { notionUpdateBlock } from '../src/lib/actions/notion-update-block';++async function runWith(props: Record<string, unknown>) {+ update.mockResolvedValue({ id: 'b1' });+ await Reflect.apply(notionUpdateBlock.run, undefined, [+ {+ auth: { access_token: 'tok' },+ propsValue: { block_id: 'b1', content: 'hello', ...props },+ },+ ]);+ return update.mock.calls[0][0];+}++describe('notion_update_block', () => {+ beforeEach(() => {+ update.mockReset();+ });++ it('omits checked when unchanged', async () => {+ const req = await runWith({ block_type: 'to_do', checked: 'unchanged' });+ expect(req.to_do).not.toHaveProperty('checked');+ });++ it('omits checked when undefined', async () => {+ const req = await runWith({ block_type: 'to_do' });+ expect(req.to_do).not.toHaveProperty('checked');+ });++ it('omits checked when empty string', async () => {+ const req = await runWith({ block_type: 'to_do', checked: '' });+ expect(req.to_do).not.toHaveProperty('checked');+ });++ it('omits checked when null', async () => {+ const req = await runWith({ block_type: 'to_do', checked: null });+ expect(req.to_do).not.toHaveProperty('checked');+ });++ it('sends true for yes', async () => {+ const req = await runWith({ block_type: 'to_do', checked: 'yes' });+ expect(req.to_do.checked).toBe(true);+ });++ it('sends false for no', async () => {+ const req = await runWith({ block_type: 'to_do', checked: 'no' });+ expect(req.to_do.checked).toBe(false);+ });++ it('sends true for the legacy string true', async () => {+ const req = await runWith({ block_type: 'to_do', checked: 'true' });+ expect(req.to_do.checked).toBe(true);+ });++ it('sends false for the legacy string false', async () => {+ const req = await runWith({ block_type: 'to_do', checked: 'False' });+ expect(req.to_do.checked).toBe(false);+ });++ it('keeps legacy true', async () => {+ const req = await runWith({ block_type: 'to_do', checked: true });+ expect(req.to_do.checked).toBe(true);+ });++ it('keeps legacy false', async () => {+ const req = await runWith({ block_type: 'to_do', checked: false });+ expect(req.to_do.checked).toBe(false);+ });++ it('ignores checked for non to_do blocks', async () => {+ const req = await runWith({ block_type: 'paragraph', checked: 'yes' });+ expect(req.paragraph).not.toHaveProperty('checked');+ expect(req.paragraph.rich_text).toEqual([{ text: { content: 'hello' } }]);+ });++ it('sends language for code when provided', async () => {+ const req = await runWith({ block_type: 'code', language: 'python' });+ expect(req.code.language).toBe('python');+ });++ it('omits language for code when not provided', async () => {+ const req = await runWith({ block_type: 'code' });+ expect(req.code).not.toHaveProperty('language');+ });+});diff --git a/packages/pieces/community/zoom/package.json b/packages/pieces/community/zoom/package.jsonindex 3603267f2a4..388b97744f2 100644--- a/packages/pieces/community/zoom/package.json+++ b/packages/pieces/community/zoom/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-zoom",- "version": "0.9.1",+ "version": "0.9.2","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {diff --git a/packages/pieces/community/zoom/src/lib/actions/update-meeting-by-id.ts b/packages/pieces/community/zoom/src/lib/actions/update-meeting-by-id.tsindex e1b24e3ddaf..85ad0fe4d3c 100644--- a/packages/pieces/community/zoom/src/lib/actions/update-meeting-by-id.ts+++ b/packages/pieces/community/zoom/src/lib/actions/update-meeting-by-id.ts@@ -65,11 +65,11 @@ export const zoomUpdateMeetingById = createAction({],},}),- host_video: Property.Checkbox({ displayName: 'Host Video', description: 'Start video when the host joins.', required: false }),- participant_video: Property.Checkbox({ displayName: 'Participant Video', description: 'Start video when participants join.', required: false }),- join_before_host: Property.Checkbox({ displayName: 'Join Before Host', description: 'Let participants join before the host.', required: false }),- mute_upon_entry: Property.Checkbox({ displayName: 'Mute Upon Entry', description: 'Mute participants when they join.', required: false }),- waiting_room: Property.Checkbox({ displayName: 'Waiting Room', description: 'Turn the waiting room on or off.', required: false }),+ host_video: triStateSetting({ displayName: 'Host Video', description: 'Start video when the host joins.' }),+ participant_video: triStateSetting({ displayName: 'Participant Video', description: 'Start video when participants join.' }),+ join_before_host: triStateSetting({ displayName: 'Join Before Host', description: 'Let participants join before the host.' }),+ mute_upon_entry: triStateSetting({ displayName: 'Mute Upon Entry', description: 'Mute participants when they join.' }),+ waiting_room: triStateSetting({ displayName: 'Waiting Room', description: 'Turn the waiting room on or off.' }),},async run(context) {const meetingId = zoomClient.normalizeMeetingId(context.propsValue.meeting_id);@@ -111,11 +111,11 @@ function buildUpdateBody({ propsValue }: { propsValue: UpdateProps }): Record<stconst settingEntries = Object.entries({auto_recording: propsValue.auto_recording,audio: propsValue.audio,- host_video: propsValue.host_video,- participant_video: propsValue.participant_video,- join_before_host: propsValue.join_before_host,- mute_upon_entry: propsValue.mute_upon_entry,- waiting_room: propsValue.waiting_room,+ host_video: toSettingValue(propsValue.host_video),+ participant_video: toSettingValue(propsValue.participant_video),+ join_before_host: toSettingValue(propsValue.join_before_host),+ mute_upon_entry: toSettingValue(propsValue.mute_upon_entry),+ waiting_room: toSettingValue(propsValue.waiting_room),}).filter(([, value]) => value !== undefined && value !== null && value !== '');return {...(topic !== undefined ? { topic } : {}),@@ -128,6 +128,33 @@ function buildUpdateBody({ propsValue }: { propsValue: UpdateProps }): Record<st};}+function triStateSetting({ displayName, description }: { displayName: string; description: string }) {+ return Property.StaticDropdown({+ displayName,+ description: `${description} Leave unchanged to keep the meeting's current setting.`,+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Yes', value: 'yes' },+ { label: 'No', value: 'no' },+ { label: 'Leave unchanged', value: 'unchanged' },+ ],+ },+ });+}++function toSettingValue(value: TriStateValue): boolean | undefined {+ if (typeof value === 'boolean') return value;+ if (typeof value !== 'string') return undefined;+ const normalized = value.trim().toLowerCase();+ if (normalized === 'yes' || normalized === 'true') return true;+ if (normalized === 'no' || normalized === 'false') return false;+ return undefined;+}++type TriStateValue = string | boolean | null | undefined;+type UpdateProps = {topic?: string;start_time?: string;@@ -138,9 +165,9 @@ type UpdateProps = {password?: string;auto_recording?: string;audio?: string;- host_video?: boolean;- participant_video?: boolean;- join_before_host?: boolean;- mute_upon_entry?: boolean;- waiting_room?: boolean;+ host_video?: TriStateValue;+ participant_video?: TriStateValue;+ join_before_host?: TriStateValue;+ mute_upon_entry?: TriStateValue;+ waiting_room?: TriStateValue;};diff --git a/packages/pieces/community/zoom/test/meetings.test.ts b/packages/pieces/community/zoom/test/meetings.test.tsindex 29d384ad3e3..876f5106c5c 100644--- a/packages/pieces/community/zoom/test/meetings.test.ts+++ b/packages/pieces/community/zoom/test/meetings.test.ts@@ -34,13 +34,51 @@ describe('Update Meeting (by ID)', () => {it('sends only the fields given', async () => {const fetchMock = installFetch();fetchMock.mockResolvedValueOnce(emptyResponse({ status: 204 }));- const result = await runAction({ action: zoomUpdateMeetingById, propsValue: { meeting_id: '1', topic: 'New', duration: 0, waiting_room: false } });+ const result = await runAction({ action: zoomUpdateMeetingById, propsValue: { meeting_id: '1', topic: 'New', duration: 0, waiting_room: 'no' } });const request = requestOf({ fetchMock, call: 0 });expect(request.method).toBe('PATCH');expect(request.body).toEqual({ topic: 'New', duration: 0, settings: { waiting_room: false } });expect(result).toEqual({ success: true, meeting_id: '1', occurrence_id: null, updated_fields: ['topic', 'duration', 'settings.waiting_room'] });});+ it('leaves the meeting settings out when they are left unchanged or omitted', async () => {+ const fetchMock = installFetch();+ fetchMock.mockResolvedValueOnce(emptyResponse({ status: 204 }));+ await runAction({+ action: zoomUpdateMeetingById,+ propsValue: { meeting_id: '1', start_time: '2026-11-01T15:00:00Z', host_video: 'unchanged', participant_video: 'unchanged', waiting_room: 'unchanged' },+ });+ expect(requestOf({ fetchMock, call: 0 }).body).toEqual({ start_time: '2026-11-01T15:00:00Z' });+ });++ it('sends Yes as true for a tri-state setting', async () => {+ const fetchMock = installFetch();+ fetchMock.mockResolvedValueOnce(emptyResponse({ status: 204 }));+ await runAction({ action: zoomUpdateMeetingById, propsValue: { meeting_id: '1', waiting_room: 'yes', mute_upon_entry: 'no' } });+ expect(requestOf({ fetchMock, call: 0 }).body).toEqual({ settings: { mute_upon_entry: false, waiting_room: true } });+ });++ it('converts saved true and false strings from older steps', async () => {+ const fetchMock = installFetch();+ fetchMock.mockResolvedValueOnce(emptyResponse({ status: 204 }));+ await runAction({ action: zoomUpdateMeetingById, propsValue: { meeting_id: '1', waiting_room: 'true', host_video: 'FALSE' } });+ expect(requestOf({ fetchMock, call: 0 }).body).toEqual({ settings: { host_video: false, waiting_room: true } });+ });++ it('keeps saved boolean true and false values from older steps', async () => {+ const fetchMock = installFetch();+ fetchMock.mockResolvedValueOnce(emptyResponse({ status: 204 }));+ await runAction({ action: zoomUpdateMeetingById, propsValue: { meeting_id: '1', waiting_room: true, host_video: false } });+ expect(requestOf({ fetchMock, call: 0 }).body).toEqual({ settings: { host_video: false, waiting_room: true } });+ });++ it('omits settings saved as null or empty', async () => {+ const fetchMock = installFetch();+ fetchMock.mockResolvedValueOnce(emptyResponse({ status: 204 }));+ await runAction({ action: zoomUpdateMeetingById, propsValue: { meeting_id: '1', topic: 'T', waiting_room: null, host_video: '' } });+ expect(requestOf({ fetchMock, call: 0 }).body).toEqual({ topic: 'T' });+ });+it('clears the agenda with Clear Agenda and targets an occurrence', async () => {const fetchMock = installFetch();fetchMock.mockResolvedValueOnce(emptyResponse({ status: 204 }));