@ouro.bot/cli 0.1.0-alpha.1162 → 0.1.0-alpha.1163

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.1163",
6
+ "changes": [
7
+ "The Copilot app sense's succession record (successions.json) keeps only the sessions the sidebar lists, plus a successor that has left it while the session it succeeds is still listed, instead of every session ever seen (8,269 entries on the Mac mini), and reads no history of a session the app no longer lists. isHandedOff and handoffSuccessors read the record the sense refreshes each minute."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1162",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1162",
2
+ "runtimeVersion": "0.1.0-alpha.1163",
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.1162</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1163</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -152,13 +152,13 @@ function status(row, rows, pending, options, successors) {
152
152
  // ---------- reading ----------
153
153
  async function listSessionsAndChats(options = {}, agentRoot) {
154
154
  const rows = await (0, client_1.listAppSessions)(options);
155
- const successors = agentRoot ? (0, coordinator_1.handoffSuccessors)(agentRoot, options) : undefined;
155
+ const successors = agentRoot ? (0, coordinator_1.handoffSuccessors)(agentRoot) : undefined;
156
156
  return { total: rows.length, items: rows.map(row => item(row, rows, options, successors)) };
157
157
  }
158
158
  async function getSessionsStatus(agentRoot, state, options = {}) {
159
159
  const rows = await (0, client_1.listAppSessions)(options);
160
160
  const pending = (0, store_1.readPending)(agentRoot);
161
- const successors = (0, coordinator_1.handoffSuccessors)(agentRoot, options);
161
+ const successors = (0, coordinator_1.handoffSuccessors)(agentRoot);
162
162
  const count = (keep) => rows.filter(keep).length;
163
163
  return {
164
164
  summary: {
@@ -170,7 +170,7 @@ async function getSessionsStatus(agentRoot, state, options = {}) {
170
170
  }
171
171
  async function getSession(agentRoot, id, options = {}) {
172
172
  const rows = await (0, client_1.listAppSessions)(options);
173
- return status(findSession(rows, id), rows, (0, store_1.readPending)(agentRoot), options, (0, coordinator_1.handoffSuccessors)(agentRoot, options));
173
+ return status(findSession(rows, id), rows, (0, store_1.readPending)(agentRoot), options, (0, coordinator_1.handoffSuccessors)(agentRoot));
174
174
  }
175
175
  // ---------- writing ----------
176
176
  /** Put a message into a session, as its message box does, and wait for the app to accept it (a session that is not loaded loads first). */
@@ -294,7 +294,7 @@ async function archiveSession(agentRoot, id, options = {}, ownerAsked = false) {
294
294
  const made = (0, store_1.readProbes)(agentRoot);
295
295
  let reason = null;
296
296
  if (!made[row.id]) {
297
- reason = ownerAsked ? "owner-asked" : (0, handoff_1.isHandedOff)(agentRoot, row, options) ? "handed-off" : null;
297
+ reason = ownerAsked ? "owner-asked" : (0, handoff_1.isHandedOff)(agentRoot, row) ? "handed-off" : null;
298
298
  if (!reason) {
299
299
  (0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.app_sessions_archive_declined", message: "declined to archive a session this agent did not create", meta: { session: row.id } });
300
300
  throw new Error(`session ${row.id} was not created by this agent, so it will not archive it unless the owner asked for it or it is oversize and a newer session names it as handed off (yours: ${Object.keys(made).join(", ") || "none"})`);
@@ -21,10 +21,10 @@ const handoff_1 = require("./handoff");
21
21
  */
22
22
  exports.REPORT_SCAN_BYTES = 16 * 1024 * 1024;
23
23
  const SEND_TOOL = /(?:^|-)send_session_message$/;
24
- /** `successorOf` over the hand-offs `handoff.ts` knows, read once, the first time a pass needs one. */
25
- function handoffSuccessors(agentRoot, client) {
24
+ /** `successorOf` over the hand-offs the sense last recorded (`handoff.ts` refreshes them each minute), read once, when first needed. */
25
+ function handoffSuccessors(agentRoot) {
26
26
  let successions = null;
27
- return id => (0, handoff_1.successorOf)(id, (successions ??= (0, handoff_1.refreshSuccessions)(agentRoot, client)));
27
+ return id => (0, handoff_1.successorOf)(id, (successions ??= (0, handoff_1.readSuccessions)(agentRoot)));
28
28
  }
29
29
  const listedAs = (rows, id) => id ? rows.find(row => row.id === id || row.workspaceId === id) : undefined;
30
30
  /** The session ids this lane sent messages to, oldest first, from the end of its history. */
@@ -63,8 +63,6 @@ const FREE_TEXT_OPENING_CHARS = 2_000;
63
63
  const FREE_TEXT_ID_WINDOW = 240;
64
64
  /** How far into a history the first message is looked for, and the most read per pass while waiting for the first turn. */
65
65
  exports.FIRST_MESSAGE_SCAN_BYTES = 1024 * 1024;
66
- /** Histories untouched this long are not read for a first message (an old one cannot hand off a live session). */
67
- const RECENT_MS = 7 * 86_400_000;
68
66
  const stateFile = (agentRoot) => path.join((0, store_1.appSessionsStateDir)(agentRoot), "successions.json");
69
67
  const readSuccessions = (agentRoot) => (0, store_1.readJson)(stateFile(agentRoot), { sessions: {} }).sessions;
70
68
  exports.readSuccessions = readSuccessions;
@@ -93,30 +91,30 @@ function historyIds(client) {
93
91
  return [];
94
92
  }
95
93
  }
96
- /** Read what is new in each recent history, as far as succession needs, and remember it. Returns every succession known. */
97
- function refreshSuccessions(agentRoot, client, now = Date.now()) {
94
+ /**
95
+ * Read what is new in the history of each session the app lists, as far as succession needs, and remember only those,
96
+ * plus each pending succession: one whose successor has left the sidebar while the session it succeeds is still listed,
97
+ * so that session can still be retired. Anything else the app no longer lists drops out, and the record stays the size
98
+ * of the sidebar.
99
+ */
100
+ function refreshSuccessions(agentRoot, client, listed) {
98
101
  const before = (0, exports.readSuccessions)(agentRoot);
102
+ const live = new Set(listed);
99
103
  const ids = historyIds(client);
100
104
  const known = (value) => {
101
105
  const matches = ids.filter(id => id.toLowerCase().startsWith(value));
102
106
  return matches.length === 1 ? matches[0] : null;
103
107
  };
104
108
  const next = {};
105
- for (const id of ids) {
109
+ for (const [id, entry] of Object.entries(before))
110
+ if (!live.has(id) && entry.predecessor && live.has(entry.predecessor))
111
+ next[id] = entry;
112
+ for (const id of live) {
106
113
  const was = before[id];
107
114
  if (was && !was.pending && (!was.predecessor || was.turned)) {
108
115
  next[id] = was;
109
116
  continue;
110
117
  }
111
- let modified;
112
- try {
113
- modified = fs.statSync((0, client_1.eventLogPath)(id, client)).mtimeMs;
114
- }
115
- catch {
116
- continue;
117
- }
118
- if (!was && now - modified > RECENT_MS)
119
- continue;
120
118
  const entry = was ? { ...was } : { predecessor: null, offset: 0, pending: true };
121
119
  let message = null;
122
120
  let turned = false;
@@ -172,13 +170,13 @@ function successorOf(id, successions) {
172
170
  }
173
171
  /**
174
172
  * Whether an oversize session has been handed off: it is in the oversize list, and a newer session's first message
175
- * names it as the session it succeeds.
173
+ * names it as the session it succeeds, as the sense last recorded.
176
174
  */
177
- function isHandedOff(agentRoot, row, options = {}) {
175
+ function isHandedOff(agentRoot, row) {
178
176
  const flagged = (0, store_1.readJson)(path.join((0, store_1.appSessionsStateDir)(agentRoot), "oversize.json"), {}).sessions ?? {};
179
177
  if (!flagged[row.id])
180
178
  return false;
181
- const successor = successorOf(row.id, refreshSuccessions(agentRoot, options));
179
+ const successor = successorOf(row.id, (0, exports.readSuccessions)(agentRoot));
182
180
  if (successor)
183
181
  (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_handoff_found", message: "found the successor that a session was handed off to", meta: { session: row.id, successor } });
184
182
  return successor !== null;
@@ -38,7 +38,7 @@ function childrenNote(predecessor, children) {
38
38
  async function retireSessions(agentRoot, rows, deps) {
39
39
  const send = deps.send ?? ((id, text) => (0, app_interface_1.deliverMessage)(id, text, "immediate", deps.client));
40
40
  const archive = deps.archive ?? (async (row, reason, note) => (await (0, app_interface_1.archiveRow)(agentRoot, row, reason, deps.client, { note, keepWorktree: true })).ok === true);
41
- const successions = (0, handoff_1.refreshSuccessions)(agentRoot, deps.client, deps.now);
41
+ const successions = (0, handoff_1.refreshSuccessions)(agentRoot, deps.client, rows.map(row => row.id));
42
42
  const listed = new Map(rows.map(row => [row.id, row]));
43
43
  const childrenOf = (id) => rows.filter(row => recordedCoordinator(row) === id);
44
44
  const busyChildren = (id, except) => childrenOf(id).filter(child => child.id !== except && !(settled(child) || (child.remote && !child.isRunning)));
@@ -186,7 +186,7 @@ async function noticeOversizedSessions(agentRoot, rows, deps) {
186
186
  const big = [...listed.values()].filter(row => next[row.id]);
187
187
  // A coordinator that is itself a giant is only messaged while it runs, since a message would reload it.
188
188
  // The coordinator now, not the one the app recorded: that one may have handed off and been archived.
189
- const successors = (0, coordinator_1.handoffSuccessors)(agentRoot, client);
189
+ const successors = (0, coordinator_1.handoffSuccessors)(agentRoot);
190
190
  const reachable = (lane) => {
191
191
  const found = (0, coordinator_1.coordinatorOf)(lane, rows.filter(row => !row.remote), { client, successorOf: successors });
192
192
  const row = found && "id" in found ? listed.get(found.id) : undefined;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1162",
3
+ "version": "0.1.0-alpha.1163",
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.1162",
9
+ "version": "0.1.0-alpha.1163",
10
10
  "bundleDependencies": [
11
11
  "@ouro.bot/friends"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1162",
3
+ "version": "0.1.0-alpha.1163",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },