automify 0.1.7 → 0.1.8

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
@@ -203,8 +203,9 @@ Local desktop computer use controls the native desktop on the machine running yo
203
203
  Before running `npx automify-install-desktop`, install the native build tools for your OS:
204
204
 
205
205
  ```sh
206
- # Windows: Visual Studio C++ Build Tools plus CMake on PATH.
207
- winget install Kitware.CMake
206
+ # Windows: Visual Studio 2022 C++ Build Tools plus CMake on PATH.
207
+ winget install --id Microsoft.VisualStudio.2022.BuildTools --exact --override "--passive --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
208
+ winget install --id Kitware.CMake --exact --source winget
208
209
 
209
210
  # macOS: Xcode Command Line Tools plus CMake on PATH.
210
211
  xcode-select --install
@@ -220,7 +221,7 @@ sudo dnf install -y gcc-c++ make cmake libXtst-devel libpng-devel
220
221
  sudo pacman -S --needed base-devel cmake libxtst libpng
221
222
  ```
222
223
 
223
- On headless Linux hosts, also install `xvfb` unless you manage `DISPLAY` yourself. On macOS and Windows, `cmake --version` must work in the terminal where you run `npx automify-install-desktop`. On Windows, the VS Code CMake Tools extension is not enough by itself.
224
+ On headless Linux hosts, also install `xvfb` unless you manage `DISPLAY` yourself. On macOS and Windows, `cmake --version` must work in the terminal where you run `npx automify-install-desktop`. On Windows, the VS Code CMake Tools extension is not enough by itself, and Visual Studio 2026 is not currently recognized by the native build chain used by nut.js.
224
225
 
