@frontendxlab/opencode-computer-use 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -115,6 +115,22 @@ Use `--dry-run` to inspect the action without changing files. Set
115
115
  skips automatically when `CI=1` or `CI=true`. Restart OpenCode after a
116
116
  successful setup so the plugin is loaded.
117
117
 
118
+ The postinstall flow also runs the native permission check. To rerun it later:
119
+
120
+ ```sh
121
+ npx opencode-computer-use-permissions
122
+ # or, from a pnpm project
123
+ pnpm exec opencode-computer-use-permissions
124
+ ```
125
+
126
+ The command delegates to the native `open-computer-use doctor` flow. macOS runs
127
+ the native Accessibility and Screen Recording onboarding when needed. Linux
128
+ reports AT-SPI and desktop-session requirements. Windows reports UI Automation
129
+ and interactive-session requirements. The command never changes permissions
130
+ automatically. Use `--strict` when a missing or failed native
131
+ check should return a nonzero exit status, or set
132
+ `OPENCODE_COMPUTER_USE_SKIP_PERMISSIONS=1` to skip it.
133
+
118
134
  Recent pnpm releases may require explicit approval before running lifecycle
119
135
  scripts from dependencies. If pnpm reports `ERR_PNPM_IGNORED_BUILDS`, approve
120
136
  this package once and rerun the install:
package/SECURITY.md CHANGED
@@ -28,6 +28,8 @@ sandbox.
28
28
  conflicting or malformed configuration. Ambiguous setup is non-destructive
29
29
  and prints manual instructions. CI and explicit skip environments bypass
30
30
  postinstall mutation.
31
+ - The permission command delegates to the native runtime's `doctor` flow. It
32
+ may open macOS onboarding, but it never grants or changes permissions.
31
33
 
32
34
  ## Operator responsibilities
33
35
 
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from "node:child_process";
4
+ import { realpathSync } from "node:fs";
5
+ import { dirname, resolve } from "node:path";
6
+ import process from "node:process";
7
+ import { fileURLToPath } from "node:url";
8
+ import { backendEnvironment, resolveBackend } from "../lib/backend.js";
9
+
10
+ const SKIP_ENV = "OPENCODE_COMPUTER_USE_SKIP_PERMISSIONS";
11
+ const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
12
+
13
+ function print(text, stream = "stdout") {
14
+ process[stream].write(`${text}\n`);
15
+ }
16
+
17
+ export function usage() {
18
+ return `Usage: opencode-computer-use-permissions [options]
19
+
20
+ Run the native Open Computer Use permission and runtime onboarding check.
21
+
22
+ Options:
23
+ --strict Return a failure when the native check cannot run
24
+ --help, -h Show this help
25
+
26
+ The command uses the installed open-computer-use runtime:
27
+ macOS checks or launches Accessibility and Screen Recording onboarding
28
+ Linux reports AT-SPI and signed-in desktop-session requirements
29
+ Windows reports UI Automation and interactive-session requirements
30
+ `;
31
+ }
32
+
33
+ function parseArguments(argv) {
34
+ const options = { strict: false, help: false };
35
+ for (const argument of argv) {
36
+ if (argument === "--strict") options.strict = true;
37
+ else if (argument === "--help" || argument === "-h") options.help = true;
38
+ else throw new Error(`Unknown permission option: ${argument}`);
39
+ }
40
+ return options;
41
+ }
42
+
43
+ function shouldSkip(env) {
44
+ const developmentInstall = env.npm_lifecycle_event === "postinstall"
45
+ && env.INIT_CWD
46
+ && resolve(env.INIT_CWD) === PACKAGE_ROOT;
47
+ return developmentInstall || env.CI === "true" || env.CI === "1" || env[SKIP_ENV] === "1";
48
+ }
49
+
50
+ export function main(argv = process.argv.slice(2), env = process.env, io = print) {
51
+ let options;
52
+ try {
53
+ options = parseArguments(argv);
54
+ } catch (error) {
55
+ io(`[opencode-computer-use-permissions] ${error instanceof Error ? error.message : String(error)}`, "stderr");
56
+ io(usage(), "stderr");
57
+ return 2;
58
+ }
59
+ if (options.help) {
60
+ io(usage());
61
+ return 0;
62
+ }
63
+ if (shouldSkip(env)) {
64
+ io("OpenCode Computer Use permission onboarding skipped.");
65
+ return 0;
66
+ }
67
+
68
+ let backend;
69
+ try {
70
+ backend = resolveBackend({ backend: "native" }, env);
71
+ } catch (error) {
72
+ const message = error instanceof Error ? error.message : String(error);
73
+ io(`[opencode-computer-use-permissions] Native permission check unavailable: ${message}`);
74
+ if (options.strict) return 1;
75
+ io("Install the optional open-computer-use runtime, then run this command again.");
76
+ return 0;
77
+ }
78
+
79
+ const result = spawnSync(backend.command, ["doctor"], {
80
+ env: backendEnvironment(env),
81
+ stdio: "inherit",
82
+ windowsHide: false,
83
+ timeout: 120_000,
84
+ });
85
+ if (result.error) {
86
+ io(`[opencode-computer-use-permissions] Permission check failed: ${result.error.message}`);
87
+ return options.strict ? 1 : 0;
88
+ }
89
+ if (result.status !== 0) {
90
+ io(`[opencode-computer-use-permissions] Native permission check exited with status ${result.status}.`);
91
+ return options.strict ? 1 : 0;
92
+ }
93
+ return 0;
94
+ }
95
+
96
+ function sameFile(left, right) {
97
+ try {
98
+ return realpathSync(left) === realpathSync(right);
99
+ } catch {
100
+ return resolve(left) === resolve(right);
101
+ }
102
+ }
103
+
104
+ const invokedPath = process.argv[1] ? resolve(process.argv[1]) : "";
105
+ const scriptPath = fileURLToPath(import.meta.url);
106
+ if (invokedPath && sameFile(invokedPath, scriptPath)) {
107
+ process.exitCode = main();
108
+ }
package/docs/index.html CHANGED
@@ -460,6 +460,7 @@ npm install</code></pre><button class="copy" type="button" data-copy="#clone">Co
460
460
  # pnpm install @frontendxlab/opencode-computer-use also works</code></pre><button class="copy" type="button" data-copy="#npm-install">Copy</button></div>
