@sideboard-ai/core 0.1.352 → 0.1.353

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.
@@ -69,62 +69,66 @@ var import_zod = require("zod");
69
69
 
70
70
  // src/computer-use/computer-use.ts
71
71
  var import_node_child_process = require("child_process");
72
- var import_node_fs = require("fs");
73
- var import_node_os = require("os");
74
- var import_node_path = require("path");
75
- var import_node_util = require("util");
76
- var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
77
- var COMPUTER_USE_DESCRIPTION = "Drive this Mac to test an app you started. Off unless Settings \u2192 Advanced \u2192 Computer use is on. action is screenshot, click, type, key, or scroll. screenshot writes a PNG of the main display under the worktree .context/cli/ and returns that path plus point width, height, and scale. Read the image. x and y are screen points from the top-left of that image, not PNG pixels: divide a pixel by scale. click and scroll use those points. scroll posts a wheel event at the point (positive dx is right, positive dy is down). type sends text. key is one key (return, tab, escape, arrows, delete, or one character) with optional modifiers command, shift, option, control. Use it to check behavior and visual design (hierarchy, alignment, spacing, type, contrast, fit with the surrounding surface). preview=window means the Electron window, not a browser tab. Sideboard needs Accessibility and Screen Recording permission. Do not drive an app you did not start for this test.";
78
- var PNG_SIG = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
79
-
80
- // src/agent-rpc/client.ts
81
- var import_ws = require("ws");
82
-
83
- // src/agent-rpc/metadata.ts
84
72
  var import_node_fs7 = require("fs");
73
+ var import_node_os3 = require("os");
85
74
  var import_node_path8 = require("path");
75
+ var import_node_util = require("util");
76
+
77
+ // src/computer-use/bridge.ts
78
+ var import_node_fs6 = require("fs");
79
+ var import_node_path7 = require("path");
86
80
 
87
81
  // src/store/paths.ts
82
+ var import_node_path5 = require("path");
83
+ var import_node_os2 = require("os");
88
84
  var import_node_path6 = require("path");
89
- var import_node_os3 = require("os");
90
- var import_node_path7 = require("path");
91
- var import_node_fs6 = require("fs");
85
+ var import_node_fs5 = require("fs");
92
86
 
93
87
  // src/hook/settings.ts
94
- var import_node_fs5 = require("fs");
95
- var import_node_os2 = require("os");
96
- var import_node_path5 = require("path");
88
+ var import_node_fs4 = require("fs");
89
+ var import_node_os = require("os");
90
+ var import_node_path4 = require("path");
97
91
  var import_smol_toml = require("smol-toml");
98
92
 
99
93
  // src/hook/convention-setup.ts
100
- var import_node_fs2 = require("fs");
101
- var import_node_path2 = require("path");
94
+ var import_node_fs = require("fs");
95
+ var import_node_path = require("path");
102
96
 
103
97
  // src/hook/cursor-worktrees.ts
104
- var import_node_fs3 = require("fs");
105
- var import_node_path3 = require("path");
98
+ var import_node_fs2 = require("fs");
99
+ var import_node_path2 = require("path");
106
100
  var import_execa = require("execa");
107
101
  var import_node_readline = require("readline");
108
102
 
109
103
  // src/hook/dev-preview.ts
110
- var import_node_fs4 = require("fs");
111
- var import_node_path4 = require("path");
104
+ var import_node_fs3 = require("fs");
105
+ var import_node_path3 = require("path");
112
106
 
113
107
  // src/store/paths.ts
114
108
  function appDataDir() {
115
109
  const override = process.env.SIDEBOARD_APP_DATA?.trim();
116
- const base = override ? override : process.platform === "darwin" ? (0, import_node_path7.join)((0, import_node_os3.homedir)(), "Library", "Application Support", "sideboard") : process.platform === "win32" ? (0, import_node_path7.join)(process.env.APPDATA ?? (0, import_node_path7.join)((0, import_node_os3.homedir)(), "AppData", "Roaming"), "sideboard") : (0, import_node_path7.join)((0, import_node_os3.homedir)(), ".local", "share", "sideboard");
117
- (0, import_node_fs6.mkdirSync)(base, { recursive: true });
110
+ const base = override ? override : process.platform === "darwin" ? (0, import_node_path6.join)((0, import_node_os2.homedir)(), "Library", "Application Support", "sideboard") : process.platform === "win32" ? (0, import_node_path6.join)(process.env.APPDATA ?? (0, import_node_path6.join)((0, import_node_os2.homedir)(), "AppData", "Roaming"), "sideboard") : (0, import_node_path6.join)((0, import_node_os2.homedir)(), ".local", "share", "sideboard");
111
+ (0, import_node_fs5.mkdirSync)(base, { recursive: true });
118
112
  return base;
119
113
  }
120
114
 