225
226
  ```js
226
227
  import { initAutomify } from "automify";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automify",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "AI computer use for browser, CLI, and desktop in Node.js.",
5
5
  "homepage": "https://aldovincenti.github.io/automify",
6
6
  "bugs": {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawnSync } from "node:child_process";
3
3
  import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
- import { dirname, join, resolve } from "node:path";
4
+ import { dirname, join, resolve, sep } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
 
7
7
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -23,12 +23,7 @@ const platformPackageName = `@nut-tree/libnut-${process.platform}`;
23
23
  const platformPackageDir = join(nutScope, `libnut-${process.platform}`);
24
24
  const macPermissionsPackageDir = join(nutScope, "node-mac-permissions");
25
25
 
26
- const runtimeDependencies = [
27
- "jimp@1.6.1",
28
- "node-abort-controller@3.1.1",
29
- "clipboardy@2.3.0",
30
- "bindings@1.5.0"
31
- ];
26
+ const runtimeDependencies = ["jimp@1.6.1", "node-abort-controller@3.1.1", "clipboardy@2.3.0", "bindings@1.5.0"];
32
27
 
33
28
  console.log("Building official nut.js from source.");
34
29
  console.log(`Build directory: ${buildRoot}`);
@@ -86,7 +81,9 @@ if (process.platform === "darwin") {
86
81
  installWorkspacePackage(macPermissionsSource, macPermissionsPackageDir);
87
82
  }
88
83
 
89
- run("node", ["-e", "import('@nut-tree/nut-js').then(() => console.log('nut.js source build import ok'))"], { cwd: root });
84
+ run("node", ["-e", "import('@nut-tree/nut-js').then(() => console.log('nut.js source build import ok'))"], {
85
+ cwd: root
86
+ });
90
87
 
91
88
  function cloneOrPull(repo, target, ref) {
92
89
  if (existsSync(join(target, ".git"))) {
@@ -123,6 +120,9 @@ function checkBuildPrerequisites() {
123
120
  for (const command of ["git", "npm", "cmake"]) {
124
121
  if (!commandExists(command)) missing.push(command);
125
122
  }
123
+ if (process.platform === "win32" && !windowsBuildToolsExist()) {
124
+ missing.push("Visual Studio 2022 C++ Build Tools");
125
+ }
126
126
 
127
127
  if (missing.length === 0) return;
128
128
 
@@ -134,18 +134,87 @@ function checkBuildPrerequisites() {
134
134
  } else if (process.platform === "linux") {
135
135
  console.error("Linux: install CMake, a C/C++ compiler, libxtst-dev, and libpng++-dev.");
136
136
  } else if (process.platform === "win32") {
137
- console.error("Windows: install CMake and Visual Studio C++ Build Tools.");
137
+ console.error("Windows: install CMake and Visual Studio 2022 C++ Build Tools.");
138
+ console.error("Make sure the `Desktop development with C++` workload is installed.");
138
139
  }
139
140
 
140
141
  process.exit(1);
141
142
  }
142
143
 
143
144
  function commandExists(command) {
144
- const result = spawnSync(resolveCommand(command), ["--version"], {
145
+ return resolveCommand(command) !== null;
146
+ }
147
+
148
+ function resolveCommand(command) {
149
+ for (const candidate of commandCandidates(command)) {
150
+ const result = spawnSync(candidate.command, [...candidate.args, "--version"], {
151
+ cwd: root,
152
+ stdio: "ignore"
153
+ });
154
+ if ((result.status ?? 1) === 0) return candidate;
155
+ }
156
+ return null;
157
+ }
158
+
159
+ function commandCandidates(command) {
160
+ const candidates = [];
161
+
162
+ if (process.platform === "win32" && ["npm", "npx"].includes(command)) {
163
+ candidates.push({ command: `${command}.cmd`, args: [] });
164
+ }
165
+
166
+ const npmCli = npmCliCandidate(command);
167
+ if (npmCli) candidates.push(npmCli);
168
+
169
+ candidates.push({ command, args: [] });
170
+ return candidates;
171
+ }
172
+
173
+ function npmCliCandidate(command) {
174
+ if (!["npm", "npx"].includes(command) || !process.env.npm_execpath) return null;
175
+ if (command === "npm") return { command: process.execPath, args: [process.env.npm_execpath] };
176
+
177
+ const npxExecPath = join(dirname(process.env.npm_execpath), "npx-cli.js");
178
+ if (!existsSync(npxExecPath)) return null;
179
+ return { command: process.execPath, args: [npxExecPath] };
180
+ }
181
+
182
+ function runResolvedCommand(command, args, options = {}) {
183
+ const candidate = resolveCommand(command) ?? { command, args: [] };
184
+ return spawnSync(candidate.command, [...candidate.args, ...args], {
145
185
  cwd: root,
146
- stdio: "ignore"
186
+ ...options
147
187
  });
148
- return (result.status ?? 1) === 0;
188
+ }
189
+
190
+ function windowsBuildToolsExist() {
191
+ const vswhere = join(
192
+ process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)",
193
+ "Microsoft Visual Studio",
194
+ "Installer",
195
+ "vswhere.exe"
196
+ );
197
+ if (!existsSync(vswhere)) return false;
198
+
199
+ const result = spawnSync(
200
+ vswhere,
201
+ [
202
+ "-products",
203
+ "*",
204
+ "-version",
205
+ "[17.0,18.0)",
206
+ "-requires",
207
+ "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
208
+ "-property",
209
+ "installationPath"
210
+ ],
211
+ {
212
+ cwd: root,
213
+ encoding: "utf8",
214
+ stdio: "pipe"
215
+ }
216
+ );
217
+ return (result.status ?? 1) === 0 && result.stdout.trim().length > 0;
149
218
  }
150
219
 
151
220
  function patchPlatformLibnutDependency() {
@@ -326,15 +395,16 @@ exports.default = default_1;
326
395
  function installWorkspacePackage(source, target) {
327
396
  rmSync(target, { recursive: true, force: true });
328
397
  mkdirSync(dirname(target), { recursive: true });
398
+ const excludedDirs = [join(source, "node_modules"), join(source, "coverage")];
329
399
  cpSync(source, target, {
330
400
  recursive: true,
331
- filter: (file) => !file.includes(`${source}/node_modules`) && !file.includes(`${source}/coverage`)
401
+ filter: (file) =>
402
+ !excludedDirs.some((excludedDir) => file === excludedDir || file.startsWith(`${excludedDir}${sep}`))
332
403
  });
333
404
  }
334
405
 
335
406
  function run(command, args, options = {}) {
336
- const executable = resolveCommand(command);
337
- const result = spawnSync(executable, args, {
407
+ const result = runResolvedCommand(command, args, {
338
408
  cwd: options.cwd ?? root,
339
409
  env: options.env ?? process.env,
340
410
  shell: false,
@@ -367,10 +437,6 @@ function run(command, args, options = {}) {
367
437
  return commandResult;
368
438
  }
369
439
 
370
- function resolveCommand(command) {
371
- return process.platform === "win32" && ["npm", "npx"].includes(command) ? `${command}.cmd` : command;
372
- }
373
-
374
440
  function runPnpm(args, options = {}) {
375
441
  run("npx", ["--yes", "pnpm@8.15.2", ...args], options);
376
442
  }