@ouro.bot/cli 0.1.0-alpha.1397 → 0.1.0-alpha.1399
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/senses/bluebubbles/client.js +8 -1
- package/dist/senses/bluebubbles/host-account-verifier.js +30 -5
- package/dist/senses/bluebubbles/index.js +44 -3
- 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.1399",
|
|
6
|
+
"changes": [
|
|
7
|
+
"A BlueBubbles webhook is no longer refused with 403 when the server is too busy to answer server info and the host account was confirmed in the last 10 minutes, and a proactive send that timed out is saved as sent once it shows up in the chat."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1398",
|
|
12
|
+
"changes": [
|
|
13
|
+
"iMessage sends go through BlueBubbles' Private API helper whenever the server reports it connected, instead of AppleScript into Messages, which macOS can refuse (-1743) and which held Slugger's sends for minutes on 2026-11-23. Each send start says which method it used."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1397",
|
|
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.1399</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -290,7 +290,7 @@ function createBlueBubblesClient(config = (0, config_1.getBlueBubblesConfig)(),
|
|
|
290
290
|
if (!trimmedText) {
|
|
291
291
|
throw new Error("BlueBubbles send requires non-empty text.");
|
|
292
292
|
}
|
|
293
|
-
await assertHostAccount({ fresh: true });
|
|
293
|
+
const server = await assertHostAccount({ fresh: true });
|
|
294
294
|
const resolvedChatGuid = await resolveChatGuid(params.chat, config, channelConfig);
|
|
295
295
|
if (!resolvedChatGuid) {
|
|
296
296
|
// Nothing reached the server, so a caller may safely send again once the chat exists.
|
|
@@ -305,6 +305,12 @@ function createBlueBubblesClient(config = (0, config_1.getBlueBubblesConfig)(),
|
|
|
305
305
|
tempGuid: params.tempGuid?.trim() || (0, node_crypto_1.randomUUID)(),
|
|
306
306
|
message: trimmedText,
|
|
307
307
|
};
|
|
308
|
+
// Left to itself, BlueBubbles sends through AppleScript into Messages, which macOS can refuse ("Not authorized to
|
|
309
|
+
// send Apple events to Messages", -1743) until Messages restarts, holding the send for minutes. The Private API
|
|
310
|
+
// helper sends from inside Messages without Apple events, so every send uses it while the server reports it
|
|
311
|
+
// connected (the fresh server info above).
|
|
312
|
+
if (server?.privateApiReady === true)
|
|
313
|
+
body.method = "private-api";
|
|
308
314
|
if (params.replyToMessageGuid?.trim()) {
|
|
309
315
|
body.method = "private-api";
|
|
310
316
|
body.selectedMessageGuid = params.replyToMessageGuid.trim();
|
|
@@ -317,6 +323,7 @@ function createBlueBubblesClient(config = (0, config_1.getBlueBubblesConfig)(),
|
|
|
317
323
|
meta: {
|
|
318
324
|
chatGuid: resolvedChatGuid,
|
|
319
325
|
hasReplyTarget: Boolean(params.replyToMessageGuid?.trim()),
|
|
326
|
+
method: body.method === "private-api" ? "private-api" : "server-default",
|
|
320
327
|
},
|
|
321
328
|
});
|
|
322
329
|
const requestTimeoutSignal = AbortSignal.timeout(channelConfig.requestTimeoutMs);
|
|
@@ -22,9 +22,12 @@ class BlueBubblesHostAccountError extends Error {
|
|
|
22
22
|
exports.BlueBubblesHostAccountError = BlueBubblesHostAccountError;
|
|
23
23
|
const VERIFIED_TTL_MS = 60_000;
|
|
24
24
|
const verifiedAt = new Map();
|
|
25
|
+
/** The last time each server confirmed the account; only a mismatch forgets it. */
|
|
26
|
+
const confirmedAt = new Map();
|
|
25
27
|
/** Test seam: forget cached verifications. */
|
|
26
28
|
function resetBlueBubblesServerAccountCache() {
|
|
27
29
|
verifiedAt.clear();
|
|
30
|
+
confirmedAt.clear();
|
|
28
31
|
}
|
|
29
32
|
function refuse(message, meta) {
|
|
30
33
|
(0, runtime_1.emitNervesEvent)({
|
|
@@ -42,7 +45,7 @@ function serverInfoUrl(serverUrl, password) {
|
|
|
42
45
|
url.searchParams.set("password", password);
|
|
43
46
|
return url.toString();
|
|
44
47
|
}
|
|
45
|
-
async function
|
|
48
|
+
async function readServerInfo(input) {
|
|
46
49
|
try {
|
|
47
50
|
const response = await (input.fetchImpl ?? fetch)(serverInfoUrl(input.serverUrl, input.password), {
|
|
48
51
|
method: "GET",
|
|
@@ -56,12 +59,18 @@ async function readServerUsername(input) {
|
|
|
56
59
|
return null;
|
|
57
60
|
const at = computerId.indexOf("@");
|
|
58
61
|
const username = at > 0 ? computerId.slice(0, at) : "";
|
|
59
|
-
|
|
62
|
+
if (!username)
|
|
63
|
+
return null;
|
|
64
|
+
return { username, facts: { privateApiReady: body.data?.private_api === true && body.data?.helper_connected === true } };
|
|
60
65
|
}
|
|
61
66
|
catch {
|
|
62
67
|
return null;
|
|
63
68
|
}
|
|
64
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Confirms the server runs under the agent's host account, and returns what that server info call said about its
|
|
72
|
+
* Private API helper. A recent confirmation reused without a call returns nothing.
|
|
73
|
+
*/
|
|
65
74
|
async function verifyBlueBubblesServerAccount(input) {
|
|
66
75
|
const { agent, hostUsername, serverUrl } = input;
|
|
67
76
|
if (hostUsername === undefined) {
|
|
@@ -72,17 +81,33 @@ async function verifyBlueBubblesServerAccount(input) {
|
|
|
72
81
|
const key = `${serverUrl}\u0000${hostUsername}`;
|
|
73
82
|
const cached = verifiedAt.get(key);
|
|
74
83
|
if (!input.fresh && cached !== undefined && now - cached < VERIFIED_TTL_MS)
|
|
75
|
-
return;
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
84
|
+
return undefined;
|
|
85
|
+
const info = await readServerInfo(input);
|
|
86
|
+
if (info === null) {
|
|
78
87
|
verifiedAt.delete(key);
|
|
88
|
+
const confirmed = confirmedAt.get(key);
|
|
89
|
+
const grace = input.recentConfirmationGraceMs;
|
|
90
|
+
if (grace !== undefined && confirmed !== undefined && now - confirmed < grace) {
|
|
91
|
+
(0, runtime_1.emitNervesEvent)({
|
|
92
|
+
level: "warn",
|
|
93
|
+
component: "senses",
|
|
94
|
+
event: "senses.bluebubbles_host_account_recent_confirmation_used",
|
|
95
|
+
message: "BlueBubbles server info did not answer, so a recent confirmation of the host account was used",
|
|
96
|
+
meta: { agent, hostUsername, confirmedMsAgo: now - confirmed },
|
|
97
|
+
});
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
79
100
|
refuse(`BlueBubbles refused for agent "${agent}": could not confirm which macOS account the BlueBubbles server at ${serverUrl} runs under. Not acting.`, { agent, reason: "unconfirmed", hostUsername });
|
|
80
101
|
}
|
|
102
|
+
const serverUsername = info.username;
|
|
81
103
|
if (serverUsername !== hostUsername) {
|
|
82
104
|
verifiedAt.delete(key);
|
|
105
|
+
confirmedAt.delete(key);
|
|
83
106
|
refuse(`BlueBubbles refused for agent "${agent}": the BlueBubbles server at ${serverUrl} runs under macOS account "${serverUsername}", `
|
|
84
107
|
+ `but the agent's iMessage host is "${hostUsername}". Not acting, so the agent neither speaks nor listens as "${serverUsername}"'s Apple ID. `
|
|
85
108
|
+ `Fix: run BlueBubbles under "${hostUsername}" and point bluebubbles.serverUrl at it. Changing senses.bluebubbles.hostUsername is a human decision, because it chooses whose Apple ID the agent speaks as.`, { agent, reason: "mismatch", hostUsername, serverUsername });
|
|
86
109
|
}
|
|
87
110
|
verifiedAt.set(key, now);
|
|
111
|
+
confirmedAt.set(key, now);
|
|
112
|
+
return info.facts;
|
|
88
113
|
}
|
|
@@ -419,16 +419,22 @@ const defaultDeps = {
|
|
|
419
419
|
withSessionTurnLease: session_transaction_1.withSessionTurnLease,
|
|
420
420
|
// Incoming events recheck every time, like sends, so a server that takes over
|
|
421
421
|
// the same URL under another account is refused immediately.
|
|
422
|
-
verifyHostAccount: () => (0, host_account_verifier_1.verifyBlueBubblesServerAccount)({
|
|
422
|
+
verifyHostAccount: (options) => (0, host_account_verifier_1.verifyBlueBubblesServerAccount)({
|
|
423
423
|
agent: (0, identity_1.getAgentName)(),
|
|
424
424
|
hostUsername: (0, identity_1.loadAgentConfig)().senses?.bluebubbles.hostUsername,
|
|
425
425
|
serverUrl: (0, config_1.getBlueBubblesConfig)().serverUrl,
|
|
426
426
|
password: (0, config_1.getBlueBubblesConfig)().password,
|
|
427
427
|
requestTimeoutMs: (0, config_1.getBlueBubblesChannelConfig)().requestTimeoutMs,
|
|
428
428
|
fresh: true,
|
|
429
|
-
|
|
429
|
+
...options,
|
|
430
|
+
}).then(() => undefined),
|
|
431
|
+
/* v8 ignore next -- a real timer; tests pass their own waitMs @preserve */
|
|
432
|
+
waitMs: (ms) => new Promise((resolve) => { setTimeout(resolve, ms).unref(); }),
|
|
430
433
|
};
|
|
431
434
|
const BLUEBUBBLES_RUNTIME_SYNC_INTERVAL_MS = 30_000;
|
|
435
|
+
const BLUEBUBBLES_WEBHOOK_HOST_CONFIRMATION_GRACE_MS = 10 * 60_000;
|
|
436
|
+
const BLUEBUBBLES_PROACTIVE_ARRIVAL_CHECK_MS = 30_000;
|
|
437
|
+
const BLUEBUBBLES_PROACTIVE_ARRIVAL_CHECKS = 10;
|
|
432
438
|
/** After a failed sync, the next one comes sooner than the interval: 5 s, then 10 s, then 20 s. */
|
|
433
439
|
const BLUEBUBBLES_RUNTIME_SYNC_RETRY_BASE_MS = 5_000;
|
|
434
440
|
/**
|
|
@@ -3663,7 +3669,9 @@ function createBlueBubblesWebhookHandler(deps = {}, options = {}) {
|
|
|
3663
3669
|
// Only take in messages from the agent's own Apple ID: a server running
|
|
3664
3670
|
// under another macOS account would hand the agent that person's iMessages.
|
|
3665
3671
|
try {
|
|
3666
|
-
|
|
3672
|
+
// BlueBubbles doesn't send a webhook again, so a server too busy to answer server info right now (as while
|
|
3673
|
+
// Messages restarts) gets the benefit of a recent confirmation; a mismatch still refuses.
|
|
3674
|
+
await { ...defaultDeps, ...deps }.verifyHostAccount({ recentConfirmationGraceMs: BLUEBUBBLES_WEBHOOK_HOST_CONFIRMATION_GRACE_MS });
|
|
3667
3675
|
}
|
|
3668
3676
|
catch (error) {
|
|
3669
3677
|
writeJson(res, 403, { handled: false, notifiedAgent: false, error: error instanceof Error ? error.message : String(error) });
|
|
@@ -3883,6 +3891,36 @@ function recordBlueBubblesProactiveSend(friend, params, chat, sentChatGuid) {
|
|
|
3883
3891
|
meta: { friendId: friend.id, error: error instanceof Error ? error.message : String(error) } });
|
|
3884
3892
|
}
|
|
3885
3893
|
}
|
|
3894
|
+
function sameMessageText(a, b) {
|
|
3895
|
+
const normalize = (value) => value.trim().replace(/\s+/g, " ");
|
|
3896
|
+
return normalize(a) === normalize(b);
|
|
3897
|
+
}
|
|
3898
|
+
/**
|
|
3899
|
+
* A proactive send that timed out may still go out: BlueBubbles retries after restarting Messages. Look in the chat
|
|
3900
|
+
* every 30 seconds for 5 minutes, and once the message is there save it into its chat as sent, so the agent knows it
|
|
3901
|
+
* went out and doesn't send it again.
|
|
3902
|
+
*/
|
|
3903
|
+
async function watchForTimedOutProactiveSend(deps, client, friend, params, chat, sentAt) {
|
|
3904
|
+
const chatGuid = chat.chatGuid;
|
|
3905
|
+
if (!chatGuid || !client.listRecentMessages)
|
|
3906
|
+
return;
|
|
3907
|
+
for (let checks = 1; checks <= BLUEBUBBLES_PROACTIVE_ARRIVAL_CHECKS; checks++) {
|
|
3908
|
+
await deps.waitMs(BLUEBUBBLES_PROACTIVE_ARRIVAL_CHECK_MS);
|
|
3909
|
+
const recent = await client.listRecentMessages({ chatGuid, limit: 25 }).catch(() => []);
|
|
3910
|
+
const arrived = recent.find((message) => message.kind === "message" && message.fromMe && message.timestamp >= sentAt
|
|
3911
|
+
&& sameMessageText(message.text, params.text));
|
|
3912
|
+
if (arrived) {
|
|
3913
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.bluebubbles_proactive_send_arrived",
|
|
3914
|
+
message: "a proactive bluebubbles send that timed out showed up in the chat, so it was saved as sent",
|
|
3915
|
+
meta: { friendId: friend.id, sessionKey: params.sessionKey, messageGuid: arrived.messageGuid, checks } });
|
|
3916
|
+
recordBlueBubblesProactiveSend(friend, params, chat, chatGuid);
|
|
3917
|
+
return;
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
(0, runtime_1.emitNervesEvent)({ level: "warn", component: "senses", event: "senses.bluebubbles_proactive_send_not_seen",
|
|
3921
|
+
message: "a proactive bluebubbles send that timed out never showed up in the chat",
|
|
3922
|
+
meta: { friendId: friend.id, sessionKey: params.sessionKey, checks: BLUEBUBBLES_PROACTIVE_ARRIVAL_CHECKS } });
|
|
3923
|
+
}
|
|
3886
3924
|
async function sendProactiveBlueBubblesMessageToSession(params, deps = {}) {
|
|
3887
3925
|
if ((0, bluebubbles_meta_guard_1.containsInternalMetaMarkers)(params.text)) {
|
|
3888
3926
|
(0, bluebubbles_meta_guard_1.emitBluebubblesMetaBlocked)({
|
|
@@ -4001,6 +4039,7 @@ async function sendProactiveBlueBubblesMessageToSession(params, deps = {}) {
|
|
|
4001
4039
|
});
|
|
4002
4040
|
return { delivered: false, reason: "internal_content_blocked" };
|
|
4003
4041
|
}
|
|
4042
|
+
const sentAt = Date.now();
|
|
4004
4043
|
try {
|
|
4005
4044
|
const sent = await client.sendText({ chat, text: params.text });
|
|
4006
4045
|
(0, runtime_1.emitNervesEvent)({
|
|
@@ -4051,6 +4090,8 @@ async function sendProactiveBlueBubblesMessageToSession(params, deps = {}) {
|
|
|
4051
4090
|
});
|
|
4052
4091
|
const refused = error instanceof client_1.BlueBubblesSendError && error.httpStatus !== null && error.httpStatus >= 400 && error.httpStatus < 500 && error.httpStatus !== 408 && error.httpStatus !== 409;
|
|
4053
4092
|
const mayHaveGoneOut = error instanceof client_1.BlueBubblesSendError && error.transportInvoked && !refused;
|
|
4093
|
+
if (mayHaveGoneOut)
|
|
4094
|
+
void watchForTimedOutProactiveSend(resolvedDeps, client, friend, params, chat, sentAt);
|
|
4054
4095
|
return { delivered: false, reason: "send_error", ...(mayHaveGoneOut ? { delivery: { state: "unknown" } } : {}) };
|
|
4055
4096
|
}
|
|
4056
4097
|
}
|
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.1399",
|
|
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.1399",
|
|
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.1399",
|
|
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": {
|