115
+ // src/computer-use/computer-use.ts
116
+ var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
117
+ var COMPUTER_USE_DESCRIPTION = "Drive this Mac to test an app you started. Off unless Settings \u2192 Advanced \u2192 Computer use is on. action is screenshot, click, type, key, or scroll. screenshot writes a PNG of the main display under the worktree .context/cli/ and returns that path plus point width, height, and scale. Read the image. x and y are screen points from the top-left of that image, not PNG pixels: divide a pixel by scale. click and scroll use those points. scroll posts a wheel event at the point (positive dx is right, positive dy is down). type sends text. key is one key (return, tab, escape, arrows, delete, or one character) with optional modifiers command, shift, option, control. Use it to check behavior and visual design (hierarchy, alignment, spacing, type, contrast, fit with the surrounding surface). preview=window means the Electron window, not a browser tab. Clicks, typing, scrolling, and screenshots are posted by Sideboard after macOS allows Sideboard to control this Mac and record the screen. Do not drive an app you did not start for this test.";
118
+ var PNG_SIG = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
119
+
120
+ // src/agent-rpc/client.ts
121
+ var import_ws = require("ws");
122
+
121
123
  // src/agent-rpc/metadata.ts
124
+ var import_node_fs8 = require("fs");
125
+ var import_node_path9 = require("path");
122
126
  function agentRuntimeMetadataPath() {
123
- return (0, import_node_path8.join)(appDataDir(), "agent-runtime.json");
127
+ return (0, import_node_path9.join)(appDataDir(), "agent-runtime.json");
124
128
  }
125
129
  function readAgentRuntimeMetadata() {
126
130
  try {
127
- const raw = JSON.parse((0, import_node_fs7.readFileSync)(agentRuntimeMetadataPath(), "utf8"));
131
+ const raw = JSON.parse((0, import_node_fs8.readFileSync)(agentRuntimeMetadataPath(), "utf8"));
128
132
  if (!raw || typeof raw !== "object") return null;
129
133
  const rec = raw;
130
134
  if (typeof rec.runtimeId !== "string" || !rec.runtimeId.trim()) return null;
@@ -12,7 +12,7 @@ import {
12
12
  AgentRpcClient,
13
13
  PILOT_TOOL_DESCRIPTIONS,
14
14
  createPilotRpcExecutors
15
- } from "../chunk-PS6TD5MQ.js";
15
+ } from "../chunk-EAV2ZF5S.js";
16
16
  import {
17
17
  dropNestedElectronEnvFromProcess
18
18
  } from "../chunk-4TR3HZFT.js";
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  ));
25
25
 
26
26
  // src/agents/cursor-runner.ts
27
- var import_node_fs19 = require("fs");
27
+ var import_node_fs20 = require("fs");
28
28
  var import_node_readline2 = require("readline");
29
29
 
30
30
  // src/hook/nested-electron-env.ts
