@agentjam/sdk 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/events.d.ts.map +1 -1
  2. package/dist/events.js +27 -0
  3. package/dist/events.js.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/managedWebhooks.d.ts +15 -0
  8. package/dist/managedWebhooks.d.ts.map +1 -0
  9. package/dist/managedWebhooks.js +115 -0
  10. package/dist/managedWebhooks.js.map +1 -0
  11. package/dist/platforms/atlassian.d.ts +18 -0
  12. package/dist/platforms/atlassian.d.ts.map +1 -0
  13. package/dist/platforms/atlassian.js +24 -0
  14. package/dist/platforms/atlassian.js.map +1 -0
  15. package/dist/platforms/datadog.d.ts +45 -1
  16. package/dist/platforms/datadog.d.ts.map +1 -1
  17. package/dist/platforms/datadog.js +207 -0
  18. package/dist/platforms/datadog.js.map +1 -1
  19. package/dist/platforms/discord.d.ts +64 -16
  20. package/dist/platforms/discord.d.ts.map +1 -1
  21. package/dist/platforms/discord.js +15 -48
  22. package/dist/platforms/discord.js.map +1 -1
  23. package/dist/platforms/discordEvents.d.ts +213 -0
  24. package/dist/platforms/discordEvents.d.ts.map +1 -0
  25. package/dist/platforms/discordEvents.js +270 -0
  26. package/dist/platforms/discordEvents.js.map +1 -0
  27. package/dist/platforms/discordGateway.d.ts +14 -14
  28. package/dist/platforms/discordGateway.d.ts.map +1 -1
  29. package/dist/platforms/discordGateway.js +29 -45
  30. package/dist/platforms/discordGateway.js.map +1 -1
  31. package/dist/platforms/discordInteractions.d.ts +35 -0
  32. package/dist/platforms/discordInteractions.d.ts.map +1 -0
  33. package/dist/platforms/discordInteractions.js +125 -0
  34. package/dist/platforms/discordInteractions.js.map +1 -0
  35. package/dist/platforms/github.d.ts +45 -13
  36. package/dist/platforms/github.d.ts.map +1 -1
  37. package/dist/platforms/github.js +20 -40
  38. package/dist/platforms/github.js.map +1 -1
  39. package/dist/platforms/githubApi.d.ts +2 -0
  40. package/dist/platforms/githubApi.d.ts.map +1 -0
  41. package/dist/platforms/githubApi.js +38 -0
  42. package/dist/platforms/githubApi.js.map +1 -0
  43. package/dist/platforms/githubEvents.d.ts +160 -0
  44. package/dist/platforms/githubEvents.d.ts.map +1 -0
  45. package/dist/platforms/githubEvents.js +446 -0
  46. package/dist/platforms/githubEvents.js.map +1 -0
  47. package/dist/platforms/grafana.d.ts +47 -1
  48. package/dist/platforms/grafana.d.ts.map +1 -1
  49. package/dist/platforms/grafana.js +187 -0
  50. package/dist/platforms/grafana.js.map +1 -1
  51. package/dist/platforms/pagerduty.d.ts +59 -0
  52. package/dist/platforms/pagerduty.d.ts.map +1 -0
  53. package/dist/platforms/pagerduty.js +175 -0
  54. package/dist/platforms/pagerduty.js.map +1 -0
  55. package/dist/platforms/sentry.d.ts +35 -17
  56. package/dist/platforms/sentry.d.ts.map +1 -1
  57. package/dist/platforms/sentry.js +48 -25
  58. package/dist/platforms/sentry.js.map +1 -1
  59. package/dist/platforms/sentryApi.d.ts +3 -0
  60. package/dist/platforms/sentryApi.d.ts.map +1 -0
  61. package/dist/platforms/sentryApi.js +29 -0
  62. package/dist/platforms/sentryApi.js.map +1 -0
  63. package/dist/platforms/sentryEvents.d.ts +64 -0
  64. package/dist/platforms/sentryEvents.d.ts.map +1 -0
  65. package/dist/platforms/sentryEvents.js +183 -0
  66. package/dist/platforms/sentryEvents.js.map +1 -0
  67. package/dist/platforms/slack.d.ts +69 -33
  68. package/dist/platforms/slack.d.ts.map +1 -1
  69. package/dist/platforms/slack.js +29 -36
  70. package/dist/platforms/slack.js.map +1 -1
  71. package/dist/platforms/slackEvents.d.ts +204 -0
  72. package/dist/platforms/slackEvents.d.ts.map +1 -0
  73. package/dist/platforms/slackEvents.js +241 -0
  74. package/dist/platforms/slackEvents.js.map +1 -0
  75. package/dist/platforms/slackInteractions.d.ts +79 -0
  76. package/dist/platforms/slackInteractions.d.ts.map +1 -0
  77. package/dist/platforms/slackInteractions.js +160 -0
  78. package/dist/platforms/slackInteractions.js.map +1 -0
  79. package/package.json +9 -1
