@ouro.bot/cli 0.1.0-alpha.1041 → 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 +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/daemon/daemon.js +21 -0
- package/dist/heart/providers/account-pool.js +43 -1
- package/dist/heart/providers/github-copilot.js +1 -0
- package/dist/heart/versioning/self-update-defaults.js +64 -0
- package/dist/heart/versioning/self-update.js +11 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
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
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1046",
|
|
12
|
+
"changes": [
|
|
13
|
+
"Account pool: the fleet gist write cadence (at most every 30 minutes) is shared by all of an agent's processes through state/account-burn-published.json, not kept per process."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1041",
|
|
6
18
|
"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.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 */
|
|
@@ -449,7 +449,10 @@ class AccountPool {
|
|
|
449
449
|
const now = this.now();
|
|
450
450
|
const publish = this.options.publishBurn;
|
|
451
451
|
const loaded = this.loadedReadings || !this.options.loadReadings;
|
|
452
|
-
if (!publish || !loaded
|
|
452
|
+
if (!publish || !loaded)
|
|
453
|
+
return;
|
|
454
|
+
this.loadSharedPublish();
|
|
455
|
+
if (now - this.lastPublish < (this.options.publishMs ?? 30 * 60 * 1000))
|
|
453
456
|
return;
|
|
454
457
|
const content = {
|
|
455
458
|
current: this.currentKey,
|
|
@@ -465,6 +468,7 @@ class AccountPool {
|
|
|
465
468
|
return;
|
|
466
469
|
this.lastPublish = now;
|
|
467
470
|
this.lastPublished = signature;
|
|
471
|
+
this.saveSharedPublish();
|
|
468
472
|
void publish({
|
|
469
473
|
agent: this.options.agent,
|
|
470
474
|
machine: this.options.machine ?? (this.machineName ??= (this.options.machineName ?? defaultMachineName)()),
|
|
@@ -472,6 +476,44 @@ class AccountPool {
|
|
|
472
476
|
...content,
|
|
473
477
|
});
|
|
474
478
|
}
|
|
479
|
+
/** Take in a later gist write by another of the agent's processes. */
|
|
480
|
+
loadSharedPublish() {
|
|
481
|
+
const file = this.options.publishedFile;
|
|
482
|
+
if (!file)
|
|
483
|
+
return;
|
|
484
|
+
try {
|
|
485
|
+
const shared = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
486
|
+
if (typeof shared.at === "number" && shared.at > this.lastPublish) {
|
|
487
|
+
this.lastPublish = shared.at;
|
|
488
|
+
this.lastPublished = typeof shared.signature === "string" ? shared.signature : "";
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
catch {
|
|
492
|
+
// No file yet, or another process is mid-write.
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
/** Claim this write before it goes out, so the agent's other processes hold off. */
|
|
496
|
+
saveSharedPublish() {
|
|
497
|
+
const file = this.options.publishedFile;
|
|
498
|
+
if (!file)
|
|
499
|
+
return;
|
|
500
|
+
try {
|
|
501
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
502
|
+
const temp = `${file}.${process.pid}.tmp`;
|
|
503
|
+
fs.writeFileSync(temp, JSON.stringify({ at: this.lastPublish, signature: this.lastPublished }));
|
|
504
|
+
fs.renameSync(temp, file);
|
|
505
|
+
}
|
|
506
|
+
catch (error) {
|
|
507
|
+
(0, runtime_1.emitNervesEvent)({
|
|
508
|
+
level: "warn",
|
|
509
|
+
component: "engine",
|
|
510
|
+
event: "engine.account_publish_share_failed",
|
|
511
|
+
message: "could not share the gist write time with the agent's other processes",
|
|
512
|
+
// fs only throws Errors.
|
|
513
|
+
meta: { agent: this.options.agent, error: error.message },
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
}
|
|
475
517
|
/** Share this process's last-hour request times with the agent's other processes. */
|
|
476
518
|
shareRequests() {
|
|
477
519
|
const dir = this.options.burnDir;
|
|
@@ -86,6 +86,7 @@ function createGithubCopilotPooledCaller(config, owner) {
|
|
|
86
86
|
switchLog: path.join(owner.agentRoot, "state", "account-switches.jsonl"),
|
|
87
87
|
burnDir: path.join(owner.agentRoot, "state", "account-burn"),
|
|
88
88
|
refusalsFile: path.join(owner.agentRoot, "state", "account-refusals.json"),
|
|
89
|
+
publishedFile: path.join(owner.agentRoot, "state", "account-burn-published.json"),
|
|
89
90
|
/* v8 ignore start -- network readers and publisher: each is tested in its own module @preserve */
|
|
90
91
|
loadReadings: async () => (0, fleet_readings_1.mergeReadings)(await (0, fleet_readings_1.loadFleetQuota)(gist), await (0, account_pool_1.fetchDirectReadings)(accounts)),
|
|
91
92
|
publishBurn: gist ? (burn) => (0, fleet_readings_1.publishAgentBurn)(gist, burn) : undefined,
|
|
@@ -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.
|
|
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);
|
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.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.
|
|
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",
|