@ouro.bot/cli 0.1.0-alpha.1648 → 0.1.0-alpha.1649

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
@@ -2,19 +2,25 @@
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
4
  {
5
- "version": "0.1.0-alpha.1648",
5
+ "version": "0.1.0-alpha.1649",
6
+ "changes": [
7
+ "A letter filed from an agent's turn now remembers that turn's session. Once the person's answer is recorded, the daemon queues \"Ari answered L7: 2 Ouro — after lunch\" in that session, so the conversation that asked reads the answer on its next turn. A letter filed from the private runtime, the CLI or an MCP client has no session to return to. The agent's private runtime is told of every answer as before, and anyone waiting with `mailbox_wait` is released as before.",
8
+ "Each try to return an answer writes a `returned` event. A try that fails is tried again after a minute, then after a doubling wait of at most an hour, until it succeeds.",
9
+ "The session must be one the agent has really had turns in. A voice session gets no returned note, because a voice call drops notes older than a few minutes. The note comes from the mailbox, so Telegram's rule that drops an agent's own stale outreach doesn't remove it.",
10
+ "The agent's private runtime note about an answer now names the session that asked, so the agent can raise the answer there sooner than that session's next turn.",
11
+ "When another caller refiles a letter, the reply says the answer returns to the session that first filed it.",
12
+ "When the person reads a letter in iMessage, the mailbox now records it as seen. The sense tells the daemon about the read receipt, and the daemon checks the BlueBubbles server's own copy of the message: Ouro sent it, into the chat the letter was delivered to, and the server has a read time. `mailbox_list` then shows `waiting, seen 2h ago` and `mailbox_read` returns `seen: \"seen 2h ago, not answered\"`, so an agent can tell its person has read the letter and doesn't ask again. A read receipt that arrives while the sense is down is not replayed, so a letter can be read without being marked seen."
13
+ ]
14
+ },
15
+ {
16
+ "version": "0.1.0-alpha.1647",
6
17
  "changes": [
7
18
  "The Butler's host upgrade tells the bundle migration which Butler name the new image runs (`--butler-name`), so the bundle's own files (agent.json, the replay-client provisioning record, recent attachments, skills and HOUSE.md) name the container path that image mounts.",
8
19
  "An await filed from an external event still resolves after the Butler's events folder moves to its other name, in either direction.",
9
20
  "When the Butler starts and finds events saved under its other name, it merges them into its own folder even when both folders exist. It combines the privileged spool's replay manifests first, so no accepted envelope is accepted twice. A record both folders have keeps the running Butler's copy, and the other copy moves to `external-events/.adoption-conflicts/<other name>/<time>/`, with a warning; nothing is deleted and the start goes on. Only a move that fails stops the daemon from starting, with guidance naming the container and Unraid host paths. An other-name entry that is a symlink is left alone, with a warning.",
10
21
  "An upgrade that would change the Butler's name is refused, before anything is paused or changed, unless the running release can take a rollback across the rename. Ship a release from after this change with the name unchanged first, then the release that renames it.",
11
22
  "A held upgrade (`--hold-commit`) now says that a rollback puts the migrated bundle files back as they were before the migrate, so edits made to them during the hold are lost.",
12
- "The health acceptance probe runs as the Butler whose bundle is on disk, and the privileged spool scan files envelopes under the Butler the daemon start set, so neither recreates the other name's events folder after the rename.",
13
- "A letter filed from an agent's turn now remembers that turn's session. Once the person's answer is recorded, the daemon queues \"Ari answered L7: 2 Ouro — after lunch\" in that session, so the conversation that asked reads the answer on its next turn. A letter filed from the private runtime, the CLI or an MCP client has no session to return to. The agent's private runtime is told of every answer as before, and anyone waiting with `mailbox_wait` is released as before.",
14
- "Each try to return an answer writes a `returned` event. A try that fails is tried again after a minute, then after a doubling wait of at most an hour, until it succeeds.",
15
- "The session must be one the agent has really had turns in. A voice session gets no returned note, because a voice call drops notes older than a few minutes. The note comes from the mailbox, so Telegram's rule that drops an agent's own stale outreach doesn't remove it.",
16
- "The agent's private runtime note about an answer now names the session that asked, so the agent can raise the answer there sooner than that session's next turn.",
17
- "When another caller refiles a letter, the reply says the answer returns to the session that first filed it."
23
+ "The health acceptance probe runs as the Butler whose bundle is on disk, and the privileged spool scan files envelopes under the Butler the daemon start set, so neither recreates the other name's events folder after the rename."
18
24
  ]
19
25
  },
