openclaw/src/infra
Tyler Yust 0f662c2935
fix(bluebubbles): route phone-number targets to direct chats; prevent internal IDs leaking in cross-context prefix (#1751)
* fix(bluebubbles): prefer DM resolution + hide routing markers

* fix(bluebubbles): prevent message routing to group chats when targeting phone numbers

When sending a message to a phone number like +12622102921, the
resolveChatGuidForTarget function was finding and returning a GROUP
CHAT containing that phone number instead of a direct DM chat.

The bug was in the participantMatch fallback logic which matched ANY
chat containing the phone number as a participant, including groups.

This fix adds a check to ensure participantMatch only considers DM
chats (identified by ';-;' separator in the chat GUID). Group chats
(identified by ';+;' separator) are now explicitly excluded from
handle-based matching.

If a phone number only exists in a group chat (no direct DM exists),
the function now correctly returns null, which causes the send to
fail with a clear error rather than accidentally messaging a group.

Added test case to verify this behavior.

* feat(bluebubbles): auto-create new DM chats when sending to unknown phone numbers

When sending to a phone number that doesn't have an existing chat,
instead of failing with 'chatGuid not found', now automatically creates
a new chat using the /api/v1/chat/new endpoint.

- Added createNewChatWithMessage() helper function
- When resolveChatGuidForTarget returns null for a handle target,
  uses the new chat endpoint with addresses array and message
- Includes helpful error message if Private API isn't enabled
- Only applies to handle targets (phone numbers), not group chats

* fix(bluebubbles): hide internal routing metadata in cross-context markers

When sending cross-context messages via BlueBubbles, the origin marker was
exposing internal chat_guid routing info like '[from bluebubbles:chat_guid:any;-;+19257864429]'.

This adds a formatTargetDisplay() function to the BlueBubbles plugin that:
- Extracts phone numbers from chat_guid formats (iMessage;-;+1234567890 -> +1234567890)
- Normalizes handles for clean display
- Avoids returning raw chat_guid formats containing internal routing metadata

Now cross-context markers show clean identifiers like '[from +19257864429]' instead
of exposing internal routing details to recipients.

* fix: prevent cross-context decoration on direct message tool sends

Two fixes:

1. Cross-context decoration (e.g., '[from +19257864429]' prefix) was being
   added to ALL messages sent to a different target, even when the agent
   was just composing a new message via the message tool. This decoration
   should only be applied when forwarding/relaying messages between chats.

   Fix: Added skipCrossContextDecoration flag to ChannelThreadingToolContext.
   The message tool now sets this flag to true, so direct sends don't get
   decorated. The buildCrossContextDecoration function checks this flag
   and returns null when set.

2. Aborted requests were still completing because the abort signal wasn't
   being passed through the message tool execution chain.

   Fix: Added abortSignal propagation from message tool → runMessageAction →
   executeSendAction → sendMessage → deliverOutboundPayloads. Added abort
   checks at key points in the chain to fail fast when aborted.

Files changed:
- src/channels/plugins/types.core.ts: Added skipCrossContextDecoration field
- src/infra/outbound/outbound-policy.ts: Check skip flag before decorating
- src/agents/tools/message-tool.ts: Set skip flag, accept and pass abort signal
- src/infra/outbound/message-action-runner.ts: Pass abort signal through
- src/infra/outbound/outbound-send-service.ts: Check and pass abort signal
- src/infra/outbound/message.ts: Pass abort signal to delivery

* fix(bluebubbles): preserve friendly display names in formatTargetDisplay
2026-01-25 10:03:08 +00:00
..
net fix: harden web fetch SSRF and redirects 2026-01-21 02:54:14 +00:00
outbound fix(bluebubbles): route phone-number targets to direct chats; prevent internal IDs leaking in cross-context prefix (#1751) 2026-01-25 10:03:08 +00:00
tls fix: tighten tls fingerprints and approval events 2026-01-20 13:04:20 +00:00
agent-events.test.ts fix: preserve gateway presence instanceId 2026-01-20 09:52:26 +00:00
agent-events.ts fix: add agent context to ws logs 2026-01-17 20:37:36 +00:00
archive.test.ts refactor: rename hooks docs and add tests 2026-01-17 07:32:54 +00:00
archive.ts style: run oxfmt 2026-01-17 08:00:05 +00:00
backoff.ts refactor: share backoff helpers 2026-01-07 23:22:12 +00:00
binaries.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
binaries.ts chore: format to 2-space and bump changelog 2025-11-26 00:53:53 +01:00
bonjour-ciao.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
bonjour-discovery.test.ts fix: shorten bonjour gateway service type 2026-01-20 15:10:06 +00:00
bonjour-discovery.ts fix: shorten bonjour gateway service type 2026-01-20 15:10:06 +00:00
bonjour-errors.ts refactor: centralize unhandled rejection setup 2026-01-07 20:59:49 +00:00
bonjour.test.ts fix: stabilize gateway tests 2026-01-20 16:02:46 +00:00
bonjour.ts fix: shorten bonjour gateway service type 2026-01-20 15:10:06 +00:00
brew.test.ts fix(ci): stabilize windows tests 2026-01-08 02:44:19 +00:00
brew.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
canvas-host-url.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
channel-activity.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
channel-activity.ts refactor!: rename chat providers to channels 2026-01-13 08:40:39 +00:00
channel-summary.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
channels-status-issues.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
clawdbot-root.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
clipboard.ts feat(browser): copy extension path to clipboard 2026-01-15 06:19:47 +00:00
control-ui-assets.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
control-ui-assets.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
dedupe.test.ts fix: dedupe inbound messages across providers 2026-01-11 00:12:25 +01:00
dedupe.ts fix: dedupe inbound messages across providers 2026-01-11 00:12:25 +01:00
device-auth-store.ts feat: wire role-scoped device creds 2026-01-20 13:04:19 +00:00
device-identity.ts fix: resolve format/build failures 2026-01-19 11:32:15 +00:00
device-pairing.test.ts fix: sync device scopes on token rotation 2026-01-20 10:46:33 +00:00
device-pairing.ts fix: sync device scopes on token rotation 2026-01-20 10:46:33 +00:00
diagnostic-events.test.ts fix: wire OTLP logs for diagnostics 2026-01-20 22:51:47 +00:00
diagnostic-events.ts fix: emit diagnostics across channels 2026-01-21 00:30:34 +00:00
dotenv.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
dotenv.ts fix: load global .env fallback 2026-01-05 01:11:29 +01:00
env-file.ts feat: improve auth setup flows 2026-01-09 09:59:58 +01:00
env.test.ts CLI: streamline startup paths and env parsing 2026-01-18 23:10:39 +00:00
env.ts CLI: streamline startup paths and env parsing 2026-01-18 23:10:39 +00:00
errors.ts fix: tame invalid config logging 2026-01-21 01:58:47 +00:00
exec-approval-forwarder.test.ts feat(discord): add exec approval forwarding to DMs (#1621) 2026-01-24 20:56:40 +00:00
exec-approval-forwarder.ts feat(discord): add exec approval forwarding to DMs (#1621) 2026-01-24 20:56:40 +00:00
exec-approvals.test.ts fix: allow chained exec allowlists 2026-01-23 00:11:58 +00:00
exec-approvals.ts fix(exec-approvals): stabilize allowlist ids (#1521) 2026-01-23 19:00:45 +00:00
exec-host.ts feat: route exec approvals via gateway 2026-01-20 13:04:19 +00:00
exec-safety.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
fetch.test.ts fix: add duplex for fetch uploads 2026-01-25 04:05:30 +00:00
fetch.ts fix: add duplex for fetch uploads 2026-01-25 04:05:30 +00:00
format-duration.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
gateway-lock.test.ts fix: move gateway lock to temp dir 2026-01-25 09:21:46 +00:00
gateway-lock.ts fix: move gateway lock to temp dir 2026-01-25 09:21:46 +00:00
git-commit.ts fix: stamp build commit metadata 2026-01-17 12:30:11 +00:00
heartbeat-events.ts feat(heartbeat): add configurable visibility for heartbeat responses 2026-01-24 09:07:03 +00:00
heartbeat-runner.respects-ackmaxchars-heartbeat-acks.test.ts feat(heartbeat): add configurable visibility for heartbeat responses 2026-01-24 09:07:03 +00:00
heartbeat-runner.returns-default-unset.test.ts feat(heartbeat): skip API calls when HEARTBEAT.md is effectively empty (#1535) 2026-01-24 04:19:01 +00:00
heartbeat-runner.scheduler.test.ts fix: reschedule heartbeat on hot reload 2026-01-21 00:53:54 +00:00
heartbeat-runner.sender-prefers-delivery-target.test.ts test: isolate heartbeat runner workspace in tests 2026-01-24 04:48:01 +00:00
heartbeat-runner.ts feat(discord): add exec approval forwarding to DMs (#1621) 2026-01-24 20:56:40 +00:00
heartbeat-visibility.test.ts feat(heartbeat): add configurable visibility for heartbeat responses 2026-01-24 09:07:03 +00:00
heartbeat-visibility.ts feat(heartbeat): add configurable visibility for heartbeat responses 2026-01-24 09:07:03 +00:00
heartbeat-wake.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
is-main.test.ts chore: rename project to clawdbot 2026-01-04 14:38:51 +00:00
is-main.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
json-file.ts fix: harden cli credential sync 2026-01-10 16:37:54 +01:00
machine-name.ts test: stabilize gateway suites 2026-01-18 05:44:22 +00:00
node-pairing.ts feat: add nodes list table with last connect 2026-01-21 03:03:48 +00:00
node-shell.ts fix: resolve ci failures 2026-01-18 08:45:29 +00:00
os-summary.ts feat(status): improve status output 2026-01-10 23:32:07 +01:00
path-env.test.ts chore: drop legacy Relay signing 2026-01-16 03:11:16 +00:00
path-env.ts CLI: streamline startup paths and env parsing 2026-01-18 23:10:39 +00:00
ports-format.ts feat: fold gateway service commands into gateway 2026-01-21 17:45:26 +00:00
ports-inspect.test.ts fix: harden port listener detection 2026-01-21 18:52:55 +00:00
ports-inspect.ts fix: harden port listener detection 2026-01-21 18:52:55 +00:00
ports-lsof.ts fix: harden port listener detection 2026-01-21 18:52:55 +00:00
ports-types.ts refactor: split port diagnostics helpers 2026-01-08 02:42:43 +01:00
ports.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
ports.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
provider-usage.auth.ts chore: standardize Claude Code CLI naming (#915) 2026-01-14 20:07:35 +00:00
provider-usage.fetch.antigravity.test.ts [AI Assisted] Usage: add Google Antigravity usage tracking (#1490) 2026-01-23 07:17:59 +00:00
provider-usage.fetch.antigravity.ts [AI Assisted] Usage: add Google Antigravity usage tracking (#1490) 2026-01-23 07:17:59 +00:00
provider-usage.fetch.claude.ts chore: standardize Claude Code CLI naming (#915) 2026-01-14 20:07:35 +00:00
provider-usage.fetch.codex.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
provider-usage.fetch.copilot.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
provider-usage.fetch.gemini.ts refactor(infra): split provider usage 2026-01-14 05:40:03 +00:00
provider-usage.fetch.minimax.ts Infra: update MiniMax usage endpoint 2026-01-17 19:45:48 +00:00
provider-usage.fetch.shared.ts refactor(infra): split provider usage 2026-01-14 05:40:03 +00:00
provider-usage.fetch.ts [AI Assisted] Usage: add Google Antigravity usage tracking (#1490) 2026-01-23 07:17:59 +00:00
provider-usage.fetch.zai.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
provider-usage.format.ts fix: hide usage errors in status 2026-01-23 19:43:26 +00:00
provider-usage.load.ts [AI Assisted] Usage: add Google Antigravity usage tracking (#1490) 2026-01-23 07:17:59 +00:00
provider-usage.shared.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
provider-usage.test.ts Infra: update MiniMax usage endpoint 2026-01-17 19:45:48 +00:00
provider-usage.ts feat: sticky auth profile rotation + usage headers 2026-01-16 00:25:49 +00:00
provider-usage.types.ts feat(usage): add minimax usage snapshot 2026-01-14 09:57:32 +00:00
restart-sentinel.test.ts feat: add gateway config/update restart flow 2026-01-08 01:30:02 +01:00
restart-sentinel.ts fix: preserve restart routing + thread replies (#1337) (thanks @John-Rood) 2026-01-21 01:20:25 +00:00
restart.test.ts fix: gate gateway restarts and discord abort reconnects 2026-01-19 00:15:45 +00:00
restart.ts fix: gate gateway restarts and discord abort reconnects 2026-01-19 00:15:45 +00:00
retry-policy.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
retry.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
retry.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
runtime-guard.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
runtime-guard.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
session-cost-usage.test.ts Usage: add cost summaries to /usage + mac menu 2026-01-19 00:05:06 +00:00
session-cost-usage.ts fix: cache usage cost summary 2026-01-22 08:51:22 +00:00
shell-env.path.test.ts fix: merge login shell PATH for gateway exec 2026-01-20 14:04:13 +00:00
shell-env.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
shell-env.ts fix: merge login shell PATH for gateway exec 2026-01-20 14:04:13 +00:00
skills-remote.ts fix: reduce log noise for node disconnect/late invoke errors (#1607) 2026-01-24 20:05:41 +00:00
ssh-config.test.ts fix: sync remote ssh targets 2026-01-16 07:33:15 +00:00
ssh-config.ts fix: sync remote ssh targets 2026-01-16 07:33:15 +00:00
ssh-tunnel.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
state-migrations.fs.test.ts fix: guard session store against array corruption 2026-01-24 04:51:46 +00:00
state-migrations.fs.ts fix: guard session store against array corruption 2026-01-24 04:51:46 +00:00
state-migrations.ts fix: normalize session keys and outbound mirroring 2026-01-24 11:57:11 +00:00
system-events.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
system-events.ts System events: add local timestamps in prompt injection 2026-01-12 21:38:56 -06:00
system-presence.test.ts fix: validate ws tls fingerprint 2026-01-20 13:04:20 +00:00
system-presence.ts feat: enrich presence with roles 2026-01-20 13:04:20 +00:00
tailnet.test.ts Gateway: wide-area Bonjour via clawdis.internal 2025-12-17 17:01:10 +01:00
tailnet.ts Gateway: wide-area Bonjour via clawdis.internal 2025-12-17 17:01:10 +01:00
tailscale.test.ts test: relax tailscale binary expectations 2026-01-24 00:49:04 +00:00
tailscale.ts fix: guard tailscale sudo fallback (#1551) (thanks @sweepies) 2026-01-24 00:17:20 +00:00
transport-ready.test.ts fix: stabilize transport-ready test timing 2026-01-16 23:03:12 +00:00
transport-ready.ts fix: bound signal/imessage transport readiness waits 2026-01-16 20:33:04 +00:00
unhandled-rejections.ts fix: tame invalid config logging 2026-01-21 01:58:47 +00:00
update-channels.ts feat: add update channel status 2026-01-20 14:19:03 +00:00
update-check.test.ts test: avoid hardcoded version strings 2026-01-22 02:01:11 +00:00
update-check.ts fix: prefer stable release when beta lags 2026-01-20 16:36:04 +00:00
update-global.ts feat: align update channel installs 2026-01-21 06:00:54 +00:00
update-runner.test.ts feat: preflight update runner before rebase 2026-01-22 04:19:33 +00:00
update-runner.ts feat: preflight update runner before rebase 2026-01-22 04:19:33 +00:00
update-startup.test.ts test: cover beta fallback update logic 2026-01-20 16:36:37 +00:00
update-startup.ts fix: prefer stable release when beta lags 2026-01-20 16:36:04 +00:00
voicewake.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
voicewake.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
warnings.ts chore: suppress remaining deprecation warnings 2026-01-24 11:16:46 +00:00
widearea-dns.test.ts fix: shorten bonjour gateway service type 2026-01-20 15:10:06 +00:00
widearea-dns.ts fix: shorten bonjour gateway service type 2026-01-20 15:10:06 +00:00
ws.ts fix: resolve build errors 2025-12-23 03:00:04 +01:00
wsl.ts style: apply oxfmt 2026-01-17 18:32:23 +00:00