@@ -1,3 +1,25 @@
1
+ import type { EventSource } from "../events.js";
2
+ import type { ManagedWebhooksOptions } from "../managedWebhooks.js";
3
+ import type { SecretConnection, Trigger } from "../types.js";
4
+ /** Options for `grafanaWebhooks()`. */
5
+ export type GrafanaWebhooksOptions = {
6
+ /** The secret you passed to `grafanaTriggers()`. */
7
+ secret: string;
8
+ };
9
+ /** An alert that started or stopped firing, as the `task.event.data` of an `alert` run. */
10
+ export type GrafanaAlertData = {
11
+ status: "firing" | "resolved";
12
+ /** The alert's `alertname` label. */
13
+ title: string;
14
+ /** The alert's labels, leaving out Grafana's own, which start with `__`. */
15
+ labels: Record<string, string>;
16
+ annotations: Record<string, string>;
17
+ fingerprint: string;
18
+ startsAt: string;
19
+ endsAt: string;
20
+ /** The alert rule's page in Grafana. */
21
+ url?: string;
22
+ };
1
23
  /**
2
24
  * Connects a skill to a Grafana instance with a service account token, which the human enters in the platform's form
3
25
  * and tasks reach through `connectionFetch()`.
@@ -6,5 +28,29 @@
6
28
  * @returns A connection to list in a skill's `connections`.
7
29
  * @throws {AgentJamError} If an allowed request is invalid, or `descriptions` names a field the connection doesn't ask for.
8
30
  */
9
- export declare const grafanaConnection: ({ allow, descriptions, }?: import("../secrets.js").SecretPresetOptions<"baseUrl" | "token">) => import("../types.js").SecretConnection;
31
+ export declare const grafanaConnection: ({ allow, descriptions, }?: import("../secrets.js").SecretPresetOptions<"baseUrl" | "token">) => SecretConnection;
32
+ /**
33
+ * Reads the webhooks `grafanaTriggers()` creates, for `agent.receiveEvents()` at the URL you passed it. It checks
34
+ * each request's signature with its schedule's secret in constant time, and responds to one that isn't signed in the
35
+ * last five minutes with a `401`.
36
+ *
37
+ * @param options The secret you passed to `grafanaTriggers()`.
38
+ * @returns An event source for Grafana's webhooks.
39
+ */
40
+ export declare const grafanaWebhooks: ({ secret, }: GrafanaWebhooksOptions) => EventSource;
41
+ /**
42
+ * Triggers that run a schedule when a Grafana instance's alerts fire or resolve, for a skill whose connections
43
+ * include `connection`, with a service account token allowed to write notification settings, such as an Editor's.
44
+ * Each schedule gets its own webhook contact point and a notification policy that copies it the alerts it watches
45
+ * before the rest of the policy tree routes them as before, plus a poll of firing alerts for any webhook it loses.
46
+ * Both are removed once the schedule ends.
47
+ *
48
+ * @param connection The skill's Grafana connection.
49
+ * @param options Where Grafana sends webhooks, the secret they derive from, and how the fallback polls run.
50
+ * @returns The `alert` trigger, for a skill's `triggers`.
51
+ */
52
+ export declare const grafanaTriggers: (connection: SecretConnection, options: ManagedWebhooksOptions) => {
53
+ /** An alert matching `config.matchers` starts or stops firing. */
54
+ alert: Trigger;
55
+ };
10
56
  //# sourceMappingURL=grafana.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"grafana.d.ts","sourceRoot":"","sources":["../../src/platforms/grafana.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,yIAG5B,CAAC"}
