@ouro.bot/cli 0.1.0-alpha.1024 → 0.1.0-alpha.1026

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,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.1026",
6
+ "changes": [
7
+ "Private-runtime sessions no longer grow without bound: superseded system prompts are dropped from session history, so a long-running agent's dialog.json stays small instead of reaching hundreds of megabytes and running Node out of memory."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1025",
12
+ "changes": [
13
+ "A Copilot account pool's refusals are shared by all of the agent's processes (state/account-refusals.json), so a spent account is skipped everywhere after one 402 or 429 instead of once per process."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1024",
6
18
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1024",
2
+ "runtimeVersion": "0.1.0-alpha.1026",
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.1024</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1026</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -279,6 +279,46 @@ class AccountPool {
279
279
  throw new Error("an account pool needs at least one account");
280
280
  this.accounts = accounts;
281
281
  this.options = options;
282
+ this.loadSharedRefusals();
283
+ }
284
+ /** Take in refusals another of the agent's processes recorded; the later end wins. */
285
+ loadSharedRefusals() {
286
+ const file = this.options.refusalsFile;
287
+ if (!file)
288
+ return;
289
+ try {
290
+ const shared = JSON.parse(fs.readFileSync(file, "utf8"));
291
+ for (const [key, until] of Object.entries(shared)) {
292
+ if (typeof until === "number" && until > this.now() && !(this.refused[key] >= until))
293
+ this.refused[key] = until;
294
+ }
295
+ }
296
+ catch {
297
+ // No file yet, or another process is mid-write: nothing to take in.
298
+ }
299
+ }
300
+ saveSharedRefusals() {
301
+ const file = this.options.refusalsFile;
302
+ if (!file)
303
+ return;
304
+ this.loadSharedRefusals();
305
+ const live = Object.fromEntries(Object.entries(this.refused).filter(([, until]) => until > this.now()));
306
+ try {
307
+ fs.mkdirSync(path.dirname(file), { recursive: true });
308
+ const temp = `${file}.${process.pid}.tmp`;
309
+ fs.writeFileSync(temp, JSON.stringify(live));
310
+ fs.renameSync(temp, file);
311
+ }
312
+ catch (error) {
313
+ (0, runtime_1.emitNervesEvent)({
314
+ level: "warn",
315
+ component: "engine",
316
+ event: "engine.account_refusals_save_failed",
317
+ message: "could not share account refusals with the agent's other processes",
318
+ // fs only throws Errors.
319
+ meta: { agent: this.options.agent, error: error.message },
320
+ });
321
+ }
282
322
  }
283
323
  now() {
284
324
  return (this.options.now ?? Date.now)();
@@ -328,6 +368,7 @@ class AccountPool {
328
368
  /** Called between turns: stay on the current account until it reaches the tranche cap. */
329
369
  beforeTurn() {
330
370
  void this.refreshIfStale();
371
+ this.loadSharedRefusals();
331
372
  const previous = this.currentKey;
332
373
  const caps = this.options.caps ?? tranche_1.DEFAULT_TRANCHE_CAPS;
333
374
  const next = chooseAccount(this.accounts, this.readings, { current: previous, refused: this.refused, now: this.now(), caps })
@@ -348,6 +389,7 @@ class AccountPool {
348
389
  const reset = this.readings.find((reading) => reading.key === key)?.reset;
349
390
  const until = refusalUntil(status, error, reset, this.now());
350
391
  this.refused[key] = until;
392
+ this.saveSharedRefusals();
351
393
  const next = chooseAccount(this.accounts, this.readings, { current: null, refused: this.refused, now: this.now(), caps: this.options.caps });
352
394
  if (!next || (0, exports.accountKey)(next) === key) {
353
395
  (0, runtime_1.emitNervesEvent)({
@@ -85,6 +85,7 @@ function createGithubCopilotPooledCaller(config, owner) {
85
85
  machine: config.fleetMachine,
86
86
  switchLog: path.join(owner.agentRoot, "state", "account-switches.jsonl"),
87
87
  burnDir: path.join(owner.agentRoot, "state", "account-burn"),
88
+ refusalsFile: path.join(owner.agentRoot, "state", "account-refusals.json"),
88
89
  /* v8 ignore start -- network readers and publisher: each is tested in its own module @preserve */
89
90
  loadReadings: async () => (0, fleet_readings_1.mergeReadings)(await (0, fleet_readings_1.loadFleetQuota)(gist), await (0, account_pool_1.fetchDirectReadings)(accounts)),
90
91
  publishBurn: gist ? (burn) => (0, fleet_readings_1.publishAgentBurn)(gist, burn) : undefined,
@@ -1395,6 +1395,42 @@ function retainedSourceEventIds(message, existing, used) {
1395
1395
  && messageFingerprint(candidate, true) === fingerprint);
1396
1396
  return originals.some(matches) || sanitizeProviderMessages(originals).some(matches) ? ids : null;
1397
1397
  }
1398
+ /**
1399
+ * The system prompt is rebuilt every turn (it carries live world state), so each turn used to add
1400
+ * a full copy to native history: one long-running private-runtime session held 3,773 of them (329 MB of
1401
+ * 357 MB) and parsing it ran Node out of memory. A system prompt the projection no longer uses is
1402
+ * not conversation, so it is dropped once superseded. System records without text (redaction
1403
+ * markers), events anything refers to, and the newest event (so sequence numbers never repeat)
1404
+ * are always kept.
1405
+ */
1406
+ function dropSupersededSystemPrompts(events, projectionEventIds, approvalSuspensions) {
1407
+ if (projectionEventIds.length === 0)
1408
+ return events;
1409
+ const keep = new Set(projectionEventIds);
1410
+ for (const event of events) {
1411
+ const relations = event.relations;
1412
+ for (const id of [relations.replyToEventId, relations.threadRootEventId, relations.supersedesEventId, relations.redactsEventId, ...relations.references]) {
1413
+ if (id)
1414
+ keep.add(id);
1415
+ }
1416
+ }
1417
+ for (const id of JSON.stringify(approvalSuspensions ?? []).match(/evt-\d+/g) ?? [])
1418
+ keep.add(id);
1419
+ const newestSequence = events.reduce((max, event) => Math.max(max, event.sequence), -Infinity);
1420
+ const kept = events.filter((event) => event.role !== "system"
1421
+ || typeof event.content !== "string"
1422
+ || keep.has(event.id)
1423
+ || event.sequence === newestSequence);
1424
+ if (kept.length < events.length) {
1425
+ (0, runtime_1.emitNervesEvent)({
1426
+ component: "mind",
1427
+ event: "mind.session_system_prompts_dropped",
1428
+ message: "dropped superseded system prompts from session history",
1429
+ meta: { dropped: events.length - kept.length, kept: kept.length },
1430
+ });
1431
+ }
1432
+ return kept;
1433
+ }
1398
1434
  function buildCanonicalSessionEnvelope(options) {
1399
1435
  const existing = options.existing;
1400
1436
  // Callers pass pre-sanitized messages + pre-captured ingress times.
@@ -1474,14 +1510,15 @@ function buildCanonicalSessionEnvelope(options) {
1474
1510
  usedEventIds.add(id);
1475
1511
  }
1476
1512
  const projectionEventIds = selectProjectedEventIds(currentMessages, currentEventIds, trimmedMessages);
1513
+ const keptEvents = dropSupersededSystemPrompts(events, projectionEventIds, existing?.approvalSuspensions);
1477
1514
  // Projection omissions are not authority to delete native history.
1478
1515
  const projectionIdSet = new Set(projectionEventIds);
1479
- const effectiveEvents = selectEffectiveSessionEvents(events);
1516
+ const effectiveEvents = selectEffectiveSessionEvents(keptEvents);
1480
1517
  const effectiveIds = new Set(effectiveEvents.map((event) => event.id));
1481
1518
  const evictedEvents = effectiveEvents.filter((event) => !projectionIdSet.has(event.id));
1482
1519
  const envelope = {
1483
1520
  version: 2,
1484
- events,
1521
+ events: keptEvents,
1485
1522
  projection: {
1486
1523
  eventIds: projectionEventIds.filter((id) => effectiveIds.has(id)),
1487
1524
  trimmed: evictedEvents.length > 0,
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1024",
3
+ "version": "0.1.0-alpha.1026",
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.1024",
9
+ "version": "0.1.0-alpha.1026",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.78.0",
12
12
  "@ouro.bot/friends": "0.1.0-alpha.17",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1024",
3
+ "version": "0.1.0-alpha.1026",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },