aicomputer 0.1.18 → 0.1.20
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 +28 -0
- package/dist/{chunk-3ZUTAUUD.js → chunk-36BZXAAX.js} +129 -258
- package/dist/chunk-3ZF7JRBW.js +270 -0
- package/dist/chunk-4TE5XTYE.js +242 -0
- package/dist/chunk-5Y2NWK5I.js +14 -0
- package/dist/chunk-D3SAFNSI.js +75 -0
- package/dist/chunk-GD42GHW3.js +183 -0
- package/dist/chunk-GGBVVRLL.js +32 -0
- package/dist/chunk-LOGK7YYJ.js +255 -0
- package/dist/{chunk-F2U4SFJ4.js → chunk-TPFE3CC6.js} +24 -174
- package/dist/index.js +678 -430
- package/dist/lib/autossh-runtime.d.ts +21 -0
- package/dist/lib/autossh-runtime.js +23 -0
- package/dist/lib/mount-config.d.ts +5 -1
- package/dist/lib/mount-mutagen.d.ts +2 -0
- package/dist/lib/mount-mutagen.js +3 -1
- package/dist/lib/mount-reconcile.js +5 -2
- package/dist/lib/mutagen-runtime.d.ts +20 -0
- package/dist/lib/mutagen-runtime.js +19 -0
- package/dist/lib/ssh-access.d.ts +74 -0
- package/dist/lib/ssh-access.js +25 -0
- package/dist/lib/ssh-config.d.ts +14 -0
- package/dist/lib/ssh-config.js +10 -0
- package/dist/lib/upgrade-version.d.ts +10 -0
- package/dist/lib/upgrade-version.js +8 -0
- package/package.json +3 -3
- package/scripts/postinstall.mjs +36 -23
|
@@ -3,178 +3,21 @@ import {
|
|
|
3
3
|
ensureHandleDirectories,
|
|
4
4
|
ensureMountDirectories
|
|
5
5
|
} from "./chunk-KXLTHWW3.js";
|
|
6
|
-
|
|
7
|
-
// src/lib/mount-mutagen.ts
|
|
8
|
-
import { chmodSync as chmodSync2, readFileSync, symlinkSync, unlinkSync, writeFileSync } from "fs";
|
|
9
|
-
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
10
|
-
import { basename, join as join2, relative, resolve } from "path";
|
|
11
|
-
|
|
12
|
-
// src/lib/mutagen-runtime.ts
|
|
13
|
-
import { spawnSync } from "child_process";
|
|
14
6
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
mkdirSync,
|
|
18
|
-
renameSync,
|
|
19
|
-
rmSync
|
|
20
|
-
} from "fs";
|
|
21
|
-
import { writeFile } from "fs/promises";
|
|
22
|
-
import { homedir } from "os";
|
|
23
|
-
import { dirname, join } from "path";
|
|
24
|
-
var BUNDLED_MUTAGEN_VERSION = "0.18.1";
|
|
25
|
-
var BUNDLED_MUTAGEN_DOWNLOAD_BASE = `https://github.com/mutagen-io/mutagen/releases/download/v${BUNDLED_MUTAGEN_VERSION}`;
|
|
26
|
-
var AGENTCOMPUTER_MUTAGEN_PATH_ENV = "AGENTCOMPUTER_MUTAGEN_PATH";
|
|
27
|
-
function getBundledMutagenAsset(platform = process.platform, arch = process.arch, homeDirectory = homedir()) {
|
|
28
|
-
if (!isSupportedPlatform(platform) || !isSupportedArch(arch)) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const assetName = `mutagen_${platform}_${arch}_v${BUNDLED_MUTAGEN_VERSION}.tar.gz`;
|
|
32
|
-
const installDir = join(
|
|
33
|
-
homeDirectory,
|
|
34
|
-
".agentcomputer",
|
|
35
|
-
"tools",
|
|
36
|
-
"mutagen",
|
|
37
|
-
`v${BUNDLED_MUTAGEN_VERSION}`,
|
|
38
|
-
`${platform}-${arch}`
|
|
39
|
-
);
|
|
40
|
-
return {
|
|
41
|
-
platform,
|
|
42
|
-
arch,
|
|
43
|
-
version: BUNDLED_MUTAGEN_VERSION,
|
|
44
|
-
assetName,
|
|
45
|
-
downloadUrl: `${BUNDLED_MUTAGEN_DOWNLOAD_BASE}/${assetName}`,
|
|
46
|
-
installDir,
|
|
47
|
-
executablePath: join(installDir, "mutagen")
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function resolveSystemCommandPath(command) {
|
|
51
|
-
const result = spawnSync("which", [command], { encoding: "utf8" });
|
|
52
|
-
if (result.status !== 0) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
const resolved = result.stdout.trim();
|
|
56
|
-
return resolved.length > 0 ? resolved : null;
|
|
57
|
-
}
|
|
58
|
-
async function ensureMutagenCommandPath() {
|
|
59
|
-
const asset = getBundledMutagenAsset();
|
|
60
|
-
if (asset && existsSync(asset.executablePath)) {
|
|
61
|
-
return asset.executablePath;
|
|
62
|
-
}
|
|
63
|
-
const systemPath = resolveSystemCommandPath("mutagen");
|
|
64
|
-
if (!asset) {
|
|
65
|
-
if (systemPath) {
|
|
66
|
-
return systemPath;
|
|
67
|
-
}
|
|
68
|
-
throw new Error(
|
|
69
|
-
`Agent Computer does not ship bundled Mutagen for ${process.platform} ${process.arch}. Install Mutagen manually and rerun \`computer mount\`.`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
return await installBundledMutagen(asset);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
if (systemPath) {
|
|
76
|
-
return systemPath;
|
|
77
|
-
}
|
|
78
|
-
const reason = error instanceof Error ? error.message : "unknown Mutagen install failure";
|
|
79
|
-
throw new Error(
|
|
80
|
-
`Failed to install Agent Computer's bundled Mutagen (${reason}). Check your network connection and rerun \`computer mount\`.`
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
async function ensureBundledMutagenInstalled() {
|
|
85
|
-
const asset = getBundledMutagenAsset();
|
|
86
|
-
if (!asset) {
|
|
87
|
-
throw new Error(
|
|
88
|
-
`Agent Computer does not ship bundled Mutagen for ${process.platform} ${process.arch}.`
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
return installBundledMutagen(asset);
|
|
92
|
-
}
|
|
93
|
-
function resolveMutagenCommandPath() {
|
|
94
|
-
const overridden = process.env[AGENTCOMPUTER_MUTAGEN_PATH_ENV]?.trim();
|
|
95
|
-
if (overridden) {
|
|
96
|
-
return overridden;
|
|
97
|
-
}
|
|
98
|
-
const asset = getBundledMutagenAsset();
|
|
99
|
-
if (asset && existsSync(asset.executablePath)) {
|
|
100
|
-
return asset.executablePath;
|
|
101
|
-
}
|
|
102
|
-
const systemPath = resolveSystemCommandPath("mutagen");
|
|
103
|
-
if (systemPath) {
|
|
104
|
-
return systemPath;
|
|
105
|
-
}
|
|
106
|
-
if (!asset) {
|
|
107
|
-
throw new Error(
|
|
108
|
-
`Agent Computer does not ship bundled Mutagen for ${process.platform} ${process.arch}. Install Mutagen manually and rerun \`computer mount\`.`
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
throw new Error(
|
|
112
|
-
"Mutagen is not installed yet. Re-run `computer mount` and Agent Computer will install its bundled copy."
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
async function installBundledMutagen(asset) {
|
|
116
|
-
if (existsSync(asset.executablePath)) {
|
|
117
|
-
return asset.executablePath;
|
|
118
|
-
}
|
|
119
|
-
mkdirSync(dirname(asset.installDir), { recursive: true });
|
|
120
|
-
const stagingDir = `${asset.installDir}.staging-${process.pid}-${Date.now()}`;
|
|
121
|
-
const archivePath = join(stagingDir, asset.assetName);
|
|
122
|
-
rmSync(stagingDir, { recursive: true, force: true });
|
|
123
|
-
if (existsSync(asset.installDir) && !existsSync(asset.executablePath)) {
|
|
124
|
-
rmSync(asset.installDir, { recursive: true, force: true });
|
|
125
|
-
}
|
|
126
|
-
mkdirSync(stagingDir, { recursive: true });
|
|
127
|
-
try {
|
|
128
|
-
const response = await fetch(asset.downloadUrl, {
|
|
129
|
-
headers: {
|
|
130
|
-
"User-Agent": "aicomputer-cli"
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
if (!response.ok || !response.body) {
|
|
134
|
-
throw new Error(`download failed with status ${response.status}`);
|
|
135
|
-
}
|
|
136
|
-
await writeFile(archivePath, Buffer.from(await response.arrayBuffer()), {
|
|
137
|
-
mode: 384
|
|
138
|
-
});
|
|
139
|
-
const extract = spawnSync("tar", ["-xzf", archivePath, "-C", stagingDir], {
|
|
140
|
-
encoding: "utf8"
|
|
141
|
-
});
|
|
142
|
-
if (extract.status !== 0) {
|
|
143
|
-
throw new Error(
|
|
144
|
-
extract.stderr.trim() || extract.stdout.trim() || `failed to extract ${asset.assetName}`
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
if (!existsSync(join(stagingDir, "mutagen"))) {
|
|
148
|
-
throw new Error("archive did not contain the Mutagen executable");
|
|
149
|
-
}
|
|
150
|
-
chmodSync(join(stagingDir, "mutagen"), 493);
|
|
151
|
-
rmSync(archivePath, { force: true });
|
|
152
|
-
try {
|
|
153
|
-
renameSync(stagingDir, asset.installDir);
|
|
154
|
-
} catch (error) {
|
|
155
|
-
if (!existsSync(asset.executablePath)) {
|
|
156
|
-
throw error;
|
|
157
|
-
}
|
|
158
|
-
rmSync(stagingDir, { recursive: true, force: true });
|
|
159
|
-
}
|
|
160
|
-
return asset.executablePath;
|
|
161
|
-
} catch (error) {
|
|
162
|
-
rmSync(stagingDir, { recursive: true, force: true });
|
|
163
|
-
throw error;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
function isSupportedPlatform(platform) {
|
|
167
|
-
return platform === "darwin" || platform === "linux";
|
|
168
|
-
}
|
|
169
|
-
function isSupportedArch(arch) {
|
|
170
|
-
return arch === "arm64" || arch === "x64";
|
|
171
|
-
}
|
|
7
|
+
resolveMutagenCommandPath
|
|
8
|
+
} from "./chunk-GD42GHW3.js";
|
|
172
9
|
|
|
173
10
|
// src/lib/mount-mutagen.ts
|
|
11
|
+
import { chmodSync, readFileSync, symlinkSync, unlinkSync, writeFileSync } from "fs";
|
|
12
|
+
import { spawn, spawnSync } from "child_process";
|
|
13
|
+
import { basename, join, relative, resolve } from "path";
|
|
174
14
|
var SYNC_NAME_PREFIX = "agentcomputer-mount-";
|
|
175
15
|
var DEFAULT_IGNORE_PATHS = [
|
|
176
16
|
".codex/tmp",
|
|
17
|
+
".dbus",
|
|
177
18
|
".local",
|
|
19
|
+
".run",
|
|
20
|
+
".runtime",
|
|
178
21
|
".ssh/sshd.log"
|
|
179
22
|
];
|
|
180
23
|
function ensureMutagenSshEnvironment(config, paths) {
|
|
@@ -198,7 +41,7 @@ function createHandleSession(handle, config, paths, signal) {
|
|
|
198
41
|
const args = [
|
|
199
42
|
"sync",
|
|
200
43
|
"create",
|
|
201
|
-
|
|
44
|
+
join(paths.rootPath, handle),
|
|
202
45
|
`${handle}@${config.alias}:/home/node`,
|
|
203
46
|
"--name",
|
|
204
47
|
sessionName,
|
|
@@ -272,9 +115,11 @@ async function listOwnedSessions(config, paths, signal) {
|
|
|
272
115
|
betaConnected: session.betaConnected,
|
|
273
116
|
status: session.status,
|
|
274
117
|
lastError: session.lastError,
|
|
118
|
+
stagingProgress: session.stagingProgress,
|
|
119
|
+
currentFile: session.currentFile,
|
|
275
120
|
scanProblemCount: session.scanProblemCount,
|
|
276
121
|
conflictCount: session.conflictCount,
|
|
277
|
-
legacy: session.name !== expectedName || session.betaUrl !== expectedBeta || alphaPath !== resolve(
|
|
122
|
+
legacy: session.name !== expectedName || session.betaUrl !== expectedBeta || alphaPath !== resolve(join(rootPath, handle))
|
|
278
123
|
};
|
|
279
124
|
}).filter((session) => session !== null);
|
|
280
125
|
return sessions.sort((left, right) => left.handle.localeCompare(right.handle));
|
|
@@ -336,6 +181,14 @@ function parseMutagenSyncList(output) {
|
|
|
336
181
|
current.status = trimmed.slice("Status: ".length);
|
|
337
182
|
continue;
|
|
338
183
|
}
|
|
184
|
+
if (trimmed.startsWith("Staging progress: ")) {
|
|
185
|
+
current.stagingProgress = trimmed.slice("Staging progress: ".length);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (trimmed.startsWith("Current file: ")) {
|
|
189
|
+
current.currentFile = trimmed.slice("Current file: ".length);
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
339
192
|
if (trimmed.startsWith("Last error: ")) {
|
|
340
193
|
current.lastError = trimmed.slice("Last error: ".length);
|
|
341
194
|
continue;
|
|
@@ -462,14 +315,14 @@ function createAbortError(handle) {
|
|
|
462
315
|
return error;
|
|
463
316
|
}
|
|
464
317
|
function resolveCommandPath(command) {
|
|
465
|
-
const result =
|
|
318
|
+
const result = spawnSync("which", [command], { encoding: "utf8" });
|
|
466
319
|
if (result.status !== 0) {
|
|
467
320
|
throw new Error(`failed to resolve ${command}`);
|
|
468
321
|
}
|
|
469
322
|
return result.stdout.trim();
|
|
470
323
|
}
|
|
471
324
|
function writeExecutableLink(directory, name, target) {
|
|
472
|
-
const linkPath =
|
|
325
|
+
const linkPath = join(directory, name);
|
|
473
326
|
try {
|
|
474
327
|
unlinkSync(linkPath);
|
|
475
328
|
} catch {
|
|
@@ -481,7 +334,7 @@ function writeExecutableLink(directory, name, target) {
|
|
|
481
334
|
exec "${escapeShell(target)}" "$@"
|
|
482
335
|
`;
|
|
483
336
|
writeFileSync(linkPath, script, { mode: 493 });
|
|
484
|
-
|
|
337
|
+
chmodSync(linkPath, 493);
|
|
485
338
|
return;
|
|
486
339
|
}
|
|
487
340
|
try {
|
|
@@ -494,7 +347,7 @@ exec "${escapeShell(target)}" "$@"
|
|
|
494
347
|
exec "${escapeShell(target)}" "$@"
|
|
495
348
|
`;
|
|
496
349
|
writeFileSync(linkPath, script, { mode: 493 });
|
|
497
|
-
|
|
350
|
+
chmodSync(linkPath, 493);
|
|
498
351
|
}
|
|
499
352
|
}
|
|
500
353
|
function escapeShell(value) {
|
|
@@ -502,9 +355,6 @@ function escapeShell(value) {
|
|
|
502
355
|
}
|
|
503
356
|
|
|
504
357
|
export {
|
|
505
|
-
AGENTCOMPUTER_MUTAGEN_PATH_ENV,
|
|
506
|
-
ensureMutagenCommandPath,
|
|
507
|
-
ensureBundledMutagenInstalled,
|
|
508
358
|
ensureMutagenSshEnvironment,
|
|
509
359
|
getHandleSessionName,
|
|
510
360
|
getDefaultMountIgnorePaths,
|