1
+ {"version":3,"file":"grafana.d.ts","sourceRoot":"","sources":["../../src/platforms/grafana.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EACV,sBAAsB,EAGvB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,KAAK,EAEV,gBAAgB,EAChB,OAAO,EAIR,MAAM,aAAa,CAAC;AAGrB,uCAAuC;AACvC,MAAM,MAAM,sBAAsB,GAAG;IACnC,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,2FAA2F;AAC3F,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9B,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAkCF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,mHAG5B,CAAC;AA2LH;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,gBAEzB,sBAAsB,KAAG,WAyB1B,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,eACd,gBAAgB,WACnB,sBAAsB;IAG7B,kEAAkE;;CAqBhC,CAAC"}
@@ -1,4 +1,15 @@
1
+ import { createHmac } from "node:crypto";
2
+ import { AgentJamError } from "../errors.js";
3
+ import { readSourceRequest } from "../events.js";
4
+ import { computeWebhookSecret, constructManagedTrigger, constructWebhookKey, isMatchingSecret, requestProvider, } from "../managedWebhooks.js";
5
+ import { truncateSummary } from "../polling.js";
1
6
  import { constructSecretPreset } from "./presets.js";
7
+ const contactPointsPath = "/api/v1/provisioning/contact-points";
8
+ const policiesPath = "/api/v1/provisioning/policies";
9
+ const signatureHeader = "x-grafana-alerting-signature";
10
+ const timestampHeader = "x-grafana-alerting-timestamp";
11
+ const maxWebhookAgeSeconds = 300;
12
+ const matcherPattern = /([A-Za-z_]\w*)\s*(=~|!~|!=|=)\s*(?:"((?:[^"\\]|\\.)*)"|([^,"]*))/g;
2
13
  /**
3
14
  * Connects a skill to a Grafana instance with a service account token, which the human enters in the platform's form
4
15
  * and tasks reach through `connectionFetch()`.
@@ -11,4 +22,180 @@ export const grafanaConnection = constructSecretPreset("grafana", [
11
22
  "baseUrl",
12
23
  "token",
13
24
  ]);
25
+ const parseMatchers = (matchers = "") => {
26
+ if (matchers.replace(matcherPattern, "").replace(/[\s,]/g, "") !== "") {
27
+ throw new AgentJamError(`Grafana matchers must be label matchers like service="checkout", not ${matchers}`);
28
+ }
29
+ return [...matchers.matchAll(matcherPattern)].map(([, label = "", operator = "", quoted, bare = ""]) => [
30
+ label,
31
+ operator,
32
+ quoted === undefined ? bare.trim() : quoted.replace(/\\(.)/g, "$1"),
33
+ ]);
34
+ };
35
+ const requestGrafana = (fetch, path, request = {}) => requestProvider(fetch, "Grafana", path, {
36
+ ...request,
37
+ headers: { "x-disable-provenance": "true" },
38
+ });
39
+ const findContactPoint = async (fetch, name) => {
40
+ const found = await requestGrafana(fetch, `${contactPointsPath}?${new URLSearchParams({ name }).toString()}`);
41
+ return found?.[0];
42
+ };
43
+ // WARNING: Grafana keeps every notification policy in one tree, so schedules updating it at once can drop a route.
44
+ const updatePolicies = async (fetch, update) => {
45
+ const { routes = [], ...root } = (await requestGrafana(fetch, policiesPath)) ?? {};
46
+ await requestGrafana(fetch, policiesPath, {
47
+ method: "PUT",
48
+ body: { ...root, routes: update(routes) },
49
+ });
50
+ };
51
+ const subscribeAlerts = (connection) => async ({ name, url, secret }, { config }, context) => {
52
+ const matchers = parseMatchers(config.matchers);
53
+ const fetch = context.connectionFetch(connection);
54
+ const existing = await findContactPoint(fetch, name);
55
+ const uid = existing?.uid ?? name;
56
+ await requestGrafana(fetch, existing ? `${contactPointsPath}/${uid}` : contactPointsPath, {
57
+ method: existing ? "PUT" : "POST",
58
+ body: {
59
+ uid,
60
+ name,
61
+ type: "webhook",
62
+ settings: {
63
+ url,
64
+ httpMethod: "POST",
65
+ hmacConfig: { secret, header: signatureHeader, timestampHeader },
66
+ },
67
+ disableResolveMessage: false,
68
+ },
69
+ });
70
+ await updatePolicies(fetch, (routes) => [
71
+ { receiver: name, object_matchers: matchers, continue: true },
72
+ ...routes.filter(({ receiver }) => receiver !== name),
73
+ ]);
74
+ };
75
+ const unsubscribeAlerts = (connection) => async ({ name }, _, context) => {
76
+ const fetch = context.connectionFetch(connection);
77
+ await updatePolicies(fetch, (routes) => routes.filter(({ receiver }) => receiver !== name));
78
+ const existing = await findContactPoint(fetch, name);
79
+ if (existing) {
80
+ await requestGrafana(fetch, `${contactPointsPath}/${existing.uid}`, {
81
+ method: "DELETE",
82
+ });
83
+ }
84
+ };
85
+ const constructAlertEvent = (alert, status) => {
86
+ const labels = Object.fromEntries(Object.entries(alert.labels).filter(([label]) => !label.startsWith("__")));
87
+ const title = alert.labels.alertname ?? alert.fingerprint;
88
+ const data = {
89
+ status,
90
+ title,
91
+ labels,
92
+ annotations: alert.annotations,
93
+ fingerprint: alert.fingerprint,
94
+ startsAt: alert.startsAt,
95
+ endsAt: alert.endsAt,
96
+ ...(alert.generatorURL && { url: alert.generatorURL }),
97
+ };
98
+ return {
99
+ id: `grafana:${alert.fingerprint}:${Date.parse(alert.startsAt)}:${status}`,
100
+ summary: truncateSummary(`Grafana alert ${status}: ${title}`),
101
+ data,
102
+ };
103
+ };
104
+ const reconcileAlerts = (connection) => async (since, { config }, context) => {
105
+ const filters = parseMatchers(config.matchers).map(([label, operator, value]) => [
106
+ "filter",
107
+ `${label}${operator}${JSON.stringify(value)}`,
108
+ ]);
109
+ const query = new URLSearchParams([
110
+ ["active", "true"],
111
+ ["silenced", "false"],
112
+ ["inhibited", "false"],
113
+ ...filters,
114
+ ]);
115
+ const alerts = await requestGrafana(context.connectionFetch(connection), `/api/alertmanager/grafana/api/v2/alerts?${query.toString()}`);
116
+ return (alerts ?? [])
117
+ .filter(({ startsAt }) => Date.parse(startsAt) >= since.getTime())
118
+ .toSorted((first, second) => Date.parse(first.startsAt) - Date.parse(second.startsAt))
119
+ .map((alert) => constructAlertEvent(alert, "firing"));
120
+ };
121
+ const readReceiver = (body) => {
122
+ try {
123
+ const { receiver } = JSON.parse(body);
124
+ return typeof receiver === "string" ? receiver : "";
125
+ }
126
+ catch {
127
+ return "";
128
+ }
129
+ };
130
+ const isSigned = (secret, headers, body) => {
131
+ const timestamp = headers.get(timestampHeader) ?? "";
132
+ const ageSeconds = Math.abs(Date.now() / 1000 - Number(timestamp));
133
+ if (Number.isNaN(ageSeconds) || ageSeconds > maxWebhookAgeSeconds) {
134
+ return false;
135
+ }
136
+ const webhookSecret = computeWebhookSecret(secret, readReceiver(body));
137
+ const expected = createHmac("sha256", webhookSecret)
138
+ .update(`${timestamp}:${body}`)
139
+ .digest("hex");
140
+ return isMatchingSecret(headers.get(signatureHeader), expected);
141
+ };
142
+ /**
143
+ * Reads the webhooks `grafanaTriggers()` creates, for `agent.receiveEvents()` at the URL you passed it. It checks
144
+ * each request's signature with its schedule's secret in constant time, and responds to one that isn't signed in the
145
+ * last five minutes with a `401`.
146
+ *
147
+ * @param options The secret you passed to `grafanaTriggers()`.
148
+ * @returns An event source for Grafana's webhooks.
149
+ */
150
+ export const grafanaWebhooks = ({ secret, }) => ({
151
+ receive: async (request) => {
152
+ const { headers, body } = await readSourceRequest(request);
153
+ if (!isSigned(secret, headers, body)) {
154
+ return {
155
+ response: { status: 401, body: "Invalid Grafana signature" },
156
+ events: [],
157
+ };
158
+ }
159
+ const { receiver, alerts } = JSON.parse(body);
160
+ const eventKeys = [constructWebhookKey("grafana", receiver)];
161
+ return {
162
+ response: { status: 200 },
163
+ events: alerts.map((alert) => ({
164
+ type: "event",
165
+ eventKeys,
166
+ event: constructAlertEvent(alert, alert.status),
167
+ })),
168
+ };
169
+ },
170
+ });
171
+ /**
172
+ * Triggers that run a schedule when a Grafana instance's alerts fire or resolve, for a skill whose connections
173
+ * include `connection`, with a service account token allowed to write notification settings, such as an Editor's.
174
+ * Each schedule gets its own webhook contact point and a notification policy that copies it the alerts it watches
175
+ * before the rest of the policy tree routes them as before, plus a poll of firing alerts for any webhook it loses.
176
+ * Both are removed once the schedule ends.
177
+ *
178
+ * @param connection The skill's Grafana connection.
179
+ * @param options Where Grafana sends webhooks, the secret they derive from, and how the fallback polls run.
180
+ * @returns The `alert` trigger, for a skill's `triggers`.
181
+ */
182
+ export const grafanaTriggers = (connection, options) => ({
183
+ /** An alert matching `config.matchers` starts or stops firing. */
184
+ alert: constructManagedTrigger({
185
+ provider: "grafana",
186
+ description: "A Grafana alert starts or stops firing",
187
+ config: {
188
+ type: "object",
189
+ properties: {
190
+ matchers: {
191
+ type: "string",
192
+ description: 'Label matchers narrowing the alerts to watch, such as service="checkout",env=~"prod|staging". Every alert is watched when left out',
193
+ },
194
+ },
195
+ },
196
+ subscribe: subscribeAlerts(connection),
197
+ unsubscribe: unsubscribeAlerts(connection),
198
+ reconcile: reconcileAlerts(connection),
199
+ }, options),
200
+ });
14
201
  //# sourceMappingURL=grafana.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"grafana.js","sourceRoot":"","sources":["../../src/platforms/grafana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,SAAS,EAAE;IAChE,SAAS;IACT,OAAO;CACR,CAAC,CAAC"}
