@ouro.bot/cli 0.1.0-alpha.1110 → 0.1.0-alpha.1111
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 +6 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/daemon/sense-manager.js +7 -3
- package/dist/nerves/coverage/file-completeness.js +3 -0
- package/dist/senses/app-sessions/client.js +27 -3
- package/dist/senses/app-sessions/sense.js +15 -4
- package/dist/senses/app-sessions/waiting-prompts.js +137 -0
- package/dist/senses/app-sessions/waiting-status.js +23 -0
- package/dist/senses/app-sessions-entry.js +15 -1
- package/dist/senses/shepherd/owner-notice.js +2 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
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.1111",
|
|
6
|
+
"changes": [
|
|
7
|
+
"The app-sessions sense tells the owner once, with no model turn, when a Copilot app session has waited more than two minutes on a permission prompt only they can answer, naming the session and what it waits on; ouro status lists each waiting session."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.1110",
|
|
6
12
|
"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.1111</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -47,6 +47,7 @@ const machine_identity_1 = require("../machine-identity");
|
|
|
47
47
|
const shepherd_config_1 = require("../shepherd-config");
|
|
48
48
|
const issue_drain_state_1 = require("../../senses/app-sessions/issue-drain-state");
|
|
49
49
|
const store_1 = require("../../senses/app-sessions/store");
|
|
50
|
+
const waiting_status_1 = require("../../senses/app-sessions/waiting-status");
|
|
50
51
|
const process_manager_1 = require("./process-manager");
|
|
51
52
|
const presence_1 = require("./presence");
|
|
52
53
|
const config_1 = require("../../a2a/config");
|
|
@@ -126,6 +127,11 @@ function readAgentSenses(agentJsonPath) {
|
|
|
126
127
|
}
|
|
127
128
|
return { senses: defaults, workbenchHasStaleBundleEntry };
|
|
128
129
|
}
|
|
130
|
+
/** The app-sessions row's `ouro status` lines: sessions waiting on the owner, then each issue drain. */
|
|
131
|
+
function appSessionsLines(agentRoot, drains, now) {
|
|
132
|
+
const lines = [...(0, waiting_status_1.waitingStatusLines)((0, store_1.readSnapshot)(agentRoot), now), ...(drains?.length ? (0, issue_drain_state_1.drainStatusLines)(drains, (0, issue_drain_state_1.readDrainStates)(agentRoot), now) : [])];
|
|
133
|
+
return lines.length ? { lines } : {};
|
|
134
|
+
}
|
|
129
135
|
function textField(record, key) {
|
|
130
136
|
const value = record?.[key];
|
|
131
137
|
return typeof value === "string" ? value.trim() : "";
|
|
@@ -1099,9 +1105,7 @@ class DaemonSenseManager {
|
|
|
1099
1105
|
: entry.sense === "workbench"
|
|
1100
1106
|
? WORKBENCH_RUNTIME_INJECTION_DETAIL
|
|
1101
1107
|
: "not enabled in agent.json",
|
|
1102
|
-
...(entry.enabled && entry.sense === "app-sessions"
|
|
1103
|
-
lines: (0, issue_drain_state_1.drainStatusLines)(context.senses["app-sessions"].issueDrains, (0, issue_drain_state_1.readDrainStates)(path.join(this.bundlesRoot, `${agent}.ouro`)), Date.now()),
|
|
1104
|
-
} : {}),
|
|
1108
|
+
...(entry.enabled && entry.sense === "app-sessions" ? appSessionsLines(path.join(this.bundlesRoot, `${agent}.ouro`), context.senses["app-sessions"].issueDrains, Date.now()) : {}),
|
|
1105
1109
|
...(entry.sense === "bluebubbles" && blueBubblesConfigured ? {
|
|
1106
1110
|
proofMethod: blueBubblesRuntimeFacts.proofMethod,
|
|
1107
1111
|
lastProofAt: blueBubblesRuntimeFacts.lastProofAt,
|
|
@@ -106,6 +106,9 @@ const DISPATCH_EXEMPT_PATTERNS = [
|
|
|
106
106
|
// Issue-drain status reader: pure state-file read and line rendering for `ouro status`. The poller
|
|
107
107
|
// (issue-drains.ts) owns observability via senses.issue_drain_poll and friends.
|
|
108
108
|
"senses/app-sessions/issue-drain-state",
|
|
109
|
+
// Waiting-prompt status reader: pure line rendering for `ouro status`. The notifier
|
|
110
|
+
// (waiting-prompts.ts) owns observability via senses.app_sessions_waiting_notice and friends.
|
|
111
|
+
"senses/app-sessions/waiting-status",
|
|
109
112
|
// Pure Shepherd command/parser/projection seams; IO callers own observability.
|
|
110
113
|
"heart/shepherd/operation-commands.ts",
|
|
111
114
|
"heart/shepherd/operations.ts",
|
|
@@ -42,6 +42,7 @@ exports.assertSessionId = assertSessionId;
|
|
|
42
42
|
exports.eventLogPath = eventLogPath;
|
|
43
43
|
exports.readEventLog = readEventLog;
|
|
44
44
|
exports.parseEventLines = parseEventLines;
|
|
45
|
+
exports.describePermission = describePermission;
|
|
45
46
|
exports.tailFacts = tailFacts;
|
|
46
47
|
exports.classify = classify;
|
|
47
48
|
exports.listAppSessions = listAppSessions;
|
|
@@ -194,10 +195,31 @@ function parseEventLines(text) {
|
|
|
194
195
|
function tailEvents(stateDir, id, bytes) {
|
|
195
196
|
return parseEventLines(readEventLog(id, { stateDir, maxBytes: bytes }).text);
|
|
196
197
|
}
|
|
198
|
+
const PERMISSION_WHAT = {
|
|
199
|
+
shell: "run a shell command",
|
|
200
|
+
write: "change a file",
|
|
201
|
+
read: "read a file",
|
|
202
|
+
url: "open a web address",
|
|
203
|
+
mcp: "use a connected tool",
|
|
204
|
+
"custom-tool": "use a custom tool",
|
|
205
|
+
"extension-management": "change an extension",
|
|
206
|
+
};
|
|
207
|
+
/** The request in a few plain words. A command's text stays out: it can carry secrets. */
|
|
208
|
+
function describePermission(request) {
|
|
209
|
+
const record = isRecord(request) ? request : {};
|
|
210
|
+
const kind = str(record.kind);
|
|
211
|
+
if (kind === "extension-permission-access") {
|
|
212
|
+
const capabilities = Array.isArray(record.capabilities) ? record.capabilities.filter((item) => typeof item === "string").join(", ") : "";
|
|
213
|
+
return `let the extension ${str(record.extensionName) ?? "(unnamed)"} ${capabilities || "ask for access"}`;
|
|
214
|
+
}
|
|
215
|
+
const what = (kind && PERMISSION_WHAT[kind]) || (kind ? `a ${kind} permission` : "a permission");
|
|
216
|
+
const intention = str(record.intention);
|
|
217
|
+
return intention ? `${what} (${intention})` : what;
|
|
218
|
+
}
|
|
197
219
|
/** What the session's own history says about its agent loop. Sub-agent events are their parent's business. */
|
|
198
220
|
function tailFacts(events) {
|
|
199
221
|
const tools = new Map();
|
|
200
|
-
const permissions = new
|
|
222
|
+
const permissions = new Map();
|
|
201
223
|
let last = null;
|
|
202
224
|
let lastActivity = null;
|
|
203
225
|
let askedTools = false;
|
|
@@ -216,7 +238,7 @@ function tailFacts(events) {
|
|
|
216
238
|
if (type === "tool.execution_complete" && str(data.toolCallId))
|
|
217
239
|
tools.delete(data.toolCallId);
|
|
218
240
|
if (type === "permission.requested" && str(data.requestId) && data.resolvedByHook !== true)
|
|
219
|
-
permissions.
|
|
241
|
+
permissions.set(data.requestId, { requestId: data.requestId, what: describePermission(data.permissionRequest), at: str(event.timestamp) });
|
|
220
242
|
if (type === "permission.completed" && str(data.requestId))
|
|
221
243
|
permissions.delete(data.requestId);
|
|
222
244
|
if (!LOOP.has(type))
|
|
@@ -253,7 +275,8 @@ function tailFacts(events) {
|
|
|
253
275
|
loopCut = true;
|
|
254
276
|
detail = `mid-turn (last ${last})`;
|
|
255
277
|
}
|
|
256
|
-
|
|
278
|
+
const prompt = permissions.values().next().value;
|
|
279
|
+
return { awaiting, loopCut, detail, lastActivity, ...(prompt ? { prompt } : {}) };
|
|
257
280
|
}
|
|
258
281
|
const factsCache = new Map();
|
|
259
282
|
/** The tail facts, re-read only when the log changed, so a periodic snapshot stays cheap. */
|
|
@@ -321,6 +344,7 @@ function listAppSessions(options = {}) {
|
|
|
321
344
|
remote: (!!row.host_id && row.host_id !== "local") || (!!row.execution_location && row.execution_location !== "local"),
|
|
322
345
|
updatedAt: row.updated_at,
|
|
323
346
|
lastActivity: facts.lastActivity ?? row.updated_at,
|
|
347
|
+
...(facts.prompt ? { prompt: facts.prompt } : {}),
|
|
324
348
|
});
|
|
325
349
|
}
|
|
326
350
|
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_listed", message: "listed the Copilot app's sessions", meta: { sessions: rows.length } });
|
|
@@ -17,6 +17,7 @@ const cmux_1 = require("../shepherd/cmux");
|
|
|
17
17
|
const issue_drains_1 = require("./issue-drains");
|
|
18
18
|
const client_1 = require("./client");
|
|
19
19
|
const store_1 = require("./store");
|
|
20
|
+
const waiting_prompts_1 = require("./waiting-prompts");
|
|
20
21
|
/**
|
|
21
22
|
* The app-sessions perception loop. Every minute it snapshots the app's sessions (counts and stuck ids) into the
|
|
22
23
|
* agent's state for its prompt and health. Every ten seconds it reads the new part of each watched session's log
|
|
@@ -119,9 +120,14 @@ async function checkWatches(agentRoot, deliver, client, now) {
|
|
|
119
120
|
function recordSnapshot(agentRoot, client, now) {
|
|
120
121
|
let result;
|
|
121
122
|
try {
|
|
122
|
-
const
|
|
123
|
+
const rows = (0, client_1.listAppSessions)({ ...client, now: () => now });
|
|
124
|
+
const picture = (0, client_1.snapshot)({ ...client, now: () => now }, rows);
|
|
123
125
|
const names = new Map(picture.sessions.map(row => [row.id, row.name]));
|
|
124
|
-
result = {
|
|
126
|
+
result = {
|
|
127
|
+
...picture,
|
|
128
|
+
stuck: picture.sessions.filter(row => row.state === "stuck").map(row => ({ id: row.id, name: names.get(row.id) })),
|
|
129
|
+
waitingPrompts: (0, waiting_prompts_1.waitingPromptsOf)(agentRoot, rows, now),
|
|
130
|
+
};
|
|
125
131
|
}
|
|
126
132
|
catch (error) {
|
|
127
133
|
result = { at: new Date(now).toISOString(), appRunning: false, counts: { working: 0, idle: 0, waiting: 0, stuck: 0 }, sessions: [], stuck: [], error: error.message };
|
|
@@ -156,10 +162,15 @@ function startAppSessionsSense(options) {
|
|
|
156
162
|
let inFlight = Promise.resolve();
|
|
157
163
|
let cancelIssues = null;
|
|
158
164
|
let issuePoll = Promise.resolve();
|
|
165
|
+
let waitingPoll = Promise.resolve();
|
|
166
|
+
const notifyOwner = options.notifyOwner ?? (0, waiting_prompts_1.ownerNotifier)(options.agentName, agentRoot);
|
|
159
167
|
const snapshotTick = () => {
|
|
160
168
|
if (stopped)
|
|
161
169
|
return;
|
|
162
|
-
recordSnapshot(agentRoot, client, now());
|
|
170
|
+
const taken = recordSnapshot(agentRoot, client, now());
|
|
171
|
+
waitingPoll = waitingPoll.then(() => (0, waiting_prompts_1.noticeWaitingPrompts)(agentRoot, taken, { notify: notifyOwner, now: now() })).catch((error) => {
|
|
172
|
+
(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 } });
|
|
173
|
+
});
|
|
163
174
|
cancelSnapshot = schedule(snapshotTick, exports.SNAPSHOT_MS);
|
|
164
175
|
};
|
|
165
176
|
const watchTick = () => {
|
|
@@ -192,6 +203,6 @@ function startAppSessionsSense(options) {
|
|
|
192
203
|
cancelIssues?.();
|
|
193
204
|
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_end", message: "app-sessions sense stopped", meta: { agent: options.agentName } });
|
|
194
205
|
},
|
|
195
|
-
done: () => Promise.all([inFlight, issuePoll]).then(() => undefined),
|
|
206
|
+
done: () => Promise.all([inFlight, issuePoll, waitingPoll]).then(() => undefined),
|
|
196
207
|
};
|
|
197
208
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
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.promptKey = exports.WAITING_LIST_MAX = exports.WAITING_MAX_AGE_MS = exports.WAITING_NOTICE_MS = void 0;
|
|
37
|
+
exports.waitingPromptsOf = waitingPromptsOf;
|
|
38
|
+
exports.waitingMessage = waitingMessage;
|
|
39
|
+
exports.noticeWaitingPrompts = noticeWaitingPrompts;
|
|
40
|
+
exports.ownerNotifier = ownerNotifier;
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
43
|
+
const owner_notice_1 = require("../shepherd/owner-notice");
|
|
44
|
+
const store_1 = require("./store");
|
|
45
|
+
const waiting_status_1 = require("./waiting-status");
|
|
46
|
+
/**
|
|
47
|
+
* A session frozen on a permission prompt looks idle from outside, and only the person can answer it in the app. The
|
|
48
|
+
* snapshot already reads every session's history each minute, so noticing is deterministic and costs no model turn:
|
|
49
|
+
* a prompt open for more than two minutes is told to the owner once, in one plain message, through the same proactive
|
|
50
|
+
* path Shepherd's owner notices use. A prompt older than a day is shown in `ouro status` but never announced: it is
|
|
51
|
+
* most likely left over from a session the app stopped.
|
|
52
|
+
*/
|
|
53
|
+
exports.WAITING_NOTICE_MS = 2 * 60_000;
|
|
54
|
+
exports.WAITING_MAX_AGE_MS = 24 * 3_600_000;
|
|
55
|
+
/** Prompts named in one message; the rest are counted. */
|
|
56
|
+
exports.WAITING_LIST_MAX = 6;
|
|
57
|
+
const stateFile = (agentRoot) => path.join((0, store_1.appSessionsStateDir)(agentRoot), "waiting-prompts.json");
|
|
58
|
+
const promptKey = (prompt) => `${prompt.session}:${prompt.requestId}`;
|
|
59
|
+
exports.promptKey = promptKey;
|
|
60
|
+
/** The open permission prompts in the sidebar. A prompt the app timed without an event time keeps the first time it was seen. */
|
|
61
|
+
function waitingPromptsOf(agentRoot, rows, now) {
|
|
62
|
+
const before = new Map(((0, store_1.readSnapshot)(agentRoot)?.waitingPrompts ?? []).map(prompt => [(0, exports.promptKey)(prompt), prompt.since]));
|
|
63
|
+
const prompts = [];
|
|
64
|
+
for (const row of rows) {
|
|
65
|
+
if (!row.prompt)
|
|
66
|
+
continue;
|
|
67
|
+
const stamped = Date.parse(row.prompt.at ?? "");
|
|
68
|
+
const since = Number.isNaN(stamped) ? before.get((0, exports.promptKey)({ session: row.id, requestId: row.prompt.requestId })) ?? now : stamped;
|
|
69
|
+
prompts.push({ session: row.id, name: row.name, requestId: row.prompt.requestId, what: row.prompt.what, since });
|
|
70
|
+
}
|
|
71
|
+
return prompts;
|
|
72
|
+
}
|
|
73
|
+
/** One plain message naming each session, what it waits on and that only the owner can answer. */
|
|
74
|
+
function waitingMessage(prompts, now) {
|
|
75
|
+
const line = (prompt) => `"${(0, owner_notice_1.plain)(prompt.name, 60)}" waits on ${(0, owner_notice_1.plain)(prompt.what, 120)}, for ${(0, waiting_status_1.ageLabel)(now - prompt.since)}`;
|
|
76
|
+
if (prompts.length === 1)
|
|
77
|
+
return `${line(prompts[0])}. Only you can answer it, in the Copilot app: open that session and approve or decline.`;
|
|
78
|
+
const shown = prompts.slice(0, exports.WAITING_LIST_MAX).map(prompt => `- ${line(prompt)}`);
|
|
79
|
+
const more = prompts.length > exports.WAITING_LIST_MAX ? `\n- and ${prompts.length - exports.WAITING_LIST_MAX} more` : "";
|
|
80
|
+
return `${prompts.length} sessions wait on prompts only you can answer, in the Copilot app (open each session and approve or decline):\n${shown.join("\n")}${more}`;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Tell the owner about each prompt open past the threshold that they have not been told about. Returns how many
|
|
84
|
+
* prompts were announced. A snapshot that could not read the app changes nothing, so a blip cannot forget a prompt.
|
|
85
|
+
*/
|
|
86
|
+
async function noticeWaitingPrompts(agentRoot, snapshot, deps) {
|
|
87
|
+
if (snapshot.error)
|
|
88
|
+
return 0;
|
|
89
|
+
const open = snapshot.waitingPrompts ?? [];
|
|
90
|
+
const keys = new Set(open.map(exports.promptKey));
|
|
91
|
+
const state = (0, store_1.readJson)(stateFile(agentRoot), { notified: {} });
|
|
92
|
+
const kept = Object.fromEntries(Object.entries(state.notified).filter(([key]) => keys.has(key)));
|
|
93
|
+
const due = open.filter(prompt => {
|
|
94
|
+
const age = deps.now - prompt.since;
|
|
95
|
+
return age > exports.WAITING_NOTICE_MS && age <= exports.WAITING_MAX_AGE_MS && !kept[(0, exports.promptKey)(prompt)];
|
|
96
|
+
});
|
|
97
|
+
let announced = 0;
|
|
98
|
+
if (due.length > 0) {
|
|
99
|
+
const dueKeys = due.map(exports.promptKey);
|
|
100
|
+
const outcome = await deps.notify(waitingMessage(due, deps.now), dueKeys);
|
|
101
|
+
if (outcome !== "pending") {
|
|
102
|
+
for (const prompt of due)
|
|
103
|
+
kept[(0, exports.promptKey)(prompt)] = { at: new Date(deps.now).toISOString(), name: prompt.name };
|
|
104
|
+
announced = due.length;
|
|
105
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_waiting_notice", message: "told the owner about Copilot app sessions waiting on a prompt", meta: { prompts: due.length, outcome } });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (announced > 0 || Object.keys(kept).length !== Object.keys(state.notified).length)
|
|
109
|
+
(0, store_1.writeJson)(stateFile(agentRoot), { notified: kept });
|
|
110
|
+
return announced;
|
|
111
|
+
}
|
|
112
|
+
/** Sends the notice to the owner on the channel Shepherd's notices use. An outcome the transport could not confirm is `unknown`, never retried, so the owner is not told twice. */
|
|
113
|
+
function ownerNotifier(agent, agentRoot, deps = {}) {
|
|
114
|
+
const resolveTargets = deps.resolveTargets ?? (() => (0, owner_notice_1.resolveNoticeTargets)(agentRoot, undefined, (0, owner_notice_1.readEnabledReachChannels)(agent, agentRoot)));
|
|
115
|
+
const send = deps.send ?? (0, owner_notice_1.createNoticeSender)(agentRoot, { origin: "proactive" });
|
|
116
|
+
return async (text, keys) => {
|
|
117
|
+
const targets = await resolveTargets();
|
|
118
|
+
if (targets.length === 0) {
|
|
119
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.app_sessions_waiting_no_target", message: "no family friend is reachable on any enabled channel, so the waiting-prompt notice waits", meta: { agent } });
|
|
120
|
+
return "pending";
|
|
121
|
+
}
|
|
122
|
+
const outcomes = [];
|
|
123
|
+
for (const target of targets) {
|
|
124
|
+
try {
|
|
125
|
+
const result = await send(target, text, keys);
|
|
126
|
+
outcomes.push(result.delivered ? "sent"
|
|
127
|
+
: result.delivery ? result.delivery.state === "not_sent" ? "pending" : "unknown"
|
|
128
|
+
: result.reason && result.reason !== "send_error" ? "pending" : "unknown");
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
outcomes.push("unknown");
|
|
132
|
+
(0, runtime_1.emitNervesEvent)({ level: "error", component: "senses", event: "senses.app_sessions_waiting_notice_error", message: "sending the waiting-prompt notice failed; its outcome is unknown", meta: { agent, friendId: target.friendId, error: error.message } });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return outcomes.includes("sent") ? "sent" : outcomes.includes("unknown") ? "unknown" : "pending";
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ageLabel = ageLabel;
|
|
4
|
+
exports.waitingStatusLines = waitingStatusLines;
|
|
5
|
+
const store_1 = require("./store");
|
|
6
|
+
/** The daemon reads this to print `ouro status`, so it stays free of the sense process's heavier imports. */
|
|
7
|
+
const STATUS_LIST_MAX = 8;
|
|
8
|
+
function ageLabel(ms) {
|
|
9
|
+
const m = Math.max(1, Math.round(ms / 60_000));
|
|
10
|
+
return m < 90 ? `${m} min` : `${Math.round(m / 60)} h`;
|
|
11
|
+
}
|
|
12
|
+
const flat = (value, max) => {
|
|
13
|
+
const text = value.replace(/\s+/g, " ").trim();
|
|
14
|
+
return text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}…`;
|
|
15
|
+
};
|
|
16
|
+
/** `ouro status` lines for the open prompts, oldest first. A stale or failed snapshot shows none: its summary already says so. */
|
|
17
|
+
function waitingStatusLines(snapshot, now) {
|
|
18
|
+
if (!snapshot || snapshot.error || now - Date.parse(snapshot.at) > store_1.SNAPSHOT_STALE_MS)
|
|
19
|
+
return [];
|
|
20
|
+
const open = [...(snapshot.waitingPrompts ?? [])].sort((a, b) => a.since - b.since);
|
|
21
|
+
const lines = open.slice(0, STATUS_LIST_MAX).map(prompt => `waiting on you: ${prompt.session.slice(0, 8)} (${flat(prompt.name, 60)}) for ${ageLabel(now - prompt.since)}: ${flat(prompt.what, 120)}`);
|
|
22
|
+
return open.length > STATUS_LIST_MAX ? [...lines, `waiting on you: and ${open.length - STATUS_LIST_MAX} more`] : lines;
|
|
23
|
+
}
|
|
@@ -49,7 +49,21 @@ const runtime_1 = require("../nerves/runtime");
|
|
|
49
49
|
message: "booting app-sessions entrypoint",
|
|
50
50
|
meta: { entry: "app-sessions", agentName },
|
|
51
51
|
});
|
|
52
|
-
|
|
52
|
+
// The owner notice for a session frozen on a prompt sends through Teams, which reads the machine's runtime credentials.
|
|
53
|
+
Promise.resolve().then(() => __importStar(require("../heart/runtime-credentials"))).then(async ({ refreshMachineRuntimeCredentialConfig, runtimeCredentialConfigSettled, waitForRuntimeCredentialBootstrap }) => {
|
|
54
|
+
try {
|
|
55
|
+
await waitForRuntimeCredentialBootstrap(agentName);
|
|
56
|
+
if (!runtimeCredentialConfigSettled(agentName, "machineRuntimeConfig")) {
|
|
57
|
+
const { loadOrCreateMachineIdentity } = await Promise.resolve().then(() => __importStar(require("../heart/machine-identity")));
|
|
58
|
+
await refreshMachineRuntimeCredentialConfig(agentName, loadOrCreateMachineIdentity().machineId, { preserveCachedOnFailure: true });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.app_sessions_credentials_unavailable", message: "runtime credentials are unavailable; owner notices wait until they are", meta: { agentName, error: error instanceof Error ? error.message : String(error) } });
|
|
63
|
+
}
|
|
64
|
+
return Promise.resolve().then(() => __importStar(require("./app-sessions/sense")));
|
|
65
|
+
})
|
|
66
|
+
.then(({ startAppSessionsSense }) => {
|
|
53
67
|
const app = startAppSessionsSense({ agentName: agentName });
|
|
54
68
|
const shutdown = () => {
|
|
55
69
|
app.stop();
|
|
@@ -316,7 +316,7 @@ function createNoticeSender(agentRoot, deps = {}) {
|
|
|
316
316
|
return { delivered: false, reason: "bluebubbles_unavailable" };
|
|
317
317
|
}
|
|
318
318
|
const store = new friends_1.FileFriendStore(path.join(agentRoot, "friends"));
|
|
319
|
-
return send({ friendId: target.friendId, sessionKey: target.key, text, intent: "generic_outreach", deliveryId, origin: "shepherd" }, { createClient: () => client, createFriendStore: () => store });
|
|
319
|
+
return send({ friendId: target.friendId, sessionKey: target.key, text, intent: "generic_outreach", deliveryId, origin: deps.origin ?? "shepherd" }, { createClient: () => client, createFriendStore: () => store });
|
|
320
320
|
}
|
|
321
321
|
const config = chooseTeamsBot(target.tenantId, (deps.primary ?? config_1.getTeamsConfig)(), (deps.secondary ?? config_1.getTeamsSecondaryConfig)());
|
|
322
322
|
if (!config)
|
|
@@ -330,7 +330,7 @@ function createNoticeSender(agentRoot, deps = {}) {
|
|
|
330
330
|
bot.catch(() => bots.delete(config.clientId));
|
|
331
331
|
}
|
|
332
332
|
const { sendProactiveTeamsMessageToSession } = await Promise.resolve().then(() => __importStar(require("../teams")));
|
|
333
|
-
return sendProactiveTeamsMessageToSession({ friendId: target.friendId, sessionKey: target.key, text, textFormat: "plain", intent: "generic_outreach", captureReceipt: true, deliveryId, origin: "shepherd" }, { botApi: await bot, store: new friends_1.FileFriendStore(path.join(agentRoot, "friends")) });
|
|
333
|
+
return sendProactiveTeamsMessageToSession({ friendId: target.friendId, sessionKey: target.key, text, textFormat: "plain", intent: "generic_outreach", captureReceipt: true, deliveryId, origin: deps.origin ?? "shepherd" }, { botApi: await bot, store: new friends_1.FileFriendStore(path.join(agentRoot, "friends")) });
|
|
334
334
|
};
|
|
335
335
|
}
|
|
336
336
|
/** Collects durable notice intents; acceptance is distinct from transport delivery. */
|
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.1111",
|
|
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.1111",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@ouro.bot/friends": "0.1.0-alpha.18",
|