@ouro.bot/cli 0.1.0-alpha.1046 → 0.1.0-alpha.1047

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 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.1047",
6
+ "changes": [
7
+ "Self-update off macOS: daemon schedules the updater, passes check free disk"
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1046",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1046",
2
+ "runtimeVersion": "0.1.0-alpha.1047",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -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.1046</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1047</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -611,6 +611,13 @@ async function handleAgentAskTurn(command, runtime) {
611
611
  message: question,
612
612
  }, runtime);
613
613
  }
614
+ /* v8 ignore start -- platform default: tests inject the launcher, and the launcher itself is production wiring @preserve */
615
+ function defaultSelfUpdateLauncher() {
616
+ if (process.platform === "darwin")
617
+ return null;
618
+ return async () => (await Promise.resolve().then(() => __importStar(require("../versioning/self-update-defaults")))).launchUnattendedSelfUpdate();
619
+ }
620
+ /* v8 ignore stop */
614
621
  class OuroDaemon {
615
622
  socketPath;
616
623
  processManager;
@@ -648,6 +655,7 @@ class OuroDaemon {
648
655
  orphanStartupDrain;
649
656
  socketAnswering;
650
657
  externalEventSourceReadiness;
658
+ selfUpdateLauncher;
651
659
  constructor(options) {
652
660
  this.socketPath = options.socketPath;
653
661
  this.processManager = options.processManager;
@@ -681,6 +689,7 @@ class OuroDaemon {
681
689
  this.schedulerFireConsumer = options.schedulerFireConsumer;
682
690
  this.orphanStartupDrain = options.orphanStartupDrain ?? drainOrphanProcessesBeforeStartup;
683
691
  this.socketAnswering = options.socketAnswering ?? socket_client_1.checkDaemonSocketAlive;
692
+ this.selfUpdateLauncher = options.selfUpdateLauncher !== undefined ? options.selfUpdateLauncher : defaultSelfUpdateLauncher();
684
693
  this.externalEventSourceReadiness = options.externalEventSourceReadiness ?? (async (agent, source) => {
685
694
  const { ensureSanctuarySourceRuntimeReady } = await Promise.resolve().then(() => __importStar(require("../../senses/sanctuary-runtime")));
686
695
  await ensureSanctuarySourceRuntimeReady(agent, source);
@@ -838,8 +847,20 @@ class OuroDaemon {
838
847
  });
839
848
  }
840
849
  else {
850
+ const launchSelfUpdate = this.selfUpdateLauncher;
841
851
  (0, update_checker_1.startUpdateChecker)({
842
852
  currentVersion,
853
+ ...(launchSelfUpdate ? {
854
+ onUpdate: async (update) => {
855
+ const outcome = await launchSelfUpdate();
856
+ (0, runtime_1.emitNervesEvent)({
857
+ component: "daemon",
858
+ event: "daemon.self_update_launched",
859
+ message: "update checker saw a newer release and asked the unattended updater to run",
860
+ meta: { currentVersion, latestVersion: update.latestVersion ?? null, outcome },
861
+ });
862
+ },
863
+ } : {}),
843
864
  deps: {
844
865
  distTag: update_checker_1.CLI_UPDATE_DIST_TAG,
845
866
  /* v8 ignore start -- integration: real HTTP fetch @preserve */
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.releaseSourceDeps = void 0;
37
37
  exports.isSelfUpdateLockHeld = isSelfUpdateLockHeld;
38
38
  exports.createDefaultSelfUpdateDeps = createDefaultSelfUpdateDeps;
39
+ exports.launchUnattendedSelfUpdate = launchUnattendedSelfUpdate;
39
40
  exports.ensureDefaultUpdaterAgent = ensureDefaultUpdaterAgent;
40
41
  exports.isDefaultUpdaterAgentInstalled = isDefaultUpdaterAgentInstalled;
41
42
  /* v8 ignore start -- production wiring for self-update: real network, npm, launchd and daemon socket; the logic it feeds is unit-tested through injected deps @preserve */
@@ -236,8 +237,52 @@ function createDefaultSelfUpdateDeps(options = {}) {
236
237
  },
237
238
  isDevMode: () => fs.existsSync(path.join(cliHome, "dev-config.json")),
238
239
  acquireLock: () => acquireLock(cliHome),
240
+ diskSpace: () => {
241
+ try {
242
+ const stats = fs.statfsSync(cliHome);
243
+ const current = (0, ouro_version_manager_1.getCurrentVersion)({ homeDir });
244
+ const currentBytes = current ? directoryBytes(path.join(cliHome, "versions", current)) : 0;
245
+ // 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 };
247
+ }
248
+ catch {
249
+ return null;
250
+ }
251
+ },
239
252
  };
240
253
  }
254
+ /** Room left after an install, for logs, sessions and the next update's download. */
255
+ const INSTALL_HEADROOM_BYTES = 64 * 1024 * 1024;
256
+ /** Disk used by a directory tree (allocated blocks, symlinks not followed). */
257
+ function directoryBytes(dir) {
258
+ let total = 0;
259
+ const pending = [dir];
260
+ while (pending.length > 0) {
261
+ const current = pending.pop();
262
+ let entries;
263
+ try {
264
+ entries = fs.readdirSync(current, { withFileTypes: true });
265
+ }
266
+ catch {
267
+ continue;
268
+ }
269
+ for (const entry of entries) {
270
+ const entryPath = path.join(current, entry.name);
271
+ if (entry.isDirectory()) {
272
+ pending.push(entryPath);
273
+ continue;
274
+ }
275
+ try {
276
+ const stat = fs.lstatSync(entryPath);
277
+ total += stat.blocks ? stat.blocks * 512 : stat.size;
278
+ }
279
+ catch {
280
+ // gone mid-walk
281
+ }
282
+ }
283
+ }
284
+ return total;
285
+ }
241
286
  function nodeMajorOf(nodePath) {
242
287
  try {
243
288
  fs.accessSync(nodePath, fs.constants.X_OK);
@@ -249,6 +294,25 @@ function nodeMajorOf(nodePath) {
249
294
  return null;
250
295
  }
251
296
  }
297
+ /**
298
+ * Starts one unattended `ouro self-update` pass as its own process group, so it outlives the daemon restart it may
299
+ * perform. Used where no launch agent schedules the updater (Linux). Returns what happened.
300
+ */
301
+ function launchUnattendedSelfUpdate(options = {}) {
302
+ const cliHome = (0, ouro_version_manager_1.getOuroCliHome)(options.homeDir ?? os.homedir());
303
+ if (isSelfUpdateLockHeld(cliHome))
304
+ return "busy";
305
+ const launcher = path.join(cliHome, "bin", "ouro-launcher.js");
306
+ if (!fs.existsSync(launcher))
307
+ return "no-launcher";
308
+ const child = (0, child_process_1.spawn)(process.execPath, [launcher, "self-update", "--unattended"], {
309
+ detached: true,
310
+ stdio: "ignore",
311
+ env: { ...process.env, OURO_UNATTENDED: "1" },
312
+ });
313
+ child.unref();
314
+ return "started";
315
+ }
252
316
  function ensureDefaultUpdaterAgent(options = {}) {
253
317
  // The package end-to-end test runs in a throwaway HOME; it must never load
254
318
  // a real launch agent on the host.
@@ -16,7 +16,8 @@ const ouro_version_manager_1 = require("./ouro-version-manager");
16
16
  * 2. Ask every release source for the newest version. When nothing is newer
17
17
  * but a running daemon still reports an older version (a pass was killed
18
18
  * between activation and restart), restart it on CurrentVersion.
19
- * 3. Install it, validate the payload and run its `--version` smoke test.
19
+ * 3. Unless the disk is too full for another version, install it, validate the
20
+ * payload and run its `--version` smoke test.
20
21
  * 4. Activate it. If the daemon was running, restart it on the new version
21
22
  * and check that it answers; otherwise leave the daemon stopped.
22
23
  * 5. On a failed check, reactivate the previous version, pin it with reason
@@ -161,7 +162,15 @@ async function runLocked(deps) {
161
162
  latestVersion: latest,
162
163
  });
163
164
  }
164
- // 3. Install, validate, smoke test.
165
+ // 3. Install (when there is room), validate, smoke test.
166
+ const space = deps.diskSpace?.() ?? null;
167
+ if (space && space.freeBytes < space.neededBytes) {
168
+ const mib = (bytes) => Math.round(bytes / (1024 * 1024));
169
+ return finish("install-failed", {
170
+ summary: `not enough free disk to install ${latest}: ${mib(space.freeBytes)} MiB free, about ${mib(space.neededBytes)} MiB needed; staying on ${currentVersion}`,
171
+ latestVersion: latest,
172
+ });
173
+ }
165
174
  let installSource;
166
175
  try {
167
176
  installSource = await deps.install(latest, lookup);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1046",
3
+ "version": "0.1.0-alpha.1047",
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.1046",
9
+ "version": "0.1.0-alpha.1047",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.78.0",
12
12
  "@ouro.bot/friends": "0.1.0-alpha.18",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1046",
3
+ "version": "0.1.0-alpha.1047",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },