@ouro.bot/cli 0.1.0-alpha.1376 → 0.1.0-alpha.1378
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/heart/daemon/cli-defaults.js +19 -0
- package/dist/heart/daemon/runtime-replacement-handoff.js +79 -9
- package/dist/senses/telegram-client.js +5 -2
- package/dist/senses/telegram-effect-adapter.js +2 -0
- package/dist/senses/telegram-owner-route.js +27 -7
- package/dist/senses/telegram.js +46 -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.1378",
|
|
6
|
+
"changes": [
|
|
7
|
+
"An `ouro up` that an agent's shell runs inside the daemon's own launchd job now hands the daemon replacement to the detached helper instead of stranding the daemon. Apple's sh, bash and zsh set XPC_SERVICE_NAME=0 for every child they fork, so the label check alone missed it; the check now also looks for the daemon job's pid among the command's ancestors, treats a launchctl or ps failure as inside the job, and logs which check decided (daemon.runtime_replacement_job_check)."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1377",
|
|
12
|
+
"changes": [
|
|
13
|
+
"The Butler checks Slugger's card every 5 minutes. After 3 failed checks it tells the owner once on Telegram that Slugger is unreachable, and silently when he is back."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1376",
|
|
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.1378</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -45,6 +45,7 @@ exports.readFirstBundleMetaVersion = readFirstBundleMetaVersion;
|
|
|
45
45
|
exports.niceOption = niceOption;
|
|
46
46
|
exports.isDaemonLaunchAgentLoaded = isDaemonLaunchAgentLoaded;
|
|
47
47
|
exports.waitForBootstrappedDaemonSocket = waitForBootstrappedDaemonSocket;
|
|
48
|
+
exports.readDaemonJobPidFailSafe = readDaemonJobPidFailSafe;
|
|
48
49
|
exports.defaultListHomeAgents = defaultListHomeAgents;
|
|
49
50
|
exports.defaultListDiscoveredAgents = defaultListDiscoveredAgents;
|
|
50
51
|
exports.defaultRunSerpentGuide = defaultRunSerpentGuide;
|
|
@@ -492,10 +493,28 @@ function defaultPrepareDaemonRuntimeReplacement() {
|
|
|
492
493
|
// settle before the replacement daemon binds the same socket path.
|
|
493
494
|
(0, child_process_1.execSync)("/bin/sleep 1", { stdio: "ignore" });
|
|
494
495
|
}
|
|
496
|
+
/** launchctl exits 113 when the label isn't loaded; anything else it can't answer throws. */
|
|
497
|
+
const LAUNCHCTL_NO_SUCH_SERVICE = 113;
|
|
498
|
+
const JOB_CHECK_TIMEOUT_MS = 5_000;
|
|
499
|
+
/** The running pid of the daemon's launchd job, or null when the job isn't loaded or has no process. */
|
|
500
|
+
function readDaemonJobPidFailSafe(run = (file, args) => (0, child_process_1.execFileSync)(file, args, { encoding: "utf-8", timeout: JOB_CHECK_TIMEOUT_MS, stdio: ["ignore", "pipe", "pipe"] })) {
|
|
501
|
+
try {
|
|
502
|
+
return (0, runtime_replacement_handoff_1.parseLaunchctlJobPid)(run("launchctl", ["print", `${launchAgentDomain()}/${launchd_1.DAEMON_PLIST_LABEL}`]));
|
|
503
|
+
}
|
|
504
|
+
catch (error) {
|
|
505
|
+
if (error.status === LAUNCHCTL_NO_SUCH_SERVICE)
|
|
506
|
+
return null;
|
|
507
|
+
throw error;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
495
510
|
function defaultHandOffDaemonRuntimeReplacement() {
|
|
496
511
|
return (0, runtime_replacement_handoff_1.handOffDaemonRuntimeReplacement)({
|
|
497
512
|
platform: process.platform,
|
|
498
513
|
env: process.env,
|
|
514
|
+
pid: process.pid,
|
|
515
|
+
readDaemonJobPid: () => readDaemonJobPidFailSafe(),
|
|
516
|
+
/* v8 ignore next 2 -- host default: reads this machine's process table @preserve */
|
|
517
|
+
readProcessParents: () => (0, runtime_replacement_handoff_1.parseProcessParents)((0, child_process_1.execFileSync)("ps", ["-axo", "pid=,ppid="], { encoding: "utf-8", timeout: JOB_CHECK_TIMEOUT_MS, stdio: ["ignore", "pipe", "pipe"] })),
|
|
499
518
|
execPath: process.execPath,
|
|
500
519
|
entryPath: process.argv[1],
|
|
501
520
|
logPath: path.join((0, ouro_version_manager_1.getOuroCliHome)(), "daemon", "logs", "runtime-replacement-helper.log"),
|
|
@@ -48,10 +48,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
48
48
|
};
|
|
49
49
|
})();
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.STRANDED_REPLACEMENT_AFTER_MS = void 0;
|
|
51
|
+
exports.RUNTIME_REPLACEMENT_HELPER_ENV = exports.STRANDED_REPLACEMENT_AFTER_MS = void 0;
|
|
52
52
|
exports.runtimeReplacementMarkerPath = runtimeReplacementMarkerPath;
|
|
53
53
|
exports.isRuntimeReplacementStranded = isRuntimeReplacementStranded;
|
|
54
|
-
exports.
|
|
54
|
+
exports.detectDaemonLaunchdJob = detectDaemonLaunchdJob;
|
|
55
|
+
exports.parseLaunchctlJobPid = parseLaunchctlJobPid;
|
|
56
|
+
exports.parseProcessParents = parseProcessParents;
|
|
55
57
|
exports.handOffDaemonRuntimeReplacement = handOffDaemonRuntimeReplacement;
|
|
56
58
|
const path = __importStar(require("path"));
|
|
57
59
|
const runtime_1 = require("../../nerves/runtime");
|
|
@@ -74,13 +76,71 @@ function isRuntimeReplacementStranded(input) {
|
|
|
74
76
|
return false;
|
|
75
77
|
return !input.labelLoaded();
|
|
76
78
|
}
|
|
79
|
+
/** Set in the helper's env so the helper does the replacement instead of handing off again. */
|
|
80
|
+
exports.RUNTIME_REPLACEMENT_HELPER_ENV = "OURO_RUNTIME_REPLACEMENT_HELPER";
|
|
81
|
+
/** Parent links are followed at most this many times, so a corrupt table can't loop forever. */
|
|
82
|
+
const MAX_ANCESTRY_DEPTH = 128;
|
|
77
83
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
84
|
+
* Decides whether this command runs inside the daemon's launchd job.
|
|
85
|
+
*
|
|
86
|
+
* launchd gives the job's processes XPC_SERVICE_NAME=bot.ouro.daemon, but that
|
|
87
|
+
* label isn't enough by itself: Apple's /bin/sh, bash and zsh set
|
|
88
|
+
* XPC_SERVICE_NAME=0 for every child they fork, so an `ouro up` an agent's
|
|
89
|
+
* shell runs in a pipeline sees "0" (2026-11-22 live test). Being a descendant
|
|
90
|
+
* of the job's running pid settles it. When launchd or the process table can't
|
|
91
|
+
* be read the answer is "inside": a needless hand-off costs seconds, and a
|
|
92
|
+
* missed one strands the daemon.
|
|
81
93
|
*/
|
|
82
|
-
function
|
|
83
|
-
|
|
94
|
+
function detectDaemonLaunchdJob(deps) {
|
|
95
|
+
const xpcServiceName = deps.env.XPC_SERVICE_NAME ?? null;
|
|
96
|
+
const result = (inside, reason, daemonPid = null, error) => ({ inside, reason, xpcServiceName, daemonPid, ...(error === undefined ? {} : { error }) });
|
|
97
|
+
if (deps.platform !== "darwin")
|
|
98
|
+
return result(false, "not_macos");
|
|
99
|
+
if (deps.env[exports.RUNTIME_REPLACEMENT_HELPER_ENV] === "1")
|
|
100
|
+
return result(false, "replacement_helper");
|
|
101
|
+
if (xpcServiceName === launchd_1.DAEMON_PLIST_LABEL)
|
|
102
|
+
return result(true, "launchd_label");
|
|
103
|
+
let daemonPid;
|
|
104
|
+
try {
|
|
105
|
+
daemonPid = deps.readDaemonJobPid();
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
return result(true, "launchctl_failed", null, formatError(error));
|
|
109
|
+
}
|
|
110
|
+
if (daemonPid === null)
|
|
111
|
+
return result(false, "no_daemon_job");
|
|
112
|
+
let parents;
|
|
113
|
+
try {
|
|
114
|
+
parents = deps.readProcessParents();
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return result(true, "process_table_failed", daemonPid, formatError(error));
|
|
118
|
+
}
|
|
119
|
+
let current = deps.pid;
|
|
120
|
+
for (let depth = 0; current !== undefined && current > 1 && depth < MAX_ANCESTRY_DEPTH; depth++) {
|
|
121
|
+
if (current === daemonPid)
|
|
122
|
+
return result(true, "daemon_ancestor", daemonPid);
|
|
123
|
+
current = parents.get(current);
|
|
124
|
+
}
|
|
125
|
+
return result(false, "not_descendant", daemonPid);
|
|
126
|
+
}
|
|
127
|
+
/** The running pid from `launchctl print` output, or null when the job has no process. */
|
|
128
|
+
function parseLaunchctlJobPid(output) {
|
|
129
|
+
const match = /^\s*pid = (\d+)\s*$/m.exec(output);
|
|
130
|
+
return match ? Number(match[1]) : null;
|
|
131
|
+
}
|
|
132
|
+
/** pid to parent pid from `ps -axo pid=,ppid=` output. */
|
|
133
|
+
function parseProcessParents(output) {
|
|
134
|
+
const parents = new Map();
|
|
135
|
+
for (const line of output.split("\n")) {
|
|
136
|
+
const match = /^\s*(\d+)\s+(\d+)\s*$/.exec(line);
|
|
137
|
+
if (match)
|
|
138
|
+
parents.set(Number(match[1]), Number(match[2]));
|
|
139
|
+
}
|
|
140
|
+
return parents;
|
|
141
|
+
}
|
|
142
|
+
function formatError(error) {
|
|
143
|
+
return error instanceof Error ? error.message : String(error);
|
|
84
144
|
}
|
|
85
145
|
/**
|
|
86
146
|
* Starts the detached helper when the current command is inside the daemon's
|
|
@@ -89,7 +149,17 @@ function isInsideDaemonLaunchdJob(env, platform) {
|
|
|
89
149
|
* this module exists to prevent.
|
|
90
150
|
*/
|
|
91
151
|
function handOffDaemonRuntimeReplacement(deps) {
|
|
92
|
-
|
|
152
|
+
const check = detectDaemonLaunchdJob(deps);
|
|
153
|
+
(0, runtime_1.emitNervesEvent)({
|
|
154
|
+
level: check.error === undefined ? "info" : "warn",
|
|
155
|
+
component: "daemon",
|
|
156
|
+
event: "daemon.runtime_replacement_job_check",
|
|
157
|
+
message: check.inside
|
|
158
|
+
? "runtime replacement runs inside the daemon's launchd job"
|
|
159
|
+
: "runtime replacement runs outside the daemon's launchd job",
|
|
160
|
+
meta: { ...check },
|
|
161
|
+
});
|
|
162
|
+
if (!check.inside)
|
|
93
163
|
return null;
|
|
94
164
|
if (!deps.entryPath) {
|
|
95
165
|
(0, runtime_1.emitNervesEvent)({
|
|
@@ -105,7 +175,7 @@ function handOffDaemonRuntimeReplacement(deps) {
|
|
|
105
175
|
const logFd = deps.openLog(deps.logPath);
|
|
106
176
|
// Without the daemon's label the helper replaces the daemon itself rather
|
|
107
177
|
// than handing off again.
|
|
108
|
-
const env = { ...deps.env, OURO_UNATTENDED: "1" };
|
|
178
|
+
const env = { ...deps.env, OURO_UNATTENDED: "1", [exports.RUNTIME_REPLACEMENT_HELPER_ENV]: "1" };
|
|
109
179
|
delete env.XPC_SERVICE_NAME;
|
|
110
180
|
const child = deps.spawn(deps.execPath, [deps.entryPath, "up"], {
|
|
111
181
|
detached: true,
|
|
@@ -1621,7 +1621,10 @@ async function sendTelegramText(api, chatId, text, options = {}) {
|
|
|
1621
1621
|
options.onMessageDelivered?.(messageId, chunk);
|
|
1622
1622
|
};
|
|
1623
1623
|
for (const [index, chunk] of (options.split ?? telegram_markdown_1.splitTelegramText)(text).entries()) {
|
|
1624
|
-
const replyTo =
|
|
1624
|
+
const replyTo = {
|
|
1625
|
+
...(index === 0 && options.replyToMessageId ? { reply_parameters: { message_id: options.replyToMessageId } } : {}),
|
|
1626
|
+
...(options.silent ? { disable_notification: true } : {}),
|
|
1627
|
+
};
|
|
1625
1628
|
try {
|
|
1626
1629
|
recordMessageId(await api.request("sendMessage", {
|
|
1627
1630
|
chat_id: chatId,
|
|
@@ -1644,7 +1647,7 @@ async function sendTelegramText(api, chatId, text, options = {}) {
|
|
|
1644
1647
|
throw retry;
|
|
1645
1648
|
}
|
|
1646
1649
|
}
|
|
1647
|
-
recordMessageId(await api.request("sendMessage", { chat_id: chatId, text: chunk }, options.signal), chunk);
|
|
1650
|
+
recordMessageId(await api.request("sendMessage", { chat_id: chatId, text: chunk, ...(options.silent ? { disable_notification: true } : {}) }, options.signal), chunk);
|
|
1648
1651
|
}
|
|
1649
1652
|
}
|
|
1650
1653
|
return results;
|
|
@@ -117,6 +117,7 @@ function validateArtifact(artifact, expectedId) {
|
|
|
117
117
|
const effectValid = effect?.kind === "text" || effect?.kind === "admission_ack"
|
|
118
118
|
? boundedText(effect.text, 150_000)
|
|
119
119
|
&& (effect.kind !== "text" || effect.replyToMessageId === undefined || (Number.isSafeInteger(effect.replyToMessageId) && effect.replyToMessageId > 0))
|
|
120
|
+
&& (effect.kind !== "text" || effect.silent === undefined || effect.silent === true)
|
|
120
121
|
: effect?.kind === "card"
|
|
121
122
|
? boundedText(effect.text) && (effect.silent === undefined || effect.silent === true) && Array.isArray(effect.buttons) && effect.buttons.length > 0 && effect.buttons.length <= 20
|
|
122
123
|
&& effect.buttons.every((row) => Array.isArray(row) && row.length > 0 && row.length <= 8
|
|
@@ -385,6 +386,7 @@ async function executePart(api, artifact, part, chatId, signal) {
|
|
|
385
386
|
...(signal ? { signal } : {}),
|
|
386
387
|
...(markdown ? { renderHtml: telegram_markdown_1.renderTelegramMarkdown, fallbackHtml: telegram_markdown_1.renderTelegramMarkdownSafe } : {}),
|
|
387
388
|
...(replyToMessageId ? { replyToMessageId } : {}),
|
|
389
|
+
...(effect.kind === "text" && effect.silent ? { silent: true } : {}),
|
|
388
390
|
});
|
|
389
391
|
if (ids.length !== 1)
|
|
390
392
|
throw new Error("Telegram effect chunk renderer returned an unexpected message count");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OWNER_ROUTE_FALLBACK_PREFIX = void 0;
|
|
3
|
+
exports.OWNER_ROUTE_FALLBACK_PREFIX = exports.OWNER_ROUTE_BACK_TEXT = exports.OWNER_ROUTE_DOWN_TEXT = exports.OWNER_ROUTE_WATCH_FAILURES = exports.OWNER_ROUTE_WATCH_INTERVAL_MS = void 0;
|
|
4
4
|
exports.ownerRouteUrgency = ownerRouteUrgency;
|
|
5
5
|
exports.ownerRouteDedupeKey = ownerRouteDedupeKey;
|
|
6
6
|
exports.ownerRouteItem = ownerRouteItem;
|
|
@@ -12,6 +12,11 @@ const client_1 = require("../a2a/client");
|
|
|
12
12
|
const identity_1 = require("../a2a/identity");
|
|
13
13
|
const identity_2 = require("../heart/identity");
|
|
14
14
|
const runtime_1 = require("../nerves/runtime");
|
|
15
|
+
/** How often the Butler checks the peer, and how many failed checks in a row (15 minutes) count as down. */
|
|
16
|
+
exports.OWNER_ROUTE_WATCH_INTERVAL_MS = 5 * 60_000;
|
|
17
|
+
exports.OWNER_ROUTE_WATCH_FAILURES = 3;
|
|
18
|
+
exports.OWNER_ROUTE_DOWN_TEXT = "Slugger (your phone bot) has been unreachable for 15 min; agents can't reach you through him.";
|
|
19
|
+
exports.OWNER_ROUTE_BACK_TEXT = "Slugger is reachable again, so agents reach you through him as before.";
|
|
15
20
|
exports.OWNER_ROUTE_FALLBACK_PREFIX = "Slugger can't be reached, so this comes to you directly.";
|
|
16
21
|
function ownerRouteUrgency(key, critical) {
|
|
17
22
|
if (critical)
|
|
@@ -65,14 +70,28 @@ const reason = (error) => error instanceof Error ? error.message : String(error)
|
|
|
65
70
|
function createA2AOwnerRoute(options) {
|
|
66
71
|
const fetchCard = options.fetchCard ?? client_1.fetchA2AAgentCard;
|
|
67
72
|
const send = options.send ?? client_1.sendSealedA2AChat;
|
|
68
|
-
|
|
73
|
+
/** null when the card at the address serves the pinned DID; otherwise why not. */
|
|
74
|
+
const pinned = async () => {
|
|
75
|
+
const served = (0, client_1.cardDid)(await fetchCard(options.cardUrl));
|
|
76
|
+
if (served === options.did)
|
|
77
|
+
return null;
|
|
78
|
+
(0, runtime_1.emitNervesEvent)({ level: "error", component: "senses", event: "senses.telegram_owner_route_pin_mismatch", message: "the owner route's peer card serves another DID", meta: { cardUrl: options.cardUrl, served: served ?? null, pinned: options.did } });
|
|
79
|
+
return `the card at ${options.cardUrl} serves ${served}, not the pinned ${options.did}`;
|
|
80
|
+
};
|
|
81
|
+
const probe = async () => {
|
|
82
|
+
try {
|
|
83
|
+
const detail = await pinned();
|
|
84
|
+
return detail ? { status: "unreachable", detail } : { status: "delivered" };
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return { status: "unreachable", detail: reason(error) };
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const route = async (item) => {
|
|
69
91
|
try {
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
const detail = `the card at ${options.cardUrl} serves ${served}, not the pinned ${options.did}`;
|
|
73
|
-
(0, runtime_1.emitNervesEvent)({ level: "error", component: "senses", event: "senses.telegram_owner_route_pin_mismatch", message: "the owner route's peer card serves another DID", meta: { cardUrl: options.cardUrl, served: served ?? null, pinned: options.did } });
|
|
92
|
+
const detail = await pinned();
|
|
93
|
+
if (detail)
|
|
74
94
|
return { status: "unreachable", detail };
|
|
75
|
-
}
|
|
76
95
|
await send({ cardUrl: options.cardUrl, text: formatOwnerRouteMessage(item), identity: await options.loadIdentity() });
|
|
77
96
|
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.telegram_owner_route_delivered", message: "sent a self-started Butler message to the owner's primary agent", meta: { urgency: item.urgency, dedupeKey: item.dedupeKey } });
|
|
78
97
|
return { status: "delivered" };
|
|
@@ -82,6 +101,7 @@ function createA2AOwnerRoute(options) {
|
|
|
82
101
|
return { status: "unreachable", detail: reason(error) };
|
|
83
102
|
}
|
|
84
103
|
};
|
|
104
|
+
return Object.assign(route, { probe });
|
|
85
105
|
}
|
|
86
106
|
/** The owner route `agent.json` names (`senses.telegram.ownerNoticesTo`), signing as this agent's A2A identity; none when unset. */
|
|
87
107
|
function ownerRouteForAgent(agentName, agentRoot) {
|
package/dist/senses/telegram.js
CHANGED
|
@@ -1104,6 +1104,45 @@ function createTelegramSenseApp(options) {
|
|
|
1104
1104
|
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.telegram_notice_held_for_owner_route", message: "held a house notice until the owner's primary agent can be reached", meta: { agentName: options.agentName, dedupeKey: item.dedupeKey } });
|
|
1105
1105
|
return null;
|
|
1106
1106
|
};
|
|
1107
|
+
const ownerRouteWatchPath = path.join(agentRoot, "state", "telegram", "owner-route-watch.json");
|
|
1108
|
+
const readOwnerRouteWatch = () => {
|
|
1109
|
+
try {
|
|
1110
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(ownerRouteWatchPath, "utf8"));
|
|
1111
|
+
return { failures: Number.isSafeInteger(parsed.failures) ? parsed.failures : 0, alertedAt: typeof parsed.alertedAt === "string" ? parsed.alertedAt : null };
|
|
1112
|
+
}
|
|
1113
|
+
catch {
|
|
1114
|
+
return { failures: 0, alertedAt: null };
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
const writeOwnerRouteWatch = (state) => {
|
|
1118
|
+
(0, node_fs_1.mkdirSync)(path.dirname(ownerRouteWatchPath), { recursive: true });
|
|
1119
|
+
(0, atomic_file_1.writeFileAtomicSync)(ownerRouteWatchPath, JSON.stringify(state));
|
|
1120
|
+
};
|
|
1121
|
+
const checkOwnerRoute = async () => {
|
|
1122
|
+
const probe = options.ownerRoute?.probe;
|
|
1123
|
+
if (!probe)
|
|
1124
|
+
return;
|
|
1125
|
+
const outcome = await probe();
|
|
1126
|
+
const state = readOwnerRouteWatch();
|
|
1127
|
+
if (outcome.status === "delivered") {
|
|
1128
|
+
if (state.alertedAt) {
|
|
1129
|
+
await executeAuthorizedEffect({ idempotencyKey: `owner-route-watch:back:${state.alertedAt}`, target: configuredOwnerTarget(), authorClass: "butler", effect: { kind: "text", text: telegram_owner_route_1.OWNER_ROUTE_BACK_TEXT, silent: true } });
|
|
1130
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.telegram_owner_route_back", message: "told the owner, silently, that the primary agent is reachable again", meta: { agentName: options.agentName, downSince: state.alertedAt } });
|
|
1131
|
+
}
|
|
1132
|
+
if (state.failures || state.alertedAt)
|
|
1133
|
+
writeOwnerRouteWatch({ failures: 0, alertedAt: null });
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
const failures = state.failures + 1;
|
|
1137
|
+
if (failures < telegram_owner_route_1.OWNER_ROUTE_WATCH_FAILURES || state.alertedAt) {
|
|
1138
|
+
writeOwnerRouteWatch({ failures, alertedAt: state.alertedAt });
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
const alertedAt = new Date().toISOString();
|
|
1142
|
+
await executeAuthorizedEffect({ idempotencyKey: `owner-route-watch:down:${alertedAt}`, target: configuredOwnerTarget(), authorClass: "butler", effect: { kind: "text", text: telegram_owner_route_1.OWNER_ROUTE_DOWN_TEXT } });
|
|
1143
|
+
writeOwnerRouteWatch({ failures, alertedAt });
|
|
1144
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.telegram_owner_route_down", message: "told the owner on Telegram that the primary agent has been unreachable for 15 minutes", meta: { agentName: options.agentName, detail: outcome.detail } });
|
|
1145
|
+
};
|
|
1107
1146
|
/** With an owner route, held notices go to the peer one by one; a critical one it can't take goes to Telegram as a fallback. */
|
|
1108
1147
|
const releaseHeldNoticesToRoute = async (route, signal) => {
|
|
1109
1148
|
const sessionPath = (0, shared_turn_1.getSenseSessionPath)(options.agentName, configuredOwnerFriendId, "telegram", configuredOwnerSessionKey, agentRoot);
|
|
@@ -1867,6 +1906,7 @@ function createTelegramSenseApp(options) {
|
|
|
1867
1906
|
retireAcceptanceAudit,
|
|
1868
1907
|
]);
|
|
1869
1908
|
return {
|
|
1909
|
+
checkOwnerRoute,
|
|
1870
1910
|
run(signal) {
|
|
1871
1911
|
if (runPromise)
|
|
1872
1912
|
return runPromise;
|
|
@@ -1907,10 +1947,16 @@ function createTelegramSenseApp(options) {
|
|
|
1907
1947
|
approvalReconciliationActive = true;
|
|
1908
1948
|
nextApprovalReconcileDeadline = undefined;
|
|
1909
1949
|
scheduleApprovalReconcile();
|
|
1950
|
+
const ownerRouteWatch = options.ownerRoute?.probe
|
|
1951
|
+
? setInterval(() => {
|
|
1952
|
+
void checkOwnerRoute().catch((error) => (0, runtime_1.emitNervesEvent)({ level: "error", component: "senses", event: "senses.telegram_owner_route_watch_error", message: "the check of the owner's primary agent failed", meta: { agentName: options.agentName, error: transportError(error) } }));
|
|
1953
|
+
}, telegram_owner_route_1.OWNER_ROUTE_WATCH_INTERVAL_MS)
|
|
1954
|
+
: undefined;
|
|
1910
1955
|
try {
|
|
1911
1956
|
await poll.run(signal);
|
|
1912
1957
|
}
|
|
1913
1958
|
finally {
|
|
1959
|
+
clearInterval(ownerRouteWatch);
|
|
1914
1960
|
approvalReconciliationActive = false;
|
|
1915
1961
|
nextApprovalReconcileDeadline = undefined;
|
|
1916
1962
|
clearApprovalReconcileTimer();
|
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.1378",
|
|
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.1378",
|
|
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.
|
|
3
|
+
"version": "0.1.0-alpha.1378",
|
|
4
4
|
"description": "Ouroboros, the agent harness: agents with durable memory that live where you talk (terminal, Teams, iMessage, mail, voice) and use real tools. Start with npx ouro.bot@latest.",
|
|
5
5
|
"homepage": "https://ouroboros.bot/",
|
|
6
6
|
"engines": {
|