@ouro.bot/cli 0.1.0-alpha.1144 → 0.1.0-alpha.1145

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.1145",
6
+ "changes": [
7
+ "The app-sessions sense now flags any Copilot app session whose history passes 500 MB, because the app loads a whole history into memory whenever it resumes that session, and several multi-GB ones froze a Mac. It asks the session's coordinator (or the session itself) once, with no model turn, to hand off to a fresh successor and to keep images out of chat, and records the session as never-resume."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1144",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1144",
2
+ "runtimeVersion": "0.1.0-alpha.1145",
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.1144</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1145</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -53,6 +53,7 @@ const digest_1 = require("./digest");
53
53
  const digest_push_1 = require("./digest-push");
54
54
  const client_1 = require("./client");
55
55
  const store_1 = require("./store");
56
+ const size_watch_1 = require("./size-watch");
56
57
  const waiting_prompts_1 = require("./waiting-prompts");
57
58
  const wake_runner_1 = require("./wake-runner");
58
59
  /**
@@ -240,6 +241,7 @@ function startAppSessionsSense(options) {
240
241
  let runnerPoll = Promise.resolve();
241
242
  const due = new Map();
242
243
  let waitingPoll = Promise.resolve();
244
+ let sizePoll = Promise.resolve();
243
245
  const notifyOwner = options.notifyOwner ?? (0, waiting_prompts_1.ownerNotifier)(options.agentName, agentRoot);
244
246
  let cancelDigest = null;
245
247
  let digestPoll = Promise.resolve();
@@ -250,6 +252,9 @@ function startAppSessionsSense(options) {
250
252
  waitingPoll = waitingPoll.then(() => (0, waiting_prompts_1.noticeWaitingPrompts)(agentRoot, taken, { notify: notifyOwner, now: now() })).catch((error) => {
251
253
  (0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.app_sessions_waiting_error", message: "could not check the sessions waiting on a prompt", meta: { error: error.message } });
252
254
  });
255
+ sizePoll = sizePoll.then(() => (0, size_watch_1.noticeOversizedSessions)(agentRoot, (0, client_1.listAppSessions)({ ...client, now: () => now() }), { notify: notifyOwner, now: now(), client })).then(() => undefined).catch((error) => {
256
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.app_sessions_oversize_error", message: "could not check the sessions' history sizes", meta: { error: error.message } });
257
+ });
253
258
  cancelSnapshot = schedule(snapshotTick, exports.SNAPSHOT_MS);
254
259
  };
255
260
  const watchTick = () => {
@@ -292,6 +297,6 @@ function startAppSessionsSense(options) {
292
297
  cancelDigest?.();
293
298
  (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_end", message: "app-sessions sense stopped", meta: { agent: options.agentName } });
294
299
  },
295
- done: () => Promise.all([inFlight, runnerPoll, waitingPoll, digestPoll]).then(() => undefined),
300
+ done: () => Promise.all([inFlight, runnerPoll, waitingPoll, sizePoll, digestPoll]).then(() => undefined),
296
301
  };
297
302
  }
@@ -0,0 +1,108 @@
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.neverResume = exports.readOversize = exports.OVERSIZE_BYTES = void 0;
37
+ exports.handoffNudge = handoffNudge;
38
+ exports.noticeOversizedSessions = noticeOversizedSessions;
39
+ const path = __importStar(require("node:path"));
40
+ const runtime_1 = require("../../nerves/runtime");
41
+ const owner_notice_1 = require("../shepherd/owner-notice");
42
+ const client_1 = require("./client");
43
+ const store_1 = require("./store");
44
+ /**
45
+ * A session's event log is loaded whole into memory when the app resumes it, and a log of several GB (almost all of it
46
+ * inline images) has frozen the machine. The snapshot already lists every session each minute, so this is deterministic
47
+ * and costs no model turn: a session whose `events.jsonl` passes the limit is flagged never-resume, and its coordinator
48
+ * (or the session itself when it has none) is asked once to hand it off to a fresh successor. A session that is not running
49
+ * and has no smaller coordinator is not messaged, because the message would reload it; the owner is told instead.
50
+ */
51
+ exports.OVERSIZE_BYTES = 500 * 1024 * 1024;
52
+ const stateFile = (agentRoot) => path.join((0, store_1.appSessionsStateDir)(agentRoot), "oversize.json");
53
+ const readOversize = (agentRoot) => (0, store_1.readJson)(stateFile(agentRoot), { sessions: {} }).sessions;
54
+ exports.readOversize = readOversize;
55
+ /** The ids of sessions flagged never-resume: a resume path asks this before it wakes one. */
56
+ const neverResume = (agentRoot) => Object.keys((0, exports.readOversize)(agentRoot));
57
+ exports.neverResume = neverResume;
58
+ const mb = (bytes) => bytes >= 1024 ** 3 ? `${(bytes / 1024 ** 3).toFixed(1)} GB` : `${Math.round(bytes / 1024 ** 2)} MB`;
59
+ function handoffNudge(name, bytes) {
60
+ return `The session "${(0, owner_notice_1.plain)(name, 60)}" has a ${mb(bytes)} history, over the ${mb(exports.OVERSIZE_BYTES)} limit: the app loads all of it into memory every time that session resumes, and a few like it froze this Mac. Please hand it off before it grows: write a checkpoint of its purpose and open work, start a fresh successor session that reads that checkpoint plus the tail of the old log, then archive the old one. Keep images out of chat (save screenshots and art as files and link the path): inline images are nearly all of the size.`;
61
+ }
62
+ /** Flag every over-limit session and nudge each once. Returns the number nudged (or owner-told) this run. */
63
+ async function noticeOversizedSessions(agentRoot, rows, deps) {
64
+ const size = deps.size ?? ((id) => (0, client_1.eventLogSize)(id, deps.client));
65
+ const send = deps.send ?? ((id, text) => (0, client_1.sendToAppSession)(id, text, { ...deps.client, delivery: "enqueue" }));
66
+ const before = (0, exports.readOversize)(agentRoot);
67
+ const sizes = new Map(rows.filter(row => !row.remote).map(row => [row.id, size(row.id)]));
68
+ const big = rows.filter(row => (sizes.get(row.id) ?? 0) > exports.OVERSIZE_BYTES);
69
+ const bigIds = new Set(big.map(row => row.id));
70
+ const next = {};
71
+ let nudged = 0;
72
+ const ownerLines = [];
73
+ for (const row of big) {
74
+ const bytes = sizes.get(row.id);
75
+ const entry = { ...before[row.id], bytes, name: row.name };
76
+ next[row.id] = entry;
77
+ if (entry.nudgedAt)
78
+ continue;
79
+ const parent = rows.find(other => other.id === row.coordinatingCreatorSessionId);
80
+ const recipient = parent && !bigIds.has(parent.id) ? parent.id : row.isRunning ? row.id : null;
81
+ if (recipient) {
82
+ const sent = await send(recipient, handoffNudge(row.name, bytes)).catch((error) => ({ ok: false, reply: "", messageId: null, error: error.message }));
83
+ if (!sent.ok)
84
+ continue;
85
+ entry.nudgedAt = new Date(deps.now).toISOString();
86
+ entry.to = recipient;
87
+ nudged += 1;
88
+ }
89
+ else {
90
+ // Not in memory and no smaller coordinator: any message would reload gigabytes, so the owner is told instead.
91
+ ownerLines.push(`- "${(0, owner_notice_1.plain)(row.name, 60)}" (${mb(bytes)})`);
92
+ entry.to = "owner";
93
+ }
94
+ }
95
+ if (ownerLines.length) {
96
+ const outcome = await deps.notify(`These sessions have histories over ${mb(exports.OVERSIZE_BYTES)} and cannot be nudged without reloading them. They need a hand-off to a fresh successor session (checkpoint, tail, archive); keep images out of chat:\n${ownerLines.join("\n")}`, big.filter(row => next[row.id].to === "owner").map(row => `oversize:${row.id}`));
97
+ if (outcome !== "pending")
98
+ for (const row of big)
99
+ if (next[row.id].to === "owner") {
100
+ next[row.id].nudgedAt = new Date(deps.now).toISOString();
101
+ nudged += 1;
102
+ }
103
+ }
104
+ (0, store_1.writeJson)(stateFile(agentRoot), { sessions: next });
105
+ if (nudged)
106
+ (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_oversize_nudge", message: "asked for a hand-off of Copilot app sessions whose history is over the limit", meta: { sessions: nudged } });
107
+ return nudged;
108
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1144",
3
+ "version": "0.1.0-alpha.1145",
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.1144",
9
+ "version": "0.1.0-alpha.1145",
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.1144",
3
+ "version": "0.1.0-alpha.1145",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },