@visca-ai/mellowagents 0.1.0 → 0.1.2
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/index.js +181 -42
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
import { EventEmitter } from "node:events";
|
|
5
5
|
import childProcess, { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
6
6
|
import path, { basename, delimiter, dirname, join as join$1, resolve, win32 } from "node:path";
|
|
7
|
-
import fs, { chmodSync, chownSync, closeSync, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
7
|
+
import fs, { chmodSync, chownSync, closeSync, constants, existsSync, fstatSync, fsyncSync, linkSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
8
8
|
import process$1 from "node:process";
|
|
9
9
|
import { stripVTControlCharacters } from "node:util";
|
|
10
10
|
import { homedir, userInfo } from "node:os";
|
|
@@ -20419,10 +20419,10 @@ function nodeSatisfies(range, nodeVersion) {
|
|
|
20419
20419
|
}
|
|
20420
20420
|
// src/registry.ts
|
|
20421
20421
|
const DAEMON_PKG = "@visca-ai/mellowagents-daemon";
|
|
20422
|
-
const COMPUTER_PKG = "@
|
|
20422
|
+
const COMPUTER_PKG = "@visca-ai/mellowagents-computer";
|
|
20423
20423
|
const COMPUTER_APP_PKGS = {
|
|
20424
|
-
arm64: "@
|
|
20425
|
-
x64: "@
|
|
20424
|
+
arm64: "@visca-ai/mellowagents-computer-darwin-arm64",
|
|
20425
|
+
x64: "@visca-ai/mellowagents-computer-darwin-x64"
|
|
20426
20426
|
};
|
|
20427
20427
|
function registryBase() {
|
|
20428
20428
|
return (process.env.MELLOWAGENTS_NPM_REGISTRY ?? process.env.AGENTCONNECT_NPM_REGISTRY ?? "https://registry.npmjs.org").replace(/\/+$/, "");
|
|
@@ -20457,7 +20457,7 @@ async function resolveDaemonTarget(opts, name = DAEMON_PKG) {
|
|
|
20457
20457
|
};
|
|
20458
20458
|
}
|
|
20459
20459
|
async function downloadTarball(url) {
|
|
20460
|
-
const res = await fetch(url
|
|
20460
|
+
const res = await fetch(url);
|
|
20461
20461
|
if (!res.ok) throw new Error(`tarball download failed: HTTP ${res.status} ${res.statusText} (${url})`);
|
|
20462
20462
|
return Buffer.from(await res.arrayBuffer());
|
|
20463
20463
|
}
|
|
@@ -20732,13 +20732,19 @@ function classifyInvocation(argv) {
|
|
|
20732
20732
|
if (cmd !== void 0 && !CLI_OWNED_COMMANDS.has(cmd)) return "delegate";
|
|
20733
20733
|
return "cli";
|
|
20734
20734
|
}
|
|
20735
|
-
|
|
20735
|
+
// ../computer/distribution.json
|
|
20736
|
+
var appName = "Visca Managed agents Computer";
|
|
20737
|
+
var bundleId = "ai.visca.mellowagents.computer";
|
|
20738
|
+
var teamId = "4K8CVP69DX";
|
|
20739
|
+
var executable = "mellowagents-computer";
|
|
20740
|
+
const COMPUTER_BUNDLE = "mellowagents-computer.mjs";
|
|
20736
20741
|
const COMPUTER_PACKAGE_ENTRY = `dist/${COMPUTER_BUNDLE}`;
|
|
20737
|
-
const COMPUTER_APP =
|
|
20738
|
-
const COMPUTER_APP_BINARY =
|
|
20739
|
-
const COMPUTER_APP_ID =
|
|
20740
|
-
const
|
|
20741
|
-
const
|
|
20742
|
+
const COMPUTER_APP = `${appName}.app`;
|
|
20743
|
+
const COMPUTER_APP_BINARY = executable;
|
|
20744
|
+
const COMPUTER_APP_ID = bundleId;
|
|
20745
|
+
const COMPUTER_APP_TEAM = teamId;
|
|
20746
|
+
const COMPUTER_COMMAND_ENV = "MELLOWAGENTS_COMPUTER_COMMAND";
|
|
20747
|
+
const COMPUTER_SERVICE_ENTRY_ENV = "MELLOWAGENTS_COMPUTER_SERVICE_ENTRY";
|
|
20742
20748
|
const hostDefaults = () => ({
|
|
20743
20749
|
env: process.env,
|
|
20744
20750
|
platform: process.platform,
|
|
@@ -20746,9 +20752,10 @@ const hostDefaults = () => ({
|
|
|
20746
20752
|
exists: existsSync
|
|
20747
20753
|
});
|
|
20748
20754
|
function computerDataDir(host) {
|
|
20749
|
-
|
|
20755
|
+
const explicit = host.env.MELLOWAGENTS_COMPUTER_HOME ?? host.env.AGENTCONNECT_COMPUTER_HOME;
|
|
20756
|
+
if (explicit) return explicit;
|
|
20750
20757
|
if (host.platform === "win32") return win32.join(host.env.LOCALAPPDATA ?? win32.join(host.home, "AppData", "Local"), "Visca Managed agents", "computer");
|
|
20751
|
-
return join$1(host.home, ".
|
|
20758
|
+
return join$1(host.home, ".mellowagents", "computer");
|
|
20752
20759
|
}
|
|
20753
20760
|
const pathJoin = (platform) => platform === "win32" ? win32.join : join$1;
|
|
20754
20761
|
const storeEntry = (root, platform = process.platform) => pathJoin(platform)(root, "current", ...COMPUTER_PACKAGE_ENTRY.split("/"));
|
|
@@ -20758,12 +20765,12 @@ function computerArgv(argv) {
|
|
|
20758
20765
|
if (at === void 0 || argv[at] !== "computer") throw new Error(`not a computer invocation: ${argv.join(" ")}`);
|
|
20759
20766
|
return argv.slice(at + 1);
|
|
20760
20767
|
}
|
|
20761
|
-
const computerAppBinaries = (home) => [join$1(home, "Applications"), "/Applications"].map((dir) => join$1(dir, COMPUTER_APP, "Contents", "MacOS", COMPUTER_APP_BINARY));
|
|
20768
|
+
const computerAppBinaries = (home, directory) => [directory ?? join$1(home, "Applications"), "/Applications"].map((dir) => join$1(dir, COMPUTER_APP, "Contents", "MacOS", COMPUTER_APP_BINARY));
|
|
20762
20769
|
function computerAppRunner(host) {
|
|
20763
|
-
return host.platform === "darwin" ? computerAppBinaries(host.home).find((path) => host.exists(path)) : void 0;
|
|
20770
|
+
return host.platform === "darwin" ? computerAppBinaries(host.home, host.env.MELLOWAGENTS_COMPUTER_APPS_DIR).find((path) => host.exists(path)) : void 0;
|
|
20764
20771
|
}
|
|
20765
20772
|
function computerCandidates(host) {
|
|
20766
|
-
const override = host.env.AGENTCONNECT_COMPUTER_ENTRY;
|
|
20773
|
+
const override = host.env.MELLOWAGENTS_COMPUTER_ENTRY ?? host.env.AGENTCONNECT_COMPUTER_ENTRY;
|
|
20767
20774
|
if (override) return [override];
|
|
20768
20775
|
const root = computerDataDir(host);
|
|
20769
20776
|
return [storeEntry(root, host.platform), pathJoin(host.platform)(root, "app", COMPUTER_BUNDLE)];
|
|
@@ -20782,8 +20789,8 @@ function resolveComputerLaunch(args, host = hostDefaults(), node = process.execP
|
|
|
20782
20789
|
serviceEntry: managed
|
|
20783
20790
|
} : launch;
|
|
20784
20791
|
}
|
|
20785
|
-
if (host.env.AGENTCONNECT_COMPUTER_ENTRY) throw new Error(`
|
|
20786
|
-
throw new Error(`the computer daemon is not installed (looked in ${candidates.join(", ")}). Install it with \`${selfCommand} install\`, or set
|
|
20792
|
+
if (host.env.MELLOWAGENTS_COMPUTER_ENTRY ?? host.env.AGENTCONNECT_COMPUTER_ENTRY) throw new Error(`MELLOWAGENTS_COMPUTER_ENTRY points at a missing file`);
|
|
20793
|
+
throw new Error(`the computer daemon is not installed (looked in ${candidates.join(", ")}). Install it with \`${selfCommand} install\`, or set MELLOWAGENTS_COMPUTER_ENTRY to a built ${COMPUTER_BUNDLE}`);
|
|
20787
20794
|
}
|
|
20788
20795
|
// src/computer/run.ts
|
|
20789
20796
|
function childEnv(launch, selfCommand) {
|
|
@@ -20791,6 +20798,7 @@ function childEnv(launch, selfCommand) {
|
|
|
20791
20798
|
...process.env,
|
|
20792
20799
|
[COMPUTER_COMMAND_ENV]: selfCommand
|
|
20793
20800
|
};
|
|
20801
|
+
delete env.AGENTCONNECT_COMPUTER_SERVICE_ENTRY;
|
|
20794
20802
|
if (launch.serviceEntry) env[COMPUTER_SERVICE_ENTRY_ENV] = launch.serviceEntry;
|
|
20795
20803
|
else delete env[COMPUTER_SERVICE_ENTRY_ENV];
|
|
20796
20804
|
return env;
|
|
@@ -20849,8 +20857,89 @@ async function execComputer(launch, selfCommand) {
|
|
|
20849
20857
|
process.removeListener("SIGINT", onInt);
|
|
20850
20858
|
});
|
|
20851
20859
|
}
|
|
20860
|
+
// src/computer/migrate.ts
|
|
20861
|
+
const FILES = ["config.json", "computer-key.json"];
|
|
20862
|
+
function privateWindowsDirectory(path, run = (program, args) => execFileSync(program, args, {
|
|
20863
|
+
encoding: "utf8",
|
|
20864
|
+
windowsHide: true
|
|
20865
|
+
})) {
|
|
20866
|
+
const script = `$ErrorActionPreference='Stop'; $acl=Get-Acl -LiteralPath '${path.replace(/'/g, "''")}'; $me=[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value; $allowed=@($me,'S-1-5-18','S-1-5-32-544'); $owner=$acl.GetOwner([System.Security.Principal.SecurityIdentifier]).Value; $bad=@($acl.Access | Where-Object { $_.AccessControlType -eq 'Allow' -and $_.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier]).Value -notin $allowed }); @{ private=($owner -in $allowed -and $bad.Count -eq 0) } | ConvertTo-Json -Compress`;
|
|
20867
|
+
const result = JSON.parse(run("powershell.exe", [
|
|
20868
|
+
"-NoProfile",
|
|
20869
|
+
"-NonInteractive",
|
|
20870
|
+
"-EncodedCommand",
|
|
20871
|
+
Buffer.from(script, "utf16le").toString("base64")
|
|
20872
|
+
]));
|
|
20873
|
+
return typeof result === "object" && result !== null && "private" in result && result.private === true;
|
|
20874
|
+
}
|
|
20875
|
+
function migrateComputerData(source, destination) {
|
|
20876
|
+
if (resolve(source) === resolve(destination)) throw new Error("Migration source and destination must differ");
|
|
20877
|
+
if (!lstatSync(source).isDirectory() || lstatSync(source).isSymbolicLink()) throw new Error("Migration source must be a real directory");
|
|
20878
|
+
mkdirSync(destination, {
|
|
20879
|
+
recursive: true,
|
|
20880
|
+
mode: 448
|
|
20881
|
+
});
|
|
20882
|
+
if (!lstatSync(destination).isDirectory() || lstatSync(destination).isSymbolicLink()) throw new Error("Migration destination must be a real directory");
|
|
20883
|
+
if (process.platform === "win32" ? !privateWindowsDirectory(destination) : (lstatSync(destination).mode & 63) !== 0) throw new Error("Migration destination must be private to its owner; no metadata was copied");
|
|
20884
|
+
const staged = mkdtempSync(join$1(destination, ".migration-"));
|
|
20885
|
+
const published = [];
|
|
20886
|
+
try {
|
|
20887
|
+
for (const name of FILES) {
|
|
20888
|
+
const path = join$1(source, name);
|
|
20889
|
+
let fd;
|
|
20890
|
+
try {
|
|
20891
|
+
fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
20892
|
+
} catch (error) {
|
|
20893
|
+
if (error.code === "ENOENT") continue;
|
|
20894
|
+
throw new Error(`Cannot read migration file ${name}; source was not changed`);
|
|
20895
|
+
}
|
|
20896
|
+
try {
|
|
20897
|
+
const info = fstatSync(fd);
|
|
20898
|
+
if (!info.isFile() || info.size > 65536 || lstatSync(path).isSymbolicLink()) throw new Error(`Migration file ${name} must be a bounded regular file`);
|
|
20899
|
+
const bytes = readFileSync(fd);
|
|
20900
|
+
const parsed = JSON.parse(bytes.toString("utf8"));
|
|
20901
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`Migration file ${name} must contain an object`);
|
|
20902
|
+
const copy = openSync(join$1(staged, name), "wx", 384);
|
|
20903
|
+
try {
|
|
20904
|
+
writeFileSync(copy, bytes);
|
|
20905
|
+
fsyncSync(copy);
|
|
20906
|
+
} finally {
|
|
20907
|
+
closeSync(copy);
|
|
20908
|
+
}
|
|
20909
|
+
} finally {
|
|
20910
|
+
closeSync(fd);
|
|
20911
|
+
}
|
|
20912
|
+
}
|
|
20913
|
+
for (const name of FILES) {
|
|
20914
|
+
try {
|
|
20915
|
+
lstatSync(join$1(staged, name));
|
|
20916
|
+
} catch (error) {
|
|
20917
|
+
if (error.code === "ENOENT") continue;
|
|
20918
|
+
throw error;
|
|
20919
|
+
}
|
|
20920
|
+
linkSync(join$1(staged, name), join$1(destination, name));
|
|
20921
|
+
published.push(name);
|
|
20922
|
+
}
|
|
20923
|
+
if (!published.length) throw new Error("No configuration or registration metadata found to migrate");
|
|
20924
|
+
return published;
|
|
20925
|
+
} catch (error) {
|
|
20926
|
+
for (const name of published) {
|
|
20927
|
+
const target = join$1(destination, name);
|
|
20928
|
+
const original = lstatSync(join$1(staged, name));
|
|
20929
|
+
const actual = lstatSync(target);
|
|
20930
|
+
if (actual.ino === original.ino && actual.dev === original.dev) rmSync(target);
|
|
20931
|
+
}
|
|
20932
|
+
throw error;
|
|
20933
|
+
} finally {
|
|
20934
|
+
rmSync(staged, {
|
|
20935
|
+
recursive: true,
|
|
20936
|
+
force: true
|
|
20937
|
+
});
|
|
20938
|
+
}
|
|
20939
|
+
}
|
|
20852
20940
|
// src/computer/macos-app.ts
|
|
20853
20941
|
const appBinary = (app) => join$1(app, "Contents", "MacOS", COMPUTER_APP_BINARY);
|
|
20942
|
+
const appMenuHelper = (app) => join$1(dirname(appBinary(app)), `${COMPUTER_APP_BINARY}-menubar`);
|
|
20854
20943
|
function appPackage(arch) {
|
|
20855
20944
|
return arch === "arm64" || arch === "x64" ? COMPUTER_APP_PKGS[arch] : void 0;
|
|
20856
20945
|
}
|
|
@@ -20870,34 +20959,42 @@ function appVersion(app) {
|
|
|
20870
20959
|
}
|
|
20871
20960
|
}
|
|
20872
20961
|
function codesignVerify(app) {
|
|
20873
|
-
|
|
20874
|
-
"
|
|
20875
|
-
"
|
|
20876
|
-
|
|
20877
|
-
|
|
20878
|
-
|
|
20879
|
-
|
|
20880
|
-
|
|
20881
|
-
|
|
20882
|
-
|
|
20883
|
-
|
|
20962
|
+
for (const [path, identifier] of [[app, COMPUTER_APP_ID], [appMenuHelper(app), `${COMPUTER_APP_ID}.menubar`]]) {
|
|
20963
|
+
const requirement = `anchor apple generic and identifier "${identifier}" and certificate leaf[subject.OU] = "${COMPUTER_APP_TEAM}" and certificate leaf[field.1.2.840.113635.100.6.1.13] exists`;
|
|
20964
|
+
execFileSync("codesign", [
|
|
20965
|
+
"--verify",
|
|
20966
|
+
"--strict",
|
|
20967
|
+
"-R",
|
|
20968
|
+
`=${requirement}`,
|
|
20969
|
+
path
|
|
20970
|
+
], { stdio: "pipe" });
|
|
20971
|
+
const details = spawnSync("codesign", [
|
|
20972
|
+
"-d",
|
|
20973
|
+
"--verbose=2",
|
|
20974
|
+
path
|
|
20975
|
+
], { encoding: "utf8" });
|
|
20976
|
+
if (details.status !== 0 || !`${details.stdout}${details.stderr}`.split("\n").includes(`Identifier=${identifier}`) || !`${details.stdout}${details.stderr}`.split("\n").includes(`TeamIdentifier=${COMPUTER_APP_TEAM}`)) throw new Error(`${path} is not signed as ${identifier}; refusing to install it`);
|
|
20977
|
+
}
|
|
20884
20978
|
}
|
|
20885
20979
|
async function ensureApp(root, version, apps, arch, ops) {
|
|
20886
20980
|
const name = appPackage(arch);
|
|
20887
20981
|
if (!name) throw new Error(`no Visca Managed agents Computer app is built for ${arch} Macs`);
|
|
20888
20982
|
const pinned = pinnedApp(root, version, name);
|
|
20889
|
-
if (!pinned) {
|
|
20890
|
-
|
|
20983
|
+
if (!pinned || !/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(pinned)) throw new Error(`computer daemon ${version} does not pin an exact macOS app; refusing to run setup`);
|
|
20984
|
+
const dest = join$1(apps, COMPUTER_APP);
|
|
20985
|
+
if (appVersion(dest) === pinned) {
|
|
20986
|
+
ops.verifySignature(dest);
|
|
20987
|
+
ops.log(`${COMPUTER_APP} ${pinned} already installed`);
|
|
20891
20988
|
return;
|
|
20892
20989
|
}
|
|
20893
|
-
const dest = join$1(apps, COMPUTER_APP);
|
|
20894
|
-
if (appVersion(dest) === pinned) return void ops.log(`${COMPUTER_APP} ${pinned} already installed`);
|
|
20895
20990
|
const target = await ops.resolve(name, pinned);
|
|
20896
20991
|
ops.log(`downloading ${COMPUTER_APP} ${pinned}…`);
|
|
20897
20992
|
const buf = await ops.download(target.tarball);
|
|
20898
20993
|
verifyTarball(buf, target);
|
|
20899
20994
|
const tmp = join$1(apps, `.${COMPUTER_APP}.${pinned}.tmp`);
|
|
20900
20995
|
const old = join$1(apps, `.${COMPUTER_APP}.old`);
|
|
20996
|
+
let installed = false;
|
|
20997
|
+
const rename = ops.rename ?? renameSync;
|
|
20901
20998
|
mkdirSync(apps, { recursive: true });
|
|
20902
20999
|
rmSync(tmp, {
|
|
20903
21000
|
recursive: true,
|
|
@@ -20913,21 +21010,29 @@ async function ensureApp(root, version, apps, arch, ops) {
|
|
|
20913
21010
|
"--strip-components=1"
|
|
20914
21011
|
], { input: buf });
|
|
20915
21012
|
const staged = join$1(tmp, COMPUTER_APP);
|
|
20916
|
-
if (!existsSync(appBinary(staged))) throw new Error(`${name}@${pinned} has no ${COMPUTER_APP} — refusing to install`);
|
|
21013
|
+
if (!existsSync(appBinary(staged)) || !existsSync(appMenuHelper(staged))) throw new Error(`${name}@${pinned} has no ${COMPUTER_APP} — refusing to install`);
|
|
21014
|
+
if (appVersion(staged) !== pinned) throw new Error(`${name}@${pinned} contains a different app version`);
|
|
20917
21015
|
chmodSync(appBinary(staged), 493);
|
|
21016
|
+
chmodSync(appMenuHelper(staged), 493);
|
|
20918
21017
|
ops.verifySignature(staged);
|
|
20919
21018
|
rmSync(old, {
|
|
20920
21019
|
recursive: true,
|
|
20921
21020
|
force: true
|
|
20922
21021
|
});
|
|
20923
|
-
if (existsSync(dest))
|
|
20924
|
-
|
|
21022
|
+
if (existsSync(dest)) rename(dest, old);
|
|
21023
|
+
try {
|
|
21024
|
+
rename(staged, dest);
|
|
21025
|
+
installed = true;
|
|
21026
|
+
} catch (error) {
|
|
21027
|
+
if (existsSync(old) && !existsSync(dest)) rename(old, dest);
|
|
21028
|
+
throw error;
|
|
21029
|
+
}
|
|
20925
21030
|
} finally {
|
|
20926
21031
|
rmSync(tmp, {
|
|
20927
21032
|
recursive: true,
|
|
20928
21033
|
force: true
|
|
20929
21034
|
});
|
|
20930
|
-
rmSync(old, {
|
|
21035
|
+
if (installed) rmSync(old, {
|
|
20931
21036
|
recursive: true,
|
|
20932
21037
|
force: true
|
|
20933
21038
|
});
|
|
@@ -20992,7 +21097,30 @@ const COMPUTER_STORE = {
|
|
|
20992
21097
|
entry: COMPUTER_PACKAGE_ENTRY
|
|
20993
21098
|
};
|
|
20994
21099
|
const missing = (selfCommand) => (version) => () => `computer daemon ${version} is not installed — run \`${selfCommand} install --version ${version}\``;
|
|
21100
|
+
function assertOwnComputerStore(root) {
|
|
21101
|
+
let versions;
|
|
21102
|
+
try {
|
|
21103
|
+
versions = readdirSync(join$1(root, "versions"), { withFileTypes: true });
|
|
21104
|
+
} catch (error) {
|
|
21105
|
+
if (error.code === "ENOENT") return;
|
|
21106
|
+
throw error;
|
|
21107
|
+
}
|
|
21108
|
+
for (const entry of versions) {
|
|
21109
|
+
if (entry.isSymbolicLink()) throw new Error("An installed Computer directory is a symlink; no files were changed");
|
|
21110
|
+
if (!entry.isDirectory()) continue;
|
|
21111
|
+
const version = entry.name;
|
|
21112
|
+
let manifest;
|
|
21113
|
+
try {
|
|
21114
|
+
manifest = JSON.parse(readFileSync(join$1(root, "versions", version, "package.json"), "utf8"));
|
|
21115
|
+
} catch (error) {
|
|
21116
|
+
if (error.code === "ENOENT") continue;
|
|
21117
|
+
throw new Error("An installed Computer manifest cannot be verified; no files were changed");
|
|
21118
|
+
}
|
|
21119
|
+
if (manifest.name && manifest.name !== "@visca-ai/mellowagents-computer") throw new Error("This directory contains a previous Computer package family. Use the new default directory and `mellowagents computer migrate --from <previous-directory>`; its executable store and service were not changed.");
|
|
21120
|
+
}
|
|
21121
|
+
}
|
|
20995
21122
|
async function installComputer(root, opts, ops, selfCommand) {
|
|
21123
|
+
assertOwnComputerStore(root);
|
|
20996
21124
|
const channel = opts.channel ?? readMeta(root).channel;
|
|
20997
21125
|
const target = await ops.resolve({
|
|
20998
21126
|
...opts.version ? { to: opts.version } : {},
|
|
@@ -21015,6 +21143,7 @@ async function installComputer(root, opts, ops, selfCommand) {
|
|
|
21015
21143
|
return target.version;
|
|
21016
21144
|
}
|
|
21017
21145
|
async function upgradeComputer(root, opts, ops, selfCommand) {
|
|
21146
|
+
assertOwnComputerStore(root);
|
|
21018
21147
|
const meta = readMeta(root);
|
|
21019
21148
|
const channel = opts.channel ?? meta.channel;
|
|
21020
21149
|
const target = await ops.resolve({
|
|
@@ -21164,7 +21293,8 @@ const COMPUTER_OWNED_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
21164
21293
|
"uninstall",
|
|
21165
21294
|
"start",
|
|
21166
21295
|
"stop",
|
|
21167
|
-
"restart"
|
|
21296
|
+
"restart",
|
|
21297
|
+
"migrate"
|
|
21168
21298
|
]);
|
|
21169
21299
|
const HELP_FLAGS = /* @__PURE__ */ new Set([
|
|
21170
21300
|
"-h",
|
|
@@ -21182,7 +21312,7 @@ function computerContext(cli, host = hostDefaults()) {
|
|
|
21182
21312
|
log: (m) => console.log(m)
|
|
21183
21313
|
};
|
|
21184
21314
|
}
|
|
21185
|
-
const appsDir = (ctx) => join$1(ctx.host.home, "Applications");
|
|
21315
|
+
const appsDir = (ctx) => ctx.host.env.MELLOWAGENTS_COMPUTER_APPS_DIR ?? join$1(ctx.host.home, "Applications");
|
|
21186
21316
|
function storeOps(ctx) {
|
|
21187
21317
|
const mac = ctx.host.platform === "darwin";
|
|
21188
21318
|
const appOps = ctx.appOps ?? realAppOps(ctx.log, (name, version) => resolveTarget({
|
|
@@ -21292,9 +21422,9 @@ async function status(ctx) {
|
|
|
21292
21422
|
}
|
|
21293
21423
|
function removeLegacyLauncher(root, log) {
|
|
21294
21424
|
if (process.platform === "win32") return;
|
|
21295
|
-
const launcher = join$1(homedir(), ".local", "bin", "
|
|
21425
|
+
const launcher = join$1(homedir(), ".local", "bin", "mellowagents-computer");
|
|
21296
21426
|
try {
|
|
21297
|
-
if (readFileSync(launcher, "utf8").includes(join$1(root, "app", "
|
|
21427
|
+
if (readFileSync(launcher, "utf8").includes(join$1(root, "app", "mellowagents-computer.mjs"))) {
|
|
21298
21428
|
rmSync(launcher, { force: true });
|
|
21299
21429
|
log(`removed ${launcher}`);
|
|
21300
21430
|
}
|
|
@@ -21338,7 +21468,7 @@ async function uninstall(ctx, purge) {
|
|
|
21338
21468
|
});
|
|
21339
21469
|
}, { wait: true });
|
|
21340
21470
|
removeLegacyLauncher(ctx.root, ctx.log);
|
|
21341
|
-
if (ctx.host.platform === "darwin" && existsSync(join$1(appsDir(ctx),
|
|
21471
|
+
if (ctx.host.platform === "darwin" && existsSync(join$1(appsDir(ctx), COMPUTER_APP))) {
|
|
21342
21472
|
rmSync(join$1(appsDir(ctx), COMPUTER_APP), {
|
|
21343
21473
|
recursive: true,
|
|
21344
21474
|
force: true
|
|
@@ -21362,6 +21492,15 @@ function program(ctx) {
|
|
|
21362
21492
|
};
|
|
21363
21493
|
const p = new Command(ctx.self).description("Install, upgrade and diagnose the Visca Managed agents computer daemon (the computer-use daemon)").helpOption("-h, --help", "show this help").addHelpText("after", `\nAny other command runs in the installed computer daemon: setup, register, run, pause, resume, token, service,\ninstall-driver, install-ffmpeg, … (\`${ctx.self} setup --help\` lists them). Data dir: ${ctx.root}`);
|
|
21364
21494
|
const targetOptions = (c) => c.option("--version <version>", "a specific version instead of the channel latest").option("--channel <channel>", "stable|rc (default: the stored channel, else the CLI’s own)").option("--keep <n>", "how many versions to keep afterwards (0 disables cleanup)", String(3));
|
|
21495
|
+
p.command("migrate").description("Copy configuration and registration metadata from a previous installation; preserve its files and services").requiredOption("--from <directory>", "previous Computer data directory").action(async (o) => {
|
|
21496
|
+
try {
|
|
21497
|
+
ensureRoot(ctx.root);
|
|
21498
|
+
const files = await withVersionLock(ctx.root, "migrate", () => migrateComputerData(o.from, ctx.root));
|
|
21499
|
+
ctx.log(`Copied ${files.length} metadata files; the original files, services and macOS permissions were not changed.`);
|
|
21500
|
+
} catch (error) {
|
|
21501
|
+
fail("migrate", error);
|
|
21502
|
+
}
|
|
21503
|
+
});
|
|
21365
21504
|
targetOptions(p.command("install").description("Download and verify the computer daemon from npm, make it current, then run its setup (driver, grants, service)").option("--register <token>", "the one-time registration token from the console (Computers → Add Computer)").option("--cp-url <url>", "the Control Plane to register with (the console prints it)").option("--name <name>", "the Computer name shown in the console (default: this host name)").option("--no-service", "do not install the background service").option("--no-setup", "only install the package; run setup later").allowUnknownOption().allowExcessArguments()).action(async (o, cmd) => {
|
|
21366
21505
|
try {
|
|
21367
21506
|
ensureRoot(ctx.root);
|