@ouro.bot/cli 0.1.0-alpha.1643 → 0.1.0-alpha.1645

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 CHANGED
@@ -1,10 +1,18 @@
1
1
  {
2
2
  "_note": "Each pull request writes its own change note under changes/; the release job on main gives each landed change its version and adds the notes here (scripts/release-version.cjs). On main this file stops at the last version set by hand; the published package has every release. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.1645",
6
+ "changes": [
7
+ "`ouro doctor` now says how far each agent's BlueBubbles address can be trusted with the server password, which every request carries. A server on the same Mac, behind https, or at a tailnet address passes. Plain http to anything else warns, as does an address that isn't an http or https URL; each says the mailbox won't read letter answers from it and names the fix. A MagicDNS name counts only over https.",
8
+ "`ouro doctor` also says whether a shell beside the daemon could send iMessages as the agent's person. It compares the uid that owns the daemon's socket with the uid of the declared host account (`senses.bluebubbles.hostUsername`), the one signed in to the agent's own Apple ID, so it holds when `ouro doctor` runs as the person and the daemon doesn't. It passes when they match. A socket no daemon answers on counts as no daemon. Otherwise it warns that each letter answer is marked `shared-apple-id` until a human runs the daemon under that account.",
9
+ "A person can now answer a letter by texting its code and an option number, such as `L7 2`, in the iMessage chat the letter went to. When a one-to-one message in answer form arrives, the BlueBubbles sense hands the daemon only its GUID, and the daemon decides from the server's own copy. A recorded answer is not a chat turn. A message that already answered is handled the same when it is replayed. Anything else stays an ordinary chat turn, and so does a message the daemon doesn't answer for within 30 seconds: the daemon records nothing after 27 seconds, so a message is never both.",
10
+ "Once an answer is recorded, the person gets a one-line receipt in the same chat, naming the letter as its heading does, such as `Recorded L7 · Slugger asks: Which name? → 2 Ouro`, so a misread answer shows at once. The agent is told in its private runtime and woken; the private-runtime policy allows that wake only when it names the letter and comes from the daemon's answer command. A receipt or wake that fails is logged and never undoes the answer."
11
+ ]
12
+ },
4
13
  {
5
14
  "version": "0.1.0-alpha.1643",
6
15
  "changes": [
7
- "Update the Ouro UI files to Ouro UI v1.3.590.",
8
16
  "The daemon can now record a person's answer to a letter from their own iMessage. Given only a message's GUID, it reads that message from the agent's BlueBubbles server and records the answer only when every check holds on the server's own fields:",
9
17
  "The text is exactly the letter's code and an option number, such as `L7 2`, with an optional note after a dash. The note loses format characters and is capped at 200 characters.",
10
18
  "It comes from the letter's answering handle, in that handle's one-to-one iMessage chat. It is not sent by SMS, not by the agent (a message whose direction the server doesn't state counts as the agent's), and not as a threaded reply, an edit or a retraction.",
@@ -14,6 +22,12 @@
14
22
  "A message that already answered its letter gets the same answer when it is checked again, so a retry or a recovery replay is never also run as a chat turn. The asker can set a deadline, and nothing is recorded after it."
15
23
  ]
16
24
  },
25
+ {
26
+ "version": "0.1.0-alpha.1642",
27
+ "changes": [
28
+ "Update the Ouro UI files to Ouro UI v1.3.590."
29
+ ]
30
+ },
17
31
  {
18
32
  "version": "0.1.0-alpha.1641",
19
33
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1643",
2
+ "runtimeVersion": "0.1.0-alpha.1645",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -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.1643</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1645</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -1386,6 +1386,8 @@ class OuroDaemon {
1386
1386
  deliverChat: (await Promise.resolve().then(() => __importStar(require("../../senses/bluebubbles/agent-client")))).letterChatSender(this.bundlesRoot),
1387
1387
  // Filing tells the agent, in its own private runtime, so it decides when its person sees the letter.
1388
1388
  onFiled: (await Promise.resolve().then(() => __importStar(require("../letters/filed-note")))).letterFiledTeller(this.bundlesRoot, (wake) => this.handlePrivateRuntimeWake(wake)),
1389
+ // A recorded answer sends the person a receipt in the same chat and tells the agent.
1390
+ onAnswered: (await Promise.resolve().then(() => __importStar(require("../letters/answered-note")))).letterAnsweredTeller(this.bundlesRoot, (await Promise.resolve().then(() => __importStar(require("../../senses/bluebubbles/agent-client")))).letterChatSender(this.bundlesRoot), (wake) => this.handlePrivateRuntimeWake(wake)),
1389
1391
  }))();