461
461
  <p>The package postinstall step detects OpenCode 1 versus OpenCode2 and local versus global installation. It edits JSONC without discarding comments, avoids duplicate entries, and prints both manual formats when the choice is ambiguous. Run it explicitly with <code>npx opencode-computer-use-setup</code>, or add <code>--local</code>, <code>--global</code>, <code>--v1</code>, or <code>--v2</code> when you want to choose explicitly.</p>
462
462
  <p>Recent pnpm releases can require explicit lifecycle-script approval. If pnpm reports <code>ERR_PNPM_IGNORED_BUILDS</code>, run <code>pnpm approve-builds @frontendxlab/opencode-computer-use</code> once, then rerun <code>pnpm install</code>. If scripts are disabled, run <code>pnpm exec opencode-computer-use-setup</code> manually. CI environments skip setup automatically.</p>
463
+ <p>The postinstall flow also runs the native <code>open-computer-use doctor</code> permission check. To rerun it, use <code>npx opencode-computer-use-permissions</code> or <code>pnpm exec opencode-computer-use-permissions</code>. macOS can launch Accessibility and Screen Recording onboarding, Linux reports AT-SPI requirements, and Windows reports UI Automation requirements. Permissions are never changed automatically.</p>
463
464
  <div class="tabs" role="tablist" aria-label="OpenCode generation">
464
465
  <button role="tab" id="tab-v1" aria-controls="panel-v1" aria-selected="true">OpenCode 1</button>
465
466
  <button role="tab" id="tab-v2" aria-controls="panel-v2" aria-selected="false" tabindex="-1">OpenCode2</button>
@@ -626,7 +627,8 @@ nodeRepl.write(state);</code></pre><button class="copy" type="button" data-copy=
626
627
  <h2>When the session is quiet.</h2>
627
628
  <details><summary><code>cua_repl</code> is not listed</summary><p>Check that the plugin path is in the active OpenCode generation's configuration, restart the TUI, and run <code>opencode mcp list</code>. Do not register the same plugin and MCP server twice.</p></details>
628
629
  <details><summary>Node cannot be found</summary><p>Set <code>OPENCODE_NODE</code> to an absolute Node executable before starting OpenCode, or make <code>node</code> available on the server PATH.</p></details>
629
- <details><summary>The app list is empty</summary><p>Run <code>open-computer-use list-apps</code> in the same graphical session. Confirm the app is already running and that the desktop accessibility session is available.</p></details>
630
+ <details><summary>Permission onboarding needs to be rerun</summary><p>Run <code>opencode-computer-use-permissions</code>. On macOS it can reopen Accessibility and Screen Recording onboarding; Linux and Windows print the relevant runtime requirements.</p></details>
631
+ <details><summary>The app list is empty</summary><p>Run <code>open-computer-use-permissions</code>, then <code>open-computer-use list-apps</code> in the same graphical session. Confirm the app is already running and that the desktop accessibility session is available.</p></details>
630
632
  <details><summary>Screenshots are unavailable</summary><p>Screen capture depends on the OS compositor and permissions. The plugin can still provide bounded accessibility text when capture is unavailable.</p></details>
631
633
  <details><summary>Linux input returns success but nothing changes</summary><p>Check the desktop session type and native runtime prerequisites. A pseudo-window or Wayland compositor can expose state without accepting synthetic input. Observe again before retrying a mutating action.</p></details>
632
634
  <details><summary>Global pointer fallback is rejected</summary><p>This is the expected safety gate. Enable <code>allowGlobalPointerFallbacks</code> only for an explicit diagnostic session where moving the real pointer and changing focus are acceptable.</p></details>
@@ -90,7 +90,11 @@ manual instructions. Run it explicitly with npx opencode-computer-use-setup;
90
90
  use --local, --global, --v1, or --v2 to choose explicitly. If pnpm reports
91
91
  ERR_PNPM_IGNORED_BUILDS, approve the package once with pnpm approve-builds
92
92
  @frontendxlab/opencode-computer-use, or run pnpm exec
93
- opencode-computer-use-setup manually. CI environments skip setup.
93
+ opencode-computer-use-setup manually. CI environments skip setup. The
94
+ postinstall flow also runs the native permission check. Rerun it with
95
+ npx opencode-computer-use-permissions or pnpm exec
96
+ opencode-computer-use-permissions. macOS can launch onboarding, Linux reports
97
+ AT-SPI requirements, and Windows reports UI Automation requirements.
94
98
  OpenCode 1 (opencode.json or opencode.jsonc, plugin list):
95
99
  { "$schema": "https://opencode.ai/config.json",
96
100
  "plugin": [["@frontendxlab/opencode-computer-use", { "backend": "auto" }]] }
package/docs/llms.txt CHANGED
@@ -27,6 +27,6 @@
27
27
  - Safety profiles: safetyMode=read-only blocks mutating CUA methods and changes js annotations; appAccess supports exact-name and ID allow/deny rules.
28
28
  - Reliability: app bindings and output are bounded; native timeouts send cancellation; shutdown sends a best-effort turn-ended notification.
29
29
  - No arbitrary shell escape. No run_shell in the model-facing API. Restricted VM blocks require, process, fetch, filesystem, dynamic import, and code generation.
30
- - Published package: @frontendxlab/opencode-computer-use. Its postinstall setup detects OpenCode generation and local/global scope, preserves JSONC, and prints manual instructions when ambiguous. Explicit setup: npx opencode-computer-use-setup --local|--global --v1|--v2.
30
+ - Published package: @frontendxlab/opencode-computer-use. Its postinstall setup detects OpenCode generation and local/global scope, preserves JSONC, and prints manual instructions when ambiguous. Explicit setup: npx opencode-computer-use-setup --local|--global --v1|--v2. Permission onboarding rerun: npx opencode-computer-use-permissions.
31
31
  - Requirements: Node.js 18 or newer, OpenCode 1.18.29 or newer (V1) or OpenCode2 V2, plus a signed-in graphical desktop session with OS accessibility and capture permissions.
32
32
  - Native runtimes packaged for darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-arm64, win32-x64. Live smoke tests passed on Linux x64 only; macOS and Windows need on-host validation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontendxlab/opencode-computer-use",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "A dual OpenCode and OpenCode2 plugin for local cross-platform desktop control.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,7 +29,8 @@
29
29
  },
30
30
  "bin": {
31
31
  "opencode-computer-use-repl": "bin/opencode-computer-use-repl.js",
32
- "opencode-computer-use-setup": "bin/opencode-computer-use-setup.js"
32
+ "opencode-computer-use-setup": "bin/opencode-computer-use-setup.js",
33
+ "opencode-computer-use-permissions": "bin/opencode-computer-use-permissions.js"
33
34
  },
34
35
  "files": [
35
36
  "bin/",
@@ -46,10 +47,10 @@
46
47
  "opencode": ">=0.0.0-beta-18684"
47
48
  },
48
49
  "scripts": {
49
- "postinstall": "node bin/opencode-computer-use-setup.js --auto",
50
- "lint": "node --check index.js && node --check bin/opencode-computer-use-repl.js && node --check bin/opencode-computer-use-setup.js && node --check lib/backend.js && node --check lib/json-line-peer.mjs && node --check lib/options.js && node --check lib/output.mjs && node --check lib/repl.mjs && node --check lib/repl-kernel.mjs && node --check lib/sandbox.mjs",
50
+ "postinstall": "node bin/opencode-computer-use-setup.js --auto && node bin/opencode-computer-use-permissions.js",
51
+ "lint": "node --check index.js && node --check bin/opencode-computer-use-repl.js && node --check bin/opencode-computer-use-setup.js && node --check bin/opencode-computer-use-permissions.js && node --check lib/backend.js && node --check lib/json-line-peer.mjs && node --check lib/options.js && node --check lib/output.mjs && node --check lib/repl.mjs && node --check lib/repl-kernel.mjs && node --check lib/sandbox.mjs",
51
52
  "test": "node --test",
52
- "prepack": "node --check index.js && node --check bin/opencode-computer-use-repl.js && node --check bin/opencode-computer-use-setup.js && node -e \"JSON.parse(require('fs').readFileSync('package.json','utf8'))\"",
53
+ "prepack": "node --check index.js && node --check bin/opencode-computer-use-repl.js && node --check bin/opencode-computer-use-setup.js && node --check bin/opencode-computer-use-permissions.js && node -e \"JSON.parse(require('fs').readFileSync('package.json','utf8'))\"",
53
54
  "prepublishOnly": "npm run lint && npm test"
54
55
  },
55
56
  "optionalDependencies": {