@ouro.bot/cli 0.1.0-alpha.1080 → 0.1.0-alpha.1084
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/mind/prompt.js +12 -1
- package/dist/repertoire/skill-summaries.js +108 -0
- package/dist/senses/shepherd/copilot-app-holds.js +138 -0
- package/dist/senses/shepherd/copilot-app.js +30 -2
- package/dist/senses/shepherd/owner-notice.js +1 -0
- package/dist/senses/shepherd/sense.js +11 -2
- 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.1084",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Shepherd leaves Copilot app sessions alone while they wait on something besides their human: a session automation, a session they coordinate that is running or moved in the last two hours, a reply they asked another session for, or a message saying they are waiting. It answers a real stall once, then holds until the human writes again, read from the session's own log so a daemon restart cannot reset it. Its automatic messages are signed [Shepherd for <agent>], never as the human."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1083",
|
|
12
|
+
"changes": [
|
|
13
|
+
"The prompt's skills list shows each skill's own 'i use this when…' sentence (or frontmatter description), so a question a skill covers is answered with it, not from whatever the prompt already holds"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1080",
|
|
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.1084</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
package/dist/mind/prompt.js
CHANGED
|
@@ -70,6 +70,7 @@ const core_1 = require("../heart/core");
|
|
|
70
70
|
const ouro_version_manager_1 = require("../heart/versioning/ouro-version-manager");
|
|
71
71
|
const tools_1 = require("../repertoire/tools");
|
|
72
72
|
const skills_1 = require("../repertoire/skills");
|
|
73
|
+
const skill_summaries_1 = require("../repertoire/skill-summaries");
|
|
73
74
|
const identity_1 = require("../heart/identity");
|
|
74
75
|
const runtime_cwd_1 = require("../heart/runtime-cwd");
|
|
75
76
|
const config_1 = require("../heart/config");
|
|
@@ -850,7 +851,17 @@ function skillsSection() {
|
|
|
850
851
|
const names = (0, skills_1.listSkills)() || [];
|
|
851
852
|
if (!names.length)
|
|
852
853
|
return "";
|
|
853
|
-
|
|
854
|
+
const when = (0, skill_summaries_1.skillWhenLines)(names);
|
|
855
|
+
if (!when.size)
|
|
856
|
+
return `## my skills (use load_skill to activate)\n${names.join(", ")}`;
|
|
857
|
+
// A question one of these covers is answered with the skill, not from what this prompt already holds.
|
|
858
|
+
const described = names.filter((name) => when.has(name)).map((name) => `- ${name}: ${when.get(name)}`);
|
|
859
|
+
const rest = names.filter((name) => !when.has(name));
|
|
860
|
+
return [
|
|
861
|
+
"## my skills (use load_skill to activate; when a question matches one, i load it and follow it before answering)",
|
|
862
|
+
...described,
|
|
863
|
+
...(rest.length ? [`also: ${rest.join(", ")}`] : []),
|
|
864
|
+
].join("\n");
|
|
854
865
|
}
|
|
855
866
|
function toolContractsSection(channel, options) {
|
|
856
867
|
const lines = [
|
|
@@ -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.whenLine = whenLine;
|
|
37
|
+
exports.skillWhenLines = skillWhenLines;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const identity_1 = require("../heart/identity");
|
|
41
|
+
const runtime_1 = require("../nerves/runtime");
|
|
42
|
+
const MAX_WHEN_LENGTH = 220;
|
|
43
|
+
/**
|
|
44
|
+
* The sentence a skill uses to say when it applies: a frontmatter `description:`, else the first line that starts
|
|
45
|
+
* "i use this when", "use this when" or "use when". Shown beside the skill's name in the prompt, so a question that
|
|
46
|
+
* a skill covers is answered with the skill rather than from whatever the prompt already holds.
|
|
47
|
+
*/
|
|
48
|
+
function whenLine(markdown) {
|
|
49
|
+
const lines = markdown.split(/\r?\n/);
|
|
50
|
+
let body = lines;
|
|
51
|
+
if (lines[0]?.trim() === "---") {
|
|
52
|
+
const end = lines.indexOf("---", 1);
|
|
53
|
+
if (end > 0) {
|
|
54
|
+
const description = lines.slice(1, end).find((line) => /^description:\s*\S/i.test(line));
|
|
55
|
+
if (description)
|
|
56
|
+
return clip(description.replace(/^description:\s*/i, "").replace(/^["']|["']$/g, ""));
|
|
57
|
+
body = lines.slice(end + 1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const line = body.map((l) => l.trim()).find((l) => /^(i |we )?use (this|it|me) when\b|^use when\b/i.test(l));
|
|
61
|
+
return line ? clip(line) : null;
|
|
62
|
+
}
|
|
63
|
+
function clip(text) {
|
|
64
|
+
const sentence = text.trim().match(/^.*?[.!?](?=\s|$)/)?.[0] ?? text.trim();
|
|
65
|
+
return sentence.length > MAX_WHEN_LENGTH ? `${sentence.slice(0, MAX_WHEN_LENGTH - 1)}…` : sentence;
|
|
66
|
+
}
|
|
67
|
+
function skillPath(name) {
|
|
68
|
+
const roots = [
|
|
69
|
+
() => path.join((0, identity_1.getAgentRoot)(), "skills"),
|
|
70
|
+
() => path.join((0, identity_1.getAgentRoot)(), "skills", "protocols"),
|
|
71
|
+
() => path.join((0, identity_1.getRepoRoot)(), "skills"),
|
|
72
|
+
];
|
|
73
|
+
for (const root of roots) {
|
|
74
|
+
try {
|
|
75
|
+
const candidate = path.join(root(), `${name}.md`);
|
|
76
|
+
if (fs.existsSync(candidate))
|
|
77
|
+
return candidate;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// a root that cannot be resolved (no agent yet) has no skills
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/** Each skill's "when" sentence, for the skills it can read; skills without one are left out. */
|
|
86
|
+
function skillWhenLines(names) {
|
|
87
|
+
const found = new Map();
|
|
88
|
+
for (const name of names) {
|
|
89
|
+
const file = skillPath(name);
|
|
90
|
+
if (!file)
|
|
91
|
+
continue;
|
|
92
|
+
try {
|
|
93
|
+
const when = whenLine(fs.readFileSync(file, "utf-8"));
|
|
94
|
+
if (when)
|
|
95
|
+
found.set(name, when);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// an unreadable skill keeps just its name
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
(0, runtime_1.emitNervesEvent)({
|
|
102
|
+
component: "repertoire",
|
|
103
|
+
event: "repertoire.skill_when_lines",
|
|
104
|
+
message: "read when-lines for the prompt's skills list",
|
|
105
|
+
meta: { skills: names.length, described: found.size },
|
|
106
|
+
});
|
|
107
|
+
return found;
|
|
108
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
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.HANDOFF_TOOLS = exports.CHILD_RECENT_MS = void 0;
|
|
37
|
+
exports.databaseHold = databaseHold;
|
|
38
|
+
exports.copilotAppHold = copilotAppHold;
|
|
39
|
+
const fs = __importStar(require("node:fs"));
|
|
40
|
+
const path = __importStar(require("node:path"));
|
|
41
|
+
const sqlite_1 = require("../../heart/sqlite");
|
|
42
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
43
|
+
/**
|
|
44
|
+
* Why Shepherd leaves a stopped Copilot app session alone. A session that is waiting on something
|
|
45
|
+
* other than its human (a schedule, a lane it coordinates, a reply it asked for) is not stalled,
|
|
46
|
+
* and one Shepherd already nudged since its human last wrote is not nudged again. Every reason
|
|
47
|
+
* comes from the app's own records, so it holds across daemon restarts and across machines.
|
|
48
|
+
*/
|
|
49
|
+
/** A coordinated session that moved this recently still counts as live work. */
|
|
50
|
+
exports.CHILD_RECENT_MS = 2 * 3_600_000;
|
|
51
|
+
/** Tools that hand work to another session, whose answer the caller then waits for. */
|
|
52
|
+
exports.HANDOFF_TOOLS = new Set([
|
|
53
|
+
"send_session_message", "create_session", "write_agent", "open_pr_session", "open_issue_session", "fork_session", "run_dynamic_workflow",
|
|
54
|
+
]);
|
|
55
|
+
/** What the agent says when it is waiting on something other than its human. */
|
|
56
|
+
const WAITING_WORDS = new RegExp([
|
|
57
|
+
String.raw `\b(?:i'?m|i am|we'?re|still|now|currently|just)\s+(?:waiting|holding)\b`,
|
|
58
|
+
String.raw `\bwaiting\s+(?:on|for|until)\b`,
|
|
59
|
+
String.raw `\b(?:i'?ll|i will|will|going to)\s+(?:wait|hold|check back|report back|pick (?:it|this) up)\b`,
|
|
60
|
+
String.raw `\b(?:until|once|when)\s+(?:it|they|that|those|the \w+|#\d+|\w+'s \w+)\s+(?:lands?|merges?|finish(?:es)?|repl(?:y|ies)|reports?|returns?|completes?|comes? back|is (?:in|done|merged|green))\b`,
|
|
61
|
+
String.raw `\bbackground (?:agents?|tasks?|lanes?|work|shells?|jobs?)\b`,
|
|
62
|
+
String.raw `\blanes? (?:is|are) (?:running|working|under ?way)\b`,
|
|
63
|
+
String.raw `\bon hold\b`,
|
|
64
|
+
].join("|"), "i");
|
|
65
|
+
function hasTable(db, table) {
|
|
66
|
+
return !!db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table);
|
|
67
|
+
}
|
|
68
|
+
function columns(db, table) {
|
|
69
|
+
return new Set(db.prepare(`SELECT name FROM pragma_table_info('${table}')`).all().map(row => row.name));
|
|
70
|
+
}
|
|
71
|
+
/** The app database's reasons to leave the session alone, or null. A database that exists but cannot be read holds. */
|
|
72
|
+
function databaseHold(stateDir, sessionId, now) {
|
|
73
|
+
const file = path.join(stateDir, "data.db");
|
|
74
|
+
if (!fs.existsSync(file))
|
|
75
|
+
return null;
|
|
76
|
+
let db;
|
|
77
|
+
try {
|
|
78
|
+
db = (0, sqlite_1.openDatabase)(file, { readonly: true, fileMustExist: true, timeout: 3_000 });
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return `the Copilot app database could not be read (${String(error).slice(0, 120)})`;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
if (hasTable(db, "session_automations")) {
|
|
85
|
+
const automation = db.prepare(`SELECT name FROM session_automations
|
|
86
|
+
WHERE (session_id = ? OR owner_session_id = ?) AND paused_at IS NULL LIMIT 1`).get(sessionId, sessionId);
|
|
87
|
+
if (automation)
|
|
88
|
+
return `it has a session automation${automation.name ? ` ("${automation.name}")` : ""}, which wakes it on schedule`;
|
|
89
|
+
}
|
|
90
|
+
const children = [];
|
|
91
|
+
if (hasTable(db, "workspaces") && hasTable(db, "sessions")) {
|
|
92
|
+
const has = columns(db, "workspaces");
|
|
93
|
+
const by = ["creator_session_id", "coordinating_creator_session_id"].filter(column => has.has(column));
|
|
94
|
+
if (by.length > 0) {
|
|
95
|
+
children.push(...db.prepare(`SELECT s.id, s.title, s.is_running, s.updated_at FROM workspaces w JOIN sessions s ON s.id = w.session_id
|
|
96
|
+
WHERE w.archived_at IS NULL AND s.id != ? AND (${by.map(column => `w.${column} = ?`).join(" OR ")})`).all(sessionId, ...by.map(() => sessionId)));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (hasTable(db, "chat_parent_links") && hasTable(db, "sessions")) {
|
|
100
|
+
const has = columns(db, "chat_parent_links");
|
|
101
|
+
const by = ["parent_session_id", "coordinating_creator_session_id"].filter(column => has.has(column));
|
|
102
|
+
if (by.length > 0) {
|
|
103
|
+
children.push(...db.prepare(`SELECT s.id, s.title, s.is_running, s.updated_at FROM chat_parent_links c JOIN sessions s ON s.id = c.session_id
|
|
104
|
+
WHERE s.archived_at IS NULL AND s.id != ? AND (${by.map(column => `c.${column} = ?`).join(" OR ")})`).all(sessionId, ...by.map(() => sessionId)));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const live = children.filter(child => child.is_running === 1 || now - Date.parse(child.updated_at ?? "") < exports.CHILD_RECENT_MS);
|
|
108
|
+
if (live.length > 0) {
|
|
109
|
+
const named = live.slice(0, 3).map(child => child.title ? `"${child.title.slice(0, 60)}"` : child.id.slice(0, 8)).join(", ");
|
|
110
|
+
return `it coordinates ${live.length} live session${live.length === 1 ? "" : "s"} (${named}${live.length > 3 ? ", …" : ""}) and waits on them`;
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
return `the Copilot app database could not be read (${String(error).slice(0, 120)})`;
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
db.close();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** Why Shepherd must not nudge this stopped session, or null when it may judge it. */
|
|
122
|
+
function copilotAppHold(stateDir, sessionId, facts, lastBody, now) {
|
|
123
|
+
const reason = holdReason(stateDir, sessionId, facts, lastBody, now);
|
|
124
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.shepherd_copilot_app_hold", message: reason ? "Shepherd holds off a stopped Copilot app session" : "no hold on a stopped Copilot app session",
|
|
125
|
+
meta: { session: sessionId.slice(0, 8), held: reason !== null } });
|
|
126
|
+
return reason;
|
|
127
|
+
}
|
|
128
|
+
function holdReason(stateDir, sessionId, facts, lastBody, now) {
|
|
129
|
+
if (facts.shepherdAt !== null && (facts.humanAt === null || facts.humanAt < facts.shepherdAt)) {
|
|
130
|
+
return "Shepherd already nudged it once since its human last wrote; one nudge per stall";
|
|
131
|
+
}
|
|
132
|
+
const handoff = facts.lastTurnTools.find(tool => exports.HANDOFF_TOOLS.has(tool));
|
|
133
|
+
if (handoff)
|
|
134
|
+
return `its last turn handed work to another session (${handoff}), so it is waiting on that reply`;
|
|
135
|
+
if (lastBody && WAITING_WORDS.test(lastBody))
|
|
136
|
+
return "its last message says it is waiting on something other than its human";
|
|
137
|
+
return databaseHold(stateDir, sessionId, now);
|
|
138
|
+
}
|
|
@@ -49,6 +49,7 @@ const node_crypto_1 = require("node:crypto");
|
|
|
49
49
|
const ws_1 = __importDefault(require("ws"));
|
|
50
50
|
const runtime_1 = require("../../nerves/runtime");
|
|
51
51
|
const cmux_1 = require("./cmux");
|
|
52
|
+
const copilot_app_holds_1 = require("./copilot-app-holds");
|
|
52
53
|
/**
|
|
53
54
|
* The GitHub Copilot app host. The app runs a local WebSocket server whose port and token it
|
|
54
55
|
* rewrites under `<stateDir>/run/` on every launch, so each connection reads them fresh. Shepherd
|
|
@@ -192,6 +193,8 @@ function readConversation(stateDir, sessionId) {
|
|
|
192
193
|
const lines = [];
|
|
193
194
|
const permissions = new Map();
|
|
194
195
|
let humanAt = null;
|
|
196
|
+
let shepherdAt = null;
|
|
197
|
+
let lastTurnTools = [];
|
|
195
198
|
const push = (block) => {
|
|
196
199
|
for (const line of block.split(/\r?\n/))
|
|
197
200
|
lines.push(line);
|
|
@@ -217,6 +220,12 @@ function readConversation(stateDir, sessionId) {
|
|
|
217
220
|
continue;
|
|
218
221
|
switch (event.type) {
|
|
219
222
|
case "user.message":
|
|
223
|
+
lastTurnTools = [];
|
|
224
|
+
if (SHEPHERD_LABEL.test(str(data.content) ?? "")) {
|
|
225
|
+
const at = Date.parse(str(event.timestamp) ?? "");
|
|
226
|
+
if (!Number.isNaN(at))
|
|
227
|
+
shepherdAt = at;
|
|
228
|
+
}
|
|
220
229
|
if (str(data.content))
|
|
221
230
|
push(`› ${str(data.source) ? `(${data.source}) ` : ""}${data.content}`);
|
|
222
231
|
break;
|
|
@@ -225,6 +234,8 @@ function readConversation(stateDir, sessionId) {
|
|
|
225
234
|
push(data.content);
|
|
226
235
|
break;
|
|
227
236
|
case "tool.execution_start": {
|
|
237
|
+
if (str(data.toolName))
|
|
238
|
+
lastTurnTools.push(data.toolName);
|
|
228
239
|
const args = isRecord(data.arguments) ? data.arguments : {};
|
|
229
240
|
const what = str(args.description) ?? str(args.command) ?? str(args.question) ?? str(args.path) ?? "";
|
|
230
241
|
push(`• ${str(data.toolName) ?? "tool"}${what ? `: ${what.replace(/\s+/g, " ").slice(0, 160)}` : ""}`);
|
|
@@ -254,7 +265,7 @@ function readConversation(stateDir, sessionId) {
|
|
|
254
265
|
const pending = [...permissions.entries()].at(-1);
|
|
255
266
|
if (pending)
|
|
256
267
|
lines.push(`Waiting for permission: ${pending[1].replace(/\s+/g, " ").slice(0, 300)}`);
|
|
257
|
-
return { lines, pendingPermission: pending?.[0] ?? null, humanAt };
|
|
268
|
+
return { lines, pendingPermission: pending?.[0] ?? null, humanAt, shepherdAt, lastTurnTools };
|
|
258
269
|
}
|
|
259
270
|
/** One connection: frames go to `onFrame` until the socket closes. Throws if the socket cannot be created. */
|
|
260
271
|
function openStream(url, openSocket, onFrame, onClose) {
|
|
@@ -482,10 +493,27 @@ function createCopilotAppHost(connection, options = {}) {
|
|
|
482
493
|
const session = inventory.find(candidate => candidate.id === sessionId);
|
|
483
494
|
if (!session)
|
|
484
495
|
return;
|
|
496
|
+
const body = lastBody.get(sessionId) ?? null;
|
|
497
|
+
let hold;
|
|
498
|
+
try {
|
|
499
|
+
let facts = { humanAt: null, shepherdAt: null, lastTurnTools: [] };
|
|
500
|
+
try {
|
|
501
|
+
facts = readConversation(stateDir, sessionId);
|
|
502
|
+
}
|
|
503
|
+
catch (error) {
|
|
504
|
+
// A session with no log yet has said and been sent nothing.
|
|
505
|
+
if (error.code !== "ENOENT")
|
|
506
|
+
throw error;
|
|
507
|
+
}
|
|
508
|
+
hold = (0, copilot_app_holds_1.copilotAppHold)(stateDir, sessionId, facts, body, now());
|
|
509
|
+
}
|
|
510
|
+
catch (error) {
|
|
511
|
+
hold = `its records could not be read (${String(error).slice(0, 120)})`;
|
|
512
|
+
}
|
|
485
513
|
handlers.returned({
|
|
486
514
|
sessionId, transitionId, agent: session.agent, cwd: session.cwd ?? null,
|
|
487
515
|
workspaceTitle: session.workspaceTitle ?? null, title: session.title,
|
|
488
|
-
lastBody:
|
|
516
|
+
lastBody: body, backgroundWork, hold,
|
|
489
517
|
});
|
|
490
518
|
}, GRACE_MS));
|
|
491
519
|
};
|
|
@@ -78,6 +78,7 @@ const BLOCK_DESCRIPTION = {
|
|
|
78
78
|
state_changed: "it changed while I was looking",
|
|
79
79
|
custody: "an earlier reply may still be on its way",
|
|
80
80
|
stopped: "Shepherd was stopping",
|
|
81
|
+
hold: "it's waiting on something besides you, or I already nudged it once",
|
|
81
82
|
};
|
|
82
83
|
/** Kinds a "needs-me" owner still hears about. */
|
|
83
84
|
const NEEDS_ME = new Set(["gate", "done", "loop_guard"]);
|
|
@@ -430,6 +430,8 @@ async function startShepherdSenseApp(options) {
|
|
|
430
430
|
void wake(wakeIds.splice(0));
|
|
431
431
|
}, WAKE_DELAY_MS);
|
|
432
432
|
};
|
|
433
|
+
/** Automatic input is signed by Shepherd itself: the human sent none of it. */
|
|
434
|
+
const automaticLabel = `[Shepherd for ${presentation.name}]`;
|
|
433
435
|
async function dispatch(record, reply, instance, screenFingerprint, expected, canSend) {
|
|
434
436
|
const claim = custody.claimDispatch({ host: host.name, session: record.session, instance, screenFingerprint,
|
|
435
437
|
guidanceRevision: String(record.guidanceRevision), reply: reply.text,
|
|
@@ -443,9 +445,9 @@ async function startShepherdSenseApp(options) {
|
|
|
443
445
|
let result;
|
|
444
446
|
try {
|
|
445
447
|
if (expected)
|
|
446
|
-
result = await host.promptIfUnchanged(record.session,
|
|
448
|
+
result = await host.promptIfUnchanged(record.session, `${automaticLabel} ${exports.PERIODIC_RESUME}`, expected, canSend);
|
|
447
449
|
else {
|
|
448
|
-
await host.prompt(record.session,
|
|
450
|
+
await host.prompt(record.session, `${automaticLabel} ${reply.text}`);
|
|
449
451
|
result = { state: "sent" };
|
|
450
452
|
}
|
|
451
453
|
}
|
|
@@ -520,6 +522,13 @@ async function startShepherdSenseApp(options) {
|
|
|
520
522
|
notice = false;
|
|
521
523
|
return;
|
|
522
524
|
}
|
|
525
|
+
if (!periodic && event.hold) {
|
|
526
|
+
// The host says this stop is not a stall: no judge call, no input and no notice.
|
|
527
|
+
Object.assign(record, { kind: "working", reason: `held: ${event.hold}` });
|
|
528
|
+
record.actionBlockReason = "hold";
|
|
529
|
+
notice = false;
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
523
532
|
if (!periodic && event.backgroundWork && state.backgroundBody !== undefined && state.backgroundBody === event.lastBody) {
|
|
524
533
|
// Still waiting on the same background work with nothing new to say: no judge call.
|
|
525
534
|
Object.assign(record, { kind: "working", reason: "still waiting on its background work; nothing new since the last judgment" });
|
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.1084",
|
|
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.1084",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@ouro.bot/friends": "0.1.0-alpha.18",
|