1390
1392
  return this.lettersWriter;
1391
1393
  }
@@ -44,6 +44,8 @@ exports.KNOWN_DOCTOR_CATEGORIES = exports.DEFAULT_MEMORY_FLOOR_MB = exports.DEFA
44
44
  exports.checkCliPath = checkCliPath;
45
45
  exports.checkDaemon = checkDaemon;
46
46
  exports.senseInboundDeliveryCheck = senseInboundDeliveryCheck;
47
+ exports.daemonAccount = daemonAccount;
48
+ exports.accountUid = accountUid;
47
49
  exports.checkAgents = checkAgents;
48
50
  exports.checkSenses = checkSenses;
49
51
  exports.checkHabits = checkHabits;
@@ -57,11 +59,15 @@ exports.checkDisk = checkDisk;
57
59
  exports.checkLifecycle = checkLifecycle;
58
60
  exports.checkGit = checkGit;
59
61
  exports.runDoctorChecks = runDoctorChecks;
62
+ const child_process_1 = require("child_process");
63
+ const fs = __importStar(require("fs"));
64
+ const os = __importStar(require("os"));
60
65
  const path = __importStar(require("path"));
61
66
  const portable_git_1 = require("./portable-git");
62
67
  const runtime_1 = require("../../nerves/runtime");
63
68
  const bluebubbles_health_diagnostics_1 = require("./bluebubbles-health-diagnostics");
64
69
  const webhook_registration_1 = require("../../senses/bluebubbles/webhook-registration");
70
+ const url_trust_1 = require("../../senses/bluebubbles/url-trust");
65
71
  const freshness_1 = require("./freshness");
66
72
  const ouro_path_installer_1 = require("../versioning/ouro-path-installer");
67
73
  const runtime_credentials_1 = require("../runtime-credentials");
@@ -280,6 +286,74 @@ const DEFINITIVE_BLUEBUBBLES_WEBHOOK_STATES = new Set([
280
286
  "listener-not-ready",
281
287
  "host-account-refused",
282
288
  ]);