1
+ {"version":3,"file":"grafana.js","sourceRoot":"","sources":["../../src/platforms/grafana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMjD,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAShD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AA0CrD,MAAM,iBAAiB,GAAG,qCAAqC,CAAC;AAEhE,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD,MAAM,eAAe,GAAG,8BAA8B,CAAC;AAEvD,MAAM,eAAe,GAAG,8BAA8B,CAAC;AAEvD,MAAM,oBAAoB,GAAG,GAAG,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,MAAM,EAAE,GAAG,EAAE;YACzB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC7B,IAAI,EAAE,OAAO;gBACb,SAAS;gBACT,KAAK,EAAE,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;aAChD,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,UAA4B,EAC5B,OAA+B,EAC/B,EAAE,CACF,CAAC;IACC,kEAAkE;IAClE,KAAK,EAAE,uBAAuB,CAC5B;QACE,QAAQ,EAAE,SAAS;QACnB,WAAW,EAAE,wCAAwC;QACrD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,oIAAoI;iBACvI;aACF;SACF;QACD,SAAS,EAAE,eAAe,CAAC,UAAU,CAAC;QACtC,WAAW,EAAE,iBAAiB,CAAC,UAAU,CAAC;QAC1C,SAAS,EAAE,eAAe,CAAC,UAAU,CAAC;KACvC,EACD,OAAO,CACR;CACF,CAAmC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { CredentialSource, OAuthConnection, OAuthPresetOptions } from "../connections.js";
2
+ import type { EventSource } from "../events.js";
3
+ import type { ManagedWebhooksOptions } from "../managedWebhooks.js";
4
+ import type { JsonObject, Trigger } from "../types.js";
5
+ /** Options for `pagerdutyWebhooks()`. */
6
+ export type PagerDutyWebhooksOptions = {
7
+ /** The secret you passed to `pagerdutyTriggers()`. */
8
+ secret: string;
9
+ };
10
+ /** The incident events a PagerDuty webhook subscription can send. */
11
+ export declare const pagerdutyIncidentEvents: readonly ["incident.acknowledged", "incident.annotated", "incident.delegated", "incident.escalated", "incident.priority_updated", "incident.reassigned", "incident.reopened", "incident.resolved", "incident.responder.added", "incident.responder.replied", "incident.status_update_published", "incident.triggered", "incident.unacknowledged"];
12
+ /** An incident event a PagerDuty webhook subscription sends. */
13
+ export type PagerDutyIncidentEvent = (typeof pagerdutyIncidentEvents)[number];
14
+ /** An incident's change, as the `task.event.data` of an `incident` run. */
15
+ export type PagerDutyIncidentData = {
16
+ eventType: PagerDutyIncidentEvent;
17
+ occurredAt: string;
18
+ /** Who made the change, such as a user's name, if anyone did. */
19
+ agent: string | null;
20
+ /** The incident as PagerDuty describes it, with its `id`, `title`, `status`, `urgency`, `service` and `html_url`. */
21
+ incident: JsonObject;
22
+ };
23
+ /** How to run PagerDuty's OAuth flow, which follows the standard. */
24
+ export declare const pagerdutyProfile: import("../providers.js").OAuthProfile;
25
+ /**
26
+ * Connects a skill to a human's PagerDuty account through a PagerDuty app's scoped OAuth. `pagerdutyTriggers()`
27
+ * needs the `webhook_subscriptions.read` and `webhook_subscriptions.write` scopes. The client settings left out are
28
+ * read from `PAGERDUTY_CLIENT_ID`, `PAGERDUTY_CLIENT_SECRET` and `PAGERDUTY_REDIRECT_URI`.
29
+ *
30
+ * @param options The scopes to request, such as `incidents.read`, and a token store if the relay holds no grants.
31
+ * @returns A connection to list in a skill's `connections`.
32
+ * @throws {AgentJamError} If a client setting is neither passed nor set in the environment.
33
+ */
34
+ export declare const pagerdutyConnection: (options: OAuthPresetOptions & {
35
+ scopes: string[];
36
+ }) => OAuthConnection<"default">;
37
+ /**
38
+ * Reads the webhooks `pagerdutyTriggers()` subscribes to, for `agent.receiveEvents()` at the URL you passed it. It
39
+ * checks each request carries its schedule's secret in constant time, and responds to one that doesn't with a `401`.
40
+ *
41
+ * @param options The secret you passed to `pagerdutyTriggers()`.
42
+ * @returns An event source for PagerDuty's webhooks.
43
+ */
44
+ export declare const pagerdutyWebhooks: ({ secret, }: PagerDutyWebhooksOptions) => EventSource;
45
+ /**
46
+ * Triggers that run a schedule on a PagerDuty account's incidents, for a skill whose connections include
47
+ * `connection`, with the `webhook_subscriptions.read` and `webhook_subscriptions.write` scopes. Each schedule gets
48
+ * its own webhook subscription, which PagerDuty sends to `url` for `pagerdutyWebhooks()` to read, and which is
49
+ * removed once the schedule ends.
50
+ *
51
+ * @param connection The skill's PagerDuty connection.
52
+ * @param options Where PagerDuty sends webhooks, and the secret they derive from.
53
+ * @returns The `incident` trigger, for a skill's `triggers`.
54
+ */
55
+ export declare const pagerdutyTriggers: (connection: CredentialSource, options: Pick<ManagedWebhooksOptions, "url" | "secret">) => {
56
+ /** An incident of the account, or of `config.service` or `config.team`, changes in one of `config.events`. */
57
+ incident: Trigger;
58
+ };
59
+ //# sourceMappingURL=pagerduty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagerduty.d.ts","sourceRoot":"","sources":["../../src/platforms/pagerduty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EACV,sBAAsB,EAGvB,MAAM,uBAAuB,CAAC;AAU/B,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EAIR,MAAM,aAAa,CAAC;AAGrB,yCAAyC;AACzC,MAAM,MAAM,wBAAwB,GAAG;IACrC,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,YAClC,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,EAC1B,4BAA4B,EAC5B,kCAAkC,EAClC,oBAAoB,EACpB,yBAAyB,CACjB,CAAC;AAEX,gEAAgE;AAChE,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,2EAA2E;AAC3E,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,sBAAsB,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,qHAAqH;IACrH,QAAQ,EAAE,UAAU,CAAC;CACtB,CAAC;AA+BF,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,wCAG3B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,YACrB,kBAAkB,GAAG;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,KACjD,eAAe,CAAC,SAAS,CAIzB,CAAC;AAgIJ;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,gBAE3B,wBAAwB,KAAG,WACsC,CAAC;AAErE;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,eAChB,gBAAgB,WACnB,IAAI,CAAC,sBAAsB,EAAE,KAAK,GAAG,QAAQ,CAAC;IAGrD,8GAA8G;;CAmC5E,CAAC"}
@@ -0,0 +1,175 @@
1
+ import { constructHeaderWebhooks, constructManagedTrigger, requestProvider, secretHeader, subscriptionHeader, } from "../managedWebhooks.js";
2
+ import { truncateSummary } from "../polling.js";
3
+ import { constructStandardProfile } from "../providers.js";
4
+ import { constructOAuthPreset } from "./presets.js";
5
+ /** The incident events a PagerDuty webhook subscription can send. */
6
+ export const pagerdutyIncidentEvents = [
7
+ "incident.acknowledged",
8
+ "incident.annotated",
9
+ "incident.delegated",
10
+ "incident.escalated",
11
+ "incident.priority_updated",
12
+ "incident.reassigned",
13
+ "incident.reopened",
14
+ "incident.resolved",
15
+ "incident.responder.added",
16
+ "incident.responder.replied",
17
+ "incident.status_update_published",
18
+ "incident.triggered",
19
+ "incident.unacknowledged",
20
+ ];
21
+ const pagerdutyApi = "https://api.pagerduty.com";
22
+ const subscriptionsPageSize = 100;
23
+ const referencePattern = "^[A-Z0-9]{1,32}$";
24
+ /** How to run PagerDuty's OAuth flow, which follows the standard. */
25
+ export const pagerdutyProfile = constructStandardProfile({
26
+ authorize: "https://identity.pagerduty.com/oauth/authorize",
27
+ token: "https://identity.pagerduty.com/oauth/token",
28
+ });
29
+ /**
30
+ * Connects a skill to a human's PagerDuty account through a PagerDuty app's scoped OAuth. `pagerdutyTriggers()`
31
+ * needs the `webhook_subscriptions.read` and `webhook_subscriptions.write` scopes. The client settings left out are
32
+ * read from `PAGERDUTY_CLIENT_ID`, `PAGERDUTY_CLIENT_SECRET` and `PAGERDUTY_REDIRECT_URI`.
33
+ *
34
+ * @param options The scopes to request, such as `incidents.read`, and a token store if the relay holds no grants.
35
+ * @returns A connection to list in a skill's `connections`.
36
+ * @throws {AgentJamError} If a client setting is neither passed nor set in the environment.
37
+ */
38
+ export const pagerdutyConnection = (options) => constructOAuthPreset({ provider: "pagerduty", profile: pagerdutyProfile, prefix: "PAGERDUTY" }, options);
39
+ const requestPagerDuty = (token, path, request = {}) => requestProvider((input, init) => fetch(`${pagerdutyApi}${input}`, init), "PagerDuty", path, {
40
+ ...request,
41
+ headers: {
42
+ accept: "application/vnd.pagerduty+json;version=2",
43
+ authorization: `Bearer ${token}`,
44
+ },
45
+ });
46
+ const findSubscription = async (token, name) => {
47
+ for (let offset = 0;; offset += subscriptionsPageSize) {
48
+ const query = new URLSearchParams({
49
+ limit: String(subscriptionsPageSize),
50
+ offset: String(offset),
51
+ });
52
+ const page = await requestPagerDuty(token, `/webhook_subscriptions?${query.toString()}`);
53
+ const found = page?.webhook_subscriptions.find(({ description }) => description === name);
54
+ if (found || !page?.more)
55
+ return found;
56
+ }
57
+ };
58
+ const deleteSubscription = async (token, name) => {
59
+ const existing = await findSubscription(token, name);
60
+ if (existing) {
61
+ await requestPagerDuty(token, `/webhook_subscriptions/${existing.id}`, {
62
+ method: "DELETE",
63
+ });
64
+ }
65
+ };
66
+ const constructFilter = ({ service, team }) => {
67
+ if (service !== undefined)
68
+ return { type: "service_reference", id: service };
69
+ if (team !== undefined)
70
+ return { type: "team_reference", id: team };
71
+ return { type: "account_reference" };
72
+ };
73
+ const subscribeIncidents = (connection) => async ({ name, url, secret }, schedule, context) => {
74
+ const config = schedule.config;
75
+ const token = await context.credentials(connection);
76
+ // WARNING: PagerDuty can't change a subscription's headers, so a changed URL or secret needs a new subscription.
77
+ await deleteSubscription(token, name);
78
+ await requestPagerDuty(token, "/webhook_subscriptions", {
79
+ method: "POST",
80
+ body: {
81
+ webhook_subscription: {
82
+ type: "webhook_subscription",
83
+ description: name,
84
+ events: config.events ?? [...pagerdutyIncidentEvents],
85
+ filter: constructFilter(config),
86
+ delivery_method: {
87
+ type: "http_delivery_method",
88
+ url,
89
+ custom_headers: [
90
+ { name: subscriptionHeader, value: name },
91
+ { name: secretHeader, value: secret },
92
+ ],
93
+ },
94
+ },
95
+ },
96
+ });
97
+ };
98
+ const unsubscribeIncidents = (connection) => async ({ name }, _, context) => {
99
+ await deleteSubscription(await context.credentials(connection), name);
100
+ };
101
+ const isIncidentEvent = (eventType) => pagerdutyIncidentEvents.includes(eventType);
102
+ const readPagerDutyWebhook = (payload) => {
103
+ const { event } = payload;
104
+ if (!event?.id || !isIncidentEvent(event.event_type))
105
+ return [];
106
+ const agent = event.agent?.summary ?? null;
107
+ const incident = event.data ?? {};
108
+ const change = event.event_type
109
+ .slice("incident.".length)
110
+ .replace(/[._]/g, " ");
111
+ const data = {
112
+ eventType: event.event_type,
113
+ occurredAt: event.occurred_at ?? "",
114
+ agent,
115
+ incident,
116
+ };
117
+ return [
118
+ {
119
+ id: `pagerduty:${event.id}`,
120
+ summary: truncateSummary(`PagerDuty incident ${change}${agent ? ` by ${agent}` : ""}: ${incident.title ?? ""}`),
121
+ data,
122
+ },
123
+ ];
124
+ };
125
+ /**
126
+ * Reads the webhooks `pagerdutyTriggers()` subscribes to, for `agent.receiveEvents()` at the URL you passed it. It
127
+ * checks each request carries its schedule's secret in constant time, and responds to one that doesn't with a `401`.
128
+ *
129
+ * @param options The secret you passed to `pagerdutyTriggers()`.
130
+ * @returns An event source for PagerDuty's webhooks.
131
+ */
132
+ export const pagerdutyWebhooks = ({ secret, }) => constructHeaderWebhooks("pagerduty", secret, readPagerDutyWebhook);
133
+ /**
134
+ * Triggers that run a schedule on a PagerDuty account's incidents, for a skill whose connections include
135
+ * `connection`, with the `webhook_subscriptions.read` and `webhook_subscriptions.write` scopes. Each schedule gets
136
+ * its own webhook subscription, which PagerDuty sends to `url` for `pagerdutyWebhooks()` to read, and which is
137
+ * removed once the schedule ends.
138
+ *
139
+ * @param connection The skill's PagerDuty connection.
140
+ * @param options Where PagerDuty sends webhooks, and the secret they derive from.
141
+ * @returns The `incident` trigger, for a skill's `triggers`.
142
+ */
143
+ export const pagerdutyTriggers = (connection, options) => ({
144
+ /** An incident of the account, or of `config.service` or `config.team`, changes in one of `config.events`. */
145
+ incident: constructManagedTrigger({
146
+ provider: "pagerduty",
147
+ description: "A PagerDuty incident is triggered, acknowledged, resolved or otherwise changes",
148
+ config: {
149
+ type: "object",
150
+ properties: {
151
+ events: {
152
+ type: "array",
153
+ items: { enum: [...pagerdutyIncidentEvents] },
154
+ minItems: 1,
155
+ uniqueItems: true,
156
+ description: "The incident events to run on, such as incident.triggered. Defaults to all of them",
157
+ },
158
+ service: {
159
+ type: "string",
160
+ pattern: referencePattern,
161
+ description: "The id of the service whose incidents to watch",
162
+ },
163
+ team: {
164
+ type: "string",
165
+ pattern: referencePattern,
166
+ description: "The id of the team whose incidents to watch",
167
+ },
168
+ },
169
+ not: { required: ["service", "team"] },
170
+ },
171
+ subscribe: subscribeIncidents(connection),
172
+ unsubscribe: unsubscribeIncidents(connection),
173
+ }, options),
174
+ });
175
+ //# sourceMappingURL=pagerduty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagerduty.js","sourceRoot":"","sources":["../../src/platforms/pagerduty.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,kBAAkB,GACnB,MAAM,uBAAuB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D,EACvD,EAAE,CACF,CAAC;IACC,8GAA8G;IAC9G,QAAQ,EAAE,uBAAuB,CAC/B;QACE,QAAQ,EAAE,WAAW;QACrB,WAAW,EACT,gFAAgF;QAClF,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,uBAAuB,CAAC,EAAE;oBAC7C,QAAQ,EAAE,CAAC;oBACX,WAAW,EAAE,IAAI;oBACjB,WAAW,EACT,oFAAoF;iBACvF;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,gBAAgB;oBACzB,WAAW,EAAE,gDAAgD;iBAC9D;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,gBAAgB;oBACzB,WAAW,EAAE,6CAA6C;iBAC3D;aACF;YACD,GAAG,EAAE,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE;SACvC;QACD,SAAS,EAAE,kBAAkB,CAAC,UAAU,CAAC;QACzC,WAAW,EAAE,oBAAoB,CAAC,UAAU,CAAC;KAC9C,EACD,OAAO,CACR;CACF,CAAmC,CAAC"}
@@ -1,5 +1,10 @@
1
1
  import type { CredentialSource, OAuthConnection, OAuthPresetOptions } from "../connections.js";
2
+ import type { EventSource } from "../events.js";
3
+ import type { Trigger } from "../types.js";
2
4
  import type { WatermarkStore } from "../watermarks.js";
5
+ import type { SentryRegion } from "./sentryApi.js";
6
+ export type { SentryRegion } from "./sentryApi.js";
7
+ export type { SentryEventData, SentryResourceName } from "./sentryEvents.js";
3
8
  /** Options for `sentryTriggers()`. */
4
9
  export type SentryEventsOptions = {
5
10
  /** Where polls keep each schedule's progress. Defaults to a `MemoryWatermarkStore`, which forgets it on exit. */
@@ -8,9 +13,14 @@ export type SentryEventsOptions = {
8
13
  pollIntervalMinutes?: number;
9
14
  /** Handles a failed poll, which is tried again at the next interval. Defaults to `console.error`. */
10
15
  onError?: (error: unknown) => void;
16
+ /** The slug of your Sentry integration, whose webhooks `sentryWebhooks()` reads. The webhook triggers need it. */
17
+ integration?: string;
18
+ };
19
+ /** Options for `sentryWebhooks()`. */
20
+ export type SentryWebhooksOptions = {
21
+ /** The client secret of your Sentry integration, which signs each webhook. */
22
+ secret: string;
11
23
  };
12
- /** The Sentry region an organization's data lives in, which picks its API's host. */
13
- export type SentryRegion = "us" | "de";
14
24
  /** A new Sentry issue, as the `task.event.data` of an `error_reported` run. */
15
25
  export type SentryErrorData = {
16
26
  region: SentryRegion;
@@ -40,30 +50,33 @@ export declare const sentryConnection: (options: OAuthPresetOptions & {
40
50
  scopes: string[];
41
51
  }) => OAuthConnection<"default">;
42
52
  /**
43
- * Triggers that run a schedule on a Sentry project's errors, for a skill whose connections include `connection`,
44
- * with the `event:read`, `project:read` and `org:read` scopes. Each schedule polls with its token from where
45
- * `watermarks` says it left off.
53
+ * Reads the webhooks of your Sentry integration, for `agent.receiveEvents()` at its webhook URL. It verifies each
54
+ * request's `Sentry-Hook-Signature` in constant time, and reads it under the keys the webhook triggers of
55
+ * `sentryTriggers()` subscribe to.
56
+ *
57
+ * @param options The integration's client secret.
58
+ * @returns An event source for Sentry's webhooks.
59
+ */
60
+ export declare const sentryWebhooks: ({ secret, }: SentryWebhooksOptions) => EventSource;
61
+ /**
62
+ * Triggers that run a schedule on a Sentry organization's activity, for a skill whose connections include
63
+ * `connection`, with the `event:read`, `project:read` and `org:read` scopes. `error_reported` polls with the
64
+ * schedule's token from where `watermarks` says it left off, while the trigger named after each webhook resource,
65
+ * such as `issue`, runs on the webhooks `sentryWebhooks()` reads from the organization's install of `integration`.
46
66
  *
47
67
  * @param connection The skill's Sentry connection.
48
- * @param options Where polls keep their progress, and how often they run.
49
- * @returns The `error_reported` trigger, for a skill's `triggers`.
68
+ * @param options Where polls keep their progress, how often they run, and your Sentry integration's slug.
69
+ * @returns The `error_reported` trigger, and one per webhook resource, for a skill's `triggers`.
50
70
  */
51
- export declare const sentryTriggers: (connection: CredentialSource, { watermarks, pollIntervalMinutes, onError, }?: SentryEventsOptions) => {
71
+ export declare const sentryTriggers: (connection: CredentialSource, { watermarks, pollIntervalMinutes, onError, integration, }?: SentryEventsOptions) => {
52
72
  /** A new unresolved issue in `config.project`, once per issue, which an issue that regresses after it's resolved doesn't repeat. */
53
73
  error_reported: {
54
74
  description: string;
55
75
  config: {
56
76
  type: string;
57
77
  properties: {
58
- region: {
59
- enum: string[];
60
- description: string;
61
- };
62
- organization: {
63
- type: string;
64
- pattern: string;
65
- description: string;
66
- };
78
+ region: import("../types.js").JsonSchema;
79
+ organization: import("../types.js").JsonSchema;
67
80
  project: {
68
81
  type: string;
69
82
  pattern: string;
@@ -75,5 +88,10 @@ export declare const sentryTriggers: (connection: CredentialSource, { watermarks
75
88
  };
76
89
  onScheduleActive: (schedule: import("../types.js").TriggerSchedule, context: import("../types.js").TriggerContext) => import("../types.js").Awaitable<import("../types.js").TriggerActivation | void>;
77
90
  };
91
+ comment: Trigger;
92
+ error: Trigger;
93
+ event_alert: Trigger;
94
+ issue: Trigger;
95
+ metric_alert: Trigger;
78
96
  };
79
97
  //# sourceMappingURL=sentry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../../src/platforms/sentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAU3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,sCAAsC;AACtC,MAAM,MAAM,mBAAmB,GAAG;IAChC,iHAAiH;IACjH,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,+FAA+F;IAC/F,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,qGAAqG;IACrG,OAAO,CAAC,EAAE,CAAC,KAAK,E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