From 2de4462850510c4a7dead48cb80b4774dcf46def Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 11 Jun 2026 11:49:29 -0700 Subject: [PATCH 1/6] feat(integrations): add Trigger.dev integration --- apps/docs/components/icons.tsx | 29 + apps/docs/components/ui/icon-mapping.ts | 2 + .../content/docs/en/integrations/meta.json | 1 + .../docs/en/integrations/trigger_dev.mdx | 852 ++++++++++++++++++ apps/sim/blocks/blocks/trigger_dev.ts | 792 ++++++++++++++++ apps/sim/blocks/registry.ts | 3 + apps/sim/components/icons.tsx | 29 + apps/sim/lib/integrations/icon-mapping.ts | 2 + apps/sim/lib/integrations/integrations.json | 111 +++ apps/sim/tools/registry.ts | 48 + .../tools/trigger_dev/activate_schedule.ts | 53 ++ .../tools/trigger_dev/batch_trigger_task.ts | 77 ++ apps/sim/tools/trigger_dev/cancel_run.ts | 50 + apps/sim/tools/trigger_dev/create_env_var.ts | 75 ++ apps/sim/tools/trigger_dev/create_schedule.ts | 89 ++ .../tools/trigger_dev/deactivate_schedule.ts | 53 ++ apps/sim/tools/trigger_dev/delete_env_var.ts | 65 ++ apps/sim/tools/trigger_dev/delete_schedule.ts | 53 ++ apps/sim/tools/trigger_dev/get_env_var.ts | 65 ++ apps/sim/tools/trigger_dev/get_queue.ts | 58 ++ apps/sim/tools/trigger_dev/get_run.ts | 48 + apps/sim/tools/trigger_dev/get_schedule.ts | 53 ++ apps/sim/tools/trigger_dev/index.ts | 23 + apps/sim/tools/trigger_dev/list_env_vars.ts | 73 ++ apps/sim/tools/trigger_dev/list_runs.ts | 190 ++++ apps/sim/tools/trigger_dev/list_schedules.ts | 143 +++ apps/sim/tools/trigger_dev/pause_queue.ts | 61 ++ apps/sim/tools/trigger_dev/replay_run.ts | 50 + apps/sim/tools/trigger_dev/reschedule_run.ts | 62 ++ apps/sim/tools/trigger_dev/resume_queue.ts | 60 ++ apps/sim/tools/trigger_dev/trigger_task.ts | 130 +++ apps/sim/tools/trigger_dev/types.ts | 410 +++++++++ apps/sim/tools/trigger_dev/update_env_var.ts | 74 ++ .../tools/trigger_dev/update_run_metadata.ts | 63 ++ apps/sim/tools/trigger_dev/update_schedule.ts | 88 ++ apps/sim/tools/trigger_dev/utils.ts | 536 +++++++++++ 36 files changed, 4571 insertions(+) create mode 100644 apps/docs/content/docs/en/integrations/trigger_dev.mdx create mode 100644 apps/sim/blocks/blocks/trigger_dev.ts create mode 100644 apps/sim/tools/trigger_dev/activate_schedule.ts create mode 100644 apps/sim/tools/trigger_dev/batch_trigger_task.ts create mode 100644 apps/sim/tools/trigger_dev/cancel_run.ts create mode 100644 apps/sim/tools/trigger_dev/create_env_var.ts create mode 100644 apps/sim/tools/trigger_dev/create_schedule.ts create mode 100644 apps/sim/tools/trigger_dev/deactivate_schedule.ts create mode 100644 apps/sim/tools/trigger_dev/delete_env_var.ts create mode 100644 apps/sim/tools/trigger_dev/delete_schedule.ts create mode 100644 apps/sim/tools/trigger_dev/get_env_var.ts create mode 100644 apps/sim/tools/trigger_dev/get_queue.ts create mode 100644 apps/sim/tools/trigger_dev/get_run.ts create mode 100644 apps/sim/tools/trigger_dev/get_schedule.ts create mode 100644 apps/sim/tools/trigger_dev/index.ts create mode 100644 apps/sim/tools/trigger_dev/list_env_vars.ts create mode 100644 apps/sim/tools/trigger_dev/list_runs.ts create mode 100644 apps/sim/tools/trigger_dev/list_schedules.ts create mode 100644 apps/sim/tools/trigger_dev/pause_queue.ts create mode 100644 apps/sim/tools/trigger_dev/replay_run.ts create mode 100644 apps/sim/tools/trigger_dev/reschedule_run.ts create mode 100644 apps/sim/tools/trigger_dev/resume_queue.ts create mode 100644 apps/sim/tools/trigger_dev/trigger_task.ts create mode 100644 apps/sim/tools/trigger_dev/types.ts create mode 100644 apps/sim/tools/trigger_dev/update_env_var.ts create mode 100644 apps/sim/tools/trigger_dev/update_run_metadata.ts create mode 100644 apps/sim/tools/trigger_dev/update_schedule.ts create mode 100644 apps/sim/tools/trigger_dev/utils.ts diff --git a/apps/docs/components/icons.tsx b/apps/docs/components/icons.tsx index 6f5df2b76b..acefa964ca 100644 --- a/apps/docs/components/icons.tsx +++ b/apps/docs/components/icons.tsx @@ -7602,3 +7602,32 @@ export function WizaIcon(props: SVGProps) { ) } + +export function TriggerDevIcon(props: SVGProps) { + const id = useId() + const gradientId = `triggerdev_paint0_${id}` + + return ( + + + + + + + + + + ) +} diff --git a/apps/docs/components/ui/icon-mapping.ts b/apps/docs/components/ui/icon-mapping.ts index 7a8e927a2c..cbe25a2592 100644 --- a/apps/docs/components/ui/icon-mapping.ts +++ b/apps/docs/components/ui/icon-mapping.ts @@ -197,6 +197,7 @@ import { TextractIcon, TinybirdIcon, TrelloIcon, + TriggerDevIcon, TwilioIcon, TypeformIcon, UpstashIcon, @@ -438,6 +439,7 @@ export const blockTypeToIconMap: Record = { textract_v2: TextractIcon, tinybird: TinybirdIcon, trello: TrelloIcon, + trigger_dev: TriggerDevIcon, twilio_sms: TwilioIcon, twilio_voice: TwilioIcon, typeform: TypeformIcon, diff --git a/apps/docs/content/docs/en/integrations/meta.json b/apps/docs/content/docs/en/integrations/meta.json index dd4558a99c..a2bd8b7f78 100644 --- a/apps/docs/content/docs/en/integrations/meta.json +++ b/apps/docs/content/docs/en/integrations/meta.json @@ -197,6 +197,7 @@ "textract", "tinybird", "trello", + "trigger_dev", "twilio_sms", "twilio_voice", "typeform", diff --git a/apps/docs/content/docs/en/integrations/trigger_dev.mdx b/apps/docs/content/docs/en/integrations/trigger_dev.mdx new file mode 100644 index 0000000000..1adf4d146b --- /dev/null +++ b/apps/docs/content/docs/en/integrations/trigger_dev.mdx @@ -0,0 +1,852 @@ +--- +title: Trigger.dev +description: Trigger tasks and manage runs and schedules +--- + +import { BlockInfoCard } from "@/components/ui/block-info-card" + + + +{/* MANUAL-CONTENT-START:intro */} +[Trigger.dev](https://trigger.dev/) is an open-source platform for running background jobs and AI workloads. You write tasks in plain TypeScript, deploy them to Trigger.dev, and get durable runs with automatic retries, queues, cron schedules, and full observability — no servers or infrastructure to manage. + +With Trigger.dev, you can: + +- **Trigger tasks on demand**: Start a background task with any JSON payload and get back a run ID to track it +- **Batch trigger at scale**: Kick off up to 1,000 runs of a task in a single request +- **Track and control runs**: Retrieve a run's status, payload, output, and attempts; list and filter runs; cancel, replay, or reschedule them +- **Run tasks on a schedule**: Create, update, activate, and deactivate cron schedules with timezone support +- **Manage environment variables**: List, create, read, update, and delete env vars across dev, staging, and prod +- **Control queues**: Inspect queue depth and concurrency, and pause or resume queues during incidents + +In Sim, the Trigger.dev integration lets your agents drive this entire lifecycle. An agent can trigger a deployed task with a payload, poll the run until it completes and use its output downstream, monitor for failed runs and replay the transient ones, manage per-customer cron schedules, and pause a queue when something goes wrong. Connect it with a project-scoped secret API key (starts with `tr_`) — the key determines which environment the runs, schedules, and queues belong to. This makes Sim a natural control plane for the background jobs that power your product. +{/* MANUAL-CONTENT-END */} + + +## Usage Instructions + +Integrate Trigger.dev into the workflow. Trigger and batch trigger background tasks with a JSON payload, retrieve and list runs, cancel, replay, or reschedule runs, manage cron schedules, environment variables, and queues. + + + +## Actions + +### `trigger_dev_trigger_task` + +Trigger a Trigger.dev task by its identifier with an optional JSON payload. Returns the ID of the created run. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `taskIdentifier` | string | Yes | Identifier of the task to trigger \(e.g., "send-welcome-email"\) | +| `payload` | json | No | JSON payload passed to the task run. Example: \{"userId": "user_123"\} | +| `idempotencyKey` | string | No | Idempotency key that ensures the task is only triggered once per key | +| `queue` | string | No | Name of the queue to run the task on | +| `concurrencyKey` | string | No | Key that scopes the queue concurrency limit \(e.g., a user ID\) | +| `delay` | string | No | Delay before the run executes, as a duration \("30m", "1h", "2d"\) or an ISO 8601 date | +| `ttl` | string | No | Time-to-live before an unstarted run expires, as a duration \("1h42m"\) or seconds | +| `machine` | string | No | Machine preset for the run: micro, small-1x, small-2x, medium-1x, medium-2x, large-1x, or large-2x | +| `tags` | string | No | Comma-separated tags to attach to the run \(max 10, each under 128 characters\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | ID of the run that was triggered \(starts with run_\) | + +### `trigger_dev_batch_trigger_task` + +Batch trigger a Trigger.dev task with up to 1,000 payloads. All items in the batch run the same task. Returns the batch ID and the created run IDs. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `taskIdentifier` | string | Yes | Identifier of the task to batch trigger \(e.g., "send-welcome-email"\) | +| `items` | json | Yes | JSON array of batch items \(max 1,000\). Each item is an object with a "payload" and optional "options" \(queue, concurrencyKey, idempotencyKey, ttl, delay, tags, machine\). Example: \[\{"payload": \{"userId": "user_1"\}\}, \{"payload": \{"userId": "user_2"\}, "options": \{"delay": "1h"\}\}\] | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `batchId` | string | ID of the batch that was triggered | +| `runIds` | array | IDs of the runs created by the batch | + +### `trigger_dev_get_run` + +Retrieve a Trigger.dev run by its ID, including status, payload, output, attempts, and timing details. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `runId` | string | Yes | ID of the run to retrieve \(starts with run_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | + +### `trigger_dev_list_runs` + +List Trigger.dev runs in the environment of the API key, with optional filters for status, task, version, tags, schedule, and creation time. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `status` | string | No | Comma-separated run statuses to filter by: PENDING_VERSION, DELAYED, QUEUED, EXECUTING, REATTEMPTING, FROZEN, COMPLETED, CANCELED, FAILED, CRASHED, INTERRUPTED, SYSTEM_FAILURE | +| `taskIdentifier` | string | No | Comma-separated task identifiers to filter by | +| `version` | string | No | Comma-separated worker versions to filter by \(e.g., "20240101.1"\) | +| `tag` | string | No | Comma-separated tags to filter by | +| `schedule` | string | No | Schedule ID to filter by \(starts with sched_\) | +| `isTest` | string | No | Filter by test runs: "true" for only test runs, "false" to exclude them | +| `period` | string | No | Only return runs created in the given period \(e.g., "1h", "7d"\) | +| `from` | string | No | Only return runs created on or after this ISO 8601 timestamp | +| `to` | string | No | Only return runs created on or before this ISO 8601 timestamp | +| `pageSize` | number | No | Number of runs per page \(max 100, default 25\) | +| `pageAfter` | string | No | Run ID to start the page after, for forward pagination | +| `pageBefore` | string | No | Run ID to start the page before, for backward pagination | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `runs` | array | Runs matching the filters | +| `pagination` | object | Cursor pagination details | +| ↳ `next` | string | Run ID to start the next page after | +| ↳ `previous` | string | Run ID to start the previous page before | + +### `trigger_dev_cancel_run` + +Cancel an in-progress Trigger.dev run. Has no effect if the run is already completed. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `runId` | string | Yes | ID of the run to cancel \(starts with run_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | ID of the run that was canceled | + +### `trigger_dev_replay_run` + +Replay a Trigger.dev run, creating a new run with the same payload and options as the original. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `runId` | string | Yes | ID of the run to replay \(starts with run_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | ID of the new run created by the replay | + +### `trigger_dev_reschedule_run` + +Reschedule a delayed Trigger.dev run with a new delay. Only valid while the run is in the DELAYED state. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `runId` | string | Yes | ID of the delayed run to reschedule \(starts with run_\) | +| `delay` | string | Yes | New delay for the run, as a duration \("30m", "1h", "2d"\) or an ISO 8601 date to delay until | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | + +### `trigger_dev_update_run_metadata` + +Replace the metadata of a Trigger.dev run with a new JSON object. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `runId` | string | Yes | ID of the run to update \(starts with run_\) | +| `metadata` | json | Yes | JSON object to set as the run metadata. Example: \{"stage": "approved"\} | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `metadata` | json | The updated metadata of the run | + +### `trigger_dev_create_schedule` + +Create an imperative cron schedule that triggers a Trigger.dev task on a recurring basis. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `task` | string | Yes | Identifier of the task to schedule \(e.g., "daily-report"\) | +| `cron` | string | Yes | Cron expression defining when the task runs \(e.g., "0 0 * * *"\) | +| `timezone` | string | No | IANA timezone the cron expression is evaluated in \(e.g., "America/New_York"\). Defaults to UTC | +| `externalId` | string | No | External identifier to associate with the schedule \(e.g., a user ID\) | +| `deduplicationKey` | string | No | Key that prevents duplicate schedules; creating again with the same key updates the existing schedule | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | + +### `trigger_dev_get_schedule` + +Retrieve a Trigger.dev schedule by its ID. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `scheduleId` | string | Yes | ID of the schedule to retrieve \(starts with sched_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | + +### `trigger_dev_list_schedules` + +List Trigger.dev schedules in the project, with page-based pagination. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `page` | number | No | Page number to return \(default 1\) | +| `perPage` | number | No | Number of schedules per page | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `schedules` | array | Schedules in the project | +| ↳ `id` | string | Unique ID of the schedule \(starts with sched_\) | +| ↳ `task` | string | Identifier of the task the schedule triggers | +| ↳ `type` | string | Schedule type \(DECLARATIVE or IMPERATIVE\) | +| ↳ `active` | boolean | Whether the schedule is active | +| ↳ `deduplicationKey` | string | Deduplication key of the schedule | +| ↳ `externalId` | string | External ID associated with the schedule | +| ↳ `cron` | string | Cron expression of the schedule | +| ↳ `cronDescription` | string | Human-readable description of the cron expression | +| ↳ `timezone` | string | IANA timezone of the schedule | +| ↳ `nextRun` | string | ISO timestamp of the next scheduled run | +| ↳ `environments` | array | Environments the schedule runs in | +| ↳ `id` | string | Environment ID | +| ↳ `type` | string | Environment type | +| ↳ `userName` | string | Username for dev environments | +| `pagination` | object | Page-based pagination details | +| ↳ `currentPage` | number | Current page number | +| ↳ `totalPages` | number | Total number of pages | +| ↳ `count` | number | Total number of schedules | + +### `trigger_dev_update_schedule` + +Update an imperative Trigger.dev schedule by its ID, replacing its task, cron expression, timezone, and external ID. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `scheduleId` | string | Yes | ID of the schedule to update \(starts with sched_\) | +| `task` | string | Yes | Identifier of the task the schedule triggers \(e.g., "daily-report"\) | +| `cron` | string | Yes | Cron expression defining when the task runs \(e.g., "0 0 * * *"\) | +| `timezone` | string | No | IANA timezone the cron expression is evaluated in \(e.g., "America/New_York"\). Defaults to UTC | +| `externalId` | string | No | External identifier to associate with the schedule \(e.g., a user ID\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | + +### `trigger_dev_delete_schedule` + +Delete an imperative Trigger.dev schedule by its ID. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `scheduleId` | string | Yes | ID of the schedule to delete \(starts with sched_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `deleted` | boolean | Whether the schedule was deleted | +| `scheduleId` | string | ID of the schedule that was deleted | + +### `trigger_dev_activate_schedule` + +Activate an imperative Trigger.dev schedule so it resumes triggering its task. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `scheduleId` | string | Yes | ID of the schedule to activate \(starts with sched_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | + +### `trigger_dev_deactivate_schedule` + +Deactivate an imperative Trigger.dev schedule so it stops triggering its task. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `scheduleId` | string | Yes | ID of the schedule to deactivate \(starts with sched_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | + +### `trigger_dev_list_env_vars` + +List the environment variables of a Trigger.dev project environment, including their values. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `projectRef` | string | Yes | External ref of the project, from the project settings \(starts with proj_\) | +| `environment` | string | Yes | Environment to list variables for: dev, staging, or prod | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `variables` | array | Environment variables in the project environment | +| ↳ `name` | string | Name of the environment variable | +| ↳ `value` | string | Value of the environment variable | + +### `trigger_dev_create_env_var` + +Create an environment variable in a Trigger.dev project environment. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `projectRef` | string | Yes | External ref of the project, from the project settings \(starts with proj_\) | +| `environment` | string | Yes | Environment to create the variable in: dev, staging, or prod | +| `name` | string | Yes | Name of the environment variable \(e.g., "SLACK_API_KEY"\) | +| `value` | string | Yes | Value of the environment variable | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether the environment variable was created | +| `name` | string | Name of the environment variable that was created | + +### `trigger_dev_get_env_var` + +Retrieve an environment variable from a Trigger.dev project environment. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `projectRef` | string | Yes | External ref of the project, from the project settings \(starts with proj_\) | +| `environment` | string | Yes | Environment to read the variable from: dev, staging, or prod | +| `name` | string | Yes | Name of the environment variable \(e.g., "SLACK_API_KEY"\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `name` | string | Name of the environment variable | +| `value` | string | Value of the environment variable | + +### `trigger_dev_update_env_var` + +Update the value of an environment variable in a Trigger.dev project environment. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `projectRef` | string | Yes | External ref of the project, from the project settings \(starts with proj_\) | +| `environment` | string | Yes | Environment the variable belongs to: dev, staging, or prod | +| `name` | string | Yes | Name of the environment variable to update \(e.g., "SLACK_API_KEY"\) | +| `value` | string | Yes | New value of the environment variable | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether the environment variable was updated | +| `name` | string | Name of the environment variable that was updated | + +### `trigger_dev_delete_env_var` + +Delete an environment variable from a Trigger.dev project environment. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `projectRef` | string | Yes | External ref of the project, from the project settings \(starts with proj_\) | +| `environment` | string | Yes | Environment the variable belongs to: dev, staging, or prod | +| `name` | string | Yes | Name of the environment variable to delete \(e.g., "SLACK_API_KEY"\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether the environment variable was deleted | +| `name` | string | Name of the environment variable that was deleted | + +### `trigger_dev_get_queue` + +Retrieve a Trigger.dev queue by ID, task identifier, or custom queue name, including its running and queued counts. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `queueName` | string | Yes | Queue ID \(starts with queue_\), task identifier, or custom queue name, depending on the queue type | +| `queueType` | string | No | How to interpret the queue name: "id" \(default\) for a queue ID, "task" for a task identifier, or "custom" for a custom queue name | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | + +### `trigger_dev_pause_queue` + +Pause a Trigger.dev queue so no new runs start. Runs that are currently executing continue to completion. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `queueName` | string | Yes | Queue ID \(starts with queue_\), task identifier, or custom queue name, depending on the queue type | +| `queueType` | string | No | How to interpret the queue name: "id" \(default\) for a queue ID, "task" for a task identifier, or "custom" for a custom queue name | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | + +### `trigger_dev_resume_queue` + +Resume a paused Trigger.dev queue so new runs can start again. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `queueName` | string | Yes | Queue ID \(starts with queue_\), task identifier, or custom queue name, depending on the queue type | +| `queueType` | string | No | How to interpret the queue name: "id" \(default\) for a queue ID, "task" for a task identifier, or "custom" for a custom queue name | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | + + diff --git a/apps/sim/blocks/blocks/trigger_dev.ts b/apps/sim/blocks/blocks/trigger_dev.ts new file mode 100644 index 0000000000..9c058c1219 --- /dev/null +++ b/apps/sim/blocks/blocks/trigger_dev.ts @@ -0,0 +1,792 @@ +import { TriggerDevIcon } from '@/components/icons' +import type { BlockConfig, BlockMeta } from '@/blocks/types' +import { AuthMode, IntegrationType } from '@/blocks/types' +import type { TriggerDevResponse } from '@/tools/trigger_dev/types' + +const TASK_IDENTIFIER_OPERATIONS = ['trigger_dev_trigger_task', 'trigger_dev_batch_trigger_task'] +const RUN_ID_OPERATIONS = [ + 'trigger_dev_get_run', + 'trigger_dev_cancel_run', + 'trigger_dev_replay_run', + 'trigger_dev_reschedule_run', + 'trigger_dev_update_run_metadata', +] +const ENV_VAR_OPERATIONS = [ + 'trigger_dev_list_env_vars', + 'trigger_dev_create_env_var', + 'trigger_dev_get_env_var', + 'trigger_dev_update_env_var', + 'trigger_dev_delete_env_var', +] +const ENV_VAR_NAME_OPERATIONS = [ + 'trigger_dev_create_env_var', + 'trigger_dev_get_env_var', + 'trigger_dev_update_env_var', + 'trigger_dev_delete_env_var', +] +const ENV_VAR_VALUE_OPERATIONS = ['trigger_dev_create_env_var', 'trigger_dev_update_env_var'] +const QUEUE_OPERATIONS = [ + 'trigger_dev_get_queue', + 'trigger_dev_pause_queue', + 'trigger_dev_resume_queue', +] +const SCHEDULE_ID_OPERATIONS = [ + 'trigger_dev_get_schedule', + 'trigger_dev_update_schedule', + 'trigger_dev_delete_schedule', + 'trigger_dev_activate_schedule', + 'trigger_dev_deactivate_schedule', +] +const SCHEDULE_DEFINITION_OPERATIONS = [ + 'trigger_dev_create_schedule', + 'trigger_dev_update_schedule', +] + +export const TriggerDevBlock: BlockConfig = { + type: 'trigger_dev', + name: 'Trigger.dev', + description: 'Trigger tasks and manage runs and schedules', + authMode: AuthMode.ApiKey, + longDescription: + 'Integrate Trigger.dev into the workflow. Trigger and batch trigger background tasks with a JSON payload, retrieve and list runs, cancel, replay, or reschedule runs, manage cron schedules, environment variables, and queues.', + docsLink: 'https://docs.sim.ai/integrations/trigger_dev', + category: 'tools', + integrationType: IntegrationType.DevOps, + bgColor: '#000000', + icon: TriggerDevIcon, + + subBlocks: [ + { + id: 'operation', + title: 'Operation', + type: 'dropdown', + options: [ + { label: 'Trigger Task', id: 'trigger_dev_trigger_task' }, + { label: 'Batch Trigger Task', id: 'trigger_dev_batch_trigger_task' }, + { label: 'Get Run', id: 'trigger_dev_get_run' }, + { label: 'List Runs', id: 'trigger_dev_list_runs' }, + { label: 'Cancel Run', id: 'trigger_dev_cancel_run' }, + { label: 'Replay Run', id: 'trigger_dev_replay_run' }, + { label: 'Reschedule Run', id: 'trigger_dev_reschedule_run' }, + { label: 'Update Run Metadata', id: 'trigger_dev_update_run_metadata' }, + { label: 'Create Schedule', id: 'trigger_dev_create_schedule' }, + { label: 'Get Schedule', id: 'trigger_dev_get_schedule' }, + { label: 'List Schedules', id: 'trigger_dev_list_schedules' }, + { label: 'Update Schedule', id: 'trigger_dev_update_schedule' }, + { label: 'Delete Schedule', id: 'trigger_dev_delete_schedule' }, + { label: 'Activate Schedule', id: 'trigger_dev_activate_schedule' }, + { label: 'Deactivate Schedule', id: 'trigger_dev_deactivate_schedule' }, + { label: 'List Env Vars', id: 'trigger_dev_list_env_vars' }, + { label: 'Create Env Var', id: 'trigger_dev_create_env_var' }, + { label: 'Get Env Var', id: 'trigger_dev_get_env_var' }, + { label: 'Update Env Var', id: 'trigger_dev_update_env_var' }, + { label: 'Delete Env Var', id: 'trigger_dev_delete_env_var' }, + { label: 'Get Queue', id: 'trigger_dev_get_queue' }, + { label: 'Pause Queue', id: 'trigger_dev_pause_queue' }, + { label: 'Resume Queue', id: 'trigger_dev_resume_queue' }, + ], + value: () => 'trigger_dev_trigger_task', + }, + { + id: 'apiKey', + title: 'Secret API Key', + type: 'short-input', + password: true, + placeholder: 'Enter your Trigger.dev secret API key (tr_...)', + required: true, + }, + // Trigger Task fields + { + id: 'taskIdentifier', + title: 'Task Identifier', + type: 'short-input', + placeholder: 'e.g., send-welcome-email', + condition: { field: 'operation', value: TASK_IDENTIFIER_OPERATIONS }, + required: { field: 'operation', value: TASK_IDENTIFIER_OPERATIONS }, + }, + { + id: 'payload', + title: 'Payload', + type: 'code', + language: 'json', + placeholder: '{\n "userId": "user_123"\n}', + condition: { field: 'operation', value: 'trigger_dev_trigger_task' }, + wandConfig: { + enabled: true, + prompt: `Generate a JSON payload for a Trigger.dev task based on the user's description. +The payload is passed to the task's run function and can include any valid JSON. + +Current input: {context} + +Examples: +- "send a welcome email to user 123" -> +{"userId": "user_123", "template": "welcome"} + +- "process order 456 with priority shipping" -> +{"orderId": "order_456", "shipping": "priority"} + +Return ONLY the valid JSON object - no explanations, no markdown.`, + placeholder: 'Describe the payload you need...', + generationType: 'json-object', + }, + }, + { + id: 'idempotencyKey', + title: 'Idempotency Key', + type: 'short-input', + placeholder: 'Unique key to deduplicate triggers', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_trigger_task' }, + }, + { + id: 'queue', + title: 'Queue', + type: 'short-input', + placeholder: 'Queue name to run the task on', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_trigger_task' }, + }, + { + id: 'concurrencyKey', + title: 'Concurrency Key', + type: 'short-input', + placeholder: 'Key to scope the concurrency limit (e.g., a user ID)', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_trigger_task' }, + }, + { + id: 'delay', + title: 'Delay', + type: 'short-input', + placeholder: 'e.g., 30m, 1h, or an ISO 8601 date', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_trigger_task' }, + }, + { + id: 'ttl', + title: 'TTL', + type: 'short-input', + placeholder: 'e.g., 1h42m, or seconds', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_trigger_task' }, + }, + { + id: 'machine', + title: 'Machine', + type: 'dropdown', + options: [ + { label: 'Default', id: '' }, + { label: 'Micro', id: 'micro' }, + { label: 'Small 1x', id: 'small-1x' }, + { label: 'Small 2x', id: 'small-2x' }, + { label: 'Medium 1x', id: 'medium-1x' }, + { label: 'Medium 2x', id: 'medium-2x' }, + { label: 'Large 1x', id: 'large-1x' }, + { label: 'Large 2x', id: 'large-2x' }, + ], + value: () => '', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_trigger_task' }, + }, + { + id: 'tags', + title: 'Tags', + type: 'short-input', + placeholder: 'user_123, org_456 (comma-separated, max 10)', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_trigger_task' }, + }, + // Batch Trigger Task fields + { + id: 'items', + title: 'Batch Items', + type: 'code', + language: 'json', + placeholder: + '[\n { "payload": { "userId": "user_1" } },\n { "payload": { "userId": "user_2" }, "options": { "delay": "1h" } }\n]', + condition: { field: 'operation', value: 'trigger_dev_batch_trigger_task' }, + required: { field: 'operation', value: 'trigger_dev_batch_trigger_task' }, + wandConfig: { + enabled: true, + prompt: `Generate a JSON array of batch items for a Trigger.dev task based on the user's description. +Each item is an object with a "payload" (any valid JSON) and optional "options" (queue, concurrencyKey, idempotencyKey, ttl, delay, tags, machine). + +Current input: {context} + +Examples: +- "send welcome emails to users 1 and 2" -> +[{"payload": {"userId": "user_1"}}, {"payload": {"userId": "user_2"}}] + +- "process orders 10 and 11, the second after an hour" -> +[{"payload": {"orderId": "order_10"}}, {"payload": {"orderId": "order_11"}, "options": {"delay": "1h"}}] + +Return ONLY the valid JSON array - no explanations, no markdown.`, + placeholder: 'Describe the batch items you need...', + generationType: 'json-object', + }, + }, + // Run fields + { + id: 'runId', + title: 'Run ID', + type: 'short-input', + placeholder: 'e.g., run_abc123', + condition: { field: 'operation', value: RUN_ID_OPERATIONS }, + required: { field: 'operation', value: RUN_ID_OPERATIONS }, + }, + { + id: 'rescheduleDelay', + title: 'Delay', + type: 'short-input', + placeholder: 'e.g., 30m, 1h, or an ISO 8601 date', + condition: { field: 'operation', value: 'trigger_dev_reschedule_run' }, + required: { field: 'operation', value: 'trigger_dev_reschedule_run' }, + }, + { + id: 'metadata', + title: 'Metadata', + type: 'code', + language: 'json', + placeholder: '{\n "stage": "approved"\n}', + condition: { field: 'operation', value: 'trigger_dev_update_run_metadata' }, + required: { field: 'operation', value: 'trigger_dev_update_run_metadata' }, + wandConfig: { + enabled: true, + prompt: `Generate a JSON metadata object for a Trigger.dev run based on the user's description. +The metadata replaces the run's existing metadata and can include any valid JSON. + +Current input: {context} + +Example: +- "mark the run as approved by ops" -> +{"stage": "approved", "approvedBy": "ops"} + +Return ONLY the valid JSON object - no explanations, no markdown.`, + placeholder: 'Describe the metadata you need...', + generationType: 'json-object', + }, + }, + // List Runs filters + { + id: 'status', + title: 'Status Filter', + type: 'short-input', + placeholder: 'COMPLETED, FAILED (comma-separated)', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + }, + { + id: 'filterTaskIdentifier', + title: 'Task Filter', + type: 'short-input', + placeholder: 'send-welcome-email, daily-report (comma-separated)', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + }, + { + id: 'period', + title: 'Created Within', + type: 'short-input', + placeholder: 'e.g., 1h, 7d', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + }, + { + id: 'from', + title: 'Created From', + type: 'short-input', + placeholder: '2024-01-01T00:00:00.000Z', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + wandConfig: { + enabled: true, + prompt: `Generate an ISO 8601 timestamp based on the user's description. +Use the current date context to resolve relative references like "yesterday" or "last week". + +Current input: {context} + +Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, + placeholder: 'Describe the start of the time range (e.g., "yesterday", "last week")...', + generationType: 'timestamp', + }, + }, + { + id: 'to', + title: 'Created To', + type: 'short-input', + placeholder: '2024-12-31T23:59:59.999Z', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + wandConfig: { + enabled: true, + prompt: `Generate an ISO 8601 timestamp based on the user's description. +Use the current date context to resolve relative references like "today" or "an hour ago". + +Current input: {context} + +Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, + placeholder: 'Describe the end of the time range (e.g., "now", "end of today")...', + generationType: 'timestamp', + }, + }, + { + id: 'version', + title: 'Version Filter', + type: 'short-input', + placeholder: '20240101.1 (comma-separated)', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + }, + { + id: 'tag', + title: 'Tag Filter', + type: 'short-input', + placeholder: 'user_123, org_456 (comma-separated)', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + }, + { + id: 'schedule', + title: 'Schedule Filter', + type: 'short-input', + placeholder: 'e.g., sched_abc123', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + }, + { + id: 'isTest', + title: 'Test Runs', + type: 'dropdown', + options: [ + { label: 'All Runs', id: '' }, + { label: 'Only Test Runs', id: 'true' }, + { label: 'Exclude Test Runs', id: 'false' }, + ], + value: () => '', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + }, + { + id: 'pageSize', + title: 'Page Size', + type: 'short-input', + placeholder: 'Runs per page (max 100, default 25)', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + }, + { + id: 'pageAfter', + title: 'Page After', + type: 'short-input', + placeholder: 'Run ID to start the page after', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + }, + { + id: 'pageBefore', + title: 'Page Before', + type: 'short-input', + placeholder: 'Run ID to start the page before', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + }, + // Schedule fields + { + id: 'scheduleId', + title: 'Schedule ID', + type: 'short-input', + placeholder: 'e.g., sched_abc123', + condition: { field: 'operation', value: SCHEDULE_ID_OPERATIONS }, + required: { field: 'operation', value: SCHEDULE_ID_OPERATIONS }, + }, + { + id: 'task', + title: 'Task Identifier', + type: 'short-input', + placeholder: 'e.g., daily-report', + condition: { field: 'operation', value: SCHEDULE_DEFINITION_OPERATIONS }, + required: { field: 'operation', value: SCHEDULE_DEFINITION_OPERATIONS }, + }, + { + id: 'cron', + title: 'Cron Expression', + type: 'short-input', + placeholder: 'e.g., 0 0 * * *', + condition: { field: 'operation', value: SCHEDULE_DEFINITION_OPERATIONS }, + required: { field: 'operation', value: SCHEDULE_DEFINITION_OPERATIONS }, + }, + { + id: 'timezone', + title: 'Timezone', + type: 'short-input', + placeholder: 'e.g., America/New_York (default UTC)', + mode: 'advanced', + condition: { field: 'operation', value: SCHEDULE_DEFINITION_OPERATIONS }, + }, + { + id: 'externalId', + title: 'External ID', + type: 'short-input', + placeholder: 'e.g., a user or org ID to associate', + mode: 'advanced', + condition: { field: 'operation', value: SCHEDULE_DEFINITION_OPERATIONS }, + }, + { + id: 'deduplicationKey', + title: 'Deduplication Key', + type: 'short-input', + placeholder: 'Key to prevent duplicate schedules', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_create_schedule' }, + }, + // List Schedules pagination + { + id: 'page', + title: 'Page', + type: 'short-input', + placeholder: 'Page number (default 1)', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_schedules' }, + }, + { + id: 'perPage', + title: 'Per Page', + type: 'short-input', + placeholder: 'Schedules per page', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_schedules' }, + }, + // Environment variable fields + { + id: 'projectRef', + title: 'Project Ref', + type: 'short-input', + placeholder: 'e.g., proj_yubjwjsfkxnylobaqvqz', + condition: { field: 'operation', value: ENV_VAR_OPERATIONS }, + required: { field: 'operation', value: ENV_VAR_OPERATIONS }, + }, + { + id: 'environment', + title: 'Environment', + type: 'dropdown', + options: [ + { label: 'Dev', id: 'dev' }, + { label: 'Staging', id: 'staging' }, + { label: 'Prod', id: 'prod' }, + ], + value: () => 'dev', + condition: { field: 'operation', value: ENV_VAR_OPERATIONS }, + required: { field: 'operation', value: ENV_VAR_OPERATIONS }, + }, + { + id: 'name', + title: 'Variable Name', + type: 'short-input', + placeholder: 'e.g., SLACK_API_KEY', + condition: { field: 'operation', value: ENV_VAR_NAME_OPERATIONS }, + required: { field: 'operation', value: ENV_VAR_NAME_OPERATIONS }, + }, + { + id: 'value', + title: 'Variable Value', + type: 'short-input', + password: true, + placeholder: 'Value of the environment variable', + condition: { field: 'operation', value: ENV_VAR_VALUE_OPERATIONS }, + required: { field: 'operation', value: ENV_VAR_VALUE_OPERATIONS }, + }, + // Queue fields + { + id: 'queueName', + title: 'Queue', + type: 'short-input', + placeholder: 'Queue ID, task identifier, or custom queue name', + condition: { field: 'operation', value: QUEUE_OPERATIONS }, + required: { field: 'operation', value: QUEUE_OPERATIONS }, + }, + { + id: 'queueType', + title: 'Queue Type', + type: 'dropdown', + options: [ + { label: 'Queue ID', id: 'id' }, + { label: 'Task Identifier', id: 'task' }, + { label: 'Custom Queue Name', id: 'custom' }, + ], + value: () => 'id', + condition: { field: 'operation', value: QUEUE_OPERATIONS }, + }, + ], + + tools: { + access: [ + 'trigger_dev_trigger_task', + 'trigger_dev_batch_trigger_task', + 'trigger_dev_get_run', + 'trigger_dev_list_runs', + 'trigger_dev_cancel_run', + 'trigger_dev_replay_run', + 'trigger_dev_reschedule_run', + 'trigger_dev_update_run_metadata', + 'trigger_dev_create_schedule', + 'trigger_dev_get_schedule', + 'trigger_dev_list_schedules', + 'trigger_dev_update_schedule', + 'trigger_dev_delete_schedule', + 'trigger_dev_activate_schedule', + 'trigger_dev_deactivate_schedule', + 'trigger_dev_list_env_vars', + 'trigger_dev_create_env_var', + 'trigger_dev_get_env_var', + 'trigger_dev_update_env_var', + 'trigger_dev_delete_env_var', + 'trigger_dev_get_queue', + 'trigger_dev_pause_queue', + 'trigger_dev_resume_queue', + ], + config: { + tool: (params) => params.operation, + params: (params) => { + const result: Record = {} + if (params.filterTaskIdentifier) result.taskIdentifier = params.filterTaskIdentifier + if (params.rescheduleDelay) result.delay = params.rescheduleDelay + if (params.pageSize) result.pageSize = Number(params.pageSize) + if (params.page) result.page = Number(params.page) + if (params.perPage) result.perPage = Number(params.perPage) + return result + }, + }, + }, + + inputs: { + operation: { type: 'string', description: 'Operation to perform' }, + apiKey: { type: 'string', description: 'Trigger.dev secret API key' }, + // Trigger Task + taskIdentifier: { type: 'string', description: 'Identifier of the task to trigger' }, + payload: { type: 'json', description: 'JSON payload passed to the task run' }, + idempotencyKey: { type: 'string', description: 'Idempotency key to deduplicate triggers' }, + queue: { type: 'string', description: 'Queue name to run the task on' }, + concurrencyKey: { type: 'string', description: 'Key to scope the concurrency limit' }, + delay: { type: 'string', description: 'Delay before the run executes' }, + ttl: { type: 'string', description: 'Time-to-live before an unstarted run expires' }, + machine: { type: 'string', description: 'Machine preset for the run' }, + tags: { type: 'string', description: 'Comma-separated tags to attach to the run' }, + // Batch Trigger Task + items: { + type: 'json', + description: 'JSON array of batch items, each with a payload and optional options', + }, + // Runs + runId: { type: 'string', description: 'Run ID (starts with run_)' }, + rescheduleDelay: { type: 'string', description: 'New delay for a delayed run' }, + metadata: { type: 'json', description: 'JSON object to set as the run metadata' }, + status: { type: 'string', description: 'Comma-separated run statuses to filter by' }, + filterTaskIdentifier: { + type: 'string', + description: 'Comma-separated task identifiers to filter by', + }, + period: { type: 'string', description: 'Only return runs created in the given period' }, + from: { type: 'string', description: 'Only return runs created on or after this timestamp' }, + to: { type: 'string', description: 'Only return runs created on or before this timestamp' }, + version: { type: 'string', description: 'Comma-separated worker versions to filter by' }, + tag: { type: 'string', description: 'Comma-separated tags to filter by' }, + schedule: { type: 'string', description: 'Schedule ID to filter runs by' }, + isTest: { type: 'string', description: 'Filter by test runs ("true" or "false")' }, + pageSize: { type: 'number', description: 'Number of runs per page (max 100)' }, + pageAfter: { type: 'string', description: 'Run ID to start the page after' }, + pageBefore: { type: 'string', description: 'Run ID to start the page before' }, + // Schedules + scheduleId: { type: 'string', description: 'Schedule ID (starts with sched_)' }, + task: { type: 'string', description: 'Identifier of the task the schedule triggers' }, + cron: { type: 'string', description: 'Cron expression defining when the task runs' }, + timezone: { type: 'string', description: 'IANA timezone for the cron expression' }, + externalId: { type: 'string', description: 'External identifier for the schedule' }, + deduplicationKey: { type: 'string', description: 'Key to prevent duplicate schedules' }, + page: { type: 'number', description: 'Page number for listing schedules' }, + perPage: { type: 'number', description: 'Number of schedules per page' }, + // Environment variables + projectRef: { type: 'string', description: 'Project ref (starts with proj_)' }, + environment: { type: 'string', description: 'Project environment (dev, staging, or prod)' }, + name: { type: 'string', description: 'Name of the environment variable' }, + value: { type: 'string', description: 'Value of the environment variable' }, + // Queues + queueName: { + type: 'string', + description: 'Queue ID, task identifier, or custom queue name', + }, + queueType: { + type: 'string', + description: 'How to interpret the queue name (id, task, or custom)', + }, + }, + + outputs: { + // Trigger Task / Cancel Run / Replay Run / schedule operations + id: { type: 'string', description: 'Run, schedule, or queue ID' }, + // Batch Trigger Task + batchId: { type: 'string', description: 'Batch ID (Batch Trigger Task)' }, + runIds: { type: 'json', description: 'IDs of the created runs (Batch Trigger Task)' }, + // Get Run + status: { type: 'string', description: 'Run status (Get Run)' }, + taskIdentifier: { type: 'string', description: 'Task identifier of the run (Get Run)' }, + createdAt: { type: 'string', description: 'When the run was created (Get Run)' }, + startedAt: { type: 'string', description: 'When the run started (Get Run)' }, + finishedAt: { type: 'string', description: 'When the run finished (Get Run)' }, + durationMs: { type: 'number', description: 'Compute duration in milliseconds (Get Run)' }, + costInCents: { type: 'number', description: 'Compute cost in cents (Get Run)' }, + isTest: { type: 'boolean', description: 'Whether the run is a test run (Get Run)' }, + tags: { type: 'json', description: 'Tags attached to the run (Get Run)' }, + payload: { type: 'json', description: 'Payload the run was triggered with (Get Run)' }, + output: { type: 'json', description: 'Output returned by the run (Get Run)' }, + attempts: { type: 'json', description: 'Attempts made for the run (Get Run)' }, + metadata: { type: 'json', description: 'Run metadata (Get Run, Update Run Metadata)' }, + // List Runs / List Schedules + runs: { type: 'json', description: 'Runs matching the filters (List Runs)' }, + schedules: { type: 'json', description: 'Schedules in the project (List Schedules)' }, + pagination: { type: 'json', description: 'Pagination details (list operations)' }, + // Schedules + task: { type: 'string', description: 'Task the schedule triggers (schedule operations)' }, + active: { + type: 'boolean', + description: 'Whether the schedule is active (schedule operations)', + }, + cron: { type: 'string', description: 'Cron expression (schedule operations)' }, + cronDescription: { + type: 'string', + description: 'Human-readable cron description (schedule operations)', + }, + timezone: { type: 'string', description: 'Timezone of the schedule (schedule operations)' }, + nextRun: { type: 'string', description: 'Next scheduled run time (schedule operations)' }, + environments: { + type: 'json', + description: 'Environments the schedule runs in (schedule operations)', + }, + deleted: { type: 'boolean', description: 'Whether the schedule was deleted (Delete Schedule)' }, + // Environment variables + variables: { + type: 'json', + description: 'Environment variables in the project environment (List Env Vars)', + }, + name: { + type: 'string', + description: 'Environment variable or queue name (env var and queue operations)', + }, + value: { type: 'string', description: 'Value of the environment variable (Get Env Var)' }, + success: { + type: 'boolean', + description: 'Whether the env var operation succeeded (Create/Update/Delete Env Var)', + }, + // Queues + running: { type: 'number', description: 'Runs currently executing (queue operations)' }, + queued: { type: 'number', description: 'Runs waiting in the queue (queue operations)' }, + paused: { type: 'boolean', description: 'Whether the queue is paused (queue operations)' }, + concurrencyLimit: { + type: 'number', + description: 'Concurrency limit of the queue (queue operations)', + }, + concurrency: { + type: 'json', + description: 'Concurrency details of the queue (queue operations)', + }, + }, +} + +export const TriggerDevBlockMeta = { + tags: ['automation', 'ci-cd', 'monitoring'], + templates: [ + { + icon: TriggerDevIcon, + title: 'Trigger.dev job kickoff', + prompt: + 'Build a workflow that receives an event from another system, triggers the matching Trigger.dev background task with a JSON payload, and returns the run ID for tracking.', + modules: ['agent', 'workflows'], + category: 'engineering', + tags: ['automation'], + }, + { + icon: TriggerDevIcon, + title: 'Trigger.dev failed-run monitor', + prompt: + 'Build a scheduled workflow that lists Trigger.dev runs with status FAILED or CRASHED from the last hour, summarizes the failures per task, and posts a digest to the engineering Slack channel.', + modules: ['scheduled', 'agent', 'workflows'], + category: 'engineering', + tags: ['monitoring', 'devops'], + alsoIntegrations: ['slack'], + }, + { + icon: TriggerDevIcon, + title: 'Trigger.dev auto-retry agent', + prompt: + 'Create an agent that lists failed Trigger.dev runs, inspects each run error to decide whether the failure looks transient, and replays the runs that are safe to retry.', + modules: ['agent', 'workflows'], + category: 'engineering', + tags: ['automation', 'devops'], + }, + { + icon: TriggerDevIcon, + title: 'Trigger.dev run-output collector', + prompt: + 'Build a workflow that triggers a Trigger.dev task, polls Get Run until the run completes, and writes the run output and timing details into a results table.', + modules: ['tables', 'agent', 'workflows'], + category: 'operations', + tags: ['automation', 'sync'], + }, + { + icon: TriggerDevIcon, + title: 'Trigger.dev schedule manager', + prompt: + 'Create an agent that manages Trigger.dev cron schedules per customer — creating a schedule with the customer ID as external ID on signup, and deactivating or deleting it on churn.', + modules: ['agent', 'workflows'], + category: 'operations', + tags: ['automation', 'scheduling'], + }, + { + icon: TriggerDevIcon, + title: 'Trigger.dev stuck-run janitor', + prompt: + 'Build a scheduled workflow that lists Trigger.dev runs still executing past their expected duration, cancels the stuck runs, and posts the canceled run IDs to Slack.', + modules: ['scheduled', 'agent', 'workflows'], + category: 'engineering', + tags: ['monitoring', 'devops'], + alsoIntegrations: ['slack'], + }, + { + icon: TriggerDevIcon, + title: 'Trigger.dev compute cost reporter', + prompt: + 'Create a weekly scheduled workflow that lists Trigger.dev runs from the past week, aggregates compute cost and duration per task, and emails a cost report to the team.', + modules: ['scheduled', 'agent', 'workflows'], + category: 'operations', + tags: ['reporting', 'devops'], + alsoIntegrations: ['gmail'], + }, + ], + skills: [ + { + name: 'trigger-task-and-wait', + description: + 'Trigger a Trigger.dev background task with a payload and poll until the run completes, returning its output.', + content: + '# Trigger Task and Wait\n\nKick off a Trigger.dev background task and collect its result.\n\n## Steps\n1. Use the Trigger Task operation with the task identifier and a JSON payload. Set an idempotency key when the same event might arrive twice.\n2. Poll the Get Run operation with the returned run ID until the status is COMPLETED, FAILED, CANCELED, CRASHED, or another terminal state.\n3. On COMPLETED, read the run output. On failure states, read the attempts to surface the error message.\n\n## Output\nReturn the run ID, final status, duration, and the run output — or the error details if the run did not complete.', + }, + { + name: 'monitor-failed-runs', + description: + 'List recent failed Trigger.dev runs, group them by task, and produce a failure digest. Use for run health monitoring.', + content: + '# Monitor Failed Runs\n\nReview recent Trigger.dev failures and summarize what needs attention.\n\n## Steps\n1. Use the List Runs operation with a status filter of FAILED, CRASHED, SYSTEM_FAILURE and a created-within period (e.g., 1h or 1d).\n2. Group the runs by task identifier and count failures per task.\n3. For the most affected tasks, fetch a representative run with Get Run and pull the attempt error message.\n\n## Output\nReport failures per task with counts, representative error messages, and run IDs. If nothing failed, say so briefly.', + }, + { + name: 'replay-transient-failures', + description: + 'Inspect failed Trigger.dev runs and replay the ones whose errors look transient (timeouts, rate limits, network).', + content: + '# Replay Transient Failures\n\nRetry failed Trigger.dev runs that are safe to run again.\n\n## Steps\n1. List runs with status FAILED for the relevant period and task filter.\n2. For each run, use Get Run and inspect the attempt errors. Treat timeouts, rate limits, and network errors as transient; treat validation and logic errors as permanent.\n3. Use the Replay Run operation on transient failures only, and record the new run IDs.\n\n## Output\nList the replayed runs (old run ID to new run ID) and the runs skipped as permanent failures, with the reason for each decision.', + }, + { + name: 'manage-cron-schedules', + description: + 'Create, update, activate, deactivate, or delete Trigger.dev cron schedules for a task, scoped by external ID.', + content: + '# Manage Cron Schedules\n\nKeep Trigger.dev schedules in sync with the desired cadence.\n\n## Steps\n1. Use List Schedules to find existing schedules for the task, matching on external ID when schedules are per customer or per resource.\n2. Create a schedule with the task identifier, cron expression, timezone, and a deduplication key so reruns do not create duplicates.\n3. Update the cron or timezone on an existing schedule by ID, and use Activate or Deactivate to pause and resume without deleting.\n4. Delete schedules that are no longer needed.\n\n## Output\nReport the schedule ID, task, cron expression, timezone, active state, and next run time after the change.', + }, + ], +} as const satisfies BlockMeta diff --git a/apps/sim/blocks/registry.ts b/apps/sim/blocks/registry.ts index 2703ead3bd..db864ceff6 100644 --- a/apps/sim/blocks/registry.ts +++ b/apps/sim/blocks/registry.ts @@ -278,6 +278,7 @@ import { ThinkingBlock } from '@/blocks/blocks/thinking' import { TinybirdBlock, TinybirdBlockMeta } from '@/blocks/blocks/tinybird' import { TranslateBlock } from '@/blocks/blocks/translate' import { TrelloBlock, TrelloBlockMeta } from '@/blocks/blocks/trello' +import { TriggerDevBlock, TriggerDevBlockMeta } from '@/blocks/blocks/trigger_dev' import { TtsBlock } from '@/blocks/blocks/tts' import { TwilioSMSBlock, TwilioSMSBlockMeta } from '@/blocks/blocks/twilio' import { TwilioVoiceBlock, TwilioVoiceBlockMeta } from '@/blocks/blocks/twilio_voice' @@ -571,6 +572,7 @@ const BLOCK_REGISTRY: Record = { tinybird: TinybirdBlock, translate: TranslateBlock, trello: TrelloBlock, + trigger_dev: TriggerDevBlock, tts: TtsBlock, twilio_sms: TwilioSMSBlock, twilio_voice: TwilioVoiceBlock, @@ -811,6 +813,7 @@ const BLOCK_META_REGISTRY: Record = { textract: TextractBlockMeta, tinybird: TinybirdBlockMeta, trello: TrelloBlockMeta, + trigger_dev: TriggerDevBlockMeta, twilio_sms: TwilioSMSBlockMeta, twilio_voice: TwilioVoiceBlockMeta, typeform: TypeformBlockMeta, diff --git a/apps/sim/components/icons.tsx b/apps/sim/components/icons.tsx index 6f5df2b76b..acefa964ca 100644 --- a/apps/sim/components/icons.tsx +++ b/apps/sim/components/icons.tsx @@ -7602,3 +7602,32 @@ export function WizaIcon(props: SVGProps) { ) } + +export function TriggerDevIcon(props: SVGProps) { + const id = useId() + const gradientId = `triggerdev_paint0_${id}` + + return ( + + + + + + + + + + ) +} diff --git a/apps/sim/lib/integrations/icon-mapping.ts b/apps/sim/lib/integrations/icon-mapping.ts index b7d26906bb..f47a562448 100644 --- a/apps/sim/lib/integrations/icon-mapping.ts +++ b/apps/sim/lib/integrations/icon-mapping.ts @@ -196,6 +196,7 @@ import { TextractIcon, TinybirdIcon, TrelloIcon, + TriggerDevIcon, TwilioIcon, TypeformIcon, UpstashIcon, @@ -412,6 +413,7 @@ export const blockTypeToIconMap: Record = { textract_v2: TextractIcon, tinybird: TinybirdIcon, trello: TrelloIcon, + trigger_dev: TriggerDevIcon, twilio_sms: TwilioIcon, twilio_voice: TwilioIcon, typeform: TypeformIcon, diff --git a/apps/sim/lib/integrations/integrations.json b/apps/sim/lib/integrations/integrations.json index b6b6beeaf4..05753a73a8 100644 --- a/apps/sim/lib/integrations/integrations.json +++ b/apps/sim/lib/integrations/integrations.json @@ -14808,6 +14808,117 @@ "integrationType": "productivity", "tags": ["project-management", "ticketing"] }, + { + "type": "trigger_dev", + "slug": "trigger-dev", + "name": "Trigger.dev", + "description": "Trigger tasks and manage runs and schedules", + "longDescription": "Integrate Trigger.dev into the workflow. Trigger and batch trigger background tasks with a JSON payload, retrieve and list runs, cancel, replay, or reschedule runs, manage cron schedules, environment variables, and queues.", + "bgColor": "#000000", + "iconName": "TriggerDevIcon", + "docsUrl": "https://docs.sim.ai/integrations/trigger_dev", + "operations": [ + { + "name": "Trigger Task", + "description": "Trigger a Trigger.dev task by its identifier with an optional JSON payload. Returns the ID of the created run." + }, + { + "name": "Batch Trigger Task", + "description": "Batch trigger a Trigger.dev task with up to 1,000 payloads. All items in the batch run the same task. Returns the batch ID and the created run IDs." + }, + { + "name": "Get Run", + "description": "Retrieve a Trigger.dev run by its ID, including status, payload, output, attempts, and timing details." + }, + { + "name": "List Runs", + "description": "List Trigger.dev runs in the environment of the API key, with optional filters for status, task, version, tags, schedule, and creation time." + }, + { + "name": "Cancel Run", + "description": "Cancel an in-progress Trigger.dev run. Has no effect if the run is already completed." + }, + { + "name": "Replay Run", + "description": "Replay a Trigger.dev run, creating a new run with the same payload and options as the original." + }, + { + "name": "Reschedule Run", + "description": "Reschedule a delayed Trigger.dev run with a new delay. Only valid while the run is in the DELAYED state." + }, + { + "name": "Update Run Metadata", + "description": "Replace the metadata of a Trigger.dev run with a new JSON object." + }, + { + "name": "Create Schedule", + "description": "Create an imperative cron schedule that triggers a Trigger.dev task on a recurring basis." + }, + { + "name": "Get Schedule", + "description": "Retrieve a Trigger.dev schedule by its ID." + }, + { + "name": "List Schedules", + "description": "List Trigger.dev schedules in the project, with page-based pagination." + }, + { + "name": "Update Schedule", + "description": "Update an imperative Trigger.dev schedule by its ID, replacing its task, cron expression, timezone, and external ID." + }, + { + "name": "Delete Schedule", + "description": "Delete an imperative Trigger.dev schedule by its ID." + }, + { + "name": "Activate Schedule", + "description": "Activate an imperative Trigger.dev schedule so it resumes triggering its task." + }, + { + "name": "Deactivate Schedule", + "description": "Deactivate an imperative Trigger.dev schedule so it stops triggering its task." + }, + { + "name": "List Env Vars", + "description": "List the environment variables of a Trigger.dev project environment, including their values." + }, + { + "name": "Create Env Var", + "description": "Create an environment variable in a Trigger.dev project environment." + }, + { + "name": "Get Env Var", + "description": "Retrieve an environment variable from a Trigger.dev project environment." + }, + { + "name": "Update Env Var", + "description": "Update the value of an environment variable in a Trigger.dev project environment." + }, + { + "name": "Delete Env Var", + "description": "Delete an environment variable from a Trigger.dev project environment." + }, + { + "name": "Get Queue", + "description": "Retrieve a Trigger.dev queue by ID, task identifier, or custom queue name, including its running and queued counts." + }, + { + "name": "Pause Queue", + "description": "Pause a Trigger.dev queue so no new runs start. Runs that are currently executing continue to completion." + }, + { + "name": "Resume Queue", + "description": "Resume a paused Trigger.dev queue so new runs can start again." + } + ], + "operationCount": 23, + "triggers": [], + "triggerCount": 0, + "authType": "api-key", + "category": "tools", + "integrationType": "devops", + "tags": ["automation", "ci-cd", "monitoring"] + }, { "type": "twilio_sms", "slug": "twilio-sms", diff --git a/apps/sim/tools/registry.ts b/apps/sim/tools/registry.ts index 35572109fb..a61982d468 100644 --- a/apps/sim/tools/registry.ts +++ b/apps/sim/tools/registry.ts @@ -3189,6 +3189,31 @@ import { trelloListListsTool, trelloUpdateCardTool, } from '@/tools/trello' +import { + triggerDevActivateScheduleTool, + triggerDevBatchTriggerTaskTool, + triggerDevCancelRunTool, + triggerDevCreateEnvVarTool, + triggerDevCreateScheduleTool, + triggerDevDeactivateScheduleTool, + triggerDevDeleteEnvVarTool, + triggerDevDeleteScheduleTool, + triggerDevGetEnvVarTool, + triggerDevGetQueueTool, + triggerDevGetRunTool, + triggerDevGetScheduleTool, + triggerDevListEnvVarsTool, + triggerDevListRunsTool, + triggerDevListSchedulesTool, + triggerDevPauseQueueTool, + triggerDevReplayRunTool, + triggerDevRescheduleRunTool, + triggerDevResumeQueueTool, + triggerDevTriggerTaskTool, + triggerDevUpdateEnvVarTool, + triggerDevUpdateRunMetadataTool, + triggerDevUpdateScheduleTool, +} from '@/tools/trigger_dev' import { azureTtsTool, cartesiaTtsTool, @@ -5257,6 +5282,29 @@ export const tools: Record = { trello_update_card: trelloUpdateCardTool, trello_get_actions: trelloGetActionsTool, trello_add_comment: trelloAddCommentTool, + trigger_dev_trigger_task: triggerDevTriggerTaskTool, + trigger_dev_batch_trigger_task: triggerDevBatchTriggerTaskTool, + trigger_dev_get_run: triggerDevGetRunTool, + trigger_dev_list_runs: triggerDevListRunsTool, + trigger_dev_cancel_run: triggerDevCancelRunTool, + trigger_dev_replay_run: triggerDevReplayRunTool, + trigger_dev_reschedule_run: triggerDevRescheduleRunTool, + trigger_dev_update_run_metadata: triggerDevUpdateRunMetadataTool, + trigger_dev_create_schedule: triggerDevCreateScheduleTool, + trigger_dev_get_schedule: triggerDevGetScheduleTool, + trigger_dev_list_schedules: triggerDevListSchedulesTool, + trigger_dev_update_schedule: triggerDevUpdateScheduleTool, + trigger_dev_delete_schedule: triggerDevDeleteScheduleTool, + trigger_dev_activate_schedule: triggerDevActivateScheduleTool, + trigger_dev_deactivate_schedule: triggerDevDeactivateScheduleTool, + trigger_dev_list_env_vars: triggerDevListEnvVarsTool, + trigger_dev_create_env_var: triggerDevCreateEnvVarTool, + trigger_dev_get_env_var: triggerDevGetEnvVarTool, + trigger_dev_update_env_var: triggerDevUpdateEnvVarTool, + trigger_dev_delete_env_var: triggerDevDeleteEnvVarTool, + trigger_dev_get_queue: triggerDevGetQueueTool, + trigger_dev_pause_queue: triggerDevPauseQueueTool, + trigger_dev_resume_queue: triggerDevResumeQueueTool, vercel_list_deployments: vercelListDeploymentsTool, vercel_get_deployment: vercelGetDeploymentTool, vercel_create_deployment: vercelCreateDeploymentTool, diff --git a/apps/sim/tools/trigger_dev/activate_schedule.ts b/apps/sim/tools/trigger_dev/activate_schedule.ts new file mode 100644 index 0000000000..e3b2378b9e --- /dev/null +++ b/apps/sim/tools/trigger_dev/activate_schedule.ts @@ -0,0 +1,53 @@ +import type { + TriggerDevScheduleIdParams, + TriggerDevScheduleResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevSchedule, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_SCHEDULE_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevActivateScheduleTool: ToolConfig< + TriggerDevScheduleIdParams, + TriggerDevScheduleResponse +> = { + id: 'trigger_dev_activate_schedule', + name: 'Trigger.dev Activate Schedule', + description: 'Activate an imperative Trigger.dev schedule so it resumes triggering its task.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + scheduleId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the schedule to activate (starts with sched_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/schedules/${encodeURIComponent(params.scheduleId.trim())}/activate`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevSchedule(data), + } + }, + + outputs: TRIGGER_DEV_SCHEDULE_OUTPUTS, +} diff --git a/apps/sim/tools/trigger_dev/batch_trigger_task.ts b/apps/sim/tools/trigger_dev/batch_trigger_task.ts new file mode 100644 index 0000000000..5b42984407 --- /dev/null +++ b/apps/sim/tools/trigger_dev/batch_trigger_task.ts @@ -0,0 +1,77 @@ +import type { + TriggerDevBatchTriggerTaskParams, + TriggerDevBatchTriggerTaskResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + parseJsonInput, + TRIGGER_DEV_API_BASE, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevBatchTriggerTaskTool: ToolConfig< + TriggerDevBatchTriggerTaskParams, + TriggerDevBatchTriggerTaskResponse +> = { + id: 'trigger_dev_batch_trigger_task', + name: 'Trigger.dev Batch Trigger Task', + description: + 'Batch trigger a Trigger.dev task with up to 1,000 payloads. All items in the batch run the same task. Returns the batch ID and the created run IDs.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + taskIdentifier: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Identifier of the task to batch trigger (e.g., "send-welcome-email")', + }, + items: { + type: 'json', + required: true, + visibility: 'user-or-llm', + description: + 'JSON array of batch items (max 1,000). Each item is an object with a "payload" and optional "options" (queue, concurrencyKey, idempotencyKey, ttl, delay, tags, machine). Example: [{"payload": {"userId": "user_1"}}, {"payload": {"userId": "user_2"}, "options": {"delay": "1h"}}]', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/tasks/${encodeURIComponent(params.taskIdentifier.trim())}/batch`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => { + const items = parseJsonInput(params.items, 'items') + if (!Array.isArray(items)) { + throw new Error('The items parameter must be a JSON array of batch items') + } + return { items } + }, + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + batchId: data.batchId, + runIds: data.runs ?? [], + }, + } + }, + + outputs: { + batchId: { type: 'string', description: 'ID of the batch that was triggered' }, + runIds: { + type: 'array', + description: 'IDs of the runs created by the batch', + items: { type: 'string', description: 'Run ID (starts with run_)' }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/cancel_run.ts b/apps/sim/tools/trigger_dev/cancel_run.ts new file mode 100644 index 0000000000..436ba2e0f3 --- /dev/null +++ b/apps/sim/tools/trigger_dev/cancel_run.ts @@ -0,0 +1,50 @@ +import type { TriggerDevRunActionResponse, TriggerDevRunIdParams } from '@/tools/trigger_dev/types' +import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevCancelRunTool: ToolConfig< + TriggerDevRunIdParams, + TriggerDevRunActionResponse +> = { + id: 'trigger_dev_cancel_run', + name: 'Trigger.dev Cancel Run', + description: + 'Cancel an in-progress Trigger.dev run. Has no effect if the run is already completed.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + runId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the run to cancel (starts with run_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v2/runs/${encodeURIComponent(params.runId.trim())}/cancel`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + id: data.id, + }, + } + }, + + outputs: { + id: { type: 'string', description: 'ID of the run that was canceled' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/create_env_var.ts b/apps/sim/tools/trigger_dev/create_env_var.ts new file mode 100644 index 0000000000..4c55c50482 --- /dev/null +++ b/apps/sim/tools/trigger_dev/create_env_var.ts @@ -0,0 +1,75 @@ +import type { + TriggerDevEnvVarActionResponse, + TriggerDevEnvVarWriteParams, +} from '@/tools/trigger_dev/types' +import { buildTriggerDevEnvVarsUrl, buildTriggerDevHeaders } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevCreateEnvVarTool: ToolConfig< + TriggerDevEnvVarWriteParams, + TriggerDevEnvVarActionResponse +> = { + id: 'trigger_dev_create_env_var', + name: 'Trigger.dev Create Env Var', + description: 'Create an environment variable in a Trigger.dev project environment.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + projectRef: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'External ref of the project, from the project settings (starts with proj_)', + }, + environment: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Environment to create the variable in: dev, staging, or prod', + }, + name: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Name of the environment variable (e.g., "SLACK_API_KEY")', + }, + value: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Value of the environment variable', + }, + }, + + request: { + url: (params) => buildTriggerDevEnvVarsUrl(params.projectRef, params.environment), + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => ({ + name: params.name, + value: params.value, + }), + }, + + transformResponse: async (response, params) => { + const data = await response.json() + return { + success: true, + output: { + success: data.success ?? true, + name: params?.name ?? '', + }, + } + }, + + outputs: { + success: { type: 'boolean', description: 'Whether the environment variable was created' }, + name: { type: 'string', description: 'Name of the environment variable that was created' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/create_schedule.ts b/apps/sim/tools/trigger_dev/create_schedule.ts new file mode 100644 index 0000000000..cc8861591e --- /dev/null +++ b/apps/sim/tools/trigger_dev/create_schedule.ts @@ -0,0 +1,89 @@ +import type { + TriggerDevCreateScheduleParams, + TriggerDevScheduleResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevSchedule, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_SCHEDULE_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevCreateScheduleTool: ToolConfig< + TriggerDevCreateScheduleParams, + TriggerDevScheduleResponse +> = { + id: 'trigger_dev_create_schedule', + name: 'Trigger.dev Create Schedule', + description: + 'Create an imperative cron schedule that triggers a Trigger.dev task on a recurring basis.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + task: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Identifier of the task to schedule (e.g., "daily-report")', + }, + cron: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Cron expression defining when the task runs (e.g., "0 0 * * *")', + }, + timezone: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'IANA timezone the cron expression is evaluated in (e.g., "America/New_York"). Defaults to UTC', + }, + externalId: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'External identifier to associate with the schedule (e.g., a user ID)', + }, + deduplicationKey: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Key that prevents duplicate schedules; creating again with the same key updates the existing schedule', + }, + }, + + request: { + url: `${TRIGGER_DEV_API_BASE}/api/v1/schedules`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => { + const body: Record = { + task: params.task, + cron: params.cron, + } + if (params.timezone) body.timezone = params.timezone + if (params.externalId) body.externalId = params.externalId + if (params.deduplicationKey) body.deduplicationKey = params.deduplicationKey + return body + }, + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevSchedule(data), + } + }, + + outputs: TRIGGER_DEV_SCHEDULE_OUTPUTS, +} diff --git a/apps/sim/tools/trigger_dev/deactivate_schedule.ts b/apps/sim/tools/trigger_dev/deactivate_schedule.ts new file mode 100644 index 0000000000..1542d3ea3f --- /dev/null +++ b/apps/sim/tools/trigger_dev/deactivate_schedule.ts @@ -0,0 +1,53 @@ +import type { + TriggerDevScheduleIdParams, + TriggerDevScheduleResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevSchedule, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_SCHEDULE_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevDeactivateScheduleTool: ToolConfig< + TriggerDevScheduleIdParams, + TriggerDevScheduleResponse +> = { + id: 'trigger_dev_deactivate_schedule', + name: 'Trigger.dev Deactivate Schedule', + description: 'Deactivate an imperative Trigger.dev schedule so it stops triggering its task.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + scheduleId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the schedule to deactivate (starts with sched_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/schedules/${encodeURIComponent(params.scheduleId.trim())}/deactivate`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevSchedule(data), + } + }, + + outputs: TRIGGER_DEV_SCHEDULE_OUTPUTS, +} diff --git a/apps/sim/tools/trigger_dev/delete_env_var.ts b/apps/sim/tools/trigger_dev/delete_env_var.ts new file mode 100644 index 0000000000..216e0557da --- /dev/null +++ b/apps/sim/tools/trigger_dev/delete_env_var.ts @@ -0,0 +1,65 @@ +import type { + TriggerDevEnvVarActionResponse, + TriggerDevEnvVarNameParams, +} from '@/tools/trigger_dev/types' +import { buildTriggerDevEnvVarsUrl, buildTriggerDevHeaders } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevDeleteEnvVarTool: ToolConfig< + TriggerDevEnvVarNameParams, + TriggerDevEnvVarActionResponse +> = { + id: 'trigger_dev_delete_env_var', + name: 'Trigger.dev Delete Env Var', + description: 'Delete an environment variable from a Trigger.dev project environment.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + projectRef: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'External ref of the project, from the project settings (starts with proj_)', + }, + environment: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Environment the variable belongs to: dev, staging, or prod', + }, + name: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Name of the environment variable to delete (e.g., "SLACK_API_KEY")', + }, + }, + + request: { + url: (params) => buildTriggerDevEnvVarsUrl(params.projectRef, params.environment, params.name), + method: 'DELETE', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response, params) => { + const data = await response.json() + return { + success: true, + output: { + success: data.success ?? true, + name: params?.name ?? '', + }, + } + }, + + outputs: { + success: { type: 'boolean', description: 'Whether the environment variable was deleted' }, + name: { type: 'string', description: 'Name of the environment variable that was deleted' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/delete_schedule.ts b/apps/sim/tools/trigger_dev/delete_schedule.ts new file mode 100644 index 0000000000..785bb5208a --- /dev/null +++ b/apps/sim/tools/trigger_dev/delete_schedule.ts @@ -0,0 +1,53 @@ +import type { + TriggerDevDeleteScheduleResponse, + TriggerDevScheduleIdParams, +} from '@/tools/trigger_dev/types' +import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevDeleteScheduleTool: ToolConfig< + TriggerDevScheduleIdParams, + TriggerDevDeleteScheduleResponse +> = { + id: 'trigger_dev_delete_schedule', + name: 'Trigger.dev Delete Schedule', + description: 'Delete an imperative Trigger.dev schedule by its ID.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + scheduleId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the schedule to delete (starts with sched_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/schedules/${encodeURIComponent(params.scheduleId.trim())}`, + method: 'DELETE', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (_response, params) => { + return { + success: true, + output: { + deleted: true, + scheduleId: params?.scheduleId ?? '', + }, + } + }, + + outputs: { + deleted: { type: 'boolean', description: 'Whether the schedule was deleted' }, + scheduleId: { type: 'string', description: 'ID of the schedule that was deleted' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/get_env_var.ts b/apps/sim/tools/trigger_dev/get_env_var.ts new file mode 100644 index 0000000000..e7a2f46bec --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_env_var.ts @@ -0,0 +1,65 @@ +import type { + TriggerDevEnvVarNameParams, + TriggerDevEnvVarResponse, +} from '@/tools/trigger_dev/types' +import { buildTriggerDevEnvVarsUrl, buildTriggerDevHeaders } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetEnvVarTool: ToolConfig< + TriggerDevEnvVarNameParams, + TriggerDevEnvVarResponse +> = { + id: 'trigger_dev_get_env_var', + name: 'Trigger.dev Get Env Var', + description: 'Retrieve an environment variable from a Trigger.dev project environment.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + projectRef: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'External ref of the project, from the project settings (starts with proj_)', + }, + environment: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Environment to read the variable from: dev, staging, or prod', + }, + name: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Name of the environment variable (e.g., "SLACK_API_KEY")', + }, + }, + + request: { + url: (params) => buildTriggerDevEnvVarsUrl(params.projectRef, params.environment, params.name), + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + name: data.name, + value: data.value, + }, + } + }, + + outputs: { + name: { type: 'string', description: 'Name of the environment variable' }, + value: { type: 'string', description: 'Value of the environment variable' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/get_queue.ts b/apps/sim/tools/trigger_dev/get_queue.ts new file mode 100644 index 0000000000..c399149786 --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_queue.ts @@ -0,0 +1,58 @@ +import type { TriggerDevQueueParams, TriggerDevQueueResponse } from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevQueue, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_QUEUE_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetQueueTool: ToolConfig = { + id: 'trigger_dev_get_queue', + name: 'Trigger.dev Get Queue', + description: + 'Retrieve a Trigger.dev queue by ID, task identifier, or custom queue name, including its running and queued counts.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + queueName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Queue ID (starts with queue_), task identifier, or custom queue name, depending on the queue type', + }, + queueType: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'How to interpret the queue name: "id" (default) for a queue ID, "task" for a task identifier, or "custom" for a custom queue name', + }, + }, + + request: { + url: (params) => { + const base = `${TRIGGER_DEV_API_BASE}/api/v1/queues/${encodeURIComponent(params.queueName.trim())}` + return params.queueType ? `${base}?type=${encodeURIComponent(params.queueType)}` : base + }, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevQueue(data), + } + }, + + outputs: TRIGGER_DEV_QUEUE_OUTPUTS, +} diff --git a/apps/sim/tools/trigger_dev/get_run.ts b/apps/sim/tools/trigger_dev/get_run.ts new file mode 100644 index 0000000000..66b8a8aaca --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_run.ts @@ -0,0 +1,48 @@ +import type { TriggerDevRunIdParams, TriggerDevRunResponse } from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevRunDetail, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_RUN_DETAIL_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetRunTool: ToolConfig = { + id: 'trigger_dev_get_run', + name: 'Trigger.dev Get Run', + description: + 'Retrieve a Trigger.dev run by its ID, including status, payload, output, attempts, and timing details.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + runId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the run to retrieve (starts with run_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v3/runs/${encodeURIComponent(params.runId.trim())}`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevRunDetail(data), + } + }, + + outputs: TRIGGER_DEV_RUN_DETAIL_OUTPUTS, +} diff --git a/apps/sim/tools/trigger_dev/get_schedule.ts b/apps/sim/tools/trigger_dev/get_schedule.ts new file mode 100644 index 0000000000..340c6053be --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_schedule.ts @@ -0,0 +1,53 @@ +import type { + TriggerDevScheduleIdParams, + TriggerDevScheduleResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevSchedule, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_SCHEDULE_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetScheduleTool: ToolConfig< + TriggerDevScheduleIdParams, + TriggerDevScheduleResponse +> = { + id: 'trigger_dev_get_schedule', + name: 'Trigger.dev Get Schedule', + description: 'Retrieve a Trigger.dev schedule by its ID.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + scheduleId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the schedule to retrieve (starts with sched_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/schedules/${encodeURIComponent(params.scheduleId.trim())}`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevSchedule(data), + } + }, + + outputs: TRIGGER_DEV_SCHEDULE_OUTPUTS, +} diff --git a/apps/sim/tools/trigger_dev/index.ts b/apps/sim/tools/trigger_dev/index.ts new file mode 100644 index 0000000000..f59351b498 --- /dev/null +++ b/apps/sim/tools/trigger_dev/index.ts @@ -0,0 +1,23 @@ +export { triggerDevActivateScheduleTool } from '@/tools/trigger_dev/activate_schedule' +export { triggerDevBatchTriggerTaskTool } from '@/tools/trigger_dev/batch_trigger_task' +export { triggerDevCancelRunTool } from '@/tools/trigger_dev/cancel_run' +export { triggerDevCreateEnvVarTool } from '@/tools/trigger_dev/create_env_var' +export { triggerDevCreateScheduleTool } from '@/tools/trigger_dev/create_schedule' +export { triggerDevDeactivateScheduleTool } from '@/tools/trigger_dev/deactivate_schedule' +export { triggerDevDeleteEnvVarTool } from '@/tools/trigger_dev/delete_env_var' +export { triggerDevDeleteScheduleTool } from '@/tools/trigger_dev/delete_schedule' +export { triggerDevGetEnvVarTool } from '@/tools/trigger_dev/get_env_var' +export { triggerDevGetQueueTool } from '@/tools/trigger_dev/get_queue' +export { triggerDevGetRunTool } from '@/tools/trigger_dev/get_run' +export { triggerDevGetScheduleTool } from '@/tools/trigger_dev/get_schedule' +export { triggerDevListEnvVarsTool } from '@/tools/trigger_dev/list_env_vars' +export { triggerDevListRunsTool } from '@/tools/trigger_dev/list_runs' +export { triggerDevListSchedulesTool } from '@/tools/trigger_dev/list_schedules' +export { triggerDevPauseQueueTool } from '@/tools/trigger_dev/pause_queue' +export { triggerDevReplayRunTool } from '@/tools/trigger_dev/replay_run' +export { triggerDevRescheduleRunTool } from '@/tools/trigger_dev/reschedule_run' +export { triggerDevResumeQueueTool } from '@/tools/trigger_dev/resume_queue' +export { triggerDevTriggerTaskTool } from '@/tools/trigger_dev/trigger_task' +export { triggerDevUpdateEnvVarTool } from '@/tools/trigger_dev/update_env_var' +export { triggerDevUpdateRunMetadataTool } from '@/tools/trigger_dev/update_run_metadata' +export { triggerDevUpdateScheduleTool } from '@/tools/trigger_dev/update_schedule' diff --git a/apps/sim/tools/trigger_dev/list_env_vars.ts b/apps/sim/tools/trigger_dev/list_env_vars.ts new file mode 100644 index 0000000000..62da45901b --- /dev/null +++ b/apps/sim/tools/trigger_dev/list_env_vars.ts @@ -0,0 +1,73 @@ +import type { + TriggerDevEnvVarsScopeParams, + TriggerDevListEnvVarsResponse, +} from '@/tools/trigger_dev/types' +import { buildTriggerDevEnvVarsUrl, buildTriggerDevHeaders } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevListEnvVarsTool: ToolConfig< + TriggerDevEnvVarsScopeParams, + TriggerDevListEnvVarsResponse +> = { + id: 'trigger_dev_list_env_vars', + name: 'Trigger.dev List Env Vars', + description: + 'List the environment variables of a Trigger.dev project environment, including their values.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + projectRef: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'External ref of the project, from the project settings (starts with proj_)', + }, + environment: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Environment to list variables for: dev, staging, or prod', + }, + }, + + request: { + url: (params) => buildTriggerDevEnvVarsUrl(params.projectRef, params.environment), + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + const variables = Array.isArray(data) ? data : [] + return { + success: true, + output: { + variables: variables.map((variable) => ({ + name: variable.name, + value: variable.value, + })), + }, + } + }, + + outputs: { + variables: { + type: 'array', + description: 'Environment variables in the project environment', + items: { + type: 'object', + description: 'Environment variable', + properties: { + name: { type: 'string', description: 'Name of the environment variable' }, + value: { type: 'string', description: 'Value of the environment variable' }, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/list_runs.ts b/apps/sim/tools/trigger_dev/list_runs.ts new file mode 100644 index 0000000000..c3dc8bbaba --- /dev/null +++ b/apps/sim/tools/trigger_dev/list_runs.ts @@ -0,0 +1,190 @@ +import type { + TriggerDevListRunsParams, + TriggerDevListRunsResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevRunSummary, + splitCommaSeparated, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_RUN_SUMMARY_PROPERTIES, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevListRunsTool: ToolConfig< + TriggerDevListRunsParams, + TriggerDevListRunsResponse +> = { + id: 'trigger_dev_list_runs', + name: 'Trigger.dev List Runs', + description: + 'List Trigger.dev runs in the environment of the API key, with optional filters for status, task, version, tags, schedule, and creation time.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + status: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Comma-separated run statuses to filter by: PENDING_VERSION, DELAYED, QUEUED, EXECUTING, REATTEMPTING, FROZEN, COMPLETED, CANCELED, FAILED, CRASHED, INTERRUPTED, SYSTEM_FAILURE', + }, + taskIdentifier: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated task identifiers to filter by', + }, + version: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated worker versions to filter by (e.g., "20240101.1")', + }, + tag: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated tags to filter by', + }, + schedule: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Schedule ID to filter by (starts with sched_)', + }, + isTest: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter by test runs: "true" for only test runs, "false" to exclude them', + }, + period: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Only return runs created in the given period (e.g., "1h", "7d")', + }, + from: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Only return runs created on or after this ISO 8601 timestamp', + }, + to: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Only return runs created on or before this ISO 8601 timestamp', + }, + pageSize: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of runs per page (max 100, default 25)', + }, + pageAfter: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Run ID to start the page after, for forward pagination', + }, + pageBefore: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Run ID to start the page before, for backward pagination', + }, + }, + + request: { + url: (params) => { + const query = new URLSearchParams() + if (params.pageSize) query.set('page[size]', String(params.pageSize)) + if (params.pageAfter) query.set('page[after]', params.pageAfter) + if (params.pageBefore) query.set('page[before]', params.pageBefore) + if (params.status) { + for (const status of splitCommaSeparated(params.status)) { + query.append('filter[status]', status.toUpperCase()) + } + } + if (params.taskIdentifier) { + for (const task of splitCommaSeparated(params.taskIdentifier)) { + query.append('filter[taskIdentifier]', task) + } + } + if (params.version) { + for (const version of splitCommaSeparated(params.version)) { + query.append('filter[version]', version) + } + } + if (params.tag) { + for (const tag of splitCommaSeparated(params.tag)) { + query.append('filter[tag]', tag) + } + } + if (params.schedule) query.set('filter[schedule]', params.schedule) + if (params.isTest === 'true' || params.isTest === 'false') { + query.set('filter[isTest]', params.isTest) + } + if (params.period) query.set('filter[createdAt][period]', params.period) + if (params.from) query.set('filter[createdAt][from]', params.from) + if (params.to) query.set('filter[createdAt][to]', params.to) + + const queryString = query.toString() + return queryString + ? `${TRIGGER_DEV_API_BASE}/api/v1/runs?${queryString}` + : `${TRIGGER_DEV_API_BASE}/api/v1/runs` + }, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + runs: (data.data ?? []).map(mapTriggerDevRunSummary), + pagination: { + next: data.pagination?.next ?? null, + previous: data.pagination?.previous ?? null, + }, + }, + } + }, + + outputs: { + runs: { + type: 'array', + description: 'Runs matching the filters', + items: { + type: 'object', + description: 'Run summary', + properties: TRIGGER_DEV_RUN_SUMMARY_PROPERTIES, + }, + }, + pagination: { + type: 'object', + description: 'Cursor pagination details', + properties: { + next: { + type: 'string', + description: 'Run ID to start the next page after', + nullable: true, + }, + previous: { + type: 'string', + description: 'Run ID to start the previous page before', + nullable: true, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/list_schedules.ts b/apps/sim/tools/trigger_dev/list_schedules.ts new file mode 100644 index 0000000000..f724cdd277 --- /dev/null +++ b/apps/sim/tools/trigger_dev/list_schedules.ts @@ -0,0 +1,143 @@ +import type { + TriggerDevListSchedulesParams, + TriggerDevListSchedulesResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevSchedule, + TRIGGER_DEV_API_BASE, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevListSchedulesTool: ToolConfig< + TriggerDevListSchedulesParams, + TriggerDevListSchedulesResponse +> = { + id: 'trigger_dev_list_schedules', + name: 'Trigger.dev List Schedules', + description: 'List Trigger.dev schedules in the project, with page-based pagination.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + page: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Page number to return (default 1)', + }, + perPage: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of schedules per page', + }, + }, + + request: { + url: (params) => { + const query = new URLSearchParams() + if (params.page) query.set('page', String(params.page)) + if (params.perPage) query.set('perPage', String(params.perPage)) + const queryString = query.toString() + return queryString + ? `${TRIGGER_DEV_API_BASE}/api/v1/schedules?${queryString}` + : `${TRIGGER_DEV_API_BASE}/api/v1/schedules` + }, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + schedules: (data.data ?? []).map(mapTriggerDevSchedule), + pagination: { + currentPage: data.pagination?.currentPage ?? null, + totalPages: data.pagination?.totalPages ?? null, + count: data.pagination?.count ?? null, + }, + }, + } + }, + + outputs: { + schedules: { + type: 'array', + description: 'Schedules in the project', + items: { + type: 'object', + description: 'Schedule', + properties: { + id: { type: 'string', description: 'Unique ID of the schedule (starts with sched_)' }, + task: { type: 'string', description: 'Identifier of the task the schedule triggers' }, + type: { + type: 'string', + description: 'Schedule type (DECLARATIVE or IMPERATIVE)', + nullable: true, + }, + active: { type: 'boolean', description: 'Whether the schedule is active' }, + deduplicationKey: { + type: 'string', + description: 'Deduplication key of the schedule', + nullable: true, + }, + externalId: { + type: 'string', + description: 'External ID associated with the schedule', + nullable: true, + }, + cron: { type: 'string', description: 'Cron expression of the schedule', nullable: true }, + cronDescription: { + type: 'string', + description: 'Human-readable description of the cron expression', + nullable: true, + }, + timezone: { + type: 'string', + description: 'IANA timezone of the schedule', + nullable: true, + }, + nextRun: { + type: 'string', + description: 'ISO timestamp of the next scheduled run', + nullable: true, + }, + environments: { + type: 'array', + description: 'Environments the schedule runs in', + items: { + type: 'object', + description: 'Environment the schedule is associated with', + properties: { + id: { type: 'string', description: 'Environment ID', nullable: true }, + type: { type: 'string', description: 'Environment type', nullable: true }, + userName: { + type: 'string', + description: 'Username for dev environments', + nullable: true, + }, + }, + }, + }, + }, + }, + }, + pagination: { + type: 'object', + description: 'Page-based pagination details', + properties: { + currentPage: { type: 'number', description: 'Current page number', nullable: true }, + totalPages: { type: 'number', description: 'Total number of pages', nullable: true }, + count: { type: 'number', description: 'Total number of schedules', nullable: true }, + }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/pause_queue.ts b/apps/sim/tools/trigger_dev/pause_queue.ts new file mode 100644 index 0000000000..4d36be8b40 --- /dev/null +++ b/apps/sim/tools/trigger_dev/pause_queue.ts @@ -0,0 +1,61 @@ +import type { TriggerDevQueueParams, TriggerDevQueueResponse } from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevQueue, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_QUEUE_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevPauseQueueTool: ToolConfig = + { + id: 'trigger_dev_pause_queue', + name: 'Trigger.dev Pause Queue', + description: + 'Pause a Trigger.dev queue so no new runs start. Runs that are currently executing continue to completion.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + queueName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Queue ID (starts with queue_), task identifier, or custom queue name, depending on the queue type', + }, + queueType: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'How to interpret the queue name: "id" (default) for a queue ID, "task" for a task identifier, or "custom" for a custom queue name', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/queues/${encodeURIComponent(params.queueName.trim())}/pause`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => ({ + action: 'pause', + ...(params.queueType ? { type: params.queueType } : {}), + }), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevQueue(data), + } + }, + + outputs: TRIGGER_DEV_QUEUE_OUTPUTS, + } diff --git a/apps/sim/tools/trigger_dev/replay_run.ts b/apps/sim/tools/trigger_dev/replay_run.ts new file mode 100644 index 0000000000..91176e91ad --- /dev/null +++ b/apps/sim/tools/trigger_dev/replay_run.ts @@ -0,0 +1,50 @@ +import type { TriggerDevRunActionResponse, TriggerDevRunIdParams } from '@/tools/trigger_dev/types' +import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevReplayRunTool: ToolConfig< + TriggerDevRunIdParams, + TriggerDevRunActionResponse +> = { + id: 'trigger_dev_replay_run', + name: 'Trigger.dev Replay Run', + description: + 'Replay a Trigger.dev run, creating a new run with the same payload and options as the original.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + runId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the run to replay (starts with run_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/runs/${encodeURIComponent(params.runId.trim())}/replay`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + id: data.id, + }, + } + }, + + outputs: { + id: { type: 'string', description: 'ID of the new run created by the replay' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/reschedule_run.ts b/apps/sim/tools/trigger_dev/reschedule_run.ts new file mode 100644 index 0000000000..90e47017d2 --- /dev/null +++ b/apps/sim/tools/trigger_dev/reschedule_run.ts @@ -0,0 +1,62 @@ +import type { + TriggerDevRescheduleRunParams, + TriggerDevRunResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevRunDetail, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_RUN_DETAIL_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevRescheduleRunTool: ToolConfig< + TriggerDevRescheduleRunParams, + TriggerDevRunResponse +> = { + id: 'trigger_dev_reschedule_run', + name: 'Trigger.dev Reschedule Run', + description: + 'Reschedule a delayed Trigger.dev run with a new delay. Only valid while the run is in the DELAYED state.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + runId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the delayed run to reschedule (starts with run_)', + }, + delay: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'New delay for the run, as a duration ("30m", "1h", "2d") or an ISO 8601 date to delay until', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/runs/${encodeURIComponent(params.runId.trim())}/reschedule`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => ({ delay: params.delay }), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevRunDetail(data), + } + }, + + outputs: TRIGGER_DEV_RUN_DETAIL_OUTPUTS, +} diff --git a/apps/sim/tools/trigger_dev/resume_queue.ts b/apps/sim/tools/trigger_dev/resume_queue.ts new file mode 100644 index 0000000000..d012a5ec10 --- /dev/null +++ b/apps/sim/tools/trigger_dev/resume_queue.ts @@ -0,0 +1,60 @@ +import type { TriggerDevQueueParams, TriggerDevQueueResponse } from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevQueue, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_QUEUE_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevResumeQueueTool: ToolConfig = + { + id: 'trigger_dev_resume_queue', + name: 'Trigger.dev Resume Queue', + description: 'Resume a paused Trigger.dev queue so new runs can start again.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + queueName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Queue ID (starts with queue_), task identifier, or custom queue name, depending on the queue type', + }, + queueType: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'How to interpret the queue name: "id" (default) for a queue ID, "task" for a task identifier, or "custom" for a custom queue name', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/queues/${encodeURIComponent(params.queueName.trim())}/pause`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => ({ + action: 'resume', + ...(params.queueType ? { type: params.queueType } : {}), + }), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevQueue(data), + } + }, + + outputs: TRIGGER_DEV_QUEUE_OUTPUTS, + } diff --git a/apps/sim/tools/trigger_dev/trigger_task.ts b/apps/sim/tools/trigger_dev/trigger_task.ts new file mode 100644 index 0000000000..b0f7803a28 --- /dev/null +++ b/apps/sim/tools/trigger_dev/trigger_task.ts @@ -0,0 +1,130 @@ +import type { + TriggerDevTriggerTaskParams, + TriggerDevTriggerTaskResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + parseJsonInput, + splitCommaSeparated, + TRIGGER_DEV_API_BASE, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevTriggerTaskTool: ToolConfig< + TriggerDevTriggerTaskParams, + TriggerDevTriggerTaskResponse +> = { + id: 'trigger_dev_trigger_task', + name: 'Trigger.dev Trigger Task', + description: + 'Trigger a Trigger.dev task by its identifier with an optional JSON payload. Returns the ID of the created run.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + taskIdentifier: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Identifier of the task to trigger (e.g., "send-welcome-email")', + }, + payload: { + type: 'json', + required: false, + visibility: 'user-or-llm', + description: 'JSON payload passed to the task run. Example: {"userId": "user_123"}', + }, + idempotencyKey: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Idempotency key that ensures the task is only triggered once per key', + }, + queue: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Name of the queue to run the task on', + }, + concurrencyKey: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Key that scopes the queue concurrency limit (e.g., a user ID)', + }, + delay: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Delay before the run executes, as a duration ("30m", "1h", "2d") or an ISO 8601 date', + }, + ttl: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Time-to-live before an unstarted run expires, as a duration ("1h42m") or seconds', + }, + machine: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Machine preset for the run: micro, small-1x, small-2x, medium-1x, medium-2x, large-1x, or large-2x', + }, + tags: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated tags to attach to the run (max 10, each under 128 characters)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/tasks/${encodeURIComponent(params.taskIdentifier.trim())}/trigger`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => { + const body: Record = {} + + const payload = parseJsonInput(params.payload, 'payload') + if (payload !== undefined) body.payload = payload + + const options: Record = {} + if (params.idempotencyKey) options.idempotencyKey = params.idempotencyKey + if (params.queue) options.queue = { name: params.queue } + if (params.concurrencyKey) options.concurrencyKey = params.concurrencyKey + if (params.delay) options.delay = params.delay + if (params.ttl) options.ttl = params.ttl + if (params.machine) options.machine = params.machine + if (params.tags) { + const tags = splitCommaSeparated(params.tags) + if (tags.length > 0) options.tags = tags + } + if (Object.keys(options).length > 0) body.options = options + + return body + }, + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + id: data.id, + }, + } + }, + + outputs: { + id: { type: 'string', description: 'ID of the run that was triggered (starts with run_)' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/types.ts b/apps/sim/tools/trigger_dev/types.ts new file mode 100644 index 0000000000..bcb2d6c9cd --- /dev/null +++ b/apps/sim/tools/trigger_dev/types.ts @@ -0,0 +1,410 @@ +import type { ToolResponse } from '@/tools/types' + +interface TriggerDevBaseParams { + apiKey: string +} + +/** Raw run object returned by the Trigger.dev list runs and retrieve run endpoints */ +export interface TriggerDevApiRun { + id: string + status: string + taskIdentifier: string + version?: string + idempotencyKey?: string + isTest?: boolean + createdAt?: string + updatedAt?: string + startedAt?: string + finishedAt?: string + delayedUntil?: string + ttl?: string | number + expiredAt?: string + tags?: string[] + metadata?: Record + costInCents?: number + baseCostInCents?: number + durationMs?: number + depth?: number + batchId?: string + triggerFunction?: string + env?: { + id?: string + name?: string + user?: string + } +} + +/** Raw run detail object returned by the Trigger.dev retrieve and reschedule run endpoints */ +export interface TriggerDevApiRunDetail extends TriggerDevApiRun { + payload?: unknown + payloadPresignedUrl?: string + output?: unknown + outputPresignedUrl?: string + schedule?: { + id?: string + externalId?: string + deduplicationKey?: string + generator?: { + type?: string + expression?: string + description?: string + } + } + attempts?: TriggerDevApiAttempt[] + relatedRuns?: { + root?: TriggerDevApiRun + parent?: TriggerDevApiRun + children?: TriggerDevApiRun[] + } +} + +/** Raw queue object returned by the Trigger.dev queues endpoints */ +export interface TriggerDevApiQueue { + id: string + name: string + type?: string + running?: number + queued?: number + paused?: boolean + concurrencyLimit?: number | null + concurrency?: { + current?: number + base?: number + override?: number | null + overriddenAt?: string | null + } +} + +/** Raw schedule object returned by the Trigger.dev schedules endpoints */ +export interface TriggerDevApiSchedule { + id: string + task: string + type?: string + active?: boolean + deduplicationKey?: string + externalId?: string + generator?: { + type?: string + expression?: string + description?: string + } + timezone?: string + nextRun?: string + environments?: { + id?: string + type?: string + userName?: string + }[] +} + +/** Raw attempt object included in the Trigger.dev retrieve run response */ +export interface TriggerDevApiAttempt { + id: string + status: string + createdAt?: string + updatedAt?: string + startedAt?: string + completedAt?: string + error?: { + message?: string + name?: string + stackTrace?: string + } +} + +/** Normalized run fields shared by the list runs and get run outputs */ +export interface TriggerDevRunSummary { + id: string + status: string + taskIdentifier: string + version: string | null + idempotencyKey: string | null + isTest: boolean + createdAt: string | null + updatedAt: string | null + startedAt: string | null + finishedAt: string | null + delayedUntil: string | null + ttl: string | number | null + expiredAt: string | null + tags: string[] + costInCents: number | null + baseCostInCents: number | null + durationMs: number | null + env: { + id: string | null + name: string | null + user: string | null + } | null +} + +/** Normalized attempt entry in the get run output */ +export interface TriggerDevAttempt { + id: string + status: string + createdAt: string | null + updatedAt: string | null + startedAt: string | null + completedAt: string | null + error: { + message: string | null + name: string | null + stackTrace: string | null + } | null +} + +/** Full normalized run returned by the get run tool */ +export interface TriggerDevRunDetail extends TriggerDevRunSummary { + metadata: Record | null + depth: number | null + batchId: string | null + triggerFunction: string | null + payload: unknown + payloadPresignedUrl: string | null + output: unknown + outputPresignedUrl: string | null + schedule: { + id: string | null + externalId: string | null + deduplicationKey: string | null + generator: { + type: string | null + expression: string | null + description: string | null + } | null + } | null + attempts: TriggerDevAttempt[] + relatedRuns: { + root: TriggerDevRunSummary | null + parent: TriggerDevRunSummary | null + children: TriggerDevRunSummary[] + } | null +} + +/** Normalized schedule returned by the schedule tools */ +export interface TriggerDevSchedule { + id: string + task: string + type: string | null + active: boolean + deduplicationKey: string | null + externalId: string | null + cron: string | null + cronDescription: string | null + timezone: string | null + nextRun: string | null + environments: { + id: string | null + type: string | null + userName: string | null + }[] +} + +/** Normalized queue returned by the queue tools */ +export interface TriggerDevQueue { + id: string + name: string + type: string | null + running: number | null + queued: number | null + paused: boolean + concurrencyLimit: number | null + concurrency: { + current: number | null + base: number | null + override: number | null + overriddenAt: string | null + } | null +} + +/** Normalized environment variable returned by the env var tools */ +export interface TriggerDevEnvVar { + name: string + value: string +} + +export interface TriggerDevTriggerTaskParams extends TriggerDevBaseParams { + taskIdentifier: string + payload?: string | Record + idempotencyKey?: string + queue?: string + concurrencyKey?: string + delay?: string + ttl?: string + machine?: string + tags?: string +} + +export interface TriggerDevBatchTriggerTaskParams extends TriggerDevBaseParams { + taskIdentifier: string + items: string | Record[] +} + +export interface TriggerDevRunIdParams extends TriggerDevBaseParams { + runId: string +} + +export interface TriggerDevRescheduleRunParams extends TriggerDevBaseParams { + runId: string + delay: string +} + +export interface TriggerDevUpdateRunMetadataParams extends TriggerDevBaseParams { + runId: string + metadata: string | Record +} + +export interface TriggerDevListRunsParams extends TriggerDevBaseParams { + status?: string + taskIdentifier?: string + version?: string + tag?: string + schedule?: string + isTest?: string + period?: string + from?: string + to?: string + pageSize?: number + pageAfter?: string + pageBefore?: string +} + +export interface TriggerDevCreateScheduleParams extends TriggerDevBaseParams { + task: string + cron: string + timezone?: string + externalId?: string + deduplicationKey?: string +} + +export interface TriggerDevUpdateScheduleParams extends TriggerDevBaseParams { + scheduleId: string + task: string + cron: string + timezone?: string + externalId?: string +} + +export interface TriggerDevScheduleIdParams extends TriggerDevBaseParams { + scheduleId: string +} + +export interface TriggerDevListSchedulesParams extends TriggerDevBaseParams { + page?: number + perPage?: number +} + +export interface TriggerDevEnvVarsScopeParams extends TriggerDevBaseParams { + projectRef: string + environment: string +} + +export interface TriggerDevEnvVarNameParams extends TriggerDevEnvVarsScopeParams { + name: string +} + +export interface TriggerDevEnvVarWriteParams extends TriggerDevEnvVarNameParams { + value: string +} + +export interface TriggerDevQueueParams extends TriggerDevBaseParams { + queueName: string + queueType?: string +} + +export interface TriggerDevTriggerTaskResponse extends ToolResponse { + output: { + id: string + } +} + +export interface TriggerDevBatchTriggerTaskResponse extends ToolResponse { + output: { + batchId: string + runIds: string[] + } +} + +export interface TriggerDevUpdateRunMetadataResponse extends ToolResponse { + output: { + metadata: Record | null + } +} + +export interface TriggerDevListEnvVarsResponse extends ToolResponse { + output: { + variables: TriggerDevEnvVar[] + } +} + +export interface TriggerDevEnvVarResponse extends ToolResponse { + output: TriggerDevEnvVar +} + +export interface TriggerDevEnvVarActionResponse extends ToolResponse { + output: { + success: boolean + name: string + } +} + +export interface TriggerDevQueueResponse extends ToolResponse { + output: TriggerDevQueue +} + +export interface TriggerDevRunResponse extends ToolResponse { + output: TriggerDevRunDetail +} + +export interface TriggerDevListRunsResponse extends ToolResponse { + output: { + runs: TriggerDevRunSummary[] + pagination: { + next: string | null + previous: string | null + } + } +} + +export interface TriggerDevRunActionResponse extends ToolResponse { + output: { + id: string + } +} + +export interface TriggerDevScheduleResponse extends ToolResponse { + output: TriggerDevSchedule +} + +export interface TriggerDevListSchedulesResponse extends ToolResponse { + output: { + schedules: TriggerDevSchedule[] + pagination: { + currentPage: number | null + totalPages: number | null + count: number | null + } + } +} + +export interface TriggerDevDeleteScheduleResponse extends ToolResponse { + output: { + deleted: boolean + scheduleId: string + } +} + +export type TriggerDevResponse = + | TriggerDevTriggerTaskResponse + | TriggerDevBatchTriggerTaskResponse + | TriggerDevRunResponse + | TriggerDevListRunsResponse + | TriggerDevRunActionResponse + | TriggerDevUpdateRunMetadataResponse + | TriggerDevScheduleResponse + | TriggerDevListSchedulesResponse + | TriggerDevDeleteScheduleResponse + | TriggerDevListEnvVarsResponse + | TriggerDevEnvVarResponse + | TriggerDevEnvVarActionResponse + | TriggerDevQueueResponse diff --git a/apps/sim/tools/trigger_dev/update_env_var.ts b/apps/sim/tools/trigger_dev/update_env_var.ts new file mode 100644 index 0000000000..2a70fec3b7 --- /dev/null +++ b/apps/sim/tools/trigger_dev/update_env_var.ts @@ -0,0 +1,74 @@ +import type { + TriggerDevEnvVarActionResponse, + TriggerDevEnvVarWriteParams, +} from '@/tools/trigger_dev/types' +import { buildTriggerDevEnvVarsUrl, buildTriggerDevHeaders } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevUpdateEnvVarTool: ToolConfig< + TriggerDevEnvVarWriteParams, + TriggerDevEnvVarActionResponse +> = { + id: 'trigger_dev_update_env_var', + name: 'Trigger.dev Update Env Var', + description: 'Update the value of an environment variable in a Trigger.dev project environment.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + projectRef: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'External ref of the project, from the project settings (starts with proj_)', + }, + environment: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Environment the variable belongs to: dev, staging, or prod', + }, + name: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Name of the environment variable to update (e.g., "SLACK_API_KEY")', + }, + value: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'New value of the environment variable', + }, + }, + + request: { + url: (params) => buildTriggerDevEnvVarsUrl(params.projectRef, params.environment, params.name), + method: 'PUT', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => ({ + value: params.value, + }), + }, + + transformResponse: async (response, params) => { + const data = await response.json() + return { + success: true, + output: { + success: data.success ?? true, + name: params?.name ?? '', + }, + } + }, + + outputs: { + success: { type: 'boolean', description: 'Whether the environment variable was updated' }, + name: { type: 'string', description: 'Name of the environment variable that was updated' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/update_run_metadata.ts b/apps/sim/tools/trigger_dev/update_run_metadata.ts new file mode 100644 index 0000000000..12c2b20217 --- /dev/null +++ b/apps/sim/tools/trigger_dev/update_run_metadata.ts @@ -0,0 +1,63 @@ +import type { + TriggerDevUpdateRunMetadataParams, + TriggerDevUpdateRunMetadataResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + parseJsonInput, + TRIGGER_DEV_API_BASE, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevUpdateRunMetadataTool: ToolConfig< + TriggerDevUpdateRunMetadataParams, + TriggerDevUpdateRunMetadataResponse +> = { + id: 'trigger_dev_update_run_metadata', + name: 'Trigger.dev Update Run Metadata', + description: 'Replace the metadata of a Trigger.dev run with a new JSON object.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + runId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the run to update (starts with run_)', + }, + metadata: { + type: 'json', + required: true, + visibility: 'user-or-llm', + description: 'JSON object to set as the run metadata. Example: {"stage": "approved"}', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/runs/${encodeURIComponent(params.runId.trim())}/metadata`, + method: 'PUT', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => ({ metadata: parseJsonInput(params.metadata, 'metadata') ?? {} }), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + metadata: data.metadata ?? null, + }, + } + }, + + outputs: { + metadata: { type: 'json', description: 'The updated metadata of the run' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/update_schedule.ts b/apps/sim/tools/trigger_dev/update_schedule.ts new file mode 100644 index 0000000000..251723754f --- /dev/null +++ b/apps/sim/tools/trigger_dev/update_schedule.ts @@ -0,0 +1,88 @@ +import type { + TriggerDevScheduleResponse, + TriggerDevUpdateScheduleParams, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevSchedule, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_SCHEDULE_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevUpdateScheduleTool: ToolConfig< + TriggerDevUpdateScheduleParams, + TriggerDevScheduleResponse +> = { + id: 'trigger_dev_update_schedule', + name: 'Trigger.dev Update Schedule', + description: + 'Update an imperative Trigger.dev schedule by its ID, replacing its task, cron expression, timezone, and external ID.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + scheduleId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the schedule to update (starts with sched_)', + }, + task: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Identifier of the task the schedule triggers (e.g., "daily-report")', + }, + cron: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Cron expression defining when the task runs (e.g., "0 0 * * *")', + }, + timezone: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'IANA timezone the cron expression is evaluated in (e.g., "America/New_York"). Defaults to UTC', + }, + externalId: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'External identifier to associate with the schedule (e.g., a user ID)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/schedules/${encodeURIComponent(params.scheduleId.trim())}`, + method: 'PUT', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => { + const body: Record = { + task: params.task, + cron: params.cron, + } + if (params.timezone) body.timezone = params.timezone + if (params.externalId) body.externalId = params.externalId + return body + }, + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevSchedule(data), + } + }, + + outputs: TRIGGER_DEV_SCHEDULE_OUTPUTS, +} diff --git a/apps/sim/tools/trigger_dev/utils.ts b/apps/sim/tools/trigger_dev/utils.ts new file mode 100644 index 0000000000..d1c0225c63 --- /dev/null +++ b/apps/sim/tools/trigger_dev/utils.ts @@ -0,0 +1,536 @@ +import type { + TriggerDevApiAttempt, + TriggerDevApiQueue, + TriggerDevApiRun, + TriggerDevApiRunDetail, + TriggerDevApiSchedule, + TriggerDevAttempt, + TriggerDevQueue, + TriggerDevRunDetail, + TriggerDevRunSummary, + TriggerDevSchedule, +} from '@/tools/trigger_dev/types' +import type { OutputProperty, ToolConfig } from '@/tools/types' + +export const TRIGGER_DEV_API_BASE = 'https://api.trigger.dev' + +/** + * Builds the standard headers for Trigger.dev management API requests. + */ +export function buildTriggerDevHeaders(apiKey: string): Record { + return { + Authorization: `Bearer ${apiKey}`, + 'Content-Type': 'application/json', + } +} + +/** + * Splits a comma-separated string into trimmed, non-empty values. + */ +export function splitCommaSeparated(value: string): string[] { + return value + .split(',') + .map((entry) => entry.trim()) + .filter((entry) => entry.length > 0) +} + +/** + * Normalizes a JSON parameter that may arrive as a parsed value or a JSON string. + * Throws a descriptive error when the string is not valid JSON. + */ +export function parseJsonInput(value: unknown, paramName: string): unknown { + if (value === undefined || value === null || value === '') return undefined + if (typeof value !== 'string') return value + try { + return JSON.parse(value) + } catch { + throw new Error(`Invalid JSON in ${paramName} parameter`) + } +} + +/** + * Builds the URL for the environment variable endpoints of a project environment. + */ +export function buildTriggerDevEnvVarsUrl( + projectRef: string, + environment: string, + name?: string +): string { + const base = `${TRIGGER_DEV_API_BASE}/api/v1/projects/${encodeURIComponent(projectRef.trim())}/envvars/${encodeURIComponent(environment.trim())}` + return name ? `${base}/${encodeURIComponent(name.trim())}` : base +} + +/** + * Maps a raw Trigger.dev run object to the normalized run summary shape. + */ +export function mapTriggerDevRunSummary(run: TriggerDevApiRun): TriggerDevRunSummary { + return { + id: run.id, + status: run.status, + taskIdentifier: run.taskIdentifier, + version: run.version ?? null, + idempotencyKey: run.idempotencyKey ?? null, + isTest: run.isTest ?? false, + createdAt: run.createdAt ?? null, + updatedAt: run.updatedAt ?? null, + startedAt: run.startedAt ?? null, + finishedAt: run.finishedAt ?? null, + delayedUntil: run.delayedUntil ?? null, + ttl: run.ttl ?? null, + expiredAt: run.expiredAt ?? null, + tags: run.tags ?? [], + costInCents: run.costInCents ?? null, + baseCostInCents: run.baseCostInCents ?? null, + durationMs: run.durationMs ?? null, + env: run.env + ? { + id: run.env.id ?? null, + name: run.env.name ?? null, + user: run.env.user ?? null, + } + : null, + } +} + +/** + * Maps a raw Trigger.dev attempt object to the normalized attempt shape. + */ +export function mapTriggerDevAttempt(attempt: TriggerDevApiAttempt): TriggerDevAttempt { + return { + id: attempt.id, + status: attempt.status, + createdAt: attempt.createdAt ?? null, + updatedAt: attempt.updatedAt ?? null, + startedAt: attempt.startedAt ?? null, + completedAt: attempt.completedAt ?? null, + error: attempt.error + ? { + message: attempt.error.message ?? null, + name: attempt.error.name ?? null, + stackTrace: attempt.error.stackTrace ?? null, + } + : null, + } +} + +/** + * Maps a raw Trigger.dev run detail object (retrieve and reschedule responses) + * to the normalized run detail shape. + */ +export function mapTriggerDevRunDetail(run: TriggerDevApiRunDetail): TriggerDevRunDetail { + return { + ...mapTriggerDevRunSummary(run), + metadata: run.metadata ?? null, + depth: run.depth ?? null, + batchId: run.batchId ?? null, + triggerFunction: run.triggerFunction ?? null, + payload: run.payload ?? null, + payloadPresignedUrl: run.payloadPresignedUrl ?? null, + output: run.output ?? null, + outputPresignedUrl: run.outputPresignedUrl ?? null, + schedule: run.schedule + ? { + id: run.schedule.id ?? null, + externalId: run.schedule.externalId ?? null, + deduplicationKey: run.schedule.deduplicationKey ?? null, + generator: run.schedule.generator + ? { + type: run.schedule.generator.type ?? null, + expression: run.schedule.generator.expression ?? null, + description: run.schedule.generator.description ?? null, + } + : null, + } + : null, + attempts: (run.attempts ?? []).map(mapTriggerDevAttempt), + relatedRuns: run.relatedRuns + ? { + root: run.relatedRuns.root ? mapTriggerDevRunSummary(run.relatedRuns.root) : null, + parent: run.relatedRuns.parent ? mapTriggerDevRunSummary(run.relatedRuns.parent) : null, + children: (run.relatedRuns.children ?? []).map(mapTriggerDevRunSummary), + } + : null, + } +} + +/** + * Maps a raw Trigger.dev queue object to the normalized queue shape. + */ +export function mapTriggerDevQueue(queue: TriggerDevApiQueue): TriggerDevQueue { + return { + id: queue.id, + name: queue.name, + type: queue.type ?? null, + running: queue.running ?? null, + queued: queue.queued ?? null, + paused: queue.paused ?? false, + concurrencyLimit: queue.concurrencyLimit ?? null, + concurrency: queue.concurrency + ? { + current: queue.concurrency.current ?? null, + base: queue.concurrency.base ?? null, + override: queue.concurrency.override ?? null, + overriddenAt: queue.concurrency.overriddenAt ?? null, + } + : null, + } +} + +/** + * Maps a raw Trigger.dev schedule object to the normalized schedule shape. + */ +export function mapTriggerDevSchedule(schedule: TriggerDevApiSchedule): TriggerDevSchedule { + return { + id: schedule.id, + task: schedule.task, + type: schedule.type ?? null, + active: schedule.active ?? false, + deduplicationKey: schedule.deduplicationKey ?? null, + externalId: schedule.externalId ?? null, + cron: schedule.generator?.expression ?? null, + cronDescription: schedule.generator?.description ?? null, + timezone: schedule.timezone ?? null, + nextRun: schedule.nextRun ?? null, + environments: (schedule.environments ?? []).map((environment) => ({ + id: environment.id ?? null, + type: environment.type ?? null, + userName: environment.userName ?? null, + })), + } +} + +/** + * Output property schema for a normalized run summary, shared by the run tools. + */ +export const TRIGGER_DEV_RUN_SUMMARY_PROPERTIES: Record = { + id: { type: 'string', description: 'Unique ID of the run (starts with run_)' }, + status: { + type: 'string', + description: + 'Run status (PENDING_VERSION, DELAYED, QUEUED, EXECUTING, REATTEMPTING, FROZEN, COMPLETED, CANCELED, FAILED, CRASHED, INTERRUPTED, or SYSTEM_FAILURE)', + }, + taskIdentifier: { type: 'string', description: 'Identifier of the task the run executes' }, + version: { + type: 'string', + description: 'Worker version the run executes on', + optional: true, + nullable: true, + }, + idempotencyKey: { + type: 'string', + description: 'Idempotency key the run was triggered with', + optional: true, + nullable: true, + }, + isTest: { type: 'boolean', description: 'Whether the run is a test run' }, + createdAt: { + type: 'string', + description: 'ISO timestamp when the run was created', + nullable: true, + }, + updatedAt: { + type: 'string', + description: 'ISO timestamp when the run was last updated', + nullable: true, + }, + startedAt: { + type: 'string', + description: 'ISO timestamp when the run started executing', + optional: true, + nullable: true, + }, + finishedAt: { + type: 'string', + description: 'ISO timestamp when the run finished', + optional: true, + nullable: true, + }, + delayedUntil: { + type: 'string', + description: 'ISO timestamp the run is delayed until', + optional: true, + nullable: true, + }, + ttl: { + type: 'string', + description: 'Time-to-live before an unstarted run expires', + optional: true, + nullable: true, + }, + expiredAt: { + type: 'string', + description: 'ISO timestamp when the run expired', + optional: true, + nullable: true, + }, + tags: { + type: 'array', + description: 'Tags attached to the run', + items: { type: 'string', description: 'Run tag' }, + }, + costInCents: { + type: 'number', + description: 'Compute cost of the run in cents', + optional: true, + nullable: true, + }, + baseCostInCents: { + type: 'number', + description: 'Base invocation cost of the run in cents', + optional: true, + nullable: true, + }, + durationMs: { + type: 'number', + description: 'Compute duration of the run in milliseconds', + optional: true, + nullable: true, + }, + env: { + type: 'object', + description: 'Environment the run executes in', + optional: true, + nullable: true, + properties: { + id: { type: 'string', description: 'Environment ID', nullable: true }, + name: { type: 'string', description: 'Environment name', nullable: true }, + user: { type: 'string', description: 'Username for dev environments', nullable: true }, + }, + }, +} + +/** + * Output schema for a normalized schedule, shared by the schedule tools. + */ +export const TRIGGER_DEV_SCHEDULE_OUTPUTS: NonNullable = { + id: { type: 'string', description: 'Unique ID of the schedule (starts with sched_)' }, + task: { type: 'string', description: 'Identifier of the task the schedule triggers' }, + type: { + type: 'string', + description: 'Schedule type (DECLARATIVE or IMPERATIVE)', + optional: true, + }, + active: { type: 'boolean', description: 'Whether the schedule is active' }, + deduplicationKey: { + type: 'string', + description: 'Deduplication key of the schedule', + optional: true, + }, + externalId: { + type: 'string', + description: 'External ID associated with the schedule', + optional: true, + }, + cron: { type: 'string', description: 'Cron expression of the schedule', optional: true }, + cronDescription: { + type: 'string', + description: 'Human-readable description of the cron expression', + optional: true, + }, + timezone: { type: 'string', description: 'IANA timezone of the schedule', optional: true }, + nextRun: { + type: 'string', + description: 'ISO timestamp of the next scheduled run', + optional: true, + }, + environments: { + type: 'array', + description: 'Environments the schedule runs in', + items: { + type: 'object', + description: 'Environment the schedule is associated with', + properties: { + id: { type: 'string', description: 'Environment ID', nullable: true }, + type: { type: 'string', description: 'Environment type', nullable: true }, + userName: { type: 'string', description: 'Username for dev environments', nullable: true }, + }, + }, + }, +} + +/** + * Output schema for a normalized run detail, shared by the get run and + * reschedule run tools. + */ +export const TRIGGER_DEV_RUN_DETAIL_OUTPUTS: NonNullable = { + ...TRIGGER_DEV_RUN_SUMMARY_PROPERTIES, + metadata: { + type: 'json', + description: 'Metadata attached to the run', + optional: true, + }, + depth: { + type: 'number', + description: 'Depth of the run in a parent-child run hierarchy', + optional: true, + }, + batchId: { + type: 'string', + description: 'ID of the batch the run belongs to, if batch-triggered', + optional: true, + }, + triggerFunction: { + type: 'string', + description: + 'Function used to trigger the run (trigger, triggerAndWait, batchTrigger, or batchTriggerAndWait)', + optional: true, + }, + payload: { + type: 'json', + description: 'Payload the run was triggered with', + optional: true, + }, + payloadPresignedUrl: { + type: 'string', + description: 'Presigned URL to download the payload when it is too large to inline', + optional: true, + }, + output: { + type: 'json', + description: 'Output returned by the run', + optional: true, + }, + outputPresignedUrl: { + type: 'string', + description: 'Presigned URL to download the output when it is too large to inline', + optional: true, + }, + schedule: { + type: 'object', + description: 'Schedule that triggered the run, if any', + optional: true, + properties: { + id: { type: 'string', description: 'Schedule ID', nullable: true }, + externalId: { type: 'string', description: 'External ID of the schedule', nullable: true }, + deduplicationKey: { + type: 'string', + description: 'Deduplication key of the schedule', + nullable: true, + }, + generator: { + type: 'object', + description: 'Schedule generator details', + nullable: true, + properties: { + type: { type: 'string', description: 'Generator type (e.g., CRON)', nullable: true }, + expression: { type: 'string', description: 'Cron expression', nullable: true }, + description: { + type: 'string', + description: 'Human-readable description of the cron expression', + nullable: true, + }, + }, + }, + }, + }, + attempts: { + type: 'array', + description: 'Attempts made for the run', + items: { + type: 'object', + description: 'Run attempt', + properties: { + id: { type: 'string', description: 'Attempt ID (starts with attempt_)' }, + status: { + type: 'string', + description: + 'Attempt status (PENDING, EXECUTING, PAUSED, COMPLETED, FAILED, or CANCELED)', + }, + createdAt: { + type: 'string', + description: 'ISO timestamp when the attempt was created', + nullable: true, + }, + updatedAt: { + type: 'string', + description: 'ISO timestamp when the attempt was last updated', + nullable: true, + }, + startedAt: { + type: 'string', + description: 'ISO timestamp when the attempt started', + nullable: true, + }, + completedAt: { + type: 'string', + description: 'ISO timestamp when the attempt completed', + nullable: true, + }, + error: { + type: 'object', + description: 'Error details when the attempt failed', + nullable: true, + properties: { + message: { type: 'string', description: 'Error message', nullable: true }, + name: { type: 'string', description: 'Error name', nullable: true }, + stackTrace: { type: 'string', description: 'Error stack trace', nullable: true }, + }, + }, + }, + }, + }, + relatedRuns: { + type: 'object', + description: 'Root, parent, and child runs related to this run', + optional: true, + properties: { + root: { + type: 'object', + description: 'Root run of the hierarchy', + nullable: true, + properties: TRIGGER_DEV_RUN_SUMMARY_PROPERTIES, + }, + parent: { + type: 'object', + description: 'Parent run of this run', + nullable: true, + properties: TRIGGER_DEV_RUN_SUMMARY_PROPERTIES, + }, + children: { + type: 'array', + description: 'Child runs of this run', + items: { + type: 'object', + description: 'Child run', + properties: TRIGGER_DEV_RUN_SUMMARY_PROPERTIES, + }, + }, + }, + }, +} + +/** + * Output schema for a normalized queue, shared by the queue tools. + */ +export const TRIGGER_DEV_QUEUE_OUTPUTS: NonNullable = { + id: { type: 'string', description: 'Unique ID of the queue (starts with queue_)' }, + name: { type: 'string', description: 'Name of the queue' }, + type: { + type: 'string', + description: 'Queue type (task for task-default queues, custom for named queues)', + optional: true, + }, + running: { type: 'number', description: 'Number of runs currently executing', optional: true }, + queued: { type: 'number', description: 'Number of runs waiting in the queue', optional: true }, + paused: { type: 'boolean', description: 'Whether the queue is paused' }, + concurrencyLimit: { + type: 'number', + description: 'Maximum number of runs that can execute concurrently', + optional: true, + }, + concurrency: { + type: 'object', + description: 'Concurrency details for the queue', + optional: true, + properties: { + current: { type: 'number', description: 'Current concurrency limit', nullable: true }, + base: { type: 'number', description: 'Base concurrency limit', nullable: true }, + override: { type: 'number', description: 'Overridden concurrency limit', nullable: true }, + overriddenAt: { + type: 'string', + description: 'ISO timestamp when the concurrency limit was overridden', + nullable: true, + }, + }, + }, +} From b3de6b2f3d34330080d88087cf18df8e76d07d9a Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 11 Jun 2026 12:18:01 -0700 Subject: [PATCH 2/6] feat(integrations): cover the full Trigger.dev management API surface Adds batch retrieve/results, run result/events/trace/tags, queue list and concurrency override/reset, deployments, TRQL query + schema, waitpoint tokens, env var import, and timezones (44 tools total). Marks deduplicationKey required on create schedule and switches list-run filters to the documented comma-separated form, both per the OpenAPI spec. --- .../docs/en/integrations/trigger_dev.mdx | 1107 ++++++++++++++++- apps/sim/blocks/blocks/trigger_dev.ts | 485 +++++++- apps/sim/lib/integrations/integrations.json | 90 +- apps/sim/tools/registry.ts | 42 + apps/sim/tools/trigger_dev/add_run_tags.ts | 64 + .../trigger_dev/complete_waitpoint_token.ts | 68 + apps/sim/tools/trigger_dev/create_schedule.ts | 4 +- .../trigger_dev/create_waitpoint_token.ts | 103 ++ apps/sim/tools/trigger_dev/execute_query.ts | 99 ++ apps/sim/tools/trigger_dev/get_batch.ts | 127 ++ .../tools/trigger_dev/get_batch_results.ts | 68 + apps/sim/tools/trigger_dev/get_deployment.ts | 54 + .../trigger_dev/get_latest_deployment.ts | 43 + .../sim/tools/trigger_dev/get_query_schema.ts | 112 ++ apps/sim/tools/trigger_dev/get_run_events.ts | 145 +++ apps/sim/tools/trigger_dev/get_run_result.ts | 51 + apps/sim/tools/trigger_dev/get_run_trace.ts | 56 + .../tools/trigger_dev/get_waitpoint_token.ts | 54 + apps/sim/tools/trigger_dev/import_env_vars.ts | 89 ++ apps/sim/tools/trigger_dev/index.ts | 21 + .../sim/tools/trigger_dev/list_deployments.ts | 122 ++ apps/sim/tools/trigger_dev/list_queues.ts | 135 ++ apps/sim/tools/trigger_dev/list_runs.ts | 20 +- apps/sim/tools/trigger_dev/list_timezones.ts | 59 + .../trigger_dev/list_waitpoint_tokens.ts | 152 +++ .../trigger_dev/override_queue_concurrency.ts | 71 ++ .../tools/trigger_dev/promote_deployment.ts | 65 + .../trigger_dev/reset_queue_concurrency.ts | 60 + apps/sim/tools/trigger_dev/types.ts | 382 +++++- apps/sim/tools/trigger_dev/utils.ts | 271 ++++ 30 files changed, 4153 insertions(+), 66 deletions(-) create mode 100644 apps/sim/tools/trigger_dev/add_run_tags.ts create mode 100644 apps/sim/tools/trigger_dev/complete_waitpoint_token.ts create mode 100644 apps/sim/tools/trigger_dev/create_waitpoint_token.ts create mode 100644 apps/sim/tools/trigger_dev/execute_query.ts create mode 100644 apps/sim/tools/trigger_dev/get_batch.ts create mode 100644 apps/sim/tools/trigger_dev/get_batch_results.ts create mode 100644 apps/sim/tools/trigger_dev/get_deployment.ts create mode 100644 apps/sim/tools/trigger_dev/get_latest_deployment.ts create mode 100644 apps/sim/tools/trigger_dev/get_query_schema.ts create mode 100644 apps/sim/tools/trigger_dev/get_run_events.ts create mode 100644 apps/sim/tools/trigger_dev/get_run_result.ts create mode 100644 apps/sim/tools/trigger_dev/get_run_trace.ts create mode 100644 apps/sim/tools/trigger_dev/get_waitpoint_token.ts create mode 100644 apps/sim/tools/trigger_dev/import_env_vars.ts create mode 100644 apps/sim/tools/trigger_dev/list_deployments.ts create mode 100644 apps/sim/tools/trigger_dev/list_queues.ts create mode 100644 apps/sim/tools/trigger_dev/list_timezones.ts create mode 100644 apps/sim/tools/trigger_dev/list_waitpoint_tokens.ts create mode 100644 apps/sim/tools/trigger_dev/override_queue_concurrency.ts create mode 100644 apps/sim/tools/trigger_dev/promote_deployment.ts create mode 100644 apps/sim/tools/trigger_dev/reset_queue_concurrency.ts diff --git a/apps/docs/content/docs/en/integrations/trigger_dev.mdx b/apps/docs/content/docs/en/integrations/trigger_dev.mdx index 1adf4d146b..165b931c05 100644 --- a/apps/docs/content/docs/en/integrations/trigger_dev.mdx +++ b/apps/docs/content/docs/en/integrations/trigger_dev.mdx @@ -28,7 +28,7 @@ In Sim, the Trigger.dev integration lets your agents drive this entire lifecycle ## Usage Instructions -Integrate Trigger.dev into the workflow. Trigger and batch trigger background tasks with a JSON payload, retrieve and list runs, cancel, replay, or reschedule runs, manage cron schedules, environment variables, and queues. +Integrate Trigger.dev into the workflow. Trigger and batch trigger background tasks, retrieve and control runs (cancel, replay, reschedule, tags, metadata, events, traces), manage cron schedules, environment variables, queues, deployments, and waitpoint tokens, and query run data with TRQL. @@ -78,6 +78,54 @@ Batch trigger a Trigger.dev task with up to 1,000 payloads. All items in the bat | `batchId` | string | ID of the batch that was triggered | | `runIds` | array | IDs of the runs created by the batch | +### `trigger_dev_get_batch` + +Retrieve a Trigger.dev batch by its ID, including its status, run IDs, and success and failure counts. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `batchId` | string | Yes | ID of the batch to retrieve \(starts with batch_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | ID of the batch \(starts with batch_\) | +| `status` | string | Batch status \(PENDING, PROCESSING, COMPLETED, PARTIAL_FAILED, or ABORTED\) | +| `idempotencyKey` | string | Idempotency key provided when triggering the batch | +| `createdAt` | string | ISO timestamp when the batch was created | +| `updatedAt` | string | ISO timestamp when the batch was last updated | +| `runCount` | number | Total number of runs in the batch | +| `runIds` | array | IDs of the runs in the batch | +| `successfulRunCount` | number | Number of successful runs, populated after completion | +| `failedRunCount` | number | Number of failed runs, populated after completion | +| `errors` | array | Error details for failed items, present for PARTIAL_FAILED batches | +| ↳ `index` | number | Index of the failed item | +| ↳ `taskIdentifier` | string | Task identifier of the failed item | +| ↳ `error` | json | Error details | +| ↳ `errorCode` | string | Optional error code | + +### `trigger_dev_get_batch_results` + +Retrieve the execution results of every run in a Trigger.dev batch, including outputs and error details. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `batchId` | string | Yes | ID of the batch to retrieve results for \(starts with batch_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | ID of the batch \(starts with batch_\) | +| `items` | array | Execution results for each run in the batch | + ### `trigger_dev_get_run` Retrieve a Trigger.dev run by its ID, including status, payload, output, attempts, and timing details. @@ -95,7 +143,89 @@ Retrieve a Trigger.dev run by its ID, including status, payload, output, attempt | --------- | ---- | ----------- | | `id` | string | Run, schedule, or queue ID | | `batchId` | string | Batch ID \(Batch Trigger Task\) | -| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | + +### `trigger_dev_get_run_result` + +Retrieve the result of a Trigger.dev run: whether it succeeded, its output, and error details. Lighter than Get Run when only the outcome is needed. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `runId` | string | Yes | ID of the run to retrieve the result for \(starts with run_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | | `status` | string | Run status \(Get Run\) | | `taskIdentifier` | string | Task identifier of the run \(Get Run\) | | `createdAt` | string | When the run was created \(Get Run\) | @@ -109,6 +239,13 @@ Retrieve a Trigger.dev run by its ID, including status, payload, output, attempt | `output` | json | Output returned by the run \(Get Run\) | | `attempts` | json | Attempts made for the run \(Get Run\) | | `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | | `runs` | json | Runs matching the filters \(List Runs\) | | `schedules` | json | Schedules in the project \(List Schedules\) | | `pagination` | json | Pagination details \(list operations\) | @@ -123,12 +260,76 @@ Retrieve a Trigger.dev run by its ID, including status, payload, output, attempt | `variables` | json | Environment variables in the project environment \(List Env Vars\) | | `name` | string | Environment variable or queue name \(env var and queue operations\) | | `value` | string | Value of the environment variable \(Get Env Var\) | -| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | | `running` | number | Runs currently executing \(queue operations\) | | `queued` | number | Runs waiting in the queue \(queue operations\) | | `paused` | boolean | Whether the queue is paused \(queue operations\) | | `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | | `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | + +### `trigger_dev_get_run_events` + +Retrieve the log and span events of a Trigger.dev run, including messages, levels, durations, and error events. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `runId` | string | Yes | ID of the run to retrieve events for \(starts with run_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `events` | array | Log and span events recorded during the run | +| ↳ `spanId` | string | Span ID of the event | +| ↳ `parentId` | string | Parent span ID | +| ↳ `runId` | string | Run ID associated with the event | +| ↳ `message` | string | Event message | +| ↳ `startTime` | string | Start time as a bigint string \(nanoseconds since epoch\) | +| ↳ `duration` | number | Duration of the event in nanoseconds | +| ↳ `isError` | boolean | Whether the event represents an error | +| ↳ `isPartial` | boolean | Whether the event is still in progress | +| ↳ `isCancelled` | boolean | Whether the event was cancelled | +| ↳ `level` | string | Log level \(TRACE, DEBUG, LOG, INFO, WARN, or ERROR\) | +| ↳ `kind` | string | Kind of span event | +| ↳ `attemptNumber` | number | Attempt number the event belongs to | +| ↳ `taskSlug` | string | Task identifier | +| ↳ `events` | array | Span events \(e.g., exceptions\) that occurred during this event | +| ↳ `name` | string | Event name | +| ↳ `time` | string | When the event occurred | + +### `trigger_dev_get_run_trace` + +Retrieve the OpenTelemetry trace of a Trigger.dev run as a tree of spans with timing, errors, and nested children. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `runId` | string | Yes | ID of the run to retrieve the trace for \(starts with run_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `traceId` | string | OpenTelemetry trace ID of the run | +| `rootSpan` | json | Root span of the trace; each span has id, parentId, runId, data \(message, taskSlug, startTime, duration, isError, level, events\), and recursively nested children spans | ### `trigger_dev_list_runs` @@ -213,7 +414,12 @@ Reschedule a delayed Trigger.dev run with a new delay. Only valid while the run | --------- | ---- | ----------- | | `id` | string | Run, schedule, or queue ID | | `batchId` | string | Batch ID \(Batch Trigger Task\) | -| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | | `status` | string | Run status \(Get Run\) | | `taskIdentifier` | string | Task identifier of the run \(Get Run\) | | `createdAt` | string | When the run was created \(Get Run\) | @@ -227,6 +433,13 @@ Reschedule a delayed Trigger.dev run with a new delay. Only valid while the run | `output` | json | Output returned by the run \(Get Run\) | | `attempts` | json | Attempts made for the run \(Get Run\) | | `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | | `runs` | json | Runs matching the filters \(List Runs\) | | `schedules` | json | Schedules in the project \(List Schedules\) | | `pagination` | json | Pagination details \(list operations\) | @@ -241,12 +454,43 @@ Reschedule a delayed Trigger.dev run with a new delay. Only valid while the run | `variables` | json | Environment variables in the project environment \(List Env Vars\) | | `name` | string | Environment variable or queue name \(env var and queue operations\) | | `value` | string | Value of the environment variable \(Get Env Var\) | -| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | | `running` | number | Runs currently executing \(queue operations\) | | `queued` | number | Runs waiting in the queue \(queue operations\) | | `paused` | boolean | Whether the queue is paused \(queue operations\) | | `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | | `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | + +### `trigger_dev_add_run_tags` + +Add tags to an existing Trigger.dev run. Runs can have up to 10 tags. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `runId` | string | Yes | ID of the run to tag \(starts with run_\) | +| `tags` | string | Yes | Comma-separated tags to add to the run \(max 10 total, each under 128 characters\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `message` | string | Confirmation message for the added tags | ### `trigger_dev_update_run_metadata` @@ -279,7 +523,7 @@ Create an imperative cron schedule that triggers a Trigger.dev task on a recurri | `cron` | string | Yes | Cron expression defining when the task runs \(e.g., "0 0 * * *"\) | | `timezone` | string | No | IANA timezone the cron expression is evaluated in \(e.g., "America/New_York"\). Defaults to UTC | | `externalId` | string | No | External identifier to associate with the schedule \(e.g., a user ID\) | -| `deduplicationKey` | string | No | Key that prevents duplicate schedules; creating again with the same key updates the existing schedule | +| `deduplicationKey` | string | Yes | Key that prevents duplicate schedules; creating again with the same key updates the existing schedule | #### Output @@ -287,7 +531,12 @@ Create an imperative cron schedule that triggers a Trigger.dev task on a recurri | --------- | ---- | ----------- | | `id` | string | Run, schedule, or queue ID | | `batchId` | string | Batch ID \(Batch Trigger Task\) | -| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | | `status` | string | Run status \(Get Run\) | | `taskIdentifier` | string | Task identifier of the run \(Get Run\) | | `createdAt` | string | When the run was created \(Get Run\) | @@ -301,6 +550,13 @@ Create an imperative cron schedule that triggers a Trigger.dev task on a recurri | `output` | json | Output returned by the run \(Get Run\) | | `attempts` | json | Attempts made for the run \(Get Run\) | | `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | | `runs` | json | Runs matching the filters \(List Runs\) | | `schedules` | json | Schedules in the project \(List Schedules\) | | `pagination` | json | Pagination details \(list operations\) | @@ -315,12 +571,25 @@ Create an imperative cron schedule that triggers a Trigger.dev task on a recurri | `variables` | json | Environment variables in the project environment \(List Env Vars\) | | `name` | string | Environment variable or queue name \(env var and queue operations\) | | `value` | string | Value of the environment variable \(Get Env Var\) | -| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | | `running` | number | Runs currently executing \(queue operations\) | | `queued` | number | Runs waiting in the queue \(queue operations\) | | `paused` | boolean | Whether the queue is paused \(queue operations\) | | `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | | `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | ### `trigger_dev_get_schedule` @@ -339,7 +608,12 @@ Retrieve a Trigger.dev schedule by its ID. | --------- | ---- | ----------- | | `id` | string | Run, schedule, or queue ID | | `batchId` | string | Batch ID \(Batch Trigger Task\) | -| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | | `status` | string | Run status \(Get Run\) | | `taskIdentifier` | string | Task identifier of the run \(Get Run\) | | `createdAt` | string | When the run was created \(Get Run\) | @@ -353,6 +627,13 @@ Retrieve a Trigger.dev schedule by its ID. | `output` | json | Output returned by the run \(Get Run\) | | `attempts` | json | Attempts made for the run \(Get Run\) | | `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | | `runs` | json | Runs matching the filters \(List Runs\) | | `schedules` | json | Schedules in the project \(List Schedules\) | | `pagination` | json | Pagination details \(list operations\) | @@ -367,12 +648,25 @@ Retrieve a Trigger.dev schedule by its ID. | `variables` | json | Environment variables in the project environment \(List Env Vars\) | | `name` | string | Environment variable or queue name \(env var and queue operations\) | | `value` | string | Value of the environment variable \(Get Env Var\) | -| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | | `running` | number | Runs currently executing \(queue operations\) | | `queued` | number | Runs waiting in the queue \(queue operations\) | | `paused` | boolean | Whether the queue is paused \(queue operations\) | | `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | | `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | ### `trigger_dev_list_schedules` @@ -431,7 +725,12 @@ Update an imperative Trigger.dev schedule by its ID, replacing its task, cron ex | --------- | ---- | ----------- | | `id` | string | Run, schedule, or queue ID | | `batchId` | string | Batch ID \(Batch Trigger Task\) | -| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | | `status` | string | Run status \(Get Run\) | | `taskIdentifier` | string | Task identifier of the run \(Get Run\) | | `createdAt` | string | When the run was created \(Get Run\) | @@ -445,6 +744,13 @@ Update an imperative Trigger.dev schedule by its ID, replacing its task, cron ex | `output` | json | Output returned by the run \(Get Run\) | | `attempts` | json | Attempts made for the run \(Get Run\) | | `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | | `runs` | json | Runs matching the filters \(List Runs\) | | `schedules` | json | Schedules in the project \(List Schedules\) | | `pagination` | json | Pagination details \(list operations\) | @@ -459,12 +765,25 @@ Update an imperative Trigger.dev schedule by its ID, replacing its task, cron ex | `variables` | json | Environment variables in the project environment \(List Env Vars\) | | `name` | string | Environment variable or queue name \(env var and queue operations\) | | `value` | string | Value of the environment variable \(Get Env Var\) | -| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | | `running` | number | Runs currently executing \(queue operations\) | | `queued` | number | Runs waiting in the queue \(queue operations\) | | `paused` | boolean | Whether the queue is paused \(queue operations\) | | `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | | `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | ### `trigger_dev_delete_schedule` @@ -501,7 +820,12 @@ Activate an imperative Trigger.dev schedule so it resumes triggering its task. | --------- | ---- | ----------- | | `id` | string | Run, schedule, or queue ID | | `batchId` | string | Batch ID \(Batch Trigger Task\) | -| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | | `status` | string | Run status \(Get Run\) | | `taskIdentifier` | string | Task identifier of the run \(Get Run\) | | `createdAt` | string | When the run was created \(Get Run\) | @@ -515,6 +839,13 @@ Activate an imperative Trigger.dev schedule so it resumes triggering its task. | `output` | json | Output returned by the run \(Get Run\) | | `attempts` | json | Attempts made for the run \(Get Run\) | | `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | | `runs` | json | Runs matching the filters \(List Runs\) | | `schedules` | json | Schedules in the project \(List Schedules\) | | `pagination` | json | Pagination details \(list operations\) | @@ -529,12 +860,25 @@ Activate an imperative Trigger.dev schedule so it resumes triggering its task. | `variables` | json | Environment variables in the project environment \(List Env Vars\) | | `name` | string | Environment variable or queue name \(env var and queue operations\) | | `value` | string | Value of the environment variable \(Get Env Var\) | -| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | | `running` | number | Runs currently executing \(queue operations\) | | `queued` | number | Runs waiting in the queue \(queue operations\) | | `paused` | boolean | Whether the queue is paused \(queue operations\) | | `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | | `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | ### `trigger_dev_deactivate_schedule` @@ -553,7 +897,12 @@ Deactivate an imperative Trigger.dev schedule so it stops triggering its task. | --------- | ---- | ----------- | | `id` | string | Run, schedule, or queue ID | | `batchId` | string | Batch ID \(Batch Trigger Task\) | -| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | | `status` | string | Run status \(Get Run\) | | `taskIdentifier` | string | Task identifier of the run \(Get Run\) | | `createdAt` | string | When the run was created \(Get Run\) | @@ -567,6 +916,13 @@ Deactivate an imperative Trigger.dev schedule so it stops triggering its task. | `output` | json | Output returned by the run \(Get Run\) | | `attempts` | json | Attempts made for the run \(Get Run\) | | `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | | `runs` | json | Runs matching the filters \(List Runs\) | | `schedules` | json | Schedules in the project \(List Schedules\) | | `pagination` | json | Pagination details \(list operations\) | @@ -581,12 +937,25 @@ Deactivate an imperative Trigger.dev schedule so it stops triggering its task. | `variables` | json | Environment variables in the project environment \(List Env Vars\) | | `name` | string | Environment variable or queue name \(env var and queue operations\) | | `value` | string | Value of the environment variable \(Get Env Var\) | -| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | | `running` | number | Runs currently executing \(queue operations\) | | `queued` | number | Runs waiting in the queue \(queue operations\) | | `paused` | boolean | Whether the queue is paused \(queue operations\) | | `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | | `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | ### `trigger_dev_list_env_vars` @@ -690,6 +1059,27 @@ Delete an environment variable from a Trigger.dev project environment. | `success` | boolean | Whether the environment variable was deleted | | `name` | string | Name of the environment variable that was deleted | +### `trigger_dev_import_env_vars` + +Upload multiple environment variables to a Trigger.dev project environment in one request. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `projectRef` | string | Yes | External ref of the project, from the project settings \(starts with proj_\) | +| `environment` | string | Yes | Environment to upload the variables to: dev, staging, or prod | +| `variables` | json | Yes | JSON array of environment variables to upload. Example: \[\{"name": "SLACK_API_KEY", "value": "slack_123"\}\] | +| `override` | string | No | Whether to override existing variables: "true" or "false" \(default false\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether the environment variables were uploaded | +| `count` | number | Number of environment variables submitted | + ### `trigger_dev_get_queue` Retrieve a Trigger.dev queue by ID, task identifier, or custom queue name, including its running and queued counts. @@ -708,7 +1098,12 @@ Retrieve a Trigger.dev queue by ID, task identifier, or custom queue name, inclu | --------- | ---- | ----------- | | `id` | string | Run, schedule, or queue ID | | `batchId` | string | Batch ID \(Batch Trigger Task\) | -| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | | `status` | string | Run status \(Get Run\) | | `taskIdentifier` | string | Task identifier of the run \(Get Run\) | | `createdAt` | string | When the run was created \(Get Run\) | @@ -722,6 +1117,13 @@ Retrieve a Trigger.dev queue by ID, task identifier, or custom queue name, inclu | `output` | json | Output returned by the run \(Get Run\) | | `attempts` | json | Attempts made for the run \(Get Run\) | | `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | | `runs` | json | Runs matching the filters \(List Runs\) | | `schedules` | json | Schedules in the project \(List Schedules\) | | `pagination` | json | Pagination details \(list operations\) | @@ -736,12 +1138,59 @@ Retrieve a Trigger.dev queue by ID, task identifier, or custom queue name, inclu | `variables` | json | Environment variables in the project environment \(List Env Vars\) | | `name` | string | Environment variable or queue name \(env var and queue operations\) | | `value` | string | Value of the environment variable \(Get Env Var\) | -| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | | `running` | number | Runs currently executing \(queue operations\) | | `queued` | number | Runs waiting in the queue \(queue operations\) | | `paused` | boolean | Whether the queue is paused \(queue operations\) | | `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | | `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | + +### `trigger_dev_list_queues` + +List the queues in the environment of the API key, including running and queued counts, with page-based pagination. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `page` | number | No | Page number to return \(default 1\) | +| `perPage` | number | No | Number of queues per page | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `queues` | array | Queues in the environment | +| ↳ `id` | string | Unique ID of the queue \(starts with queue_\) | +| ↳ `name` | string | Name of the queue | +| ↳ `type` | string | Queue type \(task for task-default queues, custom for named queues\) | +| ↳ `running` | number | Number of runs currently executing | +| ↳ `queued` | number | Number of runs waiting in the queue | +| ↳ `paused` | boolean | Whether the queue is paused | +| ↳ `concurrencyLimit` | number | Maximum number of runs that can execute concurrently | +| ↳ `concurrency` | object | Concurrency details for the queue | +| ↳ `current` | number | Current concurrency limit | +| ↳ `base` | number | Base concurrency limit | +| ↳ `override` | number | Overridden concurrency limit | +| ↳ `overriddenAt` | string | ISO timestamp when the concurrency limit was overridden | +| `pagination` | object | Page-based pagination details | +| ↳ `currentPage` | number | Current page number | +| ↳ `totalPages` | number | Total number of pages | +| ↳ `count` | number | Total number of queues | ### `trigger_dev_pause_queue` @@ -761,7 +1210,12 @@ Pause a Trigger.dev queue so no new runs start. Runs that are currently executin | --------- | ---- | ----------- | | `id` | string | Run, schedule, or queue ID | | `batchId` | string | Batch ID \(Batch Trigger Task\) | -| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | | `status` | string | Run status \(Get Run\) | | `taskIdentifier` | string | Task identifier of the run \(Get Run\) | | `createdAt` | string | When the run was created \(Get Run\) | @@ -775,6 +1229,13 @@ Pause a Trigger.dev queue so no new runs start. Runs that are currently executin | `output` | json | Output returned by the run \(Get Run\) | | `attempts` | json | Attempts made for the run \(Get Run\) | | `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | | `runs` | json | Runs matching the filters \(List Runs\) | | `schedules` | json | Schedules in the project \(List Schedules\) | | `pagination` | json | Pagination details \(list operations\) | @@ -789,12 +1250,25 @@ Pause a Trigger.dev queue so no new runs start. Runs that are currently executin | `variables` | json | Environment variables in the project environment \(List Env Vars\) | | `name` | string | Environment variable or queue name \(env var and queue operations\) | | `value` | string | Value of the environment variable \(Get Env Var\) | -| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | | `running` | number | Runs currently executing \(queue operations\) | | `queued` | number | Runs waiting in the queue \(queue operations\) | | `paused` | boolean | Whether the queue is paused \(queue operations\) | | `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | | `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | ### `trigger_dev_resume_queue` @@ -814,7 +1288,346 @@ Resume a paused Trigger.dev queue so new runs can start again. | --------- | ---- | ----------- | | `id` | string | Run, schedule, or queue ID | | `batchId` | string | Batch ID \(Batch Trigger Task\) | -| `runIds` | json | IDs of the created runs \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | + +### `trigger_dev_override_queue_concurrency` + +Override the concurrency limit of a Trigger.dev queue with a new value. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `queueName` | string | Yes | Queue ID \(starts with queue_\), task identifier, or custom queue name, depending on the queue type | +| `queueType` | string | No | How to interpret the queue name: "id" \(default\) for a queue ID, "task" for a task identifier, or "custom" for a custom queue name | +| `concurrencyLimit` | number | Yes | New concurrency limit for the queue \(0 to 100000\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | + +### `trigger_dev_reset_queue_concurrency` + +Reset the concurrency limit of a Trigger.dev queue back to its base value, removing any override. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `queueName` | string | Yes | Queue ID \(starts with queue_\), task identifier, or custom queue name, depending on the queue type | +| `queueType` | string | No | How to interpret the queue name: "id" \(default\) for a queue ID, "task" for a task identifier, or "custom" for a custom queue name | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | + +### `trigger_dev_list_deployments` + +List Trigger.dev deployments in the environment of the API key, with optional status and creation-time filters. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `status` | string | No | Deployment status to filter by: PENDING, BUILDING, DEPLOYING, DEPLOYED, FAILED, CANCELED, or TIMED_OUT | +| `period` | string | No | Only return deployments created in the given period \(e.g., "1h", "7d"\) | +| `from` | string | No | Only return deployments created on or after this ISO 8601 timestamp | +| `to` | string | No | Only return deployments created on or before this ISO 8601 timestamp | +| `pageSize` | number | No | Number of deployments per page \(5 to 100, default 20\) | +| `pageAfter` | string | No | Cursor to start the page after, from the previous response pagination | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `deployments` | array | Deployments matching the filters | +| `pagination` | object | Cursor pagination details | +| ↳ `next` | string | Cursor to pass as the page-after parameter for the next page | + +### `trigger_dev_get_deployment` + +Retrieve a Trigger.dev deployment by its ID, including its status, version, and registered tasks. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `deploymentId` | string | Yes | ID of the deployment to retrieve | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | + +### `trigger_dev_get_latest_deployment` + +Retrieve the latest Trigger.dev deployment in the environment of the API key. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | | `status` | string | Run status \(Get Run\) | | `taskIdentifier` | string | Task identifier of the run \(Get Run\) | | `createdAt` | string | When the run was created \(Get Run\) | @@ -828,6 +1641,13 @@ Resume a paused Trigger.dev queue so new runs can start again. | `output` | json | Output returned by the run \(Get Run\) | | `attempts` | json | Attempts made for the run \(Get Run\) | | `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | | `runs` | json | Runs matching the filters \(List Runs\) | | `schedules` | json | Schedules in the project \(List Schedules\) | | `pagination` | json | Pagination details \(list operations\) | @@ -842,11 +1662,254 @@ Resume a paused Trigger.dev queue so new runs can start again. | `variables` | json | Environment variables in the project environment \(List Env Vars\) | | `name` | string | Environment variable or queue name \(env var and queue operations\) | | `value` | string | Value of the environment variable \(Get Env Var\) | -| `success` | boolean | Whether the env var operation succeeded \(Create/Update/Delete Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | | `running` | number | Runs currently executing \(queue operations\) | | `queued` | number | Runs waiting in the queue \(queue operations\) | | `paused` | boolean | Whether the queue is paused \(queue operations\) | | `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | | `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | + +### `trigger_dev_promote_deployment` + +Promote a Trigger.dev deployment version so new runs execute on it (e.g., to roll back to a previous version). + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `version` | string | Yes | Deployment version to promote \(e.g., "20250228.1"\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | ID of the promoted deployment | +| `version` | string | Version of the promoted deployment | +| `shortCode` | string | Short code of the promoted deployment | + +### `trigger_dev_execute_query` + +Execute a TRQL (SQL-like) query against Trigger.dev run data for reporting and analytics. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `query` | string | Yes | TRQL query to execute \(e.g., "SELECT run_id, status, triggered_at FROM runs WHERE status = \'Failed\' LIMIT 10"\) | +| `scope` | string | No | Scope of data to query: environment \(default\), project, or organization | +| `period` | string | No | Time period shorthand \(e.g., "1h", "7d", "30d"\). Cannot be combined with from/to | +| `from` | string | No | Start of the time range as an ISO 8601 timestamp. Must be used with "to" | +| `to` | string | No | End of the time range as an ISO 8601 timestamp. Must be used with "from" | +| `format` | string | No | Response format: "json" \(default\) for structured rows or "csv" for a CSV string | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `format` | string | Format of the results \(json or csv\) | +| `results` | json | Query results: an array of row objects for json format, a CSV string for csv | + +### `trigger_dev_get_query_schema` + +Retrieve the TRQL query schema: the tables and columns available for Execute Query, with types and allowed values. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `tables` | array | Tables that can be queried with TRQL | +| ↳ `name` | string | Table name used in TRQL queries | +| ↳ `description` | string | Description of the table | +| ↳ `timeColumn` | string | Primary time column for the table | +| ↳ `columns` | array | Columns of the table | +| ↳ `name` | string | Column name | +| ↳ `type` | string | ClickHouse data type | +| ↳ `description` | string | Column description | +| ↳ `example` | string | Example value | +| ↳ `allowedValues` | array | Allowed values for enum-like columns | +| ↳ `coreColumn` | boolean | Whether the column is included in default queries | + +### `trigger_dev_create_waitpoint_token` + +Create a Trigger.dev waitpoint token that a task can wait on until it is completed from outside (e.g., a human approval). + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `timeout` | string | No | How long before the token times out, as a duration \("30s", "1m", "2h", "3d"\) or an ISO 8601 date | +| `idempotencyKey` | string | No | Idempotency key; passing the same key before it expires returns the original token | +| `idempotencyKeyTTL` | string | No | How long the idempotency key is valid, as a duration \("30s", "1m", "2h", "3d"\) | +| `tags` | string | No | Comma-separated tags to attach to the waitpoint \(max 10, each under 128 characters\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Unique ID of the waitpoint token \(starts with waitpoint_\) | +| `isCached` | boolean | Whether an existing token was returned because the same idempotency key was reused | +| `url` | string | HTTP callback URL; a POST request to this URL completes the waitpoint without an API key | + +### `trigger_dev_complete_waitpoint_token` + +Complete a Trigger.dev waitpoint token, resuming any task waiting on it and passing it optional JSON data. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `waitpointId` | string | Yes | ID of the waitpoint token to complete \(starts with waitpoint_\) | +| `data` | json | No | JSON data passed back to the waiting run as the token result. Example: \{"status": "approved"\} | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether the waitpoint token was completed | + +### `trigger_dev_get_waitpoint_token` + +Retrieve a Trigger.dev waitpoint token by its ID, including its status, timeout, and completion data. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `waitpointId` | string | Yes | ID of the waitpoint token to retrieve \(starts with waitpoint_\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Run, schedule, or queue ID | +| `batchId` | string | Batch ID \(Batch Trigger Task\) | +| `runIds` | json | Run IDs in the batch \(batch operations\) | +| `runCount` | number | Total number of runs in the batch \(Get Batch\) | +| `successfulRunCount` | number | Number of successful runs in the batch \(Get Batch\) | +| `failedRunCount` | number | Number of failed runs in the batch \(Get Batch\) | +| `errors` | json | Error details for failed batch items \(Get Batch\) | +| `items` | json | Execution results for each run in the batch \(Get Batch Results\) | +| `status` | string | Run status \(Get Run\) | +| `taskIdentifier` | string | Task identifier of the run \(Get Run\) | +| `createdAt` | string | When the run was created \(Get Run\) | +| `startedAt` | string | When the run started \(Get Run\) | +| `finishedAt` | string | When the run finished \(Get Run\) | +| `durationMs` | number | Compute duration in milliseconds \(Get Run\) | +| `costInCents` | number | Compute cost in cents \(Get Run\) | +| `isTest` | boolean | Whether the run is a test run \(Get Run\) | +| `tags` | json | Tags attached to the run \(Get Run\) | +| `payload` | json | Payload the run was triggered with \(Get Run\) | +| `output` | json | Output returned by the run \(Get Run\) | +| `attempts` | json | Attempts made for the run \(Get Run\) | +| `metadata` | json | Run metadata \(Get Run, Update Run Metadata\) | +| `ok` | boolean | Whether the run succeeded \(Get Run Result\) | +| `outputType` | string | Content type of the run output \(Get Run Result\) | +| `error` | json | Error details for a failed run \(Get Run Result\) | +| `message` | string | Confirmation message \(Add Run Tags\) | +| `events` | json | Log and span events of the run \(Get Run Events\) | +| `traceId` | string | OpenTelemetry trace ID \(Get Run Trace\) | +| `rootSpan` | json | Root span of the run trace \(Get Run Trace\) | +| `runs` | json | Runs matching the filters \(List Runs\) | +| `schedules` | json | Schedules in the project \(List Schedules\) | +| `pagination` | json | Pagination details \(list operations\) | +| `task` | string | Task the schedule triggers \(schedule operations\) | +| `active` | boolean | Whether the schedule is active \(schedule operations\) | +| `cron` | string | Cron expression \(schedule operations\) | +| `cronDescription` | string | Human-readable cron description \(schedule operations\) | +| `timezone` | string | Timezone of the schedule \(schedule operations\) | +| `nextRun` | string | Next scheduled run time \(schedule operations\) | +| `environments` | json | Environments the schedule runs in \(schedule operations\) | +| `deleted` | boolean | Whether the schedule was deleted \(Delete Schedule\) | +| `variables` | json | Environment variables in the project environment \(List Env Vars\) | +| `name` | string | Environment variable or queue name \(env var and queue operations\) | +| `value` | string | Value of the environment variable \(Get Env Var\) | +| `success` | boolean | Whether the operation succeeded \(env var operations, Complete Waitpoint Token\) | +| `count` | number | Number of environment variables submitted \(Import Env Vars\) | +| `queues` | json | Queues in the environment \(List Queues\) | +| `running` | number | Runs currently executing \(queue operations\) | +| `queued` | number | Runs waiting in the queue \(queue operations\) | +| `paused` | boolean | Whether the queue is paused \(queue operations\) | +| `concurrencyLimit` | number | Concurrency limit of the queue \(queue operations\) | +| `concurrency` | json | Concurrency details of the queue \(queue operations\) | +| `deployments` | json | Deployments matching the filters \(List Deployments\) | +| `version` | string | Deployment version \(deployment operations\) | +| `shortCode` | string | Deployment short code \(deployment operations\) | +| `tasks` | json | Tasks registered by the deployed worker \(deployment operations\) | +| `format` | string | Format of the query results \(Execute Query\) | +| `results` | json | Query results \(Execute Query\) | +| `tables` | json | Queryable TRQL tables and columns \(Get Query Schema\) | +| `tokens` | json | Waitpoint tokens \(List Waitpoint Tokens\) | +| `url` | string | Waitpoint callback URL \(waitpoint operations\) | +| `isCached` | boolean | Whether an existing token was returned \(Create Waitpoint Token\) | +| `timezones` | json | Supported IANA timezones \(List Timezones\) | + +### `trigger_dev_list_waitpoint_tokens` + +List Trigger.dev waitpoint tokens in the environment of the API key, with optional status, tag, and creation-time filters. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `status` | string | No | Waitpoint status to filter by: WAITING, COMPLETED, or TIMED_OUT | +| `idempotencyKey` | string | No | Idempotency key to filter by | +| `tags` | string | No | Comma-separated tags to filter by | +| `period` | string | No | Only return tokens created in the given period \(e.g., "1h", "7d"\) | +| `from` | string | No | Only return tokens created on or after this ISO 8601 timestamp | +| `to` | string | No | Only return tokens created on or before this ISO 8601 timestamp | +| `pageSize` | number | No | Number of tokens per page \(max 100\) | +| `pageAfter` | string | No | Waitpoint ID to start the page after, for forward pagination | +| `pageBefore` | string | No | Waitpoint ID to start the page before, for backward pagination | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `tokens` | array | Waitpoint tokens matching the filters | +| `pagination` | object | Cursor pagination details | +| ↳ `next` | string | Waitpoint ID to start the next page after | +| ↳ `previous` | string | Waitpoint ID to start the previous page before | + +### `trigger_dev_list_timezones` + +List the IANA timezones supported by Trigger.dev schedules, for use as the timezone of a cron schedule. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | Trigger.dev secret API key \(starts with tr_\) | +| `excludeUtc` | string | No | Set to "true" to exclude UTC from the returned timezones | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `timezones` | array | IANA timezones supported by schedules | diff --git a/apps/sim/blocks/blocks/trigger_dev.ts b/apps/sim/blocks/blocks/trigger_dev.ts index 9c058c1219..9e54d425dd 100644 --- a/apps/sim/blocks/blocks/trigger_dev.ts +++ b/apps/sim/blocks/blocks/trigger_dev.ts @@ -6,17 +6,23 @@ import type { TriggerDevResponse } from '@/tools/trigger_dev/types' const TASK_IDENTIFIER_OPERATIONS = ['trigger_dev_trigger_task', 'trigger_dev_batch_trigger_task'] const RUN_ID_OPERATIONS = [ 'trigger_dev_get_run', + 'trigger_dev_get_run_result', + 'trigger_dev_get_run_events', + 'trigger_dev_get_run_trace', 'trigger_dev_cancel_run', 'trigger_dev_replay_run', 'trigger_dev_reschedule_run', + 'trigger_dev_add_run_tags', 'trigger_dev_update_run_metadata', ] +const BATCH_ID_OPERATIONS = ['trigger_dev_get_batch', 'trigger_dev_get_batch_results'] const ENV_VAR_OPERATIONS = [ 'trigger_dev_list_env_vars', 'trigger_dev_create_env_var', 'trigger_dev_get_env_var', 'trigger_dev_update_env_var', 'trigger_dev_delete_env_var', + 'trigger_dev_import_env_vars', ] const ENV_VAR_NAME_OPERATIONS = [ 'trigger_dev_create_env_var', @@ -29,6 +35,8 @@ const QUEUE_OPERATIONS = [ 'trigger_dev_get_queue', 'trigger_dev_pause_queue', 'trigger_dev_resume_queue', + 'trigger_dev_override_queue_concurrency', + 'trigger_dev_reset_queue_concurrency', ] const SCHEDULE_ID_OPERATIONS = [ 'trigger_dev_get_schedule', @@ -41,6 +49,28 @@ const SCHEDULE_DEFINITION_OPERATIONS = [ 'trigger_dev_create_schedule', 'trigger_dev_update_schedule', ] +const WAITPOINT_ID_OPERATIONS = [ + 'trigger_dev_get_waitpoint_token', + 'trigger_dev_complete_waitpoint_token', +] +const IDEMPOTENCY_KEY_OPERATIONS = [ + 'trigger_dev_trigger_task', + 'trigger_dev_create_waitpoint_token', +] +const TAGS_OPERATIONS = ['trigger_dev_trigger_task', 'trigger_dev_create_waitpoint_token'] +const CREATED_AT_FILTER_OPERATIONS = [ + 'trigger_dev_list_runs', + 'trigger_dev_list_deployments', + 'trigger_dev_list_waitpoint_tokens', + 'trigger_dev_execute_query', +] +const CURSOR_PAGE_OPERATIONS = [ + 'trigger_dev_list_runs', + 'trigger_dev_list_deployments', + 'trigger_dev_list_waitpoint_tokens', +] +const PAGE_BEFORE_OPERATIONS = ['trigger_dev_list_runs', 'trigger_dev_list_waitpoint_tokens'] +const NUMBERED_PAGE_OPERATIONS = ['trigger_dev_list_schedules', 'trigger_dev_list_queues'] export const TriggerDevBlock: BlockConfig = { type: 'trigger_dev', @@ -48,7 +78,7 @@ export const TriggerDevBlock: BlockConfig = { description: 'Trigger tasks and manage runs and schedules', authMode: AuthMode.ApiKey, longDescription: - 'Integrate Trigger.dev into the workflow. Trigger and batch trigger background tasks with a JSON payload, retrieve and list runs, cancel, replay, or reschedule runs, manage cron schedules, environment variables, and queues.', + 'Integrate Trigger.dev into the workflow. Trigger and batch trigger background tasks, retrieve and control runs (cancel, replay, reschedule, tags, metadata, events, traces), manage cron schedules, environment variables, queues, deployments, and waitpoint tokens, and query run data with TRQL.', docsLink: 'https://docs.sim.ai/integrations/trigger_dev', category: 'tools', integrationType: IntegrationType.DevOps, @@ -63,11 +93,17 @@ export const TriggerDevBlock: BlockConfig = { options: [ { label: 'Trigger Task', id: 'trigger_dev_trigger_task' }, { label: 'Batch Trigger Task', id: 'trigger_dev_batch_trigger_task' }, + { label: 'Get Batch', id: 'trigger_dev_get_batch' }, + { label: 'Get Batch Results', id: 'trigger_dev_get_batch_results' }, { label: 'Get Run', id: 'trigger_dev_get_run' }, + { label: 'Get Run Result', id: 'trigger_dev_get_run_result' }, + { label: 'Get Run Events', id: 'trigger_dev_get_run_events' }, + { label: 'Get Run Trace', id: 'trigger_dev_get_run_trace' }, { label: 'List Runs', id: 'trigger_dev_list_runs' }, { label: 'Cancel Run', id: 'trigger_dev_cancel_run' }, { label: 'Replay Run', id: 'trigger_dev_replay_run' }, { label: 'Reschedule Run', id: 'trigger_dev_reschedule_run' }, + { label: 'Add Run Tags', id: 'trigger_dev_add_run_tags' }, { label: 'Update Run Metadata', id: 'trigger_dev_update_run_metadata' }, { label: 'Create Schedule', id: 'trigger_dev_create_schedule' }, { label: 'Get Schedule', id: 'trigger_dev_get_schedule' }, @@ -81,9 +117,24 @@ export const TriggerDevBlock: BlockConfig = { { label: 'Get Env Var', id: 'trigger_dev_get_env_var' }, { label: 'Update Env Var', id: 'trigger_dev_update_env_var' }, { label: 'Delete Env Var', id: 'trigger_dev_delete_env_var' }, + { label: 'Import Env Vars', id: 'trigger_dev_import_env_vars' }, { label: 'Get Queue', id: 'trigger_dev_get_queue' }, + { label: 'List Queues', id: 'trigger_dev_list_queues' }, { label: 'Pause Queue', id: 'trigger_dev_pause_queue' }, { label: 'Resume Queue', id: 'trigger_dev_resume_queue' }, + { label: 'Override Queue Concurrency', id: 'trigger_dev_override_queue_concurrency' }, + { label: 'Reset Queue Concurrency', id: 'trigger_dev_reset_queue_concurrency' }, + { label: 'List Deployments', id: 'trigger_dev_list_deployments' }, + { label: 'Get Deployment', id: 'trigger_dev_get_deployment' }, + { label: 'Get Latest Deployment', id: 'trigger_dev_get_latest_deployment' }, + { label: 'Promote Deployment', id: 'trigger_dev_promote_deployment' }, + { label: 'Execute Query', id: 'trigger_dev_execute_query' }, + { label: 'Get Query Schema', id: 'trigger_dev_get_query_schema' }, + { label: 'Create Waitpoint Token', id: 'trigger_dev_create_waitpoint_token' }, + { label: 'Complete Waitpoint Token', id: 'trigger_dev_complete_waitpoint_token' }, + { label: 'Get Waitpoint Token', id: 'trigger_dev_get_waitpoint_token' }, + { label: 'List Waitpoint Tokens', id: 'trigger_dev_list_waitpoint_tokens' }, + { label: 'List Timezones', id: 'trigger_dev_list_timezones' }, ], value: () => 'trigger_dev_trigger_task', }, @@ -134,9 +185,9 @@ Return ONLY the valid JSON object - no explanations, no markdown.`, id: 'idempotencyKey', title: 'Idempotency Key', type: 'short-input', - placeholder: 'Unique key to deduplicate triggers', + placeholder: 'Unique key to deduplicate requests', mode: 'advanced', - condition: { field: 'operation', value: 'trigger_dev_trigger_task' }, + condition: { field: 'operation', value: IDEMPOTENCY_KEY_OPERATIONS }, }, { id: 'queue', @@ -194,7 +245,7 @@ Return ONLY the valid JSON object - no explanations, no markdown.`, type: 'short-input', placeholder: 'user_123, org_456 (comma-separated, max 10)', mode: 'advanced', - condition: { field: 'operation', value: 'trigger_dev_trigger_task' }, + condition: { field: 'operation', value: TAGS_OPERATIONS }, }, // Batch Trigger Task fields { @@ -225,6 +276,15 @@ Return ONLY the valid JSON array - no explanations, no markdown.`, generationType: 'json-object', }, }, + // Batch fields + { + id: 'batchId', + title: 'Batch ID', + type: 'short-input', + placeholder: 'e.g., batch_abc123', + condition: { field: 'operation', value: BATCH_ID_OPERATIONS }, + required: { field: 'operation', value: BATCH_ID_OPERATIONS }, + }, // Run fields { id: 'runId', @@ -242,6 +302,14 @@ Return ONLY the valid JSON array - no explanations, no markdown.`, condition: { field: 'operation', value: 'trigger_dev_reschedule_run' }, required: { field: 'operation', value: 'trigger_dev_reschedule_run' }, }, + { + id: 'runTags', + title: 'Tags', + type: 'short-input', + placeholder: 'user_123, org_456 (comma-separated, max 10 total)', + condition: { field: 'operation', value: 'trigger_dev_add_run_tags' }, + required: { field: 'operation', value: 'trigger_dev_add_run_tags' }, + }, { id: 'metadata', title: 'Metadata', @@ -283,19 +351,19 @@ Return ONLY the valid JSON object - no explanations, no markdown.`, }, { id: 'period', - title: 'Created Within', + title: 'Time Period', type: 'short-input', placeholder: 'e.g., 1h, 7d', mode: 'advanced', - condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + condition: { field: 'operation', value: CREATED_AT_FILTER_OPERATIONS }, }, { id: 'from', - title: 'Created From', + title: 'From', type: 'short-input', placeholder: '2024-01-01T00:00:00.000Z', mode: 'advanced', - condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + condition: { field: 'operation', value: CREATED_AT_FILTER_OPERATIONS }, wandConfig: { enabled: true, prompt: `Generate an ISO 8601 timestamp based on the user's description. @@ -310,11 +378,11 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, }, { id: 'to', - title: 'Created To', + title: 'To', type: 'short-input', placeholder: '2024-12-31T23:59:59.999Z', mode: 'advanced', - condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + condition: { field: 'operation', value: CREATED_AT_FILTER_OPERATIONS }, wandConfig: { enabled: true, prompt: `Generate an ISO 8601 timestamp based on the user's description. @@ -368,25 +436,25 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, id: 'pageSize', title: 'Page Size', type: 'short-input', - placeholder: 'Runs per page (max 100, default 25)', + placeholder: 'Items per page (max 100)', mode: 'advanced', - condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + condition: { field: 'operation', value: CURSOR_PAGE_OPERATIONS }, }, { id: 'pageAfter', title: 'Page After', type: 'short-input', - placeholder: 'Run ID to start the page after', + placeholder: 'Cursor to start the page after', mode: 'advanced', - condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + condition: { field: 'operation', value: CURSOR_PAGE_OPERATIONS }, }, { id: 'pageBefore', title: 'Page Before', type: 'short-input', - placeholder: 'Run ID to start the page before', + placeholder: 'Cursor to start the page before', mode: 'advanced', - condition: { field: 'operation', value: 'trigger_dev_list_runs' }, + condition: { field: 'operation', value: PAGE_BEFORE_OPERATIONS }, }, // Schedule fields { @@ -434,25 +502,25 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, title: 'Deduplication Key', type: 'short-input', placeholder: 'Key to prevent duplicate schedules', - mode: 'advanced', condition: { field: 'operation', value: 'trigger_dev_create_schedule' }, + required: { field: 'operation', value: 'trigger_dev_create_schedule' }, }, - // List Schedules pagination + // List Schedules / List Queues pagination { id: 'page', title: 'Page', type: 'short-input', placeholder: 'Page number (default 1)', mode: 'advanced', - condition: { field: 'operation', value: 'trigger_dev_list_schedules' }, + condition: { field: 'operation', value: NUMBERED_PAGE_OPERATIONS }, }, { id: 'perPage', title: 'Per Page', type: 'short-input', - placeholder: 'Schedules per page', + placeholder: 'Items per page', mode: 'advanced', - condition: { field: 'operation', value: 'trigger_dev_list_schedules' }, + condition: { field: 'operation', value: NUMBERED_PAGE_OPERATIONS }, }, // Environment variable fields { @@ -493,6 +561,27 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, condition: { field: 'operation', value: ENV_VAR_VALUE_OPERATIONS }, required: { field: 'operation', value: ENV_VAR_VALUE_OPERATIONS }, }, + { + id: 'variables', + title: 'Variables', + type: 'code', + language: 'json', + placeholder: '[\n { "name": "SLACK_API_KEY", "value": "slack_123" }\n]', + condition: { field: 'operation', value: 'trigger_dev_import_env_vars' }, + required: { field: 'operation', value: 'trigger_dev_import_env_vars' }, + }, + { + id: 'override', + title: 'Override Existing', + type: 'dropdown', + options: [ + { label: 'No (default)', id: 'false' }, + { label: 'Yes', id: 'true' }, + ], + value: () => 'false', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_import_env_vars' }, + }, // Queue fields { id: 'queueName', @@ -514,17 +603,207 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, value: () => 'id', condition: { field: 'operation', value: QUEUE_OPERATIONS }, }, + { + id: 'concurrencyLimit', + title: 'Concurrency Limit', + type: 'short-input', + placeholder: 'New concurrency limit (0 to 100000)', + condition: { field: 'operation', value: 'trigger_dev_override_queue_concurrency' }, + required: { field: 'operation', value: 'trigger_dev_override_queue_concurrency' }, + }, + // Deployment fields + { + id: 'deploymentId', + title: 'Deployment ID', + type: 'short-input', + placeholder: 'ID of the deployment', + condition: { field: 'operation', value: 'trigger_dev_get_deployment' }, + required: { field: 'operation', value: 'trigger_dev_get_deployment' }, + }, + { + id: 'deploymentVersion', + title: 'Deployment Version', + type: 'short-input', + placeholder: 'e.g., 20250228.1', + condition: { field: 'operation', value: 'trigger_dev_promote_deployment' }, + required: { field: 'operation', value: 'trigger_dev_promote_deployment' }, + }, + { + id: 'deploymentStatus', + title: 'Status Filter', + type: 'dropdown', + options: [ + { label: 'All', id: '' }, + { label: 'Pending', id: 'PENDING' }, + { label: 'Building', id: 'BUILDING' }, + { label: 'Deploying', id: 'DEPLOYING' }, + { label: 'Deployed', id: 'DEPLOYED' }, + { label: 'Failed', id: 'FAILED' }, + { label: 'Canceled', id: 'CANCELED' }, + { label: 'Timed Out', id: 'TIMED_OUT' }, + ], + value: () => '', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_deployments' }, + }, + // Query fields + { + id: 'query', + title: 'TRQL Query', + type: 'long-input', + placeholder: "SELECT run_id, status, triggered_at FROM runs WHERE status = 'Failed' LIMIT 10", + condition: { field: 'operation', value: 'trigger_dev_execute_query' }, + required: { field: 'operation', value: 'trigger_dev_execute_query' }, + wandConfig: { + enabled: true, + prompt: `Generate a TRQL query for Trigger.dev run data based on the user's description. +TRQL is a SQL-like language; the main table is "runs" with columns like run_id, task_identifier, status, triggered_at, duration_ms, cost_in_cents, and tags. + +Current input: {context} + +Examples: +- "failed runs from the last day" -> +SELECT run_id, task_identifier, status, triggered_at FROM runs WHERE status = 'Failed' ORDER BY triggered_at DESC LIMIT 100 + +- "cost per task this week" -> +SELECT task_identifier, SUM(cost_in_cents) AS total_cost FROM runs GROUP BY task_identifier ORDER BY total_cost DESC + +Return ONLY the TRQL query - no explanations, no markdown.`, + placeholder: 'Describe the query you need...', + generationType: 'sql-query', + }, + }, + { + id: 'scope', + title: 'Scope', + type: 'dropdown', + options: [ + { label: 'Environment (default)', id: 'environment' }, + { label: 'Project', id: 'project' }, + { label: 'Organization', id: 'organization' }, + ], + value: () => 'environment', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_execute_query' }, + }, + { + id: 'format', + title: 'Format', + type: 'dropdown', + options: [ + { label: 'JSON (default)', id: 'json' }, + { label: 'CSV', id: 'csv' }, + ], + value: () => 'json', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_execute_query' }, + }, + // Waitpoint fields + { + id: 'waitpointId', + title: 'Waitpoint ID', + type: 'short-input', + placeholder: 'e.g., waitpoint_abc123', + condition: { field: 'operation', value: WAITPOINT_ID_OPERATIONS }, + required: { field: 'operation', value: WAITPOINT_ID_OPERATIONS }, + }, + { + id: 'waitpointData', + title: 'Completion Data', + type: 'code', + language: 'json', + placeholder: '{\n "status": "approved"\n}', + condition: { field: 'operation', value: 'trigger_dev_complete_waitpoint_token' }, + wandConfig: { + enabled: true, + prompt: `Generate a JSON object to pass back to a Trigger.dev run waiting on a waitpoint token. +The data is returned to the task as the token result. + +Current input: {context} + +Example: +- "approve with a comment" -> +{"status": "approved", "comment": "Looks good"} + +Return ONLY the valid JSON object - no explanations, no markdown.`, + placeholder: 'Describe the completion data you need...', + generationType: 'json-object', + }, + }, + { + id: 'timeout', + title: 'Timeout', + type: 'short-input', + placeholder: 'e.g., 30s, 1m, 2h, or an ISO 8601 date', + condition: { field: 'operation', value: 'trigger_dev_create_waitpoint_token' }, + }, + { + id: 'idempotencyKeyTTL', + title: 'Idempotency Key TTL', + type: 'short-input', + placeholder: 'e.g., 30s, 1m, 2h, 3d', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_create_waitpoint_token' }, + }, + { + id: 'waitpointStatus', + title: 'Status Filter', + type: 'dropdown', + options: [ + { label: 'All', id: '' }, + { label: 'Waiting', id: 'WAITING' }, + { label: 'Completed', id: 'COMPLETED' }, + { label: 'Timed Out', id: 'TIMED_OUT' }, + ], + value: () => '', + condition: { field: 'operation', value: 'trigger_dev_list_waitpoint_tokens' }, + }, + { + id: 'filterIdempotencyKey', + title: 'Idempotency Key Filter', + type: 'short-input', + placeholder: 'Idempotency key to filter by', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_waitpoint_tokens' }, + }, + { + id: 'waitpointTags', + title: 'Tag Filter', + type: 'short-input', + placeholder: 'user_123, org_456 (comma-separated)', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_waitpoint_tokens' }, + }, + // Timezone fields + { + id: 'excludeUtc', + title: 'Exclude UTC', + type: 'dropdown', + options: [ + { label: 'No (default)', id: 'false' }, + { label: 'Yes', id: 'true' }, + ], + value: () => 'false', + mode: 'advanced', + condition: { field: 'operation', value: 'trigger_dev_list_timezones' }, + }, ], tools: { access: [ 'trigger_dev_trigger_task', 'trigger_dev_batch_trigger_task', + 'trigger_dev_get_batch', + 'trigger_dev_get_batch_results', 'trigger_dev_get_run', + 'trigger_dev_get_run_result', + 'trigger_dev_get_run_events', + 'trigger_dev_get_run_trace', 'trigger_dev_list_runs', 'trigger_dev_cancel_run', 'trigger_dev_replay_run', 'trigger_dev_reschedule_run', + 'trigger_dev_add_run_tags', 'trigger_dev_update_run_metadata', 'trigger_dev_create_schedule', 'trigger_dev_get_schedule', @@ -538,9 +817,24 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, 'trigger_dev_get_env_var', 'trigger_dev_update_env_var', 'trigger_dev_delete_env_var', + 'trigger_dev_import_env_vars', 'trigger_dev_get_queue', + 'trigger_dev_list_queues', 'trigger_dev_pause_queue', 'trigger_dev_resume_queue', + 'trigger_dev_override_queue_concurrency', + 'trigger_dev_reset_queue_concurrency', + 'trigger_dev_list_deployments', + 'trigger_dev_get_deployment', + 'trigger_dev_get_latest_deployment', + 'trigger_dev_promote_deployment', + 'trigger_dev_execute_query', + 'trigger_dev_get_query_schema', + 'trigger_dev_create_waitpoint_token', + 'trigger_dev_complete_waitpoint_token', + 'trigger_dev_get_waitpoint_token', + 'trigger_dev_list_waitpoint_tokens', + 'trigger_dev_list_timezones', ], config: { tool: (params) => params.operation, @@ -548,6 +842,14 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, const result: Record = {} if (params.filterTaskIdentifier) result.taskIdentifier = params.filterTaskIdentifier if (params.rescheduleDelay) result.delay = params.rescheduleDelay + if (params.runTags) result.tags = params.runTags + if (params.deploymentVersion) result.version = params.deploymentVersion + if (params.deploymentStatus) result.status = params.deploymentStatus + if (params.waitpointData) result.data = params.waitpointData + if (params.waitpointStatus) result.status = params.waitpointStatus + if (params.filterIdempotencyKey) result.idempotencyKey = params.filterIdempotencyKey + if (params.waitpointTags) result.tags = params.waitpointTags + if (params.concurrencyLimit) result.concurrencyLimit = Number(params.concurrencyLimit) if (params.pageSize) result.pageSize = Number(params.pageSize) if (params.page) result.page = Number(params.page) if (params.perPage) result.perPage = Number(params.perPage) @@ -574,9 +876,11 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'json', description: 'JSON array of batch items, each with a payload and optional options', }, + batchId: { type: 'string', description: 'Batch ID (starts with batch_)' }, // Runs runId: { type: 'string', description: 'Run ID (starts with run_)' }, rescheduleDelay: { type: 'string', description: 'New delay for a delayed run' }, + runTags: { type: 'string', description: 'Comma-separated tags to add to a run' }, metadata: { type: 'json', description: 'JSON object to set as the run metadata' }, status: { type: 'string', description: 'Comma-separated run statuses to filter by' }, filterTaskIdentifier: { @@ -607,6 +911,14 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, environment: { type: 'string', description: 'Project environment (dev, staging, or prod)' }, name: { type: 'string', description: 'Name of the environment variable' }, value: { type: 'string', description: 'Value of the environment variable' }, + variables: { + type: 'json', + description: 'JSON array of environment variables to import ({name, value} objects)', + }, + override: { + type: 'string', + description: 'Whether to override existing variables on import ("true" or "false")', + }, // Queues queueName: { type: 'string', @@ -616,14 +928,71 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'string', description: 'How to interpret the queue name (id, task, or custom)', }, + concurrencyLimit: { + type: 'number', + description: 'New concurrency limit for the queue (0 to 100000)', + }, + // Deployments + deploymentId: { type: 'string', description: 'ID of the deployment to retrieve' }, + deploymentVersion: { type: 'string', description: 'Deployment version to promote' }, + deploymentStatus: { type: 'string', description: 'Deployment status to filter by' }, + // Query + query: { type: 'string', description: 'TRQL query to execute' }, + scope: { + type: 'string', + description: 'Scope of data to query (environment, project, or organization)', + }, + format: { type: 'string', description: 'Query response format (json or csv)' }, + // Waitpoints + waitpointId: { type: 'string', description: 'Waitpoint token ID (starts with waitpoint_)' }, + waitpointData: { + type: 'json', + description: 'JSON data passed back to the run waiting on the token', + }, + timeout: { type: 'string', description: 'How long before the waitpoint token times out' }, + idempotencyKeyTTL: { + type: 'string', + description: 'How long the waitpoint idempotency key is valid', + }, + waitpointStatus: { + type: 'string', + description: 'Waitpoint status to filter by (WAITING, COMPLETED, or TIMED_OUT)', + }, + filterIdempotencyKey: { + type: 'string', + description: 'Idempotency key to filter waitpoint tokens by', + }, + waitpointTags: { + type: 'string', + description: 'Comma-separated tags to filter waitpoint tokens by', + }, + // Timezones + excludeUtc: { + type: 'string', + description: 'Whether to exclude UTC from the timezones ("true" or "false")', + }, }, outputs: { // Trigger Task / Cancel Run / Replay Run / schedule operations id: { type: 'string', description: 'Run, schedule, or queue ID' }, - // Batch Trigger Task + // Batches batchId: { type: 'string', description: 'Batch ID (Batch Trigger Task)' }, - runIds: { type: 'json', description: 'IDs of the created runs (Batch Trigger Task)' }, + runIds: { type: 'json', description: 'Run IDs in the batch (batch operations)' }, + runCount: { type: 'number', description: 'Total number of runs in the batch (Get Batch)' }, + successfulRunCount: { + type: 'number', + description: 'Number of successful runs in the batch (Get Batch)', + }, + failedRunCount: { + type: 'number', + description: 'Number of failed runs in the batch (Get Batch)', + }, + errors: { type: 'json', description: 'Error details for failed batch items (Get Batch)' }, + items: { + type: 'json', + description: 'Execution results for each run in the batch (Get Batch Results)', + }, // Get Run status: { type: 'string', description: 'Run status (Get Run)' }, taskIdentifier: { type: 'string', description: 'Task identifier of the run (Get Run)' }, @@ -638,6 +1007,16 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, output: { type: 'json', description: 'Output returned by the run (Get Run)' }, attempts: { type: 'json', description: 'Attempts made for the run (Get Run)' }, metadata: { type: 'json', description: 'Run metadata (Get Run, Update Run Metadata)' }, + ok: { type: 'boolean', description: 'Whether the run succeeded (Get Run Result)' }, + outputType: { + type: 'string', + description: 'Content type of the run output (Get Run Result)', + }, + error: { type: 'json', description: 'Error details for a failed run (Get Run Result)' }, + message: { type: 'string', description: 'Confirmation message (Add Run Tags)' }, + events: { type: 'json', description: 'Log and span events of the run (Get Run Events)' }, + traceId: { type: 'string', description: 'OpenTelemetry trace ID (Get Run Trace)' }, + rootSpan: { type: 'json', description: 'Root span of the run trace (Get Run Trace)' }, // List Runs / List Schedules runs: { type: 'json', description: 'Runs matching the filters (List Runs)' }, schedules: { type: 'json', description: 'Schedules in the project (List Schedules)' }, @@ -672,9 +1051,14 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, value: { type: 'string', description: 'Value of the environment variable (Get Env Var)' }, success: { type: 'boolean', - description: 'Whether the env var operation succeeded (Create/Update/Delete Env Var)', + description: 'Whether the operation succeeded (env var operations, Complete Waitpoint Token)', + }, + count: { + type: 'number', + description: 'Number of environment variables submitted (Import Env Vars)', }, // Queues + queues: { type: 'json', description: 'Queues in the environment (List Queues)' }, running: { type: 'number', description: 'Runs currently executing (queue operations)' }, queued: { type: 'number', description: 'Runs waiting in the queue (queue operations)' }, paused: { type: 'boolean', description: 'Whether the queue is paused (queue operations)' }, @@ -686,6 +1070,30 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'json', description: 'Concurrency details of the queue (queue operations)', }, + // Deployments + deployments: { + type: 'json', + description: 'Deployments matching the filters (List Deployments)', + }, + version: { type: 'string', description: 'Deployment version (deployment operations)' }, + shortCode: { type: 'string', description: 'Deployment short code (deployment operations)' }, + tasks: { + type: 'json', + description: 'Tasks registered by the deployed worker (deployment operations)', + }, + // Query + format: { type: 'string', description: 'Format of the query results (Execute Query)' }, + results: { type: 'json', description: 'Query results (Execute Query)' }, + tables: { type: 'json', description: 'Queryable TRQL tables and columns (Get Query Schema)' }, + // Waitpoints + tokens: { type: 'json', description: 'Waitpoint tokens (List Waitpoint Tokens)' }, + url: { type: 'string', description: 'Waitpoint callback URL (waitpoint operations)' }, + isCached: { + type: 'boolean', + description: 'Whether an existing token was returned (Create Waitpoint Token)', + }, + // Timezones + timezones: { type: 'json', description: 'Supported IANA timezones (List Timezones)' }, }, } @@ -752,12 +1160,32 @@ export const TriggerDevBlockMeta = { icon: TriggerDevIcon, title: 'Trigger.dev compute cost reporter', prompt: - 'Create a weekly scheduled workflow that lists Trigger.dev runs from the past week, aggregates compute cost and duration per task, and emails a cost report to the team.', + 'Create a weekly scheduled workflow that uses Trigger.dev Execute Query to aggregate compute cost and duration per task for the past week, and emails a cost report to the team.', modules: ['scheduled', 'agent', 'workflows'], category: 'operations', tags: ['reporting', 'devops'], alsoIntegrations: ['gmail'], }, + { + icon: TriggerDevIcon, + title: 'Trigger.dev human approval gate', + prompt: + 'Build a workflow where a Trigger.dev task waits on a waitpoint token, an approver reviews the request in Slack, and the workflow completes the waitpoint token with the approval decision so the task resumes.', + modules: ['agent', 'workflows'], + category: 'operations', + tags: ['automation', 'approvals'], + alsoIntegrations: ['slack'], + }, + { + icon: TriggerDevIcon, + title: 'Trigger.dev deploy watchdog', + prompt: + 'Create a workflow that checks the latest Trigger.dev deployment after each release, and if the deployment failed or new runs start crashing, promotes the previous deployment version and alerts the on-call channel.', + modules: ['agent', 'workflows'], + category: 'engineering', + tags: ['devops', 'monitoring'], + alsoIntegrations: ['slack'], + }, ], skills: [ { @@ -781,6 +1209,13 @@ export const TriggerDevBlockMeta = { content: '# Replay Transient Failures\n\nRetry failed Trigger.dev runs that are safe to run again.\n\n## Steps\n1. List runs with status FAILED for the relevant period and task filter.\n2. For each run, use Get Run and inspect the attempt errors. Treat timeouts, rate limits, and network errors as transient; treat validation and logic errors as permanent.\n3. Use the Replay Run operation on transient failures only, and record the new run IDs.\n\n## Output\nList the replayed runs (old run ID to new run ID) and the runs skipped as permanent failures, with the reason for each decision.', }, + { + name: 'human-approval-waitpoint', + description: + 'Create a Trigger.dev waitpoint token for a task to wait on, then complete it with approval data once a human decides.', + content: + '# Human Approval Waitpoint\n\nGate a Trigger.dev task on an external decision using waitpoint tokens.\n\n## Steps\n1. Use Create Waitpoint Token with a timeout (e.g., 1d) and an idempotency key tied to the request, and pass the token ID to the task that should wait.\n2. When the decision arrives, use Complete Waitpoint Token with the token ID and a JSON payload like {"status": "approved"} so the waiting run resumes with that data.\n3. Use Get Waitpoint Token or List Waitpoint Tokens to check for tokens that are still WAITING or have TIMED_OUT.\n\n## Output\nReport the token ID, its status, and the completion data passed to the run. Flag tokens that timed out without a decision.', + }, { name: 'manage-cron-schedules', description: diff --git a/apps/sim/lib/integrations/integrations.json b/apps/sim/lib/integrations/integrations.json index 05753a73a8..8059442bf0 100644 --- a/apps/sim/lib/integrations/integrations.json +++ b/apps/sim/lib/integrations/integrations.json @@ -2239,7 +2239,7 @@ { "type": "calcom", "slug": "cal-com", - "name": "Cal Com", + "name": "Cal.com", "description": "Manage Cal.com bookings, event types, schedules, and availability", "longDescription": "Integrate Cal.com into your workflow. Create and manage bookings, event types, schedules, and check availability slots. Supports creating, listing, rescheduling, and canceling bookings, as well as managing event types and schedules. Can also trigger workflows based on Cal.com webhook events (booking created, cancelled, rescheduled). Connect your Cal.com account via OAuth.", "bgColor": "#292929", @@ -14813,7 +14813,7 @@ "slug": "trigger-dev", "name": "Trigger.dev", "description": "Trigger tasks and manage runs and schedules", - "longDescription": "Integrate Trigger.dev into the workflow. Trigger and batch trigger background tasks with a JSON payload, retrieve and list runs, cancel, replay, or reschedule runs, manage cron schedules, environment variables, and queues.", + "longDescription": "Integrate Trigger.dev into the workflow. Trigger and batch trigger background tasks, retrieve and control runs (cancel, replay, reschedule, tags, metadata, events, traces), manage cron schedules, environment variables, queues, deployments, and waitpoint tokens, and query run data with TRQL.", "bgColor": "#000000", "iconName": "TriggerDevIcon", "docsUrl": "https://docs.sim.ai/integrations/trigger_dev", @@ -14826,10 +14826,30 @@ "name": "Batch Trigger Task", "description": "Batch trigger a Trigger.dev task with up to 1,000 payloads. All items in the batch run the same task. Returns the batch ID and the created run IDs." }, + { + "name": "Get Batch", + "description": "Retrieve a Trigger.dev batch by its ID, including its status, run IDs, and success and failure counts." + }, + { + "name": "Get Batch Results", + "description": "Retrieve the execution results of every run in a Trigger.dev batch, including outputs and error details." + }, { "name": "Get Run", "description": "Retrieve a Trigger.dev run by its ID, including status, payload, output, attempts, and timing details." }, + { + "name": "Get Run Result", + "description": "Retrieve the result of a Trigger.dev run: whether it succeeded, its output, and error details. Lighter than Get Run when only the outcome is needed." + }, + { + "name": "Get Run Events", + "description": "Retrieve the log and span events of a Trigger.dev run, including messages, levels, durations, and error events." + }, + { + "name": "Get Run Trace", + "description": "Retrieve the OpenTelemetry trace of a Trigger.dev run as a tree of spans with timing, errors, and nested children." + }, { "name": "List Runs", "description": "List Trigger.dev runs in the environment of the API key, with optional filters for status, task, version, tags, schedule, and creation time." @@ -14846,6 +14866,10 @@ "name": "Reschedule Run", "description": "Reschedule a delayed Trigger.dev run with a new delay. Only valid while the run is in the DELAYED state." }, + { + "name": "Add Run Tags", + "description": "Add tags to an existing Trigger.dev run. Runs can have up to 10 tags." + }, { "name": "Update Run Metadata", "description": "Replace the metadata of a Trigger.dev run with a new JSON object." @@ -14898,10 +14922,18 @@ "name": "Delete Env Var", "description": "Delete an environment variable from a Trigger.dev project environment." }, + { + "name": "Import Env Vars", + "description": "Upload multiple environment variables to a Trigger.dev project environment in one request." + }, { "name": "Get Queue", "description": "Retrieve a Trigger.dev queue by ID, task identifier, or custom queue name, including its running and queued counts." }, + { + "name": "List Queues", + "description": "List the queues in the environment of the API key, including running and queued counts, with page-based pagination." + }, { "name": "Pause Queue", "description": "Pause a Trigger.dev queue so no new runs start. Runs that are currently executing continue to completion." @@ -14909,9 +14941,61 @@ { "name": "Resume Queue", "description": "Resume a paused Trigger.dev queue so new runs can start again." + }, + { + "name": "Override Queue Concurrency", + "description": "Override the concurrency limit of a Trigger.dev queue with a new value." + }, + { + "name": "Reset Queue Concurrency", + "description": "Reset the concurrency limit of a Trigger.dev queue back to its base value, removing any override." + }, + { + "name": "List Deployments", + "description": "List Trigger.dev deployments in the environment of the API key, with optional status and creation-time filters." + }, + { + "name": "Get Deployment", + "description": "Retrieve a Trigger.dev deployment by its ID, including its status, version, and registered tasks." + }, + { + "name": "Get Latest Deployment", + "description": "Retrieve the latest Trigger.dev deployment in the environment of the API key." + }, + { + "name": "Promote Deployment", + "description": "Promote a Trigger.dev deployment version so new runs execute on it (e.g., to roll back to a previous version)." + }, + { + "name": "Execute Query", + "description": "Execute a TRQL (SQL-like) query against Trigger.dev run data for reporting and analytics." + }, + { + "name": "Get Query Schema", + "description": "Retrieve the TRQL query schema: the tables and columns available for Execute Query, with types and allowed values." + }, + { + "name": "Create Waitpoint Token", + "description": "Create a Trigger.dev waitpoint token that a task can wait on until it is completed from outside (e.g., a human approval)." + }, + { + "name": "Complete Waitpoint Token", + "description": "Complete a Trigger.dev waitpoint token, resuming any task waiting on it and passing it optional JSON data." + }, + { + "name": "Get Waitpoint Token", + "description": "Retrieve a Trigger.dev waitpoint token by its ID, including its status, timeout, and completion data." + }, + { + "name": "List Waitpoint Tokens", + "description": "List Trigger.dev waitpoint tokens in the environment of the API key, with optional status, tag, and creation-time filters." + }, + { + "name": "List Timezones", + "description": "List the IANA timezones supported by Trigger.dev schedules, for use as the timezone of a cron schedule." } ], - "operationCount": 23, + "operationCount": 44, "triggers": [], "triggerCount": 0, "authType": "api-key", diff --git a/apps/sim/tools/registry.ts b/apps/sim/tools/registry.ts index a61982d468..28770e4972 100644 --- a/apps/sim/tools/registry.ts +++ b/apps/sim/tools/registry.ts @@ -3191,23 +3191,44 @@ import { } from '@/tools/trello' import { triggerDevActivateScheduleTool, + triggerDevAddRunTagsTool, triggerDevBatchTriggerTaskTool, triggerDevCancelRunTool, + triggerDevCompleteWaitpointTokenTool, triggerDevCreateEnvVarTool, triggerDevCreateScheduleTool, + triggerDevCreateWaitpointTokenTool, triggerDevDeactivateScheduleTool, triggerDevDeleteEnvVarTool, triggerDevDeleteScheduleTool, + triggerDevExecuteQueryTool, + triggerDevGetBatchResultsTool, + triggerDevGetBatchTool, + triggerDevGetDeploymentTool, triggerDevGetEnvVarTool, + triggerDevGetLatestDeploymentTool, + triggerDevGetQuerySchemaTool, triggerDevGetQueueTool, + triggerDevGetRunEventsTool, + triggerDevGetRunResultTool, triggerDevGetRunTool, + triggerDevGetRunTraceTool, triggerDevGetScheduleTool, + triggerDevGetWaitpointTokenTool, + triggerDevImportEnvVarsTool, + triggerDevListDeploymentsTool, triggerDevListEnvVarsTool, + triggerDevListQueuesTool, triggerDevListRunsTool, triggerDevListSchedulesTool, + triggerDevListTimezonesTool, + triggerDevListWaitpointTokensTool, + triggerDevOverrideQueueConcurrencyTool, triggerDevPauseQueueTool, + triggerDevPromoteDeploymentTool, triggerDevReplayRunTool, triggerDevRescheduleRunTool, + triggerDevResetQueueConcurrencyTool, triggerDevResumeQueueTool, triggerDevTriggerTaskTool, triggerDevUpdateEnvVarTool, @@ -5284,11 +5305,17 @@ export const tools: Record = { trello_add_comment: trelloAddCommentTool, trigger_dev_trigger_task: triggerDevTriggerTaskTool, trigger_dev_batch_trigger_task: triggerDevBatchTriggerTaskTool, + trigger_dev_get_batch: triggerDevGetBatchTool, + trigger_dev_get_batch_results: triggerDevGetBatchResultsTool, trigger_dev_get_run: triggerDevGetRunTool, + trigger_dev_get_run_result: triggerDevGetRunResultTool, + trigger_dev_get_run_events: triggerDevGetRunEventsTool, + trigger_dev_get_run_trace: triggerDevGetRunTraceTool, trigger_dev_list_runs: triggerDevListRunsTool, trigger_dev_cancel_run: triggerDevCancelRunTool, trigger_dev_replay_run: triggerDevReplayRunTool, trigger_dev_reschedule_run: triggerDevRescheduleRunTool, + trigger_dev_add_run_tags: triggerDevAddRunTagsTool, trigger_dev_update_run_metadata: triggerDevUpdateRunMetadataTool, trigger_dev_create_schedule: triggerDevCreateScheduleTool, trigger_dev_get_schedule: triggerDevGetScheduleTool, @@ -5302,9 +5329,24 @@ export const tools: Record = { trigger_dev_get_env_var: triggerDevGetEnvVarTool, trigger_dev_update_env_var: triggerDevUpdateEnvVarTool, trigger_dev_delete_env_var: triggerDevDeleteEnvVarTool, + trigger_dev_import_env_vars: triggerDevImportEnvVarsTool, trigger_dev_get_queue: triggerDevGetQueueTool, + trigger_dev_list_queues: triggerDevListQueuesTool, trigger_dev_pause_queue: triggerDevPauseQueueTool, trigger_dev_resume_queue: triggerDevResumeQueueTool, + trigger_dev_override_queue_concurrency: triggerDevOverrideQueueConcurrencyTool, + trigger_dev_reset_queue_concurrency: triggerDevResetQueueConcurrencyTool, + trigger_dev_list_deployments: triggerDevListDeploymentsTool, + trigger_dev_get_deployment: triggerDevGetDeploymentTool, + trigger_dev_get_latest_deployment: triggerDevGetLatestDeploymentTool, + trigger_dev_promote_deployment: triggerDevPromoteDeploymentTool, + trigger_dev_execute_query: triggerDevExecuteQueryTool, + trigger_dev_get_query_schema: triggerDevGetQuerySchemaTool, + trigger_dev_create_waitpoint_token: triggerDevCreateWaitpointTokenTool, + trigger_dev_complete_waitpoint_token: triggerDevCompleteWaitpointTokenTool, + trigger_dev_get_waitpoint_token: triggerDevGetWaitpointTokenTool, + trigger_dev_list_waitpoint_tokens: triggerDevListWaitpointTokensTool, + trigger_dev_list_timezones: triggerDevListTimezonesTool, vercel_list_deployments: vercelListDeploymentsTool, vercel_get_deployment: vercelGetDeploymentTool, vercel_create_deployment: vercelCreateDeploymentTool, diff --git a/apps/sim/tools/trigger_dev/add_run_tags.ts b/apps/sim/tools/trigger_dev/add_run_tags.ts new file mode 100644 index 0000000000..171531c8d3 --- /dev/null +++ b/apps/sim/tools/trigger_dev/add_run_tags.ts @@ -0,0 +1,64 @@ +import type { + TriggerDevAddRunTagsParams, + TriggerDevAddRunTagsResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + splitCommaSeparated, + TRIGGER_DEV_API_BASE, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevAddRunTagsTool: ToolConfig< + TriggerDevAddRunTagsParams, + TriggerDevAddRunTagsResponse +> = { + id: 'trigger_dev_add_run_tags', + name: 'Trigger.dev Add Run Tags', + description: 'Add tags to an existing Trigger.dev run. Runs can have up to 10 tags.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + runId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the run to tag (starts with run_)', + }, + tags: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Comma-separated tags to add to the run (max 10 total, each under 128 characters)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/runs/${encodeURIComponent(params.runId.trim())}/tags`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => ({ tags: splitCommaSeparated(params.tags) }), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + message: data.message ?? '', + }, + } + }, + + outputs: { + message: { type: 'string', description: 'Confirmation message for the added tags' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/complete_waitpoint_token.ts b/apps/sim/tools/trigger_dev/complete_waitpoint_token.ts new file mode 100644 index 0000000000..373f8f94ac --- /dev/null +++ b/apps/sim/tools/trigger_dev/complete_waitpoint_token.ts @@ -0,0 +1,68 @@ +import type { + TriggerDevCompleteWaitpointTokenParams, + TriggerDevCompleteWaitpointTokenResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + parseJsonInput, + TRIGGER_DEV_API_BASE, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevCompleteWaitpointTokenTool: ToolConfig< + TriggerDevCompleteWaitpointTokenParams, + TriggerDevCompleteWaitpointTokenResponse +> = { + id: 'trigger_dev_complete_waitpoint_token', + name: 'Trigger.dev Complete Waitpoint Token', + description: + 'Complete a Trigger.dev waitpoint token, resuming any task waiting on it and passing it optional JSON data.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + waitpointId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the waitpoint token to complete (starts with waitpoint_)', + }, + data: { + type: 'json', + required: false, + visibility: 'user-or-llm', + description: + 'JSON data passed back to the waiting run as the token result. Example: {"status": "approved"}', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/waitpoints/tokens/${encodeURIComponent(params.waitpointId.trim())}/complete`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => { + const data = parseJsonInput(params.data, 'data') + return data === undefined ? {} : { data } + }, + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + success: data.success ?? true, + }, + } + }, + + outputs: { + success: { type: 'boolean', description: 'Whether the waitpoint token was completed' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/create_schedule.ts b/apps/sim/tools/trigger_dev/create_schedule.ts index cc8861591e..7ffd39fece 100644 --- a/apps/sim/tools/trigger_dev/create_schedule.ts +++ b/apps/sim/tools/trigger_dev/create_schedule.ts @@ -54,7 +54,7 @@ export const triggerDevCreateScheduleTool: ToolConfig< }, deduplicationKey: { type: 'string', - required: false, + required: true, visibility: 'user-or-llm', description: 'Key that prevents duplicate schedules; creating again with the same key updates the existing schedule', @@ -69,10 +69,10 @@ export const triggerDevCreateScheduleTool: ToolConfig< const body: Record = { task: params.task, cron: params.cron, + deduplicationKey: params.deduplicationKey, } if (params.timezone) body.timezone = params.timezone if (params.externalId) body.externalId = params.externalId - if (params.deduplicationKey) body.deduplicationKey = params.deduplicationKey return body }, }, diff --git a/apps/sim/tools/trigger_dev/create_waitpoint_token.ts b/apps/sim/tools/trigger_dev/create_waitpoint_token.ts new file mode 100644 index 0000000000..c1175065a5 --- /dev/null +++ b/apps/sim/tools/trigger_dev/create_waitpoint_token.ts @@ -0,0 +1,103 @@ +import type { + TriggerDevCreateWaitpointTokenParams, + TriggerDevCreateWaitpointTokenResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + splitCommaSeparated, + TRIGGER_DEV_API_BASE, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevCreateWaitpointTokenTool: ToolConfig< + TriggerDevCreateWaitpointTokenParams, + TriggerDevCreateWaitpointTokenResponse +> = { + id: 'trigger_dev_create_waitpoint_token', + name: 'Trigger.dev Create Waitpoint Token', + description: + 'Create a Trigger.dev waitpoint token that a task can wait on until it is completed from outside (e.g., a human approval).', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + timeout: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'How long before the token times out, as a duration ("30s", "1m", "2h", "3d") or an ISO 8601 date', + }, + idempotencyKey: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Idempotency key; passing the same key before it expires returns the original token', + }, + idempotencyKeyTTL: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'How long the idempotency key is valid, as a duration ("30s", "1m", "2h", "3d")', + }, + tags: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Comma-separated tags to attach to the waitpoint (max 10, each under 128 characters)', + }, + }, + + request: { + url: `${TRIGGER_DEV_API_BASE}/api/v1/waitpoints/tokens`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => { + const body: Record = {} + if (params.timeout) body.timeout = params.timeout + if (params.idempotencyKey) body.idempotencyKey = params.idempotencyKey + if (params.idempotencyKeyTTL) body.idempotencyKeyTTL = params.idempotencyKeyTTL + if (params.tags) { + const tags = splitCommaSeparated(params.tags) + if (tags.length > 0) body.tags = tags + } + return body + }, + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + id: data.id, + isCached: data.isCached ?? false, + url: data.url, + }, + } + }, + + outputs: { + id: { + type: 'string', + description: 'Unique ID of the waitpoint token (starts with waitpoint_)', + }, + isCached: { + type: 'boolean', + description: + 'Whether an existing token was returned because the same idempotency key was reused', + }, + url: { + type: 'string', + description: + 'HTTP callback URL; a POST request to this URL completes the waitpoint without an API key', + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/execute_query.ts b/apps/sim/tools/trigger_dev/execute_query.ts new file mode 100644 index 0000000000..070910d545 --- /dev/null +++ b/apps/sim/tools/trigger_dev/execute_query.ts @@ -0,0 +1,99 @@ +import type { + TriggerDevExecuteQueryParams, + TriggerDevExecuteQueryResponse, +} from '@/tools/trigger_dev/types' +import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevExecuteQueryTool: ToolConfig< + TriggerDevExecuteQueryParams, + TriggerDevExecuteQueryResponse +> = { + id: 'trigger_dev_execute_query', + name: 'Trigger.dev Execute Query', + description: + 'Execute a TRQL (SQL-like) query against Trigger.dev run data for reporting and analytics.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + query: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'TRQL query to execute (e.g., "SELECT run_id, status, triggered_at FROM runs WHERE status = \'Failed\' LIMIT 10")', + }, + scope: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Scope of data to query: environment (default), project, or organization', + }, + period: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Time period shorthand (e.g., "1h", "7d", "30d"). Cannot be combined with from/to', + }, + from: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Start of the time range as an ISO 8601 timestamp. Must be used with "to"', + }, + to: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'End of the time range as an ISO 8601 timestamp. Must be used with "from"', + }, + format: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Response format: "json" (default) for structured rows or "csv" for a CSV string', + }, + }, + + request: { + url: `${TRIGGER_DEV_API_BASE}/api/v1/query`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => { + const body: Record = { query: params.query } + if (params.scope) body.scope = params.scope + if (params.period) body.period = params.period + if (params.from) body.from = params.from + if (params.to) body.to = params.to + if (params.format) body.format = params.format + return body + }, + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + format: data.format ?? 'json', + results: data.results ?? [], + }, + } + }, + + outputs: { + format: { type: 'string', description: 'Format of the results (json or csv)' }, + results: { + type: 'json', + description: 'Query results: an array of row objects for json format, a CSV string for csv', + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/get_batch.ts b/apps/sim/tools/trigger_dev/get_batch.ts new file mode 100644 index 0000000000..a03ec5e14e --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_batch.ts @@ -0,0 +1,127 @@ +import type { TriggerDevBatchIdParams, TriggerDevGetBatchResponse } from '@/tools/trigger_dev/types' +import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetBatchTool: ToolConfig< + TriggerDevBatchIdParams, + TriggerDevGetBatchResponse +> = { + id: 'trigger_dev_get_batch', + name: 'Trigger.dev Get Batch', + description: + 'Retrieve a Trigger.dev batch by its ID, including its status, run IDs, and success and failure counts.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + batchId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the batch to retrieve (starts with batch_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/batches/${encodeURIComponent(params.batchId.trim())}`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + id: data.id, + status: data.status, + idempotencyKey: data.idempotencyKey ?? null, + createdAt: data.createdAt ?? null, + updatedAt: data.updatedAt ?? null, + runCount: data.runCount ?? null, + runIds: data.runs ?? [], + successfulRunCount: data.successfulRunCount ?? null, + failedRunCount: data.failedRunCount ?? null, + errors: data.errors + ? data.errors.map( + (batchError: { + index?: number + taskIdentifier?: string + error?: Record + errorCode?: string | null + }) => ({ + index: batchError.index ?? null, + taskIdentifier: batchError.taskIdentifier ?? null, + error: batchError.error ?? null, + errorCode: batchError.errorCode ?? null, + }) + ) + : null, + }, + } + }, + + outputs: { + id: { type: 'string', description: 'ID of the batch (starts with batch_)' }, + status: { + type: 'string', + description: 'Batch status (PENDING, PROCESSING, COMPLETED, PARTIAL_FAILED, or ABORTED)', + }, + idempotencyKey: { + type: 'string', + description: 'Idempotency key provided when triggering the batch', + optional: true, + }, + createdAt: { + type: 'string', + description: 'ISO timestamp when the batch was created', + optional: true, + }, + updatedAt: { + type: 'string', + description: 'ISO timestamp when the batch was last updated', + optional: true, + }, + runCount: { type: 'number', description: 'Total number of runs in the batch', optional: true }, + runIds: { + type: 'array', + description: 'IDs of the runs in the batch', + items: { type: 'string', description: 'Run ID (starts with run_)' }, + }, + successfulRunCount: { + type: 'number', + description: 'Number of successful runs, populated after completion', + optional: true, + }, + failedRunCount: { + type: 'number', + description: 'Number of failed runs, populated after completion', + optional: true, + }, + errors: { + type: 'array', + description: 'Error details for failed items, present for PARTIAL_FAILED batches', + optional: true, + items: { + type: 'object', + description: 'Failed batch item', + properties: { + index: { type: 'number', description: 'Index of the failed item', nullable: true }, + taskIdentifier: { + type: 'string', + description: 'Task identifier of the failed item', + nullable: true, + }, + error: { type: 'json', description: 'Error details', nullable: true }, + errorCode: { type: 'string', description: 'Optional error code', nullable: true }, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/get_batch_results.ts b/apps/sim/tools/trigger_dev/get_batch_results.ts new file mode 100644 index 0000000000..cbfea6e896 --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_batch_results.ts @@ -0,0 +1,68 @@ +import type { + TriggerDevBatchIdParams, + TriggerDevBatchResultsResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevRunResult, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_RUN_RESULT_PROPERTIES, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetBatchResultsTool: ToolConfig< + TriggerDevBatchIdParams, + TriggerDevBatchResultsResponse +> = { + id: 'trigger_dev_get_batch_results', + name: 'Trigger.dev Get Batch Results', + description: + 'Retrieve the execution results of every run in a Trigger.dev batch, including outputs and error details.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + batchId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the batch to retrieve results for (starts with batch_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/batches/${encodeURIComponent(params.batchId.trim())}/results`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + id: data.id, + items: (data.items ?? []).map(mapTriggerDevRunResult), + }, + } + }, + + outputs: { + id: { type: 'string', description: 'ID of the batch (starts with batch_)' }, + items: { + type: 'array', + description: 'Execution results for each run in the batch', + items: { + type: 'object', + description: 'Run result', + properties: TRIGGER_DEV_RUN_RESULT_PROPERTIES, + }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/get_deployment.ts b/apps/sim/tools/trigger_dev/get_deployment.ts new file mode 100644 index 0000000000..15ba3a56ee --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_deployment.ts @@ -0,0 +1,54 @@ +import type { + TriggerDevDeploymentResponse, + TriggerDevGetDeploymentParams, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevDeployment, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_DEPLOYMENT_PROPERTIES, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetDeploymentTool: ToolConfig< + TriggerDevGetDeploymentParams, + TriggerDevDeploymentResponse +> = { + id: 'trigger_dev_get_deployment', + name: 'Trigger.dev Get Deployment', + description: + 'Retrieve a Trigger.dev deployment by its ID, including its status, version, and registered tasks.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + deploymentId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the deployment to retrieve', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/deployments/${encodeURIComponent(params.deploymentId.trim())}`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevDeployment(data), + } + }, + + outputs: TRIGGER_DEV_DEPLOYMENT_PROPERTIES, +} diff --git a/apps/sim/tools/trigger_dev/get_latest_deployment.ts b/apps/sim/tools/trigger_dev/get_latest_deployment.ts new file mode 100644 index 0000000000..99e171d982 --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_latest_deployment.ts @@ -0,0 +1,43 @@ +import type { TriggerDevBaseParams, TriggerDevDeploymentResponse } from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevDeployment, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_DEPLOYMENT_PROPERTIES, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetLatestDeploymentTool: ToolConfig< + TriggerDevBaseParams, + TriggerDevDeploymentResponse +> = { + id: 'trigger_dev_get_latest_deployment', + name: 'Trigger.dev Get Latest Deployment', + description: 'Retrieve the latest Trigger.dev deployment in the environment of the API key.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + }, + + request: { + url: `${TRIGGER_DEV_API_BASE}/api/v1/deployments/latest`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevDeployment(data), + } + }, + + outputs: TRIGGER_DEV_DEPLOYMENT_PROPERTIES, +} diff --git a/apps/sim/tools/trigger_dev/get_query_schema.ts b/apps/sim/tools/trigger_dev/get_query_schema.ts new file mode 100644 index 0000000000..2c71529800 --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_query_schema.ts @@ -0,0 +1,112 @@ +import type { TriggerDevBaseParams, TriggerDevQuerySchemaResponse } from '@/tools/trigger_dev/types' +import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetQuerySchemaTool: ToolConfig< + TriggerDevBaseParams, + TriggerDevQuerySchemaResponse +> = { + id: 'trigger_dev_get_query_schema', + name: 'Trigger.dev Get Query Schema', + description: + 'Retrieve the TRQL query schema: the tables and columns available for Execute Query, with types and allowed values.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + }, + + request: { + url: `${TRIGGER_DEV_API_BASE}/api/v1/query/schema`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + tables: (data.tables ?? []).map( + (table: { + name?: string + description?: string + timeColumn?: string + columns?: { + name?: string + type?: string + description?: string + example?: string + allowedValues?: string[] + coreColumn?: boolean + }[] + }) => ({ + name: table.name ?? null, + description: table.description ?? null, + timeColumn: table.timeColumn ?? null, + columns: (table.columns ?? []).map((column) => ({ + name: column.name ?? null, + type: column.type ?? null, + description: column.description ?? null, + example: column.example ?? null, + allowedValues: column.allowedValues ?? [], + coreColumn: column.coreColumn ?? false, + })), + }) + ), + }, + } + }, + + outputs: { + tables: { + type: 'array', + description: 'Tables that can be queried with TRQL', + items: { + type: 'object', + description: 'Queryable table', + properties: { + name: { type: 'string', description: 'Table name used in TRQL queries', nullable: true }, + description: { type: 'string', description: 'Description of the table', nullable: true }, + timeColumn: { + type: 'string', + description: 'Primary time column for the table', + nullable: true, + }, + columns: { + type: 'array', + description: 'Columns of the table', + items: { + type: 'object', + description: 'Table column', + properties: { + name: { type: 'string', description: 'Column name', nullable: true }, + type: { type: 'string', description: 'ClickHouse data type', nullable: true }, + description: { + type: 'string', + description: 'Column description', + nullable: true, + }, + example: { type: 'string', description: 'Example value', nullable: true }, + allowedValues: { + type: 'array', + description: 'Allowed values for enum-like columns', + items: { type: 'string', description: 'Allowed value' }, + }, + coreColumn: { + type: 'boolean', + description: 'Whether the column is included in default queries', + }, + }, + }, + }, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/get_run_events.ts b/apps/sim/tools/trigger_dev/get_run_events.ts new file mode 100644 index 0000000000..f36c514941 --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_run_events.ts @@ -0,0 +1,145 @@ +import type { TriggerDevRunEventsResponse, TriggerDevRunIdParams } from '@/tools/trigger_dev/types' +import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetRunEventsTool: ToolConfig< + TriggerDevRunIdParams, + TriggerDevRunEventsResponse +> = { + id: 'trigger_dev_get_run_events', + name: 'Trigger.dev Get Run Events', + description: + 'Retrieve the log and span events of a Trigger.dev run, including messages, levels, durations, and error events.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + runId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the run to retrieve events for (starts with run_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/runs/${encodeURIComponent(params.runId.trim())}/events`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + events: (data.events ?? []).map( + (event: { + spanId?: string + parentId?: string | null + runId?: string | null + message?: string + startTime?: string + duration?: number + isError?: boolean + isPartial?: boolean + isCancelled?: boolean + level?: string + kind?: string + attemptNumber?: number | null + taskSlug?: string + events?: { name?: string; time?: string; properties?: Record }[] + }) => ({ + spanId: event.spanId ?? null, + parentId: event.parentId ?? null, + runId: event.runId ?? null, + message: event.message ?? null, + startTime: event.startTime ?? null, + duration: event.duration ?? null, + isError: event.isError ?? false, + isPartial: event.isPartial ?? false, + isCancelled: event.isCancelled ?? false, + level: event.level ?? null, + kind: event.kind ?? null, + attemptNumber: event.attemptNumber ?? null, + taskSlug: event.taskSlug ?? null, + events: (event.events ?? []).map((spanEvent) => ({ + name: spanEvent.name ?? null, + time: spanEvent.time ?? null, + properties: spanEvent.properties ?? null, + })), + }) + ), + }, + } + }, + + outputs: { + events: { + type: 'array', + description: 'Log and span events recorded during the run', + items: { + type: 'object', + description: 'Run event', + properties: { + spanId: { type: 'string', description: 'Span ID of the event', nullable: true }, + parentId: { type: 'string', description: 'Parent span ID', nullable: true }, + runId: { + type: 'string', + description: 'Run ID associated with the event', + nullable: true, + }, + message: { type: 'string', description: 'Event message', nullable: true }, + startTime: { + type: 'string', + description: 'Start time as a bigint string (nanoseconds since epoch)', + nullable: true, + }, + duration: { + type: 'number', + description: 'Duration of the event in nanoseconds', + nullable: true, + }, + isError: { type: 'boolean', description: 'Whether the event represents an error' }, + isPartial: { type: 'boolean', description: 'Whether the event is still in progress' }, + isCancelled: { type: 'boolean', description: 'Whether the event was cancelled' }, + level: { + type: 'string', + description: 'Log level (TRACE, DEBUG, LOG, INFO, WARN, or ERROR)', + nullable: true, + }, + kind: { type: 'string', description: 'Kind of span event', nullable: true }, + attemptNumber: { + type: 'number', + description: 'Attempt number the event belongs to', + nullable: true, + }, + taskSlug: { type: 'string', description: 'Task identifier', nullable: true }, + events: { + type: 'array', + description: 'Span events (e.g., exceptions) that occurred during this event', + items: { + type: 'object', + description: 'Span event', + properties: { + name: { type: 'string', description: 'Event name', nullable: true }, + time: { type: 'string', description: 'When the event occurred', nullable: true }, + properties: { + type: 'json', + description: 'Event-specific properties', + nullable: true, + }, + }, + }, + }, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/get_run_result.ts b/apps/sim/tools/trigger_dev/get_run_result.ts new file mode 100644 index 0000000000..1de3696ff2 --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_run_result.ts @@ -0,0 +1,51 @@ +import type { TriggerDevRunIdParams, TriggerDevRunResultResponse } from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevRunResult, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_RUN_RESULT_PROPERTIES, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetRunResultTool: ToolConfig< + TriggerDevRunIdParams, + TriggerDevRunResultResponse +> = { + id: 'trigger_dev_get_run_result', + name: 'Trigger.dev Get Run Result', + description: + 'Retrieve the result of a Trigger.dev run: whether it succeeded, its output, and error details. Lighter than Get Run when only the outcome is needed.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + runId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the run to retrieve the result for (starts with run_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/runs/${encodeURIComponent(params.runId.trim())}/result`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevRunResult(data), + } + }, + + outputs: TRIGGER_DEV_RUN_RESULT_PROPERTIES, +} diff --git a/apps/sim/tools/trigger_dev/get_run_trace.ts b/apps/sim/tools/trigger_dev/get_run_trace.ts new file mode 100644 index 0000000000..e90c6a3658 --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_run_trace.ts @@ -0,0 +1,56 @@ +import type { TriggerDevRunIdParams, TriggerDevRunTraceResponse } from '@/tools/trigger_dev/types' +import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetRunTraceTool: ToolConfig< + TriggerDevRunIdParams, + TriggerDevRunTraceResponse +> = { + id: 'trigger_dev_get_run_trace', + name: 'Trigger.dev Get Run Trace', + description: + 'Retrieve the OpenTelemetry trace of a Trigger.dev run as a tree of spans with timing, errors, and nested children.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + runId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the run to retrieve the trace for (starts with run_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/runs/${encodeURIComponent(params.runId.trim())}/trace`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + traceId: data.trace?.traceId ?? null, + rootSpan: data.trace?.rootSpan ?? null, + }, + } + }, + + outputs: { + traceId: { type: 'string', description: 'OpenTelemetry trace ID of the run' }, + rootSpan: { + type: 'json', + description: + 'Root span of the trace; each span has id, parentId, runId, data (message, taskSlug, startTime, duration, isError, level, events), and recursively nested children spans', + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/get_waitpoint_token.ts b/apps/sim/tools/trigger_dev/get_waitpoint_token.ts new file mode 100644 index 0000000000..634ee1a26c --- /dev/null +++ b/apps/sim/tools/trigger_dev/get_waitpoint_token.ts @@ -0,0 +1,54 @@ +import type { + TriggerDevWaitpointIdParams, + TriggerDevWaitpointTokenResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevWaitpointToken, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_WAITPOINT_TOKEN_PROPERTIES, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevGetWaitpointTokenTool: ToolConfig< + TriggerDevWaitpointIdParams, + TriggerDevWaitpointTokenResponse +> = { + id: 'trigger_dev_get_waitpoint_token', + name: 'Trigger.dev Get Waitpoint Token', + description: + 'Retrieve a Trigger.dev waitpoint token by its ID, including its status, timeout, and completion data.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + waitpointId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'ID of the waitpoint token to retrieve (starts with waitpoint_)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/waitpoints/tokens/${encodeURIComponent(params.waitpointId.trim())}`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevWaitpointToken(data), + } + }, + + outputs: TRIGGER_DEV_WAITPOINT_TOKEN_PROPERTIES, +} diff --git a/apps/sim/tools/trigger_dev/import_env_vars.ts b/apps/sim/tools/trigger_dev/import_env_vars.ts new file mode 100644 index 0000000000..d9c392d993 --- /dev/null +++ b/apps/sim/tools/trigger_dev/import_env_vars.ts @@ -0,0 +1,89 @@ +import type { + TriggerDevImportEnvVarsParams, + TriggerDevImportEnvVarsResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevEnvVarsUrl, + buildTriggerDevHeaders, + parseJsonInput, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevImportEnvVarsTool: ToolConfig< + TriggerDevImportEnvVarsParams, + TriggerDevImportEnvVarsResponse +> = { + id: 'trigger_dev_import_env_vars', + name: 'Trigger.dev Import Env Vars', + description: + 'Upload multiple environment variables to a Trigger.dev project environment in one request.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + projectRef: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'External ref of the project, from the project settings (starts with proj_)', + }, + environment: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Environment to upload the variables to: dev, staging, or prod', + }, + variables: { + type: 'json', + required: true, + visibility: 'user-only', + description: + 'JSON array of environment variables to upload. Example: [{"name": "SLACK_API_KEY", "value": "slack_123"}]', + }, + override: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Whether to override existing variables: "true" or "false" (default false)', + }, + }, + + request: { + url: (params) => `${buildTriggerDevEnvVarsUrl(params.projectRef, params.environment)}/import`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => { + const variables = parseJsonInput(params.variables, 'variables') + if (!Array.isArray(variables)) { + throw new Error('The variables parameter must be a JSON array of {"name", "value"} objects') + } + const body: Record = { variables } + if (params.override === 'true' || params.override === 'false') { + body.override = params.override === 'true' + } + return body + }, + }, + + transformResponse: async (response, params) => { + const data = await response.json() + const variables = parseJsonInput(params?.variables, 'variables') + return { + success: true, + output: { + success: data.success ?? true, + count: Array.isArray(variables) ? variables.length : 0, + }, + } + }, + + outputs: { + success: { type: 'boolean', description: 'Whether the environment variables were uploaded' }, + count: { type: 'number', description: 'Number of environment variables submitted' }, + }, +} diff --git a/apps/sim/tools/trigger_dev/index.ts b/apps/sim/tools/trigger_dev/index.ts index f59351b498..1c8f277744 100644 --- a/apps/sim/tools/trigger_dev/index.ts +++ b/apps/sim/tools/trigger_dev/index.ts @@ -1,21 +1,42 @@ export { triggerDevActivateScheduleTool } from '@/tools/trigger_dev/activate_schedule' +export { triggerDevAddRunTagsTool } from '@/tools/trigger_dev/add_run_tags' export { triggerDevBatchTriggerTaskTool } from '@/tools/trigger_dev/batch_trigger_task' export { triggerDevCancelRunTool } from '@/tools/trigger_dev/cancel_run' +export { triggerDevCompleteWaitpointTokenTool } from '@/tools/trigger_dev/complete_waitpoint_token' export { triggerDevCreateEnvVarTool } from '@/tools/trigger_dev/create_env_var' export { triggerDevCreateScheduleTool } from '@/tools/trigger_dev/create_schedule' +export { triggerDevCreateWaitpointTokenTool } from '@/tools/trigger_dev/create_waitpoint_token' export { triggerDevDeactivateScheduleTool } from '@/tools/trigger_dev/deactivate_schedule' export { triggerDevDeleteEnvVarTool } from '@/tools/trigger_dev/delete_env_var' export { triggerDevDeleteScheduleTool } from '@/tools/trigger_dev/delete_schedule' +export { triggerDevExecuteQueryTool } from '@/tools/trigger_dev/execute_query' +export { triggerDevGetBatchTool } from '@/tools/trigger_dev/get_batch' +export { triggerDevGetBatchResultsTool } from '@/tools/trigger_dev/get_batch_results' +export { triggerDevGetDeploymentTool } from '@/tools/trigger_dev/get_deployment' export { triggerDevGetEnvVarTool } from '@/tools/trigger_dev/get_env_var' +export { triggerDevGetLatestDeploymentTool } from '@/tools/trigger_dev/get_latest_deployment' +export { triggerDevGetQuerySchemaTool } from '@/tools/trigger_dev/get_query_schema' export { triggerDevGetQueueTool } from '@/tools/trigger_dev/get_queue' export { triggerDevGetRunTool } from '@/tools/trigger_dev/get_run' +export { triggerDevGetRunEventsTool } from '@/tools/trigger_dev/get_run_events' +export { triggerDevGetRunResultTool } from '@/tools/trigger_dev/get_run_result' +export { triggerDevGetRunTraceTool } from '@/tools/trigger_dev/get_run_trace' export { triggerDevGetScheduleTool } from '@/tools/trigger_dev/get_schedule' +export { triggerDevGetWaitpointTokenTool } from '@/tools/trigger_dev/get_waitpoint_token' +export { triggerDevImportEnvVarsTool } from '@/tools/trigger_dev/import_env_vars' +export { triggerDevListDeploymentsTool } from '@/tools/trigger_dev/list_deployments' export { triggerDevListEnvVarsTool } from '@/tools/trigger_dev/list_env_vars' +export { triggerDevListQueuesTool } from '@/tools/trigger_dev/list_queues' export { triggerDevListRunsTool } from '@/tools/trigger_dev/list_runs' export { triggerDevListSchedulesTool } from '@/tools/trigger_dev/list_schedules' +export { triggerDevListTimezonesTool } from '@/tools/trigger_dev/list_timezones' +export { triggerDevListWaitpointTokensTool } from '@/tools/trigger_dev/list_waitpoint_tokens' +export { triggerDevOverrideQueueConcurrencyTool } from '@/tools/trigger_dev/override_queue_concurrency' export { triggerDevPauseQueueTool } from '@/tools/trigger_dev/pause_queue' +export { triggerDevPromoteDeploymentTool } from '@/tools/trigger_dev/promote_deployment' export { triggerDevReplayRunTool } from '@/tools/trigger_dev/replay_run' export { triggerDevRescheduleRunTool } from '@/tools/trigger_dev/reschedule_run' +export { triggerDevResetQueueConcurrencyTool } from '@/tools/trigger_dev/reset_queue_concurrency' export { triggerDevResumeQueueTool } from '@/tools/trigger_dev/resume_queue' export { triggerDevTriggerTaskTool } from '@/tools/trigger_dev/trigger_task' export { triggerDevUpdateEnvVarTool } from '@/tools/trigger_dev/update_env_var' diff --git a/apps/sim/tools/trigger_dev/list_deployments.ts b/apps/sim/tools/trigger_dev/list_deployments.ts new file mode 100644 index 0000000000..1f1cf9a08f --- /dev/null +++ b/apps/sim/tools/trigger_dev/list_deployments.ts @@ -0,0 +1,122 @@ +import type { + TriggerDevListDeploymentsParams, + TriggerDevListDeploymentsResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevDeployment, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_DEPLOYMENT_PROPERTIES, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevListDeploymentsTool: ToolConfig< + TriggerDevListDeploymentsParams, + TriggerDevListDeploymentsResponse +> = { + id: 'trigger_dev_list_deployments', + name: 'Trigger.dev List Deployments', + description: + 'List Trigger.dev deployments in the environment of the API key, with optional status and creation-time filters.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + status: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Deployment status to filter by: PENDING, BUILDING, DEPLOYING, DEPLOYED, FAILED, CANCELED, or TIMED_OUT', + }, + period: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Only return deployments created in the given period (e.g., "1h", "7d")', + }, + from: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Only return deployments created on or after this ISO 8601 timestamp', + }, + to: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Only return deployments created on or before this ISO 8601 timestamp', + }, + pageSize: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of deployments per page (5 to 100, default 20)', + }, + pageAfter: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Cursor to start the page after, from the previous response pagination', + }, + }, + + request: { + url: (params) => { + const query = new URLSearchParams() + if (params.pageSize) query.set('page[size]', String(params.pageSize)) + if (params.pageAfter) query.set('page[after]', params.pageAfter) + if (params.status) query.set('status', params.status.toUpperCase()) + if (params.period) query.set('period', params.period) + if (params.from) query.set('from', params.from) + if (params.to) query.set('to', params.to) + const queryString = query.toString() + return queryString + ? `${TRIGGER_DEV_API_BASE}/api/v1/deployments?${queryString}` + : `${TRIGGER_DEV_API_BASE}/api/v1/deployments` + }, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + deployments: (data.data ?? []).map(mapTriggerDevDeployment), + pagination: { + next: data.pagination?.next ?? null, + }, + }, + } + }, + + outputs: { + deployments: { + type: 'array', + description: 'Deployments matching the filters', + items: { + type: 'object', + description: 'Deployment', + properties: TRIGGER_DEV_DEPLOYMENT_PROPERTIES, + }, + }, + pagination: { + type: 'object', + description: 'Cursor pagination details', + properties: { + next: { + type: 'string', + description: 'Cursor to pass as the page-after parameter for the next page', + nullable: true, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/list_queues.ts b/apps/sim/tools/trigger_dev/list_queues.ts new file mode 100644 index 0000000000..29862d6182 --- /dev/null +++ b/apps/sim/tools/trigger_dev/list_queues.ts @@ -0,0 +1,135 @@ +import type { + TriggerDevListQueuesParams, + TriggerDevListQueuesResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevQueue, + TRIGGER_DEV_API_BASE, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevListQueuesTool: ToolConfig< + TriggerDevListQueuesParams, + TriggerDevListQueuesResponse +> = { + id: 'trigger_dev_list_queues', + name: 'Trigger.dev List Queues', + description: + 'List the queues in the environment of the API key, including running and queued counts, with page-based pagination.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + page: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Page number to return (default 1)', + }, + perPage: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of queues per page', + }, + }, + + request: { + url: (params) => { + const query = new URLSearchParams() + if (params.page) query.set('page', String(params.page)) + if (params.perPage) query.set('perPage', String(params.perPage)) + const queryString = query.toString() + return queryString + ? `${TRIGGER_DEV_API_BASE}/api/v1/queues?${queryString}` + : `${TRIGGER_DEV_API_BASE}/api/v1/queues` + }, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + queues: (data.data ?? []).map(mapTriggerDevQueue), + pagination: { + currentPage: data.pagination?.currentPage ?? null, + totalPages: data.pagination?.totalPages ?? null, + count: data.pagination?.count ?? null, + }, + }, + } + }, + + outputs: { + queues: { + type: 'array', + description: 'Queues in the environment', + items: { + type: 'object', + description: 'Queue', + properties: { + id: { type: 'string', description: 'Unique ID of the queue (starts with queue_)' }, + name: { type: 'string', description: 'Name of the queue' }, + type: { + type: 'string', + description: 'Queue type (task for task-default queues, custom for named queues)', + nullable: true, + }, + running: { + type: 'number', + description: 'Number of runs currently executing', + nullable: true, + }, + queued: { + type: 'number', + description: 'Number of runs waiting in the queue', + nullable: true, + }, + paused: { type: 'boolean', description: 'Whether the queue is paused' }, + concurrencyLimit: { + type: 'number', + description: 'Maximum number of runs that can execute concurrently', + nullable: true, + }, + concurrency: { + type: 'object', + description: 'Concurrency details for the queue', + nullable: true, + properties: { + current: { type: 'number', description: 'Current concurrency limit', nullable: true }, + base: { type: 'number', description: 'Base concurrency limit', nullable: true }, + override: { + type: 'number', + description: 'Overridden concurrency limit', + nullable: true, + }, + overriddenAt: { + type: 'string', + description: 'ISO timestamp when the concurrency limit was overridden', + nullable: true, + }, + }, + }, + }, + }, + }, + pagination: { + type: 'object', + description: 'Page-based pagination details', + properties: { + currentPage: { type: 'number', description: 'Current page number', nullable: true }, + totalPages: { type: 'number', description: 'Total number of pages', nullable: true }, + count: { type: 'number', description: 'Total number of queues', nullable: true }, + }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/list_runs.ts b/apps/sim/tools/trigger_dev/list_runs.ts index c3dc8bbaba..f3f80f1c02 100644 --- a/apps/sim/tools/trigger_dev/list_runs.ts +++ b/apps/sim/tools/trigger_dev/list_runs.ts @@ -110,24 +110,20 @@ export const triggerDevListRunsTool: ToolConfig< if (params.pageAfter) query.set('page[after]', params.pageAfter) if (params.pageBefore) query.set('page[before]', params.pageBefore) if (params.status) { - for (const status of splitCommaSeparated(params.status)) { - query.append('filter[status]', status.toUpperCase()) - } + const statuses = splitCommaSeparated(params.status).map((status) => status.toUpperCase()) + if (statuses.length > 0) query.set('filter[status]', statuses.join(',')) } if (params.taskIdentifier) { - for (const task of splitCommaSeparated(params.taskIdentifier)) { - query.append('filter[taskIdentifier]', task) - } + const tasks = splitCommaSeparated(params.taskIdentifier) + if (tasks.length > 0) query.set('filter[taskIdentifier]', tasks.join(',')) } if (params.version) { - for (const version of splitCommaSeparated(params.version)) { - query.append('filter[version]', version) - } + const versions = splitCommaSeparated(params.version) + if (versions.length > 0) query.set('filter[version]', versions.join(',')) } if (params.tag) { - for (const tag of splitCommaSeparated(params.tag)) { - query.append('filter[tag]', tag) - } + const tags = splitCommaSeparated(params.tag) + if (tags.length > 0) query.set('filter[tag]', tags.join(',')) } if (params.schedule) query.set('filter[schedule]', params.schedule) if (params.isTest === 'true' || params.isTest === 'false') { diff --git a/apps/sim/tools/trigger_dev/list_timezones.ts b/apps/sim/tools/trigger_dev/list_timezones.ts new file mode 100644 index 0000000000..6de0e178d3 --- /dev/null +++ b/apps/sim/tools/trigger_dev/list_timezones.ts @@ -0,0 +1,59 @@ +import type { + TriggerDevListTimezonesParams, + TriggerDevListTimezonesResponse, +} from '@/tools/trigger_dev/types' +import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevListTimezonesTool: ToolConfig< + TriggerDevListTimezonesParams, + TriggerDevListTimezonesResponse +> = { + id: 'trigger_dev_list_timezones', + name: 'Trigger.dev List Timezones', + description: + 'List the IANA timezones supported by Trigger.dev schedules, for use as the timezone of a cron schedule.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + excludeUtc: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Set to "true" to exclude UTC from the returned timezones', + }, + }, + + request: { + url: (params) => + params.excludeUtc === 'true' + ? `${TRIGGER_DEV_API_BASE}/api/v1/timezones?excludeUtc=true` + : `${TRIGGER_DEV_API_BASE}/api/v1/timezones`, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + timezones: data.timezones ?? [], + }, + } + }, + + outputs: { + timezones: { + type: 'array', + description: 'IANA timezones supported by schedules', + items: { type: 'string', description: 'IANA timezone name' }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/list_waitpoint_tokens.ts b/apps/sim/tools/trigger_dev/list_waitpoint_tokens.ts new file mode 100644 index 0000000000..8ea212c35d --- /dev/null +++ b/apps/sim/tools/trigger_dev/list_waitpoint_tokens.ts @@ -0,0 +1,152 @@ +import type { + TriggerDevListWaitpointTokensParams, + TriggerDevListWaitpointTokensResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevWaitpointToken, + splitCommaSeparated, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_WAITPOINT_TOKEN_PROPERTIES, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevListWaitpointTokensTool: ToolConfig< + TriggerDevListWaitpointTokensParams, + TriggerDevListWaitpointTokensResponse +> = { + id: 'trigger_dev_list_waitpoint_tokens', + name: 'Trigger.dev List Waitpoint Tokens', + description: + 'List Trigger.dev waitpoint tokens in the environment of the API key, with optional status, tag, and creation-time filters.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + status: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Waitpoint status to filter by: WAITING, COMPLETED, or TIMED_OUT', + }, + idempotencyKey: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Idempotency key to filter by', + }, + tags: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated tags to filter by', + }, + period: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Only return tokens created in the given period (e.g., "1h", "7d")', + }, + from: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Only return tokens created on or after this ISO 8601 timestamp', + }, + to: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Only return tokens created on or before this ISO 8601 timestamp', + }, + pageSize: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of tokens per page (max 100)', + }, + pageAfter: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Waitpoint ID to start the page after, for forward pagination', + }, + pageBefore: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Waitpoint ID to start the page before, for backward pagination', + }, + }, + + request: { + url: (params) => { + const query = new URLSearchParams() + if (params.pageSize) query.set('page[size]', String(params.pageSize)) + if (params.pageAfter) query.set('page[after]', params.pageAfter) + if (params.pageBefore) query.set('page[before]', params.pageBefore) + if (params.status) query.set('filter[status]', params.status.toUpperCase()) + if (params.idempotencyKey) query.set('filter[idempotencyKey]', params.idempotencyKey) + if (params.tags) { + const tags = splitCommaSeparated(params.tags) + if (tags.length > 0) query.set('filter[tags]', tags.join(',')) + } + if (params.period) query.set('filter[createdAt][period]', params.period) + if (params.from) query.set('filter[createdAt][from]', params.from) + if (params.to) query.set('filter[createdAt][to]', params.to) + const queryString = query.toString() + return queryString + ? `${TRIGGER_DEV_API_BASE}/api/v1/waitpoints/tokens?${queryString}` + : `${TRIGGER_DEV_API_BASE}/api/v1/waitpoints/tokens` + }, + method: 'GET', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + tokens: (data.data ?? []).map(mapTriggerDevWaitpointToken), + pagination: { + next: data.pagination?.next ?? null, + previous: data.pagination?.previous ?? null, + }, + }, + } + }, + + outputs: { + tokens: { + type: 'array', + description: 'Waitpoint tokens matching the filters', + items: { + type: 'object', + description: 'Waitpoint token', + properties: TRIGGER_DEV_WAITPOINT_TOKEN_PROPERTIES, + }, + }, + pagination: { + type: 'object', + description: 'Cursor pagination details', + properties: { + next: { + type: 'string', + description: 'Waitpoint ID to start the next page after', + nullable: true, + }, + previous: { + type: 'string', + description: 'Waitpoint ID to start the previous page before', + nullable: true, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/override_queue_concurrency.ts b/apps/sim/tools/trigger_dev/override_queue_concurrency.ts new file mode 100644 index 0000000000..361746bd38 --- /dev/null +++ b/apps/sim/tools/trigger_dev/override_queue_concurrency.ts @@ -0,0 +1,71 @@ +import type { + TriggerDevOverrideQueueConcurrencyParams, + TriggerDevQueueResponse, +} from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevQueue, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_QUEUE_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevOverrideQueueConcurrencyTool: ToolConfig< + TriggerDevOverrideQueueConcurrencyParams, + TriggerDevQueueResponse +> = { + id: 'trigger_dev_override_queue_concurrency', + name: 'Trigger.dev Override Queue Concurrency', + description: 'Override the concurrency limit of a Trigger.dev queue with a new value.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + queueName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Queue ID (starts with queue_), task identifier, or custom queue name, depending on the queue type', + }, + queueType: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'How to interpret the queue name: "id" (default) for a queue ID, "task" for a task identifier, or "custom" for a custom queue name', + }, + concurrencyLimit: { + type: 'number', + required: true, + visibility: 'user-or-llm', + description: 'New concurrency limit for the queue (0 to 100000)', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/queues/${encodeURIComponent(params.queueName.trim())}/concurrency/override`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => ({ + concurrencyLimit: params.concurrencyLimit, + ...(params.queueType ? { type: params.queueType } : {}), + }), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevQueue(data), + } + }, + + outputs: TRIGGER_DEV_QUEUE_OUTPUTS, +} diff --git a/apps/sim/tools/trigger_dev/promote_deployment.ts b/apps/sim/tools/trigger_dev/promote_deployment.ts new file mode 100644 index 0000000000..8e78a7b018 --- /dev/null +++ b/apps/sim/tools/trigger_dev/promote_deployment.ts @@ -0,0 +1,65 @@ +import type { + TriggerDevPromoteDeploymentParams, + TriggerDevPromoteDeploymentResponse, +} from '@/tools/trigger_dev/types' +import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevPromoteDeploymentTool: ToolConfig< + TriggerDevPromoteDeploymentParams, + TriggerDevPromoteDeploymentResponse +> = { + id: 'trigger_dev_promote_deployment', + name: 'Trigger.dev Promote Deployment', + description: + 'Promote a Trigger.dev deployment version so new runs execute on it (e.g., to roll back to a previous version).', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + version: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Deployment version to promote (e.g., "20250228.1")', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/deployments/${encodeURIComponent(params.version.trim())}/promote`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: { + id: data.id, + version: data.version ?? null, + shortCode: data.shortCode ?? null, + }, + } + }, + + outputs: { + id: { type: 'string', description: 'ID of the promoted deployment' }, + version: { + type: 'string', + description: 'Version of the promoted deployment', + optional: true, + }, + shortCode: { + type: 'string', + description: 'Short code of the promoted deployment', + optional: true, + }, + }, +} diff --git a/apps/sim/tools/trigger_dev/reset_queue_concurrency.ts b/apps/sim/tools/trigger_dev/reset_queue_concurrency.ts new file mode 100644 index 0000000000..92141522e1 --- /dev/null +++ b/apps/sim/tools/trigger_dev/reset_queue_concurrency.ts @@ -0,0 +1,60 @@ +import type { TriggerDevQueueParams, TriggerDevQueueResponse } from '@/tools/trigger_dev/types' +import { + buildTriggerDevHeaders, + mapTriggerDevQueue, + TRIGGER_DEV_API_BASE, + TRIGGER_DEV_QUEUE_OUTPUTS, +} from '@/tools/trigger_dev/utils' +import type { ToolConfig } from '@/tools/types' + +export const triggerDevResetQueueConcurrencyTool: ToolConfig< + TriggerDevQueueParams, + TriggerDevQueueResponse +> = { + id: 'trigger_dev_reset_queue_concurrency', + name: 'Trigger.dev Reset Queue Concurrency', + description: + 'Reset the concurrency limit of a Trigger.dev queue back to its base value, removing any override.', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Trigger.dev secret API key (starts with tr_)', + }, + queueName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Queue ID (starts with queue_), task identifier, or custom queue name, depending on the queue type', + }, + queueType: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'How to interpret the queue name: "id" (default) for a queue ID, "task" for a task identifier, or "custom" for a custom queue name', + }, + }, + + request: { + url: (params) => + `${TRIGGER_DEV_API_BASE}/api/v1/queues/${encodeURIComponent(params.queueName.trim())}/concurrency/reset`, + method: 'POST', + headers: (params) => buildTriggerDevHeaders(params.apiKey), + body: (params) => (params.queueType ? { type: params.queueType } : {}), + }, + + transformResponse: async (response) => { + const data = await response.json() + return { + success: true, + output: mapTriggerDevQueue(data), + } + }, + + outputs: TRIGGER_DEV_QUEUE_OUTPUTS, +} diff --git a/apps/sim/tools/trigger_dev/types.ts b/apps/sim/tools/trigger_dev/types.ts index bcb2d6c9cd..852584e7ed 100644 --- a/apps/sim/tools/trigger_dev/types.ts +++ b/apps/sim/tools/trigger_dev/types.ts @@ -1,6 +1,6 @@ import type { ToolResponse } from '@/tools/types' -interface TriggerDevBaseParams { +export interface TriggerDevBaseParams { apiKey: string } @@ -223,6 +223,132 @@ export interface TriggerDevEnvVar { value: string } +/** Raw run result object returned by the run result and batch results endpoints */ +export interface TriggerDevApiRunResult { + ok: boolean + id: string + taskIdentifier?: string + output?: string + outputType?: string + error?: Record + usage?: { + durationMs?: number + } +} + +/** Normalized run result returned by the run result and batch results tools */ +export interface TriggerDevRunResult { + ok: boolean + id: string + taskIdentifier: string | null + output: unknown + outputType: string | null + error: Record | null + durationMs: number | null +} + +/** Span event entry attached to a run event or trace span */ +export interface TriggerDevSpanEvent { + name: string | null + time: string | null + properties: Record | null +} + +/** Normalized run event returned by the run events tool */ +export interface TriggerDevRunEvent { + spanId: string | null + parentId: string | null + runId: string | null + message: string | null + startTime: string | null + duration: number | null + isError: boolean + isPartial: boolean + isCancelled: boolean + level: string | null + kind: string | null + attemptNumber: number | null + taskSlug: string | null + events: TriggerDevSpanEvent[] +} + +/** Raw deployment object returned by the deployments endpoints */ +export interface TriggerDevApiDeployment { + id: string + status: string + createdAt?: string + shortCode?: string + version?: string + runtime?: string | null + runtimeVersion?: string | null + deployedAt?: string | null + git?: Record | null + error?: Record | null + contentHash?: string + imageReference?: string | null + errorData?: Record | null + worker?: { + id?: string + version?: string + tasks?: { + id?: string + slug?: string + filePath?: string + }[] + } | null +} + +/** Normalized deployment returned by the deployment tools */ +export interface TriggerDevDeployment { + id: string + status: string + version: string | null + shortCode: string | null + createdAt: string | null + deployedAt: string | null + runtime: string | null + runtimeVersion: string | null + git: Record | null + error: Record | null + tasks: { + id: string | null + slug: string | null + filePath: string | null + }[] +} + +/** Raw waitpoint token object returned by the waitpoint endpoints */ +export interface TriggerDevApiWaitpointToken { + id: string + url: string + status: string + idempotencyKey?: string | null + idempotencyKeyExpiresAt?: string | null + timeoutAt?: string | null + completedAt?: string | null + output?: string | null + outputType?: string | null + outputIsError?: boolean | null + tags?: string[] + createdAt?: string +} + +/** Normalized waitpoint token returned by the waitpoint tools */ +export interface TriggerDevWaitpointToken { + id: string + url: string + status: string + idempotencyKey: string | null + idempotencyKeyExpiresAt: string | null + timeoutAt: string | null + completedAt: string | null + output: unknown + outputType: string | null + outputIsError: boolean + tags: string[] + createdAt: string | null +} + export interface TriggerDevTriggerTaskParams extends TriggerDevBaseParams { taskIdentifier: string payload?: string | Record @@ -249,6 +375,15 @@ export interface TriggerDevRescheduleRunParams extends TriggerDevBaseParams { delay: string } +export interface TriggerDevAddRunTagsParams extends TriggerDevBaseParams { + runId: string + tags: string +} + +export interface TriggerDevBatchIdParams extends TriggerDevBaseParams { + batchId: string +} + export interface TriggerDevUpdateRunMetadataParams extends TriggerDevBaseParams { runId: string metadata: string | Record @@ -272,9 +407,9 @@ export interface TriggerDevListRunsParams extends TriggerDevBaseParams { export interface TriggerDevCreateScheduleParams extends TriggerDevBaseParams { task: string cron: string + deduplicationKey: string timezone?: string externalId?: string - deduplicationKey?: string } export interface TriggerDevUpdateScheduleParams extends TriggerDevBaseParams { @@ -307,11 +442,83 @@ export interface TriggerDevEnvVarWriteParams extends TriggerDevEnvVarNameParams value: string } +export interface TriggerDevImportEnvVarsParams extends TriggerDevEnvVarsScopeParams { + variables: string | Record[] + override?: string +} + export interface TriggerDevQueueParams extends TriggerDevBaseParams { queueName: string queueType?: string } +export interface TriggerDevListQueuesParams extends TriggerDevBaseParams { + page?: number + perPage?: number +} + +export interface TriggerDevOverrideQueueConcurrencyParams extends TriggerDevQueueParams { + concurrencyLimit: number +} + +export interface TriggerDevListDeploymentsParams extends TriggerDevBaseParams { + status?: string + period?: string + from?: string + to?: string + pageSize?: number + pageAfter?: string +} + +export interface TriggerDevGetDeploymentParams extends TriggerDevBaseParams { + deploymentId: string +} + +export interface TriggerDevPromoteDeploymentParams extends TriggerDevBaseParams { + version: string +} + +export interface TriggerDevExecuteQueryParams extends TriggerDevBaseParams { + query: string + scope?: string + period?: string + from?: string + to?: string + format?: string +} + +export interface TriggerDevCreateWaitpointTokenParams extends TriggerDevBaseParams { + timeout?: string + idempotencyKey?: string + idempotencyKeyTTL?: string + tags?: string +} + +export interface TriggerDevWaitpointIdParams extends TriggerDevBaseParams { + waitpointId: string +} + +export interface TriggerDevCompleteWaitpointTokenParams extends TriggerDevBaseParams { + waitpointId: string + data?: string | Record +} + +export interface TriggerDevListWaitpointTokensParams extends TriggerDevBaseParams { + status?: string + idempotencyKey?: string + tags?: string + period?: string + from?: string + to?: string + pageSize?: number + pageAfter?: string + pageBefore?: string +} + +export interface TriggerDevListTimezonesParams extends TriggerDevBaseParams { + excludeUtc?: string +} + export interface TriggerDevTriggerTaskResponse extends ToolResponse { output: { id: string @@ -325,6 +532,159 @@ export interface TriggerDevBatchTriggerTaskResponse extends ToolResponse { } } +/** Normalized batch returned by the get batch tool */ +export interface TriggerDevBatch { + id: string + status: string + idempotencyKey: string | null + createdAt: string | null + updatedAt: string | null + runCount: number | null + runIds: string[] + successfulRunCount: number | null + failedRunCount: number | null + errors: + | { + index: number | null + taskIdentifier: string | null + error: Record | null + errorCode: string | null + }[] + | null +} + +export interface TriggerDevGetBatchResponse extends ToolResponse { + output: TriggerDevBatch +} + +export interface TriggerDevBatchResultsResponse extends ToolResponse { + output: { + id: string + items: TriggerDevRunResult[] + } +} + +export interface TriggerDevRunResultResponse extends ToolResponse { + output: TriggerDevRunResult +} + +export interface TriggerDevAddRunTagsResponse extends ToolResponse { + output: { + message: string + } +} + +export interface TriggerDevRunEventsResponse extends ToolResponse { + output: { + events: TriggerDevRunEvent[] + } +} + +export interface TriggerDevRunTraceResponse extends ToolResponse { + output: { + traceId: string | null + rootSpan: Record | null + } +} + +export interface TriggerDevListQueuesResponse extends ToolResponse { + output: { + queues: TriggerDevQueue[] + pagination: { + currentPage: number | null + totalPages: number | null + count: number | null + } + } +} + +export interface TriggerDevDeploymentResponse extends ToolResponse { + output: TriggerDevDeployment +} + +export interface TriggerDevListDeploymentsResponse extends ToolResponse { + output: { + deployments: TriggerDevDeployment[] + pagination: { + next: string | null + } + } +} + +export interface TriggerDevPromoteDeploymentResponse extends ToolResponse { + output: { + id: string + version: string | null + shortCode: string | null + } +} + +export interface TriggerDevExecuteQueryResponse extends ToolResponse { + output: { + format: string + results: unknown + } +} + +export interface TriggerDevQuerySchemaResponse extends ToolResponse { + output: { + tables: { + name: string | null + description: string | null + timeColumn: string | null + columns: { + name: string | null + type: string | null + description: string | null + example: string | null + allowedValues: string[] + coreColumn: boolean + }[] + }[] + } +} + +export interface TriggerDevCreateWaitpointTokenResponse extends ToolResponse { + output: { + id: string + isCached: boolean + url: string + } +} + +export interface TriggerDevCompleteWaitpointTokenResponse extends ToolResponse { + output: { + success: boolean + } +} + +export interface TriggerDevWaitpointTokenResponse extends ToolResponse { + output: TriggerDevWaitpointToken +} + +export interface TriggerDevListWaitpointTokensResponse extends ToolResponse { + output: { + tokens: TriggerDevWaitpointToken[] + pagination: { + next: string | null + previous: string | null + } + } +} + +export interface TriggerDevImportEnvVarsResponse extends ToolResponse { + output: { + success: boolean + count: number + } +} + +export interface TriggerDevListTimezonesResponse extends ToolResponse { + output: { + timezones: string[] + } +} + export interface TriggerDevUpdateRunMetadataResponse extends ToolResponse { output: { metadata: Record | null @@ -397,9 +757,15 @@ export interface TriggerDevDeleteScheduleResponse extends ToolResponse { export type TriggerDevResponse = | TriggerDevTriggerTaskResponse | TriggerDevBatchTriggerTaskResponse + | TriggerDevGetBatchResponse + | TriggerDevBatchResultsResponse | TriggerDevRunResponse + | TriggerDevRunResultResponse | TriggerDevListRunsResponse | TriggerDevRunActionResponse + | TriggerDevAddRunTagsResponse + | TriggerDevRunEventsResponse + | TriggerDevRunTraceResponse | TriggerDevUpdateRunMetadataResponse | TriggerDevScheduleResponse | TriggerDevListSchedulesResponse @@ -407,4 +773,16 @@ export type TriggerDevResponse = | TriggerDevListEnvVarsResponse | TriggerDevEnvVarResponse | TriggerDevEnvVarActionResponse + | TriggerDevImportEnvVarsResponse | TriggerDevQueueResponse + | TriggerDevListQueuesResponse + | TriggerDevDeploymentResponse + | TriggerDevListDeploymentsResponse + | TriggerDevPromoteDeploymentResponse + | TriggerDevExecuteQueryResponse + | TriggerDevQuerySchemaResponse + | TriggerDevCreateWaitpointTokenResponse + | TriggerDevCompleteWaitpointTokenResponse + | TriggerDevWaitpointTokenResponse + | TriggerDevListWaitpointTokensResponse + | TriggerDevListTimezonesResponse diff --git a/apps/sim/tools/trigger_dev/utils.ts b/apps/sim/tools/trigger_dev/utils.ts index d1c0225c63..328ab42efd 100644 --- a/apps/sim/tools/trigger_dev/utils.ts +++ b/apps/sim/tools/trigger_dev/utils.ts @@ -1,14 +1,20 @@ import type { TriggerDevApiAttempt, + TriggerDevApiDeployment, TriggerDevApiQueue, TriggerDevApiRun, TriggerDevApiRunDetail, + TriggerDevApiRunResult, TriggerDevApiSchedule, + TriggerDevApiWaitpointToken, TriggerDevAttempt, + TriggerDevDeployment, TriggerDevQueue, TriggerDevRunDetail, + TriggerDevRunResult, TriggerDevRunSummary, TriggerDevSchedule, + TriggerDevWaitpointToken, } from '@/tools/trigger_dev/types' import type { OutputProperty, ToolConfig } from '@/tools/types' @@ -153,6 +159,88 @@ export function mapTriggerDevRunDetail(run: TriggerDevApiRunDetail): TriggerDevR } } +/** + * Parses a serialized output value using its declared content type. + * Trigger.dev returns run and waitpoint outputs as serialized strings with an + * accompanying content type; JSON payloads are parsed so downstream blocks can + * reference fields directly. Unparseable values are returned as-is. + */ +export function parseSerializedOutput( + output: string | null | undefined, + outputType: string | null | undefined +): unknown { + if (output === undefined || output === null) return null + if (outputType === 'application/json') { + try { + return JSON.parse(output) + } catch { + return output + } + } + return output +} + +/** + * Maps a raw Trigger.dev run result object (run result and batch results + * responses) to the normalized run result shape. + */ +export function mapTriggerDevRunResult(result: TriggerDevApiRunResult): TriggerDevRunResult { + return { + ok: result.ok, + id: result.id, + taskIdentifier: result.taskIdentifier ?? null, + output: parseSerializedOutput(result.output, result.outputType), + outputType: result.outputType ?? null, + error: result.error ?? null, + durationMs: result.usage?.durationMs ?? null, + } +} + +/** + * Maps a raw Trigger.dev deployment object to the normalized deployment shape. + */ +export function mapTriggerDevDeployment(deployment: TriggerDevApiDeployment): TriggerDevDeployment { + return { + id: deployment.id, + status: deployment.status, + version: deployment.version ?? null, + shortCode: deployment.shortCode ?? null, + createdAt: deployment.createdAt ?? null, + deployedAt: deployment.deployedAt ?? null, + runtime: deployment.runtime ?? null, + runtimeVersion: deployment.runtimeVersion ?? null, + git: deployment.git ?? null, + error: deployment.error ?? deployment.errorData ?? null, + tasks: (deployment.worker?.tasks ?? []).map((task) => ({ + id: task.id ?? null, + slug: task.slug ?? null, + filePath: task.filePath ?? null, + })), + } +} + +/** + * Maps a raw Trigger.dev waitpoint token object to the normalized token shape. + */ +export function mapTriggerDevWaitpointToken( + token: TriggerDevApiWaitpointToken +): TriggerDevWaitpointToken { + return { + id: token.id, + url: token.url, + status: token.status, + idempotencyKey: token.idempotencyKey ?? null, + idempotencyKeyExpiresAt: token.idempotencyKeyExpiresAt ?? null, + timeoutAt: token.timeoutAt ?? null, + completedAt: token.completedAt ?? null, + output: parseSerializedOutput(token.output, token.outputType), + outputType: token.outputType ?? null, + outputIsError: token.outputIsError ?? false, + tags: token.tags ?? [], + createdAt: token.createdAt ?? null, + } +} + /** * Maps a raw Trigger.dev queue object to the normalized queue shape. */ @@ -534,3 +622,186 @@ export const TRIGGER_DEV_QUEUE_OUTPUTS: NonNullable = { }, }, } + +/** + * Output schema for a normalized run result, shared by the run result and + * batch results tools. + */ +export const TRIGGER_DEV_RUN_RESULT_PROPERTIES: Record = { + ok: { type: 'boolean', description: 'Whether the run completed successfully' }, + id: { type: 'string', description: 'ID of the run (starts with run_)' }, + taskIdentifier: { + type: 'string', + description: 'Identifier of the task the run executed', + optional: true, + nullable: true, + }, + output: { + type: 'json', + description: 'Output returned by the run, parsed when the output type is JSON', + optional: true, + nullable: true, + }, + outputType: { + type: 'string', + description: 'Content type of the serialized output (e.g., application/json)', + optional: true, + nullable: true, + }, + error: { + type: 'json', + description: 'Error details when the run failed', + optional: true, + nullable: true, + }, + durationMs: { + type: 'number', + description: 'Duration of the run in milliseconds', + optional: true, + nullable: true, + }, +} + +/** + * Output schema for a normalized deployment, shared by the deployment tools. + */ +export const TRIGGER_DEV_DEPLOYMENT_PROPERTIES: Record = { + id: { type: 'string', description: 'Unique ID of the deployment' }, + status: { + type: 'string', + description: + 'Deployment status (PENDING, INSTALLING, BUILDING, DEPLOYING, DEPLOYED, FAILED, CANCELED, or TIMED_OUT)', + }, + version: { + type: 'string', + description: 'Deployment version (e.g., "20250228.1")', + optional: true, + nullable: true, + }, + shortCode: { + type: 'string', + description: 'Short code of the deployment', + optional: true, + nullable: true, + }, + createdAt: { + type: 'string', + description: 'ISO timestamp when the deployment was created', + optional: true, + nullable: true, + }, + deployedAt: { + type: 'string', + description: 'ISO timestamp when the deployment was promoted to DEPLOYED', + optional: true, + nullable: true, + }, + runtime: { + type: 'string', + description: 'Runtime used by the deployment (e.g., "node")', + optional: true, + nullable: true, + }, + runtimeVersion: { + type: 'string', + description: 'Runtime version of the deployment', + optional: true, + nullable: true, + }, + git: { + type: 'json', + description: 'Git metadata associated with the deployment', + optional: true, + nullable: true, + }, + error: { + type: 'json', + description: 'Error details when the deployment failed', + optional: true, + nullable: true, + }, + tasks: { + type: 'array', + description: 'Tasks registered by the deployed worker', + items: { + type: 'object', + description: 'Deployed task', + properties: { + id: { type: 'string', description: 'Task ID', nullable: true }, + slug: { type: 'string', description: 'Task identifier', nullable: true }, + filePath: { + type: 'string', + description: 'File path of the task in the project', + nullable: true, + }, + }, + }, + }, +} + +/** + * Output schema for a normalized waitpoint token, shared by the waitpoint tools. + */ +export const TRIGGER_DEV_WAITPOINT_TOKEN_PROPERTIES: Record = { + id: { type: 'string', description: 'Unique ID of the waitpoint token (starts with waitpoint_)' }, + url: { + type: 'string', + description: + 'HTTP callback URL; a POST request to this URL completes the waitpoint without an API key', + }, + status: { + type: 'string', + description: 'Status of the waitpoint token (WAITING, COMPLETED, or TIMED_OUT)', + }, + idempotencyKey: { + type: 'string', + description: 'Idempotency key used when creating the token', + optional: true, + nullable: true, + }, + idempotencyKeyExpiresAt: { + type: 'string', + description: 'ISO timestamp when the idempotency key expires', + optional: true, + nullable: true, + }, + timeoutAt: { + type: 'string', + description: 'ISO timestamp when the token times out', + optional: true, + nullable: true, + }, + completedAt: { + type: 'string', + description: 'ISO timestamp when the token was completed', + optional: true, + nullable: true, + }, + output: { + type: 'json', + description: 'Data passed when completing the token, parsed when the output type is JSON', + optional: true, + nullable: true, + }, + outputType: { + type: 'string', + description: 'Content type of the serialized output (e.g., application/json)', + optional: true, + nullable: true, + }, + outputIsError: { + type: 'boolean', + description: 'Whether the output represents an error (e.g., a timeout)', + }, + tags: { + type: 'array', + description: 'Tags attached to the waitpoint', + items: { type: 'string', description: 'Waitpoint tag' }, + }, + createdAt: { + type: 'string', + description: 'ISO timestamp when the token was created', + optional: true, + nullable: true, + }, +} From f49784d79cc5b294a76cf668f2f551e6b90e901d Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 11 Jun 2026 12:18:09 -0700 Subject: [PATCH 3/6] fix(executor): strip dots from normalized block names so dotted names resolve References split on '.', so a block named "Hunter.io 1" could never be resolved (the first path segment cut the name at the dot). normalizeName now strips dots on both the tag-generation and lookup sides, which cannot break any previously working reference. Aligns the inline normalizers in connection drag-drop, deploy modal, output select, and tag dropdown, and renames Cal Com to Cal.com now that dotted display names work. --- apps/docs/content/docs/en/integrations/calcom.mdx | 2 +- .../chat/components/output-select/output-select.tsx | 3 ++- .../deploy/components/deploy-modal/deploy-modal.tsx | 6 ++---- .../components/field-item/field-item.tsx | 3 ++- .../connection-blocks/connection-blocks.tsx | 3 ++- .../components/tag-dropdown/tag-dropdown.tsx | 2 +- apps/sim/blocks/blocks/calcom.ts | 2 +- apps/sim/executor/constants.ts | 13 ++++++++++--- apps/sim/executor/variables/resolvers/block.test.ts | 11 +++++++++++ apps/sim/stores/workflows/utils.test.ts | 9 +++++++-- 10 files changed, 39 insertions(+), 15 deletions(-) diff --git a/apps/docs/content/docs/en/integrations/calcom.mdx b/apps/docs/content/docs/en/integrations/calcom.mdx index 0e844252c3..1c62f4bd0e 100644 --- a/apps/docs/content/docs/en/integrations/calcom.mdx +++ b/apps/docs/content/docs/en/integrations/calcom.mdx @@ -1,5 +1,5 @@ --- -title: Cal Com +title: Cal.com description: Manage Cal.com bookings, event types, schedules, and availability --- diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx index fb8d6b8e60..41c5962628 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx @@ -11,6 +11,7 @@ import { flattenWorkflowOutputs, } from '@/lib/workflows/blocks/flatten-outputs' import { getBlock } from '@/blocks' +import { normalizeName } from '@/executor/constants' import { useWorkflowDiffStore } from '@/stores/workflow-diff/store' import { useSubBlockStore } from '@/stores/workflows/subblock/store' import { useWorkflowStore } from '@/stores/workflows/workflow/store' @@ -147,7 +148,7 @@ export function OutputSelect({ return flat.map((f) => { const displayBlockName = f.blockName && typeof f.blockName === 'string' - ? f.blockName.replace(/\s+/g, '').toLowerCase() + ? normalizeName(f.blockName) : `block-${f.blockId}` return { id: `${f.blockId}_${f.path}`, diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx index 5520a259d8..baa2dbff78 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx @@ -32,7 +32,7 @@ import { import { syncLocalDraftFromServer } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/sync-local-draft' import type { DeployReadiness } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-deploy-readiness' import { runPreDeployChecks } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-predeploy-checks' -import { startsWithUuid } from '@/executor/constants' +import { normalizeName, startsWithUuid } from '@/executor/constants' import { useA2AAgentByWorkflow } from '@/hooks/queries/a2a/agents' import { useApiKeys } from '@/hooks/queries/api-keys' import { @@ -273,9 +273,7 @@ export function DeployModal({ const parts = outputId.split('.') if (parts.length >= 2) { const blockName = parts[0] - return blocks.some( - (b) => b.name?.toLowerCase().replace(/\s+/g, '') === blockName.toLowerCase() - ) + return blocks.some((b) => b.name && normalizeName(b.name) === blockName.toLowerCase()) } return true }) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/connection-blocks/components/field-item/field-item.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/connection-blocks/components/field-item/field-item.tsx index 413df1010c..42c4c734ae 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/connection-blocks/components/field-item/field-item.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/connection-blocks/components/field-item/field-item.tsx @@ -7,6 +7,7 @@ import { ChevronDown } from 'lucide-react' import { Badge } from '@/components/emcn' import { handleKeyboardActivation } from '@/lib/core/utils/keyboard' import type { ConnectedBlock } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/hooks/use-block-connections' +import { normalizeName } from '@/executor/constants' const logger = createLogger('FieldItem') @@ -44,7 +45,7 @@ export function FieldItem({ }: FieldItemProps) { const handleDragStart = useCallback( (e: React.DragEvent) => { - const normalizedBlockName = connection.name.replace(/\s+/g, '').toLowerCase() + const normalizedBlockName = normalizeName(connection.name) const fullTag = `${normalizedBlockName}.${path}` e.dataTransfer.setData( diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/connection-blocks/connection-blocks.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/connection-blocks/connection-blocks.tsx index 9eda8e6930..fd09b25097 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/connection-blocks/connection-blocks.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/connection-blocks/connection-blocks.tsx @@ -14,6 +14,7 @@ import { import type { ConnectedBlock } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/hooks/use-block-connections' import { useBlockOutputFields } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-block-output-fields' import { getBlock } from '@/blocks/registry' +import { normalizeName } from '@/executor/constants' import { useWorkflowRegistry } from '@/stores/workflows/registry/store' import { EMPTY_SUBBLOCK_VALUES, useSubBlockStore } from '@/stores/workflows/subblock/store' import { useWorkflowStore } from '@/stores/workflows/workflow/store' @@ -279,7 +280,7 @@ export function ConnectionBlocks({ connections, currentBlockId }: ConnectionBloc const handleConnectionDragStart = useCallback( (e: React.DragEvent, connection: ConnectedBlock) => { - const normalizedBlockName = connection.name.replace(/\s+/g, '').toLowerCase() + const normalizedBlockName = normalizeName(connection.name) e.dataTransfer.setData( 'application/json', diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx index 142d680585..645078584a 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx @@ -1518,7 +1518,7 @@ export const TagDropdown: React.FC = ({ if (tag.startsWith(TAG_PREFIXES.VARIABLE)) { const variableName = tag.substring(TAG_PREFIXES.VARIABLE.length) const variableObj = workflowVariables.find( - (v: Variable) => v.name.replace(/\s+/g, '') === variableName + (v: Variable) => normalizeName(v.name) === variableName ) if (variableObj) { diff --git a/apps/sim/blocks/blocks/calcom.ts b/apps/sim/blocks/blocks/calcom.ts index 305ebf099d..6cbb1427fc 100644 --- a/apps/sim/blocks/blocks/calcom.ts +++ b/apps/sim/blocks/blocks/calcom.ts @@ -6,7 +6,7 @@ import { getTrigger } from '@/triggers' export const CalComBlock: BlockConfig = { type: 'calcom', - name: 'Cal Com', + name: 'Cal.com', description: 'Manage Cal.com bookings, event types, schedules, and availability', authMode: AuthMode.OAuth, triggerAllowed: true, diff --git a/apps/sim/executor/constants.ts b/apps/sim/executor/constants.ts index 592d8cecdb..b6fd8a651f 100644 --- a/apps/sim/executor/constants.ts +++ b/apps/sim/executor/constants.ts @@ -485,9 +485,16 @@ export function escapeRegExp(value: string): string { } /** - * Normalizes a name for comparison by converting to lowercase and removing spaces. - * Used for both block names and variable names to ensure consistent matching. + * Normalizes a name for comparison by converting to lowercase and removing + * spaces and dots. Used for both block names and variable names to ensure + * consistent matching. + * + * Dots are stripped because `.` is the reference path delimiter — a name like + * "Trigger.dev 1" must normalize to "triggerdev1" so the reference + * `` parses unambiguously. Dotted names could never be + * referenced before (the first path segment cut the name at the dot), so + * stripping dots cannot break any previously working reference. */ export function normalizeName(name: string): string { - return name.toLowerCase().replace(/\s+/g, '') + return name.toLowerCase().replace(/\s+/g, '').replace(/\./g, '') } diff --git a/apps/sim/executor/variables/resolvers/block.test.ts b/apps/sim/executor/variables/resolvers/block.test.ts index a225bb9edf..0cfd28944b 100644 --- a/apps/sim/executor/variables/resolvers/block.test.ts +++ b/apps/sim/executor/variables/resolvers/block.test.ts @@ -243,6 +243,17 @@ describe('BlockResolver', () => { expect(resolver.resolve('', ctx)).toEqual({ message: 'hello' }) }) + it.concurrent('should resolve blocks whose names contain dots via dot-stripped names', () => { + const workflow = createTestWorkflow([{ id: 'block-dot', name: 'Hunter.io 1' }]) + const resolver = new BlockResolver(workflow) + const ctx = createTestContext('current', { + 'block-dot': { email: 'jane@acme.com', score: 92 }, + }) + + expect(resolver.resolve('', ctx)).toBe('jane@acme.com') + expect(resolver.resolve('', ctx)).toBe(92) + }) + it.concurrent('should resolve nested property path', () => { const workflow = createTestWorkflow([{ id: 'source' }]) const resolver = new BlockResolver(workflow) diff --git a/apps/sim/stores/workflows/utils.test.ts b/apps/sim/stores/workflows/utils.test.ts index ea26c47766..00127c138e 100644 --- a/apps/sim/stores/workflows/utils.test.ts +++ b/apps/sim/stores/workflows/utils.test.ts @@ -35,10 +35,15 @@ describe('normalizeName', () => { expect(normalizeName('already_normalized')).toBe('already_normalized') }) - it.concurrent('should preserve non-space special characters', () => { + it.concurrent('should preserve non-space special characters except dots', () => { expect(normalizeName('my-variable')).toBe('my-variable') expect(normalizeName('my_variable')).toBe('my_variable') - expect(normalizeName('my.variable')).toBe('my.variable') + }) + + it.concurrent('should strip dots since they conflict with the reference path delimiter', () => { + expect(normalizeName('my.variable')).toBe('myvariable') + expect(normalizeName('Trigger.dev 1')).toBe('triggerdev1') + expect(normalizeName('Hunter.io 2')).toBe('hunterio2') }) it.concurrent('should handle tabs and newlines as whitespace', () => { From 95dd3eea6db1068417958fc3bc64ff5e0f131e3e Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 11 Jun 2026 12:21:03 -0700 Subject: [PATCH 4/6] improvement(integrations): address Trigger.dev review feedback Reads the delete schedule response instead of hardcoding success, and adds explicit plaintext-secret warnings to the env var read operations and docs. --- .../content/docs/en/integrations/trigger_dev.mdx | 10 ++++++---- apps/sim/lib/integrations/integrations.json | 4 ++-- apps/sim/tools/trigger_dev/delete_schedule.ts | 16 +++++++++++++--- apps/sim/tools/trigger_dev/get_env_var.ts | 9 +++++++-- apps/sim/tools/trigger_dev/list_env_vars.ts | 8 ++++++-- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/apps/docs/content/docs/en/integrations/trigger_dev.mdx b/apps/docs/content/docs/en/integrations/trigger_dev.mdx index 165b931c05..d15eedf596 100644 --- a/apps/docs/content/docs/en/integrations/trigger_dev.mdx +++ b/apps/docs/content/docs/en/integrations/trigger_dev.mdx @@ -23,6 +23,8 @@ With Trigger.dev, you can: - **Control queues**: Inspect queue depth and concurrency, and pause or resume queues during incidents In Sim, the Trigger.dev integration lets your agents drive this entire lifecycle. An agent can trigger a deployed task with a payload, poll the run until it completes and use its output downstream, monitor for failed runs and replay the transient ones, manage per-customer cron schedules, and pause a queue when something goes wrong. Connect it with a project-scoped secret API key (starts with `tr_`) — the key determines which environment the runs, schedules, and queues belong to. This makes Sim a natural control plane for the background jobs that power your product. + +Note: the environment variable operations (List Env Vars, Get Env Var) return variable values in plaintext, and those values appear in workflow outputs and run history. Scope workflows that read environment variables carefully. {/* MANUAL-CONTENT-END */} @@ -959,7 +961,7 @@ Deactivate an imperative Trigger.dev schedule so it stops triggering its task. ### `trigger_dev_list_env_vars` -List the environment variables of a Trigger.dev project environment, including their values. +List the environment variables of a Trigger.dev project environment. Values are returned in plaintext and will appear in workflow outputs and run history — scope this operation carefully. #### Input @@ -975,7 +977,7 @@ List the environment variables of a Trigger.dev project environment, including t | --------- | ---- | ----------- | | `variables` | array | Environment variables in the project environment | | ↳ `name` | string | Name of the environment variable | -| ↳ `value` | string | Value of the environment variable | +| ↳ `value` | string | Plaintext value of the environment variable; appears in workflow outputs and run history | ### `trigger_dev_create_env_var` @@ -1000,7 +1002,7 @@ Create an environment variable in a Trigger.dev project environment. ### `trigger_dev_get_env_var` -Retrieve an environment variable from a Trigger.dev project environment. +Retrieve an environment variable from a Trigger.dev project environment. The value is returned in plaintext and will appear in workflow outputs and run history. #### Input @@ -1016,7 +1018,7 @@ Retrieve an environment variable from a Trigger.dev project environment. | Parameter | Type | Description | | --------- | ---- | ----------- | | `name` | string | Name of the environment variable | -| `value` | string | Value of the environment variable | +| `value` | string | Plaintext value of the environment variable; appears in workflow outputs and run history | ### `trigger_dev_update_env_var` diff --git a/apps/sim/lib/integrations/integrations.json b/apps/sim/lib/integrations/integrations.json index 8059442bf0..41f091108f 100644 --- a/apps/sim/lib/integrations/integrations.json +++ b/apps/sim/lib/integrations/integrations.json @@ -14904,7 +14904,7 @@ }, { "name": "List Env Vars", - "description": "List the environment variables of a Trigger.dev project environment, including their values." + "description": "List the environment variables of a Trigger.dev project environment. Values are returned in plaintext and will appear in workflow outputs and run history — scope this operation carefully." }, { "name": "Create Env Var", @@ -14912,7 +14912,7 @@ }, { "name": "Get Env Var", - "description": "Retrieve an environment variable from a Trigger.dev project environment." + "description": "Retrieve an environment variable from a Trigger.dev project environment. The value is returned in plaintext and will appear in workflow outputs and run history." }, { "name": "Update Env Var", diff --git a/apps/sim/tools/trigger_dev/delete_schedule.ts b/apps/sim/tools/trigger_dev/delete_schedule.ts index 785bb5208a..99a393b8d8 100644 --- a/apps/sim/tools/trigger_dev/delete_schedule.ts +++ b/apps/sim/tools/trigger_dev/delete_schedule.ts @@ -36,11 +36,21 @@ export const triggerDevDeleteScheduleTool: ToolConfig< headers: (params) => buildTriggerDevHeaders(params.apiKey), }, - transformResponse: async (_response, params) => { + transformResponse: async (response, params) => { + const text = await response.text() + let deleted = response.ok + if (text) { + try { + const data = JSON.parse(text) + if (typeof data.success === 'boolean') deleted = data.success + } catch { + deleted = response.ok + } + } return { - success: true, + success: deleted, output: { - deleted: true, + deleted, scheduleId: params?.scheduleId ?? '', }, } diff --git a/apps/sim/tools/trigger_dev/get_env_var.ts b/apps/sim/tools/trigger_dev/get_env_var.ts index e7a2f46bec..3a4c21c4b0 100644 --- a/apps/sim/tools/trigger_dev/get_env_var.ts +++ b/apps/sim/tools/trigger_dev/get_env_var.ts @@ -11,7 +11,8 @@ export const triggerDevGetEnvVarTool: ToolConfig< > = { id: 'trigger_dev_get_env_var', name: 'Trigger.dev Get Env Var', - description: 'Retrieve an environment variable from a Trigger.dev project environment.', + description: + 'Retrieve an environment variable from a Trigger.dev project environment. The value is returned in plaintext and will appear in workflow outputs and run history.', version: '1.0.0', params: { @@ -60,6 +61,10 @@ export const triggerDevGetEnvVarTool: ToolConfig< outputs: { name: { type: 'string', description: 'Name of the environment variable' }, - value: { type: 'string', description: 'Value of the environment variable' }, + value: { + type: 'string', + description: + 'Plaintext value of the environment variable; appears in workflow outputs and run history', + }, }, } diff --git a/apps/sim/tools/trigger_dev/list_env_vars.ts b/apps/sim/tools/trigger_dev/list_env_vars.ts index 62da45901b..1211bd888c 100644 --- a/apps/sim/tools/trigger_dev/list_env_vars.ts +++ b/apps/sim/tools/trigger_dev/list_env_vars.ts @@ -12,7 +12,7 @@ export const triggerDevListEnvVarsTool: ToolConfig< id: 'trigger_dev_list_env_vars', name: 'Trigger.dev List Env Vars', description: - 'List the environment variables of a Trigger.dev project environment, including their values.', + 'List the environment variables of a Trigger.dev project environment. Values are returned in plaintext and will appear in workflow outputs and run history — scope this operation carefully.', version: '1.0.0', params: { @@ -65,7 +65,11 @@ export const triggerDevListEnvVarsTool: ToolConfig< description: 'Environment variable', properties: { name: { type: 'string', description: 'Name of the environment variable' }, - value: { type: 'string', description: 'Value of the environment variable' }, + value: { + type: 'string', + description: + 'Plaintext value of the environment variable; appears in workflow outputs and run history', + }, }, }, }, From f4058b6a04a0c36eae418376798964a0f40cab2e Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 11 Jun 2026 12:31:05 -0700 Subject: [PATCH 5/6] fix(integrations): scope Trigger.dev block params to the selected operation Advanced sub-block values with non-empty content are serialized regardless of their operation condition, so values left over from a previously selected operation could leak into another operation's API call (e.g., a trigger-task idempotency key filtering the waitpoint list). The params function now routes every shared or remapped param by the selected operation and clears it otherwise. Also derives delete env var success from the response like delete schedule, via a shared helper. --- apps/sim/blocks/blocks/trigger_dev.ts | 58 ++++++++++++++----- apps/sim/tools/trigger_dev/delete_env_var.ts | 12 ++-- apps/sim/tools/trigger_dev/delete_schedule.ts | 17 ++---- apps/sim/tools/trigger_dev/utils.ts | 18 ++++++ 4 files changed, 77 insertions(+), 28 deletions(-) diff --git a/apps/sim/blocks/blocks/trigger_dev.ts b/apps/sim/blocks/blocks/trigger_dev.ts index 9e54d425dd..5da81882f8 100644 --- a/apps/sim/blocks/blocks/trigger_dev.ts +++ b/apps/sim/blocks/blocks/trigger_dev.ts @@ -839,20 +839,52 @@ Return ONLY the valid JSON object - no explanations, no markdown.`, config: { tool: (params) => params.operation, params: (params) => { + const operation = params.operation as string const result: Record = {} - if (params.filterTaskIdentifier) result.taskIdentifier = params.filterTaskIdentifier - if (params.rescheduleDelay) result.delay = params.rescheduleDelay - if (params.runTags) result.tags = params.runTags - if (params.deploymentVersion) result.version = params.deploymentVersion - if (params.deploymentStatus) result.status = params.deploymentStatus - if (params.waitpointData) result.data = params.waitpointData - if (params.waitpointStatus) result.status = params.waitpointStatus - if (params.filterIdempotencyKey) result.idempotencyKey = params.filterIdempotencyKey - if (params.waitpointTags) result.tags = params.waitpointTags - if (params.concurrencyLimit) result.concurrencyLimit = Number(params.concurrencyLimit) - if (params.pageSize) result.pageSize = Number(params.pageSize) - if (params.page) result.page = Number(params.page) - if (params.perPage) result.perPage = Number(params.perPage) + + const scoped = (value: unknown, operations: string[]) => + operations.includes(operation) && value !== undefined && value !== null && value !== '' + ? value + : undefined + + result.taskIdentifier = + scoped(params.taskIdentifier, TASK_IDENTIFIER_OPERATIONS) ?? + scoped(params.filterTaskIdentifier, ['trigger_dev_list_runs']) + result.delay = + scoped(params.delay, ['trigger_dev_trigger_task']) ?? + scoped(params.rescheduleDelay, ['trigger_dev_reschedule_run']) + result.tags = + scoped(params.tags, TAGS_OPERATIONS) ?? + scoped(params.runTags, ['trigger_dev_add_run_tags']) ?? + scoped(params.waitpointTags, ['trigger_dev_list_waitpoint_tokens']) + result.idempotencyKey = + scoped(params.idempotencyKey, IDEMPOTENCY_KEY_OPERATIONS) ?? + scoped(params.filterIdempotencyKey, ['trigger_dev_list_waitpoint_tokens']) + result.status = + scoped(params.status, ['trigger_dev_list_runs']) ?? + scoped(params.deploymentStatus, ['trigger_dev_list_deployments']) ?? + scoped(params.waitpointStatus, ['trigger_dev_list_waitpoint_tokens']) + result.version = + scoped(params.version, ['trigger_dev_list_runs']) ?? + scoped(params.deploymentVersion, ['trigger_dev_promote_deployment']) + result.data = scoped(params.waitpointData, ['trigger_dev_complete_waitpoint_token']) + result.period = scoped(params.period, CREATED_AT_FILTER_OPERATIONS) + result.from = scoped(params.from, CREATED_AT_FILTER_OPERATIONS) + result.to = scoped(params.to, CREATED_AT_FILTER_OPERATIONS) + + const scopedNumber = (value: unknown, operations: string[]) => { + const raw = scoped(value, operations) + return raw === undefined ? undefined : Number(raw) + } + result.concurrencyLimit = scopedNumber(params.concurrencyLimit, [ + 'trigger_dev_override_queue_concurrency', + ]) + result.pageSize = scopedNumber(params.pageSize, CURSOR_PAGE_OPERATIONS) + result.pageAfter = scoped(params.pageAfter, CURSOR_PAGE_OPERATIONS) + result.pageBefore = scoped(params.pageBefore, PAGE_BEFORE_OPERATIONS) + result.page = scopedNumber(params.page, NUMBERED_PAGE_OPERATIONS) + result.perPage = scopedNumber(params.perPage, NUMBERED_PAGE_OPERATIONS) + return result }, }, diff --git a/apps/sim/tools/trigger_dev/delete_env_var.ts b/apps/sim/tools/trigger_dev/delete_env_var.ts index 216e0557da..08ac8ead07 100644 --- a/apps/sim/tools/trigger_dev/delete_env_var.ts +++ b/apps/sim/tools/trigger_dev/delete_env_var.ts @@ -2,7 +2,11 @@ import type { TriggerDevEnvVarActionResponse, TriggerDevEnvVarNameParams, } from '@/tools/trigger_dev/types' -import { buildTriggerDevEnvVarsUrl, buildTriggerDevHeaders } from '@/tools/trigger_dev/utils' +import { + buildTriggerDevEnvVarsUrl, + buildTriggerDevHeaders, + resolveTriggerDevSuccess, +} from '@/tools/trigger_dev/utils' import type { ToolConfig } from '@/tools/types' export const triggerDevDeleteEnvVarTool: ToolConfig< @@ -48,11 +52,11 @@ export const triggerDevDeleteEnvVarTool: ToolConfig< }, transformResponse: async (response, params) => { - const data = await response.json() + const deleted = await resolveTriggerDevSuccess(response) return { - success: true, + success: deleted, output: { - success: data.success ?? true, + success: deleted, name: params?.name ?? '', }, } diff --git a/apps/sim/tools/trigger_dev/delete_schedule.ts b/apps/sim/tools/trigger_dev/delete_schedule.ts index 99a393b8d8..3344ec904e 100644 --- a/apps/sim/tools/trigger_dev/delete_schedule.ts +++ b/apps/sim/tools/trigger_dev/delete_schedule.ts @@ -2,7 +2,11 @@ import type { TriggerDevDeleteScheduleResponse, TriggerDevScheduleIdParams, } from '@/tools/trigger_dev/types' -import { buildTriggerDevHeaders, TRIGGER_DEV_API_BASE } from '@/tools/trigger_dev/utils' +import { + buildTriggerDevHeaders, + resolveTriggerDevSuccess, + TRIGGER_DEV_API_BASE, +} from '@/tools/trigger_dev/utils' import type { ToolConfig } from '@/tools/types' export const triggerDevDeleteScheduleTool: ToolConfig< @@ -37,16 +41,7 @@ export const triggerDevDeleteScheduleTool: ToolConfig< }, transformResponse: async (response, params) => { - const text = await response.text() - let deleted = response.ok - if (text) { - try { - const data = JSON.parse(text) - if (typeof data.success === 'boolean') deleted = data.success - } catch { - deleted = response.ok - } - } + const deleted = await resolveTriggerDevSuccess(response) return { success: deleted, output: { diff --git a/apps/sim/tools/trigger_dev/utils.ts b/apps/sim/tools/trigger_dev/utils.ts index 328ab42efd..ddb4582852 100644 --- a/apps/sim/tools/trigger_dev/utils.ts +++ b/apps/sim/tools/trigger_dev/utils.ts @@ -54,6 +54,24 @@ export function parseJsonInput(value: unknown, paramName: string): unknown { } } +/** + * Derives operation success from a response that may have an empty body. + * Uses the body's boolean `success` field when present, otherwise falls back + * to the HTTP status. + */ +export async function resolveTriggerDevSuccess(response: Response): Promise { + const text = await response.text() + if (text) { + try { + const data = JSON.parse(text) + if (typeof data.success === 'boolean') return data.success + } catch { + return response.ok + } + } + return response.ok +} + /** * Builds the URL for the environment variable endpoints of a project environment. */ From a82a7173aff53ceefff9aae929480613061ad34f Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 11 Jun 2026 12:43:54 -0700 Subject: [PATCH 6/6] improvement(executor): dot-free names keep reference ownership on legacy collisions Name uniqueness is enforced at the normalized level on create and rename, so new collisions cannot be created. For legacy workflows that already contain names differing only by dots, the resolver now lets the dot-free name own the reference key regardless of block order, so previously working references never change targets. --- .../executor/variables/resolvers/block.test.ts | 17 +++++++++++++++++ apps/sim/executor/variables/resolvers/block.ts | 13 ++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/apps/sim/executor/variables/resolvers/block.test.ts b/apps/sim/executor/variables/resolvers/block.test.ts index 0cfd28944b..227648dc99 100644 --- a/apps/sim/executor/variables/resolvers/block.test.ts +++ b/apps/sim/executor/variables/resolvers/block.test.ts @@ -254,6 +254,23 @@ describe('BlockResolver', () => { expect(resolver.resolve('', ctx)).toBe(92) }) + it.concurrent('should keep dot-free names as the reference target on legacy collisions', () => { + const blocks = [ + { id: 'block-dotted', name: 'Hunter.io 1' }, + { id: 'block-plain', name: 'Hunterio 1' }, + ] + const ctx = createTestContext('current', { + 'block-dotted': { email: 'dotted@acme.com' }, + 'block-plain': { email: 'plain@acme.com' }, + }) + + const resolver = new BlockResolver(createTestWorkflow(blocks)) + expect(resolver.resolve('', ctx)).toBe('plain@acme.com') + + const reversedResolver = new BlockResolver(createTestWorkflow([...blocks].reverse())) + expect(reversedResolver.resolve('', ctx)).toBe('plain@acme.com') + }) + it.concurrent('should resolve nested property path', () => { const workflow = createTestWorkflow([{ id: 'source' }]) const resolver = new BlockResolver(workflow) diff --git a/apps/sim/executor/variables/resolvers/block.ts b/apps/sim/executor/variables/resolvers/block.ts index 32bce35e0b..6d4ca1b577 100644 --- a/apps/sim/executor/variables/resolvers/block.ts +++ b/apps/sim/executor/variables/resolvers/block.ts @@ -43,7 +43,18 @@ export class BlockResolver implements Resolver { for (const block of workflow.blocks) { this.blockById.set(block.id, block) if (block.metadata?.name) { - this.nameToBlockId.set(normalizeName(block.metadata.name), block.id) + // Name uniqueness is enforced at the normalized level on create/rename, + // but legacy workflows may contain names that collide only now that + // normalizeName strips dots. Dot-free names keep ownership of the key so + // previously working references never change targets. + const normalizedName = normalizeName(block.metadata.name) + const incumbentId = this.nameToBlockId.get(normalizedName) + const incumbentName = incumbentId + ? this.blockById.get(incumbentId)?.metadata?.name + : undefined + if (!incumbentId || incumbentName?.includes('.')) { + this.nameToBlockId.set(normalizedName, block.id) + } } } for (const loop of Object.values(workflow.loops ?? {})) {