289
+ const URL_TRUST_DETAIL = {
290
+ loopback: "on this Mac: the server password stays on this machine, and the mailbox reads letter answers from it",
291
+ tls: "over https: the server password is encrypted in transit, and the mailbox reads letter answers from it",
292
+ tailnet: "at a tailnet address: Tailscale's tunnel encrypts the server password in transit while it is up, and the mailbox reads letter answers from it",
293
+ };
294
+ /** Whether the BlueBubbles address keeps the server password, which every request carries, from the network. */
295
+ function blueBubblesAddressCheck(agentDir, agentName, serverUrl) {
296
+ const label = `${agentDir} bluebubbles server address`;
297
+ const fix = `then re-attach with \`ouro connect bluebubbles --agent ${agentName}\``;
298
+ if (!URL.canParse(serverUrl) || !/^https?:$/.test(new URL(serverUrl).protocol)) {
299
+ return { label, status: "warn", detail: `${serverUrl} isn't an http or https URL, so the mailbox won't read letter answers from it. Correct it, ${fix}` };
300
+ }
301
+ const trust = (0, url_trust_1.blueBubblesUrlTrust)(serverUrl);
302
+ if (trust !== "untrusted")
303
+ return { label, status: "pass", detail: URL_TRUST_DETAIL[trust] };
304
+ return {
305
+ label,
306
+ status: "warn",
307
+ detail: `plain http to an address outside this Mac and the tailnet, so the server password crosses the network readable and the mailbox won't read letter answers from it. Use https, the server's tailnet address, or a server on this Mac, ${fix}`,
308
+ };
309
+ }
310
+ /** The daemon's macOS account, from its socket's owner; when no daemon is running, this process's account. */
311
+ function daemonAccount(socketPath, me = os.userInfo()) {
312
+ let uid;
313
+ try {
314
+ uid = fs.statSync(socketPath).uid;
315
+ }
316
+ catch {
317
+ return { running: false, user: me.username, uid: me.uid };
318
+ }
319
+ return { running: true, user: uid === me.uid ? me.username : null, uid };
320
+ }
321
+ /** A macOS account's uid, or null when no such account exists here. */
322
+ function accountUid(username, run = child_process_1.execFileSync) {
323
+ try {
324
+ const uid = Number(String(run("id", ["-u", username], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] })).trim());
325
+ return Number.isInteger(uid) ? uid : null;
326
+ }
327
+ catch {
328
+ return null;
329
+ }
330
+ }
331
+ /**
332
+ * Whether a shell on the daemon's account could send iMessages from the person's Apple ID (design §3.4). The declared
333
+ * host account is the one signed in to the agent's own Apple ID, so a daemon running under it can at most send as the
334
+ * agent. Accounts are compared by uid, so the check holds when ouro doctor runs as the person and the daemon doesn't.
335
+ */
336
+ async function blueBubblesIMessageHostCheck(agentDir, hostUsername, deps) {
337
+ const label = `${agentDir} bluebubbles iMessage host`;
338
+ let account = (deps.daemonAccount ?? (() => daemonAccount(deps.socketPath)))();
339
+ // A socket left behind by a daemon that died names no running daemon.
340
+ if (account.running && !(await deps.checkSocketAlive(deps.socketPath))) {
341
+ const me = os.userInfo();
342
+ account = { running: false, user: me.username, uid: me.uid };
343
+ }
344
+ const judged = account.running ? "" : " The daemon isn't running, so this judges the account ouro doctor runs as.";
345
+ const hostUid = (deps.accountUid ?? accountUid)(hostUsername);
346
+ if (hostUid !== null && hostUid === account.uid) {
347
+ return { label, status: "pass", detail: `the daemon runs as ${hostUsername}, the account declared as signed in to the agent's own Apple ID, so a shell beside it can send as the agent, not from the person's Messages.${judged}` };
348
+ }
349
+ const missing = hostUid === null ? ` (no macOS account ${hostUsername} exists on this Mac)` : "";
350
+ const who = account.user ?? `uid ${account.uid}`;
351
+ return {
352
+ label,
353
+ status: "warn",
354
+ detail: `the daemon runs as ${who}, not ${hostUsername}${missing}, the account declared for the agent's own Apple ID, so a shell on ${who} could send iMessages from whatever Apple ID that account's Messages uses, perhaps the person's. Each letter answer is marked shared-apple-id until a human runs the daemon under ${hostUsername}.${judged}`,
355
+ };
356
+ }
283
357
  function blueBubblesUpstreamEvidence(probe) {
284
358
  if (probe.ok)
285
359
  return "healthy";
@@ -516,6 +590,8 @@ async function checkSenses(deps) {
516
590
  status: "pass",
517
591
  detail: `${serverUrl} (host account ${hostUsername})`,
518
592
  });
593
+ checks.push(blueBubblesAddressCheck(agentDir, agentName, serverUrl));
594
+ checks.push(await blueBubblesIMessageHostCheck(agentDir, hostUsername, deps));
519
595
  let upstreamContext = "upstream probe not run in this pass";
520
596
  let infrastructure = { upstream: "not-run", webhook: null };
