@ouro.bot/cli 0.1.0-alpha.1662 → 0.1.0-alpha.1663
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 +9 -3
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/letters/answer-reader.js +47 -0
- package/dist/heart/letters/seen-command.js +10 -4
- package/dist/heart/letters/writer.js +32 -1
- package/dist/senses/bluebubbles/index.js +8 -0
- package/dist/senses/bluebubbles/letter-answer-ingress.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -2,10 +2,16 @@
|
|
|
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.
|
|
5
|
+
"version": "0.1.0-alpha.1663",
|
|
6
6
|
"changes": [
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"Update the Ouro UI files to Ouro UI v1.3.599.",
|
|
8
|
+
"A letter now counts as seen when the person writes to the agent in the same one-to-one iMessage chat after the letter arrived there, even if their read receipts are off. Before, a letter was marked seen only from a read receipt, so for someone who doesn't send read receipts it stayed unseen even after they had replied."
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"version": "0.1.0-alpha.1661",
|
|
13
|
+
"changes": [
|
|
14
|
+
"The Butler's image may name a product module in `/opt/ouro/container-runtime.json`. The harness checks and loads it, and then asks it what that product adds. No image names one yet, so behaviour is unchanged. In the image the policy file is now owned by root and read-only, so the agent can't change which code it loads."
|
|
9
15
|
]
|
|
10
16
|
},
|
|
11
17
|
{
|
|
@@ -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.1663</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -39,6 +39,8 @@ exports.readAnsweredGuids = readAnsweredGuids;
|
|
|
39
39
|
exports.addAnsweredGuid = addAnsweredGuid;
|
|
40
40
|
exports.deliveryFloor = deliveryFloor;
|
|
41
41
|
exports.answerProblem = answerProblem;
|
|
42
|
+
exports.seenFloor = seenFloor;
|
|
43
|
+
exports.replySeenProblem = replySeenProblem;
|
|
42
44
|
exports.noteAnswerRefused = noteAnswerRefused;
|
|
43
45
|
// How a person's own iMessage answers a letter (design §3.4, "How an answer is recorded"). Only the daemon records
|
|
44
46
|
// an answer, from the BlueBubbles server's own copy of the message: the chat ingress hands it a message GUID and
|
|
@@ -163,6 +165,51 @@ function answerProblem(entry, message, answer, answered, floor) {
|
|
|
163
165
|
return "no-such-option";
|
|
164
166
|
return null;
|
|
165
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* The time a message must come after to show the person has seen a letter: the server's own send time for it, or
|
|
170
|
+
* else the daemon's delivered time with no slack, since a plain message carries no code to tie it to the letter.
|
|
171
|
+
* Null when the letter isn't delivered.
|
|
172
|
+
*/
|
|
173
|
+
async function seenFloor(entry, sentAt) {
|
|
174
|
+
const delivered = entry.events.find((event) => event.t === "delivered");
|
|
175
|
+
if (!delivered)
|
|
176
|
+
return null;
|
|
177
|
+
if (delivered.messageId && sentAt) {
|
|
178
|
+
const serverTime = await sentAt(delivered.messageId).catch(() => undefined);
|
|
179
|
+
if (serverTime !== undefined)
|
|
180
|
+
return serverTime;
|
|
181
|
+
}
|
|
182
|
+
return Date.parse(delivered.at);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Why a message the person sent doesn't show they have seen this letter, or null when it does: an iMessage from the
|
|
186
|
+
* letter's answering handle, in their one-to-one chat, sent after the letter landed there. Their read receipts may be
|
|
187
|
+
* off, but a person who writes in the chat after the letter arrived has had it on screen. `floor` is seenFloor.
|
|
188
|
+
*/
|
|
189
|
+
function replySeenProblem(entry, message, floor) {
|
|
190
|
+
const letter = entry.letter;
|
|
191
|
+
const sentAfterExpiry = letter.expiresAt !== undefined && (message.dateCreated ?? Number.POSITIVE_INFINITY) >= Date.parse(letter.expiresAt);
|
|
192
|
+
if (entry.state !== "waiting" || sentAfterExpiry)
|
|
193
|
+
return "not-waiting";
|
|
194
|
+
if (entry.events.some((event) => event.t === "seen"))
|
|
195
|
+
return "already-seen";
|
|
196
|
+
if (!letter.answeringHandle)
|
|
197
|
+
return "no-answering-handle";
|
|
198
|
+
if (message.isFromMe !== false)
|
|
199
|
+
return "from-me";
|
|
200
|
+
if (message.service !== "iMessage")
|
|
201
|
+
return "not-imessage";
|
|
202
|
+
const sender = message.sender ? (0, answering_1.normalizeAnsweringHandle)(message.sender) : null;
|
|
203
|
+
if (!sender?.ok || sender.handle !== letter.answeringHandle)
|
|
204
|
+
return "wrong-sender";
|
|
205
|
+
if (message.chatGuids.length !== 1 || directChatHandle(message.chatGuids[0]) !== letter.answeringHandle)
|
|
206
|
+
return "wrong-chat";
|
|
207
|
+
if (floor === null)
|
|
208
|
+
return "not-delivered";
|
|
209
|
+
if (message.dateCreated === undefined || message.dateCreated <= floor)
|
|
210
|
+
return "before-delivery";
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
166
213
|
/** Logs a message that looked like an answer and wasn't one, by its reason alone. */
|
|
167
214
|
function noteAnswerRefused(reason) {
|
|
168
215
|
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "daemon", event: "letters.answer_refused", message: "a message in answer form didn't answer its letter", meta: { reason } });
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.answerLettersSeenCommand = answerLettersSeenCommand;
|
|
4
|
-
// The daemon's `letters.seen` command: the BlueBubbles ingress names a message whose read receipt it saw,
|
|
5
|
-
// daemon reads that message from the agent's own server
|
|
4
|
+
// The daemon's `letters.seen` command: the BlueBubbles ingress names a message whose read receipt it saw, or a message
|
|
5
|
+
// the person sent in a one-to-one chat, and the daemon reads that message from the agent's own server. A read receipt
|
|
6
|
+
// marks seen the letter that message delivered; the person's own message marks seen each letter that landed in their
|
|
7
|
+
// chat before they wrote, since their read receipts may be off.
|
|
6
8
|
// Like `letters.answer`, the command carries only a GUID, so whoever sends it can only point at a real message.
|
|
7
9
|
const runtime_1 = require("../../nerves/runtime");
|
|
8
10
|
async function answerLettersSeenCommand(writer, command, sourceFor) {
|
|
@@ -13,8 +15,8 @@ async function answerLettersSeenCommand(writer, command, sourceFor) {
|
|
|
13
15
|
return { ok: false, error: `No agent bundle ${command.agent}.ouro is on this machine.` };
|
|
14
16
|
try {
|
|
15
17
|
const guid = command.messageGuid.trim();
|
|
16
|
-
// Most read receipts are
|
|
17
|
-
if (!writer.hasWaitingDelivery(command.agent, guid))
|
|
18
|
+
// Most read receipts and messages are ordinary chat, so the index is asked before the server is.
|
|
19
|
+
if (!writer.hasWaitingDelivery(command.agent, guid) && !writer.hasUnseenDelivery(command.agent))
|
|
18
20
|
return { ok: true, data: { recorded: false, reason: "no-letter" } };
|
|
19
21
|
const source = await sourceFor(command.agent);
|
|
20
22
|
// The server password travels in the fetch's query string, so only a server nobody between can read is asked.
|
|
@@ -23,6 +25,10 @@ async function answerLettersSeenCommand(writer, command, sourceFor) {
|
|
|
23
25
|
const message = await source.getServerMessage(guid);
|
|
24
26
|
if (!message || message.guid !== guid)
|
|
25
27
|
return { ok: true, data: { recorded: false, reason: "unknown-message" } };
|
|
28
|
+
if (message.isFromMe === false) {
|
|
29
|
+
const sentAt = async (sentGuid) => (await source.getServerMessage(sentGuid))?.dateCreated;
|
|
30
|
+
return { ok: true, data: await writer.recordSeenByReply(command.agent, message, sentAt) };
|
|
31
|
+
}
|
|
26
32
|
return { ok: true, data: await writer.recordSeen(command.agent, message) };
|
|
27
33
|
}
|
|
28
34
|
catch (error) {
|
|
@@ -371,9 +371,40 @@ class LettersWriter {
|
|
|
371
371
|
return { recorded: false, reason: problem };
|
|
372
372
|
this.addEvent(letters, entry.letter.id, { t: "seen", at: new Date(message.dateRead).toISOString(), via: "chat" });
|
|
373
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,
|
|
374
|
+
return { recorded: true, codes: [entry.letter.code] };
|
|
375
375
|
});
|
|
376
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* Records seen, at the message's send time, each waiting letter the person wrote after in the chat it landed in,
|
|
379
|
+
* from the server's own copy of their message. It is the seen for a person whose read receipts are off. `sentAt`
|
|
380
|
+
* reads the server's time for a letter's sent message, as for an answer.
|
|
381
|
+
*/
|
|
382
|
+
async recordSeenByReply(agent, message, sentAt) {
|
|
383
|
+
const letters = this.open(agent, false);
|
|
384
|
+
// Every check but the floor runs first, from the index alone, and the floors are fetched outside the queue, so a
|
|
385
|
+
// slow server never holds up an answer to the same message that is waiting behind this.
|
|
386
|
+
const candidates = letters.index.list({}).filter((entry) => (0, answer_reader_1.replySeenProblem)(entry, message, Number.NEGATIVE_INFINITY) === null);
|
|
387
|
+
const floors = new Map();
|
|
388
|
+
for (const entry of candidates)
|
|
389
|
+
floors.set(entry.letter.id, await (0, answer_reader_1.seenFloor)(entry, sentAt));
|
|
390
|
+
return this.serial(letters, async () => {
|
|
391
|
+
const codes = [];
|
|
392
|
+
for (const candidate of candidates) {
|
|
393
|
+
// Read again inside the queue, since the letter may have been answered or seen meanwhile.
|
|
394
|
+
const entry = letters.index.get(candidate.letter.id);
|
|
395
|
+
if ((0, answer_reader_1.replySeenProblem)(entry, message, floors.get(entry.letter.id)) !== null)
|
|
396
|
+
continue;
|
|
397
|
+
this.addEvent(letters, entry.letter.id, { t: "seen", at: new Date(message.dateCreated).toISOString(), via: "chat" });
|
|
398
|
+
(0, runtime_1.emitNervesEvent)({ component: "daemon", event: "letters.letter_seen_by_reply", message: "the person wrote in the chat after a letter landed there", meta: { code: entry.letter.code } });
|
|
399
|
+
codes.push(entry.letter.code);
|
|
400
|
+
}
|
|
401
|
+
return codes.length > 0 ? { recorded: true, codes } : { recorded: false, reason: "no-letter" };
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
/** Whether any waiting letter is delivered and not yet seen, read from the index alone, so most chat needs no fetch. */
|
|
405
|
+
hasUnseenDelivery(agent) {
|
|
406
|
+
return this.open(agent, false).index.list({}).some((entry) => entry.events.some((event) => event.t === "delivered") && !entry.events.some((event) => event.t === "seen"));
|
|
407
|
+
}
|
|
377
408
|
/**
|
|
378
409
|
* Whether a waiting letter was delivered as this message, read from the index alone. The daemon asks it before it
|
|
379
410
|
* fetches anything from the server, since most read receipts are for ordinary chat messages.
|
|
@@ -1824,6 +1824,14 @@ async function handleBlueBubblesNormalizedEvent(event, resolvedDeps, source, opt
|
|
|
1824
1824
|
return { handled: true, notifiedAgent: false, kind: event.kind, reason: "from_me" };
|
|
1825
1825
|
}
|
|
1826
1826
|
options.lifecycleSignal?.throwIfAborted();
|
|
1827
|
+
// Any message the person sends in a one-to-one chat shows they have had the letters that landed there on screen,
|
|
1828
|
+
// even with their read receipts off; the daemon checks it against the server's copy. Nothing waits on it.
|
|
1829
|
+
if (event.eventType === "new-message" && !event.chat.isGroup && event.fromMe !== true) {
|
|
1830
|
+
const messageGuid = event.messageGuid;
|
|
1831
|
+
resolvedDeps.letterSeen(agentName, messageGuid).catch((error) => {
|
|
1832
|
+
(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 } });
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1827
1835
|
// A message in answer form ("L7 2") from a one-to-one chat may answer a letter. The daemon decides from the
|
|
1828
1836
|
// server's copy; a recorded answer is the harness's, so it doesn't become a chat turn, and the daemon tells
|
|
1829
1837
|
// the agent. Anything else, or a daemon that can't be asked, runs the turn as usual.
|
|
@@ -16,7 +16,7 @@ const SEEN_TIMEOUT_MS = 30_000;
|
|
|
16
16
|
* Asks the daemon whether a message answers one of the agent's letters; true when it recorded an answer now or
|
|
17
17
|
* before (a replay). Past the deadline the daemon records nothing, so a timed-out ask leaves the message a chat turn.
|
|
18
18
|
*/
|
|
19
|
-
/** Tells the daemon the server reported a message read; it records `seen`
|
|
19
|
+
/** Tells the daemon the server reported a message read, or that the person sent one; it records `seen` for the letters that shows they have read. */
|
|
20
20
|
async function tellDaemonLetterSeen(agent, messageGuid, send = socket_client_1.sendDaemonCommand) {
|
|
21
21
|
const answer = await send(socket_client_1.DEFAULT_DAEMON_SOCKET_PATH, { kind: "letters.seen", agent, messageGuid }, { timeoutMs: SEEN_TIMEOUT_MS });
|
|
22
22
|
if (!answer.ok)
|
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.1663",
|
|
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.1663",
|
|
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.1663",
|
|
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": {
|