@ouro.bot/cli 0.1.0-alpha.1398 → 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 CHANGED
@@ -1,6 +1,12 @@
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
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1398",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1398",
2
+ "runtimeVersion": "0.1.0-alpha.1399",
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.1398</Repository>
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>
@@ -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)({
@@ -82,15 +85,29 @@ async function verifyBlueBubblesServerAccount(input) {
82
85
  const info = await readServerInfo(input);
83
86
  if (info === null) {
84
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
+ }
85
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 });
86
101
  }
87
102
  const serverUsername = info.username;
88
103
  if (serverUsername !== hostUsername) {
89
104
  verifiedAt.delete(key);
105
+ confirmedAt.delete(key);
90
106
  refuse(`BlueBubbles refused for agent "${agent}": the BlueBubbles server at ${serverUrl} runs under macOS account "${serverUsername}", `
91
107
  + `but the agent's iMessage host is "${hostUsername}". Not acting, so the agent neither speaks nor listens as "${serverUsername}"'s Apple ID. `
92
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 });
93
109
  }
94
110
  verifiedAt.set(key, now);
111
+ confirmedAt.set(key, now);
95
112
  return info.facts;
96
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
+ ...options,
429
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
- await { ...defaultDeps, ...deps }.verifyHostAccount();
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
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1398",
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.1398",
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.1398",
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": {