@sentry/junior-google 0.302.0 → 0.304.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.
@@ -1,300 +0,0 @@
1
- import { type GoogleToolContext } from "./shared";
2
- /** Quote a value for a Drive search query. */
3
- export declare function driveQueryString(value: string): string;
4
- /** Drive search terms for files that name the requester in a permission. */
5
- export declare function namedQuery(requester: string): string;
6
- /**
7
- * Find Docs, Sheets, and Slides that the requester could find in Drive
8
- * themselves. Never search without the requester's terms.
9
- */
10
- export declare const searchGoogleFilesTool: import("@sentry/junior-plugin-api").PluginToolDefinition<{
11
- query: string;
12
- types?: ("document" | "presentation" | "spreadsheet")[] | undefined;
13
- max_results: number;
14
- }, {
15
- [x: string]: unknown;
16
- objectAnnotations?: {
17
- kind: "object";
18
- key: string;
19
- label: string;
20
- objectType: "automation" | "calendar_event" | "chart" | "code_change" | "conversation" | "deployment" | "document" | "event" | "item" | "message" | "person" | "task" | "trace" | "web_page";
21
- title: string;
22
- url: string | null;
23
- description?: string | undefined;
24
- status?: string | undefined;
25
- trigger?: string | undefined;
26
- warning?: string | undefined;
27
- displayType?: string | undefined;
28
- sourceUpdatedAt?: string | undefined;
29
- facts?: {
30
- type: "code_change";
31
- summary?: string | undefined;
32
- author?: string | undefined;
33
- sourceBranch?: string | undefined;
34
- targetBranch?: string | undefined;
35
- reviewers?: string[] | undefined;
36
- review?: "approved" | "changes_requested" | "required" | undefined;
37
- checks?: {
38
- passed: number;
39
- failed: number;
40
- pending: number;
41
- } | undefined;
42
- mergeable?: boolean | undefined;
43
- changedFiles?: number | undefined;
44
- additions?: number | undefined;
45
- deletions?: number | undefined;
46
- previewImageUrls?: string[] | undefined;
47
- } | {
48
- type: "task";
49
- summary?: string | undefined;
50
- assignees?: string[] | undefined;
51
- priority?: string | undefined;
52
- project?: string | undefined;
53
- cycle?: string | undefined;
54
- dueDate?: string | undefined;
55
- labels?: string[] | undefined;
56
- trend?: {
57
- label: string;
58
- points: number[];
59
- } | undefined;
60
- } | {
61
- type: "deployment";
62
- summary?: string | undefined;
63
- project?: string | undefined;
64
- environment?: string | undefined;
65
- revision?: string | undefined;
66
- branch?: string | undefined;
67
- } | {
68
- type: "calendar_event";
69
- summary?: string | undefined;
70
- when?: string | undefined;
71
- attendees?: string[] | undefined;
72
- } | {
73
- type: "conversation";
74
- summary?: string | undefined;
75
- participants?: string[] | undefined;
76
- lastActivityAt?: string | undefined;
77
- } | {
78
- type: "document";
79
- summary?: string | undefined;
80
- owner?: string | undefined;
81
- modifiedAt?: string | undefined;
82
- thumbnailUrl?: string | undefined;
83
- } | {
84
- type: "message";
85
- summary?: string | undefined;
86
- channel?: string | undefined;
87
- author?: string | undefined;
88
- sentAt?: string | undefined;
89
- } | {
90
- type: "web_page";
91
- summary?: string | undefined;
92
- siteName?: string | undefined;
93
- author?: string | undefined;
94
- media?: "image" | "video" | undefined;
95
- thumbnailUrl?: string | undefined;
96
- } | {
97
- type: "chart";
98
- summary?: string | undefined;
99
- display: "area" | "bar" | "line";
100
- yAxis: string;
101
- range: string;
102
- series: {
103
- label: string;
104
- points: number[];
105
- }[];
106
- } | {
107
- type: "event";
108
- summary?: string | undefined;
109
- level?: string | undefined;
110
- project?: string | undefined;
111
- release?: string | undefined;
112
- environment?: string | undefined;
113
- occurredAt?: string | undefined;
114
- } | {
115
- type: "trace";
116
- summary?: string | undefined;
117
- rootOp?: string | undefined;
118
- rootName?: string | undefined;
119
- durationMs: number;
120
- spanCount: number;
121
- errorCount: number;
122
- performanceIssueCount: number;
123
- projects: string[];
124
- spans: {
125
- op?: string | undefined;
126
- name: string;
127
- startMs: number;
128
- durationMs: number;
129
- issue?: boolean | undefined;
130
- }[];
131
- } | {
132
- type: "person";
133
- summary?: string | undefined;
134
- email?: string | undefined;
135
- slackHandle?: string | undefined;
136
- githubHandle?: string | undefined;
137
- avatarUrl?: string | undefined;
138
- } | undefined;
139
- }[] | undefined;
140
- reply?: {
141
- text: string;
142
- url?: string | undefined;
143
- } | undefined;
144
- continuation?: {
145
- arguments: Record<string, unknown>;
146
- reason?: string | undefined;
147
- } | undefined;
148
- target: "searchGoogleFiles";
149
- files: {
150
- file_id: string;
151
- modified_at?: string | undefined;
152
- title: string;
153
- type: "document" | "presentation" | "spreadsheet";
154
- url?: string | undefined;
155
- }[];
156
- truncated: boolean;
157
- }, {
158
- [x: string]: unknown;
159
- objectAnnotations?: {
160
- kind: "object";
161
- key: string;
162
- label: string;
163
- objectType: "automation" | "calendar_event" | "chart" | "code_change" | "conversation" | "deployment" | "document" | "event" | "item" | "message" | "person" | "task" | "trace" | "web_page";
164
- title: string;
165
- url: string | null;
166
- description?: string | undefined;
167
- status?: string | undefined;
168
- trigger?: string | undefined;
169
- warning?: string | undefined;
170
- displayType?: string | undefined;
171
- sourceUpdatedAt?: string | undefined;
172
- facts?: {
173
- type: "code_change";
174
- summary?: string | undefined;
175
- author?: string | undefined;
176
- sourceBranch?: string | undefined;
177
- targetBranch?: string | undefined;
178
- reviewers?: string[] | undefined;
179
- review?: "approved" | "changes_requested" | "required" | undefined;
180
- checks?: {
181
- passed: number;
182
- failed: number;
183
- pending: number;
184
- } | undefined;
185
- mergeable?: boolean | undefined;
186
- changedFiles?: number | undefined;
187
- additions?: number | undefined;
188
- deletions?: number | undefined;
189
- previewImageUrls?: string[] | undefined;
190
- } | {
191
- type: "task";
192
- summary?: string | undefined;
193
- assignees?: string[] | undefined;
194
- priority?: string | undefined;
195
- project?: string | undefined;
196
- cycle?: string | undefined;
197
- dueDate?: string | undefined;
198
- labels?: string[] | undefined;
199
- trend?: {
200
- label: string;
201
- points: number[];
202
- } | undefined;
203
- } | {
204
- type: "deployment";
205
- summary?: string | undefined;
206
- project?: string | undefined;
207
- environment?: string | undefined;
208
- revision?: string | undefined;
209
- branch?: string | undefined;
210
- } | {
211
- type: "calendar_event";
212
- summary?: string | undefined;
213
- when?: string | undefined;
214
- attendees?: string[] | undefined;
215
- } | {
216
- type: "conversation";
217
- summary?: string | undefined;
218
- participants?: string[] | undefined;
219
- lastActivityAt?: string | undefined;
220
- } | {
221
- type: "document";
222
- summary?: string | undefined;
223
- owner?: string | undefined;
224
- modifiedAt?: string | undefined;
225
- thumbnailUrl?: string | undefined;
226
- } | {
227
- type: "message";
228
- summary?: string | undefined;
229
- channel?: string | undefined;
230
- author?: string | undefined;
231
- sentAt?: string | undefined;
232
- } | {
233
- type: "web_page";
234
- summary?: string | undefined;
235
- siteName?: string | undefined;
236
- author?: string | undefined;
237
- media?: "image" | "video" | undefined;
238
- thumbnailUrl?: string | undefined;
239
- } | {
240
- type: "chart";
241
- summary?: string | undefined;
242
- display: "area" | "bar" | "line";
243
- yAxis: string;
244
- range: string;
245
- series: {
246
- label: string;
247
- points: number[];
248
- }[];
249
- } | {
250
- type: "event";
251
- summary?: string | undefined;
252
- level?: string | undefined;
253
- project?: string | undefined;
254
- release?: string | undefined;
255
- environment?: string | undefined;
256
- occurredAt?: string | undefined;
257
- } | {
258
- type: "trace";
259
- summary?: string | undefined;
260
- rootOp?: string | undefined;
261
- rootName?: string | undefined;
262
- durationMs: number;
263
- spanCount: number;
264
- errorCount: number;
265
- performanceIssueCount: number;
266
- projects: string[];
267
- spans: {
268
- op?: string | undefined;
269
- name: string;
270
- startMs: number;
271
- durationMs: number;
272
- issue?: boolean | undefined;
273
- }[];
274
- } | {
275
- type: "person";
276
- summary?: string | undefined;
277
- email?: string | undefined;
278
- slackHandle?: string | undefined;
279
- githubHandle?: string | undefined;
280
- avatarUrl?: string | undefined;
281
- } | undefined;
282
- }[] | undefined;
283
- reply?: {
284
- text: string;
285
- url?: string | undefined;
286
- } | undefined;
287
- continuation?: {
288
- arguments: Record<string, unknown>;
289
- reason?: string | undefined;
290
- } | undefined;
291
- target: "searchGoogleFiles";
292
- files: {
293
- file_id: string;
294
- modified_at?: string | undefined;
295
- title: string;
296
- type: "document" | "presentation" | "spreadsheet";
297
- url?: string | undefined;
298
- }[];
299
- truncated: boolean;
300
- }, GoogleToolContext>;
@@ -1,323 +0,0 @@
1
- import { type PluginEgress, type PluginSandbox, type User } from "@sentry/junior-plugin-api";
2
- import * as z from "zod";
3
- import { type GoogleOperation } from "../credentials";
4
- /** Runtime capabilities the Google tools use. */
5
- export interface GoogleToolContext {
6
- /** The Workspace account Junior acts as, in lowercase. */
7
- accountEmail: string;
8
- allowedDomains: string[];
9
- egress: PluginEgress;
10
- /** Holds full meeting records that are too long to return inline. */
11
- sandbox: Pick<PluginSandbox, "root" | "run" | "writeFile">;
12
- users: {
13
- resolveActor(): Promise<{
14
- user?: User;
15
- } | undefined>;
16
- resolveTimezone(): Promise<string>;
17
- };
18
- }
19
- export declare const emailListSchema: (max: number) => z.ZodArray<z.ZodPipe<z.ZodString, z.ZodEmail>>;
20
- export declare const timeZoneSchema: z.ZodOptional<z.ZodString>;
21
- /** True when the runtime knows this IANA time zone. */
22
- export declare function isTimeZone(value: string): boolean;
23
- /** Reject people outside the domains Junior may look up or invite. */
24
- export declare function requireAllowedEmails(emails: string[], allowedDomains: string[]): void;
25
- /** Return the requester's email in lowercase, when Junior knows it. */
26
- export declare function requesterEmail(ctx: GoogleToolContext): Promise<string | undefined>;
27
- /**
28
- * Add the requester's email when Junior knows it and it is in an allowed
29
- * domain. People rarely type their own address.
30
- */
31
- export declare function withRequester(ctx: GoogleToolContext, emails: string[]): Promise<string[]>;
32
- /**
33
- * Call one Google API operation through host-owned egress.
34
- *
35
- * A JSON response body is parsed. Other bodies, such as a Drive export, are
36
- * returned as text.
37
- */
38
- export declare function googleApiRequest(ctx: Pick<GoogleToolContext, "egress">, input: {
39
- body?: unknown;
40
- headers?: Record<string, string>;
41
- operation: GoogleOperation;
42
- path: string;
43
- /** A list value repeats the parameter, as Sheets `ranges` needs. */
44
- query?: Record<string, string | string[]>;
45
- }): Promise<{
46
- body: unknown;
47
- status: number;
48
- }>;
49
- /** Turn a failed Google response into a tool error. */
50
- export declare function googleApiError(operation: GoogleOperation, response: {
51
- body: unknown;
52
- status: number;
53
- }): Error;
54
- /** Format one interval for people, in the requested time zone. */
55
- export declare function formatInterval(startMs: number, endMs: number, timeZone: string): string;
56
- /** Longest event Junior may create or move an event to. */
57
- export declare const MAX_EVENT_MS: number;
58
- /** Google attendee fields that tools read and return. */
59
- export declare const googleAttendeeSchema: z.ZodObject<{
60
- displayName: z.ZodOptional<z.ZodString>;
61
- email: z.ZodString;
62
- optional: z.ZodOptional<z.ZodBoolean>;
63
- resource: z.ZodOptional<z.ZodBoolean>;
64
- responseStatus: z.ZodOptional<z.ZodString>;
65
- }, z.core.$loose>;
66
- /** One attendee in a tool result. */
67
- export declare const attendeeOutputSchema: z.ZodObject<{
68
- email: z.ZodString;
69
- optional: z.ZodOptional<z.ZodBoolean>;
70
- response: z.ZodOptional<z.ZodEnum<{
71
- accepted: "accepted";
72
- declined: "declined";
73
- needsAction: "needsAction";
74
- tentative: "tentative";
75
- }>>;
76
- }, z.core.$strip>;
77
- /** Shape Google attendees for a tool result. Room resources are left out. */
78
- export declare function attendeeResults(attendees: Array<z.infer<typeof googleAttendeeSchema>> | undefined): Array<z.infer<typeof attendeeOutputSchema>>;
79
- /**
80
- * Make a Google Calendar event link open in the viewer's Workspace account.
81
- *
82
- * Google opens a plain event link in the browser's default account, which is
83
- * often a personal one. AccountChooser picks the signed-in account of the
84
- * Workspace domain, then continues to the event. Everyone in a Slack thread
85
- * sees the same link, so the domain comes from Junior's own account, not the
86
- * requester. `authuser`, `authdomain`, `login_hint`, `hd` on the event link,
87
- * and `/u/<email>/` do not work for every viewer.
88
- *
89
- * Returns the link unchanged for a consumer domain, a link that is not an
90
- * event link, or a link that already goes through AccountChooser.
91
- */
92
- export declare function accountChooserLink(url: string, accountEmail: string): string;
93
- /** Event fields that Junior reads back from its own calendar. */
94
- export declare const ownEventSchema: z.ZodObject<{
95
- attendees: z.ZodOptional<z.ZodArray<z.ZodObject<{
96
- displayName: z.ZodOptional<z.ZodString>;
97
- email: z.ZodString;
98
- optional: z.ZodOptional<z.ZodBoolean>;
99
- resource: z.ZodOptional<z.ZodBoolean>;
100
- responseStatus: z.ZodOptional<z.ZodString>;
101
- }, z.core.$loose>>>;
102
- description: z.ZodOptional<z.ZodString>;
103
- end: z.ZodObject<{
104
- dateTime: z.ZodString;
105
- }, z.core.$strip>;
106
- hangoutLink: z.ZodOptional<z.ZodString>;
107
- htmlLink: z.ZodOptional<z.ZodString>;
108
- id: z.ZodString;
109
- location: z.ZodOptional<z.ZodString>;
110
- organizer: z.ZodOptional<z.ZodObject<{
111
- self: z.ZodOptional<z.ZodBoolean>;
112
- }, z.core.$strip>>;
113
- recurrence: z.ZodOptional<z.ZodArray<z.ZodString>>;
114
- recurringEventId: z.ZodOptional<z.ZodString>;
115
- start: z.ZodObject<{
116
- dateTime: z.ZodString;
117
- }, z.core.$strip>;
118
- summary: z.ZodOptional<z.ZodString>;
119
- updated: z.ZodOptional<z.ZodString>;
120
- }, z.core.$strip>;
121
- export type OwnEvent = z.infer<typeof ownEventSchema>;
122
- /**
123
- * Shape one event on Junior's calendar for a tool result.
124
- *
125
- * Core saves the Calendar event annotation and shows its card with the next
126
- * reply. The event id is the key, so a change replaces the saved card. The
127
- * label is the short date for the sidebar; the card shows the full time.
128
- */
129
- export declare function ownEventResult(event: OwnEvent, timeZone: string, accountEmail: string): {
130
- objectAnnotations: {
131
- kind: "object";
132
- key: string;
133
- label: string;
134
- objectType: "automation" | "calendar_event" | "chart" | "code_change" | "conversation" | "deployment" | "document" | "event" | "item" | "message" | "person" | "task" | "trace" | "web_page";
135
- title: string;
136
- url: string | null;
137
- description?: string | undefined;
138
- status?: string | undefined;
139
- trigger?: string | undefined;
140
- warning?: string | undefined;
141
- displayType?: string | undefined;
142
- sourceUpdatedAt?: string | undefined;
143
- facts?: {
144
- type: "code_change";
145
- summary?: string | undefined;
146
- author?: string | undefined;
147
- sourceBranch?: string | undefined;
148
- targetBranch?: string | undefined;
149
- reviewers?: string[] | undefined;
150
- review?: "approved" | "changes_requested" | "required" | undefined;
151
- checks?: {
152
- passed: number;
153
- failed: number;
154
- pending: number;
155
- } | undefined;
156
- mergeable?: boolean | undefined;
157
- changedFiles?: number | undefined;
158
- additions?: number | undefined;
159
- deletions?: number | undefined;
160
- previewImageUrls?: string[] | undefined;
161
- } | {
162
- type: "task";
163
- summary?: string | undefined;
164
- assignees?: string[] | undefined;
165
- priority?: string | undefined;
166
- project?: string | undefined;
167
- cycle?: string | undefined;
168
- dueDate?: string | undefined;
169
- labels?: string[] | undefined;
170
- trend?: {
171
- label: string;
172
- points: number[];
173
- } | undefined;
174
- } | {
175
- type: "deployment";
176
- summary?: string | undefined;
177
- project?: string | undefined;
178
- environment?: string | undefined;
179
- revision?: string | undefined;
180
- branch?: string | undefined;
181
- } | {
182
- type: "calendar_event";
183
- summary?: string | undefined;
184
- when?: string | undefined;
185
- attendees?: string[] | undefined;
186
- } | {
187
- type: "conversation";
188
- summary?: string | undefined;
189
- participants?: string[] | undefined;
190
- lastActivityAt?: string | undefined;
191
- } | {
192
- type: "document";
193
- summary?: string | undefined;
194
- owner?: string | undefined;
195
- modifiedAt?: string | undefined;
196
- thumbnailUrl?: string | undefined;
197
- } | {
198
- type: "message";
199
- summary?: string | undefined;
200
- channel?: string | undefined;
201
- author?: string | undefined;
202
- sentAt?: string | undefined;
203
- } | {
204
- type: "web_page";
205
- summary?: string | undefined;
206
- siteName?: string | undefined;
207
- author?: string | undefined;
208
- media?: "image" | "video" | undefined;
209
- thumbnailUrl?: string | undefined;
210
- } | {
211
- type: "chart";
212
- summary?: string | undefined;
213
- display: "area" | "bar" | "line";
214
- yAxis: string;
215
- range: string;
216
- series: {
217
- label: string;
218
- points: number[];
219
- }[];
220
- } | {
221
- type: "event";
222
- summary?: string | undefined;
223
- level?: string | undefined;
224
- project?: string | undefined;
225
- release?: string | undefined;
226
- environment?: string | undefined;
227
- occurredAt?: string | undefined;
228
- } | {
229
- type: "trace";
230
- summary?: string | undefined;
231
- rootOp?: string | undefined;
232
- rootName?: string | undefined;
233
- durationMs: number;
234
- spanCount: number;
235
- errorCount: number;
236
- performanceIssueCount: number;
237
- projects: string[];
238
- spans: {
239
- op?: string | undefined;
240
- name: string;
241
- startMs: number;
242
- durationMs: number;
243
- issue?: boolean | undefined;
244
- }[];
245
- } | {
246
- type: "person";
247
- summary?: string | undefined;
248
- email?: string | undefined;
249
- slackHandle?: string | undefined;
250
- githubHandle?: string | undefined;
251
- avatarUrl?: string | undefined;
252
- } | undefined;
253
- }[];
254
- attendees: {
255
- email: string;
256
- optional?: boolean | undefined;
257
- response?: "accepted" | "declined" | "needsAction" | "tentative" | undefined;
258
- }[];
259
- end: string;
260
- event_id: string;
261
- label: string;
262
- start: string;
263
- title?: string | undefined;
264
- location?: string | undefined;
265
- repeats?: boolean | undefined;
266
- series_event_id?: string | undefined;
267
- url?: string | undefined;
268
- video_call_url?: string | undefined;
269
- };
270
- /** Output fields shared by the tools that create or change Junior's events. */
271
- export declare const ownEventOutputFields: {
272
- attendees: z.ZodArray<z.ZodObject<{
273
- email: z.ZodString;
274
- optional: z.ZodOptional<z.ZodBoolean>;
275
- response: z.ZodOptional<z.ZodEnum<{
276
- accepted: "accepted";
277
- declined: "declined";
278
- needsAction: "needsAction";
279
- tentative: "tentative";
280
- }>>;
281
- }, z.core.$strip>>;
282
- end: z.ZodString;
283
- event_id: z.ZodString;
284
- label: z.ZodString;
285
- location: z.ZodOptional<z.ZodString>;
286
- repeats: z.ZodOptional<z.ZodBoolean>;
287
- series_event_id: z.ZodOptional<z.ZodString>;
288
- start: z.ZodString;
289
- title: z.ZodOptional<z.ZodString>;
290
- url: z.ZodOptional<z.ZodString>;
291
- video_call_url: z.ZodOptional<z.ZodString>;
292
- };
293
- /** Event id or link input for tools that act on an event Junior organizes. */
294
- export declare const ownEventIdSchema: z.ZodString;
295
- /**
296
- * Return the event id from an id or a Google Calendar event link.
297
- *
298
- * A link's `eid` value is base64 for `<eventId> <calendar email>`. An
299
- * AccountChooser link holds the event link in `continue`.
300
- */
301
- export declare function parseEventId(value: string): string;
302
- /** Result of reading an event that Junior organizes. */
303
- export type OwnEventRead = {
304
- event: OwnEvent;
305
- eventId: string;
306
- path: string;
307
- status: "active";
308
- } | {
309
- eventId: string;
310
- path: string;
311
- status: "cancelled";
312
- };
313
- /**
314
- * Read an event that Junior organizes, for a requester who is invited to it.
315
- *
316
- * Only invited people may change or cancel an event. This keeps one requester
317
- * from moving or cancelling a meeting that Junior set up for others.
318
- *
319
- * A deleted event on Junior's calendar comes back as `cancelled`. Google
320
- * returns it as HTTP 410, or as a stub with only `id` and `status`, so it has
321
- * no organizer or attendees to check. Callers must not change it.
322
- */
323
- export declare function readOwnEventForRequester(ctx: GoogleToolContext, eventIdOrLink: string, action: "change" | "cancel"): Promise<OwnEventRead>;