@ouro.bot/cli 0.1.0-alpha.1152 → 0.1.0-alpha.1154
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/repertoire/tools-app-sessions.js +1 -1
- package/dist/senses/app-sessions/app-interface.js +16 -4
- package/dist/senses/app-sessions/digest.js +6 -0
- package/dist/senses/app-sessions/handoff.js +85 -0
- package/dist/senses/app-sessions/store.js +10 -0
- 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.1154",
|
|
6
|
+
"changes": [
|
|
7
|
+
"archive_session may now archive a session this agent did not create when it is flagged oversize and a newer session names it as handed off, or when the owner asked for it explicitly. Each such archive is logged and listed in the next status digest, and archiving is reversible."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1153",
|
|
12
|
+
"changes": [
|
|
13
|
+
"Releases no longer fail when npm lists a fresh version before it serves the version's tarball. The release check and the GitHub release step now wait, for up to about 20 minutes, for npm to serve that exact version's tarball, so each release still reaches npm and gets the GitHub release that hosts without npm access update from. 0.1.0-alpha.1151 hit this: npm still returned 404 for its tarball ten minutes after publishing it."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1152",
|
|
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.1154</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -104,7 +104,7 @@ exports.createSessionTool = define("create_session", "Start a session. With proj
|
|
|
104
104
|
}, [], write("opens a new agent session in the owner's Copilot app"), (args, agentRoot) => (0, app_interface_1.createSession)(agentRoot, args, clientOptions), ["name"]);
|
|
105
105
|
exports.answerSessionInputTool = define("answer_session_input", "Answer the question a session asked with ask_user and is blocked on. get_session shows it (awaiting_input.question, choices). A choice or free text. A question asked while this agent was not connected has no request id and cannot be answered here.", { session_id: session, answer: { type: "string" } }, ["session_id", "answer"], write("answers a question for the person in another agent session"), (args, agentRoot) => (0, app_interface_1.answerSessionInput)(agentRoot, args, clientOptions), ["session_id"]);
|
|
106
106
|
exports.respondToSessionPlanTool = define("respond_to_session_plan_v2", "Approve or reject the plan a session paused on (awaiting_plan_approval). feedback is sent to the session as a message after the decision.", { session_id: session, approved: { type: "boolean" }, selected_action: { type: "string", description: "One of awaiting_input.actions; the recommended one by default." }, feedback: { type: "string" } }, ["session_id", "approved"], write("approves or rejects another agent session's plan for the person"), (args, agentRoot) => (0, app_interface_1.respondToSessionPlan)(agentRoot, args, clientOptions), ["session_id"]);
|
|
107
|
-
exports.archiveSessionTool = define("archive_session", "Archive a session you created with create_session (a project session's worktree goes with it).", { session_id: session }, ["session_id"], write("archives a session in the owner's Copilot app"), (args, agentRoot) => (0, app_interface_1.archiveSession)(agentRoot, args.session_id, clientOptions), ["session_id"]);
|
|
107
|
+
exports.archiveSessionTool = define("archive_session", "Archive a session you created with create_session (a project session's worktree goes with it). A session you did not create is archived only when the owner asked for that session in this conversation (owner_asked: true) or when it is over the size limit and a newer session names it as handed off. Archiving can be undone, and each such archive is logged and shown in the next digest.", { session_id: session, owner_asked: { type: "boolean", description: "True only when the owner asked in this conversation for this session to be archived." } }, ["session_id"], write("archives a session in the owner's Copilot app"), (args, agentRoot) => (0, app_interface_1.archiveSession)(agentRoot, args.session_id, clientOptions, args.owner_asked === true), ["session_id"]);
|
|
108
108
|
exports.navigateToTool = define("navigate_to", "Show a session in the app's window, as following its app_url does.", { id: session }, ["id"], write("changes what the owner's Copilot app shows"), args => (0, app_interface_1.navigateTo)(args.id, clientOptions), ["id"]);
|
|
109
109
|
exports.saveSessionAutomationTool = define("save_session_automation", "Create or replace the automation that wakes a session on a schedule, or clear it. interval is once (run_at), minutes (every_minutes), daily or weekly (schedule_hour, schedule_minute, schedule_day), or cron (cron_expression, five fields, local time).", {
|
|
110
110
|
session_id: session, prompt: { type: "string" }, interval: { type: "string", enum: ["once", "minutes", "daily", "weekly", "cron"] }, run_at: { type: "string" }, every_minutes: { type: "number" },
|
|
@@ -52,6 +52,7 @@ const node_crypto_1 = require("node:crypto");
|
|
|
52
52
|
const os = __importStar(require("node:os"));
|
|
53
53
|
const runtime_1 = require("../../nerves/runtime");
|
|
54
54
|
const client_1 = require("./client");
|
|
55
|
+
const handoff_1 = require("./handoff");
|
|
55
56
|
const store_1 = require("./store");
|
|
56
57
|
/**
|
|
57
58
|
* The GitHub Copilot app's own interface, used the way a coordinating session uses its client tools: the same twelve
|
|
@@ -268,16 +269,27 @@ async function respondToSessionPlan(agentRoot, args, options = {}) {
|
|
|
268
269
|
return compact({ ok: responded.ok, approved, session_id: row.id, feedback_sent: told ? told.ok : undefined, error: responded.error });
|
|
269
270
|
}
|
|
270
271
|
/** Archive a session this agent created: its workspace when it has one (and the worktree with it), else the chat. */
|
|
271
|
-
async function archiveSession(agentRoot, id, options = {}) {
|
|
272
|
+
async function archiveSession(agentRoot, id, options = {}, ownerAsked = false) {
|
|
272
273
|
const row = await resolve(id, options);
|
|
273
274
|
const made = (0, store_1.readProbes)(agentRoot);
|
|
274
|
-
|
|
275
|
-
|
|
275
|
+
let reason = null;
|
|
276
|
+
if (!made[row.id]) {
|
|
277
|
+
reason = ownerAsked ? "owner-asked" : (0, handoff_1.isHandedOff)(agentRoot, row, options) ? "handed-off" : null;
|
|
278
|
+
if (!reason) {
|
|
279
|
+
(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 } });
|
|
280
|
+
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"})`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
276
283
|
const archived = row.workspaceId
|
|
277
284
|
? await ask({ type: "archive_workspace", workspace_id: row.workspaceId, delete_worktree: row.workspaceType === "worktree" }, (reply, requestId) => (reply.request_id === requestId ? (reply.type === "workspace_archived" ? "ok" : "fail") : "ignore"), ARCHIVE_WAIT_MS, options)
|
|
278
285
|
: await ask({ type: "archive_session", session_id: row.id }, (reply, requestId) => (reply.type === "general_chat_sessions_changed" ? "ok" : reply.request_id === requestId ? "fail" : "ignore"), ARCHIVE_WAIT_MS, options);
|
|
279
|
-
if (archived.ok)
|
|
286
|
+
if (archived.ok) {
|
|
280
287
|
(0, store_1.removeProbe)(agentRoot, row.id);
|
|
288
|
+
if (reason) {
|
|
289
|
+
(0, store_1.addArchiveLog)(agentRoot, { id: row.id, name: row.name, at: new Date(options.now?.() ?? Date.now()).toISOString(), reason });
|
|
290
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_archived_not_created", message: "archived a session this agent did not create", meta: { session: row.id, reason } });
|
|
291
|
+
}
|
|
292
|
+
}
|
|
281
293
|
else
|
|
282
294
|
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.app_sessions_archive_refused", message: "the Copilot app did not archive a session", meta: { session: row.id, error: archived.error } });
|
|
283
295
|
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_archived", message: "asked the Copilot app to archive a session", meta: { session: row.id, ok: archived.ok } });
|
|
@@ -157,6 +157,9 @@ async function buildDigest(input) {
|
|
|
157
157
|
unread.push((0, digest_sources_1.sourceFailed)(`merged today (${account.label})`, facts.error));
|
|
158
158
|
merged.push(facts);
|
|
159
159
|
}
|
|
160
|
+
const recentArchives = (0, store_1.readArchiveLog)(input.agentRoot)
|
|
161
|
+
.filter(entry => input.now - Date.parse(entry.at) < exports.CARD_WINDOW_MS)
|
|
162
|
+
.map(entry => ({ name: cut(entry.name, NAME_MAX), reason: entry.reason === "owner-asked" ? "you asked" : "handed off to a successor" }));
|
|
160
163
|
const digest = {
|
|
161
164
|
at: new Date(input.now).toISOString(),
|
|
162
165
|
appRunning: input.appRunning,
|
|
@@ -166,6 +169,7 @@ async function buildDigest(input) {
|
|
|
166
169
|
machine: machine.installed || machine.error ? machine : null,
|
|
167
170
|
drains,
|
|
168
171
|
merged,
|
|
172
|
+
...(recentArchives.length ? { archived: recentArchives } : {}),
|
|
169
173
|
unread,
|
|
170
174
|
tokens: 0,
|
|
171
175
|
};
|
|
@@ -225,6 +229,8 @@ function renderDigest(digest, now, plain = false) {
|
|
|
225
229
|
const prs = digest.merged.flatMap(account => account.prs).slice(0, 4).map(pr => `- ${pr.repo}#${pr.number} ${cut(pr.title, 70)}`);
|
|
226
230
|
blocks.push([`**Merged today** ${total}${digest.merged.length > 1 ? ` (${digest.merged.map(account => `${account.label} ${account.count}`).join(", ")})` : ""}`, ...prs].join("\n"));
|
|
227
231
|
}
|
|
232
|
+
if (digest.archived?.length)
|
|
233
|
+
blocks.push(["**Archived** (reversible)", ...digest.archived.map(item => `- ${item.name} — ${item.reason}`)].join("\n"));
|
|
228
234
|
if (digest.unread.length)
|
|
229
235
|
blocks.push(`Not read: ${digest.unread.join("; ")}`);
|
|
230
236
|
const text = blocks.join("\n\n");
|
|
@@ -0,0 +1,85 @@
|
|
|
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.isHandedOff = isHandedOff;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
40
|
+
const client_1 = require("./client");
|
|
41
|
+
const store_1 = require("./store");
|
|
42
|
+
const HEAD_BYTES = 16384;
|
|
43
|
+
const RECENT_MS = 7 * 86_400_000;
|
|
44
|
+
const HANDOFF_WORDS = /successor|hand-?off|handed off|carry on from/i;
|
|
45
|
+
/**
|
|
46
|
+
* Whether an oversize session has been handed off: it is in the oversize list, and a session newer than it opens by
|
|
47
|
+
* naming it in a hand-off. Only the first bytes of each recent log are read, so no large history is loaded.
|
|
48
|
+
*/
|
|
49
|
+
function isHandedOff(agentRoot, row, options = {}) {
|
|
50
|
+
const flagged = (0, store_1.readJson)(path.join((0, store_1.appSessionsStateDir)(agentRoot), "oversize.json"), {}).sessions ?? {};
|
|
51
|
+
if (!flagged[row.id])
|
|
52
|
+
return false;
|
|
53
|
+
const root = path.dirname(path.dirname((0, client_1.eventLogPath)(row.id, options)));
|
|
54
|
+
const born = Date.parse(String(row.createdAt));
|
|
55
|
+
let names;
|
|
56
|
+
try {
|
|
57
|
+
names = fs.readdirSync(root);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
for (const name of names) {
|
|
63
|
+
if (name === row.id)
|
|
64
|
+
continue;
|
|
65
|
+
try {
|
|
66
|
+
const file = path.join(root, name, "events.jsonl");
|
|
67
|
+
const stat = fs.statSync(file);
|
|
68
|
+
if (Date.now() - stat.mtimeMs > RECENT_MS || stat.birthtimeMs <= born)
|
|
69
|
+
continue;
|
|
70
|
+
const fd = fs.openSync(file, "r");
|
|
71
|
+
const buf = Buffer.alloc(HEAD_BYTES);
|
|
72
|
+
const len = fs.readSync(fd, buf, 0, buf.length, 0);
|
|
73
|
+
fs.closeSync(fd);
|
|
74
|
+
const head = buf.toString("utf8", 0, len);
|
|
75
|
+
if ((head.includes(row.id) || head.includes(row.id.slice(0, 8))) && HANDOFF_WORDS.test(head)) {
|
|
76
|
+
(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: name } });
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
@@ -50,6 +50,8 @@ exports.writeSnapshot = writeSnapshot;
|
|
|
50
50
|
exports.readSnapshot = readSnapshot;
|
|
51
51
|
exports.snapshotSummary = snapshotSummary;
|
|
52
52
|
exports.appSessionsSenseStatus = appSessionsSenseStatus;
|
|
53
|
+
exports.readArchiveLog = readArchiveLog;
|
|
54
|
+
exports.addArchiveLog = addArchiveLog;
|
|
53
55
|
const fs = __importStar(require("node:fs"));
|
|
54
56
|
const path = __importStar(require("node:path"));
|
|
55
57
|
const runtime_1 = require("../../nerves/runtime");
|
|
@@ -164,3 +166,11 @@ function appSessionsSenseStatus(enabled, agentRoot, now) {
|
|
|
164
166
|
return "disabled";
|
|
165
167
|
return `ready (${snapshotSummary(readSnapshot(agentRoot), now)}; app_sessions_* tools read and write them)`;
|
|
166
168
|
}
|
|
169
|
+
const archiveLogFile = (agentRoot) => path.join(appSessionsStateDir(agentRoot), "archive-log.json");
|
|
170
|
+
function readArchiveLog(agentRoot) {
|
|
171
|
+
return readJson(archiveLogFile(agentRoot), []);
|
|
172
|
+
}
|
|
173
|
+
/** Sessions archived that this agent did not create; the digest shows the recent ones. */
|
|
174
|
+
function addArchiveLog(agentRoot, entry) {
|
|
175
|
+
writeJson(archiveLogFile(agentRoot), [...readArchiveLog(agentRoot), entry].slice(-50));
|
|
176
|
+
}
|
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.1154",
|
|
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.1154",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@ouro.bot/friends": "0.1.0-alpha.18",
|