@@ -1065,12 +1065,18 @@ function slicedReadCustomToolConfig(cwd) {
1065
1065
 
1066
1066
  // src/computer-use/computer-use.ts
1067
1067
  var import_node_child_process3 = require("child_process");
1068
- var import_node_fs16 = require("fs");
1068
+ var import_node_fs17 = require("fs");
1069
1069
  var import_node_os6 = require("os");
1070
- var import_node_path18 = require("path");
1070
+ var import_node_path19 = require("path");
1071
1071
  var import_node_util = require("util");
1072
+
1073
+ // src/computer-use/bridge.ts
1074
+ var import_node_fs16 = require("fs");
1075
+ var import_node_path18 = require("path");
1076
+
1077
+ // src/computer-use/computer-use.ts
1072
1078
  var execFileAsync = (0, import_node_util.promisify)(import_node_child_process3.execFile);
1073
- var COMPUTER_USE_DESCRIPTION = "Drive this Mac to test an app you started. Off unless Settings \u2192 Advanced \u2192 Computer use is on. action is screenshot, click, type, key, or scroll. screenshot writes a PNG of the main display under the worktree .context/cli/ and returns that path plus point width, height, and scale. Read the image. x and y are screen points from the top-left of that image, not PNG pixels: divide a pixel by scale. click and scroll use those points. scroll posts a wheel event at the point (positive dx is right, positive dy is down). type sends text. key is one key (return, tab, escape, arrows, delete, or one character) with optional modifiers command, shift, option, control. Use it to check behavior and visual design (hierarchy, alignment, spacing, type, contrast, fit with the surrounding surface). preview=window means the Electron window, not a browser tab. Sideboard needs Accessibility and Screen Recording permission. Do not drive an app you did not start for this test.";
1079
+ var COMPUTER_USE_DESCRIPTION = "Drive this Mac to test an app you started. Off unless Settings \u2192 Advanced \u2192 Computer use is on. action is screenshot, click, type, key, or scroll. screenshot writes a PNG of the main display under the worktree .context/cli/ and returns that path plus point width, height, and scale. Read the image. x and y are screen points from the top-left of that image, not PNG pixels: divide a pixel by scale. click and scroll use those points. scroll posts a wheel event at the point (positive dx is right, positive dy is down). type sends text. key is one key (return, tab, escape, arrows, delete, or one character) with optional modifiers command, shift, option, control. Use it to check behavior and visual design (hierarchy, alignment, spacing, type, contrast, fit with the surrounding surface). preview=window means the Electron window, not a browser tab. Clicks, typing, scrolling, and screenshots are posted by Sideboard after macOS allows Sideboard to control this Mac and record the screen. Do not drive an app you did not start for this test.";
1074
1080
  var PNG_SIG = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
1075
1081
 
1076
1082
  // src/agent-rpc/client.ts
@@ -1097,14 +1103,14 @@ function parseRpcFrame(raw) {
1097
1103
  }
1098
1104
 
1099
1105
  // src/agent-rpc/metadata.ts
1100
- var import_node_fs17 = require("fs");
1101
- var import_node_path19 = require("path");
1106
+ var import_node_fs18 = require("fs");
1107
+ var import_node_path20 = require("path");
1102
1108
  function agentRuntimeMetadataPath() {
1103
- return (0, import_node_path19.join)(appDataDir(), "agent-runtime.json");
1109
+ return (0, import_node_path20.join)(appDataDir(), "agent-runtime.json");
1104
1110
  }
1105
1111
  function readAgentRuntimeMetadata() {
1106
1112
  try {
1107
- const raw = JSON.parse((0, import_node_fs17.readFileSync)(agentRuntimeMetadataPath(), "utf8"));
1113
+ const raw = JSON.parse((0, import_node_fs18.readFileSync)(agentRuntimeMetadataPath(), "utf8"));
1108
1114
  if (!raw || typeof raw !== "object") return null;
1109
1115
  const rec = raw;
1110
1116
  if (typeof rec.runtimeId !== "string" || !rec.runtimeId.trim()) return null;
@@ -1472,8 +1478,8 @@ function sideboardCursorRpcTools(opts) {
1472
1478
  }
1473
1479
 
1474
1480
  // src/agents/tool-result-clip.ts
1475
- var import_node_fs18 = require("fs");
1476
- var import_node_path20 = require("path");
1481
+ var import_node_fs19 = require("fs");
1482
+ var import_node_path21 = require("path");
1477
1483
 
1478
1484
  // src/paths/workspace-scratch.ts
1479
1485
  var CLI_DIR = ".context/cli";
@@ -1482,15 +1488,15 @@ var CLI_DIR = ".context/cli";
1482
1488
  function spillPath(cwd, prefix) {
1483
1489
  const stamp = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
1484
1490
  const safe = prefix.replace(/[^a-zA-Z0-9_-]+/g, "-").slice(0, 40) || "tool";
1485
- return (0, import_node_path20.join)(cwd, CLI_DIR, `${safe}-${stamp}.txt`);
1491
+ return (0, import_node_path21.join)(cwd, CLI_DIR, `${safe}-${stamp}.txt`);
1486
1492
  }
1487
1493
  function spillToolResultToCli(content, opts) {
1488
1494
  const cwd = opts?.cwd?.trim();
1489
1495
  if (!cwd || !content) return null;
1490
1496
  const file = spillPath(cwd, opts?.prefix ?? "tool-result");
1491
1497
  try {
1492
- (0, import_node_fs18.mkdirSync)((0, import_node_path20.join)(cwd, CLI_DIR), { recursive: true });
1493
- (0, import_node_fs18.writeFileSync)(file, content, "utf8");
1498
+ (0, import_node_fs19.mkdirSync)((0, import_node_path21.join)(cwd, CLI_DIR), { recursive: true });
1499
+ (0, import_node_fs19.writeFileSync)(file, content, "utf8");
1494
1500
  return file;
1495
1501
  } catch {
1496
1502
  return null;
@@ -2009,7 +2015,7 @@ function emit(event) {
2009
2015
  }
2010
2016
  function localAgentStore(Store, threadId) {
2011
2017
  const root = cursorSdkStoreDir(threadId);
2012
- (0, import_node_fs19.mkdirSync)(root, { recursive: true });
2018
+ (0, import_node_fs20.mkdirSync)(root, { recursive: true });
2013
2019
  return new Store(root);
2014
2020
  }
2015
2021
  async function readStdinJson() {
@@ -5,7 +5,7 @@ import {
5
5
  guardCursorCustomTool,
6
6
  shouldReturnRunErrorToAgent,
7
7
  sideboardCursorRpcTools
8
- } from "../chunk-V2G6AGWM.js";
8
+ } from "../chunk-AF5K6GQU.js";
9
9
  import {
10
10
  createAgentStreamCoalescer
11
11
  } from "../chunk-AXQ4ZWHK.js";
@@ -35,7 +35,7 @@ import {
35
35
  cursorSdkStoreDir
36
36
  } from "../chunk-LG6RJBIY.js";
37
37
  import "../chunk-R4W4VQJZ.js";
38
- import "../chunk-PS6TD5MQ.js";
38
+ import "../chunk-EAV2ZF5S.js";
39
39
  import {
40
40
  dropNestedElectronEnvFromProcess
41
41
  } from "../chunk-4TR3HZFT.js";
@@ -40,7 +40,7 @@ import {
40
40
  planModeTurnInstruction,
41
41
  resolveCursorModelId,
42
42
  resolveQuotaFallbackAgent
43
- } from "./chunk-UDTFOKVX.js";
43
+ } from "./chunk-Z3CGD5HC.js";
44
44
  import {
45
45
  getAgentSetupInfo,
46
46
  installAgent,
@@ -100,7 +100,7 @@ import {
100
100
  resolveCommandBinarySync,
101
101
  withExportedPath
102
102
  } from "./chunk-R4W4VQJZ.js";
103
- import "./chunk-PS6TD5MQ.js";
103
+ import "./chunk-EAV2ZF5S.js";
104
104
  import {
105
105
  ORCHESTRATOR_AGENT_KINDS,
106
106
  assertOrchestratorCapableAgent,
@@ -49,7 +49,7 @@ import {
49
49
  resolveCursorSdkRoot,
50
50
  resolveQuotaFallbackAgent,
51
51
  turnCostUsdFromCursorUsage
52
- } from "./chunk-PR5TOSRD.js";
52
+ } from "./chunk-MX2XU4BS.js";
53
53
  import "./chunk-LESWJ7L4.js";
54
54
  import {
55
55
  getAgentSetupInfo,
@@ -14,7 +14,7 @@ import {
14
14
  WAIT_FOR_TURN_DESCRIPTION,
15
15
  WAIT_FOR_TURN_SCHEMA,
16
16
  createPilotRpcExecutors
17
- } from "./chunk-PS6TD5MQ.js";
17
+ } from "./chunk-EAV2ZF5S.js";
18
18
 
19
19
  // src/agents/tool-result-clip.ts
20
20
  import { mkdirSync, writeFileSync } from "fs";
@@ -129,15 +129,144 @@ function agentRuntimeLooksLive(meta = readAgentRuntimeMetadata()) {
129
129
  return pidAlive(meta.pid);
130
130
  }
131
131
 
132
+ // src/computer-use/bridge.ts
133
+ import { readFileSync as readFileSync2 } from "fs";
134
+ import { join as join2 } from "path";
135
+ function computerUseBridgePath() {
136
+ return join2(appDataDir(), "computer-use-bridge.json");
137
+ }
138
+ var MODIFIERS = /* @__PURE__ */ new Set(["command", "cmd", "shift", "option", "alt", "control", "ctrl"]);
139
+ function readComputerUseBridge(file = computerUseBridgePath()) {
140
+ try {
141
+ const raw = JSON.parse(readFileSync2(file, "utf8"));
142
+ if (typeof raw.port !== "number" || !Number.isInteger(raw.port)) return null;
143
+ if (raw.port < 1 || raw.port > 65535) return null;
144
+ if (typeof raw.token !== "string" || raw.token.length < 16) return null;
145
+ return { port: raw.port, token: raw.token };
146
+ } catch {
147
+ return null;
148
+ }
149
+ }
150
+ function intIn(value, min, max) {
151
+ if (typeof value !== "number" || !Number.isInteger(value)) return null;
152
+ if (value < min || value > max) return null;
153
+ return value;
154
+ }
155
+ function parseComputerUseInput(value) {
156
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
157
+ const rec = value;
158
+ if (rec.type === "click") {
159
+ const x = intIn(rec.x, -8e3, 2e4);
160
+ const y = intIn(rec.y, -8e3, 2e4);
161
+ if (x === null || y === null) return null;
162
+ return { type: "click", x, y };
163
+ }
164
+ if (rec.type === "type") {
165
+ if (typeof rec.text !== "string" || !rec.text || rec.text.length > 2e3) return null;
166
+ return { type: "type", text: rec.text };
167
+ }
168
+ if (rec.type === "key") {
169
+ if (typeof rec.key !== "string" || !rec.key || rec.key.length > 32) return null;
170
+ if (!Array.isArray(rec.modifiers) || rec.modifiers.length > 4) return null;
171
+ const modifiers = [];
172
+ for (const item of rec.modifiers) {
173
+ if (typeof item !== "string" || !MODIFIERS.has(item)) return null;
174
+ modifiers.push(item);
175
+ }
176
+ return { type: "key", key: rec.key, modifiers };
177
+ }
178
+ if (rec.type === "scroll") {
179
+ const x = intIn(rec.x, -8e3, 2e4);
180
+ const y = intIn(rec.y, -8e3, 2e4);
181
+ const dx = intIn(rec.dx, -4e3, 4e3);
182
+ const dy = intIn(rec.dy, -4e3, 4e3);
183
+ if (x === null || y === null || dx === null || dy === null) return null;
184
+ if (dx === 0 && dy === 0) return null;
185
+ return { type: "scroll", x, y, dx, dy };
186
+ }
187
+ return null;
188
+ }
189
+ function cgModifierFlags(modifiers) {
190
+ let flags = 0;
191
+ for (const name of modifiers) {
192
+ if (name === "shift") flags |= 131072;
193
+ else if (name === "ctrl" || name === "control") flags |= 262144;
194
+ else if (name === "alt" || name === "option") flags |= 524288;
195
+ else if (name === "cmd" || name === "command") flags |= 1048576;
196
+ }
197
+ return flags;
198
+ }
199
+ function cgScrollWheels(dx, dy) {
200
+ return { wheel1: -dy, wheel2: -dx };
201
+ }
202
+ var MODIFIER_KEY_CODES = {
203
+ command: 55,
204
+ cmd: 55,
205
+ shift: 56,
206
+ option: 58,
207
+ alt: 58,
208
+ control: 59,
209
+ ctrl: 59
210
+ };
211
+ function modifierKeyCode(name) {
212
+ const code = MODIFIER_KEY_CODES[name];
213
+ return code === void 0 ? null : code;
214
+ }
215
+ async function bridgeError(res) {
216
+ try {
217
+ const body = await res.json();
218
+ if (typeof body.error === "string" && body.error) return body.error;
219
+ } catch {
220
+ }
221
+ return `computer use bridge returned ${res.status}`;
222
+ }
223
+ async function bridgeFetch(info, path, init) {
224
+ try {
225
+ return await fetch(`http://127.0.0.1:${info.port}${path}`, {
226
+ ...init,
227
+ headers: {
228
+ authorization: `Bearer ${info.token}`,
229
+ ...init.headers
230
+ },
231
+ signal: AbortSignal.timeout(15e3)
232
+ });
233
+ } catch {
234
+ return null;
235
+ }
236
+ }
237
+ async function postComputerUseBridge(event, file = computerUseBridgePath()) {
238
+ const info = readComputerUseBridge(file);
239
+ if (!info) return false;
240
+ const res = await bridgeFetch(info, "/v1/event", {
241
+ method: "POST",
242
+ headers: { "content-type": "application/json" },
243
+ body: JSON.stringify(event)
244
+ });
245
+ if (!res) return false;
246
+ if (!res.ok) throw new Error(await bridgeError(res));
247
+ return true;
248
+ }
249
+ async function fetchComputerUseScreenshot(file = computerUseBridgePath()) {
250
+ const info = readComputerUseBridge(file);
251
+ if (!info) return null;
252
+ const res = await bridgeFetch(info, "/v1/screenshot", { method: "POST" });
253
+ if (!res) return null;
254
+ if (!res.ok) throw new Error(await bridgeError(res));
255
+ const png = Buffer.from(await res.arrayBuffer());
256
+ if (png.length < 24) throw new Error("screen capture was empty");
257
+ const header = Number(res.headers.get("x-sideboard-scale"));
258
+ return { png, scale: Number.isFinite(header) && header > 0 ? header : 1 };
259
+ }
260
+
132
261
  // src/computer-use/computer-use.ts
133
262
  import { execFile } from "child_process";
134
- import { mkdirSync, readFileSync as readFileSync2 } from "fs";
263
+ import { mkdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
135
264
  import { tmpdir } from "os";
136
- import { isAbsolute, join as join2 } from "path";
265
+ import { isAbsolute, join as join3 } from "path";
137
266
  import { promisify } from "util";
138
267
  var execFileAsync = promisify(execFile);
139
268
  var COMPUTER_USE_OFF = "Computer use is off. Turn it on in Settings \u2192 Advanced.";
140
- var COMPUTER_USE_DESCRIPTION = "Drive this Mac to test an app you started. Off unless Settings \u2192 Advanced \u2192 Computer use is on. action is screenshot, click, type, key, or scroll. screenshot writes a PNG of the main display under the worktree .context/cli/ and returns that path plus point width, height, and scale. Read the image. x and y are screen points from the top-left of that image, not PNG pixels: divide a pixel by scale. click and scroll use those points. scroll posts a wheel event at the point (positive dx is right, positive dy is down). type sends text. key is one key (return, tab, escape, arrows, delete, or one character) with optional modifiers command, shift, option, control. Use it to check behavior and visual design (hierarchy, alignment, spacing, type, contrast, fit with the surrounding surface). preview=window means the Electron window, not a browser tab. Sideboard needs Accessibility and Screen Recording permission. Do not drive an app you did not start for this test.";
269
+ var COMPUTER_USE_DESCRIPTION = "Drive this Mac to test an app you started. Off unless Settings \u2192 Advanced \u2192 Computer use is on. action is screenshot, click, type, key, or scroll. screenshot writes a PNG of the main display under the worktree .context/cli/ and returns that path plus point width, height, and scale. Read the image. x and y are screen points from the top-left of that image, not PNG pixels: divide a pixel by scale. click and scroll use those points. scroll posts a wheel event at the point (positive dx is right, positive dy is down). type sends text. key is one key (return, tab, escape, arrows, delete, or one character) with optional modifiers command, shift, option, control. Use it to check behavior and visual design (hierarchy, alignment, spacing, type, contrast, fit with the surrounding surface). preview=window means the Electron window, not a browser tab. Clicks, typing, scrolling, and screenshots are posted by Sideboard after macOS allows Sideboard to control this Mac and record the screen. Do not drive an app you did not start for this test.";
141
270
  var KEY_CODES = {
142
271
  return: 36,
143
272
  enter: 36,
@@ -152,7 +281,11 @@ var KEY_CODES = {
152
281
  down: 125,
153
282
  up: 126
154
283
  };
155
- var MODIFIERS = /* @__PURE__ */ new Set(["command", "cmd", "shift", "option", "alt", "control", "ctrl"]);
284
+ var MODIFIERS2 = /* @__PURE__ */ new Set(["command", "cmd", "shift", "option", "alt", "control", "ctrl"]);
285
+ function macKeyCode(key) {
286
+ const code = KEY_CODES[key];
287
+ return code === void 0 ? null : code;
288
+ }
156
289
  var PNG_SIG = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
157
290
  function appleScriptString(text) {
158
291
  return `"${text.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
@@ -220,8 +353,7 @@ function scrollWheelSwift(x, y, dx, dy) {
220
353
  for (const n of [x, y, dx, dy]) {
221
354
  if (!Number.isInteger(n)) throw new Error("scroll coordinates must be integers");
222
355
  }
223
- const wheel1 = -dy;
224
- const wheel2 = -dx;
356
+ const { wheel1, wheel2 } = cgScrollWheels(dx, dy);
225
357
  return `import CoreGraphics
226
358
  let src = CGEventSource(stateID: .hidSystemState)
227
359
  let p = CGPoint(x: ${x}, y: ${y})
@@ -253,9 +385,13 @@ function scrollDelta(value) {
253
385
  }
254
386
  function screenshotFile(cwd, now) {
255
387
  const root = isAbsolute(cwd) ? cwd : tmpdir();
256
- const dir = join2(root, ".context", "cli");
388
+ const dir = join3(root, ".context", "cli");
257
389
  mkdirSync(dir, { recursive: true });
258
- return join2(dir, `computer-use-${now}.png`);
390
+ return join3(dir, `computer-use-${now}.png`);
391
+ }
392
+ async function posted(runner, event) {
393
+ if (!runner.postInput) return false;
394
+ return runner.postInput(event);
259
395
  }
260
396
  function screenshotMessage(width, height, scale) {
261
397
  return `Screenshot saved (main display). Read that PNG. x and y are screen points from the top-left of this image, not PNG pixels. Divide a pixel by scale ${scale}. Point size is ${width}\xD7${height}. Judge behavior and visual design: hierarchy, alignment, spacing, type, contrast, and fit with the surrounding surface.`;
@@ -286,17 +422,21 @@ async function performComputerUse(opts) {
286
422
  const px = point(x);
287
423
  const py = point(y);
288
424
  if (px === null || py === null) return { ok: false, error: "click point is out of range" };
289
- await opts.runner.runAppleScript(
290
- `tell application "System Events" to click at {${px}, ${py}}`
291
- );
425
+ if (!await posted(opts.runner, { type: "click", x: px, y: py })) {
426
+ await opts.runner.runAppleScript(
427
+ `tell application "System Events" to click at {${px}, ${py}}`
428
+ );
429
+ }
292
430
  return { ok: true, action, message: `Clicked ${px}, ${py}.` };
293
431
  }
294
432
  if (action === "type") {
295
433
  const text = typeof rec.text === "string" ? rec.text : "";
296
434
  if (!text) return { ok: false, error: "type requires text" };
297
435
  if (text.length > 2e3) return { ok: false, error: "type text is longer than 2000 characters" };
298
- for (const script of typeScripts(text)) {
299
- await opts.runner.runAppleScript(script);
436
+ if (!await posted(opts.runner, { type: "type", text })) {
437
+ for (const script of typeScripts(text)) {
438
+ await opts.runner.runAppleScript(script);
439
+ }
300
440
  }
301
441
  return { ok: true, action, message: `Typed ${text.length} characters.` };
302
442
  }
@@ -304,14 +444,17 @@ async function performComputerUse(opts) {
304
444
  const key = typeof rec.key === "string" ? rec.key.trim().toLowerCase() : "";
305
445
  const modifiers = Array.isArray(rec.modifiers) ? rec.modifiers.filter((item) => typeof item === "string") : [];
306
446
  if (!key) return { ok: false, error: "key requires key" };
307
- if (modifiers.some((name) => !MODIFIERS.has(name.toLowerCase()))) {
447
+ if (modifiers.some((name) => !MODIFIERS2.has(name.toLowerCase()))) {
308
448
  return { ok: false, error: "key modifiers are command, shift, option, and control" };
309
449
  }
310
- const using = modifierClause(modifiers.map((name) => name.toLowerCase()));
311
- const code = KEY_CODES[key];
312
- const script = code !== void 0 ? `tell application "System Events" to key code ${code}${using}` : key.length === 1 ? `tell application "System Events" to keystroke ${appleScriptString(key)}${using}` : "";
450
+ const mods = modifiers.map((name) => name.toLowerCase());
451
+ const using = modifierClause(mods);
452
+ const code = macKeyCode(key);
453
+ const script = code !== null ? `tell application "System Events" to key code ${code}${using}` : key.length === 1 ? `tell application "System Events" to keystroke ${appleScriptString(key)}${using}` : "";
313
454
  if (!script) return { ok: false, error: `unsupported key ${key}` };
314
- await opts.runner.runAppleScript(script);
455
+ if (!await posted(opts.runner, { type: "key", key, modifiers: mods })) {
456
+ await opts.runner.runAppleScript(script);
457
+ }
315
458
  return { ok: true, action, message: `Pressed ${key}.` };
316
459
  }
317
460
  if (action === "scroll") {
@@ -327,7 +470,9 @@ async function performComputerUse(opts) {
327
470
  const sdy = scrollDelta(dy);
328
471
  if (sdx === null || sdy === null) return { ok: false, error: "scroll delta is out of range" };
329
472
  if (sdx === 0 && sdy === 0) return { ok: false, error: "scroll requires dx or dy" };
330
- await opts.runner.scroll(px, py, sdx, sdy);
473
+ if (!await posted(opts.runner, { type: "scroll", x: px, y: py, dx: sdx, dy: sdy })) {
474
+ await opts.runner.scroll(px, py, sdx, sdy);
475
+ }
331
476
  return {
332
477
  ok: true,
333
478
  action,
@@ -348,14 +493,23 @@ function formatComputerUseHint(enabled) {
348
493
  }
349
494
  var macosComputerUseRunner = {
350
495
  async screenshot(file) {
496
+ const via = await fetchComputerUseScreenshot();
497
+ if (via) {
498
+ writeFileSync2(file, via.png);
499
+ const info = pngPointSize(via.png);
500
+ return { ...info, scale: via.scale > 0 ? via.scale : info.scale };
501
+ }
351
502
  await execFileAsync("screencapture", ["-x", "-m", file]);
352
- return pngPointSize(readFileSync2(file));
503
+ return pngPointSize(readFileSync3(file));
353
504
  },
354
505
  async runAppleScript(script) {
355
506
  await execFileAsync("osascript", ["-e", script]);
356
507
  },
357
508
  async scroll(x, y, dx, dy) {
358
509
  await execFileAsync("swift", ["-e", scrollWheelSwift(x, y, dx, dy)]);
510
+ },
511
+ postInput(event) {
512
+ return postComputerUseBridge(event);
359
513
  }
360
514
  };
361
515
 
@@ -674,7 +828,23 @@ export {
674
828
  readAgentRuntimeMetadata,
675
829
  agentRpcConnectFromMetadata,
676
830
  clearAgentRuntimeMetadataIfOwned,
831
+ computerUseBridgePath,
832
+ readComputerUseBridge,
833
+ parseComputerUseInput,
834
+ cgModifierFlags,
835
+ cgScrollWheels,
836
+ modifierKeyCode,
837
+ postComputerUseBridge,
838
+ fetchComputerUseScreenshot,
839
+ COMPUTER_USE_OFF,
677
840
  COMPUTER_USE_DESCRIPTION,
841
+ macKeyCode,
842
+ appleScriptString,
843
+ typeScripts,
844
+ modifierClause,
845
+ pngPointSize,
846
+ pointGeometry,
847
+ scrollWheelSwift,
678
848
  performComputerUse,
679
849
  formatComputerUseHint,
680
850
  macosComputerUseRunner,
@@ -15,7 +15,7 @@ import {
15
15
  parseSessionQuotaResetAt,
16
16
  planModeTurnInstruction,
17
17
  resolveQuotaFallbackAgent
18
- } from "./chunk-PR5TOSRD.js";
18
+ } from "./chunk-MX2XU4BS.js";
19
19
  import {
20
20
  applyWorktreePkgCacheEnv,
21
21
  askBlockStillWaiting,
@@ -873,8 +873,6 @@ async function removeWorktreeDroppingLeftovers(thread, deleteBranch) {
873
873
  }
874
874
 
875
875
  // src/git/agent-git-actions.ts
876
- import { existsSync } from "fs";
877
- import { join as join2 } from "path";
878
876
  var ANNOUNCE_AFTER_MERGE = "After that merge to the default branch succeeds, follow `.claude/skills/announce-on-x/SKILL.md` (`/announce-on-x`) before the turn ends. Post or skip each pull request that merge landed on the default branch. Do not schedule a catch-up.";
879
877
  var AGENT_GIT_ACTIONS = [
880
878
  "commit-push",
@@ -1008,10 +1006,6 @@ function entireGitActionExpansion(action, base) {
1008
1006
  return "This phrase is the explicit ask to merge this thread's Trail change with `entire trail merge`. Do not force-push main/master or merge locally into the main checkout. Do not use `gh`.";
1009
1007
  }
1010
1008
  }
1011
- function worktreeHasAnnounceSkill(worktreePath) {
1012
- const root = worktreePath?.trim();
1013
- return !!root && existsSync(join2(root, ".claude/skills/announce-on-x/SKILL.md"));
1014
- }
1015
1009
  function expandCanonicalGitRequest(prompt, opts) {
1016
1010
  const trimmed = prompt.trim();
1017
1011
  let action = null;
@@ -1045,7 +1039,7 @@ function expandCanonicalGitRequest(prompt, opts) {
1045
1039
  expansion = forge === "cursor" ? "Investigate that failing check (`origin pr checks`, `origin pr watch`), fix it, commit, and push. Loop only if a goal to keep going until it passes was given. Do not use `gh run`." : forge === "entire" ? "Investigate the blocking gate (`entire trail merge --dry-run`, `entire trail finding list`, `entire trail watch`), fix it, commit, and push. Loop only if a goal to keep going until it passes was given. Do not use `gh run`." : "Investigate that failing check (`gh pr checks`, `gh run view --log-failed`), fix it, commit, and push. Loop only if a goal to keep going until it passes was given.";
1046
1040
  }
1047
1041
  if (!expansion) return prompt;
1048
- if (action === "merge" && (!base || isMainishPrBase(base)) && worktreeHasAnnounceSkill(opts?.worktreePath)) {
1042
+ if (action === "merge" && (!base || isMainishPrBase(base)) && opts?.hasAnnounceSkill) {
1049
1043
  expansion = `${expansion} ${ANNOUNCE_AFTER_MERGE}`;
1050
1044
  }
1051
1045
  if (expansionPushes(action, trimmed)) expansion = withPushReview(expansion);
@@ -1067,6 +1061,14 @@ function expansionPushes(action, prompt) {
1067
1061
  return prompt === "Address review comments." || FIX_CI_RE.test(prompt);
1068
1062
  }
1069
1063
 
1064
+ // src/git/announce-skill.ts
1065
+ import { existsSync } from "fs";
1066
+ import { join as join2 } from "path";
1067
+ function announceSkillPresent(worktreePath) {
1068
+ const root = worktreePath?.trim();
1069
+ return !!root && existsSync(join2(root, ".claude/skills/announce-on-x/SKILL.md"));
1070
+ }
1071
+
1070
1072
  // src/git/pr-merge-archive.ts
1071
1073
  function normalizePrState(state) {
1072
1074
  return (state ?? "").trim().toUpperCase();
@@ -6257,7 +6259,8 @@ function promptForJoinedSteer(input) {
6257
6259
  input.worktreePath,
6258
6260
  expandCanonicalGitRequest(input.latestPrompt, {
6259
6261
  forge: input.gitForge,
6260
- worktreePath: input.worktreePath
6262
+ worktreePath: input.worktreePath,
6263
+ hasAnnounceSkill: announceSkillPresent(input.worktreePath)
6261
6264
  }),
6262
6265
  { attachments: latestAttachments }
6263
6266
  );
@@ -7690,11 +7693,11 @@ function realDeps() {
7690
7693
  parentIdForThread,
7691
7694
  designatedId: designatedOrchestratorId,
7692
7695
  send: async (threadId, prompt) => {
7693
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-5BCHUAFG.js");
7696
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-YCGWSIHF.js");
7694
7697
  await getOrchestrator2().send(threadId, prompt, { followUp: "queue" });
7695
7698
  },
7696
7699
  startOrchestration: async (prompt) => {
7697
- const { startOrchestration: startOrchestration2 } = await import("./orchestrator-5BCHUAFG.js");
7700
+ const { startOrchestration: startOrchestration2 } = await import("./orchestrator-YCGWSIHF.js");
7698
7701
  const defaults = resolveOrchestratorDefaults();
7699
7702
  await startOrchestration2({
7700
7703
  goal: prompt,
@@ -7721,7 +7724,7 @@ function formatScheduledPrompt(name, prompt) {
7721
7724
  ${prompt}`;
7722
7725
  }
7723
7726
  async function defaultDeps() {
7724
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-5BCHUAFG.js");
7727
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-YCGWSIHF.js");
7725
7728
  const orch = getOrchestrator2();
7726
7729
  return {
7727
7730
  findThread: (id) => findThreadByRef(id),
@@ -7922,7 +7925,7 @@ ${item.prompt}`);
7922
7925
  }
7923
7926
  }
7924
7927
  async function defaultSend(id, prompt) {
7925
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-5BCHUAFG.js");
7928
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-YCGWSIHF.js");
7926
7929
  await getOrchestrator2().send(id, prompt, { followUp: "join" });
7927
7930
  }
7928
7931
  function armChatFollowUps() {
@@ -8838,7 +8841,8 @@ var Orchestrator = class {
8838
8841
  const turnOrigin = thread.worktreePath?.trim() ? await resolveOriginRemote(thread.worktreePath).catch(() => null) : null;
8839
8842
  const gitPrompt = expandCanonicalGitRequest(promptText, {
8840
8843
  forge: turnOrigin?.forge,
8841
- worktreePath: thread.worktreePath
8844
+ worktreePath: thread.worktreePath,
8845
+ hasAnnounceSkill: announceSkillPresent(thread.worktreePath)
8842
8846
  });
8843
8847
  const expandedAttachments = openSteerTurnAttachments(this.openSteerPrompt.get(threadId), turnAttachments, autoContinue);
8844
8848
  const { agentPrompt: expandedPrompt } = expandComposerPrompt(