terse-types 0.0.18 → 0.0.19
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/SandboxTypes.d.ts +15 -0
- package/dist/SandboxTypes.js +1 -0
- package/dist/TriggerEventPresenters.d.ts +3 -0
- package/dist/TriggerEventPresenters.js +238 -0
- package/dist/TriggerEvents.d.ts +4054 -0
- package/dist/TriggerEvents.js +437 -0
- package/dist/json-schema/terse-types.schema.json +66 -234
- package/dist/types.d.ts +1 -0
- package/dist/types.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type SandboxLogEntry = {
|
|
2
|
+
stream: "stdout" | "stderr";
|
|
3
|
+
text: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
};
|
|
6
|
+
export type SandboxLogPayload = SandboxLogEntry & {
|
|
7
|
+
runId: string;
|
|
8
|
+
agentId: string;
|
|
9
|
+
};
|
|
10
|
+
export type SandboxLogsResponse = {
|
|
11
|
+
sandboxId: string | null;
|
|
12
|
+
entries: SandboxLogEntry[];
|
|
13
|
+
timestamp: number;
|
|
14
|
+
error?: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,238 @@
|
|
|
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
|
+
export function formatTriggerForAgent(event) {
|
|
45
|
+
if (event.eventType === "manual_sample") {
|
|
46
|
+
return TriggerPresenters.manual_sample.formatForAgent(event);
|
|
47
|
+
}
|
|
48
|
+
const presenter = TriggerPresenters[event.integrationType];
|
|
49
|
+
return presenter.formatForAgent(event);
|
|
50
|
+
}
|
|
51
|
+
export function debugTrigger(event) {
|
|
52
|
+
if (event.eventType === "manual_sample") {
|
|
53
|
+
return TriggerPresenters.manual_sample.debug(event);
|
|
54
|
+
}
|
|
55
|
+
const presenter = TriggerPresenters[event.integrationType];
|
|
56
|
+
return presenter.debug(event);
|
|
57
|
+
}
|
|
58
|
+
function formatGithubTrigger(event) {
|
|
59
|
+
const indentMultiline = (text) => text
|
|
60
|
+
.split("\n")
|
|
61
|
+
.map(line => ` ${line}`)
|
|
62
|
+
.join("\n");
|
|
63
|
+
const eventTypeDescriptions = {
|
|
64
|
+
push: "Code Push Event",
|
|
65
|
+
"pull_request.opened": "Pull Request Opened",
|
|
66
|
+
"pull_request.synchronize": "Pull Request Updated (new commits added)",
|
|
67
|
+
"pull_request.closed": "Pull Request Closed",
|
|
68
|
+
"pull_request.merged": "Pull Request Merged"
|
|
69
|
+
};
|
|
70
|
+
const eventDescription = eventTypeDescriptions[event.eventType] || event.eventType;
|
|
71
|
+
const repoInfo = [
|
|
72
|
+
`Repository: ${event.repository.owner}/${event.repository.name}`,
|
|
73
|
+
`Repository ID: ${event.repository.id}`,
|
|
74
|
+
`Default Branch: ${event.repository.defaultBranch}`,
|
|
75
|
+
`View on GitHub: https://github.com/${event.repository.owner}/${event.repository.name}`
|
|
76
|
+
].join("\n");
|
|
77
|
+
const senderInfo = [`Actor: ${event.sender.login}`, ...(event.sender.email ? [`Email: ${event.sender.email}`] : [])].join("\n");
|
|
78
|
+
const branchInfo = event.branch ? `Branch: ${event.branch}` : null;
|
|
79
|
+
let prInfo = "";
|
|
80
|
+
if (event.pullRequest) {
|
|
81
|
+
const pr = event.pullRequest;
|
|
82
|
+
const author = pr.author ?? pr.user;
|
|
83
|
+
const prLines = [
|
|
84
|
+
`Pull Request #${pr.number}: ${pr.title}`,
|
|
85
|
+
`State: ${pr.state}${pr.merged ? " (merged)" : ""}`,
|
|
86
|
+
`Author: ${author.login}${author.email ? ` (${author.email})` : ""}`,
|
|
87
|
+
`Head Branch: ${pr.head.ref} (${pr.head.sha.substring(0, 7)})`,
|
|
88
|
+
`Base Branch: ${pr.base.ref} (${pr.base.sha.substring(0, 7)})`,
|
|
89
|
+
`View PR: ${pr.url}`
|
|
90
|
+
];
|
|
91
|
+
if (pr.body) {
|
|
92
|
+
prLines.push(`\nDescription:\n${indentMultiline(pr.body)}`);
|
|
93
|
+
}
|
|
94
|
+
prInfo = prLines.join("\n");
|
|
95
|
+
}
|
|
96
|
+
let commitsInfo = "";
|
|
97
|
+
if (event.commits.length > 0) {
|
|
98
|
+
const commitLines = [];
|
|
99
|
+
commitLines.push(`Commits (${event.commits.length}):`);
|
|
100
|
+
event.commits.forEach((commit, index) => {
|
|
101
|
+
const shortSha = commit.sha.substring(0, 7);
|
|
102
|
+
const commitUrl = `https://github.com/${event.repository.owner}/${event.repository.name}/commit/${commit.sha}`;
|
|
103
|
+
commitLines.push(`\n${index + 1}. Commit ${shortSha}: ${commit.message || commit.name || ""}`);
|
|
104
|
+
commitLines.push(` URL: ${commitUrl}`);
|
|
105
|
+
if (commit.fileDiffs.length > 0) {
|
|
106
|
+
commitLines.push(` Files Changed: ${commit.fileDiffs.length}`);
|
|
107
|
+
const fileList = commit.fileDiffs.map(f => ` - ${f.filename}`).join("\n");
|
|
108
|
+
commitLines.push(` Files:\n${fileList}`);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
commitsInfo = commitLines.join("\n");
|
|
112
|
+
}
|
|
113
|
+
return [
|
|
114
|
+
`Incoming GitHub Event: ${eventDescription}`,
|
|
115
|
+
`\nRepository Information:\n${indentMultiline(repoInfo)}`,
|
|
116
|
+
`\nActor Information:\n${indentMultiline(senderInfo)}`,
|
|
117
|
+
...(branchInfo ? [`\nBranch Information:\n${indentMultiline(branchInfo)}`] : []),
|
|
118
|
+
...(prInfo ? [`\nPull Request Information:\n${indentMultiline(prInfo)}`] : []),
|
|
119
|
+
...(commitsInfo ? [`\n${commitsInfo}`] : [])
|
|
120
|
+
].join("\n\n");
|
|
121
|
+
}
|
|
122
|
+
function formatSlackTrigger(event) {
|
|
123
|
+
const blockContent = JSON.stringify(event.blocks);
|
|
124
|
+
const attachmentContent = JSON.stringify(event.attachments);
|
|
125
|
+
const messageText = event.text || "(no plain text)";
|
|
126
|
+
const threadTs = event.threadTs ?? event.threadTimestamp ?? null;
|
|
127
|
+
const eventLabel = event.eventType === "app_mention" ? "Incoming Slack App Mention Event." : event.eventType === "reaction_added" ? "Incoming Slack Reaction Added Event." : "Incoming Slack Message Event.";
|
|
128
|
+
const reactionInfo = event.eventType === "reaction_added"
|
|
129
|
+
? `Reaction: ${event.reaction || "unknown"}\n Target Message Timestamp: ${event.itemTimestamp || "unknown"}\n Target User: ${event.itemUserId || "unknown"}`
|
|
130
|
+
: "";
|
|
131
|
+
return `
|
|
132
|
+
${eventLabel}
|
|
133
|
+
|
|
134
|
+
Slack Event:
|
|
135
|
+
Event Type: ${event.eventType}
|
|
136
|
+
Channel: ${event.channelName || event.channelId}
|
|
137
|
+
User: ${event.userName || event.userId}
|
|
138
|
+
Message: ${messageText}
|
|
139
|
+
Timestamp: ${event.timestamp}
|
|
140
|
+
${threadTs ? `Thread: ${threadTs}` : ""}
|
|
141
|
+
Team ID: ${event.teamId}
|
|
142
|
+
${reactionInfo}
|
|
143
|
+
${blockContent
|
|
144
|
+
? `
|
|
145
|
+
Rich Content (from blocks):
|
|
146
|
+
${blockContent}`
|
|
147
|
+
: ""}
|
|
148
|
+
${attachmentContent
|
|
149
|
+
? `
|
|
150
|
+
Attachment Content:
|
|
151
|
+
${attachmentContent}`
|
|
152
|
+
: ""}
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
function formatGmailTrigger(event) {
|
|
156
|
+
const attachmentInfo = event.attachments?.map(attachment => `- ${attachment.filename} ${attachment.isInline ? "Inline" : "Attachment"} (${attachment.mimeType})`).join("\n") || "No attachments";
|
|
157
|
+
return `
|
|
158
|
+
Incoming Email Event.
|
|
159
|
+
|
|
160
|
+
Gmail Event:
|
|
161
|
+
Subject: ${event.subject}
|
|
162
|
+
From: ${event.from}
|
|
163
|
+
To: ${event.to}
|
|
164
|
+
Date: ${event.date}
|
|
165
|
+
Message ID: ${event.messageId}
|
|
166
|
+
Thread ID: ${event.threadId}
|
|
167
|
+
Body: ${event.body}
|
|
168
|
+
Snippet: ${event.snippet}
|
|
169
|
+
Attachments (if any listed, actual files should be added below):
|
|
170
|
+
${attachmentInfo}
|
|
171
|
+
`;
|
|
172
|
+
}
|
|
173
|
+
function formatLinearTrigger(event) {
|
|
174
|
+
const indentMultiline = (text) => text
|
|
175
|
+
.split("\n")
|
|
176
|
+
.map(line => ` ${line}`)
|
|
177
|
+
.join("\n");
|
|
178
|
+
const sections = [];
|
|
179
|
+
sections.push(`Incoming Linear ${event.type} Event`);
|
|
180
|
+
sections.push(`Action: ${event.action}`);
|
|
181
|
+
sections.push(`Actor: ${event.actor.name} (${event.actor.email})`);
|
|
182
|
+
sections.push(`Created: ${event.createdAt}`);
|
|
183
|
+
if (event.type === "Issue" && event.data) {
|
|
184
|
+
const issue = event.data;
|
|
185
|
+
const issueSections = [];
|
|
186
|
+
issueSections.push(`Issue: ${issue.identifier} - ${issue.title}`);
|
|
187
|
+
if (issue.description)
|
|
188
|
+
issueSections.push(`Description:\n${indentMultiline(issue.description)}`);
|
|
189
|
+
issueSections.push(`Priority: ${issue.priorityLabel || issue.priority}`);
|
|
190
|
+
issueSections.push(`State: ${issue.state?.name || "Unknown"}`);
|
|
191
|
+
issueSections.push(`Team: ${issue.team?.name || "Unknown"}`);
|
|
192
|
+
if (issue.assignee)
|
|
193
|
+
issueSections.push(`Assignee: ${issue.assignee.name}`);
|
|
194
|
+
if (issue.labels?.length)
|
|
195
|
+
issueSections.push(`Labels: ${issue.labels.map((label) => label.name || label).join(", ")}`);
|
|
196
|
+
if (issue.url)
|
|
197
|
+
issueSections.push(`URL: ${issue.url}`);
|
|
198
|
+
sections.push(issueSections.join("\n"));
|
|
199
|
+
}
|
|
200
|
+
else if (event.type === "Comment" && event.data) {
|
|
201
|
+
const commentSections = [`Comment on Issue: ${event.data.issueId || "Unknown"}`];
|
|
202
|
+
if (event.data.body)
|
|
203
|
+
commentSections.push(`Comment:\n${indentMultiline(event.data.body)}`);
|
|
204
|
+
sections.push(commentSections.join("\n"));
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
sections.push(`Event Data:\n${indentMultiline(JSON.stringify(event.data, null, 2))}`);
|
|
208
|
+
}
|
|
209
|
+
if (event.organizationId) {
|
|
210
|
+
sections.push(`Organization ID: ${event.organizationId}`);
|
|
211
|
+
}
|
|
212
|
+
return sections.join("\n\n");
|
|
213
|
+
}
|
|
214
|
+
function formatWorkOSTrigger(event) {
|
|
215
|
+
const parts = [`WorkOS Event: ${event.eventType}`];
|
|
216
|
+
if ("user" in event && event.user) {
|
|
217
|
+
parts.push(`User Email: ${event.user.email}`);
|
|
218
|
+
if (event.user.firstName || event.user.lastName) {
|
|
219
|
+
parts.push(`User Name: ${[event.user.firstName, event.user.lastName].filter(Boolean).join(" ")}`);
|
|
220
|
+
}
|
|
221
|
+
parts.push(`User ID: ${event.user.id}`);
|
|
222
|
+
}
|
|
223
|
+
parts.push(`\nFull Event Data:\n${JSON.stringify(event, null, 2)}`);
|
|
224
|
+
return parts.join("\n");
|
|
225
|
+
}
|
|
226
|
+
function formatWebhookTrigger(event) {
|
|
227
|
+
return `Webhook request received.\n\nMethod: ${event.method}\n\nPayload:\n${JSON.stringify(event.body, null, 2)}`;
|
|
228
|
+
}
|
|
229
|
+
function formatCronTrigger(event) {
|
|
230
|
+
if (event.isManualTrigger) {
|
|
231
|
+
let message = `This is a manually triggered event for the channel input ${event.inputId}.`;
|
|
232
|
+
if (event.manualContext) {
|
|
233
|
+
message += `\n\nUser provided context for this manual trigger:\n${event.manualContext}`;
|
|
234
|
+
}
|
|
235
|
+
return message;
|
|
236
|
+
}
|
|
237
|
+
return `This is a scheduled event for the channel input ${event.inputId}. The channel input is configured to run at the following cron expression.`;
|
|
238
|
+
}
|