@frockbot/computer-core 0.3.20 → 0.3.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frockbot/computer-core",
3
- "version": "0.3.20",
3
+ "version": "0.3.22",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -12,7 +12,7 @@
12
12
  "typecheck": "tsc --noEmit -p tsconfig.json"
13
13
  },
14
14
  "dependencies": {
15
- "@frockbot/kernel-contracts": "0.3.20",
15
+ "@frockbot/kernel-contracts": "0.3.22",
16
16
  "cordis": "4.0.0-rc.8"
17
17
  },
18
18
  "devDependencies": {
package/src/core.ts CHANGED
@@ -343,6 +343,8 @@ export interface ComputerExec {
343
343
  export type ComputerBrowserAction =
344
344
  | { type: "snapshot" }
345
345
  | { type: "navigate"; url: string }
346
+ /** Internal lifecycle action; the model-facing browser tool cannot send it. */
347
+ | { type: "close-origins"; origins: readonly string[] }
346
348
  | { type: "click"; role: string; name: string; exact?: boolean }
347
349
  | { type: "fill"; label: string; text: string; exact?: boolean }
348
350
  | { type: "press"; key: string }
@@ -66,4 +66,31 @@ describe("Computer host protocol", () => {
66
66
  "unknown or missing fields",
67
67
  );
68
68
  });
69
+
70
+ test("round-trips the bounded internal browser origin cleanup", () => {
71
+ const cleanup: ComputerHostEffectRequestV1 = {
72
+ ...request,
73
+ operation: {
74
+ type: "browser",
75
+ action: {
76
+ type: "close-origins",
77
+ origins: ["http://127.0.0.1:8787"],
78
+ },
79
+ },
80
+ };
81
+ expect(
82
+ decodeComputerHostEffectRequestV1(
83
+ computerHostEffectRequestWireV1(cleanup),
84
+ ),
85
+ ).toEqual(cleanup);
86
+ expect(() =>
87
+ decodeComputerHostEffectRequestV1({
88
+ ...computerHostEffectRequestWireV1(cleanup),
89
+ operation: {
90
+ type: "browser",
91
+ action: { type: "close-origins", origins: [] },
92
+ },
93
+ }),
94
+ ).toThrow("origins are invalid");
95
+ });
69
96
  });
@@ -114,6 +114,20 @@ function browserAction(input: unknown): ComputerBrowserAction {
114
114
  throw new Error("Computer browser URL is invalid");
115
115
  return { type, url: value.url };
116
116
  }
117
+ if (type === "close-origins") {
118
+ const value = record(input, ["type", "origins"], "Computer browser action");
119
+ if (
120
+ !Array.isArray(value.origins) ||
121
+ value.origins.length < 1 ||
122
+ value.origins.length > 16 ||
123
+ value.origins.some(
124
+ (origin) => typeof origin !== "string" || origin.length > 2_048,
125
+ )
126
+ ) {
127
+ throw new Error("Computer browser origins are invalid");
128
+ }
129
+ return { type, origins: value.origins as string[] };
130
+ }
117
131
  if (type === "click") {
118
132
  const value = record(
119
133
  input,