@qablehq/atto 0.0.28 → 0.0.30
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/bin/atto.js +50 -4
- package/out/main/index.js +54 -16
- package/package.json +1 -1
- package/scripts/install-chromium.js +73 -4
package/bin/atto.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Opens the built Atto desktop window. Installed as the `atto` command.
|
|
3
3
|
// If a silent update was queued on the previous quit, kick it off in the
|
|
4
4
|
// background — never block the window on npm install.
|
|
5
|
-
const { spawn } = require("node:child_process");
|
|
5
|
+
const { spawn, spawnSync } = require("node:child_process");
|
|
6
6
|
const fs = require("node:fs");
|
|
7
7
|
const os = require("node:os");
|
|
8
8
|
const path = require("node:path");
|
|
@@ -48,17 +48,63 @@ function kickPendingSilentUpdate() {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/** True when Electron's extracted binary looks complete (not a half-finished download). */
|
|
52
|
+
function electronLooksReady(electronPkgDir) {
|
|
53
|
+
const pathFile = path.join(electronPkgDir, "path.txt");
|
|
54
|
+
if (!fs.existsSync(pathFile)) return false;
|
|
55
|
+
const rel = fs.readFileSync(pathFile, "utf8").trim();
|
|
56
|
+
if (!rel) return false;
|
|
57
|
+
const binary = path.join(electronPkgDir, "dist", rel);
|
|
58
|
+
try {
|
|
59
|
+
const st = fs.statSync(binary);
|
|
60
|
+
// A real Electron binary is tens of MB; a stub/partial extract is tiny.
|
|
61
|
+
return st.isFile() && st.size > 1_000_000;
|
|
62
|
+
} catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function ensureElectronBinary(electronPkgDir) {
|
|
68
|
+
if (electronLooksReady(electronPkgDir)) return true;
|
|
69
|
+
console.log("Downloading Electron binary...");
|
|
70
|
+
const installJs = path.join(electronPkgDir, "install.js");
|
|
71
|
+
if (!fs.existsSync(installJs)) return false;
|
|
72
|
+
const result = spawnSync(process.execPath, [installJs], { stdio: "inherit" });
|
|
73
|
+
return result.status === 0 && electronLooksReady(electronPkgDir);
|
|
74
|
+
}
|
|
75
|
+
|
|
51
76
|
kickPendingSilentUpdate();
|
|
52
77
|
|
|
78
|
+
const appDir = path.resolve(__dirname, "..");
|
|
79
|
+
const rendererHtml = path.join(appDir, "out", "renderer", "index.html");
|
|
80
|
+
if (!fs.existsSync(rendererHtml)) {
|
|
81
|
+
console.error(
|
|
82
|
+
"Atto UI files are missing (out/renderer/index.html). Reinstall with:\n npm install -g @qablehq/atto@latest --prefix \"$HOME/.local\""
|
|
83
|
+
);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
|
|
53
87
|
let electronPath;
|
|
54
88
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
89
|
+
// Prefer resolving from this package so global/prefix installs find the right copy.
|
|
90
|
+
const electronPkgDir = path.dirname(require.resolve("electron/package.json", { paths: [appDir] }));
|
|
91
|
+
if (!ensureElectronBinary(electronPkgDir)) {
|
|
92
|
+
console.error(
|
|
93
|
+
"Electron failed to install. Fix with:\n cd \"" +
|
|
94
|
+
path.join(appDir, "node_modules", "electron") +
|
|
95
|
+
'" && node install.js'
|
|
96
|
+
);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
// Fresh require after install.js may have written path.txt / dist.
|
|
100
|
+
delete require.cache[require.resolve("electron", { paths: [appDir] })];
|
|
101
|
+
electronPath = require(require.resolve("electron", { paths: [appDir] }));
|
|
102
|
+
} catch (error) {
|
|
57
103
|
console.error("Atto could not find Electron. Install again with: npm install -g @qablehq/atto");
|
|
104
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
58
105
|
process.exit(1);
|
|
59
106
|
}
|
|
60
107
|
|
|
61
|
-
const appDir = path.resolve(__dirname, "..");
|
|
62
108
|
const child = spawn(electronPath, [appDir], {
|
|
63
109
|
stdio: "inherit",
|
|
64
110
|
env: { ...process.env, ATTO_NPM_PACKAGE: "1" },
|
package/out/main/index.js
CHANGED
|
@@ -341,10 +341,11 @@ async function tesboAgents(projectId) {
|
|
|
341
341
|
}
|
|
342
342
|
return { projectId, agents: [...SERVER_AGENTS, ...COMING_SOON], notice: null };
|
|
343
343
|
}
|
|
344
|
-
function safeTargetPath(savePath,
|
|
344
|
+
function safeTargetPath(savePath, relativePath) {
|
|
345
345
|
const folder = node_path.resolve(node_path.normalize(savePath.trim()));
|
|
346
346
|
if (!node_path.isAbsolute(folder)) throw new Error("Save location from Tesbo must be an absolute path.");
|
|
347
|
-
const
|
|
347
|
+
const relative = String(relativePath || "script.spec.ts").replace(/\\/g, "/").replace(/^\/+/, "").split("/").filter((part) => part && part !== "." && part !== "..").join("/");
|
|
348
|
+
const base = relative || "script.spec.ts";
|
|
348
349
|
const target = node_path.resolve(folder, base);
|
|
349
350
|
const root = folder.endsWith(node_path.sep) ? folder : folder + node_path.sep;
|
|
350
351
|
if (target !== folder && !target.startsWith(root)) {
|
|
@@ -366,11 +367,16 @@ async function pullAndSavePendingScripts() {
|
|
|
366
367
|
let saved = 0;
|
|
367
368
|
const errors = [];
|
|
368
369
|
for (const item of scripts) {
|
|
369
|
-
|
|
370
|
+
const bundle = Array.isArray(item?.files) && item.files.length > 0 ? item.files.filter((file) => file?.path && typeof file.content === "string") : item?.script ? [{ path: item.fileName || `${item.externalId || "script"}.spec.ts`, content: item.script }] : [];
|
|
371
|
+
if (!item?.id || !item.savePath || bundle.length === 0) continue;
|
|
370
372
|
try {
|
|
371
|
-
const
|
|
372
|
-
node_fs.mkdirSync(
|
|
373
|
-
|
|
373
|
+
const root = node_path.resolve(node_path.normalize(item.savePath.trim()));
|
|
374
|
+
node_fs.mkdirSync(root, { recursive: true });
|
|
375
|
+
for (const file of bundle) {
|
|
376
|
+
const target = safeTargetPath(item.savePath, file.path);
|
|
377
|
+
node_fs.mkdirSync(node_path.dirname(target), { recursive: true });
|
|
378
|
+
node_fs.writeFileSync(target, file.content, { encoding: "utf8" });
|
|
379
|
+
}
|
|
374
380
|
const ack = await tesboFetch(link, `/api/atto/scripts/${encodeURIComponent(item.id)}/ack`, { method: "POST", body: "{}" });
|
|
375
381
|
if (!ack.ok) throw new Error(await errorMessage(ack));
|
|
376
382
|
saved += 1;
|
|
@@ -653,6 +659,29 @@ function listPcFolderEntries(requestPath) {
|
|
|
653
659
|
const parentPath = parent === abs ? null : parent;
|
|
654
660
|
return { path: abs, parentPath, entries };
|
|
655
661
|
}
|
|
662
|
+
|
|
663
|
+
function createPcFolder(parentPath, name) {
|
|
664
|
+
const parent = node_path.resolve(String(parentPath || "").trim());
|
|
665
|
+
const folderName = String(name || "").trim();
|
|
666
|
+
if (!parent || !node_path.isAbsolute(parent) || !safeStatDir(parent)) {
|
|
667
|
+
throw new Error("Open a real folder on the PC first.");
|
|
668
|
+
}
|
|
669
|
+
if (!folderName) throw new Error("Enter a folder name.");
|
|
670
|
+
if (folderName.length > 120) throw new Error("Folder name is too long.");
|
|
671
|
+
if (/[\\/]/.test(folderName) || folderName === "." || folderName === "..") {
|
|
672
|
+
throw new Error("Folder name cannot contain path separators.");
|
|
673
|
+
}
|
|
674
|
+
const target = node_path.resolve(parent, folderName);
|
|
675
|
+
const root = parent.endsWith(node_path.sep) ? parent : parent + node_path.sep;
|
|
676
|
+
if (target !== parent && !target.startsWith(root)) {
|
|
677
|
+
throw new Error("Refusing to create a folder outside the selected path.");
|
|
678
|
+
}
|
|
679
|
+
if (safeStatDir(target)) {
|
|
680
|
+
return { path: target, parentPath: parent };
|
|
681
|
+
}
|
|
682
|
+
node_fs.mkdirSync(target, { recursive: false });
|
|
683
|
+
return { path: target, parentPath: parent };
|
|
684
|
+
}
|
|
656
685
|
const claimedDesktopCommands = /* @__PURE__ */ new Set();
|
|
657
686
|
async function pullAndHandleDesktopCommands() {
|
|
658
687
|
const link = readLink();
|
|
@@ -686,6 +715,25 @@ async function pullAndHandleDesktopCommands() {
|
|
|
686
715
|
}
|
|
687
716
|
continue;
|
|
688
717
|
}
|
|
718
|
+
|
|
719
|
+
if (command.type === "create_folder") {
|
|
720
|
+
const parentPath = String(command.parentPath || "").trim();
|
|
721
|
+
const name = String(command.name || "").trim();
|
|
722
|
+
try {
|
|
723
|
+
const created = createPcFolder(parentPath, name);
|
|
724
|
+
await tesboFetch(link, `/api/atto/commands/${encodeURIComponent(command.id)}/complete`, {
|
|
725
|
+
method: "POST",
|
|
726
|
+
body: JSON.stringify(created)
|
|
727
|
+
});
|
|
728
|
+
} catch (err) {
|
|
729
|
+
const message = err instanceof Error ? err.message : "Could not create folder.";
|
|
730
|
+
await tesboFetch(link, `/api/atto/commands/${encodeURIComponent(command.id)}/complete`, {
|
|
731
|
+
method: "POST",
|
|
732
|
+
body: JSON.stringify({ path: "", parentPath, error: message })
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
689
737
|
if (command.type !== "pick_folder") continue;
|
|
690
738
|
const win = electron.BrowserWindow.getFocusedWindow() ?? electron.BrowserWindow.getAllWindows()[0];
|
|
691
739
|
const result = win ? await electron.dialog.showOpenDialog(win, {
|
|
@@ -12708,15 +12756,6 @@ function setupAutoUpdater() {
|
|
|
12708
12756
|
});
|
|
12709
12757
|
}
|
|
12710
12758
|
registerMediaProtocolScheme();
|
|
12711
|
-
function warmChromiumInBackground() {
|
|
12712
|
-
const check = chromiumExecutable();
|
|
12713
|
-
if (check.available) return;
|
|
12714
|
-
console.log("[atto] Chromium missing — downloading in background");
|
|
12715
|
-
void installChromium().then((result) => {
|
|
12716
|
-
if (result.ok) console.log("[atto] Chromium ready");
|
|
12717
|
-
else console.warn("[atto] Chromium download failed:", result.error);
|
|
12718
|
-
});
|
|
12719
|
-
}
|
|
12720
12759
|
function createMainWindow() {
|
|
12721
12760
|
const mainWindow = new electron.BrowserWindow({
|
|
12722
12761
|
width: 1320,
|
|
@@ -12751,7 +12790,6 @@ function createMainWindow() {
|
|
|
12751
12790
|
electron.app.whenReady().then(() => {
|
|
12752
12791
|
registerMediaProtocol();
|
|
12753
12792
|
createMainWindow();
|
|
12754
|
-
warmChromiumInBackground();
|
|
12755
12793
|
const engine = process.env.TAA_ENGINE === "mock" ? new MockFixturePlayer() : new RealEngine();
|
|
12756
12794
|
registerIpcHandlers(engine);
|
|
12757
12795
|
electron.app.on("before-quit", () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,75 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
// Global install: download Electron (if incomplete) + Playwright Chromium together,
|
|
3
|
+
// same as the original setup flow — finish install with binaries ready.
|
|
4
|
+
const { spawnSync } = require("node:child_process");
|
|
5
|
+
const { createRequire } = require("node:module");
|
|
6
|
+
const fs = require("node:fs");
|
|
7
|
+
const path = require("node:path");
|
|
8
|
+
|
|
9
|
+
if (process.env.npm_config_global !== "true") {
|
|
10
|
+
process.exit(0);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const pkgRoot = path.join(__dirname, "..");
|
|
14
|
+
const requireFromPackage = createRequire(path.join(pkgRoot, "package.json"));
|
|
15
|
+
|
|
16
|
+
function electronLooksReady(electronPkgDir) {
|
|
17
|
+
const pathFile = path.join(electronPkgDir, "path.txt");
|
|
18
|
+
if (!fs.existsSync(pathFile)) return false;
|
|
19
|
+
const rel = fs.readFileSync(pathFile, "utf8").trim();
|
|
20
|
+
if (!rel) return false;
|
|
21
|
+
const binary = path.join(electronPkgDir, "dist", rel);
|
|
22
|
+
try {
|
|
23
|
+
const st = fs.statSync(binary);
|
|
24
|
+
return st.isFile() && st.size > 1_000_000;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function ensureElectron() {
|
|
31
|
+
let electronPkgDir;
|
|
32
|
+
try {
|
|
33
|
+
electronPkgDir = path.dirname(requireFromPackage.resolve("electron/package.json"));
|
|
34
|
+
} catch {
|
|
35
|
+
console.warn("[atto] Electron package missing. Re-run: npm install -g @qablehq/atto");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (electronLooksReady(electronPkgDir)) {
|
|
39
|
+
console.log("[atto] Electron ready.");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
console.log("[atto] Downloading Electron binary...");
|
|
43
|
+
const installJs = path.join(electronPkgDir, "install.js");
|
|
44
|
+
if (!fs.existsSync(installJs)) {
|
|
45
|
+
console.warn("[atto] Electron install.js missing.");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const result = spawnSync(process.execPath, [installJs], { stdio: "inherit" });
|
|
49
|
+
if (result.status !== 0 || !electronLooksReady(electronPkgDir)) {
|
|
50
|
+
console.warn("[atto] Electron download did not finish. Opening Atto will retry once.");
|
|
51
|
+
} else {
|
|
52
|
+
console.log("[atto] Electron ready.");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function ensureChromium() {
|
|
57
|
+
let cliPath;
|
|
58
|
+
try {
|
|
59
|
+
cliPath = requireFromPackage.resolve("playwright/cli");
|
|
60
|
+
} catch {
|
|
61
|
+
console.warn("[atto] Playwright is not installed. The app will download Chromium on the first test.");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
console.log("[atto] Downloading Chromium...");
|
|
65
|
+
const result = spawnSync(process.execPath, [cliPath, "install", "chromium"], { stdio: "inherit" });
|
|
66
|
+
if (result.status !== 0) {
|
|
67
|
+
console.warn("[atto] Chromium download did not finish. The app will try again on the first test.");
|
|
68
|
+
} else {
|
|
69
|
+
console.log("[atto] Chromium ready.");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ensureElectron();
|
|
74
|
+
ensureChromium();
|
|
6
75
|
process.exit(0);
|