@cydm/pie 4.12.0 → 4.12.2
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/builtin/extensions/im-forward/index.js +40 -15
- package/dist/builtin/extensions/pie-proc/index.js +2 -2
- package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +15 -6
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +163 -14
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/chunk-NL3FSRAW.js +1575 -0
- package/dist/builtin/skills/chrome-devtools-axi/{cli-K7ESY3XD.js → cli-QAJYAXI4.js} +98 -109
- package/dist/builtin/skills/computer-use-axi/SKILL.md +11 -7
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +43 -17
- package/dist/chunks/chunk-Q4NJEPIZ.js +210 -0
- package/dist/chunks/{chunk-322WLBDY.js → chunk-Q5PSWX3B.js} +3 -3
- package/dist/chunks/{chunk-6U6UGM4C.js → chunk-Y6AVNVOD.js} +31 -1
- package/dist/chunks/chunk-ZB5FVHI7.js +618 -0
- package/dist/chunks/{manager-cli-B6GIYTI7.js → manager-cli-OTIMAWO6.js} +246 -287
- package/dist/chunks/{manager-upgrade-WHER3WTJ.js → manager-upgrade-DYRQ7YZ5.js} +70 -213
- package/dist/cli.js +3 -3
- package/package.json +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/chunk-HAUDUMDO.js +0 -795
- package/dist/chunks/chunk-BSITHT43.js +0 -127
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-42SGITKJ.js";
|
|
5
5
|
import {
|
|
6
6
|
BRIDGE_PORT_IN_USE_EXIT_CODE,
|
|
7
|
+
BRIDGE_PROFILE_IN_USE_EXIT_CODE,
|
|
7
8
|
DEFAULT_SESSION_NAME,
|
|
8
9
|
PAGE_IDENTITY_CHANGED_ERROR,
|
|
9
10
|
cleanupOwnedProfileDir,
|
|
@@ -17,6 +18,8 @@ import {
|
|
|
17
18
|
needsPageId,
|
|
18
19
|
overlaySessionSelected,
|
|
19
20
|
parsePagesList,
|
|
21
|
+
pruneStaleSessionDirs,
|
|
22
|
+
reapPersistentProfileForDeadOwner,
|
|
20
23
|
rememberToolRouting,
|
|
21
24
|
resolveBridgeScript,
|
|
22
25
|
resolveSessionLogFile,
|
|
@@ -26,8 +29,9 @@ import {
|
|
|
26
29
|
resolveSessionStartLockFile,
|
|
27
30
|
resolveSessionStateDir,
|
|
28
31
|
setSelectedPageId,
|
|
32
|
+
tryAcquireAtomicLockFile,
|
|
29
33
|
writeAllocatedSessionPort
|
|
30
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-NL3FSRAW.js";
|
|
31
35
|
import "./chunk-OJ6N23UZ.js";
|
|
32
36
|
|
|
33
37
|
// ../../node_modules/chrome-devtools-axi/node_modules/@toon-format/toon/dist/index.mjs
|
|
@@ -1625,7 +1629,6 @@ function installSessionStartHooks(options = {}) {
|
|
|
1625
1629
|
|
|
1626
1630
|
// vendor/chrome-devtools-axi/src/client.ts
|
|
1627
1631
|
import { execFileSync, spawn as spawn2 } from "node:child_process";
|
|
1628
|
-
import { randomUUID } from "node:crypto";
|
|
1629
1632
|
import {
|
|
1630
1633
|
closeSync,
|
|
1631
1634
|
existsSync as existsSync3,
|
|
@@ -1633,8 +1636,7 @@ import {
|
|
|
1633
1636
|
openSync,
|
|
1634
1637
|
readFileSync as readFileSync3,
|
|
1635
1638
|
statSync as statSync2,
|
|
1636
|
-
unlinkSync
|
|
1637
|
-
writeFileSync as writeFileSync2
|
|
1639
|
+
unlinkSync
|
|
1638
1640
|
} from "node:fs";
|
|
1639
1641
|
import { request } from "node:http";
|
|
1640
1642
|
import { createServer as createNetServer } from "node:net";
|
|
@@ -2220,6 +2222,17 @@ function buildBridgeEarlyExitError(sessionName, port, code, signal) {
|
|
|
2220
2222
|
"Set a distinct CHROME_DEVTOOLS_AXI_PORT for this session, unset a global CHROME_DEVTOOLS_AXI_PORT so every session derives its own, or free whatever is holding the port."
|
|
2221
2223
|
]);
|
|
2222
2224
|
}
|
|
2225
|
+
if (code === BRIDGE_PROFILE_IN_USE_EXIT_CODE) {
|
|
2226
|
+
return new CdpError(
|
|
2227
|
+
`Persistent Chrome profile is already in use by another running Chrome process or bridge session`,
|
|
2228
|
+
"PROFILE_IN_USE",
|
|
2229
|
+
[
|
|
2230
|
+
"Stop the session currently using this profile (`CHROME_DEVTOOLS_AXI_SESSION=<other> chrome-devtools-axi stop`) or close the Chrome window holding it.",
|
|
2231
|
+
"Or choose a different persistent profile (`CHROME_DEVTOOLS_AXI_PROFILE=<other-name>` / `CHROME_DEVTOOLS_AXI_USER_DATA_DIR=<other-dir>`), or use an ephemeral background browser (`CHROME_DEVTOOLS_AXI_FRESH=1`).",
|
|
2232
|
+
`Inspect bridge diagnostics at: ${resolveSessionLogFile(sessionName)}`
|
|
2233
|
+
]
|
|
2234
|
+
);
|
|
2235
|
+
}
|
|
2223
2236
|
const sharedMcpMode = resolveSharedMcpMode();
|
|
2224
2237
|
if (sharedMcpMode) {
|
|
2225
2238
|
return new CdpError(
|
|
@@ -2246,106 +2259,8 @@ function buildBridgeEarlyExitError(sessionName, port, code, signal) {
|
|
|
2246
2259
|
);
|
|
2247
2260
|
return new CdpError(message, "BRIDGE_NOT_READY", suggestions);
|
|
2248
2261
|
}
|
|
2249
|
-
function
|
|
2250
|
-
|
|
2251
|
-
for (let attempt = 0; attempt < 2; attempt++) {
|
|
2252
|
-
let fd;
|
|
2253
|
-
try {
|
|
2254
|
-
fd = openSync(reclaimFile, "wx");
|
|
2255
|
-
} catch (error) {
|
|
2256
|
-
if (error.code !== "EEXIST") return;
|
|
2257
|
-
try {
|
|
2258
|
-
if (Date.now() - statSync2(reclaimFile).mtimeMs > 5e3) {
|
|
2259
|
-
unlinkSync(reclaimFile);
|
|
2260
|
-
continue;
|
|
2261
|
-
}
|
|
2262
|
-
} catch {
|
|
2263
|
-
continue;
|
|
2264
|
-
}
|
|
2265
|
-
return;
|
|
2266
|
-
}
|
|
2267
|
-
try {
|
|
2268
|
-
closeSync(fd);
|
|
2269
|
-
try {
|
|
2270
|
-
const raw = readFileSync3(lockFile, "utf8");
|
|
2271
|
-
const parsed = JSON.parse(raw);
|
|
2272
|
-
if (expectedToken === void 0 || parsed.token === expectedToken) {
|
|
2273
|
-
unlinkSync(lockFile);
|
|
2274
|
-
}
|
|
2275
|
-
} catch {
|
|
2276
|
-
if (expectedToken === void 0) {
|
|
2277
|
-
try {
|
|
2278
|
-
unlinkSync(lockFile);
|
|
2279
|
-
} catch {
|
|
2280
|
-
}
|
|
2281
|
-
}
|
|
2282
|
-
}
|
|
2283
|
-
} finally {
|
|
2284
|
-
try {
|
|
2285
|
-
unlinkSync(reclaimFile);
|
|
2286
|
-
} catch {
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
return;
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
function tryAcquireStartLock(lockFile, staleMs) {
|
|
2293
|
-
mkdirSync2(dirname3(lockFile), { recursive: true });
|
|
2294
|
-
const token = randomUUID();
|
|
2295
|
-
const payload = JSON.stringify({
|
|
2296
|
-
pid: process.pid,
|
|
2297
|
-
createdAt: Date.now(),
|
|
2298
|
-
token
|
|
2299
|
-
});
|
|
2300
|
-
for (let attempt = 0; attempt < 2; attempt++) {
|
|
2301
|
-
try {
|
|
2302
|
-
const fd = openSync(lockFile, "wx");
|
|
2303
|
-
try {
|
|
2304
|
-
writeFileSync2(fd, payload, "utf8");
|
|
2305
|
-
} finally {
|
|
2306
|
-
closeSync(fd);
|
|
2307
|
-
}
|
|
2308
|
-
let released = false;
|
|
2309
|
-
return {
|
|
2310
|
-
release: () => {
|
|
2311
|
-
if (released) return;
|
|
2312
|
-
released = true;
|
|
2313
|
-
try {
|
|
2314
|
-
const current = JSON.parse(readFileSync3(lockFile, "utf8"));
|
|
2315
|
-
if (current.token === token) unlinkSync(lockFile);
|
|
2316
|
-
} catch {
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
};
|
|
2320
|
-
} catch (error) {
|
|
2321
|
-
if (error.code !== "EEXIST") return null;
|
|
2322
|
-
let stale = false;
|
|
2323
|
-
let observedToken;
|
|
2324
|
-
try {
|
|
2325
|
-
const existing = JSON.parse(readFileSync3(lockFile, "utf8"));
|
|
2326
|
-
const holderPid = typeof existing.pid === "number" ? existing.pid : void 0;
|
|
2327
|
-
const createdAt = typeof existing.createdAt === "number" ? existing.createdAt : 0;
|
|
2328
|
-
observedToken = typeof existing.token === "string" ? existing.token : void 0;
|
|
2329
|
-
if (holderPid !== void 0 && holderPid !== process.pid && !isProcessAlive(holderPid)) {
|
|
2330
|
-
stale = true;
|
|
2331
|
-
} else if (Date.now() - createdAt > staleMs) {
|
|
2332
|
-
stale = true;
|
|
2333
|
-
}
|
|
2334
|
-
} catch {
|
|
2335
|
-
try {
|
|
2336
|
-
if (Date.now() - statSync2(lockFile).mtimeMs > 1e3) stale = true;
|
|
2337
|
-
} catch {
|
|
2338
|
-
stale = true;
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
|
-
if (stale) {
|
|
2342
|
-
reclaimStaleStartLock(lockFile, observedToken);
|
|
2343
|
-
continue;
|
|
2344
|
-
}
|
|
2345
|
-
return null;
|
|
2346
|
-
}
|
|
2347
|
-
}
|
|
2348
|
-
return null;
|
|
2262
|
+
function tryAcquireStartLock(lockFile, _staleMs) {
|
|
2263
|
+
return tryAcquireAtomicLockFile(lockFile);
|
|
2349
2264
|
}
|
|
2350
2265
|
function pinPendingGeneration(pidFile, pidInfo, probePid) {
|
|
2351
2266
|
if (pidInfo && (probePid === void 0 || pidInfo.pid === probePid)) {
|
|
@@ -2501,6 +2416,11 @@ async function ensureBridge(spawnBridge = spawnBridgeProcess, notice) {
|
|
|
2501
2416
|
});
|
|
2502
2417
|
if (pidInfo.ownedProfileDir) {
|
|
2503
2418
|
await cleanupOwnedProfileDir(pidInfo.ownedProfileDir);
|
|
2419
|
+
} else if (pidInfo.persistentProfileDir) {
|
|
2420
|
+
await reapPersistentProfileForDeadOwner(
|
|
2421
|
+
pidInfo.persistentProfileDir,
|
|
2422
|
+
pidInfo
|
|
2423
|
+
);
|
|
2504
2424
|
}
|
|
2505
2425
|
} else {
|
|
2506
2426
|
removePidFile(pidFile, pidInfo.pid);
|
|
@@ -2511,6 +2431,14 @@ async function ensureBridge(spawnBridge = spawnBridgeProcess, notice) {
|
|
|
2511
2431
|
if (reaped.clean) {
|
|
2512
2432
|
removePidFile(pidFile, pidInfo.pid);
|
|
2513
2433
|
}
|
|
2434
|
+
} else if (pidInfo && pidInfo.persistentProfileDir) {
|
|
2435
|
+
const reaped = await reapPersistentProfileForDeadOwner(
|
|
2436
|
+
pidInfo.persistentProfileDir,
|
|
2437
|
+
pidInfo
|
|
2438
|
+
);
|
|
2439
|
+
if (reaped.status === "reaped" || reaped.status === "not_owned") {
|
|
2440
|
+
removePidFile(pidFile, pidInfo.pid);
|
|
2441
|
+
}
|
|
2514
2442
|
}
|
|
2515
2443
|
const startLockFile = resolveSessionStartLockFile(sessionName);
|
|
2516
2444
|
const lockBudgetMs = Math.max(START_LOCK_STALE_MS, resolveBridgeTimeoutMs());
|
|
@@ -2642,10 +2570,24 @@ async function ensureBridge(spawnBridge = spawnBridgeProcess, notice) {
|
|
|
2642
2570
|
throw buildApprovalError(sessionName, racingProbe.reason);
|
|
2643
2571
|
}
|
|
2644
2572
|
if (Date.now() >= lockWaitDeadline) {
|
|
2645
|
-
|
|
2573
|
+
throw new CdpError(
|
|
2574
|
+
`Timed out after ${Math.round(lockBudgetMs / 1e3)}s waiting for session "${sessionName}" startup/prune lock (${startLockFile})`,
|
|
2575
|
+
"BRIDGE_NOT_READY",
|
|
2576
|
+
[
|
|
2577
|
+
"Another chrome-devtools-axi startup or session-prune operation is still holding the lock for this session; retry once it completes.",
|
|
2578
|
+
`If a previous crash left an unreadable lock or .reclaim gate behind, inspect: ${startLockFile}`
|
|
2579
|
+
]
|
|
2580
|
+
);
|
|
2646
2581
|
}
|
|
2647
2582
|
await sleep(100);
|
|
2648
2583
|
}
|
|
2584
|
+
if (!startLock) {
|
|
2585
|
+
throw new CdpError(
|
|
2586
|
+
`Could not acquire startup lock for session "${sessionName}" (${startLockFile})`,
|
|
2587
|
+
"BRIDGE_NOT_READY",
|
|
2588
|
+
[`Inspect lock state at: ${startLockFile}`]
|
|
2589
|
+
);
|
|
2590
|
+
}
|
|
2649
2591
|
try {
|
|
2650
2592
|
clearSelectedPageId();
|
|
2651
2593
|
let portCollisionRetried = false;
|
|
@@ -2820,8 +2762,9 @@ async function ensureBridge(spawnBridge = spawnBridgeProcess, notice) {
|
|
|
2820
2762
|
...sharedMcpSuggestions(sharedMcpMode),
|
|
2821
2763
|
"The shared MCP service may be reachable while its attached Chrome target is unavailable."
|
|
2822
2764
|
] : autoConnect ? [
|
|
2823
|
-
"
|
|
2824
|
-
"For
|
|
2765
|
+
"CHROME_DEVTOOLS_AXI_AUTO_CONNECT=1 attaches to YOUR running Chrome (personal login state included). That requires remote debugging enabled ONCE in Chrome: open chrome://inspect/#remote-debugging and follow the dialog, then re-run. Chrome will ask you to approve each connection.",
|
|
2766
|
+
"For persistent login state without approval prompts or touching personal Chrome, use a dedicated Agent Profile: CHROME_DEVTOOLS_AXI_PROFILE=<name> (log in once with CHROME_DEVTOOLS_AXI_HEADED=1, then reuse headless).",
|
|
2767
|
+
"For a throwaway isolated headless browser instead, unset CHROME_DEVTOOLS_AXI_AUTO_CONNECT or set CHROME_DEVTOOLS_AXI_FRESH=1."
|
|
2825
2768
|
] : [
|
|
2826
2769
|
"The Chrome/Electron instance the bridge was attached to may have exited.",
|
|
2827
2770
|
"Verify the target is still listening on its remote-debugging port, then re-run the command.",
|
|
@@ -3057,9 +3000,11 @@ function mapErrorMessage(message) {
|
|
|
3057
3000
|
async function getSessionSnapshotIfRunning() {
|
|
3058
3001
|
let sessionName;
|
|
3059
3002
|
let pidInfo;
|
|
3003
|
+
let expectedMode;
|
|
3060
3004
|
try {
|
|
3061
3005
|
sessionName = resolveSessionName();
|
|
3062
3006
|
pidInfo = readPidFile(resolveSessionPidFile(sessionName));
|
|
3007
|
+
expectedMode = computeTransportModeFingerprint();
|
|
3063
3008
|
} catch {
|
|
3064
3009
|
return null;
|
|
3065
3010
|
}
|
|
@@ -3068,7 +3013,7 @@ async function getSessionSnapshotIfRunning() {
|
|
|
3068
3013
|
}
|
|
3069
3014
|
const shallow = await probeBridgeHealth(pidInfo.port, {
|
|
3070
3015
|
expectedSession: sessionName,
|
|
3071
|
-
expectedMode
|
|
3016
|
+
expectedMode
|
|
3072
3017
|
});
|
|
3073
3018
|
if (shallow.kind !== "ok" || shallow.busy || shallow.dialogPending || shallow.cdpState !== void 0 && shallow.cdpState !== "connected") {
|
|
3074
3019
|
return null;
|
|
@@ -3136,8 +3081,35 @@ async function stopBridge(options = {}) {
|
|
|
3136
3081
|
removePidFile(pidFile, pidInfo.pid);
|
|
3137
3082
|
clearSelectedPageId();
|
|
3138
3083
|
if (!options.expectedGeneration) clearAllocatedSessionPort(sessionName);
|
|
3084
|
+
try {
|
|
3085
|
+
pruneStaleSessionDirs({ excludeSession: sessionName });
|
|
3086
|
+
} catch {
|
|
3087
|
+
}
|
|
3139
3088
|
return "stopped";
|
|
3140
3089
|
}
|
|
3090
|
+
if (pidInfo.persistentProfileDir) {
|
|
3091
|
+
const reaped = await reapPersistentProfileForDeadOwner(
|
|
3092
|
+
pidInfo.persistentProfileDir,
|
|
3093
|
+
pidInfo
|
|
3094
|
+
);
|
|
3095
|
+
if (reaped.status === "reaped") {
|
|
3096
|
+
removePidFile(pidFile, pidInfo.pid);
|
|
3097
|
+
clearSelectedPageId();
|
|
3098
|
+
if (!options.expectedGeneration) clearAllocatedSessionPort(sessionName);
|
|
3099
|
+
try {
|
|
3100
|
+
pruneStaleSessionDirs({ excludeSession: sessionName });
|
|
3101
|
+
} catch {
|
|
3102
|
+
}
|
|
3103
|
+
return "stopped";
|
|
3104
|
+
}
|
|
3105
|
+
if (reaped.status === "not_owned") {
|
|
3106
|
+
removePidFile(pidFile, pidInfo.pid);
|
|
3107
|
+
clearSelectedPageId();
|
|
3108
|
+
if (!options.expectedGeneration) clearAllocatedSessionPort(sessionName);
|
|
3109
|
+
return "noop";
|
|
3110
|
+
}
|
|
3111
|
+
return "failed";
|
|
3112
|
+
}
|
|
3141
3113
|
return "noop";
|
|
3142
3114
|
}
|
|
3143
3115
|
const verdict = await judgeRecordedBridge(pidInfo, sessionName);
|
|
@@ -3155,11 +3127,21 @@ async function stopBridge(options = {}) {
|
|
|
3155
3127
|
if (terminated && pidInfo.ownedProfileDir) {
|
|
3156
3128
|
const reaped = await cleanupOwnedProfileDir(pidInfo.ownedProfileDir);
|
|
3157
3129
|
profileClean = reaped.clean;
|
|
3130
|
+
} else if (terminated && pidInfo.persistentProfileDir) {
|
|
3131
|
+
const reaped = await reapPersistentProfileForDeadOwner(
|
|
3132
|
+
pidInfo.persistentProfileDir,
|
|
3133
|
+
pidInfo
|
|
3134
|
+
);
|
|
3135
|
+
profileClean = reaped.status === "reaped" || reaped.status === "not_owned";
|
|
3158
3136
|
}
|
|
3159
3137
|
if (terminated && profileClean) {
|
|
3160
3138
|
removePidFile(pidFile, pidInfo.pid);
|
|
3161
3139
|
clearSelectedPageId();
|
|
3162
3140
|
if (!options.expectedGeneration) clearAllocatedSessionPort(sessionName);
|
|
3141
|
+
try {
|
|
3142
|
+
pruneStaleSessionDirs({ excludeSession: sessionName });
|
|
3143
|
+
} catch {
|
|
3144
|
+
}
|
|
3163
3145
|
return "stopped";
|
|
3164
3146
|
}
|
|
3165
3147
|
clearSelectedPageId();
|
|
@@ -3927,7 +3909,14 @@ environment:
|
|
|
3927
3909
|
e.g. "http://127.0.0.1:9222" or "wss://cluster.example/launch"
|
|
3928
3910
|
CHROME_DEVTOOLS_AXI_WS_HEADERS JSON headers for ws(s):// endpoints (only with BROWSER_URL=wss?://)
|
|
3929
3911
|
e.g. '{"Authorization":"Bearer token"}'
|
|
3930
|
-
|
|
3912
|
+
CHROME_DEVTOOLS_AXI_PROFILE Named persistent Agent Profile stored under
|
|
3913
|
+
~/.chrome-devtools-axi/profiles/<name> (skips --isolated,
|
|
3914
|
+
runs headless by default with zero remote-debugging popups).
|
|
3915
|
+
Log in once with CHROME_DEVTOOLS_AXI_HEADED=1, then reuse
|
|
3916
|
+
headless in the background without touching personal Chrome.
|
|
3917
|
+
e.g. CHROME_DEVTOOLS_AXI_PROFILE=work
|
|
3918
|
+
CHROME_DEVTOOLS_AXI_USER_DATA_DIR Explicit persistent Chrome profile directory (skips --isolated;
|
|
3919
|
+
takes precedence over CHROME_DEVTOOLS_AXI_PROFILE)
|
|
3931
3920
|
e.g. "/path/to/.chrome-profile"
|
|
3932
3921
|
CHROME_DEVTOOLS_AXI_MCP_PATH Absolute path to a chrome-devtools-mcp script. When set
|
|
3933
3922
|
without a shared URL, the bridge spawns 'node $MCP_PATH'
|
|
@@ -26,9 +26,13 @@ so you never hijack the user's computer unnecessarily:
|
|
|
26
26
|
default escalation) ONLY when the user explicitly asked for visible/physical
|
|
27
27
|
desktop interaction and no background semantic/CDP path works.
|
|
28
28
|
|
|
29
|
-
First use on macOS installs the `pie-computer-use.app` helper;
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
First use on macOS installs the `pie-computer-use.app` helper; pure semantic
|
|
30
|
+
background flows (`roots`, `observe --mode semantic`, and follow-up
|
|
31
|
+
`search`/`expand`/`inspect`/`wait`/`act` without screenshots or OCR) require
|
|
32
|
+
only **Accessibility** and write zero image artifacts. Fused/visual observation
|
|
33
|
+
and OCR (`read_text`, `--mode fused`/`visual`) also require **Screen
|
|
34
|
+
Recording**. Use the real non-TUI setup flow (the user grants toggles in macOS
|
|
35
|
+
Settings):
|
|
32
36
|
|
|
33
37
|
```bash
|
|
34
38
|
node <baseDir>/computer-use-axi-cli.js permissions setup
|
|
@@ -157,10 +161,10 @@ node <baseDir>/computer-use-axi-cli.js act --state S1 --actions '[
|
|
|
157
161
|
- On failure the output still names the successor state — inspect it instead
|
|
158
162
|
of blindly replaying.
|
|
159
163
|
- Acting requires the platform helper: on macOS first use installs
|
|
160
|
-
`pie-computer-use.app`
|
|
161
|
-
|
|
162
|
-
`node <baseDir>/scripts/setup-helper.mjs`
|
|
163
|
-
retry.
|
|
164
|
+
`pie-computer-use.app` (Accessibility only for pure `--mode semantic`
|
|
165
|
+
workflows; Accessibility + Screen Recording for `fused`/`visual` modes). If a
|
|
166
|
+
helper/setup error appears, run `node <baseDir>/scripts/setup-helper.mjs`
|
|
167
|
+
once, grant the required permission(s), and retry.
|
|
164
168
|
|
|
165
169
|
## Uncertain outcomes
|
|
166
170
|
|
|
@@ -4281,7 +4281,8 @@ async function setupMacosPermissions(mode) {
|
|
|
4281
4281
|
restartHelper: (signal) => macosHelper.restart(signal)
|
|
4282
4282
|
}, mode);
|
|
4283
4283
|
}
|
|
4284
|
-
async function ensureMacosReady(ctx, state, signal) {
|
|
4284
|
+
async function ensureMacosReady(ctx, state, signal, options) {
|
|
4285
|
+
const requireScreenRecording = options?.requireScreenRecording ?? true;
|
|
4285
4286
|
await macosHelper.ensureInstalled(signal);
|
|
4286
4287
|
if (!await macosHelper.ensureDaemon(signal)) {
|
|
4287
4288
|
throw new Error(`pie-computer-use helper app daemon did not start. Helper app: ${HELPER_APP_PATH}`);
|
|
@@ -4290,29 +4291,43 @@ async function ensureMacosReady(ctx, state, signal) {
|
|
|
4290
4291
|
assertPlatformArchitecture("macOS", helperDiagnostics);
|
|
4291
4292
|
const now = Date.now();
|
|
4292
4293
|
const cachedStatus = state.permissionStatus;
|
|
4293
|
-
const
|
|
4294
|
+
const hasRequiredPermissions = (status) => Boolean(status?.accessibility && (!requireScreenRecording || status?.screenRecording));
|
|
4295
|
+
const canUseCachedPermissions = hasRequiredPermissions(cachedStatus) && now - state.lastPermissionCheckAt < 2e3;
|
|
4294
4296
|
if (canUseCachedPermissions) {
|
|
4295
4297
|
return { ...state, helperDiagnostics };
|
|
4296
4298
|
}
|
|
4297
4299
|
let permissionStatus = await checkPermissions(signal);
|
|
4298
4300
|
let lastPermissionCheckAt = now;
|
|
4299
|
-
if (!autoRestartAttempted && permissionStatusSuggestsHelperRestart(permissionStatus)) {
|
|
4301
|
+
if (requireScreenRecording && !autoRestartAttempted && permissionStatusSuggestsHelperRestart(permissionStatus)) {
|
|
4300
4302
|
autoRestartAttempted = true;
|
|
4301
4303
|
await macosHelper.restart(signal).catch(() => void 0);
|
|
4302
4304
|
permissionStatus = await checkPermissions(signal);
|
|
4303
4305
|
lastPermissionCheckAt = Date.now();
|
|
4304
4306
|
}
|
|
4305
|
-
if (!permissionStatus
|
|
4307
|
+
if (!hasRequiredPermissions(permissionStatus)) {
|
|
4306
4308
|
const attributionHint = permissionStatus.source?.attribution === "caller" ? `Warning: the helper is not running as the installed pie-computer-use.app (executable: ${permissionStatus.source?.executablePath ?? "unknown"}). Grants made now would attach to the launching app instead. Restart Pie so the canonical helper is used.` : void 0;
|
|
4309
|
+
const requiredKinds = requireScreenRecording ? macosPermissionKinds : [macosPermissionKinds[0]];
|
|
4310
|
+
const grantCopy = requireScreenRecording ? GRANT_INSTRUCTIONS : AX_ONLY_GRANT_INSTRUCTIONS;
|
|
4311
|
+
const promptForRequired = requireScreenRecording ? permissionPrompt : (status, helperPath, hint) => [
|
|
4312
|
+
"pie-computer-use needs macOS Accessibility permission for its helper app.",
|
|
4313
|
+
`Accessibility: ${status.accessibility ? "granted" : "missing"}`,
|
|
4314
|
+
"",
|
|
4315
|
+
`Helper: pie-computer-use.app (${helperPath})`,
|
|
4316
|
+
hint,
|
|
4317
|
+
"",
|
|
4318
|
+
`Important: ${SIGNING_MIGRATION_WARNING}`,
|
|
4319
|
+
"",
|
|
4320
|
+
"pie-computer-use.app is already listed in Accessibility \u2014 enable its toggle, then choose Recheck."
|
|
4321
|
+
].filter(Boolean).join("\n");
|
|
4307
4322
|
permissionStatus = await ensurePermissions(
|
|
4308
4323
|
ctx,
|
|
4309
4324
|
{
|
|
4310
|
-
kinds:
|
|
4325
|
+
kinds: requiredKinds,
|
|
4311
4326
|
copy: {
|
|
4312
|
-
nonInteractiveError: (helperPath) => `Run 'computer-use-axi permissions setup' to register the helper and open Settings, grant both permissions, then run 'computer-use-axi permissions recheck'. ${
|
|
4327
|
+
nonInteractiveError: (helperPath) => `Run 'computer-use-axi permissions setup' to register the helper and open Settings, grant ${requireScreenRecording ? "both permissions" : "Accessibility"}, then run 'computer-use-axi permissions recheck'. ${grantCopy}
|
|
4313
4328
|
Helper path: ${helperPath}`,
|
|
4314
|
-
prompt:
|
|
4315
|
-
incompleteError: (helperPath) => `pie-computer-use setup is incomplete. ${
|
|
4329
|
+
prompt: promptForRequired,
|
|
4330
|
+
incompleteError: (helperPath) => `pie-computer-use setup is incomplete. ${grantCopy} Helper path: ${helperPath}`,
|
|
4316
4331
|
readyMessage: "pie-computer-use is ready.",
|
|
4317
4332
|
stillMissing: missingPermissionMessage
|
|
4318
4333
|
},
|
|
@@ -4331,7 +4346,7 @@ Helper path: ${helperPath}`,
|
|
|
4331
4346
|
}
|
|
4332
4347
|
return { permissionStatus, lastPermissionCheckAt, helperDiagnostics };
|
|
4333
4348
|
}
|
|
4334
|
-
var GRANT_INSTRUCTIONS, SIGNING_MIGRATION_WARNING, macosPermissionKinds, registeredForHelperPid, autoRestartAttempted;
|
|
4349
|
+
var AX_ONLY_GRANT_INSTRUCTIONS, GRANT_INSTRUCTIONS, SIGNING_MIGRATION_WARNING, macosPermissionKinds, registeredForHelperPid, autoRestartAttempted;
|
|
4335
4350
|
var init_permissions2 = __esm({
|
|
4336
4351
|
"vendor/computer-use-axi/src/platform/macos/permissions.ts"() {
|
|
4337
4352
|
"use strict";
|
|
@@ -4339,6 +4354,7 @@ var init_permissions2 = __esm({
|
|
|
4339
4354
|
init_coerce();
|
|
4340
4355
|
init_helper();
|
|
4341
4356
|
init_architecture();
|
|
4357
|
+
AX_ONLY_GRANT_INSTRUCTIONS = "Grant Accessibility to pie-computer-use.app in System Settings \u2192 Privacy & Security. Accessibility lets the agent inspect and interact with semantic UI elements without Screen Recording.";
|
|
4342
4358
|
GRANT_INSTRUCTIONS = "Grant Accessibility and Screen Recording to pie-computer-use.app in System Settings \u2192 Privacy & Security. Screen Recording lets the agent see the window; Accessibility lets it interact with the window.";
|
|
4343
4359
|
SIGNING_MIGRATION_WARNING = "If these permissions were enabled before this install/update, macOS invalidated the old grants because pie-computer-use.app was re-signed. Re-enable both toggles for the newly signed helper. If a toggle is already on, switch it off and on again.";
|
|
4344
4360
|
macosPermissionKinds = [
|
|
@@ -9272,7 +9288,7 @@ function currentTargetOrThrow() {
|
|
|
9272
9288
|
function emptyActivation() {
|
|
9273
9289
|
return { activated: false, unminimized: false, raised: false };
|
|
9274
9290
|
}
|
|
9275
|
-
async function ensureReady3(ctx, signal) {
|
|
9291
|
+
async function ensureReady3(ctx, signal, options) {
|
|
9276
9292
|
throwIfAborted3(signal);
|
|
9277
9293
|
const ready = await currentPlatformBackend.ensureReady(
|
|
9278
9294
|
ctx,
|
|
@@ -9281,7 +9297,8 @@ async function ensureReady3(ctx, signal) {
|
|
|
9281
9297
|
lastPermissionCheckAt: runtimeState.lastPermissionCheckAt,
|
|
9282
9298
|
helperDiagnostics: runtimeState.helperDiagnostics
|
|
9283
9299
|
},
|
|
9284
|
-
signal
|
|
9300
|
+
signal,
|
|
9301
|
+
options
|
|
9285
9302
|
);
|
|
9286
9303
|
runtimeState.permissionStatus = ready.permissionStatus;
|
|
9287
9304
|
runtimeState.lastPermissionCheckAt = ready.lastPermissionCheckAt;
|
|
@@ -10233,7 +10250,12 @@ ${viewText2}` }], details: details2 };
|
|
|
10233
10250
|
timeoutMs
|
|
10234
10251
|
}, { signal, timeoutMs: timeoutMs + 2e3 });
|
|
10235
10252
|
if (!state.resourceKey || state.epoch === void 0) throw new Error("The observation has no live resource identity. Observe again.");
|
|
10236
|
-
const
|
|
10253
|
+
const includeImage = state.currentImageMode !== "never";
|
|
10254
|
+
const refreshed = (await resourceScheduler.readAt(
|
|
10255
|
+
state.resourceKey,
|
|
10256
|
+
state.epoch,
|
|
10257
|
+
async () => await captureCurrentTarget(signal, includeImage ? "auto" : "never", AUTO_IMAGE_MAX_DIMENSION, void 0, includeImage)
|
|
10258
|
+
)).value;
|
|
10237
10259
|
const transition = changesBetween(baseView.outline, refreshed.outline);
|
|
10238
10260
|
const useDiff = !transition.useFullView;
|
|
10239
10261
|
const matches = searchOutline(refreshed.outline, text, role, void 0, 1);
|
|
@@ -10329,7 +10351,7 @@ async function performSearchUi(params, signal) {
|
|
|
10329
10351
|
let matches = ranked.matches;
|
|
10330
10352
|
let escalatedOCR = false;
|
|
10331
10353
|
const look = state.currentLook;
|
|
10332
|
-
if (!state.contextId && shouldEscalateSearchOCR(matches, text) && look && look.readText?.requested !== "never" && !look.readText?.executed && state.lastSearchOcrEscalatedLookId !== look.lookId) {
|
|
10354
|
+
if (!state.contextId && state.currentImageMode !== "never" && shouldEscalateSearchOCR(matches, text) && look && look.readText?.requested !== "never" && !look.readText?.executed && state.lastSearchOcrEscalatedLookId !== look.lookId) {
|
|
10333
10355
|
state.lastSearchOcrEscalatedLookId = look.lookId;
|
|
10334
10356
|
const currentTarget = await ensureTargetWindowId(await resolveCurrentTarget(signal), signal);
|
|
10335
10357
|
if (!state.resourceKey || state.epoch === void 0) throw new Error("The observation has no live resource identity. Observe again.");
|
|
@@ -10368,7 +10390,7 @@ async function performExpandUi(params, signal) {
|
|
|
10368
10390
|
const targetWireRef = wireRefForNode(target);
|
|
10369
10391
|
if (!state.resourceKey || state.epoch === void 0) throw new Error("The observation has no live resource identity. Observe again.");
|
|
10370
10392
|
const scoped = (await resourceScheduler.readAt(state.resourceKey, state.epoch, async () => await performLook(currentTarget, {
|
|
10371
|
-
readText: "auto",
|
|
10393
|
+
readText: state.currentImageMode === "never" ? "never" : "auto",
|
|
10372
10394
|
baseLookId: outline.lookId,
|
|
10373
10395
|
scopeRef: targetWireRef,
|
|
10374
10396
|
maxDimension: 1,
|
|
@@ -10566,7 +10588,7 @@ No successor state was created. Call find_roots, then observe_ui to continue.` }
|
|
|
10566
10588
|
}
|
|
10567
10589
|
async function performDesktopTransaction(params, actions, signal) {
|
|
10568
10590
|
const state = operationState();
|
|
10569
|
-
state.currentImageMode = "auto";
|
|
10591
|
+
if (state.currentImageMode !== "never") state.currentImageMode = "auto";
|
|
10570
10592
|
validateStateId(params.stateId);
|
|
10571
10593
|
const look = currentLookOrThrow();
|
|
10572
10594
|
const baseView = { stateId: state.currentCapture.stateId, outline: state.currentOutline };
|
|
@@ -10612,7 +10634,8 @@ async function performDesktopTransaction(params, actions, signal) {
|
|
|
10612
10634
|
} else {
|
|
10613
10635
|
await sleep2(settleMsForExecution(execution), signal);
|
|
10614
10636
|
}
|
|
10615
|
-
const
|
|
10637
|
+
const includeImage = state.currentImageMode !== "never";
|
|
10638
|
+
const capture = await captureCurrentTarget(signal, includeImage ? "auto" : "never", AUTO_IMAGE_MAX_DIMENSION, target, includeImage);
|
|
10616
10639
|
execution.outcome = outcomeAfterObservedValues(execution.outcome ?? "unknown", executedActions, (ref) => nodeByRef(capture.outline, ref)?.value);
|
|
10617
10640
|
for (const action of executedActions) {
|
|
10618
10641
|
state.currentNote = noteAfterAct(state.currentNote ?? noteBefore, action.ref, capture.outline, { window: noteWindowForTarget(capture.target, capture.look), rootDelta: execution.rootDelta });
|
|
@@ -10921,12 +10944,15 @@ async function executeTool(tool, ctx, params, signal, run, runtime) {
|
|
|
10921
10944
|
if (requestedStateId) operation.artifactIds = engineArtifacts?.pinForState(requestedStateId) ?? [];
|
|
10922
10945
|
try {
|
|
10923
10946
|
const browserOnly = operation.contextId || ["launch_browser", "navigate_browser", "evaluate_browser"].includes(tool) || tool === "find_roots" && params.kind === "browser_page" || tool === "observe_ui" && runtimeState.browserContextByRoot.has(params.root ?? "");
|
|
10947
|
+
const observeParams = params;
|
|
10948
|
+
const semanticObserveWithoutOcr = tool === "observe_ui" && observeParams.mode === "semantic" && (observeParams.readText === void 0 || observeParams.readText === "never");
|
|
10949
|
+
const requireScreenRecording = !(tool === "find_roots" || tool === "expand_ui" || tool === "inspect_ui" || semanticObserveWithoutOcr || (tool === "search_ui" || tool === "wait_for" || tool === "act_ui") && operation.currentImageMode === "never");
|
|
10924
10950
|
await resourceScheduler.read("session-lifecycle", async () => {
|
|
10925
10951
|
if (browserOnly || outputRef) {
|
|
10926
10952
|
if (browserOnly && !outputRef && tool !== "find_roots" && !isBrowserUseEnabled()) {
|
|
10927
10953
|
throw new Error("Browser use is disabled by computer-use config. Enable browser_use to control browser pages.");
|
|
10928
10954
|
}
|
|
10929
|
-
} else await ensureReady3(ctx, signal);
|
|
10955
|
+
} else await ensureReady3(ctx, signal, { requireScreenRecording });
|
|
10930
10956
|
}, operation.signal);
|
|
10931
10957
|
throwIfAborted3(signal);
|
|
10932
10958
|
const result = await run();
|