Commit Graph

11918 Commits

Author SHA1 Message Date
Omar Shahine
5c7980fa11 feat(imessage): support thumb approval reactions (#85952)
* feat(imessage): support thumb approval reactions

Mirrors openclaw#85477 (WhatsApp) for the iMessage channel. iMessage can now
deliver exec/plugin approval prompts via the existing imsg/BlueBubbles
transport and resolve approvals from 👍 (allow-once) / 👎 (deny) tapbacks.
Allow-always remains on the manual /approve <id> allow-always fallback.

What changed:
- New approval surfaces under extensions/imessage/src/:
  approval-auth.ts, approval-resolver.ts, approval-reactions.ts,
  approval-handler.runtime.ts, approval-native.ts (+ tests for each).
- channel.ts wires base.approvalCapability to the new iMessage capability.
- send.ts appends the 👍/👎 hint to outbound /approve prompts and registers
  the reaction binding (keyed by accountId + chat_guid/chat_identifier/
  chat_id/handle + messageId) after a successful send.
- monitor/monitor-provider.ts resolves approval reactions ahead of the
  normal inbound decision pipeline so resolution bypasses
  reactionNotifications gating and runs its own actor authorization.
- runtime.ts now exports getIMessageRuntime / getOptionalIMessageRuntime so
  approval-reactions can open a persistent keyed store for binding state
  across gateway restarts.

What did NOT change:
- Core approval surfaces in src/gateway/server-methods/* and src/infra/*
  remain channel-agnostic; the channels.imessage.allowFrom field already
  exists and is reused as the approver list for reactions.
- Other channels and the manual /approve sender-authorized path are
  untouched.

* fix(imessage): address codex review findings on thumb approvals

Addresses 15 findings from the multi-angle codex review:

Critical (correctness / blocking):
- Register CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY in the iMessage
  monitor so the gateway can actually deliver native approval prompts via
  approval-handler.runtime.ts (it was dead code without the context lease).
- DM tapback approvals never resolved because send keyed by handle while
  inbound preferred chat_guid. Register and look up under EVERY available
  conversation key (chat_guid / chat_identifier / chat_id / handle); inbound
  probes them all and accepts the first hit.
- Reaction binding now requires the bridge's GUID string (rejecting numeric
  ROWIDs) so the binding key matches inbound reacted_to_guid.
- Outbound regex now requires both a canonical `ID: <approvalId>` header AND
  a matching `/approve <id> <decision>` line, so non-approval messages that
  legitimately mention /approve syntax no longer get a phantom reaction
  binding (and can no longer resolve a colliding live approval).
- Drop is_from_me reaction events so cross-device echoes of the operator's
  own tap cannot self-approve when their handle is in allowFrom.

High (operability / cleanup):
- Non-ApprovalNotFound errors now log at warn via the runtime child logger
  (no longer hidden behind OPENCLAW_LOG_LEVEL=debug).
- In-memory binding is cleared on successful resolve so a toggle 👍👎 (or
  chat.db replay) does not refire and emit a misleading 'expired approval'
  log line. Removed tapbacks are also owned by the shortcut and not surfaced
  as noisy reaction system events.
- Move resolveIMessageReactionContext (and its helpers) to a slim
  monitor/reaction-context.ts so approval-reactions.ts no longer transitively
  pulls monitor/inbound-processing.ts (14+ heavy runtime modules) into the
  hot channel.ts entrypoint per extensions/CLAUDE.md.

Medium (consistency / future-proofing):
- Native runtime exec pending payload now passes agentId, ask, and
  sessionKey through buildExecApprovalPendingReplyPayload so the two
  delivery routes produce identical operator-visible prompts.
- Both delivery paths now use addIMessageApprovalReactionHintToText (single
  insertion point after ID:) so the hint cannot be double-emitted by the
  native runtime path bypassing the idempotency guard.
- Extract replaceApprovalIdPlaceholder into a shared approval-text.ts that
  escapes `$` in the replacement string so an approvalId containing
  `$&`/`$1`-`$9`/`$$` cannot interpolate into the outbound text.
- In-memory Map now stores TTL alongside each entry and prunes expired
  bindings on each register so the gateway no longer accumulates an
  unbounded reaction-target Map.
- bindPending refuses to bind when accountId is missing or the approval is
  already expired, with explicit error logs instead of silent no-ops.
- Reject chat_id=0 as a synthetic key value (chat.db ROWIDs start at 1).
- Drop dead getIMessageRuntime export — only the optional accessor is used.

Documentation:
- docs/channels/imessage.md gains an 'Approval reactions (👍 / 👎)' accordion
  documenting the reaction emoji map, allowFrom approver requirement, the
  /approve <id> allow-always manual fallback, and the deliberate change to
  /approve command authorization for users with non-empty allowFrom.
- CHANGELOG.md entry added under 2026.5.24.

Tests: 411 iMessage tests pass (was 406). Added explicit coverage for the
DM key-mismatch fix, the regex-tightening fix, the is_from_me guard, the
clear-on-success behavior, and the approval-id `$` escape.

* test(imessage): match WhatsApp approval-native test coverage

Backfills the nine cases from extensions/whatsapp/src/approval-native.test.ts
that weren't mirrored in iMessage:

- target-mode exec + plugin prompt rendering with the canonical hint
- target-mode availability when no iMessage target matches
- agentFilter / sessionFilter applied to native handling
- account-scoped target enabled/disabled per account
- shouldSuppressForwardingFallback session-origin exact-match cases
- shouldSuppressForwardingFallback off when native cannot bind (locks down
  the targets-only forwarding path the Lobster live deploy exercised)
- both-mode explicit + unscoped target suppression
- group-origin tapback approvals require explicit approvers

Tests: extensions/imessage/src/approval-native.test.ts 21 passed (was 11).
Total iMessage approval-specific cases now 49 (was 40).

* fix(imessage): preserve service-prefixed direct handles as approvers

ClawSweeper P1 review finding on #85952. normalizeIMessageApproverId was
calling looksLikeIMessageExplicitTargetId() to reject conversation-target
prefixes, but that helper also matches the imessage:/sms:/auto: service
prefixes — which are valid direct-handle forms. Any allowFrom entry like
'imessage:+15551230000' dropped to undefined, leaving approvers empty,
which:
  - silently denied reaction resolution ('reactions require explicit
    approvers'), and
  - let text /approve fall back to implicit same-chat authorization.

Fix: normalize first via normalizeIMessageHandle (strips the service
prefix), then reject only chat_id:/chat_guid:/chat_identifier:
conversation-target shapes that remain after normalization.

Tests:
  - approval-auth.test.ts: assert the resolved approver list contains the
    normalized handle, plus the corollary that a non-matching sender is
    explicitly rejected (no longer masked by the implicit-same-chat
    fallback). Add a separate case covering chat_id/chat_guid/
    chat_identifier rejection (with and without a service prefix).
  - approval-reactions.test.ts: reaction resolution end-to-end with a
    service-prefixed allowFrom entry — proves resolveIMessageApproval is
    called rather than silently denied.

Focused suite: 48 passed (was 47).

* test(imessage): satisfy strict buildPendingPayload signature in render tests

CI check:test-types caught that the render.exec/render.plugin
buildPendingPayload calls were passing accountId (not in the type
signature). The signature is { cfg, request, target, nowMs }. Replace
accountId with target on the four render-test sites so the strict
test-types pass matches the SDK contract:

  - it('renders thumbs-only reaction hints in exec approval prompts')
  - it('renders thumbs-only reaction hints in plugin approval prompts ...')
  - it('renders target-mode exec prompts with concrete thumbs-only ...')
  - it('renders target-mode plugin prompts with concrete thumbs-only ...')

Verified locally with pnpm check:test-types (tsgo:core:test +
tsgo:extensions:test). 49 approval-specific tests still pass.

* fix(imessage): probe every tapback GUID form for approval lookup

ClawSweeper P1 review finding on #85952. readApprovalReactionEvent was
only using reaction.targetGuid (the first/normalized form), but
resolveIMessageReactionContext produces reaction.targetGuids = [normalized,
raw] for both `abc-123` and `p:0/abc-123` forms. If the imsg bridge
returned 'p:0/<guid>' from send() and send.ts registered the binding under
that prefixed key, the inbound resolver probing only the unprefixed form
would miss and the tapback would silently fall through.

Fix:
- Surface every GUID candidate in IMessageApprovalReactionEvent
  (messageIdCandidates).
- maybeResolveIMessageApprovalReaction now probes each candidate in
  precedence order; first hit wins.
- On success / ApprovalNotFoundError, clear the binding under all
  candidate keys so toggle/replay does not refire.

Tests: extensions/imessage/src/approval-reactions.test.ts gains a
'resolves a reaction when the binding was registered under a p:0/…
prefixed GUID and the tapback surfaces both forms' regression case;
22/22 reaction tests pass. Full iMessage suite: 424/424.

* fix(imessage): native approval binding requires GUID, not numeric id

ClawSweeper third P1 review finding on #85952. approval-handler.runtime.ts
deliverPending was using result.messageId as the approval-reaction binding
key, but that field can be a numeric ROWID coerced to a string ('12345')
when the imsg bridge returns only message_id. Inbound tapbacks carry
reacted_to_guid which is always a GUID, so a numeric-id binding can never
match.

Fix mirrors the send.ts forwarding-path treatment:
- IMessageSendResult now exposes a separate guid?: string field, populated
  from the same resolveOutboundMessageGuid helper send.ts already uses for
  the forwarding-path binding. The generic messageId field is unchanged so
  reply-cache, echo-cache, and receipt-building paths still see the
  broadest id form.
- deliverPending now binds against result.guid; when it's undefined (numeric
  ROWID or 'ok'/'unknown' placeholders), the function returns null instead
  of binding against an id the inbound tapback can't possibly match.

Tests: approval-handler.runtime.test.ts gets a deliverPending GUID-only
binding describe block with three regression cases (numeric ROWID refused,
GUID accepted, ok/unknown placeholders refused). vi.mock isolates
sendMessageIMessage so the cases run synchronously without spawning imsg.
11 tests pass across handler.runtime + send specs.

---------

Co-authored-by: Omar Shahine <10343873+omarshahine@users.noreply.github.com>
2026-05-24 10:51:21 -07:00
Andy Ye
102555c6e0 Advance iMessage catchup cursor after live handling (#85475)
Fixes #85363.

Thanks @TurboTheTurtle.
2026-05-24 09:34:16 -07:00
Vincent Koc
694d45e535 fix(media): use static image compression metadata 2026-05-24 16:47:59 +02:00
Ayaan Zaidi
5cfb12fa5d fix(telegram): migrate account topic cache sidecars 2026-05-24 18:58:02 +05:30
Ayaan Zaidi
eb9b882dae fix(telegram): migrate legacy cache sidecars 2026-05-24 18:58:02 +05:30
Ayaan Zaidi
996d07ee46 fix(telegram): store topic cache in plugin state 2026-05-24 17:38:27 +05:30
Ayaan Zaidi
2ed52969c5 fix(telegram): store bot info cache in plugin state 2026-05-24 17:38:27 +05:30
Peter Steinberger
e8643f0c15 test(telegram): keep startup limiter coverage focused 2026-05-24 12:36:45 +01:00
Peter Steinberger
04d86e0f47 test(telegram): isolate startup probe limiter timing 2026-05-24 12:23:32 +01:00
Peter Steinberger
578e73f667 test(release): harden plugin prerelease checks 2026-05-24 12:02:29 +01:00
Josh Lehman
62b51a6295 fix(telegram): serialize topic dispatch replies (#85709)
* fix(telegram): serialize topic dispatch replies (clawdbot-b19)

* fix(telegram): normalize dispatch topic context

* fix(telegram): satisfy dispatch race CI checks

* fix(telegram): normalize raw code language tags

* refactor(reply): centralize turn admission

* fix(telegram): persist recovered topic routes

* fix(reply): preserve queue policy admission

* fix(reply): retain active abort owner

* fix(reply): split active abort ownership

* fix(reply): defer busy followup drains

* fix(reply): wire hook abort ownership

* fix(reply): preserve deferred queue summaries

* fix(reply): type queued summary retry

* fix(reply): abort embedded and core runs

* test(reply): keep final abort operation active

* test(reply): stabilize abort normalization test

* fix(reply): keep non-visible admission skips silent

* test(reply): avoid dispatch shard mock bleed

* fix(reply): merge deferred queue summaries

* fix(reply): abort active-lane resolver runs

* fix(reply): compose borrowed lane abort signals

* fix(reply): keep interrupt turns caller-owned

* fix(telegram): keep recovered topic history scoped

* fix(reply): retry deferred summary queues

* fix(reply): document deferred summary restore

* fix(telegram): rebuild recovered topic prompt body

* fix(reply): run admitted session ids

* fix(telegram): recover topic chat actions

* fix(reply): honor pre-dispatch aborts for handled replies

* fix(reply): guard local handled final aborts

* fix(reply): refresh admitted session files

* fix(telegram): trust final current-message marker

* fix(telegram): migrate recovered room history

* fix(telegram): scope recovered topics to current chat

* fix(reply): wait for visible reply lane ownership

* fix(telegram): pass recovered topic body to agent

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-05-24 11:49:48 +01:00
Peter Steinberger
3679151c2c test(release): stabilize plugin prerelease checks 2026-05-24 11:40:48 +01:00
Peter Steinberger
0a8af67c11 test(telegram): wait for startup probe slots 2026-05-24 11:21:15 +01:00
Peter Steinberger
783290f7ed test(codex): match sandbox exec-server yolo policy 2026-05-24 11:01:15 +01:00
Peter Steinberger
558c1bc39a test(codex): avoid full sandbox exec-server turn run 2026-05-24 10:36:44 +01:00
Peter Steinberger
a4ef3a2c9a test(codex): type thread start mock params 2026-05-24 08:53:29 +01:00
Peter Steinberger
11bf6424ca test(codex): avoid full sandbox run in thread-start test 2026-05-24 08:40:58 +01:00
Peter Steinberger
c14a0c6d63 test(codex): complete sandbox turn inline 2026-05-24 08:19:01 +01:00
homer-byte
4d150209c3 Fix iMessage slash command acknowledgements (#82642)
Merged via squash.

Prepared head SHA: ecc8791393
Co-authored-by: homer-byte <262247270+homer-byte@users.noreply.github.com>
Co-authored-by: omarshahine <10343873+omarshahine@users.noreply.github.com>
Reviewed-by: @omarshahine
2026-05-23 23:33:33 -07:00
Peter Steinberger
02f53e6453 test(release): align prerelease contracts 2026-05-24 07:23:32 +01:00
Peter Steinberger
56eb23dda4 test(release): align plugin prerelease checks 2026-05-24 06:47:42 +01:00
Peter Steinberger
fdfcb0795a fix(discord): harden realtime voice wake joins 2026-05-24 05:54:10 +01:00
Peter Steinberger
32631eb9d4 fix(telegram): normalize legacy action targets 2026-05-24 05:38:59 +01:00
NianJiu
d4e42d61c9 fix(minimax): normalize OAuth token expiry to absolute millisecond timestamp (#83480)
* fix(minimax): normalize OAuth token expiry to absolute millisecond timestamp

MiniMax returns expired_in from the token endpoint as a relative duration
in seconds (standard OAuth expires_in semantics), but the auth profile
store's hasUsableOAuthCredential() expects an absolute millisecond
timestamp.  Without conversion the token appears perpetually expired,
triggering a slow OAuth refresh network call to api.minimaxi.com on
every request — the root cause of the 30-50s auth-stage delay.

Fixes #83449.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(minimax): cover oauth expiry normalization

* fix: polish minimax oauth expiry normalization (#83480) (thanks @NianJiuZst)

* fix: update minimax raw fetch allowlist (#83480)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-05-24 05:21:22 +01:00
David
55f994a8d0 fix(memory-wiki): show vault totals in palace summary (#85824)
* fix(memory-wiki): show vault totals in palace summary

* fix(memory-wiki): avoid zero-page legacy question label

---------

Co-authored-by: nxmxbbd <32288+nxmxbbd@users.noreply.github.com>
2026-05-24 05:11:12 +01:00
AirLin
d0751111a4 Guard OpenAI image compression for PNG outputs (#85776)
* Guard OpenAI image compression for PNG outputs

* Fix OpenAI image compression type narrowing

* docs(changelog): note OpenAI PNG compression fix

* Revert "docs(changelog): note OpenAI PNG compression fix"

This reverts commit b11e4bff01.

---------

Co-authored-by: airlin <airlin@airlins-Mac-mini.local>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-05-24 05:01:55 +01:00
Peter Steinberger
17dcdead00 fix: gate discord realtime voice by wake name (#85915) 2026-05-24 04:47:16 +01:00
Gio Della-Libera
617335250e fix(telegram): honor explicit default account warning (#85752) 2026-05-23 20:41:35 -07:00
Gio Della-Libera
2e8dee7f28 fix(browser): avoid cold mac chrome version timeouts (#85460) 2026-05-23 20:39:47 -07:00
Peter Steinberger
c38a9a883a fix: label meeting note transcript speakers
Include speaker-labeled transcript lines in Meeting Notes summaries and structured summary artifacts.
2026-05-24 04:29:01 +01:00
Peter Steinberger
8f783cdcad fix(release): keep memory plugin npm package small 2026-05-24 04:27:42 +01:00
Peter Steinberger
7a85f1ee94 test(matrix): stabilize thread binding sweep persistence 2026-05-24 04:27:42 +01:00
Cavit Erginsoy
bd91107fc6 Fix foreground reply fence visibility 2026-05-24 04:02:59 +01:00
Peter Steinberger
841cb121fb fix(twitch): cancel auth retry disconnects 2026-05-24 03:55:49 +01:00
Peter Steinberger
08159d87d2 fix: address PR review comments 2026-05-24 03:55:49 +01:00
Peter Steinberger
6a482584ee fix(ci): address review sweep regressions 2026-05-24 03:55:49 +01:00
Peter Steinberger
9177860373 fix(twitch): wait through auth retry disconnects 2026-05-24 03:55:49 +01:00
Peter Steinberger
e9bf1113fa fix(twitch): cancel pending clients during shutdown 2026-05-24 03:55:49 +01:00
Peter Steinberger
5b2703e24d fix(plugins): avoid Signal and Twitch setup regressions 2026-05-24 03:55:49 +01:00
Peter Steinberger
c617009cbf fix(plugins): stabilize Twitch and Signal setup 2026-05-24 03:55:49 +01:00
Peter Steinberger
bee15d4fa2 fix(browser): validate inputs and redact remote URLs 2026-05-24 03:55:49 +01:00
Peter Steinberger
eeb5f12293 fix(plugins): fail stalled runtime operations 2026-05-24 03:55:49 +01:00
Peter Steinberger
15ff89bf5d fix(cli): preserve command option state 2026-05-24 03:55:49 +01:00
Kaspre
96959ec3d7 fix(codex): defer native-hook-relay unregister to avoid cleanup race
Keep successful Codex native hook relays alive through a bounded grace window so late hook callbacks still reach OpenClaw enforcement, while interrupted, aborted, timed-out, and failed turns unregister immediately.\n\nCo-authored-by: Kaspre <kaspre@gmail.com>
2026-05-24 03:53:00 +01:00
Peter Steinberger
bc6d430d00 fix: recover discord realtime playback state 2026-05-24 03:44:31 +01:00
Shakker
f5b415f138 fix: bound Codex post-reasoning source reply waits 2026-05-24 03:37:43 +01:00
Shakker
c93dda9423 fix: keep long Codex source replies alive 2026-05-24 03:37:43 +01:00
WhatsSkiLL
b13166bc0c fix: gracefully escalate process supervisor cancellations (#85865)
* fix: gracefully escalate supervisor cancellations

* fix: preserve process-tree cancellation during grace

* fix: satisfy signal monitor allSettled lint

* fix(process): split graceful cancel signal escalation

---------

Co-authored-by: JARVIS-Glasses <284122573+JARVIS-Glasses@users.noreply.github.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-05-24 03:35:37 +01:00
Peter Steinberger
029472c6de fix: keep discord realtime audio playback alive 2026-05-24 03:20:01 +01:00
Masato Hoshino
069c7b87eb fix(browser): thread snapshot timeoutMs through agent tool and helpers (#75702)
Summary:
- Threads browser snapshot `timeoutMs` through the agent action, client/proxy request, snapshot route plan, Ch ...  Playwright/CDP helpers, regression tests, changelog, and one JSDoc-only shrinkwrap script type annotation.
- Reproducibility: yes. source reproduction is high-confidence: current main accepts top-level browser `timeou ...  helpers drop it. I did not rerun the original macOS or Browserbase live scenario in this read-only review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: fix(browser): apply default snapshot timeout to proxy path and add Pl…
- PR branch already contained follow-up commit before automerge: docs(changelog): add browser snapshot timeout propagation fix entry
- PR branch already contained follow-up commit before automerge: fix(browser): thread snapshot timeoutMs through agent tool and helpers
- PR branch already contained follow-up commit before automerge: fix(clawsweeper): address review for automerge-openclaw-openclaw-7570…

Validation:
- ClawSweeper review passed for head 0eec196962.
- Required merge gates passed before the squash merge.

Prepared head SHA: 0eec196962
Review: https://github.com/openclaw/openclaw/pull/75702#issuecomment-4359923127

Co-authored-by: masatohoshino <g515hoshino@gmail.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com>
Approved-by: takhoffman
Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
2026-05-24 02:15:58 +00:00