@ouro.bot/cli 0.1.0-alpha.1062 → 0.1.0-alpha.1066

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.1066",
6
+ "changes": [
7
+ "Account pool: the pool saves its last quota readings to state/account-readings.json after each load and reads them at startup, so a freshly started process chooses its first account with what the fleet last knew. Before, the first turn after a restart chose with no readings and spent one request on an account the fleet already knew was out, got a 429, and only then switched."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1062",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1062",
2
+ "runtimeVersion": "0.1.0-alpha.1066",
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.1062</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1066</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -312,6 +312,44 @@ class AccountPool {
312
312
  this.accounts = accounts;
313
313
  this.options = options;
314
314
  this.loadSharedRefusals();
315
+ this.loadSavedReadings();
316
+ }
317
+ /** Start from the readings an earlier process saved; each keeps its own `at`, so fresher loads still win. */
318
+ loadSavedReadings() {
319
+ const file = this.options.readingsFile;
320
+ if (!file)
321
+ return;
322
+ try {
323
+ const saved = JSON.parse(fs.readFileSync(file, "utf8"));
324
+ if (!Array.isArray(saved))
325
+ return;
326
+ this.setReadings(saved.filter((reading) => !!reading && typeof reading === "object" && typeof reading.key === "string"
327
+ && (reading.leftPct === null || typeof reading.leftPct === "number")));
328
+ }
329
+ catch {
330
+ // No file yet, or another process is mid-write: start without saved readings.
331
+ }
332
+ }
333
+ saveReadings() {
334
+ const file = this.options.readingsFile;
335
+ if (!file)
336
+ return;
337
+ try {
338
+ fs.mkdirSync(path.dirname(file), { recursive: true });
339
+ const temp = `${file}.${process.pid}.tmp`;
340
+ fs.writeFileSync(temp, JSON.stringify(this.readings));
341
+ fs.renameSync(temp, file);
342
+ }
343
+ catch (error) {
344
+ (0, runtime_1.emitNervesEvent)({
345
+ level: "warn",
346
+ component: "engine",
347
+ event: "engine.account_readings_save_failed",
348
+ message: "could not save account pool readings for the agent's next process",
349
+ // fs only throws Errors.
350
+ meta: { agent: this.options.agent, error: error.message },
351
+ });
352
+ }
315
353
  }
316
354
  /** Take in refusals another of the agent's processes recorded; the later end wins. */
317
355
  loadSharedRefusals() {
@@ -381,6 +419,7 @@ class AccountPool {
381
419
  .then((readings) => {
382
420
  this.setReadings(readings);
383
421
  this.loadedReadings = true;
422
+ this.saveReadings();
384
423
  this.publishIfDue();
385
424
  })
386
425
  .catch((error) => {
@@ -87,6 +87,7 @@ function createGithubCopilotPooledCaller(config, owner) {
87
87
  burnDir: path.join(owner.agentRoot, "state", "account-burn"),
88
88
  refusalsFile: path.join(owner.agentRoot, "state", "account-refusals.json"),
89
89
  publishedFile: path.join(owner.agentRoot, "state", "account-burn-published.json"),
90
+ readingsFile: path.join(owner.agentRoot, "state", "account-readings.json"),
90
91
  /* v8 ignore start -- network readers and publisher: each is tested in its own module @preserve */
91
92
  loadReadings: async () => (0, fleet_readings_1.mergeReadings)(await (0, fleet_readings_1.loadFleetQuota)(gist), await (0, account_pool_1.fetchDirectReadings)(accounts)),
92
93
  publishBurn: gist ? (burn) => (0, fleet_readings_1.publishAgentBurn)(gist, burn) : undefined,
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1062",
3
+ "version": "0.1.0-alpha.1066",
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.1062",
9
+ "version": "0.1.0-alpha.1066",
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.1062",
3
+ "version": "0.1.0-alpha.1066",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },