@getmateo/protocol 0.17.1 → 0.18.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,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  export declare const BrowserAutomationHostCapabilitySchema: z.ZodObject<{
3
- supportedCommands: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("type" | "select" | "fill" | "logs" | "list_tabs" | "new_tab" | "snapshot" | "click" | "wait" | "keypress" | "navigate" | "back" | "forward" | "reload" | "screenshot" | "upload" | "hover" | "drag" | "evaluate" | "scroll" | "resize" | "close_tab")[], string[]>>;
3
+ supportedCommands: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<("type" | "upload" | "select" | "fill" | "logs" | "list_tabs" | "new_tab" | "snapshot" | "click" | "wait" | "keypress" | "navigate" | "back" | "forward" | "reload" | "screenshot" | "hover" | "drag" | "evaluate" | "scroll" | "resize" | "close_tab" | "list_downloads")[], string[]>>;
4
4
  hostKind: z.ZodDefault<z.ZodString>;
5
5
  }, z.core.$loose>;
6
6
  export type BrowserAutomationHostCapability = z.infer<typeof BrowserAutomationHostCapabilitySchema>;
@@ -11,9 +11,11 @@ export declare const BrowserAutomationErrorCodeSchema: z.ZodEnum<{
11
11
  browser_stale_ref: "browser_stale_ref";
12
12
  browser_unknown_error: "browser_unknown_error";
13
13
  }>;
14
- export declare const BROWSER_AUTOMATION_COMMAND_NAMES: readonly ["list_tabs", "new_tab", "snapshot", "click", "fill", "wait", "type", "keypress", "navigate", "back", "forward", "reload", "screenshot", "upload", "select", "hover", "drag", "logs", "evaluate", "scroll", "resize", "close_tab"];
14
+ export declare const BROWSER_AUTOMATION_BASE_COMMANDS: readonly ["list_tabs", "new_tab", "snapshot", "click", "fill", "wait", "type", "keypress", "navigate", "back", "forward", "reload", "screenshot", "upload", "select", "hover", "drag", "logs", "evaluate", "scroll", "resize", "close_tab"];
15
+ export declare const BROWSER_AUTOMATION_COMMAND_NAMES: readonly ["list_tabs", "new_tab", "snapshot", "click", "fill", "wait", "type", "keypress", "navigate", "back", "forward", "reload", "screenshot", "upload", "select", "hover", "drag", "logs", "evaluate", "scroll", "resize", "close_tab", "list_downloads"];
15
16
  export declare const BrowserAutomationCommandNameSchema: z.ZodEnum<{
16
17
  type: "type";
18
+ upload: "upload";
17
19
  select: "select";
18
20
  fill: "fill";
19
21
  logs: "logs";
@@ -28,19 +30,23 @@ export declare const BrowserAutomationCommandNameSchema: z.ZodEnum<{
28
30
  forward: "forward";
29
31
  reload: "reload";
30
32
  screenshot: "screenshot";
31
- upload: "upload";
32
33
  hover: "hover";
33
34
  drag: "drag";
34
35
  evaluate: "evaluate";
35
36
  scroll: "scroll";
36
37
  resize: "resize";
37
38
  close_tab: "close_tab";
39
+ list_downloads: "list_downloads";
38
40
  }>;
39
41
  export declare const BrowserAutomationBrowserIdSchema: z.ZodString;
40
42
  export declare const BrowserAutomationListTabsCommandSchema: z.ZodObject<{
41
43
  command: z.ZodLiteral<"list_tabs">;
42
44
  args: z.ZodDefault<z.ZodObject<{}, z.core.$strict>>;
43
45
  }, z.core.$strip>;
46
+ export declare const BrowserAutomationListDownloadsCommandSchema: z.ZodObject<{
47
+ command: z.ZodLiteral<"list_downloads">;
48
+ args: z.ZodObject<{}, z.core.$strict>;
49
+ }, z.core.$strip>;
44
50
  export declare const BrowserAutomationNewTabCommandSchema: z.ZodObject<{
45
51
  command: z.ZodLiteral<"new_tab">;
46
52
  args: z.ZodDefault<z.ZodObject<{
@@ -209,6 +215,9 @@ export declare const BrowserAutomationCloseTabCommandSchema: z.ZodObject<{
209
215
  export declare const BrowserAutomationCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
210
216
  command: z.ZodLiteral<"list_tabs">;
211
217
  args: z.ZodDefault<z.ZodObject<{}, z.core.$strict>>;
218
+ }, z.core.$strip>, z.ZodObject<{
219
+ command: z.ZodLiteral<"list_downloads">;
220
+ args: z.ZodObject<{}, z.core.$strict>;
212
221
  }, z.core.$strip>, z.ZodObject<{
213
222
  command: z.ZodLiteral<"new_tab">;
214
223
  args: z.ZodDefault<z.ZodObject<{
@@ -377,6 +386,65 @@ export declare const BrowserAutomationListTabsResultSchema: z.ZodObject<{
377
386
  canGoForward: z.ZodOptional<z.ZodBoolean>;
378
387
  }, z.core.$strip>>;
379
388
  }, z.core.$strip>;
389
+ export declare const BrowserDownloadReceiptSchema: z.ZodObject<{
390
+ id: z.ZodString;
391
+ browserId: z.ZodNullable<z.ZodString>;
392
+ workspaceId: z.ZodNullable<z.ZodString>;
393
+ serverId: z.ZodNullable<z.ZodString>;
394
+ status: z.ZodEnum<{
395
+ completed: "completed";
396
+ failed: "failed";
397
+ cancelled: "cancelled";
398
+ }>;
399
+ path: z.ZodNullable<z.ZodString>;
400
+ url: z.ZodString;
401
+ filename: z.ZodString;
402
+ bytes: z.ZodNumber;
403
+ mimeType: z.ZodString;
404
+ finishedAt: z.ZodString;
405
+ error: z.ZodOptional<z.ZodString>;
406
+ }, z.core.$strip>;
407
+ export type BrowserDownloadReceipt = z.infer<typeof BrowserDownloadReceiptSchema>;
408
+ export declare const BROWSER_DOWNLOAD_LIST_LIMIT = 50;
409
+ export declare const BrowserDownloadListSchema: z.ZodArray<z.ZodObject<{
410
+ id: z.ZodString;
411
+ browserId: z.ZodNullable<z.ZodString>;
412
+ workspaceId: z.ZodNullable<z.ZodString>;
413
+ serverId: z.ZodNullable<z.ZodString>;
414
+ status: z.ZodEnum<{
415
+ completed: "completed";
416
+ failed: "failed";
417
+ cancelled: "cancelled";
418
+ }>;
419
+ path: z.ZodNullable<z.ZodString>;
420
+ url: z.ZodString;
421
+ filename: z.ZodString;
422
+ bytes: z.ZodNumber;
423
+ mimeType: z.ZodString;
424
+ finishedAt: z.ZodString;
425
+ error: z.ZodOptional<z.ZodString>;
426
+ }, z.core.$strip>>;
427
+ export declare const BrowserAutomationListDownloadsResultSchema: z.ZodObject<{
428
+ command: z.ZodLiteral<"list_downloads">;
429
+ downloads: z.ZodArray<z.ZodObject<{
430
+ id: z.ZodString;
431
+ browserId: z.ZodNullable<z.ZodString>;
432
+ workspaceId: z.ZodNullable<z.ZodString>;
433
+ serverId: z.ZodNullable<z.ZodString>;
434
+ status: z.ZodEnum<{
435
+ completed: "completed";
436
+ failed: "failed";
437
+ cancelled: "cancelled";
438
+ }>;
439
+ path: z.ZodNullable<z.ZodString>;
440
+ url: z.ZodString;
441
+ filename: z.ZodString;
442
+ bytes: z.ZodNumber;
443
+ mimeType: z.ZodString;
444
+ finishedAt: z.ZodString;
445
+ error: z.ZodOptional<z.ZodString>;
446
+ }, z.core.$strip>>;
447
+ }, z.core.$strip>;
380
448
  export declare const BrowserAutomationNewTabResultSchema: z.ZodObject<{
381
449
  command: z.ZodLiteral<"new_tab">;
382
450
  browserId: z.ZodString;
@@ -569,6 +637,26 @@ export declare const BrowserAutomationResultSchema: z.ZodDiscriminatedUnion<[z.Z
569
637
  canGoBack: z.ZodOptional<z.ZodBoolean>;
570
638
  canGoForward: z.ZodOptional<z.ZodBoolean>;
571
639
  }, z.core.$strip>>;
640
+ }, z.core.$strip>, z.ZodObject<{
641
+ command: z.ZodLiteral<"list_downloads">;
642
+ downloads: z.ZodArray<z.ZodObject<{
643
+ id: z.ZodString;
644
+ browserId: z.ZodNullable<z.ZodString>;
645
+ workspaceId: z.ZodNullable<z.ZodString>;
646
+ serverId: z.ZodNullable<z.ZodString>;
647
+ status: z.ZodEnum<{
648
+ completed: "completed";
649
+ failed: "failed";
650
+ cancelled: "cancelled";
651
+ }>;
652
+ path: z.ZodNullable<z.ZodString>;
653
+ url: z.ZodString;
654
+ filename: z.ZodString;
655
+ bytes: z.ZodNumber;
656
+ mimeType: z.ZodString;
657
+ finishedAt: z.ZodString;
658
+ error: z.ZodOptional<z.ZodString>;
659
+ }, z.core.$strip>>;
572
660
  }, z.core.$strip>, z.ZodObject<{
573
661
  command: z.ZodLiteral<"new_tab">;
574
662
  browserId: z.ZodString;
@@ -748,6 +836,9 @@ export declare const BrowserAutomationExecuteRequestSchema: z.ZodObject<{
748
836
  command: z.ZodDiscriminatedUnion<[z.ZodObject<{
749
837
  command: z.ZodLiteral<"list_tabs">;
750
838
  args: z.ZodDefault<z.ZodObject<{}, z.core.$strict>>;
839
+ }, z.core.$strip>, z.ZodObject<{
840
+ command: z.ZodLiteral<"list_downloads">;
841
+ args: z.ZodObject<{}, z.core.$strict>;
751
842
  }, z.core.$strip>, z.ZodObject<{
752
843
  command: z.ZodLiteral<"new_tab">;
753
844
  args: z.ZodDefault<z.ZodObject<{
@@ -911,6 +1002,26 @@ export declare const BrowserAutomationExecuteResponseSchema: z.ZodObject<{
911
1002
  canGoBack: z.ZodOptional<z.ZodBoolean>;
912
1003
  canGoForward: z.ZodOptional<z.ZodBoolean>;
913
1004
  }, z.core.$strip>>;
1005
+ }, z.core.$strip>, z.ZodObject<{
1006
+ command: z.ZodLiteral<"list_downloads">;
1007
+ downloads: z.ZodArray<z.ZodObject<{
1008
+ id: z.ZodString;
1009
+ browserId: z.ZodNullable<z.ZodString>;
1010
+ workspaceId: z.ZodNullable<z.ZodString>;
1011
+ serverId: z.ZodNullable<z.ZodString>;
1012
+ status: z.ZodEnum<{
1013
+ completed: "completed";
1014
+ failed: "failed";
1015
+ cancelled: "cancelled";
1016
+ }>;
1017
+ path: z.ZodNullable<z.ZodString>;
1018
+ url: z.ZodString;
1019
+ filename: z.ZodString;
1020
+ bytes: z.ZodNumber;
1021
+ mimeType: z.ZodString;
1022
+ finishedAt: z.ZodString;
1023
+ error: z.ZodOptional<z.ZodString>;
1024
+ }, z.core.$strip>>;
914
1025
  }, z.core.$strip>, z.ZodObject<{
915
1026
  command: z.ZodLiteral<"new_tab">;
916
1027
  browserId: z.ZodString;
@@ -14,7 +14,9 @@ export const BrowserAutomationErrorCodeSchema = z.enum([
14
14
  const BROWSER_AUTOMATION_BROWSER_ID_PATTERN = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|\d{13,}-[0-9a-f]+)$/i;
15
15
  const BROWSER_AUTOMATION_BROWSER_ID_MESSAGE = "browserId must be a real id returned by browser_new_tab or browser_list_tabs";
16
16
  const BROWSER_AUTOMATION_WAIT_CONDITION_MESSAGE = "browser_wait requires exactly one of text or url";
17
- export const BROWSER_AUTOMATION_COMMAND_NAMES = [
17
+ // Keep the registration enum sent to existing browser hosts unchanged. Download receipts
18
+ // are negotiated separately on browser.host.register, whose old validator rejects new enum values.
19
+ export const BROWSER_AUTOMATION_BASE_COMMANDS = [
18
20
  "list_tabs",
19
21
  "new_tab",
20
22
  "snapshot",
@@ -38,6 +40,10 @@ export const BROWSER_AUTOMATION_COMMAND_NAMES = [
38
40
  "resize",
39
41
  "close_tab",
40
42
  ];
43
+ export const BROWSER_AUTOMATION_COMMAND_NAMES = [
44
+ ...BROWSER_AUTOMATION_BASE_COMMANDS,
45
+ "list_downloads",
46
+ ];
41
47
  export const BrowserAutomationCommandNameSchema = z.enum(BROWSER_AUTOMATION_COMMAND_NAMES);
42
48
  export const BrowserAutomationBrowserIdSchema = z
43
49
  .string({ error: () => BROWSER_AUTOMATION_BROWSER_ID_MESSAGE })
@@ -62,6 +68,10 @@ export const BrowserAutomationListTabsCommandSchema = z.object({
62
68
  command: z.literal("list_tabs"),
63
69
  args: z.object({}).strict().default({}),
64
70
  });
71
+ export const BrowserAutomationListDownloadsCommandSchema = z.object({
72
+ command: z.literal("list_downloads"),
73
+ args: z.object({}).strict(),
74
+ });
65
75
  export const BrowserAutomationNewTabCommandSchema = z.object({
66
76
  command: z.literal("new_tab"),
67
77
  args: z
@@ -200,6 +210,7 @@ export const BrowserAutomationCloseTabCommandSchema = z.object({
200
210
  });
201
211
  export const BrowserAutomationCommandSchema = z.discriminatedUnion("command", [
202
212
  BrowserAutomationListTabsCommandSchema,
213
+ BrowserAutomationListDownloadsCommandSchema,
203
214
  BrowserAutomationNewTabCommandSchema,
204
215
  BrowserAutomationSnapshotCommandSchema,
205
216
  BrowserAutomationClickCommandSchema,
@@ -236,6 +247,28 @@ export const BrowserAutomationListTabsResultSchema = z.object({
236
247
  command: z.literal("list_tabs"),
237
248
  tabs: z.array(BrowserAutomationTabInfoSchema),
238
249
  });
250
+ export const BrowserDownloadReceiptSchema = z.object({
251
+ id: z.string(),
252
+ browserId: z.string().nullable(),
253
+ workspaceId: z.string().nullable(),
254
+ serverId: z.string().nullable(),
255
+ status: z.enum(["completed", "failed", "cancelled"]),
256
+ path: z.string().nullable(),
257
+ url: z.string(),
258
+ filename: z.string(),
259
+ bytes: z.number().int().nonnegative(),
260
+ mimeType: z.string(),
261
+ finishedAt: z.string(),
262
+ error: z.string().optional(),
263
+ });
264
+ export const BROWSER_DOWNLOAD_LIST_LIMIT = 50;
265
+ export const BrowserDownloadListSchema = z
266
+ .array(BrowserDownloadReceiptSchema)
267
+ .max(BROWSER_DOWNLOAD_LIST_LIMIT);
268
+ export const BrowserAutomationListDownloadsResultSchema = z.object({
269
+ command: z.literal("list_downloads"),
270
+ downloads: BrowserDownloadListSchema,
271
+ });
239
272
  export const BrowserAutomationNewTabResultSchema = z.object({
240
273
  command: z.literal("new_tab"),
241
274
  browserId: BrowserAutomationBrowserIdSchema,
@@ -397,6 +430,7 @@ export const BrowserAutomationCloseTabResultSchema = z.object({
397
430
  });
398
431
  export const BrowserAutomationResultSchema = z.discriminatedUnion("command", [
399
432
  BrowserAutomationListTabsResultSchema,
433
+ BrowserAutomationListDownloadsResultSchema,
400
434
  BrowserAutomationNewTabResultSchema,
401
435
  BrowserAutomationSnapshotResultSchema,
402
436
  BrowserAutomationClickResultSchema,
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ export declare function isValidWorkspaceDownloadSubdirectory(value: string): boolean;
3
+ export declare const MAX_BROWSER_DOWNLOAD_RULES = 32;
4
+ export declare const BrowserDownloadRuleSchema: z.ZodObject<{
5
+ id: z.ZodString;
6
+ workspaceId: z.ZodString;
7
+ directory: z.ZodString;
8
+ extensions: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
9
+ }, z.core.$strict>;
10
+ export declare const InstalledBrowserDownloadRuleSchema: z.ZodObject<{
11
+ id: z.ZodString;
12
+ workspaceId: z.ZodString;
13
+ directory: z.ZodString;
14
+ extensions: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
15
+ pluginId: z.ZodString;
16
+ }, z.core.$strict>;
17
+ export type BrowserDownloadRule = z.infer<typeof BrowserDownloadRuleSchema>;
18
+ export type InstalledBrowserDownloadRule = z.infer<typeof InstalledBrowserDownloadRuleSchema>;
19
+ export declare function compareBrowserDownloadRules(left: InstalledBrowserDownloadRule, right: InstalledBrowserDownloadRule): number;
20
+ export declare function selectBrowserDownloadDirectory(rules: readonly InstalledBrowserDownloadRule[], workspaceId: string, filename: string): string | undefined;
21
+ //# sourceMappingURL=browser-download-rules.d.ts.map
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+ const reservedDeviceName = /^(?:con|prn|aux|nul|clock\$|conin\$|conout\$|(?:com|lpt)[0-9¹²³]) *(?:\.|$)/i;
3
+ export function isValidWorkspaceDownloadSubdirectory(value) {
4
+ return value.split("/").every((part) => {
5
+ if (!part || part !== part.trim() || part.startsWith(".") || part.endsWith("."))
6
+ return false;
7
+ // Windows short names can alias hidden directories, such as GIT~1.
8
+ return !/[<>:"\\|?*\p{Cc}\p{Cf}]|~[0-9]/u.test(part) && !reservedDeviceName.test(part);
9
+ });
10
+ }
11
+ export const MAX_BROWSER_DOWNLOAD_RULES = 32;
12
+ export const BrowserDownloadRuleSchema = z.strictObject({
13
+ id: z
14
+ .string()
15
+ .max(128)
16
+ .regex(/^[a-z][a-z0-9-]*$/),
17
+ workspaceId: z.string().min(1).max(512),
18
+ directory: z
19
+ .string()
20
+ .min(1)
21
+ .max(512)
22
+ .refine(isValidWorkspaceDownloadSubdirectory, "Expected a safe workspace-relative directory"),
23
+ extensions: z
24
+ .array(z.string().regex(/^[a-z0-9]{1,20}$/))
25
+ .min(1)
26
+ .max(32)
27
+ .readonly()
28
+ .optional(),
29
+ });
30
+ export const InstalledBrowserDownloadRuleSchema = BrowserDownloadRuleSchema.extend({
31
+ pluginId: z.string().min(1).max(256),
32
+ });
33
+ function compareId(left, right) {
34
+ if (left === right)
35
+ return 0;
36
+ return left < right ? -1 : 1;
37
+ }
38
+ export function compareBrowserDownloadRules(left, right) {
39
+ return compareId(left.pluginId, right.pluginId) || compareId(left.id, right.id);
40
+ }
41
+ export function selectBrowserDownloadDirectory(rules, workspaceId, filename) {
42
+ const dot = filename.lastIndexOf(".");
43
+ const extension = dot > 0 ? filename.slice(dot + 1).toLowerCase() : "";
44
+ let first;
45
+ for (const rule of rules) {
46
+ if (rule.workspaceId !== workspaceId ||
47
+ (rule.extensions && !rule.extensions.includes(extension)))
48
+ continue;
49
+ if (!first || compareBrowserDownloadRules(rule, first) < 0)
50
+ first = rule;
51
+ }
52
+ return first?.directory;
53
+ }
54
+ //# sourceMappingURL=browser-download-rules.js.map