d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
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
133 lines
4.1 KiB
TypeScript
133 lines
4.1 KiB
TypeScript
import type { PagerDutySendEventParams, PagerDutySendEventResponse } from '@/tools/pagerduty/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const sendEventTool: ToolConfig<PagerDutySendEventParams, PagerDutySendEventResponse> = {
|
|
id: 'pagerduty_send_event',
|
|
name: 'PagerDuty Send Event',
|
|
description:
|
|
'Send a trigger, acknowledge, or resolve event to PagerDuty Events API v2 using a service integration key. Used to page from monitoring/alerting sources without a PagerDuty user account.',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
routingKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'The Events API v2 integration key (routing key) for the target service',
|
|
},
|
|
eventAction: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Event action: trigger, acknowledge, or resolve',
|
|
},
|
|
summary: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Brief summary of the event. Required when eventAction is trigger',
|
|
},
|
|
source: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'Unique location of the affected system (e.g. hostname). Required when eventAction is trigger',
|
|
},
|
|
severity: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'Perceived severity: critical, warning, error, or info. Required when eventAction is trigger',
|
|
},
|
|
dedupKey: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'De-duplication key identifying the alert. Required when eventAction is acknowledge or resolve; optional on trigger',
|
|
},
|
|
component: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Component of the source machine responsible for the event',
|
|
},
|
|
group: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Logical grouping of components of a service',
|
|
},
|
|
class: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'The class/type of the event',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: 'https://events.pagerduty.com/v2/enqueue',
|
|
method: 'POST',
|
|
headers: () => ({
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
body: (params) => {
|
|
const body: Record<string, unknown> = {
|
|
routing_key: params.routingKey,
|
|
event_action: params.eventAction,
|
|
}
|
|
|
|
if (params.eventAction === 'acknowledge' || params.eventAction === 'resolve') {
|
|
if (!params.dedupKey) {
|
|
throw new Error('dedupKey is required when eventAction is acknowledge or resolve')
|
|
}
|
|
}
|
|
|
|
if (params.dedupKey) body.dedup_key = params.dedupKey
|
|
|
|
if (params.eventAction === 'trigger') {
|
|
if (!params.summary || !params.source || !params.severity) {
|
|
throw new Error('summary, source, and severity are required when eventAction is trigger')
|
|
}
|
|
|
|
body.payload = {
|
|
summary: params.summary,
|
|
source: params.source,
|
|
severity: params.severity,
|
|
...(params.component && { component: params.component }),
|
|
...(params.group && { group: params.group }),
|
|
...(params.class && { class: params.class }),
|
|
}
|
|
}
|
|
|
|
return body
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
|
|
if (!response.ok) {
|
|
throw new Error(data.message || `PagerDuty Events API error: ${response.status}`)
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
status: data.status ?? null,
|
|
message: data.message ?? null,
|
|
dedupKey: data.dedup_key ?? null,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
status: { type: 'string', description: 'Result status ("success" if accepted)' },
|
|
message: { type: 'string', description: 'Description of the result', optional: true },
|
|
dedupKey: { type: 'string', description: 'De-duplication key for the alert', optional: true },
|
|
},
|
|
}
|