@ouro.bot/cli 0.1.0-alpha.1059 → 0.1.0-alpha.1061
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/changelog.json +6 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/daemon/cli-defaults.js +5 -0
- package/dist/heart/daemon/cli-exec.js +34 -0
- package/dist/heart/daemon/cli-help.js +3 -2
- package/dist/heart/daemon/cli-parse.js +37 -1
- package/dist/heart/versioning/host-self-update.js +118 -0
- package/dist/heart/versioning/self-update-defaults.js +43 -4
- package/dist/heart/versioning/self-update.js +13 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1061",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Unattended updates off macOS are opt-in per machine: lean, gentle, memory floor"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.1059",
|
|
6
12
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1061</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -71,6 +71,7 @@ const ouro_bot_global_installer_1 = require("../versioning/ouro-bot-global-insta
|
|
|
71
71
|
const version_intent_1 = require("../versioning/version-intent");
|
|
72
72
|
const self_update_defaults_1 = require("../versioning/self-update-defaults");
|
|
73
73
|
const update_state_1 = require("../versioning/update-state");
|
|
74
|
+
const host_self_update_1 = require("../versioning/host-self-update");
|
|
74
75
|
const logs_prune_1 = require("./logs-prune");
|
|
75
76
|
const daemon_health_1 = require("./daemon-health");
|
|
76
77
|
const log_tailer_1 = require("./log-tailer");
|
|
@@ -892,6 +893,10 @@ function createDefaultOuroCliDeps(socketPath = socket_client_1.DEFAULT_DAEMON_SO
|
|
|
892
893
|
getCurrentCliVersion: () => (0, ouro_version_manager_1.getCurrentVersion)({}),
|
|
893
894
|
getPreviousCliVersion: () => (0, ouro_version_manager_1.getPreviousVersion)({}),
|
|
894
895
|
listCliVersions: () => (0, ouro_version_manager_1.listInstalledVersions)({}),
|
|
896
|
+
hostSelfUpdate: {
|
|
897
|
+
read: () => (0, host_self_update_1.readHostSelfUpdateConfig)((0, ouro_version_manager_1.getOuroCliHome)()),
|
|
898
|
+
write: (config) => (0, host_self_update_1.writeHostSelfUpdateConfig)((0, ouro_version_manager_1.getOuroCliHome)(), config),
|
|
899
|
+
},
|
|
895
900
|
runSelfUpdate: async () => {
|
|
896
901
|
const { runSelfUpdate } = await Promise.resolve().then(() => __importStar(require("../versioning/self-update")));
|
|
897
902
|
const { createDefaultSelfUpdateDeps } = await Promise.resolve().then(() => __importStar(require("../versioning/self-update-defaults")));
|
|
@@ -6210,6 +6210,37 @@ async function executeSelfUpdate(command, deps) {
|
|
|
6210
6210
|
deps.writeStdout(message);
|
|
6211
6211
|
return message;
|
|
6212
6212
|
}
|
|
6213
|
+
async function executeHostSelfUpdate(command, deps) {
|
|
6214
|
+
const host = deps.hostSelfUpdate;
|
|
6215
|
+
if (!host)
|
|
6216
|
+
return returnCliFailure(deps, "self-update settings are not available in this runtime");
|
|
6217
|
+
const { DEFAULT_SELF_UPDATE_MIN_MEM_AVAILABLE_MB, DEFAULT_SELF_UPDATE_RESERVE_MB, renderHostSelfUpdateConfig } = await Promise.resolve().then(() => __importStar(require("../versioning/host-self-update")));
|
|
6218
|
+
const current = host.read();
|
|
6219
|
+
if (command.kind !== "self-update.status") {
|
|
6220
|
+
const next = command.kind === "self-update.enable"
|
|
6221
|
+
? {
|
|
6222
|
+
schemaVersion: 1,
|
|
6223
|
+
enabled: true,
|
|
6224
|
+
lean: command.full !== true,
|
|
6225
|
+
minMemAvailableMb: command.minMemAvailableMb ?? DEFAULT_SELF_UPDATE_MIN_MEM_AVAILABLE_MB,
|
|
6226
|
+
reserveMb: command.reserveMb ?? DEFAULT_SELF_UPDATE_RESERVE_MB,
|
|
6227
|
+
...(command.keepVersions !== undefined ? { keepVersions: command.keepVersions } : {}),
|
|
6228
|
+
}
|
|
6229
|
+
: {
|
|
6230
|
+
schemaVersion: 1, enabled: false, lean: current?.lean ?? true,
|
|
6231
|
+
minMemAvailableMb: current?.minMemAvailableMb ?? DEFAULT_SELF_UPDATE_MIN_MEM_AVAILABLE_MB,
|
|
6232
|
+
reserveMb: current?.reserveMb ?? DEFAULT_SELF_UPDATE_RESERVE_MB,
|
|
6233
|
+
...(current?.keepVersions !== undefined ? { keepVersions: current.keepVersions } : {}),
|
|
6234
|
+
};
|
|
6235
|
+
host.write(next);
|
|
6236
|
+
}
|
|
6237
|
+
const lines = [renderHostSelfUpdateConfig(command.kind === "self-update.status" ? current : host.read())];
|
|
6238
|
+
if (process.platform === "darwin")
|
|
6239
|
+
lines.push("(on macOS the launchd updater runs updates; this setting is for hosts without it)");
|
|
6240
|
+
const message = lines.join("\n");
|
|
6241
|
+
deps.writeStdout(message);
|
|
6242
|
+
return message;
|
|
6243
|
+
}
|
|
6213
6244
|
function withUpdateStatusLine(message, deps) {
|
|
6214
6245
|
let line = null;
|
|
6215
6246
|
try {
|
|
@@ -7733,6 +7764,9 @@ async function runOuroCli(args, deps = (0, cli_defaults_1.createDefaultOuroCliDe
|
|
|
7733
7764
|
if (command.kind === "self-update") {
|
|
7734
7765
|
return executeSelfUpdate(command, deps);
|
|
7735
7766
|
}
|
|
7767
|
+
if (command.kind === "self-update.enable" || command.kind === "self-update.disable" || command.kind === "self-update.status") {
|
|
7768
|
+
return executeHostSelfUpdate(command, deps);
|
|
7769
|
+
}
|
|
7736
7770
|
// ── versions command (local install list + published update truth, no daemon socket needed) ──
|
|
7737
7771
|
if (command.kind === "versions") {
|
|
7738
7772
|
const versions = deps.listCliVersions?.() ?? [];
|
|
@@ -71,9 +71,10 @@ exports.COMMAND_REGISTRY = {
|
|
|
71
71
|
},
|
|
72
72
|
"self-update": {
|
|
73
73
|
category: "Lifecycle",
|
|
74
|
-
description: "Update the installed CLI to the newest release from npm or GitHub, restart a running daemon on it, roll back if it fails its checks, and install the hourly launchd updater on macOS",
|
|
75
|
-
usage: "ouro self-update [--unattended]",
|
|
74
|
+
description: "Update the installed CLI to the newest release from npm or GitHub, restart a running daemon on it, roll back if it fails its checks, and install the hourly launchd updater on macOS. Elsewhere unattended updates are off until `ouro self-update enable` turns them on for this machine (lean install, lowest CPU and I/O priority, a MemAvailable floor and a disk reserve)",
|
|
75
|
+
usage: "ouro self-update [--unattended] | ouro self-update enable [--full] [--min-mem-available-mb <mb>] [--reserve-mb <mb>] [--keep-versions <n>] | ouro self-update disable | ouro self-update status",
|
|
76
76
|
example: "ouro self-update",
|
|
77
|
+
subcommands: ["enable", "disable", "status"],
|
|
77
78
|
},
|
|
78
79
|
versions: {
|
|
79
80
|
category: "Lifecycle",
|
|
@@ -239,6 +239,40 @@ function parseServiceCommand(args) {
|
|
|
239
239
|
throw new Error(SERVICE_USAGE);
|
|
240
240
|
return { kind: "service.install", init, print, ...(servicePath ? { path: servicePath } : {}), ...(Object.keys(supervision).length > 0 ? { supervision } : {}) };
|
|
241
241
|
}
|
|
242
|
+
const SELF_UPDATE_USAGE = "Usage: ouro self-update [--unattended] | ouro self-update enable [--full] [--min-mem-available-mb <mb>] [--reserve-mb <mb>] [--keep-versions <n>] | ouro self-update disable | ouro self-update status";
|
|
243
|
+
function parseSelfUpdateHostCommand(args) {
|
|
244
|
+
const [action, ...rest] = args;
|
|
245
|
+
if (action !== "enable") {
|
|
246
|
+
if (rest.length > 0)
|
|
247
|
+
throw new Error(SELF_UPDATE_USAGE);
|
|
248
|
+
return action === "disable" ? { kind: "self-update.disable" } : { kind: "self-update.status" };
|
|
249
|
+
}
|
|
250
|
+
const options = {};
|
|
251
|
+
const megabytes = (value) => value !== undefined && /^\d+$/.test(value) && Number(value) <= 1_048_576 ? Number(value) : undefined;
|
|
252
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
253
|
+
const token = rest[index];
|
|
254
|
+
const value = megabytes(rest[index + 1]);
|
|
255
|
+
if (token === "--full" && options.full === undefined) {
|
|
256
|
+
options.full = true;
|
|
257
|
+
}
|
|
258
|
+
else if (token === "--min-mem-available-mb" && value !== undefined && options.minMemAvailableMb === undefined) {
|
|
259
|
+
options.minMemAvailableMb = value;
|
|
260
|
+
index += 1;
|
|
261
|
+
}
|
|
262
|
+
else if (token === "--reserve-mb" && value !== undefined && options.reserveMb === undefined) {
|
|
263
|
+
options.reserveMb = value;
|
|
264
|
+
index += 1;
|
|
265
|
+
}
|
|
266
|
+
else if (token === "--keep-versions" && value !== undefined && value >= 2 && value <= 100 && options.keepVersions === undefined) {
|
|
267
|
+
options.keepVersions = value;
|
|
268
|
+
index += 1;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
throw new Error(SELF_UPDATE_USAGE);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return { kind: "self-update.enable", ...options };
|
|
275
|
+
}
|
|
242
276
|
function parseLogsCommand(args) {
|
|
243
277
|
if (args.length === 0)
|
|
244
278
|
return { kind: "daemon.logs" };
|
|
@@ -3282,9 +3316,11 @@ function parseOuroCommand(args) {
|
|
|
3282
3316
|
}
|
|
3283
3317
|
if (head === "self-update") {
|
|
3284
3318
|
const rest = args.slice(1);
|
|
3319
|
+
if (rest[0] === "enable" || rest[0] === "disable" || rest[0] === "status")
|
|
3320
|
+
return parseSelfUpdateHostCommand(rest);
|
|
3285
3321
|
const unknown = rest.filter((token) => token !== "--unattended");
|
|
3286
3322
|
if (unknown.length > 0)
|
|
3287
|
-
throw new Error(
|
|
3323
|
+
throw new Error(SELF_UPDATE_USAGE);
|
|
3288
3324
|
return { kind: "self-update", ...(rest.includes("--unattended") ? { unattended: true } : {}) };
|
|
3289
3325
|
}
|
|
3290
3326
|
if (head === "stop" || head === "down")
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MIN_SELF_UPDATE_KEEP_VERSIONS = exports.DEFAULT_SELF_UPDATE_KEEP_VERSIONS = exports.DEFAULT_SELF_UPDATE_RESERVE_MB = exports.DEFAULT_SELF_UPDATE_MIN_MEM_AVAILABLE_MB = void 0;
|
|
37
|
+
exports.hostSelfUpdatePath = hostSelfUpdatePath;
|
|
38
|
+
exports.readHostSelfUpdateConfig = readHostSelfUpdateConfig;
|
|
39
|
+
exports.writeHostSelfUpdateConfig = writeHostSelfUpdateConfig;
|
|
40
|
+
exports.renderHostSelfUpdateConfig = renderHostSelfUpdateConfig;
|
|
41
|
+
exports.memAvailableBytes = memAvailableBytes;
|
|
42
|
+
exports.gentleUpdaterCommand = gentleUpdaterCommand;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
46
|
+
exports.DEFAULT_SELF_UPDATE_MIN_MEM_AVAILABLE_MB = 250;
|
|
47
|
+
exports.DEFAULT_SELF_UPDATE_RESERVE_MB = 0;
|
|
48
|
+
exports.DEFAULT_SELF_UPDATE_KEEP_VERSIONS = 5;
|
|
49
|
+
exports.MIN_SELF_UPDATE_KEEP_VERSIONS = 2;
|
|
50
|
+
function hostSelfUpdatePath(cliHome) {
|
|
51
|
+
return path.join(cliHome, "self-update.json");
|
|
52
|
+
}
|
|
53
|
+
function nonNegativeInteger(value) {
|
|
54
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
55
|
+
}
|
|
56
|
+
/** The saved choice, or null when there is none or it is unreadable (both mean off). */
|
|
57
|
+
function readHostSelfUpdateConfig(cliHome) {
|
|
58
|
+
let parsed;
|
|
59
|
+
try {
|
|
60
|
+
parsed = JSON.parse(fs.readFileSync(hostSelfUpdatePath(cliHome), "utf8"));
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
if (parsed?.schemaVersion !== 1 || typeof parsed.enabled !== "boolean" || typeof parsed.lean !== "boolean"
|
|
66
|
+
|| !nonNegativeInteger(parsed.minMemAvailableMb) || !nonNegativeInteger(parsed.reserveMb)
|
|
67
|
+
|| (parsed.keepVersions !== undefined && (!nonNegativeInteger(parsed.keepVersions) || parsed.keepVersions < exports.MIN_SELF_UPDATE_KEEP_VERSIONS))) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
schemaVersion: 1, enabled: parsed.enabled, lean: parsed.lean, minMemAvailableMb: parsed.minMemAvailableMb, reserveMb: parsed.reserveMb,
|
|
72
|
+
...(parsed.keepVersions !== undefined ? { keepVersions: parsed.keepVersions } : {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function writeHostSelfUpdateConfig(cliHome, config) {
|
|
76
|
+
fs.mkdirSync(cliHome, { recursive: true });
|
|
77
|
+
const target = hostSelfUpdatePath(cliHome);
|
|
78
|
+
const temp = `${target}.${process.pid}.tmp`;
|
|
79
|
+
fs.writeFileSync(temp, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
|
|
80
|
+
fs.renameSync(temp, target);
|
|
81
|
+
(0, runtime_1.emitNervesEvent)({
|
|
82
|
+
component: "daemon",
|
|
83
|
+
event: "daemon.host_self_update_configured",
|
|
84
|
+
message: config.enabled ? "unattended updates turned on for this machine" : "unattended updates turned off for this machine",
|
|
85
|
+
meta: { ...config },
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function renderHostSelfUpdateConfig(config) {
|
|
89
|
+
if (!config?.enabled)
|
|
90
|
+
return "unattended updates on this machine: off (turn on with `ouro self-update enable`)";
|
|
91
|
+
return [
|
|
92
|
+
"unattended updates on this machine: on",
|
|
93
|
+
` install: ${config.lean ? "lean (no optional dependencies)" : "full"}, at the lowest CPU and I/O priority`,
|
|
94
|
+
` waits while MemAvailable is below ${config.minMemAvailableMb} MB`,
|
|
95
|
+
` keeps ${config.reserveMb} MB free beyond the new version and its 64 MiB headroom`,
|
|
96
|
+
` keeps the newest ${config.keepVersions ?? exports.DEFAULT_SELF_UPDATE_KEEP_VERSIONS} versions (current and previous always); when an install would not fit, first removes all but current and previous`,
|
|
97
|
+
].join("\n");
|
|
98
|
+
}
|
|
99
|
+
/** MemAvailable from /proc/meminfo text, in bytes, or null. */
|
|
100
|
+
function memAvailableBytes(meminfo) {
|
|
101
|
+
const match = /^MemAvailable:\s+(\d+)\s+kB$/m.exec(meminfo);
|
|
102
|
+
return match ? Number(match[1]) * 1024 : null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The updater's command line: `ionice -c 3` and `nice -n 19` in front of node
|
|
106
|
+
* when this host has them, so an install yields CPU and disk to everything else.
|
|
107
|
+
*/
|
|
108
|
+
function gentleUpdaterCommand(nodePath, args, which) {
|
|
109
|
+
const prefix = [];
|
|
110
|
+
const ionice = which("ionice");
|
|
111
|
+
if (ionice)
|
|
112
|
+
prefix.push(ionice, "-c", "3");
|
|
113
|
+
const nice = which("nice");
|
|
114
|
+
if (nice)
|
|
115
|
+
prefix.push(nice, "-n", "19");
|
|
116
|
+
const [file, ...rest] = [...prefix, nodePath, ...args];
|
|
117
|
+
return { file, args: rest };
|
|
118
|
+
}
|
|
@@ -52,6 +52,7 @@ const release_sources_1 = require("./release-sources");
|
|
|
52
52
|
const update_state_1 = require("./update-state");
|
|
53
53
|
const updater_launchd_1 = require("./updater-launchd");
|
|
54
54
|
const version_intent_1 = require("./version-intent");
|
|
55
|
+
const host_self_update_1 = require("./host-self-update");
|
|
55
56
|
const DAEMON_UP_TIMEOUT_MS = 10 * 60_000;
|
|
56
57
|
const DAEMON_HEALTH_WAIT_MS = 90_000;
|
|
57
58
|
function execFileText(command, args, options) {
|
|
@@ -214,7 +215,7 @@ function createDefaultSelfUpdateDeps(options = {}) {
|
|
|
214
215
|
},
|
|
215
216
|
activate: (version) => {
|
|
216
217
|
(0, ouro_version_manager_1.activateVersion)(version, { homeDir });
|
|
217
|
-
(0, ouro_version_manager_1.pruneOldVersions)(
|
|
218
|
+
(0, ouro_version_manager_1.pruneOldVersions)((0, host_self_update_1.readHostSelfUpdateConfig)(cliHome)?.keepVersions, { homeDir });
|
|
218
219
|
},
|
|
219
220
|
isDaemonRunning: () => (0, socket_client_1.checkDaemonSocketAlive)(socketPath),
|
|
220
221
|
runningDaemonVersion: async () => (await (0, socket_client_1.checkDaemonSocketAlive)(socketPath)) ? runningDaemonVersion(socketPath) : null,
|
|
@@ -242,8 +243,27 @@ function createDefaultSelfUpdateDeps(options = {}) {
|
|
|
242
243
|
const stats = fs.statfsSync(cliHome);
|
|
243
244
|
const current = (0, ouro_version_manager_1.getCurrentVersion)({ homeDir });
|
|
244
245
|
const currentBytes = current ? directoryBytes(path.join(cliHome, "versions", current)) : 0;
|
|
246
|
+
const reserveBytes = ((0, host_self_update_1.readHostSelfUpdateConfig)(cliHome)?.reserveMb ?? 0) * 1024 * 1024;
|
|
245
247
|
// Another version is about the size of this one; without one to measure, assume a full install.
|
|
246
|
-
return { freeBytes: stats.bavail * stats.bsize, neededBytes: (currentBytes || 256 * 1024 * 1024) + INSTALL_HEADROOM_BYTES };
|
|
248
|
+
return { freeBytes: stats.bavail * stats.bsize, neededBytes: (currentBytes || 256 * 1024 * 1024) + INSTALL_HEADROOM_BYTES + reserveBytes };
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
reclaimDisk: () => {
|
|
255
|
+
const pruned = (0, ouro_version_manager_1.pruneOldVersions)(0, { homeDir });
|
|
256
|
+
(0, runtime_1.emitNervesEvent)({ component: "daemon", event: "daemon.self_update_reclaimed_disk", message: "removed versions other than current and previous to make room for an update", meta: { deleted: pruned.deleted } });
|
|
257
|
+
},
|
|
258
|
+
memory: () => {
|
|
259
|
+
if (process.platform !== "linux")
|
|
260
|
+
return null;
|
|
261
|
+
try {
|
|
262
|
+
const availableBytes = (0, host_self_update_1.memAvailableBytes)(fs.readFileSync("/proc/meminfo", "utf8"));
|
|
263
|
+
if (availableBytes === null)
|
|
264
|
+
return null;
|
|
265
|
+
const floorMb = (0, host_self_update_1.readHostSelfUpdateConfig)(cliHome)?.minMemAvailableMb ?? host_self_update_1.DEFAULT_SELF_UPDATE_MIN_MEM_AVAILABLE_MB;
|
|
266
|
+
return { availableBytes, floorBytes: floorMb * 1024 * 1024 };
|
|
247
267
|
}
|
|
248
268
|
catch {
|
|
249
269
|
return null;
|
|
@@ -251,6 +271,21 @@ function createDefaultSelfUpdateDeps(options = {}) {
|
|
|
251
271
|
},
|
|
252
272
|
};
|
|
253
273
|
}
|
|
274
|
+
function whichCommand(command) {
|
|
275
|
+
for (const dir of (process.env.PATH ?? "").split(path.delimiter)) {
|
|
276
|
+
if (!dir)
|
|
277
|
+
continue;
|
|
278
|
+
const candidate = path.join(dir, command);
|
|
279
|
+
try {
|
|
280
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
281
|
+
return candidate;
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// not here
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
254
289
|
/** Room left after an install, for logs, sessions and the next update's download. */
|
|
255
290
|
const INSTALL_HEADROOM_BYTES = 64 * 1024 * 1024;
|
|
256
291
|
/** Disk used by a directory tree (allocated blocks, symlinks not followed). */
|
|
@@ -300,15 +335,19 @@ function nodeMajorOf(nodePath) {
|
|
|
300
335
|
*/
|
|
301
336
|
function launchUnattendedSelfUpdate(options = {}) {
|
|
302
337
|
const cliHome = (0, ouro_version_manager_1.getOuroCliHome)(options.homeDir ?? os.homedir());
|
|
338
|
+
const config = (0, host_self_update_1.readHostSelfUpdateConfig)(cliHome);
|
|
339
|
+
if (!config?.enabled)
|
|
340
|
+
return "not-enabled";
|
|
303
341
|
if (isSelfUpdateLockHeld(cliHome))
|
|
304
342
|
return "busy";
|
|
305
343
|
const launcher = path.join(cliHome, "bin", "ouro-launcher.js");
|
|
306
344
|
if (!fs.existsSync(launcher))
|
|
307
345
|
return "no-launcher";
|
|
308
|
-
const
|
|
346
|
+
const command = (0, host_self_update_1.gentleUpdaterCommand)(process.execPath, [launcher, "self-update", "--unattended"], whichCommand);
|
|
347
|
+
const child = (0, child_process_1.spawn)(command.file, command.args, {
|
|
309
348
|
detached: true,
|
|
310
349
|
stdio: "ignore",
|
|
311
|
-
env: { ...process.env, OURO_UNATTENDED: "1" },
|
|
350
|
+
env: { ...process.env, OURO_UNATTENDED: "1", ...(config.lean ? { npm_config_omit: "optional" } : {}) },
|
|
312
351
|
});
|
|
313
352
|
child.unref();
|
|
314
353
|
return "started";
|
|
@@ -163,7 +163,11 @@ async function runLocked(deps) {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
// 3. Install (when there is room), validate, smoke test.
|
|
166
|
-
|
|
166
|
+
let space = deps.diskSpace?.() ?? null;
|
|
167
|
+
if (space && space.freeBytes < space.neededBytes && deps.reclaimDisk) {
|
|
168
|
+
deps.reclaimDisk();
|
|
169
|
+
space = deps.diskSpace?.() ?? null;
|
|
170
|
+
}
|
|
167
171
|
if (space && space.freeBytes < space.neededBytes) {
|
|
168
172
|
const mib = (bytes) => Math.round(bytes / (1024 * 1024));
|
|
169
173
|
return finish("install-failed", {
|
|
@@ -171,6 +175,14 @@ async function runLocked(deps) {
|
|
|
171
175
|
latestVersion: latest,
|
|
172
176
|
});
|
|
173
177
|
}
|
|
178
|
+
const memory = deps.memory?.() ?? null;
|
|
179
|
+
if (memory && memory.availableBytes < memory.floorBytes) {
|
|
180
|
+
const mb = (bytes) => Math.round(bytes / (1024 * 1024));
|
|
181
|
+
return finish("install-failed", {
|
|
182
|
+
summary: `not enough free memory to install ${latest}: MemAvailable ${mb(memory.availableBytes)} MB, below the ${mb(memory.floorBytes)} MB floor; staying on ${currentVersion}`,
|
|
183
|
+
latestVersion: latest,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
174
186
|
let installSource;
|
|
175
187
|
try {
|
|
176
188
|
installSource = await deps.install(latest, lookup);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1061",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1061",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@ouro.bot/friends": "0.1.0-alpha.18",
|