20
26
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1648",
2
+ "runtimeVersion": "0.1.0-alpha.1649",
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.1648</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1649</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -330,6 +330,12 @@
330
330
  "description": "waiting, answered, withdrawn or expired; Ouro derives it from the letter's events.",
331
331
  "kind": "string"
332
332
  },
333
+ "seen": {
334
+ "label": "Seen",
335
+ "description": "When the person read a waiting letter, such as \"seen 2h ago, not answered\", so it isn't asked again.",
336
+ "optional": true,
337
+ "kind": "string"
338
+ },
333
339
  "letter": {
334
340
  "label": "Letter",
335
341
  "description": "The letter as filed, as JSON.",
@@ -108,7 +108,7 @@
108
108
  "required": true
109
109
  }
110
110
  ],
111
- "output": "{ outcome, state, letter, events }"
111
+ "output": "{ outcome, state, seen, letter, events }"
112
112
  },
113
113
  {
114
114
  "name": "mailbox wait",
@@ -255,6 +255,10 @@
255
255
  "type": "string",
256
256
  "description": "waiting, answered, withdrawn or expired; Ouro derives it from the letter's events."
257
257
  },
258
+ "seen": {
259
+ "type": "string",
260
+ "description": "When the person read a waiting letter, such as \"seen 2h ago, not answered\", so it isn't asked again."
261
+ },
258
262
  "letter": {
259
263
  "type": "string",
260
264
  "description": "The letter as filed, as JSON."
@@ -2632,6 +2632,13 @@ class OuroDaemon {
2632
2632
  const { letterAnswerSource } = await Promise.resolve().then(() => __importStar(require("../../senses/bluebubbles/agent-client")));
2633
2633
  return answerLettersAnswerCommand(await this.letters(), command, letterAnswerSource(this.bundlesRoot));
2634
2634
  }
2635
+ case "letters.seen":
2636
+ {
2637
+ // A read receipt, named by the GUID of the message Ouro delivered; the server's copy decides.
2638
+ const { answerLettersSeenCommand } = await Promise.resolve().then(() => __importStar(require("../letters/seen-command")));
2639
+ const { letterAnswerSource } = await Promise.resolve().then(() => __importStar(require("../../senses/bluebubbles/agent-client")));
2640
+ return answerLettersSeenCommand(await this.letters(), command, letterAnswerSource(this.bundlesRoot));
2641
+ }
2635
2642
  case "mcp.list": {
2636
2643
  return (0, turn_execution_lease_1.withTurnExecutionLease)(async () => {
2637
2644
  const agentName = command.agent ?? "default";
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.answerLettersSeenCommand = answerLettersSeenCommand;
4
+ // The daemon's `letters.seen` command: the BlueBubbles ingress names a message whose read receipt it saw, and the
5
+ // daemon reads that message from the agent's own server and records that the person read the letter it delivered.
6
+ // Like `letters.answer`, the command carries only a GUID, so whoever sends it can only point at a real message.
7
+ const runtime_1 = require("../../nerves/runtime");
8
+ async function answerLettersSeenCommand(writer, command, sourceFor) {
9
+ if (typeof command.agent !== "string" || typeof command.messageGuid !== "string" || !command.messageGuid.trim()) {
10
+ return { ok: false, error: "letters.seen needs an agent and a messageGuid." };
11
+ }
12
+ if (!writer.hasAgent(command.agent))
13
+ return { ok: false, error: `No agent bundle ${command.agent}.ouro is on this machine.` };
14
+ try {
15
+ const guid = command.messageGuid.trim();
16
+ // Most read receipts are for ordinary chat messages, so the index is asked before the server is.
17
+ if (!writer.hasWaitingDelivery(command.agent, guid))
18
+ return { ok: true, data: { recorded: false, reason: "no-letter" } };
19
+ const source = await sourceFor(command.agent);
20
+ // The server password travels in the fetch's query string, so only a server nobody between can read is asked.
21
+ if (source.trust === "untrusted")
22
+ return { ok: true, data: { recorded: false, reason: "untrusted-server-url" } };
23
+ const message = await source.getServerMessage(guid);
24
+ if (!message || message.guid !== guid)
25
+ return { ok: true, data: { recorded: false, reason: "unknown-message" } };
26
+ return { ok: true, data: await writer.recordSeen(command.agent, message) };
27
+ }
28
+ catch (error) {
29
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "daemon", event: "letters.seen_failed", message: "a read receipt couldn't be checked", meta: { reason: error.message } });
30
+ return { ok: false, error: error.message };
31
+ }
32
+ }
@@ -75,6 +75,11 @@ exports.ROLL_AFTER_MS = 90 * 24 * 60 * 60 * 1000;
75
75
  const AGENT_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
76
76
  const WAIT_DEFAULT_S = 60;
77
77
  const WAIT_MAX_S = 300;
78
+ /** How long ago the person read a waiting letter, such as "2h", which tells an agent not to ask again; null when unread. */
79
+ function seenAgo(entry, now) {
80
+ const seen = entry.state === "waiting" ? entry.events.find((event) => event.t === "seen") : undefined;
81
+ return seen ? ageOf(seen.at, now) : null;
82
+ }
78
83
  function ageOf(createdAt, now) {
79
84
  const minutes = Math.max(0, Math.floor((now - Date.parse(createdAt)) / 60000));
80
85
  if (minutes < 60)
@@ -342,6 +347,51 @@ class LettersWriter {
342
347
  return { recorded: true, id: letter.id, code: letter.code, subject: letter.subject, option: answer.option, label, ...(answer.note ? { note: answer.note } : {}) };
343
348
  });
344
349
  }
350
+ /**
351
+ * Records that the person read a waiting letter, from the server's own copy of the message Ouro delivered it as:
352
+ * sent by this side, into the chat it was delivered to, with the server's read time. Once per letter.
353
+ */
354
+ recordSeen(agent, message) {
355
+ const letters = this.open(agent, false);
356
+ return this.serial(letters, async () => {
357
+ const found = this.waitingDelivery(letters, message.guid);
358
+ if (!found)
359
+ return { recorded: false, reason: "no-letter" };
360
+ const { entry, delivered } = found;
361
+ let problem = null;
362
+ if (message.isFromMe !== true)
363
+ problem = "not-from-me";
364
+ else if (message.chatGuids.length !== 1 || message.chatGuids[0] !== delivered.key)
365
+ problem = "wrong-chat";
366
+ else if (message.dateRead === undefined)
367
+ problem = "not-read";
368
+ else if (entry.events.some((event) => event.t === "seen"))
369
+ problem = "already-seen";
370
+ if (problem)
371
+ return { recorded: false, reason: problem };
372
+ this.addEvent(letters, entry.letter.id, { t: "seen", at: new Date(message.dateRead).toISOString(), via: "chat" });
373
+ (0, runtime_1.emitNervesEvent)({ component: "daemon", event: "letters.letter_seen", message: "the person read a letter", meta: { code: entry.letter.code } });
374
+ return { recorded: true, code: entry.letter.code };
375
+ });
376
+ }
377
+ /**
378
+ * Whether a waiting letter was delivered as this message, read from the index alone. The daemon asks it before it
379
+ * fetches anything from the server, since most read receipts are for ordinary chat messages.
380
+ */
381
+ hasWaitingDelivery(agent, messageGuid) {
382
+ return this.waitingDelivery(this.open(agent, false), messageGuid) !== null;
383
+ }
384
+ /** The waiting letter delivered as this message, with its delivered event; a send that wasn't confirmed has no GUID. */
385
+ waitingDelivery(letters, messageGuid) {
386
+ if (!messageGuid)
387
+ return null;
388
+ for (const entry of letters.index.list({})) {
389
+ const delivered = entry.events.find((event) => event.t === "delivered" && event.messageId === messageGuid);
390
+ if (delivered)
391
+ return { entry, delivered: delivered };
392
+ }
393
+ return null;
394
+ }
345
395
  /**
346
396
  * Returns an answered letter's answer to the session that asked, when that is due, and records the try as a
347
397
  * `returned` event. A failed try is retried by returnAnswers; the answer stands either way.
@@ -412,12 +462,16 @@ class LettersWriter {
412
462
  ...(typeof input.kind === "string" ? { kind: input.kind } : {}),
413
463
  ...(input.mine === true ? { from: letters.agent } : {}),
414
464
  });
415
- const listing = entries.map((entry) => `${entry.letter.code} ${entry.state} ${ageOf(entry.letter.createdAt, now)} ${entry.letter.subject}`).join("\n");
465
+ const listing = entries.map((entry) => {
466
+ const seen = seenAgo(entry, now);
467
+ return `${entry.letter.code} ${seen ? `waiting, seen ${seen} ago` : entry.state} ${ageOf(entry.letter.createdAt, now)} ${entry.letter.subject}`;
468
+ }).join("\n");
416
469
  return { outcome: "done", count: entries.length, listing };
417
470
  }
418
471
  read(letters, input) {
419
472
  const entry = this.find(letters, input);
420
- return { outcome: "done", state: entry.state, letter: JSON.stringify(entry.letter), events: entry.events.map((event) => eventLine(entry.letter, event)).join("\n") };
473
+ const seen = seenAgo(entry, this.now().getTime());
474
+ return { outcome: "done", state: entry.state, ...(seen ? { seen: `seen ${seen} ago, not answered` } : {}), letter: JSON.stringify(entry.letter), events: entry.events.map((event) => eventLine(entry.letter, event)).join("\n") };
421
475
  }
422
476
  /** Blocks until the letter leaves waiting, or has an event past the cursor, or the timeout ends. */
423
477
  async wait(letters, input) {
@@ -443,6 +443,7 @@ const defaultDeps = {
443
443
  recordProcessed: processed_log_1.recordProcessedBlueBubblesMessage,
444
444
  withSessionTurnLease: session_transaction_1.withSessionTurnLease,
445
445
  answerLetter: (agent, messageGuid) => (0, letter_answer_ingress_1.askDaemonToAnswerLetter)(agent, messageGuid),
446
+ letterSeen: (agent, messageGuid) => (0, letter_answer_ingress_1.tellDaemonLetterSeen)(agent, messageGuid),
446
447
  // Incoming events recheck every time, like sends, so a server that takes over
447
448
  // the same URL under another account is refused immediately.
448
449
  verifyHostAccount: (options) => (0, host_account_verifier_1.verifyBlueBubblesServerAccount)({
@@ -2953,6 +2954,14 @@ async function handleCapturedBlueBubblesSemanticEvent(captured, resolvedDeps, so
2953
2954
  if (captured.normalized.chat.isGroup) {
2954
2955
  recordDiscoveredOwnHandle(captured.normalized.sender.externalId);
2955
2956
  }
2957
+ // The person read a message this side sent in a one-to-one chat; if it delivered a letter, the daemon records
2958
+ // that they've seen it, from the server's copy. Nothing waits on it, and a failure only loses the "seen".
2959
+ if (captured.capture.event.kind === "read" && !captured.normalized.chat.isGroup) {
2960
+ const messageGuid = captured.normalized.messageGuid;
2961
+ resolvedDeps.letterSeen(agentName, messageGuid).catch((error) => {
2962
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.bluebubbles_letter_seen_unchecked", message: "couldn't tell the daemon a message was read", meta: { messageGuid, reason: error.message } });
2963
+ });
2964
+ }
2956
2965
  const result = {
2957
2966
  handled: true,
2958
2967
  notifiedAgent: false,
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tellDaemonLetterSeen = tellDaemonLetterSeen;
3
4
  exports.askDaemonToAnswerLetter = askDaemonToAnswerLetter;
4
5
  // 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
6
  // server's own copy, so nothing this process saw in the webhook decides the answer.
@@ -9,10 +10,21 @@ const runtime_1 = require("../../nerves/runtime");
9
10
  const ANSWER_TIMEOUT_MS = 30_000;
10
11
  /** The daemon records nothing after this much of the wait, so an answer is never recorded once the sense gives up on it. */
11
12
  const ANSWER_DEADLINE_MS = 27_000;
13
+ /** How long the sense waits for the daemon to check a read receipt; nothing waits on the answer. */
14
+ const SEEN_TIMEOUT_MS = 30_000;
12
15
  /**
13
16
  * Asks the daemon whether a message answers one of the agent's letters; true when it recorded an answer now or
14
17
  * before (a replay). Past the deadline the daemon records nothing, so a timed-out ask leaves the message a chat turn.
15
18
  */
19
+ /** Tells the daemon the server reported a message read; it records `seen` if that message delivered a letter. */
20
+ async function tellDaemonLetterSeen(agent, messageGuid, send = socket_client_1.sendDaemonCommand) {
21
+ const answer = await send(socket_client_1.DEFAULT_DAEMON_SOCKET_PATH, { kind: "letters.seen", agent, messageGuid }, { timeoutMs: SEEN_TIMEOUT_MS });
22
+ if (!answer.ok)
23
+ throw new Error(answer.error ?? "the daemon refused the letters.seen command");
24
+ const recorded = answer.data?.recorded === true;
25
+ (0, runtime_1.emitNervesEvent)({ level: "debug", component: "senses", event: "senses.bluebubbles_letter_seen_checked", message: "told the daemon a message was read", meta: { messageGuid, recorded } });
26
+ return recorded;
27
+ }
16
28
  async function askDaemonToAnswerLetter(agent, messageGuid, send = socket_client_1.sendDaemonCommand, now = Date.now) {
17
29
  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
30
  if (!answer.ok)
@@ -21,6 +21,7 @@ function serverMessageFromPayload(payload) {
21
21
  const dateCreated = time(data.dateCreated);
22
22
  const dateEdited = time(data.dateEdited);
23
23
  const dateRetracted = time(data.dateRetracted);
24
+ const dateRead = time(data.dateRead);
24
25
  const threadOriginatorGuid = text(data.threadOriginatorGuid);
25
26
  return {
26
27
  guid,
@@ -33,6 +34,7 @@ function serverMessageFromPayload(payload) {
33
34
  ...(dateCreated ? { dateCreated } : {}),
34
35
  ...(dateEdited ? { dateEdited } : {}),
35
36
  ...(dateRetracted ? { dateRetracted } : {}),
37
+ ...(dateRead ? { dateRead } : {}),
36
38
  ...(threadOriginatorGuid ? { threadOriginatorGuid } : {}),
37
39
  };
38
40
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1648",
3
+ "version": "0.1.0-alpha.1649",
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.1648",
9
+ "version": "0.1.0-alpha.1649",
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.1648",
3
+ "version": "0.1.0-alpha.1649",
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": {