521
597
  if (deps.fetchImpl) {
@@ -0,0 +1,105 @@
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.answerReceipt = answerReceipt;
37
+ exports.letterAnsweredNote = letterAnsweredNote;
38
+ exports.letterAnsweredWake = letterAnsweredWake;
39
+ exports.tellLetterAnswered = tellLetterAnswered;
40
+ exports.letterAnsweredTeller = letterAnsweredTeller;
41
+ // What happens once a person's answer is recorded (design §3.4, "Visibility"): the harness sends them a one-line
42
+ // receipt in the letters chat, so a misread answer shows at once, and tells the owning agent in its private runtime.
43
+ // Both run after the answer is recorded and never undo it; a failure is logged.
44
+ const path = __importStar(require("path"));
45
+ const pending_1 = require("../../mind/pending");
46
+ const runtime_1 = require("../../nerves/runtime");
47
+ const render_1 = require("./render");
48
+ /**
49
+ * The receipt the person sees, naming the letter as its heading does: "Recorded L7 · Slugger asks: Which name? → 2
50
+ * Ouro", so a paraphrase of another letter can't pass for it. Only Ouro writes it, so it may name the code.
51
+ */
52
+ function answerReceipt(letter, answer) {
53
+ return `Recorded ${(0, render_1.letterHeading)(letter)} → ${answer.option} ${answer.label}`;
54
+ }
55
+ /** The agent's note; the subject, label and note are other people's words, so they are quoted as theirs. */
56
+ function letterAnsweredNote(letter, answer) {
57
+ const note = answer.note ? `, with the note ${JSON.stringify(answer.note)}` : "";
58
+ return `my person answered letter ${letter.code} (its sender's subject: ${JSON.stringify(letter.subject)}) with option ${answer.option}, ${JSON.stringify(answer.label)}${note}. mailbox_read shows it.`;
59
+ }
60
+ function letterAnsweredWake(agent, letter) {
61
+ return {
62
+ kind: "private.wake",
63
+ agent,
64
+ reason: `letter ${letter.code} answered`,
65
+ triggerSource: "letter-answered",
66
+ budgetClass: "interactive",
67
+ idempotencyKey: `letter-answered:${agent}:${letter.id}`,
68
+ originRefs: [{ kind: "letter", id: letter.id }, { kind: "daemon-command", id: "letters.answer" }],
69
+ };
70
+ }
71
+ async function tellLetterAnswered(agent, agentRoot, letter, answer, sendReceipt, wake) {
72
+ if (sendReceipt && letter.answeringHandle) {
73
+ try {
74
+ await sendReceipt({ agent, handle: letter.answeringHandle, text: answerReceipt(letter, answer) });
75
+ (0, runtime_1.emitNervesEvent)({ component: "daemon", event: "letters.receipt_sent", message: "the person was sent a receipt for their answer", meta: { code: letter.code } });
76
+ }
77
+ catch (error) {
78
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "daemon", event: "letters.receipt_failed", message: "the receipt for an answer didn't send; the answer stands", meta: { code: letter.code, error: error.message } });
79
+ }
80
+ }
81
+ (0, pending_1.queuePendingMessageOnce)((0, pending_1.getPrivateRuntimePendingDir)(agent, agentRoot), {
82
+ from: agent,
83
+ friendId: "self",
84
+ channel: "inner",
85
+ key: "dialog",
86
+ content: letterAnsweredNote(letter, answer),
87
+ timestamp: Date.parse(answer.at),
88
+ packetId: `letter-answered:${letter.id}`,
89
+ });
90
+ try {
91
+ const woke = await wake(letterAnsweredWake(agent, letter));
92
+ if (!woke.ok)
93
+ throw new Error(woke.error ?? "the wake was refused");
94
+ if (woke.data?.decision?.executable === false)
95
+ throw new Error(woke.message ?? "the wake was denied");
96
+ (0, runtime_1.emitNervesEvent)({ component: "daemon", event: "letters.answered_told", message: "the agent was told its letter was answered", meta: { code: letter.code } });
97
+ }
98
+ catch (error) {
99
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "daemon", event: "letters.answered_wake_failed", message: "an answered letter's note waits for the agent's next private turn", meta: { code: letter.code, error: error.message } });
100
+ }
101
+ }
102
+ /** The daemon's onAnswered, over each agent's own bundle. */
103
+ function letterAnsweredTeller(bundlesRoot, sendReceipt, wake) {
104
+ return (agent, letter, answer) => tellLetterAnswered(agent, path.join(bundlesRoot, `${agent}.ouro`), letter, answer, sendReceipt, wake);
105
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OPTIONS_LINE = void 0;
4
+ exports.letterHeading = letterHeading;
4
5
  exports.renderLetter = renderLetter;
5
6
  // How a letter reads in chat (design §3.4): plain text the harness writes, never the agent. The sender's fields
6
7
  // were checked and collapsed to one line each when the letter was filed, so nothing here can fake the option block.
@@ -19,12 +20,16 @@ function replyLine(letter) {
19
20
  const spoken = answers.length === 1 ? answers[0] : `${answers.slice(0, -1).join(", ")} or ${answers.at(-1)}`;
20
21
  return `Reply ${spoken}.`;
21
22
  }
23
+ /** The letter's first line, which names its code, its sender and its subject: `L7 · Slugger asks: Which name?`. */
24
+ function letterHeading(letter) {
25
+ return `${letter.code} · ${agentName(letter.from.agent)} ${VERB[letter.kind]}: ${letter.subject}`;
26
+ }
22
27
  /**
23
28
  * The letter as the person reads it. A link shows its label and address; a line anchor is dropped from the
24
29
  * address, so the chat never shows a code-shaped `#L12` beside the letter's own code.
25
30
  */
26
31
  function renderLetter(letter) {
27
- const lines = [`${letter.code} · ${agentName(letter.from.agent)} ${VERB[letter.kind]}: ${letter.subject}`];
32
+ const lines = [letterHeading(letter)];
28
33
  if (letter.whyOnlyYou)
29
34
  lines.push(letter.whyOnlyYou);
30
35
  if (letter.body)
@@ -285,6 +285,7 @@ class LettersWriter {
285
285
  });
286
286
  const label = letter.options.find((option) => option.id === answer.option).label;
287
287
  (0, runtime_1.emitNervesEvent)({ component: "daemon", event: "letters.answer_recorded", message: "a person's answer was recorded", meta: { code: letter.code, hostTrust } });
288
+ this.deps.onAnswered?.(letters.agent, letter, { option: answer.option, label, ...(answer.note ? { note: answer.note } : {}), messageGuid: message.guid, at }).catch(() => undefined);
288
289
  return { recorded: true, id: letter.id, code: letter.code, subject: letter.subject, option: answer.option, label, ...(answer.note ? { note: answer.note } : {}) };
289
290
  });
