@ouro.bot/cli 0.1.0-alpha.1644 → 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 +4 -2
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/daemon/daemon.js +2 -0
- package/dist/heart/letters/answered-note.js +105 -0
- package/dist/heart/letters/render.js +6 -1
- package/dist/heart/letters/writer.js +1 -0
- package/dist/heart/private-runtime/policy.js +8 -0
- package/dist/senses/bluebubbles/index.js +17 -0
- package/dist/senses/bluebubbles/letter-answer-ingress.js +23 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
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.1645",
|
|
6
6
|
"changes": [
|
|
7
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."
|
|
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."
|
|
9
11
|
]
|
|
10
12
|
},
|
|
11
13
|
{
|
|
@@ -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.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
|
}
|
|
@@ -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 = [
|
|
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
|
+
}
|
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.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.
|
|
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.
|
|
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": {
|