chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -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,
|
||||
}
|
||||
@@ -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' },
|
||||
},
|
||||
}
|
||||
@@ -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_)' },
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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' },
|
||||
},
|
||||
}
|
||||
@@ -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' },
|
||||
},
|
||||
}
|
||||
@@ -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' },
|
||||
},
|
||||
}
|
||||
@@ -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: true,
|
||||
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<string, unknown> = {
|
||||
task: params.task,
|
||||
cron: params.cron,
|
||||
deduplicationKey: params.deduplicationKey,
|
||||
}
|
||||
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,
|
||||
}
|
||||
@@ -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<string, unknown> = {}
|
||||
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',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import type {
|
||||
TriggerDevEnvVarActionResponse,
|
||||
TriggerDevEnvVarNameParams,
|
||||
} from '@/tools/trigger_dev/types'
|
||||
import {
|
||||
buildTriggerDevEnvVarsUrl,
|
||||
buildTriggerDevHeaders,
|
||||
resolveTriggerDevSuccess,
|
||||
} 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 deleted = await resolveTriggerDevSuccess(response)
|
||||
return {
|
||||
success: deleted,
|
||||
output: {
|
||||
success: deleted,
|
||||
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' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import type {
|
||||
TriggerDevDeleteScheduleResponse,
|
||||
TriggerDevScheduleIdParams,
|
||||
} from '@/tools/trigger_dev/types'
|
||||
import {
|
||||
buildTriggerDevHeaders,
|
||||
resolveTriggerDevSuccess,
|
||||
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) => {
|
||||
const deleted = await resolveTriggerDevSuccess(response)
|
||||
return {
|
||||
success: deleted,
|
||||
output: {
|
||||
deleted,
|
||||
scheduleId: params?.scheduleId ?? '',
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
deleted: { type: 'boolean', description: 'Whether the schedule was deleted' },
|
||||
scheduleId: { type: 'string', description: 'ID of the schedule that was deleted' },
|
||||
},
|
||||
}
|
||||
@@ -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<string, unknown> = { 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',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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<string, unknown>
|
||||
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 },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
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. The value is returned in plaintext and will appear in workflow outputs and run history.',
|
||||
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:
|
||||
'Plaintext value of the environment variable; appears in workflow outputs and run history',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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<TriggerDevQueueParams, TriggerDevQueueResponse> = {
|
||||
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,
|
||||
}
|
||||
@@ -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<TriggerDevRunIdParams, TriggerDevRunResponse> = {
|
||||
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,
|
||||
}
|
||||
@@ -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<string, unknown> }[]
|
||||
}) => ({
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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<string, unknown> = { 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' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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'
|
||||
export { triggerDevUpdateRunMetadataTool } from '@/tools/trigger_dev/update_run_metadata'
|
||||
export { triggerDevUpdateScheduleTool } from '@/tools/trigger_dev/update_schedule'
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
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. Values are returned in plaintext and will appear in workflow outputs and run history — scope this operation carefully.',
|
||||
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:
|
||||
'Plaintext value of the environment variable; appears in workflow outputs and run history',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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 },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
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) {
|
||||
const statuses = splitCommaSeparated(params.status).map((status) => status.toUpperCase())
|
||||
if (statuses.length > 0) query.set('filter[status]', statuses.join(','))
|
||||
}
|
||||
if (params.taskIdentifier) {
|
||||
const tasks = splitCommaSeparated(params.taskIdentifier)
|
||||
if (tasks.length > 0) query.set('filter[taskIdentifier]', tasks.join(','))
|
||||
}
|
||||
if (params.version) {
|
||||
const versions = splitCommaSeparated(params.version)
|
||||
if (versions.length > 0) query.set('filter[version]', versions.join(','))
|
||||
}
|
||||
if (params.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') {
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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 },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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' },
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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<TriggerDevQueueParams, TriggerDevQueueResponse> =
|
||||
{
|
||||
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,
|
||||
}
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -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' },
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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<TriggerDevQueueParams, TriggerDevQueueResponse> =
|
||||
{
|
||||
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,
|
||||
}
|
||||
@@ -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<string, unknown> = {}
|
||||
|
||||
const payload = parseJsonInput(params.payload, 'payload')
|
||||
if (payload !== undefined) body.payload = payload
|
||||
|
||||
const options: Record<string, unknown> = {}
|
||||
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_)' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,788 @@
|
||||
import type { ToolResponse } from '@/tools/types'
|
||||
|
||||
export 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<string, unknown>
|
||||
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<string, unknown> | 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
|
||||
}
|
||||
|
||||
/** 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<string, unknown>
|
||||
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<string, unknown> | 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<string, unknown> | 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<string, unknown> | null
|
||||
error?: Record<string, unknown> | null
|
||||
contentHash?: string
|
||||
imageReference?: string | null
|
||||
errorData?: Record<string, unknown> | 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<string, unknown> | null
|
||||
error: Record<string, unknown> | 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<string, unknown>
|
||||
idempotencyKey?: string
|
||||
queue?: string
|
||||
concurrencyKey?: string
|
||||
delay?: string
|
||||
ttl?: string
|
||||
machine?: string
|
||||
tags?: string
|
||||
}
|
||||
|
||||
export interface TriggerDevBatchTriggerTaskParams extends TriggerDevBaseParams {
|
||||
taskIdentifier: string
|
||||
items: string | Record<string, unknown>[]
|
||||
}
|
||||
|
||||
export interface TriggerDevRunIdParams extends TriggerDevBaseParams {
|
||||
runId: string
|
||||
}
|
||||
|
||||
export interface TriggerDevRescheduleRunParams extends TriggerDevBaseParams {
|
||||
runId: string
|
||||
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<string, unknown>
|
||||
}
|
||||
|
||||
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
|
||||
deduplicationKey: string
|
||||
timezone?: string
|
||||
externalId?: 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 TriggerDevImportEnvVarsParams extends TriggerDevEnvVarsScopeParams {
|
||||
variables: string | Record<string, unknown>[]
|
||||
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<string, unknown>
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
export interface TriggerDevBatchTriggerTaskResponse extends ToolResponse {
|
||||
output: {
|
||||
batchId: string
|
||||
runIds: string[]
|
||||
}
|
||||
}
|
||||
|
||||
/** 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<string, unknown> | 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<string, unknown> | 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<string, unknown> | 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
|
||||
| TriggerDevGetBatchResponse
|
||||
| TriggerDevBatchResultsResponse
|
||||
| TriggerDevRunResponse
|
||||
| TriggerDevRunResultResponse
|
||||
| TriggerDevListRunsResponse
|
||||
| TriggerDevRunActionResponse
|
||||
| TriggerDevAddRunTagsResponse
|
||||
| TriggerDevRunEventsResponse
|
||||
| TriggerDevRunTraceResponse
|
||||
| TriggerDevUpdateRunMetadataResponse
|
||||
| TriggerDevScheduleResponse
|
||||
| TriggerDevListSchedulesResponse
|
||||
| TriggerDevDeleteScheduleResponse
|
||||
| TriggerDevListEnvVarsResponse
|
||||
| TriggerDevEnvVarResponse
|
||||
| TriggerDevEnvVarActionResponse
|
||||
| TriggerDevImportEnvVarsResponse
|
||||
| TriggerDevQueueResponse
|
||||
| TriggerDevListQueuesResponse
|
||||
| TriggerDevDeploymentResponse
|
||||
| TriggerDevListDeploymentsResponse
|
||||
| TriggerDevPromoteDeploymentResponse
|
||||
| TriggerDevExecuteQueryResponse
|
||||
| TriggerDevQuerySchemaResponse
|
||||
| TriggerDevCreateWaitpointTokenResponse
|
||||
| TriggerDevCompleteWaitpointTokenResponse
|
||||
| TriggerDevWaitpointTokenResponse
|
||||
| TriggerDevListWaitpointTokensResponse
|
||||
| TriggerDevListTimezonesResponse
|
||||
@@ -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' },
|
||||
},
|
||||
}
|
||||
@@ -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' },
|
||||
},
|
||||
}
|
||||
@@ -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<string, unknown> = {
|
||||
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,
|
||||
}
|
||||
@@ -0,0 +1,825 @@
|
||||
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'
|
||||
|
||||
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<string, string> {
|
||||
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`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<boolean> {
|
||||
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.
|
||||
*/
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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<string, OutputProperty> = {
|
||||
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<ToolConfig['outputs']> = {
|
||||
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<ToolConfig['outputs']> = {
|
||||
...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<ToolConfig['outputs']> = {
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Output schema for a normalized run result, shared by the run result and
|
||||
* batch results tools.
|
||||
*/
|
||||
export const TRIGGER_DEV_RUN_RESULT_PROPERTIES: Record<string, OutputProperty> = {
|
||||
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<string, OutputProperty> = {
|
||||
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<string, OutputProperty> = {
|
||||
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,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user