terse-types 0.0.3 → 0.0.5
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.
- package/dist/ApiRouteBuilder.d.ts +5 -21
- package/dist/ApiRoutes.json +8 -24
- package/dist/ApprovalTypes.d.ts +47 -19
- package/dist/ApprovalTypes.js +20 -0
- package/dist/Configs.d.ts +300 -166
- package/dist/Configs.js +109 -252
- package/dist/Integrations.d.ts +0 -34
- package/dist/Integrations.js +0 -30
- package/dist/InvalidationKeys.d.ts +2 -4
- package/dist/InvalidationKeys.js +2 -18
- package/dist/ModelEvents.d.ts +134 -26
- package/dist/ModelEvents.js +68 -79
- package/dist/Notifications.d.ts +19 -8
- package/dist/Notifications.js +6 -6
- package/dist/RunHistoryTypes.d.ts +34 -39
- package/dist/RunHistoryTypes.js +12 -10
- package/dist/SlackTypes.d.ts +23 -0
- package/dist/SlackTypes.js +9 -0
- package/dist/TicketSystem.d.ts +0 -1
- package/dist/TicketSystem.js +0 -1
- package/dist/ToolDisplayUtils.js +0 -76
- package/dist/Tools.d.ts +14 -907
- package/dist/Tools.js +0 -210
- package/dist/TriggerPresenters.d.ts +3 -0
- package/dist/TriggerPresenters.js +254 -0
- package/dist/Triggers.d.ts +4065 -0
- package/dist/Triggers.js +436 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/types.d.ts +5197 -2534
- package/dist/types.js +113 -236
- package/package.json +3 -1
package/dist/Tools.js
CHANGED
|
@@ -119,42 +119,6 @@ export const slackConversationMessageSchema = z.object({
|
|
|
119
119
|
timestamp: z.string().optional(),
|
|
120
120
|
threadTs: z.string().optional()
|
|
121
121
|
});
|
|
122
|
-
export const jiraIssueStateSchema = z.object({
|
|
123
|
-
id: z.string(),
|
|
124
|
-
name: z.string()
|
|
125
|
-
});
|
|
126
|
-
export const jiraIssueAssigneeSchema = z.object({
|
|
127
|
-
id: z.string(),
|
|
128
|
-
name: z.string(),
|
|
129
|
-
email: z.string().optional()
|
|
130
|
-
});
|
|
131
|
-
export const jiraIssueProjectRefSchema = z.object({
|
|
132
|
-
id: z.string(),
|
|
133
|
-
name: z.string(),
|
|
134
|
-
key: z.string()
|
|
135
|
-
});
|
|
136
|
-
export const jiraIssueTypeRefSchema = z.object({
|
|
137
|
-
id: z.string(),
|
|
138
|
-
name: z.string()
|
|
139
|
-
});
|
|
140
|
-
export const jiraRichDescriptionSchema = z.union([z.string(), z.record(z.string(), z.unknown())]);
|
|
141
|
-
export const jiraIssueSummarySchema = z.object({
|
|
142
|
-
id: z.string().optional(),
|
|
143
|
-
key: z.string(),
|
|
144
|
-
identifier: z.string(),
|
|
145
|
-
title: z.string().optional(),
|
|
146
|
-
description: jiraRichDescriptionSchema.optional(),
|
|
147
|
-
state: jiraIssueStateSchema.optional(),
|
|
148
|
-
priority: z.number().int().optional(),
|
|
149
|
-
assignee: jiraIssueAssigneeSchema.nullable().optional(),
|
|
150
|
-
labels: z.array(z.string()).optional(),
|
|
151
|
-
dueDate: z.string().optional(),
|
|
152
|
-
project: jiraIssueProjectRefSchema.optional(),
|
|
153
|
-
issueType: jiraIssueTypeRefSchema.optional(),
|
|
154
|
-
url: z.string().optional(),
|
|
155
|
-
createdAt: z.string().optional(),
|
|
156
|
-
updatedAt: z.string().optional()
|
|
157
|
-
});
|
|
158
122
|
export const gitHubPaginationSchema = z.object({
|
|
159
123
|
page: z.number().int(),
|
|
160
124
|
perPage: z.number().int(),
|
|
@@ -403,60 +367,6 @@ export const gmailDraftSummarySchema = z.object({
|
|
|
403
367
|
summary: z.string(),
|
|
404
368
|
is_reply: z.boolean()
|
|
405
369
|
});
|
|
406
|
-
export const confluencePageSpaceSchema = z.object({
|
|
407
|
-
id: z.union([z.string(), z.number()]),
|
|
408
|
-
key: z.string(),
|
|
409
|
-
name: z.string(),
|
|
410
|
-
type: z.string()
|
|
411
|
-
});
|
|
412
|
-
export const confluencePageVersionAuthorSchema = z.object({
|
|
413
|
-
type: z.string(),
|
|
414
|
-
username: z.string().optional(),
|
|
415
|
-
userKey: z.string().optional(),
|
|
416
|
-
accountId: z.string().optional(),
|
|
417
|
-
displayName: z.string().optional()
|
|
418
|
-
});
|
|
419
|
-
export const confluencePageVersionSchema = z.object({
|
|
420
|
-
number: z.number().int(),
|
|
421
|
-
when: z.string(),
|
|
422
|
-
message: z.string().optional(),
|
|
423
|
-
by: confluencePageVersionAuthorSchema.optional()
|
|
424
|
-
});
|
|
425
|
-
export const confluenceBodyRepresentationSchema = z.object({
|
|
426
|
-
value: z.string(),
|
|
427
|
-
representation: z.string()
|
|
428
|
-
});
|
|
429
|
-
export const confluenceBodyContentSchema = z.object({
|
|
430
|
-
storage: confluenceBodyRepresentationSchema.optional(),
|
|
431
|
-
view: confluenceBodyRepresentationSchema.optional(),
|
|
432
|
-
export_view: confluenceBodyRepresentationSchema.optional()
|
|
433
|
-
});
|
|
434
|
-
export const confluencePageRelationSchema = z.object({
|
|
435
|
-
id: z.string(),
|
|
436
|
-
title: z.string(),
|
|
437
|
-
type: z.string()
|
|
438
|
-
});
|
|
439
|
-
export const confluenceCommentPositionSchema = z.object({
|
|
440
|
-
start: z.number().int(),
|
|
441
|
-
end: z.number().int()
|
|
442
|
-
});
|
|
443
|
-
export const confluencePageQueryResultSchema = z.object({
|
|
444
|
-
page_id: z.string(),
|
|
445
|
-
title: z.string(),
|
|
446
|
-
type: z.string(),
|
|
447
|
-
status: z.string(),
|
|
448
|
-
space: confluencePageSpaceSchema.optional(),
|
|
449
|
-
version: confluencePageVersionSchema.optional(),
|
|
450
|
-
created_date: z.string().optional(),
|
|
451
|
-
last_modified: z.string().optional(),
|
|
452
|
-
url: z.string().optional(),
|
|
453
|
-
body: confluenceBodyContentSchema,
|
|
454
|
-
body_text: z.string(),
|
|
455
|
-
ancestors: z.array(confluencePageRelationSchema),
|
|
456
|
-
descendants: z.array(confluencePageRelationSchema),
|
|
457
|
-
ancestors_count: z.number().int(),
|
|
458
|
-
descendants_count: z.number().int()
|
|
459
|
-
});
|
|
460
370
|
export const posthogSeverityLevelSchema = z.enum(["error", "warn", "info", "debug"]);
|
|
461
371
|
export const posthogSessionSummarySchema = z.object({
|
|
462
372
|
id: z.string(),
|
|
@@ -660,51 +570,6 @@ export const slackReadConversationInputSchema = z.object({
|
|
|
660
570
|
limit: z.number().int().min(1).max(200).nullable().optional().default(50).describe("Maximum number of messages to return."),
|
|
661
571
|
cursor: z.string().nullable().optional().describe("Pagination cursor from a previous response (nextCursor). Omit on first call.")
|
|
662
572
|
});
|
|
663
|
-
export const jiraAssigneeInputSchema = z
|
|
664
|
-
.object({
|
|
665
|
-
email: z.string().describe("The assignee email")
|
|
666
|
-
})
|
|
667
|
-
.nullable();
|
|
668
|
-
export const jiraCreateTicketInputSchema = z.object({
|
|
669
|
-
integrationId: z.string().describe("The integration ID of the Atlassian/Jira integration to use."),
|
|
670
|
-
title: z.string().describe("The issue title/summary. This is required."),
|
|
671
|
-
description: z.string().nullable().optional().describe("The issue description in plain text or markdown format."),
|
|
672
|
-
projectKey: z.string().describe('The Jira project key (e.g., "PROJ", "TEAM"). This is required.'),
|
|
673
|
-
issueType: z.string().nullable().optional().describe('The Jira issue type (e.g., "Task", "Bug", "Story", "Epic", "Subtask", "Improvement", "New Feature")').default("Task"),
|
|
674
|
-
assignee: jiraAssigneeInputSchema.optional().describe("The assignee of the ticket"),
|
|
675
|
-
priority: z.number().int().nullable().optional().describe("The priority of the ticket (number, typically 1-5)"),
|
|
676
|
-
labels: z.array(z.string()).nullable().optional().describe("The labels for the ticket (array of label names)"),
|
|
677
|
-
dueDate: z.string().nullable().optional().describe('The due date for the ticket in format "yyyy-MM-dd" (e.g., "2024-12-31"). Note: Jira requires the due date format to be yyyy-MM-dd.')
|
|
678
|
-
});
|
|
679
|
-
export const jiraUpdateTicketInputSchema = z.object({
|
|
680
|
-
integrationId: z.string().describe("The integration ID of the Atlassian/Jira integration to use."),
|
|
681
|
-
issueKey: z.string().describe('The key of the Jira issue to update (e.g., "PROJ-123"). This is required.'),
|
|
682
|
-
title: z.string().nullable().optional().describe("The issue title/summary."),
|
|
683
|
-
description: z.string().nullable().optional().describe("The issue description in plain text or markdown format."),
|
|
684
|
-
status: z.string().nullable().optional().describe('The status name to transition to (e.g., "In Progress", "Done", "To Do").'),
|
|
685
|
-
assignee: jiraAssigneeInputSchema.optional().describe("The assignee of the ticket. Set to null to unassign."),
|
|
686
|
-
priority: z.number().int().nullable().optional().describe("The priority of the ticket (number, typically 1-5)."),
|
|
687
|
-
labels: z.array(z.string()).nullable().optional().describe("The labels for the ticket (array of label names). This replaces all existing labels."),
|
|
688
|
-
dueDate: z
|
|
689
|
-
.string()
|
|
690
|
-
.nullable()
|
|
691
|
-
.optional()
|
|
692
|
-
.describe('The due date for the ticket in format "yyyy-MM-dd" (e.g., "2024-12-31"). Note: Jira requires the due date format to be yyyy-MM-dd. Set to null to remove due date.')
|
|
693
|
-
});
|
|
694
|
-
export const jiraSearchTicketInputSchema = z.object({
|
|
695
|
-
integrationId: z.string().describe("The integration ID of the Atlassian/Jira integration to use."),
|
|
696
|
-
jql: z.string().nullable().optional().describe("JQL (Jira Query Language) query to search for issues. If not provided, will search all issues."),
|
|
697
|
-
text: z.string().nullable().optional().describe('Text to search for in issue titles and descriptions. If provided, will be converted to JQL: text ~ "search term"'),
|
|
698
|
-
projectKey: z.string().nullable().optional().describe('Filter by Jira project key (e.g., "PROJ", "TEAM")'),
|
|
699
|
-
assigneeEmail: z.string().nullable().optional().describe("Filter by assignee email address"),
|
|
700
|
-
status: z.string().nullable().optional().describe('Filter by status name (e.g., "In Progress", "Done", "To Do")'),
|
|
701
|
-
limit: z.number().int().nullable().optional().describe("Maximum number of issues to return. Defaults to 50 if not provided."),
|
|
702
|
-
nextPageToken: z
|
|
703
|
-
.string()
|
|
704
|
-
.nullable()
|
|
705
|
-
.optional()
|
|
706
|
-
.describe("Token from a previous search response to retrieve the next page of results. Use the nextPageToken value from the previous response to paginate through all results.")
|
|
707
|
-
});
|
|
708
573
|
export const searchGitHubCodeInputSchema = z.object({
|
|
709
574
|
repositoryNames: z.array(z.string()).describe("Array of repository full names (owner/repo format) to search in."),
|
|
710
575
|
query: z.string().describe('The search query. Use natural language or code-specific terms. Examples: "authentication middleware", "class UserRepository", "handleSubmit form validation"'),
|
|
@@ -994,32 +859,6 @@ export const gmailSendEmailInputSchema = z.object({
|
|
|
994
859
|
export const gmailCreateDraftInputSchema = gmailSendEmailInputSchema.extend({
|
|
995
860
|
thread_id: z.string().nullable().optional().describe("Gmail Thread ID (numeric string from the email event, NOT the Message-ID header). Omit for new drafts.")
|
|
996
861
|
});
|
|
997
|
-
export const confluenceQueryPageInputSchema = z.object({
|
|
998
|
-
integrationId: z.string().describe("The integration ID of the Atlassian/Confluence integration to use."),
|
|
999
|
-
pageId: z.string().describe("The Confluence page ID to query.")
|
|
1000
|
-
});
|
|
1001
|
-
export const confluenceAddCommentInputSchema = z.object({
|
|
1002
|
-
integrationId: z.string().describe("The integration ID of the Atlassian/Confluence integration to use."),
|
|
1003
|
-
pageId: z.string().describe("The Confluence page ID to add a comment to."),
|
|
1004
|
-
comment_text: z.string().describe("The text content of the comment to add."),
|
|
1005
|
-
text_to_comment_on: z
|
|
1006
|
-
.string()
|
|
1007
|
-
.nullable()
|
|
1008
|
-
.optional()
|
|
1009
|
-
.describe("Optional: The specific text in the page that this comment refers to. If provided, the tool will try to find this text and attach the comment to it. If not provided, you must specify start_position and end_position."),
|
|
1010
|
-
start_position: z
|
|
1011
|
-
.number()
|
|
1012
|
-
.int()
|
|
1013
|
-
.nullable()
|
|
1014
|
-
.optional()
|
|
1015
|
-
.describe("Optional: The start character position (offset) in the page storage format where the comment should be attached. Required if text_to_comment_on is not provided."),
|
|
1016
|
-
end_position: z
|
|
1017
|
-
.number()
|
|
1018
|
-
.int()
|
|
1019
|
-
.nullable()
|
|
1020
|
-
.optional()
|
|
1021
|
-
.describe("Optional: The end character position (offset) in the page storage format where the comment should be attached. Required if text_to_comment_on is not provided.")
|
|
1022
|
-
});
|
|
1023
862
|
export const searchPosthogSessionsInputSchema = z.object({
|
|
1024
863
|
integrationId: z.string().describe("The integration ID of the PostHog skill to use."),
|
|
1025
864
|
projectId: z.string().describe("The PostHog project ID."),
|
|
@@ -1210,34 +1049,6 @@ export const slackReadConversationTool = defineTool({
|
|
|
1210
1049
|
nextCursor: z.string().nullable()
|
|
1211
1050
|
})
|
|
1212
1051
|
});
|
|
1213
|
-
export const jiraCreateTicketTool = defineTool({
|
|
1214
|
-
name: "jira_create_ticket",
|
|
1215
|
-
inputSchema: jiraCreateTicketInputSchema,
|
|
1216
|
-
outputSchema: toolOutputBaseSchema.extend({
|
|
1217
|
-
issue: jiraIssueSummarySchema
|
|
1218
|
-
})
|
|
1219
|
-
});
|
|
1220
|
-
export const jiraUpdateTicketTool = defineTool({
|
|
1221
|
-
name: "jira_update_ticket",
|
|
1222
|
-
inputSchema: jiraUpdateTicketInputSchema,
|
|
1223
|
-
outputSchema: toolOutputBaseSchema.extend({
|
|
1224
|
-
issue: jiraIssueSummarySchema,
|
|
1225
|
-
updatedFields: z.array(z.string())
|
|
1226
|
-
})
|
|
1227
|
-
});
|
|
1228
|
-
export const jiraSearchTicketTool = defineTool({
|
|
1229
|
-
name: "jira_search_ticket",
|
|
1230
|
-
inputSchema: jiraSearchTicketInputSchema,
|
|
1231
|
-
outputSchema: toolOutputBaseSchema.extend({
|
|
1232
|
-
issues: z.array(jiraIssueSummarySchema),
|
|
1233
|
-
count: z.number().int(),
|
|
1234
|
-
total: z.number().int(),
|
|
1235
|
-
maxResults: z.number().int(),
|
|
1236
|
-
isLast: z.boolean(),
|
|
1237
|
-
nextPageToken: z.string().optional(),
|
|
1238
|
-
jql: z.string()
|
|
1239
|
-
})
|
|
1240
|
-
});
|
|
1241
1052
|
export const searchGitHubCodeTool = defineTool({
|
|
1242
1053
|
name: "searchGitHubCode",
|
|
1243
1054
|
inputSchema: searchGitHubCodeInputSchema,
|
|
@@ -1403,22 +1214,6 @@ export const gmailCreateDraftTool = defineTool({
|
|
|
1403
1214
|
inputSchema: gmailCreateDraftInputSchema,
|
|
1404
1215
|
outputSchema: toolOutputSuccessSchema.merge(gmailDraftSummarySchema)
|
|
1405
1216
|
});
|
|
1406
|
-
export const confluenceQueryPageTool = defineTool({
|
|
1407
|
-
name: "confluence_query_page",
|
|
1408
|
-
inputSchema: confluenceQueryPageInputSchema,
|
|
1409
|
-
outputSchema: toolOutputSuccessSchema.merge(confluencePageQueryResultSchema)
|
|
1410
|
-
});
|
|
1411
|
-
export const confluenceAddCommentTool = defineTool({
|
|
1412
|
-
name: "confluence_add_comment",
|
|
1413
|
-
inputSchema: confluenceAddCommentInputSchema,
|
|
1414
|
-
outputSchema: toolOutputSuccessSchema.extend({
|
|
1415
|
-
comment_id: z.string(),
|
|
1416
|
-
comment_text: z.string(),
|
|
1417
|
-
position: confluenceCommentPositionSchema,
|
|
1418
|
-
text_commented_on: z.string().optional(),
|
|
1419
|
-
message: z.string()
|
|
1420
|
-
})
|
|
1421
|
-
});
|
|
1422
1217
|
export const searchPosthogSessionsTool = defineTool({
|
|
1423
1218
|
name: "searchPosthogSessions",
|
|
1424
1219
|
inputSchema: searchPosthogSessionsInputSchema,
|
|
@@ -2050,9 +1845,6 @@ export const ToolDefinitions = {
|
|
|
2050
1845
|
[slackListChannelsTool.name]: slackListChannelsTool,
|
|
2051
1846
|
[slackListUsersTool.name]: slackListUsersTool,
|
|
2052
1847
|
[slackReadConversationTool.name]: slackReadConversationTool,
|
|
2053
|
-
[jiraCreateTicketTool.name]: jiraCreateTicketTool,
|
|
2054
|
-
[jiraUpdateTicketTool.name]: jiraUpdateTicketTool,
|
|
2055
|
-
[jiraSearchTicketTool.name]: jiraSearchTicketTool,
|
|
2056
1848
|
[searchGitHubCodeTool.name]: searchGitHubCodeTool,
|
|
2057
1849
|
[grepGitHubCodeTool.name]: grepGitHubCodeTool,
|
|
2058
1850
|
[readGitHubFileTool.name]: readGitHubFileTool,
|
|
@@ -2070,8 +1862,6 @@ export const ToolDefinitions = {
|
|
|
2070
1862
|
[notionListUsersTool.name]: notionListUsersTool,
|
|
2071
1863
|
[gmailSendEmailTool.name]: gmailSendEmailTool,
|
|
2072
1864
|
[gmailCreateDraftTool.name]: gmailCreateDraftTool,
|
|
2073
|
-
[confluenceQueryPageTool.name]: confluenceQueryPageTool,
|
|
2074
|
-
[confluenceAddCommentTool.name]: confluenceAddCommentTool,
|
|
2075
1865
|
[searchPosthogSessionsTool.name]: searchPosthogSessionsTool,
|
|
2076
1866
|
[searchPosthogLogsTool.name]: searchPosthogLogsTool,
|
|
2077
1867
|
[getPosthogSessionEventsTool.name]: getPosthogSessionEventsTool,
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { IntegrationType } from "./Integrations.js";
|
|
2
|
+
const TriggerPresenters = {
|
|
3
|
+
manual_sample: {
|
|
4
|
+
formatForAgent: (event) => `Manual sample event for ${event.integrationType}.`,
|
|
5
|
+
debug: (event) => `${event.integrationType} ${event.eventType}`
|
|
6
|
+
},
|
|
7
|
+
[IntegrationType.GITHUB]: {
|
|
8
|
+
formatForAgent: formatGithubTrigger,
|
|
9
|
+
debug: (event) => `GitHub Event: ${event.eventType} - ${event.repository.owner}/${event.repository.name} - ${event.sender.login}`
|
|
10
|
+
},
|
|
11
|
+
[IntegrationType.SLACK]: {
|
|
12
|
+
formatForAgent: formatSlackTrigger,
|
|
13
|
+
debug: (event) => {
|
|
14
|
+
const isDM = event.channelType === "im";
|
|
15
|
+
return `Slack Event: ${event.eventType} - ${isDM ? "DM" : event.channelName || event.channelId} - ${event.userName || event.userId}`;
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
[IntegrationType.GMAIL]: {
|
|
19
|
+
formatForAgent: formatGmailTrigger,
|
|
20
|
+
debug: (event) => `Gmail Event: ${event.subject} message ID: ${event.messageId}`
|
|
21
|
+
},
|
|
22
|
+
[IntegrationType.LINEAR]: {
|
|
23
|
+
formatForAgent: formatLinearTrigger,
|
|
24
|
+
debug: (event) => {
|
|
25
|
+
if (event.type === "Issue") {
|
|
26
|
+
return `Linear ${event.type} Event: ${event.data.identifier} - ${event.data.title} (${event.action})`;
|
|
27
|
+
}
|
|
28
|
+
return `Linear ${event.type} Event: Comment on issue ${event.data.issueId || "Unknown"} (${event.action})`;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
[IntegrationType.WORKOS]: {
|
|
32
|
+
formatForAgent: formatWorkOSTrigger,
|
|
33
|
+
debug: (event) => `WorkOS ${event.eventType}`
|
|
34
|
+
},
|
|
35
|
+
[IntegrationType.WEBHOOK]: {
|
|
36
|
+
formatForAgent: formatWebhookTrigger,
|
|
37
|
+
debug: (event) => `Webhook Trigger (${event.method})`
|
|
38
|
+
},
|
|
39
|
+
[IntegrationType.CRON_JOB]: {
|
|
40
|
+
formatForAgent: formatCronTrigger,
|
|
41
|
+
debug: (event) => (event.isManualTrigger ? "Manual Trigger" : "Scheduled Event")
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
function dispatchPresenter(event, method) {
|
|
45
|
+
switch (event.integrationType) {
|
|
46
|
+
case IntegrationType.GITHUB:
|
|
47
|
+
return TriggerPresenters[IntegrationType.GITHUB][method](event);
|
|
48
|
+
case IntegrationType.SLACK:
|
|
49
|
+
return TriggerPresenters[IntegrationType.SLACK][method](event);
|
|
50
|
+
case IntegrationType.GMAIL:
|
|
51
|
+
return TriggerPresenters[IntegrationType.GMAIL][method](event);
|
|
52
|
+
case IntegrationType.LINEAR:
|
|
53
|
+
return TriggerPresenters[IntegrationType.LINEAR][method](event);
|
|
54
|
+
case IntegrationType.WORKOS:
|
|
55
|
+
return TriggerPresenters[IntegrationType.WORKOS][method](event);
|
|
56
|
+
case IntegrationType.WEBHOOK:
|
|
57
|
+
return TriggerPresenters[IntegrationType.WEBHOOK][method](event);
|
|
58
|
+
case IntegrationType.CRON_JOB:
|
|
59
|
+
return TriggerPresenters[IntegrationType.CRON_JOB][method](event);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function formatTriggerForAgent(event) {
|
|
63
|
+
if (event.eventType === "manual_sample") {
|
|
64
|
+
return TriggerPresenters.manual_sample.formatForAgent(event);
|
|
65
|
+
}
|
|
66
|
+
return dispatchPresenter(event, "formatForAgent");
|
|
67
|
+
}
|
|
68
|
+
export function debugTrigger(event) {
|
|
69
|
+
if (event.eventType === "manual_sample") {
|
|
70
|
+
return TriggerPresenters.manual_sample.debug(event);
|
|
71
|
+
}
|
|
72
|
+
return dispatchPresenter(event, "debug");
|
|
73
|
+
}
|
|
74
|
+
function formatGithubTrigger(event) {
|
|
75
|
+
const indentMultiline = (text) => text
|
|
76
|
+
.split("\n")
|
|
77
|
+
.map(line => ` ${line}`)
|
|
78
|
+
.join("\n");
|
|
79
|
+
const eventTypeDescriptions = {
|
|
80
|
+
push: "Code Push Event",
|
|
81
|
+
"pull_request.opened": "Pull Request Opened",
|
|
82
|
+
"pull_request.synchronize": "Pull Request Updated (new commits added)",
|
|
83
|
+
"pull_request.closed": "Pull Request Closed",
|
|
84
|
+
"pull_request.merged": "Pull Request Merged"
|
|
85
|
+
};
|
|
86
|
+
const eventDescription = eventTypeDescriptions[event.eventType] || event.eventType;
|
|
87
|
+
const repoInfo = [
|
|
88
|
+
`Repository: ${event.repository.owner}/${event.repository.name}`,
|
|
89
|
+
`Repository ID: ${event.repository.id}`,
|
|
90
|
+
`Default Branch: ${event.repository.defaultBranch}`,
|
|
91
|
+
`View on GitHub: https://github.com/${event.repository.owner}/${event.repository.name}`
|
|
92
|
+
].join("\n");
|
|
93
|
+
const senderInfo = [`Actor: ${event.sender.login}`, ...(event.sender.email ? [`Email: ${event.sender.email}`] : [])].join("\n");
|
|
94
|
+
const branchInfo = event.branch ? `Branch: ${event.branch}` : null;
|
|
95
|
+
let prInfo = "";
|
|
96
|
+
if (event.pullRequest) {
|
|
97
|
+
const pr = event.pullRequest;
|
|
98
|
+
const author = pr.author ?? pr.user;
|
|
99
|
+
const prLines = [
|
|
100
|
+
`Pull Request #${pr.number}: ${pr.title}`,
|
|
101
|
+
`State: ${pr.state}${pr.merged ? " (merged)" : ""}`,
|
|
102
|
+
`Author: ${author.login}${author.email ? ` (${author.email})` : ""}`,
|
|
103
|
+
`Head Branch: ${pr.head.ref} (${pr.head.sha.substring(0, 7)})`,
|
|
104
|
+
`Base Branch: ${pr.base.ref} (${pr.base.sha.substring(0, 7)})`,
|
|
105
|
+
`View PR: ${pr.url}`
|
|
106
|
+
];
|
|
107
|
+
if (pr.body) {
|
|
108
|
+
prLines.push(`\nDescription:\n${indentMultiline(pr.body)}`);
|
|
109
|
+
}
|
|
110
|
+
prInfo = prLines.join("\n");
|
|
111
|
+
}
|
|
112
|
+
let commitsInfo = "";
|
|
113
|
+
if (event.commits.length > 0) {
|
|
114
|
+
const commitLines = [];
|
|
115
|
+
commitLines.push(`Commits (${event.commits.length}):`);
|
|
116
|
+
event.commits.forEach((commit, index) => {
|
|
117
|
+
const shortSha = commit.sha.substring(0, 7);
|
|
118
|
+
const commitUrl = `https://github.com/${event.repository.owner}/${event.repository.name}/commit/${commit.sha}`;
|
|
119
|
+
commitLines.push(`\n${index + 1}. Commit ${shortSha}: ${commit.message || commit.name || ""}`);
|
|
120
|
+
commitLines.push(` URL: ${commitUrl}`);
|
|
121
|
+
if (commit.fileDiffs.length > 0) {
|
|
122
|
+
commitLines.push(` Files Changed: ${commit.fileDiffs.length}`);
|
|
123
|
+
const fileList = commit.fileDiffs.map(f => ` - ${f.filename}`).join("\n");
|
|
124
|
+
commitLines.push(` Files:\n${fileList}`);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
commitsInfo = commitLines.join("\n");
|
|
128
|
+
}
|
|
129
|
+
return [
|
|
130
|
+
`Incoming GitHub Event: ${eventDescription}`,
|
|
131
|
+
`\nRepository Information:\n${indentMultiline(repoInfo)}`,
|
|
132
|
+
`\nActor Information:\n${indentMultiline(senderInfo)}`,
|
|
133
|
+
...(branchInfo ? [`\nBranch Information:\n${indentMultiline(branchInfo)}`] : []),
|
|
134
|
+
...(prInfo ? [`\nPull Request Information:\n${indentMultiline(prInfo)}`] : []),
|
|
135
|
+
...(commitsInfo ? [`\n${commitsInfo}`] : [])
|
|
136
|
+
].join("\n\n");
|
|
137
|
+
}
|
|
138
|
+
function formatSlackTrigger(event) {
|
|
139
|
+
const blockContent = JSON.stringify(event.blocks);
|
|
140
|
+
const attachmentContent = JSON.stringify(event.attachments);
|
|
141
|
+
const messageText = event.text || "(no plain text)";
|
|
142
|
+
const threadTs = event.threadTs ?? event.threadTimestamp ?? null;
|
|
143
|
+
const eventLabel = event.eventType === "app_mention" ? "Incoming Slack App Mention Event." : event.eventType === "reaction_added" ? "Incoming Slack Reaction Added Event." : "Incoming Slack Message Event.";
|
|
144
|
+
const reactionInfo = event.eventType === "reaction_added"
|
|
145
|
+
? `Reaction: ${event.reaction || "unknown"}\n Target Message Timestamp: ${event.itemTimestamp || "unknown"}\n Target User: ${event.itemUserId || "unknown"}`
|
|
146
|
+
: "";
|
|
147
|
+
return `
|
|
148
|
+
${eventLabel}
|
|
149
|
+
|
|
150
|
+
Slack Event:
|
|
151
|
+
Event Type: ${event.eventType}
|
|
152
|
+
Channel: ${event.channelName || event.channelId}
|
|
153
|
+
User: ${event.userName || event.userId}
|
|
154
|
+
Message: ${messageText}
|
|
155
|
+
Timestamp: ${event.timestamp}
|
|
156
|
+
${threadTs ? `Thread: ${threadTs}` : ""}
|
|
157
|
+
Team ID: ${event.teamId}
|
|
158
|
+
${reactionInfo}
|
|
159
|
+
${blockContent
|
|
160
|
+
? `
|
|
161
|
+
Rich Content (from blocks):
|
|
162
|
+
${blockContent}`
|
|
163
|
+
: ""}
|
|
164
|
+
${attachmentContent
|
|
165
|
+
? `
|
|
166
|
+
Attachment Content:
|
|
167
|
+
${attachmentContent}`
|
|
168
|
+
: ""}
|
|
169
|
+
`;
|
|
170
|
+
}
|
|
171
|
+
function formatGmailTrigger(event) {
|
|
172
|
+
const attachmentInfo = event.attachments?.map(attachment => `- ${attachment.filename} ${attachment.isInline ? "Inline" : "Attachment"} (${attachment.mimeType})`).join("\n") || "No attachments";
|
|
173
|
+
return `
|
|
174
|
+
Incoming Email Event.
|
|
175
|
+
|
|
176
|
+
Gmail Event:
|
|
177
|
+
Subject: ${event.subject}
|
|
178
|
+
From: ${event.from}
|
|
179
|
+
To: ${event.to}
|
|
180
|
+
Date: ${event.date}
|
|
181
|
+
Message ID: ${event.messageId}
|
|
182
|
+
Thread ID: ${event.threadId}
|
|
183
|
+
Body: ${event.body}
|
|
184
|
+
Snippet: ${event.snippet}
|
|
185
|
+
Attachments (if any listed, actual files should be added below):
|
|
186
|
+
${attachmentInfo}
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
function formatLinearTrigger(event) {
|
|
190
|
+
const indentMultiline = (text) => text
|
|
191
|
+
.split("\n")
|
|
192
|
+
.map(line => ` ${line}`)
|
|
193
|
+
.join("\n");
|
|
194
|
+
const sections = [];
|
|
195
|
+
sections.push(`Incoming Linear ${event.type} Event`);
|
|
196
|
+
sections.push(`Action: ${event.action}`);
|
|
197
|
+
sections.push(`Actor: ${event.actor.name} (${event.actor.email})`);
|
|
198
|
+
sections.push(`Created: ${event.createdAt}`);
|
|
199
|
+
if (event.type === "Issue" && event.data) {
|
|
200
|
+
const issue = event.data;
|
|
201
|
+
const issueSections = [];
|
|
202
|
+
issueSections.push(`Issue: ${issue.identifier} - ${issue.title}`);
|
|
203
|
+
if (issue.description)
|
|
204
|
+
issueSections.push(`Description:\n${indentMultiline(issue.description)}`);
|
|
205
|
+
issueSections.push(`Priority: ${issue.priorityLabel || issue.priority}`);
|
|
206
|
+
issueSections.push(`State: ${issue.state?.name || "Unknown"}`);
|
|
207
|
+
issueSections.push(`Team: ${issue.team?.name || "Unknown"}`);
|
|
208
|
+
if (issue.assignee)
|
|
209
|
+
issueSections.push(`Assignee: ${issue.assignee.name}`);
|
|
210
|
+
if (issue.labels?.length)
|
|
211
|
+
issueSections.push(`Labels: ${issue.labels.map((label) => label.name || label).join(", ")}`);
|
|
212
|
+
if (issue.url)
|
|
213
|
+
issueSections.push(`URL: ${issue.url}`);
|
|
214
|
+
sections.push(issueSections.join("\n"));
|
|
215
|
+
}
|
|
216
|
+
else if (event.type === "Comment" && event.data) {
|
|
217
|
+
const commentSections = [`Comment on Issue: ${event.data.issueId || "Unknown"}`];
|
|
218
|
+
if (event.data.body)
|
|
219
|
+
commentSections.push(`Comment:\n${indentMultiline(event.data.body)}`);
|
|
220
|
+
sections.push(commentSections.join("\n"));
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
sections.push(`Event Data:\n${indentMultiline(JSON.stringify(event.data, null, 2))}`);
|
|
224
|
+
}
|
|
225
|
+
if (event.organizationId) {
|
|
226
|
+
sections.push(`Organization ID: ${event.organizationId}`);
|
|
227
|
+
}
|
|
228
|
+
return sections.join("\n\n");
|
|
229
|
+
}
|
|
230
|
+
function formatWorkOSTrigger(event) {
|
|
231
|
+
const parts = [`WorkOS Event: ${event.eventType}`];
|
|
232
|
+
if ("user" in event && event.user) {
|
|
233
|
+
parts.push(`User Email: ${event.user.email}`);
|
|
234
|
+
if (event.user.firstName || event.user.lastName) {
|
|
235
|
+
parts.push(`User Name: ${[event.user.firstName, event.user.lastName].filter(Boolean).join(" ")}`);
|
|
236
|
+
}
|
|
237
|
+
parts.push(`User ID: ${event.user.id}`);
|
|
238
|
+
}
|
|
239
|
+
parts.push(`\nFull Event Data:\n${JSON.stringify(event, null, 2)}`);
|
|
240
|
+
return parts.join("\n");
|
|
241
|
+
}
|
|
242
|
+
function formatWebhookTrigger(event) {
|
|
243
|
+
return `Webhook request received.\n\nMethod: ${event.method}\n\nPayload:\n${JSON.stringify(event.body, null, 2)}`;
|
|
244
|
+
}
|
|
245
|
+
function formatCronTrigger(event) {
|
|
246
|
+
if (event.isManualTrigger) {
|
|
247
|
+
let message = `This is a manually triggered event for the channel input ${event.inputId}.`;
|
|
248
|
+
if (event.manualContext) {
|
|
249
|
+
message += `\n\nUser provided context for this manual trigger:\n${event.manualContext}`;
|
|
250
|
+
}
|
|
251
|
+
return message;
|
|
252
|
+
}
|
|
253
|
+
return `This is a scheduled event for the channel input ${event.inputId}. The channel input is configured to run at the following cron expression.`;
|
|
254
|
+
}
|