aicomputer 0.1.18 → 0.1.19
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/{chunk-3ZUTAUUD.js → chunk-5JYMQXKN.js} +1 -1
- package/dist/chunk-GGBVVRLL.js +32 -0
- package/dist/chunk-MDSPJ57B.js +188 -0
- package/dist/{chunk-F2U4SFJ4.js → chunk-NN4GECN6.js} +11 -174
- package/dist/index.js +24 -34
- package/dist/lib/mount-mutagen.js +2 -1
- package/dist/lib/mount-reconcile.js +3 -2
- package/dist/lib/mutagen-runtime.d.ts +21 -0
- package/dist/lib/mutagen-runtime.js +20 -0
- package/dist/lib/upgrade-version.d.ts +10 -0
- package/dist/lib/upgrade-version.js +8 -0
- package/package.json +3 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/lib/upgrade-version.ts
|
|
2
|
+
function normalizeVersion(version) {
|
|
3
|
+
return version.split("-")[0].split(".").map((part) => Number.parseInt(part, 10)).map((part) => Number.isNaN(part) ? 0 : part);
|
|
4
|
+
}
|
|
5
|
+
function compareVersions(a, b) {
|
|
6
|
+
const left = normalizeVersion(a);
|
|
7
|
+
const right = normalizeVersion(b);
|
|
8
|
+
const size = Math.max(left.length, right.length);
|
|
9
|
+
for (let index = 0; index < size; index += 1) {
|
|
10
|
+
const diff = (left[index] ?? 0) - (right[index] ?? 0);
|
|
11
|
+
if (diff !== 0) {
|
|
12
|
+
return diff;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
function resolveLatestPublishedVersion(packument) {
|
|
18
|
+
const versions = Object.keys(packument.versions ?? {});
|
|
19
|
+
if (versions.length === 0) {
|
|
20
|
+
throw new Error("Registry response missing published versions");
|
|
21
|
+
}
|
|
22
|
+
const taggedLatest = packument["dist-tags"]?.latest;
|
|
23
|
+
if (taggedLatest && versions.includes(taggedLatest)) {
|
|
24
|
+
return taggedLatest;
|
|
25
|
+
}
|
|
26
|
+
return versions.sort((left, right) => compareVersions(right, left))[0];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
compareVersions,
|
|
31
|
+
resolveLatestPublishedVersion
|
|
32
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// src/lib/mutagen-runtime.ts
|
|
2
|
+
import { spawnSync } from "child_process";
|
|
3
|
+
import {
|
|
4
|
+
chmodSync,
|
|
5
|
+
existsSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
renameSync,
|
|
8
|
+
rmSync
|
|
9
|
+
} from "fs";
|
|
10
|
+
import { writeFile } from "fs/promises";
|
|
11
|
+
import { homedir } from "os";
|
|
12
|
+
import { dirname, join } from "path";
|
|
13
|
+
var BUNDLED_MUTAGEN_VERSION = "0.18.1";
|
|
14
|
+
var BUNDLED_MUTAGEN_DOWNLOAD_BASE = `https://github.com/mutagen-io/mutagen/releases/download/v${BUNDLED_MUTAGEN_VERSION}`;
|
|
15
|
+
var AGENTCOMPUTER_MUTAGEN_PATH_ENV = "AGENTCOMPUTER_MUTAGEN_PATH";
|
|
16
|
+
function getBundledMutagenAsset(platform = process.platform, arch = process.arch, homeDirectory = homedir()) {
|
|
17
|
+
if (!isSupportedPlatform(platform)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const assetArch = resolveMutagenAssetArch(arch);
|
|
21
|
+
if (!assetArch) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const assetName = `mutagen_${platform}_${assetArch}_v${BUNDLED_MUTAGEN_VERSION}.tar.gz`;
|
|
25
|
+
const installDir = join(
|
|
26
|
+
homeDirectory,
|
|
27
|
+
".agentcomputer",
|
|
28
|
+
"tools",
|
|
29
|
+
"mutagen",
|
|
30
|
+
`v${BUNDLED_MUTAGEN_VERSION}`,
|
|
31
|
+
`${platform}-${assetArch}`
|
|
32
|
+
);
|
|
33
|
+
return {
|
|
34
|
+
platform,
|
|
35
|
+
arch: assetArch,
|
|
36
|
+
version: BUNDLED_MUTAGEN_VERSION,
|
|
37
|
+
assetName,
|
|
38
|
+
downloadUrl: `${BUNDLED_MUTAGEN_DOWNLOAD_BASE}/${assetName}`,
|
|
39
|
+
installDir,
|
|
40
|
+
executablePath: join(installDir, "mutagen")
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function hasBundledMutagen() {
|
|
44
|
+
const asset = getBundledMutagenAsset();
|
|
45
|
+
return asset ? existsSync(asset.executablePath) : false;
|
|
46
|
+
}
|
|
47
|
+
function resolveSystemCommandPath(command) {
|
|
48
|
+
const result = spawnSync("which", [command], { encoding: "utf8" });
|
|
49
|
+
if (result.status !== 0) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const resolved = result.stdout.trim();
|
|
53
|
+
return resolved.length > 0 ? resolved : null;
|
|
54
|
+
}
|
|
55
|
+
async function ensureMutagenCommandPath() {
|
|
56
|
+
const asset = getBundledMutagenAsset();
|
|
57
|
+
if (asset && existsSync(asset.executablePath)) {
|
|
58
|
+
return asset.executablePath;
|
|
59
|
+
}
|
|
60
|
+
const systemPath = resolveSystemCommandPath("mutagen");
|
|
61
|
+
if (!asset) {
|
|
62
|
+
if (systemPath) {
|
|
63
|
+
return systemPath;
|
|
64
|
+
}
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Agent Computer does not ship bundled Mutagen for ${process.platform} ${process.arch}. Install Mutagen manually and rerun \`computer mount\`.`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
return await installBundledMutagen(asset);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (systemPath) {
|
|
73
|
+
return systemPath;
|
|
74
|
+
}
|
|
75
|
+
const reason = error instanceof Error ? error.message : "unknown Mutagen install failure";
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Failed to install Agent Computer's bundled Mutagen (${reason}). Check your network connection and rerun \`computer mount\`.`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function ensureBundledMutagenInstalled() {
|
|
82
|
+
const asset = getBundledMutagenAsset();
|
|
83
|
+
if (!asset) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`Agent Computer does not ship bundled Mutagen for ${process.platform} ${process.arch}.`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return installBundledMutagen(asset);
|
|
89
|
+
}
|
|
90
|
+
function resolveMutagenCommandPath() {
|
|
91
|
+
const overridden = process.env[AGENTCOMPUTER_MUTAGEN_PATH_ENV]?.trim();
|
|
92
|
+
if (overridden) {
|
|
93
|
+
return overridden;
|
|
94
|
+
}
|
|
95
|
+
const asset = getBundledMutagenAsset();
|
|
96
|
+
if (asset && existsSync(asset.executablePath)) {
|
|
97
|
+
return asset.executablePath;
|
|
98
|
+
}
|
|
99
|
+
const systemPath = resolveSystemCommandPath("mutagen");
|
|
100
|
+
if (systemPath) {
|
|
101
|
+
return systemPath;
|
|
102
|
+
}
|
|
103
|
+
if (!asset) {
|
|
104
|
+
throw new Error(
|
|
105
|
+
`Agent Computer does not ship bundled Mutagen for ${process.platform} ${process.arch}. Install Mutagen manually and rerun \`computer mount\`.`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
throw new Error(
|
|
109
|
+
"Mutagen is not installed yet. Re-run `computer mount` and Agent Computer will install its bundled copy."
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
async function installBundledMutagen(asset) {
|
|
113
|
+
if (existsSync(asset.executablePath)) {
|
|
114
|
+
return asset.executablePath;
|
|
115
|
+
}
|
|
116
|
+
mkdirSync(dirname(asset.installDir), { recursive: true });
|
|
117
|
+
const stagingDir = `${asset.installDir}.staging-${process.pid}-${Date.now()}`;
|
|
118
|
+
const archivePath = join(stagingDir, asset.assetName);
|
|
119
|
+
rmSync(stagingDir, { recursive: true, force: true });
|
|
120
|
+
if (existsSync(asset.installDir) && !existsSync(asset.executablePath)) {
|
|
121
|
+
rmSync(asset.installDir, { recursive: true, force: true });
|
|
122
|
+
}
|
|
123
|
+
mkdirSync(stagingDir, { recursive: true });
|
|
124
|
+
try {
|
|
125
|
+
const response = await fetch(asset.downloadUrl, {
|
|
126
|
+
headers: {
|
|
127
|
+
"User-Agent": "aicomputer-cli"
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
if (!response.ok || !response.body) {
|
|
131
|
+
throw new Error(`download failed with status ${response.status}`);
|
|
132
|
+
}
|
|
133
|
+
await writeFile(archivePath, Buffer.from(await response.arrayBuffer()), {
|
|
134
|
+
mode: 384
|
|
135
|
+
});
|
|
136
|
+
const extract = spawnSync("tar", ["-xzf", archivePath, "-C", stagingDir], {
|
|
137
|
+
encoding: "utf8"
|
|
138
|
+
});
|
|
139
|
+
if (extract.status !== 0) {
|
|
140
|
+
throw new Error(
|
|
141
|
+
extract.stderr.trim() || extract.stdout.trim() || `failed to extract ${asset.assetName}`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
if (!existsSync(join(stagingDir, "mutagen"))) {
|
|
145
|
+
throw new Error("archive did not contain the Mutagen executable");
|
|
146
|
+
}
|
|
147
|
+
chmodSync(join(stagingDir, "mutagen"), 493);
|
|
148
|
+
rmSync(archivePath, { force: true });
|
|
149
|
+
try {
|
|
150
|
+
renameSync(stagingDir, asset.installDir);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
if (!existsSync(asset.executablePath)) {
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
rmSync(stagingDir, { recursive: true, force: true });
|
|
156
|
+
}
|
|
157
|
+
return asset.executablePath;
|
|
158
|
+
} catch (error) {
|
|
159
|
+
rmSync(stagingDir, { recursive: true, force: true });
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function isSupportedPlatform(platform) {
|
|
164
|
+
return platform === "darwin" || platform === "linux";
|
|
165
|
+
}
|
|
166
|
+
function resolveMutagenAssetArch(arch) {
|
|
167
|
+
if (!isSupportedNodeArch(arch)) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
if (arch === "x64") {
|
|
171
|
+
return "amd64";
|
|
172
|
+
}
|
|
173
|
+
return arch;
|
|
174
|
+
}
|
|
175
|
+
function isSupportedNodeArch(arch) {
|
|
176
|
+
return arch === "arm64" || arch === "x64";
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export {
|
|
180
|
+
AGENTCOMPUTER_MUTAGEN_PATH_ENV,
|
|
181
|
+
getBundledMutagenAsset,
|
|
182
|
+
hasBundledMutagen,
|
|
183
|
+
resolveSystemCommandPath,
|
|
184
|
+
ensureMutagenCommandPath,
|
|
185
|
+
ensureBundledMutagenInstalled,
|
|
186
|
+
resolveMutagenCommandPath,
|
|
187
|
+
resolveMutagenAssetArch
|
|
188
|
+
};
|
|
@@ -3,174 +3,14 @@ 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-MDSPJ57B.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",
|
|
@@ -198,7 +38,7 @@ function createHandleSession(handle, config, paths, signal) {
|
|
|
198
38
|
const args = [
|
|
199
39
|
"sync",
|
|
200
40
|
"create",
|
|
201
|
-
|
|
41
|
+
join(paths.rootPath, handle),
|
|
202
42
|
`${handle}@${config.alias}:/home/node`,
|
|
203
43
|
"--name",
|
|
204
44
|
sessionName,
|
|
@@ -274,7 +114,7 @@ async function listOwnedSessions(config, paths, signal) {
|
|
|
274
114
|
lastError: session.lastError,
|
|
275
115
|
scanProblemCount: session.scanProblemCount,
|
|
276
116
|
conflictCount: session.conflictCount,
|
|
277
|
-
legacy: session.name !== expectedName || session.betaUrl !== expectedBeta || alphaPath !== resolve(
|
|
117
|
+
legacy: session.name !== expectedName || session.betaUrl !== expectedBeta || alphaPath !== resolve(join(rootPath, handle))
|
|
278
118
|
};
|
|
279
119
|
}).filter((session) => session !== null);
|
|
280
120
|
return sessions.sort((left, right) => left.handle.localeCompare(right.handle));
|
|
@@ -462,14 +302,14 @@ function createAbortError(handle) {
|
|
|
462
302
|
return error;
|
|
463
303
|
}
|
|
464
304
|
function resolveCommandPath(command) {
|
|
465
|
-
const result =
|
|
305
|
+
const result = spawnSync("which", [command], { encoding: "utf8" });
|
|
466
306
|
if (result.status !== 0) {
|
|
467
307
|
throw new Error(`failed to resolve ${command}`);
|
|
468
308
|
}
|
|
469
309
|
return result.stdout.trim();
|
|
470
310
|
}
|
|
471
311
|
function writeExecutableLink(directory, name, target) {
|
|
472
|
-
const linkPath =
|
|
312
|
+
const linkPath = join(directory, name);
|
|
473
313
|
try {
|
|
474
314
|
unlinkSync(linkPath);
|
|
475
315
|
} catch {
|
|
@@ -481,7 +321,7 @@ function writeExecutableLink(directory, name, target) {
|
|
|
481
321
|
exec "${escapeShell(target)}" "$@"
|
|
482
322
|
`;
|
|
483
323
|
writeFileSync(linkPath, script, { mode: 493 });
|
|
484
|
-
|
|
324
|
+
chmodSync(linkPath, 493);
|
|
485
325
|
return;
|
|
486
326
|
}
|
|
487
327
|
try {
|
|
@@ -494,7 +334,7 @@ exec "${escapeShell(target)}" "$@"
|
|
|
494
334
|
exec "${escapeShell(target)}" "$@"
|
|
495
335
|
`;
|
|
496
336
|
writeFileSync(linkPath, script, { mode: 493 });
|
|
497
|
-
|
|
337
|
+
chmodSync(linkPath, 493);
|
|
498
338
|
}
|
|
499
339
|
}
|
|
500
340
|
function escapeShell(value) {
|
|
@@ -502,9 +342,6 @@ function escapeShell(value) {
|
|
|
502
342
|
}
|
|
503
343
|
|
|
504
344
|
export {
|
|
505
|
-
AGENTCOMPUTER_MUTAGEN_PATH_ENV,
|
|
506
|
-
ensureMutagenCommandPath,
|
|
507
|
-
ensureBundledMutagenInstalled,
|
|
508
345
|
ensureMutagenSshEnvironment,
|
|
509
346
|
getHandleSessionName,
|
|
510
347
|
getDefaultMountIgnorePaths,
|
package/dist/index.js
CHANGED
|
@@ -33,13 +33,10 @@ import {
|
|
|
33
33
|
timeAgo,
|
|
34
34
|
vncURL,
|
|
35
35
|
webURL
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-5JYMQXKN.js";
|
|
37
37
|
import {
|
|
38
|
-
AGENTCOMPUTER_MUTAGEN_PATH_ENV,
|
|
39
|
-
ensureBundledMutagenInstalled,
|
|
40
|
-
ensureMutagenCommandPath,
|
|
41
38
|
isAbortError
|
|
42
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-NN4GECN6.js";
|
|
43
40
|
import {
|
|
44
41
|
defaultMountServiceConfig,
|
|
45
42
|
ensureMountDirectories,
|
|
@@ -52,6 +49,15 @@ import {
|
|
|
52
49
|
writeMountControllerLock,
|
|
53
50
|
writeMountStatusSnapshot
|
|
54
51
|
} from "./chunk-KXLTHWW3.js";
|
|
52
|
+
import {
|
|
53
|
+
AGENTCOMPUTER_MUTAGEN_PATH_ENV,
|
|
54
|
+
ensureBundledMutagenInstalled,
|
|
55
|
+
ensureMutagenCommandPath
|
|
56
|
+
} from "./chunk-MDSPJ57B.js";
|
|
57
|
+
import {
|
|
58
|
+
compareVersions,
|
|
59
|
+
resolveLatestPublishedVersion
|
|
60
|
+
} from "./chunk-GGBVVRLL.js";
|
|
55
61
|
|
|
56
62
|
// src/index.ts
|
|
57
63
|
import { Command as Command15 } from "commander";
|
|
@@ -4563,21 +4569,6 @@ import ora10 from "ora";
|
|
|
4563
4569
|
var pkg2 = JSON.parse(
|
|
4564
4570
|
readFileSync2(new URL("../package.json", import.meta.url), "utf8")
|
|
4565
4571
|
);
|
|
4566
|
-
function normalizeVersion(version) {
|
|
4567
|
-
return version.split("-")[0].split(".").map((part) => Number.parseInt(part, 10)).map((part) => Number.isNaN(part) ? 0 : part);
|
|
4568
|
-
}
|
|
4569
|
-
function compareVersions(a, b) {
|
|
4570
|
-
const left = normalizeVersion(a);
|
|
4571
|
-
const right = normalizeVersion(b);
|
|
4572
|
-
const size = Math.max(left.length, right.length);
|
|
4573
|
-
for (let index = 0; index < size; index += 1) {
|
|
4574
|
-
const diff = (left[index] ?? 0) - (right[index] ?? 0);
|
|
4575
|
-
if (diff !== 0) {
|
|
4576
|
-
return diff;
|
|
4577
|
-
}
|
|
4578
|
-
}
|
|
4579
|
-
return 0;
|
|
4580
|
-
}
|
|
4581
4572
|
function resolveExecutablePath() {
|
|
4582
4573
|
const candidate = process.argv[1] || process.execPath;
|
|
4583
4574
|
try {
|
|
@@ -4625,8 +4616,9 @@ function findNixProfileElement(executablePath) {
|
|
|
4625
4616
|
}
|
|
4626
4617
|
return null;
|
|
4627
4618
|
}
|
|
4628
|
-
function resolveUpgradeCommand(method, executablePath) {
|
|
4619
|
+
function resolveUpgradeCommand(method, executablePath, targetVersion) {
|
|
4629
4620
|
const packageName = pkg2.name ?? "aicomputer";
|
|
4621
|
+
const packageSpec = `${packageName}@${targetVersion}`;
|
|
4630
4622
|
switch (method) {
|
|
4631
4623
|
case "nix": {
|
|
4632
4624
|
const element = findNixProfileElement(executablePath);
|
|
@@ -4644,34 +4636,32 @@ function resolveUpgradeCommand(method, executablePath) {
|
|
|
4644
4636
|
case "pnpm":
|
|
4645
4637
|
return {
|
|
4646
4638
|
command: "pnpm",
|
|
4647
|
-
args: ["add", "-g",
|
|
4648
|
-
label: `pnpm add -g ${
|
|
4639
|
+
args: ["add", "-g", packageSpec],
|
|
4640
|
+
label: `pnpm add -g ${packageSpec}`
|
|
4649
4641
|
};
|
|
4650
4642
|
case "yarn":
|
|
4651
4643
|
return {
|
|
4652
4644
|
command: "yarn",
|
|
4653
|
-
args: ["global", "add",
|
|
4654
|
-
label: `yarn global add ${
|
|
4645
|
+
args: ["global", "add", packageSpec],
|
|
4646
|
+
label: `yarn global add ${packageSpec}`
|
|
4655
4647
|
};
|
|
4656
4648
|
case "npm":
|
|
4657
4649
|
case "unknown":
|
|
4658
4650
|
return {
|
|
4659
4651
|
command: "npm",
|
|
4660
|
-
args: ["install", "-g",
|
|
4661
|
-
label: `npm install -g ${
|
|
4652
|
+
args: ["install", "-g", packageSpec],
|
|
4653
|
+
label: `npm install -g ${packageSpec}`
|
|
4662
4654
|
};
|
|
4663
4655
|
}
|
|
4664
4656
|
}
|
|
4665
4657
|
async function getLatestVersion(packageName) {
|
|
4666
|
-
const response = await fetch(`https://registry.npmjs.org/${packageName}
|
|
4658
|
+
const response = await fetch(`https://registry.npmjs.org/${packageName}`);
|
|
4667
4659
|
if (!response.ok) {
|
|
4668
4660
|
throw new Error(`Failed to check npm registry (${response.status})`);
|
|
4669
4661
|
}
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
}
|
|
4674
|
-
return payload.version;
|
|
4662
|
+
return resolveLatestPublishedVersion(
|
|
4663
|
+
await response.json()
|
|
4664
|
+
);
|
|
4675
4665
|
}
|
|
4676
4666
|
function attemptBundledMutagenRefresh(executablePath) {
|
|
4677
4667
|
const install = spawnSync(
|
|
@@ -4713,7 +4703,7 @@ var upgradeCommand = new Command13("upgrade").description("Update the CLI to the
|
|
|
4713
4703
|
const method = detectInstallMethod(executablePath);
|
|
4714
4704
|
let upgrade;
|
|
4715
4705
|
try {
|
|
4716
|
-
upgrade = resolveUpgradeCommand(method, executablePath);
|
|
4706
|
+
upgrade = resolveUpgradeCommand(method, executablePath, latestVersion);
|
|
4717
4707
|
} catch (error) {
|
|
4718
4708
|
spinner.fail(
|
|
4719
4709
|
error instanceof Error ? error.message : "Failed to prepare upgrade"
|
|
@@ -8,8 +8,9 @@ import {
|
|
|
8
8
|
listOwnedSessions,
|
|
9
9
|
selectPreferredSession,
|
|
10
10
|
terminateSession
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-NN4GECN6.js";
|
|
12
12
|
import "../chunk-KXLTHWW3.js";
|
|
13
|
+
import "../chunk-MDSPJ57B.js";
|
|
13
14
|
export {
|
|
14
15
|
createHandleSession,
|
|
15
16
|
ensureMutagenSshEnvironment,
|
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
planMountReconcile,
|
|
4
4
|
reconcileMounts,
|
|
5
5
|
teardownManagedSessions
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-5JYMQXKN.js";
|
|
7
|
+
import "../chunk-NN4GECN6.js";
|
|
8
8
|
import "../chunk-KXLTHWW3.js";
|
|
9
|
+
import "../chunk-MDSPJ57B.js";
|
|
9
10
|
export {
|
|
10
11
|
computeMountPlan,
|
|
11
12
|
planMountReconcile,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type SupportedPlatform = "darwin" | "linux";
|
|
2
|
+
type SupportedAssetArch = "amd64" | "arm64";
|
|
3
|
+
type BundledMutagenAsset = {
|
|
4
|
+
platform: SupportedPlatform;
|
|
5
|
+
arch: SupportedAssetArch;
|
|
6
|
+
version: string;
|
|
7
|
+
assetName: string;
|
|
8
|
+
downloadUrl: string;
|
|
9
|
+
installDir: string;
|
|
10
|
+
executablePath: string;
|
|
11
|
+
};
|
|
12
|
+
declare const AGENTCOMPUTER_MUTAGEN_PATH_ENV = "AGENTCOMPUTER_MUTAGEN_PATH";
|
|
13
|
+
declare function getBundledMutagenAsset(platform?: NodeJS.Platform, arch?: string, homeDirectory?: string): BundledMutagenAsset | null;
|
|
14
|
+
declare function hasBundledMutagen(): boolean;
|
|
15
|
+
declare function resolveSystemCommandPath(command: string): string | null;
|
|
16
|
+
declare function ensureMutagenCommandPath(): Promise<string>;
|
|
17
|
+
declare function ensureBundledMutagenInstalled(): Promise<string>;
|
|
18
|
+
declare function resolveMutagenCommandPath(): string;
|
|
19
|
+
declare function resolveMutagenAssetArch(arch: string): SupportedAssetArch | null;
|
|
20
|
+
|
|
21
|
+
export { AGENTCOMPUTER_MUTAGEN_PATH_ENV, type BundledMutagenAsset, ensureBundledMutagenInstalled, ensureMutagenCommandPath, getBundledMutagenAsset, hasBundledMutagen, resolveMutagenAssetArch, resolveMutagenCommandPath, resolveSystemCommandPath };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AGENTCOMPUTER_MUTAGEN_PATH_ENV,
|
|
3
|
+
ensureBundledMutagenInstalled,
|
|
4
|
+
ensureMutagenCommandPath,
|
|
5
|
+
getBundledMutagenAsset,
|
|
6
|
+
hasBundledMutagen,
|
|
7
|
+
resolveMutagenAssetArch,
|
|
8
|
+
resolveMutagenCommandPath,
|
|
9
|
+
resolveSystemCommandPath
|
|
10
|
+
} from "../chunk-MDSPJ57B.js";
|
|
11
|
+
export {
|
|
12
|
+
AGENTCOMPUTER_MUTAGEN_PATH_ENV,
|
|
13
|
+
ensureBundledMutagenInstalled,
|
|
14
|
+
ensureMutagenCommandPath,
|
|
15
|
+
getBundledMutagenAsset,
|
|
16
|
+
hasBundledMutagen,
|
|
17
|
+
resolveMutagenAssetArch,
|
|
18
|
+
resolveMutagenCommandPath,
|
|
19
|
+
resolveSystemCommandPath
|
|
20
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type RegistryPackument = {
|
|
2
|
+
"dist-tags"?: {
|
|
3
|
+
latest?: string;
|
|
4
|
+
};
|
|
5
|
+
versions?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
declare function compareVersions(a: string, b: string): number;
|
|
8
|
+
declare function resolveLatestPublishedVersion(packument: RegistryPackument): string;
|
|
9
|
+
|
|
10
|
+
export { compareVersions, resolveLatestPublishedVersion };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aicomputer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "Computer CLI - manage your Agent Computer machines from the terminal",
|
|
5
5
|
"homepage": "https://agentcomputer.ai",
|
|
6
6
|
"repository": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"registry": "https://registry.npmjs.org/"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "tsup src/index.ts src/lib/mount-config.ts src/lib/mount-host.ts src/lib/mount-mutagen.ts src/lib/mount-reconcile.ts --format esm --dts",
|
|
22
|
-
"dev": "tsup src/index.ts src/lib/mount-config.ts src/lib/mount-host.ts src/lib/mount-mutagen.ts src/lib/mount-reconcile.ts --format esm --watch",
|
|
21
|
+
"build": "tsup src/index.ts src/lib/mount-config.ts src/lib/mount-host.ts src/lib/mount-mutagen.ts src/lib/mount-reconcile.ts src/lib/mutagen-runtime.ts src/lib/upgrade-version.ts --format esm --dts",
|
|
22
|
+
"dev": "tsup src/index.ts src/lib/mount-config.ts src/lib/mount-host.ts src/lib/mount-mutagen.ts src/lib/mount-reconcile.ts src/lib/mutagen-runtime.ts src/lib/upgrade-version.ts --format esm --watch",
|
|
23
23
|
"postinstall": "node ./scripts/postinstall.mjs",
|
|
24
24
|
"prepack": "npm run build",
|
|
25
25
|
"sync:nix": "../../scripts/cli/sync-nix-package.sh",
|