@ouro.bot/cli 0.1.0-alpha.1363 → 0.1.0-alpha.1365
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/identity.js +26 -0
- package/dist/senses/telegram-effect-adapter.js +4 -3
- package/dist/senses/telegram-owner-route.js +93 -0
- package/dist/senses/telegram.js +88 -7
- 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.1365",
|
|
6
|
+
"changes": [
|
|
7
|
+
"With an owner route, the approvals the Butler needs from its owner (tool approval prompts, admission cards) go to the owner's primary agent first as urgent; the card still reaches Telegram so its buttons work, silently when the primary agent has it."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1364",
|
|
12
|
+
"changes": [
|
|
13
|
+
"The Butler can send the messages it starts itself (house notices, external events, unprompted messages) to the owner's primary agent over A2A instead of to Telegram, set by senses.telegram.ownerNoticesTo in agent.json; replies stay on Telegram, and while the peer can't be reached only urgent messages go to Telegram, marked as a fallback."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1363",
|
|
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.1365</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/heart/identity.js
CHANGED
|
@@ -224,6 +224,27 @@ function normalizeAppSessionsConfig(rawSense, configFile) {
|
|
|
224
224
|
result.digest = normalizeDigest(rawSense.digest, fail);
|
|
225
225
|
return result;
|
|
226
226
|
}
|
|
227
|
+
function normalizeOwnerNoticesTo(value, configFile) {
|
|
228
|
+
const fail = (message) => {
|
|
229
|
+
(0, runtime_1.emitNervesEvent)({ level: "error", event: "config_identity.error", component: "config/identity", message: "agent config has an invalid Telegram owner route", meta: { path: configFile } });
|
|
230
|
+
throw new Error(`agent.json at ${configFile}: ${message}`);
|
|
231
|
+
};
|
|
232
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
233
|
+
return fail("senses.telegram.ownerNoticesTo must be { cardUrl, did }.");
|
|
234
|
+
const { cardUrl, did } = value;
|
|
235
|
+
let protocol = "";
|
|
236
|
+
try {
|
|
237
|
+
protocol = typeof cardUrl === "string" ? new URL(cardUrl).protocol : "";
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
protocol = "";
|
|
241
|
+
}
|
|
242
|
+
if (protocol !== "http:" && protocol !== "https:")
|
|
243
|
+
return fail("senses.telegram.ownerNoticesTo.cardUrl must be an http or https URL.");
|
|
244
|
+
if (typeof did !== "string" || !did.startsWith("did:key:"))
|
|
245
|
+
return fail("senses.telegram.ownerNoticesTo.did must be a did:key.");
|
|
246
|
+
return { cardUrl: cardUrl, did };
|
|
247
|
+
}
|
|
227
248
|
function normalizeSenses(value, configFile) {
|
|
228
249
|
const defaults = {
|
|
229
250
|
cli: { ...exports.DEFAULT_AGENT_SENSES.cli },
|
|
@@ -318,6 +339,11 @@ function normalizeSenses(value, configFile) {
|
|
|
318
339
|
defaults[senseName] = { enabled, ...normalizeAppSessionsConfig(rawSense, configFile) };
|
|
319
340
|
continue;
|
|
320
341
|
}
|
|
342
|
+
const ownerNoticesTo = rawSense.ownerNoticesTo;
|
|
343
|
+
if (senseName === "telegram" && ownerNoticesTo !== undefined) {
|
|
344
|
+
defaults[senseName] = { enabled, ownerNoticesTo: normalizeOwnerNoticesTo(ownerNoticesTo, configFile) };
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
321
347
|
defaults[senseName] = { enabled };
|
|
322
348
|
}
|
|
323
349
|
return defaults;
|
|
@@ -118,7 +118,7 @@ function validateArtifact(artifact, expectedId) {
|
|
|
118
118
|
? boundedText(effect.text, 150_000)
|
|
119
119
|
&& (effect.kind !== "text" || effect.replyToMessageId === undefined || (Number.isSafeInteger(effect.replyToMessageId) && effect.replyToMessageId > 0))
|
|
120
120
|
: effect?.kind === "card"
|
|
121
|
-
? boundedText(effect.text) && Array.isArray(effect.buttons) && effect.buttons.length > 0 && effect.buttons.length <= 20
|
|
121
|
+
? boundedText(effect.text) && (effect.silent === undefined || effect.silent === true) && Array.isArray(effect.buttons) && effect.buttons.length > 0 && effect.buttons.length <= 20
|
|
122
122
|
&& effect.buttons.every((row) => Array.isArray(row) && row.length > 0 && row.length <= 8
|
|
123
123
|
&& row.every((button) => boundedText(button?.text, 256) && boundedText(button?.callbackData, 64) && Buffer.byteLength(button.callbackData, "utf8") <= 64))
|
|
124
124
|
: effect?.kind === "edit"
|
|
@@ -392,14 +392,15 @@ async function executePart(api, artifact, part, chatId, signal) {
|
|
|
392
392
|
}
|
|
393
393
|
if (effect.kind === "card") {
|
|
394
394
|
const reply_markup = { inline_keyboard: effect.buttons.map((row) => row.map((button) => ({ text: button.text, callback_data: button.callbackData }))) };
|
|
395
|
+
const quiet = effect.silent ? { disable_notification: true } : {};
|
|
395
396
|
let result;
|
|
396
397
|
try {
|
|
397
|
-
result = await api.request("sendMessage", { chat_id: chatId, text: (0, telegram_client_1.escapeTelegramHtml)(effect.text), parse_mode: "HTML", reply_markup }, signal);
|
|
398
|
+
result = await api.request("sendMessage", { chat_id: chatId, text: (0, telegram_client_1.escapeTelegramHtml)(effect.text), parse_mode: "HTML", reply_markup, ...quiet }, signal);
|
|
398
399
|
}
|
|
399
400
|
catch (error) {
|
|
400
401
|
if (!(error instanceof telegram_client_1.TelegramApiError) || error.status !== 400)
|
|
401
402
|
throw error;
|
|
402
|
-
result = await api.request("sendMessage", { chat_id: chatId, text: effect.text, reply_markup }, signal);
|
|
403
|
+
result = await api.request("sendMessage", { chat_id: chatId, text: effect.text, reply_markup, ...quiet }, signal);
|
|
403
404
|
}
|
|
404
405
|
return canonicalMessageId(result);
|
|
405
406
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OWNER_ROUTE_FALLBACK_PREFIX = void 0;
|
|
4
|
+
exports.ownerRouteUrgency = ownerRouteUrgency;
|
|
5
|
+
exports.ownerRouteDedupeKey = ownerRouteDedupeKey;
|
|
6
|
+
exports.ownerRouteItem = ownerRouteItem;
|
|
7
|
+
exports.formatOwnerRouteMessage = formatOwnerRouteMessage;
|
|
8
|
+
exports.createA2AOwnerRoute = createA2AOwnerRoute;
|
|
9
|
+
exports.ownerRouteForAgent = ownerRouteForAgent;
|
|
10
|
+
const node_crypto_1 = require("node:crypto");
|
|
11
|
+
const client_1 = require("../a2a/client");
|
|
12
|
+
const identity_1 = require("../a2a/identity");
|
|
13
|
+
const identity_2 = require("../heart/identity");
|
|
14
|
+
const runtime_1 = require("../nerves/runtime");
|
|
15
|
+
exports.OWNER_ROUTE_FALLBACK_PREFIX = "Slugger can't be reached, so this comes to you directly.";
|
|
16
|
+
function ownerRouteUrgency(key, critical) {
|
|
17
|
+
if (critical)
|
|
18
|
+
return "now";
|
|
19
|
+
if (key.startsWith("owner-notice:house-sweep:"))
|
|
20
|
+
return "batch";
|
|
21
|
+
return "today";
|
|
22
|
+
}
|
|
23
|
+
const slug = (value) => value.toLowerCase().replace(/[^a-z0-9]+/gu, "-").replace(/^-+|-+$/gu, "");
|
|
24
|
+
function ownerRouteDedupeKey(key, text) {
|
|
25
|
+
const [kind, ...rest] = key.split(":");
|
|
26
|
+
const tail = rest.join(":");
|
|
27
|
+
let condition;
|
|
28
|
+
if (kind === "external-event") {
|
|
29
|
+
// The generation counts re-fires of one event; the condition is its source and id.
|
|
30
|
+
let identity;
|
|
31
|
+
try {
|
|
32
|
+
identity = JSON.parse(tail);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
identity = null;
|
|
36
|
+
}
|
|
37
|
+
condition = Array.isArray(identity) && identity.length >= 2 ? `${identity[0]}-${identity[1]}` : key;
|
|
38
|
+
}
|
|
39
|
+
else if (kind === "proactive") {
|
|
40
|
+
// A proactive key is a fresh UUID each time, so the same words name the same condition.
|
|
41
|
+
condition = `proactive-${(0, node_crypto_1.createHash)("sha256").update(text).digest("hex").slice(0, 12)}`;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
condition = kind === "owner-notice" ? tail : key;
|
|
45
|
+
}
|
|
46
|
+
return `butler-${slug(condition)}`.slice(0, 120);
|
|
47
|
+
}
|
|
48
|
+
function ownerRouteItem(key, text, critical) {
|
|
49
|
+
return { key, text, urgency: ownerRouteUrgency(key, critical), dedupeKey: ownerRouteDedupeKey(key, text) };
|
|
50
|
+
}
|
|
51
|
+
function formatOwnerRouteMessage(item) {
|
|
52
|
+
const firstLine = item.text.trim().split("\n")[0].trim();
|
|
53
|
+
const ask = firstLine.length > 200 ? `${firstLine.slice(0, 199)}…` : firstLine;
|
|
54
|
+
return [
|
|
55
|
+
"from: the Butler (sanctuary, Ari's house server)",
|
|
56
|
+
`urgency: ${item.urgency}`,
|
|
57
|
+
`ask: ${ask}`,
|
|
58
|
+
"why only Ari: it is about his house, and the Butler reports to him",
|
|
59
|
+
`steps: ${item.text}`,
|
|
60
|
+
"deadline: none",
|
|
61
|
+
`dedupe key: ${item.dedupeKey}`,
|
|
62
|
+
].join("\n");
|
|
63
|
+
}
|
|
64
|
+
const reason = (error) => error instanceof Error ? error.message : String(error);
|
|
65
|
+
function createA2AOwnerRoute(options) {
|
|
66
|
+
const fetchCard = options.fetchCard ?? client_1.fetchA2AAgentCard;
|
|
67
|
+
const send = options.send ?? client_1.sendSealedA2AChat;
|
|
68
|
+
return async (item) => {
|
|
69
|
+
try {
|
|
70
|
+
const served = (0, client_1.cardDid)(await fetchCard(options.cardUrl));
|
|
71
|
+
if (served !== options.did) {
|
|
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 } });
|
|
74
|
+
return { status: "unreachable", detail };
|
|
75
|
+
}
|
|
76
|
+
await send({ cardUrl: options.cardUrl, text: formatOwnerRouteMessage(item), identity: await options.loadIdentity() });
|
|
77
|
+
(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
|
+
return { status: "delivered" };
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.telegram_owner_route_unreachable", message: "the owner's primary agent could not be reached", meta: { urgency: item.urgency, dedupeKey: item.dedupeKey, error: reason(error) } });
|
|
82
|
+
return { status: "unreachable", detail: reason(error) };
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** The owner route `agent.json` names (`senses.telegram.ownerNoticesTo`), signing as this agent's A2A identity; none when unset. */
|
|
87
|
+
function ownerRouteForAgent(agentName, agentRoot) {
|
|
88
|
+
const peer = (0, identity_2.loadAgentConfig)({ agentName, agentRoot }).senses?.telegram.ownerNoticesTo;
|
|
89
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.telegram_owner_route_configured", message: "read the Telegram owner route", meta: { agentName, cardUrl: peer?.cardUrl ?? null } });
|
|
90
|
+
if (!peer)
|
|
91
|
+
return undefined;
|
|
92
|
+
return createA2AOwnerRoute({ cardUrl: peer.cardUrl, did: peer.did, loadIdentity: () => (0, identity_1.loadSelfA2AIdentity)({ agentName }) });
|
|
93
|
+
}
|
package/dist/senses/telegram.js
CHANGED
|
@@ -91,6 +91,7 @@ const sanctuary_grounding_1 = require("./sanctuary-grounding");
|
|
|
91
91
|
const telegram_approval_runtime_1 = require("./telegram-approval-runtime");
|
|
92
92
|
const telegram_audit_ledger_1 = require("./telegram-audit-ledger");
|
|
93
93
|
const session_events_1 = require("../heart/session-events");
|
|
94
|
+
const telegram_owner_route_1 = require("./telegram-owner-route");
|
|
94
95
|
const telegram_handoff_1 = require("./telegram-handoff");
|
|
95
96
|
const router_1 = require("../heart/external-events/router");
|
|
96
97
|
const session_transaction_1 = require("../mind/session-transaction");
|
|
@@ -830,12 +831,33 @@ function createTelegramSenseApp(options) {
|
|
|
830
831
|
const authorizeEffect = options.authorizeEffect ?? defaultEffectAuthorization;
|
|
831
832
|
let recordAcceptedEffects;
|
|
832
833
|
const configuredOwnerTarget = () => ({ kind: "approved_relationship", friendId: configuredOwnerFriendId, sessionKey: configuredOwnerSessionKey });
|
|
833
|
-
const
|
|
834
|
+
const fallbackText = (text) => `${telegram_owner_route_1.OWNER_ROUTE_FALLBACK_PREFIX}\n\n${text}`;
|
|
835
|
+
const executeOnTelegram = (0, telegram_effect_adapter_1.createTelegramAuthorizedEffectExecutor)({
|
|
834
836
|
store: getEffectJournal,
|
|
835
837
|
api,
|
|
836
838
|
authorize: authorizeEffect,
|
|
837
839
|
barrier: acceptanceAuditBarrier,
|
|
838
840
|
});
|
|
841
|
+
/**
|
|
842
|
+
* An approval card the agent wants from the owner (a tool approval's prompt, a newcomer's admission card) goes to the owner
|
|
843
|
+
* route first, as urgent. The card still goes to Telegram so its buttons work: silently when the primary agent has it,
|
|
844
|
+
* and with the fallback line when it can't be reached. A resend of a card already in the journal is left as it was.
|
|
845
|
+
*/
|
|
846
|
+
const executeAuthorizedEffect = async (input) => {
|
|
847
|
+
const route = options.ownerRoute;
|
|
848
|
+
if (!route || input.effect.kind !== "card" || input.target.kind !== "approved_relationship" || input.target.friendId !== configuredOwnerFriendId
|
|
849
|
+
|| !/^(?:approval:.+:prompt|owner-card:.+)$/u.test(input.idempotencyKey) || getEffectJournal().readByIdempotencyKey(input.idempotencyKey)) {
|
|
850
|
+
return executeOnTelegram(input);
|
|
851
|
+
}
|
|
852
|
+
const effect = input.effect;
|
|
853
|
+
const choices = effect.buttons.flat().map((button) => button.text).join(", ");
|
|
854
|
+
const outcome = await route((0, telegram_owner_route_1.ownerRouteItem)(input.idempotencyKey, `${effect.text}\n\nOptions: ${choices}. The buttons are on the card in the Butler's Telegram chat.`, true));
|
|
855
|
+
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.telegram_owner_route_approval", message: "offered an approval card to the owner's primary agent", meta: { agentName: options.agentName, outcome: outcome.status } });
|
|
856
|
+
return executeOnTelegram({
|
|
857
|
+
...input,
|
|
858
|
+
effect: outcome.status === "delivered" ? { ...effect, silent: true } : { ...effect, text: fallbackText(effect.text) },
|
|
859
|
+
});
|
|
860
|
+
};
|
|
839
861
|
const recordConfiguredOwnerEffect = async (artifact, causalEventId) => {
|
|
840
862
|
await recordAcceptedEffects((0, shared_turn_1.getSenseSessionPath)(options.agentName, configuredOwnerFriendId, "telegram", configuredOwnerSessionKey, agentRoot), [artifact], undefined, causalEventId ? { [artifact.id]: causalEventId } : undefined);
|
|
841
863
|
};
|
|
@@ -1054,12 +1076,58 @@ function createTelegramSenseApp(options) {
|
|
|
1054
1076
|
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.telegram_notice_held_for_pacing", message: "held a house notice for quiet hours or the daily message cap", meta: { agentName: options.agentName, reason: pacingReason } });
|
|
1055
1077
|
return true;
|
|
1056
1078
|
};
|
|
1079
|
+
// Keys the owner's primary agent accepted, so a retry is already sent (as with the effect journal for Telegram).
|
|
1080
|
+
const routedKeysPath = path.join(agentRoot, "state", "telegram", "routed-owner-notices.json");
|
|
1081
|
+
/**
|
|
1082
|
+
* Offers a self-started message to the owner route. Returns null when it is handled (the peer has it, or it waits in the
|
|
1083
|
+
* held file for the peer), or the text Telegram should send: the message itself with no route, or, for an urgent message
|
|
1084
|
+
* the peer can't take, the message marked as a fallback.
|
|
1085
|
+
*/
|
|
1086
|
+
const routeSelfStarted = async (text, key, critical = (0, telegram_handoff_1.isCriticalNoticeKey)(key), signal) => {
|
|
1087
|
+
if (!options.ownerRoute)
|
|
1088
|
+
return text;
|
|
1089
|
+
// Older held notices go first, so the peer hears them in order.
|
|
1090
|
+
await releaseHeldNotices(signal);
|
|
1091
|
+
const item = (0, telegram_owner_route_1.ownerRouteItem)(key, text, critical);
|
|
1092
|
+
const outcome = await options.ownerRoute(item);
|
|
1093
|
+
if (outcome.status === "delivered") {
|
|
1094
|
+
(0, telegram_handoff_1.recordReleasedHeldKeys)(routedKeysPath, [key]);
|
|
1095
|
+
return null;
|
|
1096
|
+
}
|
|
1097
|
+
if (item.urgency === "now") {
|
|
1098
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.telegram_owner_route_fallback", message: "the owner's primary agent can't be reached; an urgent message goes to Telegram", meta: { agentName: options.agentName, dedupeKey: item.dedupeKey, detail: outcome.detail } });
|
|
1099
|
+
return fallbackText(text);
|
|
1100
|
+
}
|
|
1101
|
+
const held = (0, telegram_handoff_1.readHeldNotices)(heldNoticesPath);
|
|
1102
|
+
if (!held.some((notice) => notice.key === key))
|
|
1103
|
+
(0, telegram_handoff_1.writeHeldNotices)(heldNoticesPath, [...held, { key, text }]);
|
|
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
|
+
return null;
|
|
1106
|
+
};
|
|
1107
|
+
/** 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
|
+
const releaseHeldNoticesToRoute = async (route, signal) => {
|
|
1109
|
+
const sessionPath = (0, shared_turn_1.getSenseSessionPath)(options.agentName, configuredOwnerFriendId, "telegram", configuredOwnerSessionKey, agentRoot);
|
|
1110
|
+
for (const notice of (0, telegram_handoff_1.readHeldNotices)(heldNoticesPath)) {
|
|
1111
|
+
const critical = (0, telegram_handoff_1.isCriticalNoticeKey)(notice.key);
|
|
1112
|
+
const outcome = await route((0, telegram_owner_route_1.ownerRouteItem)(notice.key, notice.text, critical));
|
|
1113
|
+
if (outcome.status !== "delivered" && !critical)
|
|
1114
|
+
continue;
|
|
1115
|
+
(0, telegram_handoff_1.writeHeldNotices)(heldNoticesPath, (0, telegram_handoff_1.readHeldNotices)(heldNoticesPath).filter((entry) => entry.key !== notice.key));
|
|
1116
|
+
if (outcome.status === "delivered") {
|
|
1117
|
+
(0, telegram_handoff_1.recordReleasedHeldKeys)(routedKeysPath, [notice.key]);
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
await recordAcceptedEffects(sessionPath, [await deliverButlerEffect(fallbackText(notice.text), notice.key, signal)]);
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1057
1123
|
let heldNoticeRelease = Promise.resolve();
|
|
1058
1124
|
const releaseHeldNotices = async (signal) => {
|
|
1059
1125
|
// Nearly always nothing is held: return without queueing, so ordinary turns and the reconcile tick pay nothing.
|
|
1060
1126
|
if ((0, telegram_handoff_1.readHeldNotices)(heldNoticesPath).length === 0)
|
|
1061
1127
|
return;
|
|
1062
1128
|
const release = heldNoticeRelease.then(async () => {
|
|
1129
|
+
if (options.ownerRoute)
|
|
1130
|
+
return releaseHeldNoticesToRoute(options.ownerRoute, signal);
|
|
1063
1131
|
const held = (0, telegram_handoff_1.readHeldNotices)(heldNoticesPath);
|
|
1064
1132
|
if (ownerChatIsHandedOff())
|
|
1065
1133
|
return;
|
|
@@ -1881,10 +1949,13 @@ function createTelegramSenseApp(options) {
|
|
|
1881
1949
|
return;
|
|
1882
1950
|
}
|
|
1883
1951
|
const key = `proactive:${(0, node_crypto_1.randomUUID)()}`;
|
|
1884
|
-
|
|
1952
|
+
const telegramText = await routeSelfStarted(proactiveText, key, undefined, signal);
|
|
1953
|
+
if (telegramText === null)
|
|
1954
|
+
return;
|
|
1955
|
+
if (holdNoticeDuringHandoff(telegramText, key))
|
|
1885
1956
|
return;
|
|
1886
1957
|
await releaseHeldNotices(signal);
|
|
1887
|
-
const effect = await deliverButlerEffect(
|
|
1958
|
+
const effect = await deliverButlerEffect(telegramText, key, signal);
|
|
1888
1959
|
countProactiveSend();
|
|
1889
1960
|
const sessionPath = (0, shared_turn_1.getSenseSessionPath)(options.agentName, configuredOwnerFriendId, "telegram", configuredOwnerSessionKey, agentRoot);
|
|
1890
1961
|
await recordAcceptedEffects(sessionPath, [effect]);
|
|
@@ -1905,8 +1976,10 @@ function createTelegramSenseApp(options) {
|
|
|
1905
1976
|
const sessionPath = (0, shared_turn_1.getSenseSessionPath)(options.agentName, configuredOwnerFriendId, "telegram", configuredOwnerSessionKey, agentRoot);
|
|
1906
1977
|
const held = (0, telegram_handoff_1.readHeldNotices)(heldNoticesPath);
|
|
1907
1978
|
const releasedKeys = (0, telegram_handoff_1.readReleasedHeldKeys)(releasedHeldKeysPath);
|
|
1979
|
+
const routedKeys = (0, telegram_handoff_1.readReleasedHeldKeys)(routedKeysPath);
|
|
1908
1980
|
const ownerMessageExists = (candidate) => held.some((notice) => notice.key === candidate)
|
|
1909
1981
|
|| releasedKeys.includes(candidate)
|
|
1982
|
+
|| routedKeys.includes(candidate)
|
|
1910
1983
|
|| getEffectJournal().readByIdempotencyKey(candidate) !== null;
|
|
1911
1984
|
if (ownerMessageExists(key)) {
|
|
1912
1985
|
// A retry after the message went out (or was held): finish the original send, never send a reworded second one.
|
|
@@ -1930,10 +2003,14 @@ function createTelegramSenseApp(options) {
|
|
|
1930
2003
|
});
|
|
1931
2004
|
return { status: "covered", effectKey: coveredBy };
|
|
1932
2005
|
}
|
|
1933
|
-
|
|
2006
|
+
const critical = [key, ...relatedKeys].some(telegram_handoff_1.isCriticalNoticeKey);
|
|
2007
|
+
const telegramText = await routeSelfStarted(text, key, critical, input.signal);
|
|
2008
|
+
if (telegramText === null)
|
|
2009
|
+
return { status: "sent", effectKey: key };
|
|
2010
|
+
if (holdNoticeDuringHandoff(telegramText, key, critical))
|
|
1934
2011
|
return { status: "sent", effectKey: key };
|
|
1935
2012
|
await releaseHeldNotices(input.signal);
|
|
1936
|
-
const effect = await deliverButlerEffect(
|
|
2013
|
+
const effect = await deliverButlerEffect(telegramText, key, input.signal);
|
|
1937
2014
|
countProactiveSend();
|
|
1938
2015
|
await recordAcceptedEffects(sessionPath, [effect]);
|
|
1939
2016
|
return { status: "sent", effectKey: key };
|
|
@@ -1948,10 +2025,13 @@ function createTelegramSenseApp(options) {
|
|
|
1948
2025
|
throw new Error("Telegram owner notice id is invalid");
|
|
1949
2026
|
await runWithAcceptanceAuditOwner(async () => {
|
|
1950
2027
|
const text = requiredText(input.text, "owner notice");
|
|
1951
|
-
|
|
2028
|
+
const telegramText = await routeSelfStarted(text, `owner-notice:${noticeId}`, undefined, input.signal);
|
|
2029
|
+
if (telegramText === null)
|
|
2030
|
+
return;
|
|
2031
|
+
if (holdNoticeDuringHandoff(telegramText, `owner-notice:${noticeId}`))
|
|
1952
2032
|
return;
|
|
1953
2033
|
await releaseHeldNotices(input.signal);
|
|
1954
|
-
const effect = await deliverButlerEffect(
|
|
2034
|
+
const effect = await deliverButlerEffect(telegramText, `owner-notice:${noticeId}`, input.signal);
|
|
1955
2035
|
countProactiveSend();
|
|
1956
2036
|
const sessionPath = (0, shared_turn_1.getSenseSessionPath)(options.agentName, configuredOwnerFriendId, "telegram", configuredOwnerSessionKey, agentRoot);
|
|
1957
2037
|
await recordAcceptedEffects(sessionPath, [effect]);
|
|
@@ -2266,6 +2346,7 @@ async function startTelegramSenseApp(agentName, waitForAuthority = false) {
|
|
|
2266
2346
|
authorityTransport,
|
|
2267
2347
|
// The owner is in Los Angeles; a container without TZ would otherwise run quiet hours on UTC.
|
|
2268
2348
|
proactivePacing: { timeZone: process.env.TZ || "America/Los_Angeles" },
|
|
2349
|
+
...(() => { const ownerRoute = (0, telegram_owner_route_1.ownerRouteForAgent)(agentName, (0, identity_1.getAgentRoot)(agentName)); return ownerRoute ? { ownerRoute } : {}; })(),
|
|
2269
2350
|
...(await createProductionTelegramRelationshipComposition(agentName, credentials, undefined, authorityTransport)),
|
|
2270
2351
|
...(agentName === "sanctuary" ? { privilegedFailsafe: {
|
|
2271
2352
|
eventRoot: (0, router_1.getExternalEventRoot)(),
|
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.1365",
|
|
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.1365",
|
|
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.1365",
|
|
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": {
|