diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..aaaa5e7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +## 1.3.0 + +- New triggers (instant, Taskade Pro plan or higher): New Comment, Task Assigned, New Project, Project Assigned, Member Joined Project. +- New task actions: Complete Task, Update Task, Delete Task, Move Task, Set Task Due Date, Assign Task, Set Task Note, Set Task Custom Field. +- New project actions: Create Project, Create Project From Template, Complete Project, Copy Project, Get Project Share Link. +- New AI agent actions: Run AI Agent, Create AI Agent, Generate AI Agent, Update AI Agent, Add Knowledge to AI Agent, Enable Public Agent Access. +- New actions: Run Automation (starts a Taskade automation that begins with a webhook trigger), Custom API Call. +- New searches: Find Task, Find Project, Find AI Agent, Get Project Content. +- Update: Run AI Agent picks the folder and the agent from dropdowns. +- Update: Create Task has a clearer description. Task Due and Create Task keep their inputs and outputs. + +## 1.0.8 + +- Fix: connections no longer expire about 1 hour after connecting. diff --git a/README.md b/README.md index 632f0be..61d6f94 100644 --- a/README.md +++ b/README.md @@ -11,21 +11,50 @@ Building a Taskade integration for another platform (n8n, Activepieces, Make, Pi | Platform | Status | |---|---| -| Zapier | Live: [Taskade on Zapier](https://zapier.com/apps/taskade/integrations). Deploys are manual, so the live app version can lag this source. | -| n8n | Source in [`packages/n8n-nodes-taskade`](packages/n8n-nodes-taskade) (package `n8n-nodes-taskade` 0.2.0). Not yet published to npm. | -| Activepieces, Make, Pipedream | Planned. No code in this repo yet. | +| Zapier | Live: [Taskade on Zapier](https://zapier.com/apps/taskade/integrations). The public version has 1 trigger (Task Due) and 1 action (Create Task). This source holds the full set below. Deploys are manual, so the live app version can lag this source. | +| Activepieces | Live: [Taskade on Activepieces](https://www.activepieces.com/pieces/taskade) (`@activepieces/piece-taskade`). Activepieces maintains the piece in [its own repo](https://github.com/activepieces/activepieces). | +| Pipedream | Live: [Taskade on Pipedream](https://pipedream.com/apps/taskade). Pipedream maintains the components in [its own repo](https://github.com/PipedreamHQ/pipedream). | +| n8n | Source in [`packages/n8n-nodes-taskade`](packages/n8n-nodes-taskade). Not yet published to npm. | +| Make | In review: the official Make app is in [#34](https://github.com/taskade/integrations/pull/34). Not yet on Make. | ## Zapier app capabilities -| Type | Keys | Notes | -|---|---|---| -| Trigger (instant) | `task_due` | Fires when a task is due. Uses Taskade-internal webhook routes. | -| Trigger (instant) | `new_comment`, `task_assigned`, `new_project`, `project_assigned`, `project_joined` | Use the public webhook-subscription API (`POST /api/v2/subscribeWebhook`) | -| Action (tasks) | `create_task`, `complete_task`, `update_task`, `delete_task`, `move_task`, `set_task_date`, `assign_task`, `set_task_note`, `set_custom_field` | `create_task` splits content over 2000 characters into sibling tasks | -| Action (projects) | `create_project`, `create_project_from_template`, `complete_project`, `copy_project`, `enable_share_link` | | -| Action (AI agents) | `run_agent`, `create_agent`, `generate_agent`, `update_agent`, `add_agent_knowledge`, `publish_agent` | `run_agent` prompts an agent and returns its response | -| Action (other) | `trigger_automation`, `custom_api_call` | `custom_api_call` sends an authenticated request to any Taskade API endpoint | -| Search | `find_task`, `find_project` | | +All triggers are instant (webhooks). The 5 triggers on the public webhook-subscription API need a Taskade Pro plan or higher. Actions and searches do not need Pro. Run AI Agent and Generate AI Agent use AI credits, and Run Automation needs an automation with a webhook trigger, which also needs Pro. + +| Type | Name | Key | Notes | +|---|---|---|---| +| Trigger | Task Due | `task_due` | Fires when a task is due. Uses Taskade-internal webhook routes. | +| Trigger | New Comment | `new_comment` | Public webhook-subscription API (`POST /api/v2/subscribeWebhook`) | +| Trigger | Task Assigned | `task_assigned` | Public webhook-subscription API | +| Trigger | New Project | `new_project` | Public webhook-subscription API | +| Trigger | Project Assigned | `project_assigned` | Public webhook-subscription API | +| Trigger | Member Joined Project | `project_joined` | Public webhook-subscription API | +| Action | Create Task | `create_task` | Splits content over 2000 characters into sibling tasks | +| Action | Complete Task | `complete_task` | Can also reopen a task | +| Action | Update Task | `update_task` | | +| Action | Delete Task | `delete_task` | | +| Action | Move Task | `move_task` | | +| Action | Set Task Due Date | `set_task_date` | Can also clear the date | +| Action | Assign Task | `assign_task` | | +| Action | Set Task Note | `set_task_note` | | +| Action | Set Task Custom Field | `set_custom_field` | | +| Action | Create Project | `create_project` | From Markdown text | +| Action | Create Project From Template | `create_project_from_template` | | +| Action | Complete Project | `complete_project` | Can also restore a project | +| Action | Copy Project | `copy_project` | | +| Action | Get Project Share Link | `enable_share_link` | | +| Action | Run AI Agent | `run_agent` | Sends a prompt and returns the reply. Uses AI credits. | +| Action | Create AI Agent | `create_agent` | From a persona template | +| Action | Generate AI Agent | `generate_agent` | From a plain-language description | +| Action | Update AI Agent | `update_agent` | | +| Action | Add Knowledge to AI Agent | `add_agent_knowledge` | A project or a media file | +| Action | Enable Public Agent Access | `publish_agent` | | +| Action | Run Automation | `trigger_automation` | Starts a Taskade automation that begins with a webhook trigger | +| Action | Custom API Call | `custom_api_call` | Sends an authenticated request to any Taskade API endpoint | +| Search | Find Task | `find_task` | | +| Search | Find Project | `find_project` | | +| Search | Find AI Agent | `find_agent` | | +| Search | Get Project Content | `get_project_content` | Returns the project as Markdown | Hidden dropdown helpers (not user-facing): `get_all_spaces`, `get_all_projects`, `get_all_blocks`, `get_all_assignable_members`, `get_all_tasks`, `get_all_project_templates`, `get_all_agents`, `get_all_fields`. @@ -48,8 +77,11 @@ The test suite validates the full app definition with `zapier-platform-schema`'s ### Release -1. Bump `version` in `package.json` -2. `yarn build && zapier build && zapier push` +1. Bump `version` in `package.json` to a number that `zapier versions` does not list yet +2. Add the release notes to `CHANGELOG.md` +3. `yarn build && zapier push` +4. Test each new trigger, action and search in a Zap, then `zapier promote ` +5. `zapier migrate ` moves existing users to the new version. Start with a small percent and watch `zapier logs` Deploying to the live Zapier app is a deliberate, manual step — never automatic on merge. @@ -63,13 +95,13 @@ zapier logs --type=http --detailed ## Roadmap -- Platform-agnostic operation manifest + per-platform codegen — the existing [n8n node](packages/n8n-nodes-taskade) and future targets (Activepieces, Make, Pipedream) rendered from one source +- Platform-agnostic operation manifest + per-platform codegen: the existing [n8n node](packages/n8n-nodes-taskade) and the Make app rendered from one source - Move `task_due` to the public webhook-subscription API See the [Zapier Integration Guide](https://help.taskade.com/en/articles/8958540-zapier-integration) for end-user docs. ## Related repos -- [Taskade Docs](https://github.com/taskade/docs) — source for [docs.taskade.com](https://docs.taskade.com) -- [Taskade MCP](https://github.com/taskade/mcp) — official MCP server ([`@taskade/mcp-server`](https://www.npmjs.com/package/@taskade/mcp-server) on npm) -- [Taskade](https://github.com/taskade/taskade) — platform home, including the Genesis AI app builder +- [Taskade Docs](https://github.com/taskade/docs): source for [docs.taskade.com](https://docs.taskade.com) +- [Taskade MCP](https://github.com/taskade/mcp): official MCP server ([`@taskade/mcp-server`](https://www.npmjs.com/package/@taskade/mcp-server) on npm) +- [Taskade](https://github.com/taskade/taskade): platform home, including the Taskade Genesis AI app builder diff --git a/package.json b/package.json index 9d685be..f13831b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "taskade", - "version": "1.2.0", + "version": "1.3.0", "description": "Taskade is a collaboration platform for remote teams to organize and manage projects.", "main": "index.js", "scripts": { diff --git a/src/creates/createAgent.ts b/src/creates/createAgent.ts index 3f84645..8fd7cd5 100644 --- a/src/creates/createAgent.ts +++ b/src/creates/createAgent.ts @@ -54,7 +54,7 @@ export default { default: 'Tasker', required: true, helpText: - 'The agent template to start from. Any valid Taskade persona works — this list shows common ones.', + 'The agent template to start from. This list shows common personas. You can also enter another valid Taskade persona.', }, ], perform, diff --git a/src/creates/createProject.ts b/src/creates/createProject.ts index f82297a..2309825 100644 --- a/src/creates/createProject.ts +++ b/src/creates/createProject.ts @@ -9,7 +9,8 @@ const perform = async (z: ZObject, bundle: Bundle) => { path: '/projects', body: { folderId: bundle.inputData.space_id, - contentType: (bundle.inputData.content_type as string) ?? 'text/markdown', + // The endpoint accepts only Markdown. Plain text is valid Markdown. + contentType: 'text/markdown', content: bundle.inputData.content as string, }, }); @@ -35,15 +36,8 @@ export default { label: 'Content', type: 'text', required: true, - helpText: 'Markdown content for the project, e.g. a title line followed by tasks.', - }, - { - key: 'content_type', - label: 'Format', - type: 'string', - choices: { 'text/markdown': 'Markdown', 'text/plain': 'Plain text' }, - default: 'text/markdown', - required: false, + helpText: + 'The project text in Markdown, for example a title line followed by a list of tasks.', }, ], perform, diff --git a/src/creates/createProjectFromTemplate.ts b/src/creates/createProjectFromTemplate.ts index b3143b7..4fcf6d1 100644 --- a/src/creates/createProjectFromTemplate.ts +++ b/src/creates/createProjectFromTemplate.ts @@ -22,7 +22,7 @@ export default { key: 'create_project_from_template', noun: 'Project', display: { - label: 'Create Project from Template', + label: 'Create Project From Template', description: 'Creates a new project from an existing template in a folder.', hidden: false, }, diff --git a/src/creates/createTask.ts b/src/creates/createTask.ts index 8b7368a..87171c9 100644 --- a/src/creates/createTask.ts +++ b/src/creates/createTask.ts @@ -235,7 +235,7 @@ export default { noun: 'Task', display: { label: 'Create Task', - description: 'Creates a Task in Taskade', + description: 'Creates a task in a Taskade project.', hidden: false, }, operation: { @@ -296,7 +296,7 @@ export default { }, { key: 'member_id', - label: 'Assign to', + label: 'Assign To', type: 'string', dynamic: 'get_all_assignable_members.id.displayName', required: false, diff --git a/src/creates/customApiCall.ts b/src/creates/customApiCall.ts index 3a66669..3843926 100644 --- a/src/creates/customApiCall.ts +++ b/src/creates/customApiCall.ts @@ -1,23 +1,39 @@ import { Bundle, ZObject } from 'zapier-platform-core'; +const TASKADE_ORIGIN = 'https://www.taskade.com'; + const perform = async (z: ZObject, bundle: Bundle) => { - const raw = bundle.inputData.url as string; - const url = raw.startsWith('http') - ? raw - : `https://www.taskade.com${raw.startsWith('/') ? '' : '/'}${raw}`; + const raw = String(bundle.inputData.url ?? '').trim(); + // The request carries the user's Taskade token, so it may go only to Taskade. + // A relative path resolves against the Taskade host. + let url: URL; + try { + url = new URL(raw, TASKADE_ORIGIN); + } catch { + throw new z.errors.Error(`"${raw}" is not a valid URL or path.`, 'invalid_input', 400); + } + if (url.origin !== TASKADE_ORIGIN) { + throw new z.errors.Error( + `The URL must be on ${TASKADE_ORIGIN}. Use a path such as /api/v2/listSpaces.`, + 'invalid_input', + 400, + ); + } const method = (bundle.inputData.http_method as 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH') || 'GET'; + // The API rejects an empty body when the content type is JSON. + const hasBody = method === 'POST' || method === 'PUT' || method === 'PATCH'; const response = await z.request({ - url, + url: url.toString(), method, headers: { Accept: 'application/json', 'content-type': 'application/json', authorization: `Bearer ${bundle.authData.access_token}`, }, - body: bundle.inputData.body ? (bundle.inputData.body as string) : undefined, + body: bundle.inputData.body ? (bundle.inputData.body as string) : hasBody ? '{}' : undefined, // Don't auto-throw on 4xx/5xx: this escape hatch must surface the real // status + error body so power users can inspect failed calls. skipThrowForStatus: true, @@ -32,7 +48,7 @@ export default { display: { label: 'Custom API Call', description: - 'Make an authenticated request to any Taskade API endpoint. Advanced — see developer.taskade.com.', + 'Makes an authenticated request to any Taskade API endpoint. For advanced users.', hidden: false, }, operation: { @@ -50,7 +66,8 @@ export default { label: 'URL or Path', type: 'string', required: true, - helpText: 'A full URL, or a path such as `/api/v1/me/projects`.', + helpText: + 'A path such as `/api/v2/listSpaces`, or a full `https://www.taskade.com` URL. Version 2 paths need the Method POST. See the [API docs](https://www.taskade.com/api/documentation/v2).', }, { key: 'body', diff --git a/src/creates/runAgent.ts b/src/creates/runAgent.ts index 49eb659..8fe0bfc 100644 --- a/src/creates/runAgent.ts +++ b/src/creates/runAgent.ts @@ -1,6 +1,7 @@ import { Bundle, ZObject } from 'zapier-platform-core'; import { ApiResponse, parseOk, request } from '../client'; +import { spaceField } from '../fields'; const perform = async (z: ZObject, bundle: Bundle) => { const response = await request(z, bundle, { @@ -24,35 +25,38 @@ export default { noun: 'Agent Response', display: { label: 'Run AI Agent', - description: 'Sends a prompt to a Taskade AI agent and returns its response.', + description: + 'Sends a prompt to a Taskade AI agent and returns its reply. Each run uses AI credits from your Taskade plan.', hidden: false, }, operation: { inputFields: [ { - key: 'space_id', - label: 'Workspace ID', - type: 'string', - required: true, - helpText: 'The ID of the workspace the agent belongs to.', + ...spaceField(true), + label: 'Folder', + altersDynamicFields: true, + helpText: 'The workspace or folder that holds the agent.', }, { key: 'agent_id', - label: 'Agent ID', + label: 'Agent', type: 'string', + dynamic: 'get_all_agents.id.title', + search: 'find_agent.id', required: true, - helpText: 'The ID of the agent to prompt.', + list: false, + altersDynamicFields: false, }, { key: 'prompt', label: 'Prompt', type: 'text', required: true, - helpText: 'The message to send to the agent.', + helpText: 'The message to send to the agent, for example "Summarize this support email".', }, ], perform, sample: { summary: 'Here is the agent response.' }, - outputFields: [{ key: 'summary', label: 'Response' }], + outputFields: [{ key: 'summary', label: 'Agent Reply' }], }, }; diff --git a/src/creates/setTaskNote.ts b/src/creates/setTaskNote.ts index 228c8f6..accba38 100644 --- a/src/creates/setTaskNote.ts +++ b/src/creates/setTaskNote.ts @@ -36,7 +36,7 @@ export default { label: 'Note', type: 'string', required: true, - helpText: 'Note content — single line, no line breaks.', + helpText: 'The note text, on a single line with no line breaks.', }, { key: 'note_type', diff --git a/src/creates/triggerAutomation.ts b/src/creates/triggerAutomation.ts index bcc2fd9..ea3e92f 100644 --- a/src/creates/triggerAutomation.ts +++ b/src/creates/triggerAutomation.ts @@ -25,7 +25,7 @@ const perform = async (z: ZObject, bundle: Bundle) => { if (response.status >= 400) { throw new z.errors.Error( - `Automation webhook returned ${response.status} — check the webhook URL is current.`, + `Automation webhook returned ${response.status}. Make sure that the webhook URL is current and the automation is on.`, 'invalid_input', response.status, ); @@ -38,9 +38,9 @@ export default { key: 'trigger_automation', noun: 'Automation Run', display: { - label: 'Trigger Taskade Automation', + label: 'Run Automation', description: - 'Starts a Taskade automation that uses a Webhook trigger, passing an optional JSON payload.', + 'Starts a Taskade automation that begins with a webhook trigger, and sends it optional JSON data. Webhook triggers require a Taskade Pro plan or higher.', hidden: false, }, operation: { diff --git a/src/index.ts b/src/index.ts index e293d62..fed06c0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,8 +25,10 @@ import SetTaskNote from './creates/setTaskNote'; import TriggerAutomation from './creates/triggerAutomation'; import UpdateAgent from './creates/updateAgent'; import UpdateTask from './creates/updateTask'; +import FindAgent from './searches/findAgent'; import FindProject from './searches/findProject'; import FindTask from './searches/findTask'; +import GetProjectContent from './searches/getProjectContent'; import GetAllAgents from './triggers/getAllAgents'; import GetAllAssignableMembers from './triggers/getAllAssignableMembers'; import GetAllBlocks from './triggers/getAllBlocks'; @@ -102,5 +104,7 @@ export default { searches: { [FindTask.key]: FindTask, [FindProject.key]: FindProject, + [GetProjectContent.key]: GetProjectContent, + [FindAgent.key]: FindAgent, }, }; diff --git a/src/searches/findAgent.ts b/src/searches/findAgent.ts new file mode 100644 index 0000000..43dcb3f --- /dev/null +++ b/src/searches/findAgent.ts @@ -0,0 +1,68 @@ +import { Bundle, ZObject } from 'zapier-platform-core'; + +import { ApiResponse, parseOk, request } from '../client'; +import { spaceField } from '../fields'; + +const TAA_AGENT_ID = 'taa'; + +const perform = async (z: ZObject, bundle: Bundle) => { + const response = await request(z, bundle, { + method: 'POST', + path: '/listAgents', + version: 'v2', + body: { + spaceId: bundle.inputData.space_id, + filterBy: { name: { operator: 'contains', value: String(bundle.inputData.query ?? '') } }, + }, + }); + + const data: ApiResponse = parseOk(z, response.json); + const query = String(bundle.inputData.query ?? '').toLowerCase(); + + const agents = (data.items ?? []) + // `taa` is the built-in Taskade agent that the API lists first. It is not + // one of the user's agents, so a name search must not pick it. + .filter((agent) => agent.id !== TAA_AGENT_ID) + .map((agent) => ({ + id: agent.id as string, + name: (agent.name ?? '') as string, + description: (agent.description ?? '') as string, + })); + + // Zapier uses the first result, so put an exact name match first. + const exact = agents.filter((agent) => agent.name.toLowerCase() === query); + return [...exact, ...agents.filter((agent) => agent.name.toLowerCase() !== query)]; +}; + +export default { + key: 'find_agent', + noun: 'Agent', + display: { + label: 'Find AI Agent', + description: 'Finds an AI agent in a folder by its name.', + hidden: false, + }, + operation: { + inputFields: [ + { ...spaceField(true), label: 'Folder' }, + { + key: 'query', + label: 'Agent Name', + type: 'string', + required: true, + helpText: 'Returns agents whose name contains this value.', + }, + ], + perform, + sample: { + id: 'agent-123', + name: 'Support Triage Agent', + description: 'You sort inbound support emails by topic and urgency.', + }, + outputFields: [ + { key: 'id', label: 'Agent ID' }, + { key: 'name', label: 'Name' }, + { key: 'description', label: 'Description' }, + ], + }, +}; diff --git a/src/searches/getProjectContent.ts b/src/searches/getProjectContent.ts new file mode 100644 index 0000000..01e2c43 --- /dev/null +++ b/src/searches/getProjectContent.ts @@ -0,0 +1,49 @@ +import { Bundle, ZObject } from 'zapier-platform-core'; + +import { ApiResponse, parseOk, request } from '../client'; +import { projectField, spaceField } from '../fields'; + +const perform = async (z: ZObject, bundle: Bundle) => { + const response = await request(z, bundle, { + method: 'POST', + path: '/exportProject', + version: 'v2', + body: { projectId: bundle.inputData.project_id }, + }); + + const data: ApiResponse = parseOk(z, response.json); + const item = (data.item ?? {}) as Record; + + return [ + { + id: (item.id ?? bundle.inputData.project_id) as string, + name: (item.name ?? '') as string, + content: (item.content ?? '') as string, + }, + ]; +}; + +export default { + key: 'get_project_content', + noun: 'Project Content', + display: { + label: 'Get Project Content', + description: + 'Gets the full text of a project as Markdown, for use in later steps such as an email or an AI prompt.', + hidden: false, + }, + operation: { + inputFields: [spaceField(false), projectField(true)], + perform, + sample: { + id: 'A1b2C3d4E5f6G7h8', + name: 'Q3 Launch Plan', + content: '# Q3 Launch Plan\n\n- [ ] Draft the launch email\n- [x] Book the venue', + }, + outputFields: [ + { key: 'id', label: 'Project ID' }, + { key: 'name', label: 'Name' }, + { key: 'content', label: 'Content (Markdown)' }, + ], + }, +}; diff --git a/src/test/app.test.ts b/src/test/app.test.ts index c1345ec..435a17e 100644 --- a/src/test/app.test.ts +++ b/src/test/app.test.ts @@ -1,4 +1,11 @@ +import { Bundle, ZObject } from 'zapier-platform-core'; + +import CreateProject from '../creates/createProject'; +import CustomApiCall from '../creates/customApiCall'; +import RunAgent from '../creates/runAgent'; import App from '../index'; +import FindAgent from '../searches/findAgent'; +import GetProjectContent from '../searches/getProjectContent'; // zapier-platform-schema ships with the platform and has no published types; // require() keeps it untyped without tripping noImplicitAny. @@ -83,7 +90,7 @@ describe('Taskade app definition', () => { it('registers the expected searches', () => { expect(Object.keys(App.searches)).toEqual( - expect.arrayContaining(['find_task', 'find_project']), + expect.arrayContaining(['find_task', 'find_project', 'find_agent', 'get_project_content']), ); }); @@ -92,3 +99,176 @@ describe('Taskade app definition', () => { expect(App.creates.create_task).toBeDefined(); }); }); + +interface Operation { + display: { label: string; description: string; hidden: boolean }; +} + +const visible = (group: Record) => + Object.values(group).filter((operation) => !operation.display.hidden); + +// Words that Zapier's title case check leaves in lower case. +const SMALL_WORDS = new Set(['a', 'an', 'and', 'as', 'by', 'for', 'in', 'of', 'on', 'or', 'to']); + +describe('Zapier listing copy', () => { + it('writes every visible label in title case', () => { + const operations = [ + ...visible(App.triggers as Record), + ...visible(App.creates as Record), + ...visible(App.searches as Record), + ]; + for (const { display } of operations) { + const lowerWords = display.label + .split(' ') + .filter((word) => !SMALL_WORDS.has(word) && word[0] !== word[0].toUpperCase()); + expect({ label: display.label, lowerWords }).toEqual({ label: display.label, lowerWords: [] }); + expect(display.label).not.toMatch(/zapier/i); + } + }); + + it('starts every visible trigger description with "Triggers when" and ends it with a period', () => { + for (const { display } of visible(App.triggers as Record)) { + expect(display.description).toMatch(/^Triggers when .+\.$/); + } + }); + + it('states the Pro plan requirement on every public webhook trigger', () => { + for (const key of ['new_comment', 'task_assigned', 'new_project', 'project_assigned', 'project_joined']) { + expect(App.triggers[key].display.description).toContain('Requires a Taskade Pro plan or higher.'); + } + }); + + it('ends every visible action and search description with a period', () => { + const operations = [ + ...visible(App.creates as Record), + ...visible(App.searches as Record), + ]; + for (const { display } of operations) { + expect(display.description).toMatch(/^[A-Z][a-z]+s .+\.$/); + } + }); +}); + +// A minimal stand-in for the Zapier `z` object: it records each request and +// answers with the given JSON body. +const fakeZ = (json: unknown) => { + const calls: Array<{ url: string; method: string; body?: string }> = []; + const z = { + request: async (options: { url: string; method: string; body?: string }) => { + calls.push(options); + return { status: 200, json }; + }, + errors: { Error: class extends Error {} }, + } as unknown as ZObject; + return { z, calls }; +}; + +const fakeBundle = (inputData: Record) => + ({ authData: { access_token: 'token' }, inputData, meta: {} }) as unknown as Bundle; + +describe('Taskade Genesis actions and searches', () => { + it('prompts the selected agent through the v2 API and returns its reply', async () => { + const { z, calls } = fakeZ({ ok: true, summary: 'Hello from the agent.' }); + const result = await RunAgent.operation.perform( + z, + fakeBundle({ space_id: 'folder-1', agent_id: 'agent-1', prompt: 'Hi' }), + ); + expect(result).toEqual({ summary: 'Hello from the agent.' }); + expect(calls[0].url).toBe('https://www.taskade.com/api/v2/promptAgent'); + expect(JSON.parse(calls[0].body ?? '{}')).toEqual({ + spaceId: 'folder-1', + agentId: 'agent-1', + prompt: 'Hi', + }); + }); + + it('offers dropdowns, not raw ID fields, for the agent to run', () => { + const fields = RunAgent.operation.inputFields as Array>; + expect(fields.find((field) => field.key === 'space_id')?.dynamic).toBe('get_all_spaces.id.name'); + expect(fields.find((field) => field.key === 'agent_id')?.dynamic).toBe('get_all_agents.id.title'); + }); + + it('finds agents by name with the v2 name filter', async () => { + const { z, calls } = fakeZ({ + ok: true, + items: [{ id: 'agent-1', name: 'Support Triage', description: 'Sorts mail.', tools: {} }], + }); + const result = await FindAgent.operation.perform( + z, + fakeBundle({ space_id: 'folder-1', query: 'Support' }), + ); + expect(result).toEqual([{ id: 'agent-1', name: 'Support Triage', description: 'Sorts mail.' }]); + expect(calls[0].url).toBe('https://www.taskade.com/api/v2/listAgents'); + expect(JSON.parse(calls[0].body ?? '{}')).toEqual({ + spaceId: 'folder-1', + filterBy: { name: { operator: 'contains', value: 'Support' } }, + }); + }); + + it('returns the project Markdown as one search result', async () => { + const { z, calls } = fakeZ({ + ok: true, + item: { id: 'project-1', name: 'Plan', contentType: 'text/markdown', content: '# Plan' }, + }); + const result = await GetProjectContent.operation.perform(z, fakeBundle({ project_id: 'project-1' })); + expect(result).toEqual([{ id: 'project-1', name: 'Plan', content: '# Plan' }]); + expect(calls[0].url).toBe('https://www.taskade.com/api/v2/exportProject'); + expect(JSON.parse(calls[0].body ?? '{}')).toEqual({ projectId: 'project-1' }); + }); + + it('creates projects as Markdown, the only content type the endpoint accepts', async () => { + const { z, calls } = fakeZ({ ok: true, item: { id: 'project-1', name: 'Plan' } }); + // A Zap saved with the removed "Plain text" option still holds content_type. + await CreateProject.operation.perform( + z, + fakeBundle({ space_id: 'folder-1', content: '# Plan', content_type: 'text/plain' }), + ); + expect(CreateProject.operation.inputFields.map((field) => field.key)).not.toContain('content_type'); + expect(JSON.parse(calls[0].body ?? '{}')).toEqual({ + folderId: 'folder-1', + contentType: 'text/markdown', + content: '# Plan', + }); + }); + + it('returns a search sample with the same keys as the live result', async () => { + const { z } = fakeZ({ ok: true, item: { id: 'p', name: 'n', content: 'c' } }); + const [result] = await GetProjectContent.operation.perform(z, fakeBundle({ project_id: 'p' })); + expect(Object.keys(result).sort()).toEqual(Object.keys(GetProjectContent.operation.sample).sort()); + }); +}); + +describe('Review fixes', () => { + it('skips the built-in TAA agent and puts an exact name match first', async () => { + const { z } = fakeZ({ + ok: true, + items: [ + { id: 'taa', name: 'Taskade Agent (TAA)', description: 'The general purpose agent', tools: {} }, + { id: 'agent-2', name: 'Sales Agent Follow-up', description: '', tools: {} }, + { id: 'agent-1', name: 'Sales Agent', description: '', tools: {} }, + ], + }); + const result = await FindAgent.operation.perform(z, fakeBundle({ space_id: 'f', query: 'sales agent' })); + expect(result.map((agent: { id: string }) => agent.id)).toEqual(['agent-1', 'agent-2']); + }); + + it.each([ + 'https://attacker.example/x', + 'http://www.taskade.com/api/v2/listSpaces', + '//attacker.example/x', + 'https://www.taskade.com.attacker.example/x', + ])('refuses to send the token to %s', async (url) => { + const { z, calls } = fakeZ({}); + await expect( + CustomApiCall.operation.perform(z, fakeBundle({ url, http_method: 'GET' })), + ).rejects.toThrow(); + expect(calls).toHaveLength(0); + }); + + it('sends a Taskade path to Taskade with an empty JSON body on POST', async () => { + const { z, calls } = fakeZ({ ok: true }); + await CustomApiCall.operation.perform(z, fakeBundle({ url: '/api/v2/listSpaces', http_method: 'POST' })); + expect(calls[0].url).toBe('https://www.taskade.com/api/v2/listSpaces'); + expect(calls[0].body).toBe('{}'); + }); +}); diff --git a/src/triggers/getAllAgents.ts b/src/triggers/getAllAgents.ts index edb9b99..23f2a57 100644 --- a/src/triggers/getAllAgents.ts +++ b/src/triggers/getAllAgents.ts @@ -7,6 +7,8 @@ const perform = async (z: ZObject, bundle: Bundle) => { const response = await request(z, bundle, { method: 'GET', path: `/folders/${bundle.inputData.space_id}/agents`, + // The route returns 20 agents by default. Ask for more so older agents show too. + params: { limit: '100' }, }); const data: ApiResponse = parseOk(z, response.json); diff --git a/src/triggers/publicWebhook.ts b/src/triggers/publicWebhook.ts index 386b5e1..6e5ac01 100644 --- a/src/triggers/publicWebhook.ts +++ b/src/triggers/publicWebhook.ts @@ -77,7 +77,7 @@ export const NewComment = makePublicWebhookTrigger({ key: 'new_comment', noun: 'Comment', label: 'New Comment', - description: 'Triggers when a comment is added to a task.', + description: 'Triggers when a comment is added to a task. Requires a Taskade Pro plan or higher.', triggerType: 'comment.created', sample: { projectName: 'Customer Projects', @@ -86,7 +86,7 @@ export const NewComment = makePublicWebhookTrigger({ nodeText: 'Follow up with the client', commenterDisplayName: 'Jane Doe', commenterHandle: 'janedoe', - commentBody: 'Done — sent the proposal.', + commentBody: 'Done. I sent the proposal.', commentBodyType: 'text/markdown', assignees: [], mentionedHandles: [], @@ -107,7 +107,7 @@ export const TaskAssigned = makePublicWebhookTrigger({ key: 'task_assigned', noun: 'Task Assignment', label: 'Task Assigned', - description: 'Triggers when tasks are assigned to someone.', + description: 'Triggers when tasks are assigned to someone. Requires a Taskade Pro plan or higher.', triggerType: 'task.assigned', sample: { projectName: 'Customer Projects', @@ -136,7 +136,7 @@ export const NewProject = makePublicWebhookTrigger({ key: 'new_project', noun: 'Project', label: 'New Project', - description: 'Triggers when a project is created.', + description: 'Triggers when a project is created. Requires a Taskade Pro plan or higher.', triggerType: 'project.created', sample: { spaceName: 'Acme Workspace', @@ -158,7 +158,7 @@ export const ProjectAssigned = makePublicWebhookTrigger({ key: 'project_assigned', noun: 'Project Assignment', label: 'Project Assigned', - description: 'Triggers when a project is assigned to someone.', + description: 'Triggers when a project is assigned to someone. Requires a Taskade Pro plan or higher.', triggerType: 'project.assigned', sample: { spaceName: 'Acme Workspace', @@ -182,7 +182,7 @@ export const ProjectJoined = makePublicWebhookTrigger({ key: 'project_joined', noun: 'Project Member', label: 'Member Joined Project', - description: 'Triggers when someone joins a project.', + description: 'Triggers when someone joins a project. Requires a Taskade Pro plan or higher.', triggerType: 'project.joined', sample: { spaceId: '1UsRFaZu9XgyTFej',