290
291
  }
@@ -201,6 +201,14 @@ async function evaluatePolicy(request, context, deps) {
201
201
  reason: "a letter was filed for the agent's person",
202
202
  };
203
203
  }
204
+ if (request.triggerSource === "letter-answered"
205
+ && hasNonEmptyOriginRef(originRefs, "letter")
206
+ && hasOriginRef(originRefs, "daemon-command", "letters.answer")) {
207
+ return {
208
+ result: "allow",
209
+ reason: "the agent's person answered a letter",
210
+ };
211
+ }
204
212
  if (isVerifiedHabitWake(request.triggerSource, originRefs)) {
205
213
  return {
206
214
  result: "allow",
@@ -86,6 +86,8 @@ const model_1 = require("./model");
86
86
  const client_1 = require("./client");
87
87
  const letter_guard_1 = require("./letter-guard");
88
88
  const chat_interaction_1 = require("../../heart/chat-interaction");
89
+ const answer_command_1 = require("../../heart/letters/answer-command");
90
+ const letter_answer_ingress_1 = require("./letter-answer-ingress");
89
91
  const reactions_1 = require("./reactions");
90
92
  const send_file_1 = require("./send-file");
91
93
  const chat_file_1 = require("../chat-file");
@@ -440,6 +442,7 @@ const defaultDeps = {
440
442
  },
441
443
  recordProcessed: processed_log_1.recordProcessedBlueBubblesMessage,
442
444
  withSessionTurnLease: session_transaction_1.withSessionTurnLease,
445
+ answerLetter: (agent, messageGuid) => (0, letter_answer_ingress_1.askDaemonToAnswerLetter)(agent, messageGuid),
443
446
  // Incoming events recheck every time, like sends, so a server that takes over
444
447
  // the same URL under another account is refused immediately.
445
448
  verifyHostAccount: (options) => (0, host_account_verifier_1.verifyBlueBubblesServerAccount)({
@@ -1820,6 +1823,20 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
1820
1823
  return { handled: true, notifiedAgent: false, kind: event.kind, reason: "from_me" };
1821
1824
  }
1822
1825
  options.lifecycleSignal?.throwIfAborted();
1826
+ // A message in answer form ("L7 2") from a one-to-one chat may answer a letter. The daemon decides from the
1827
+ // server's copy; a recorded answer is the harness's, so it doesn't become a chat turn, and the daemon tells
1828
+ // the agent. Anything else, or a daemon that can't be asked, runs the turn as usual.
1829
+ if (event.eventType === "new-message" && !event.chat.isGroup && event.fromMe !== true && (0, answer_command_1.looksLikeAnswer)(event.text)) {
1830
+ try {
1831
+ if (await resolvedDeps.answerLetter(agentName, event.messageGuid)) {
1832
+ (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.bluebubbles_letter_answered", message: "a message answered a letter, so it is not a chat turn", meta: { messageGuid: event.messageGuid } });
1833
+ return { handled: true, notifiedAgent: false, kind: event.kind, reason: "letter_answered" };
1834
+ }
1835
+ }
1836
+ catch (error) {
1837
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.bluebubbles_letter_answer_unchecked", message: "couldn't ask the daemon whether a message answers a letter; it is a chat turn", meta: { messageGuid: event.messageGuid, reason: error.message } });
1838
+ }
1839
+ }
1823
1840
  // ── Adapter setup: friend, session, content, callbacks ────────
1824
1841
  const store = resolvedDeps.createFriendStore();
1825
1842
  const resolver = resolvedDeps.createFriendResolver(store, resolveFriendParams(event));
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.askDaemonToAnswerLetter = askDaemonToAnswerLetter;
4
+ // The chat side of a letter's answer (design §3.4): the sense names a message by GUID and the daemon decides from the
5
+ // server's own copy, so nothing this process saw in the webhook decides the answer.
6
+ const socket_client_1 = require("../../heart/daemon/socket-client");
7
+ const runtime_1 = require("../../nerves/runtime");
8
+ /** How long the sense waits for the daemon. A deliver can hold the daemon's letter queue for up to 25 s. */
9
+ const ANSWER_TIMEOUT_MS = 30_000;
10
+ /** The daemon records nothing after this much of the wait, so an answer is never recorded once the sense gives up on it. */
11
+ const ANSWER_DEADLINE_MS = 27_000;
12
+ /**
13
+ * Asks the daemon whether a message answers one of the agent's letters; true when it recorded an answer now or
14
+ * before (a replay). Past the deadline the daemon records nothing, so a timed-out ask leaves the message a chat turn.
15
+ */
16
+ async function askDaemonToAnswerLetter(agent, messageGuid, send = socket_client_1.sendDaemonCommand, now = Date.now) {
17
+ const answer = await send(socket_client_1.DEFAULT_DAEMON_SOCKET_PATH, { kind: "letters.answer", agent, messageGuid, deadlineAt: now() + ANSWER_DEADLINE_MS }, { timeoutMs: ANSWER_TIMEOUT_MS });
18
+ if (!answer.ok)
19
+ throw new Error(answer.error ?? "the daemon refused the letters.answer command");
20
+ const recorded = answer.data?.recorded === true;
21
+ (0, runtime_1.emitNervesEvent)({ level: "debug", component: "senses", event: "senses.bluebubbles_letter_answer_checked", message: "asked the daemon whether a message answers a letter", meta: { messageGuid, recorded } });
22
+ return recorded;
23
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1643",
3
+ "version": "0.1.0-alpha.1645",
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.1643",
9
+ "version": "0.1.0-alpha.1645",
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.1643",
3
+ "version": "0.1.0-alpha.1645",
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": {