Commit Graph

322 Commits

Author SHA1 Message Date
Peter Steinberger
4ca07559ab refactor: move provider seams behind plugin sdk surfaces 2026-03-27 23:26:26 +00:00
Peter Steinberger
992b30604d refactor: move extension-owned tests to extensions 2026-03-27 21:37:09 +00:00
Peter Steinberger
d506eea076 fix(ci): restore contract plugin-sdk source loading 2026-03-27 21:33:32 +00:00
Tak Hoffman
9446ee8ea3 fix(regression): restore Telegram fallback probe coverage 2026-03-27 15:47:16 -05:00
Tak Hoffman
fc570934de fix(regression): refresh Telegram probe test imports 2026-03-27 15:42:03 -05:00
Tak Hoffman
7772395618 fix(regression): isolate Telegram runtime helper tests 2026-03-27 15:42:03 -05:00
Tak Hoffman
366c1d6b9e fix(regression): tighten Telegram runtime helper coverage 2026-03-27 15:42:03 -05:00
Jacob Tomlinson
20c7cbbf78 Telegram: tighten media SSRF policy (#56004)
* Telegram: tighten media SSRF policy

* Telegram: restrict media downloads to configured hosts

* Telegram: preserve custom media apiRoot hosts
2026-03-27 20:39:24 +00:00
Tak Hoffman
77060aa9f9 fix(regression): preserve Telegram status fallback without runtime 2026-03-27 15:33:10 -05:00
Jacob Tomlinson
eb6a3fca26 telegram: use live runtime helpers in channel status 2026-03-27 20:14:33 +00:00
Peter Steinberger
c9d68fb9c2 fix: repair ci test and loader regressions 2026-03-27 18:41:47 +00:00
Peter Steinberger
6e107b8857 fix(runtime): stabilize provider and channel runtime tests 2026-03-27 18:15:40 +00:00
Peter Steinberger
cd92549119 test: split extension-owned core coverage 2026-03-27 16:08:57 +00:00
Josh Avant
6ade9c474c feat(hooks): add async requireApproval to before_tool_call (#55339)
* Plugins: add native ask dialog for before_tool_call hooks

Extend the before_tool_call plugin hook with a requireApproval return field
that pauses agent execution and waits for real user approval via channels
(Telegram, Discord, /approve command) instead of relying on the agent to
cooperate with a soft block.

- Add requireApproval field to PluginHookBeforeToolCallResult with id, title,
  description, severity, timeout, and timeoutBehavior options
- Extend runModifyingHook merge callback to receive hook registration so
  mergers can stamp pluginId; always invoke merger even for the first result
- Make ExecApprovalManager generic so it can be reused for plugin approvals
- Add plugin.approval.request/waitDecision/resolve gateway methods with
  schemas, scope guards, and broadcast events
- Handle requireApproval in pi-tools via two-phase gateway RPC with fallback
  to soft block when the gateway is unavailable
- Extend the exec approval forwarder with plugin approval message builders
  and forwarding methods
- Update /approve command to fall back to plugin.approval.resolve when exec
  approval lookup fails
- Document before_tool_call requireApproval in hooks docs and unified
  /approve behavior in exec-approvals docs

* Plugins: simplify plugin approval code

- Extract mergeParamsWithApprovalOverrides helper to deduplicate param
  merge logic in before_tool_call hook handling
- Use idiomatic conditional spread syntax in toolContext construction
- Extract callApprovalMethod helper in /approve command to eliminate
  duplicated callGateway calls
- Simplify plugin approval schema by removing unnecessary Type.Union
  with Type.Null on optional fields
- Extract normalizeTrimmedString helper for turn source field trimming

* Tests: add plugin approval wiring and /approve fallback coverage

Fix 3 broken assertions expecting old "Exec approval" message text.
Add tests for the /approve command's exec→plugin fallback path,
plugin approval method registration and scope authorization, and
handler factory key verification.

* UI: wire plugin approval events into the exec approval overlay

Handle plugin.approval.requested and plugin.approval.resolved gateway
events by extending the existing exec approval queue with a kind
discriminator. Plugin approvals reuse the same overlay, queue management,
and expiry timer, with branched rendering for plugin-specific content
(title, description, severity). The decision handler routes resolve calls
to the correct gateway method based on kind.

* fix: read plugin approval fields from nested request payload

The gateway broadcasts plugin approval payloads with title, description,
severity, pluginId, agentId, and sessionKey nested inside the request
object (PluginApprovalRequestPayload), not at the top level. Fix the
parser to read from the correct location so the overlay actually appears.

* feat: invoke plugin onResolution callback after approval decision

Adds onResolution to the requireApproval type and invokes it after
the user resolves the approval dialog, enabling plugins to react to
allow-always vs allow-once decisions.

* docs: add onResolution callback to requireApproval hook documentation

* test: fix /approve assertion for unified approval response text

* docs: regenerate plugin SDK API baseline

* docs: add changelog entry for plugin approval hooks

* fix: harden plugin approval hook reliability

- Add APPROVAL_NOT_FOUND error code so /approve fallback uses structured
  matching instead of fragile string comparison
- Check block before requireApproval so higher-priority plugin blocks
  cannot be overridden by a lower-priority approval
- Race waitDecision against abort signal so users are not stuck waiting
  for the full approval timeout after cancelling a run
- Use null consistently for missing pluginDescription instead of
  converting to undefined
- Add comments explaining the +10s timeout buffer on gateway RPCs

* docs: document block > requireApproval precedence in hooks

* fix: address Phase 1 critical correctness issues for plugin approval hooks

- Fix timeout-allow param bug: return merged hook params instead of
  original params when timeoutBehavior is "allow", preventing security
  plugins from having their parameter rewrites silently discarded.

- Host-generate approval IDs: remove plugin-provided id field from the
  requireApproval type, gateway request, and protocol schema. Server
  always generates IDs via randomUUID() to prevent forged/predictable
  ID attacks.

- Define onResolution semantics: add PluginApprovalResolutions constants
  and PluginApprovalResolution type. onResolution callback now fires on
  every exit path (allow, deny, timeout, abort, gateway error, no-ID).
  Decision branching uses constants instead of hard-coded strings.

- Fix pre-existing test infrastructure issues: bypass CJS mock cache for
  getGlobalHookRunner global singleton, reset gateway mock between tests,
  fix hook merger priority ordering in block+requireApproval test.

* fix: tighten plugin approval schema and add kind-prefixed IDs

Harden the plugin approval request schema: restrict severity to
enum (info|warning|critical), cap timeoutMs at 600s, limit title
to 80 chars and description to 256 chars. Prefix plugin approval
IDs with `plugin:` so /approve routing can distinguish them from
exec approvals deterministically instead of relying on fallback.

* fix: address remaining PR feedback (Phases 1-3 source changes)

* chore: regenerate baselines and protocol artifacts

* fix: exclude requesting connection from approval-client availability check

hasExecApprovalClients() counted the backend connection that issued
the plugin.approval.request RPC as an approval client, preventing
the no-approval-route fast path from firing in headless setups and
causing 120s stalls. Pass the caller's connId so it is skipped.
Applied to both plugin and exec approval handlers.

* Approvals: complete Discord parity and compatibility fallback

* Hooks: make plugin approval onResolution non-blocking

* Hooks: freeze params after approval owner is selected

* Gateway: harden plugin approval request/decision flow

* Discord/Telegram: fix plugin approval delivery parity

* Approvals: fix Telegram plugin approval edge cases

* Auto-reply: enforce Telegram plugin approval approvers

* Approvals: harden Telegram and plugin resolve policies

* Agents: static-import gateway approval call and fix e2e mock loading

* Auto-reply: restore /approve Telegram import boundary

* Approvals: fail closed on no-route and neutralize Discord mentions

* docs: refresh generated config and plugin API baselines

---------

Co-authored-by: Václav Belák <vaclav.belak@gendigital.com>
2026-03-27 09:06:40 -07:00
Peter Steinberger
351a931a62 fix(ci): restore runtime-api guardrails 2026-03-27 15:56:54 +00:00
Peter Steinberger
8ddeada97d test: move extension-owned coverage into plugins 2026-03-27 15:11:33 +00:00
Peter Steinberger
66a2e72bee fix: restore CI runtime seams 2026-03-27 14:07:01 +00:00
Peter Steinberger
45849eb757 refactor: remove remaining core extension reach-ins 2026-03-27 13:46:16 +00:00
Peter Steinberger
9a775aa59c refactor: continue plugin seam cleanup 2026-03-27 13:46:16 +00:00
Peter Steinberger
b96f5d94db chore(telegram): downgrade default network logs 2026-03-27 02:29:32 +00:00
Peter Steinberger
40bd36e35d refactor: move channel config metadata into plugin-owned manifests 2026-03-27 01:59:30 +00:00
Peter Steinberger
0e182dd3e1 refactor: share top-level setup dm policies 2026-03-26 23:20:26 +00:00
Peter Steinberger
bfad32aa16 refactor: share directory config listers 2026-03-26 23:20:26 +00:00
Peter Steinberger
53f90af990 test: dedupe telegram polling session harness 2026-03-26 21:30:28 +00:00
Peter Steinberger
0c0f1e34cb refactor: split telegram polling and sdk surfaces 2026-03-26 21:13:16 +00:00
Peter Steinberger
61d29efc04 test: eliminate remaining clone seams 2026-03-26 20:28:36 +00:00
pkuGeo
e035a0d98c telegram: rebuild transport after stalled polling cycles 2026-03-26 13:11:15 -07:00
Peter Steinberger
2fc017788c test: reduce remaining clone seams 2026-03-26 20:01:01 +00:00
Peter Steinberger
be328e6cd1 test: dedupe extension channel fixtures 2026-03-26 19:47:27 +00:00
Peter Steinberger
8f1716ae5a refactor: share slack and telegram action helpers 2026-03-26 19:07:35 +00:00
Jacob Tomlinson
c2c136ae95 telegram: throttle repeated webhook auth guesses (#55142)
* telegram: throttle repeated webhook auth guesses

* telegram: use per-listener webhook rate limits

* config: stabilize doc baseline ordering
2026-03-26 16:19:31 +00:00
Peter Steinberger
339cc33cf8 perf: speed up channel test runs 2026-03-26 15:40:01 +00:00
Peter Steinberger
5f9f08394a refactor: share matrix and telegram dedupe helpers 2026-03-26 15:08:45 +00:00
Jacob Tomlinson
269282ac69 Telegram: enforce DM auth for callbacks (#55112) 2026-03-26 11:42:27 +00:00
wangchunyue
ebad7490b4 fix: resolve telegram token fallback for binding-created accounts (#54362) (thanks @openperf)
* fix(telegram): resolve channel-level token fallthrough for binding-created accountIds

Fixes #53876

* fix(telegram): align isConfigured with resolveTelegramToken multi-bot guard

* fix(telegram): use normalized account lookup and require available token
2026-03-26 09:16:15 +05:30
Devin Robison
b7d70ade3b Fix/telegram writeback admin scope gate (#54561)
* fix(telegram): require operator.admin for legacy target writeback persistence

* Address claude feedback

* Update extensions/telegram/src/target-writeback.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Remove stray brace

* Add updated docs

* Add missing test file, address codex concerns

* Fix test formatting error

* Address comments, fix tests

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-25 12:12:09 -06:00
Harold Hunt
055ad65896 Telegram: ignore self-authored DM message updates (#54530)
Merged via squash.

Prepared head SHA: c1c8a85168
Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com>
Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com>
Reviewed-by: @huntharo
2026-03-25 13:16:35 -04:00
Peter Steinberger
52bec1612c test: collapse telegram transport and status suites 2026-03-25 11:23:18 +00:00
Peter Steinberger
12082f47bd test: collapse telegram button and access suites 2026-03-25 11:23:18 +00:00
Peter Steinberger
3de04bdd6d test: collapse telegram context and transport suites 2026-03-25 11:17:58 +00:00
Peter Steinberger
fc49258c12 test: collapse telegram helper suites 2026-03-25 11:17:58 +00:00
hnshah
c7f021f70f fix: preflight invalid telegram photos (#52545) (thanks @hnshah)
* fix(telegram): validate photo dimensions before sendPhoto

Prevents PHOTO_INVALID_DIMENSIONS errors by checking image dimensions
against Telegram Bot API requirements before calling sendPhoto.

If dimensions exceed limits (width + height > 10,000px), automatically
falls back to sending as document instead of crashing with 400 error.

Tested in production (openclaw 2026.3.13) where this error occurred:
  [telegram] tool reply failed: GrammyError: Call to 'sendPhoto' failed!
  (400: Bad Request: PHOTO_INVALID_DIMENSIONS)

Uses existing sharp dependency to read image metadata. Gracefully
degrades if sharp fails (lets Telegram handle validation, backward
compatible behavior).

Closes: #XXXXX (will reference OpenClaw issue if one exists)

* fix(telegram): validate photo aspect ratio

* refactor: use shared telegram image metadata

* fix: fail closed on telegram image metadata

* fix: preflight invalid telegram photos (#52545) (thanks @hnshah)

---------

Co-authored-by: Bob Shah <bobshah@Macs-Mac-Studio.local>
Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-03-25 12:00:20 +05:30
VACInc
89b7fee352 fix: preserve Telegram forum topic last-route delivery (#53052) (thanks @VACInc)
* fix(telegram): preserve forum topic thread in last-route delivery

* style(telegram): format last-route update

* test(telegram): cover General topic last-route thread

* test(telegram): align topic route helper

* fix(telegram): skip bound-topic last-route writes

---------

Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>
Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-03-25 11:31:01 +05:30
nimbleenigma
abec3ed645 fix: keep Telegram native commands on runtime snapshot (#53179) (thanks @nimbleenigma)
* fix(telegram): use runtime snapshot for native commands

* fix: keep Telegram native commands on runtime snapshot (#53179) (thanks @nimbleenigma)

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-03-25 11:18:54 +05:30
SUMUKH
149c4683a3 fix: scope Telegram pairing code blocks (#52784) (thanks @sumukhj1219)
* Telegram: format pairing challenge for easier copy

* test: restore Telegram pairing chatId assertion

* fix: scope Telegram pairing code blocks (#52784) (thanks @sumukhj1219)

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-03-25 11:03:33 +05:30
w-sss
247f82119c fix: improve Telegram 403 membership delivery errors (#53635) (thanks @w-sss)
* fix(telegram): improve error messages for 403 bot not member errors

- Detect 403 'bot is not a member' errors specifically
- Provide actionable guidance for users to fix the issue
- Fixes #48273 where outbound sendMessage fails with 403

Root cause:
When a Telegram bot tries to send a message to a channel/group it's not
a member of, the API returns 403 'bot is not a member of the channel chat'.
The error message was not clear about how to fix this.

Fix:
1. Detect 403 errors in wrapTelegramChatNotFoundError
2. Provide clear error message explaining the issue
3. Suggest adding the bot to the channel/group

* fix(telegram): fix regex precedence for 403 error detection

- Group alternatives correctly: /403.*(bot.*not.*member|bot was blocked)/i
- Require 403 for both alternatives (previously bot.*blocked matched any error)
- Update error message to cover both scenarios
- Fixes Greptile review feedback

* fix(telegram): correct regex alternation precedence for 403 errors

- Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/
- Ensures 403 requirement applies to both alternatives
- Fixes Greptile review comment on PR #48650

* fix(telegram): add 'bot was kicked' to 403 error regex and message

* fix(telegram): preserve membership delivery errors

* fix: improve Telegram 403 membership delivery errors (#53635) (thanks @w-sss)

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-03-25 10:59:29 +05:30
Peter Steinberger
6f137fff76 test: collapse telegram and whatsapp target suites 2026-03-25 05:21:16 +00:00
Jealous
2c3cf4f387 chore(tts): rename VOICE_BUBBLE identifiers to OPUS and update docs 2026-03-25 10:49:21 +05:30
Peter Steinberger
fe84148724 test: collapse messaging target test suites 2026-03-25 04:52:36 +00:00
Peter Steinberger
6f6468027a refactor: dedupe test and runtime seams 2026-03-24 23:33:30 +00:00