Commit Graph

358 Commits

Author SHA1 Message Date
Peter Steinberger
5802d112da refactor: narrow telegram test mocks off infra runtime 2026-03-28 06:56:41 +00:00
Peter Steinberger
61936938e9 refactor: move test harnesses off infra runtime 2026-03-28 06:52:06 +00:00
Peter Steinberger
922c90e9fa refactor: add approval runtime sdk seam 2026-03-28 06:33:07 +00:00
Peter Steinberger
0d98ce1065 refactor: add diagnostic and error runtime sdk seams 2026-03-28 06:26:38 +00:00
Peter Steinberger
1db1c75a98 refactor: trim state persistence runtime seams 2026-03-28 06:08:18 +00:00
Peter Steinberger
c222a44e6f refactor: add retry runtime sdk seam 2026-03-28 05:59:07 +00:00
Peter Steinberger
a126d23f0d refactor: add fetch runtime sdk seam 2026-03-28 05:44:33 +00:00
Peter Steinberger
49f693d06a refactor: widen webhook request guard sdk seam 2026-03-28 05:28:10 +00:00
Peter Steinberger
be31e7aa4c fix: unblock telegram typing and topic runtime builds 2026-03-28 04:58:34 +00:00
Ayaan Zaidi
fe679f0a90 fix(telegram): tighten reaction typings 2026-03-28 10:28:24 +05:30
Peter Steinberger
dc87ffa46d fix(ci): guard telegram native command auth typing 2026-03-28 04:55:26 +00:00
Peter Steinberger
090a767754 fix: tighten telegram runtime type guards 2026-03-28 04:53:26 +00:00
Peter Steinberger
222ba9f174 fix(ci): tighten telegram and typing test types 2026-03-28 04:49:21 +00:00
Peter Steinberger
324c621ebe fix(ci): align telegram runtime and test drift 2026-03-28 04:41:23 +00:00
Tak Hoffman
84af16e9c7 fix(regression): handle telegram command error envelopes 2026-03-27 23:36:37 -05:00
Ayaan Zaidi
6949e17429 refactor(telegram): simplify transport typing 2026-03-28 10:05:11 +05:30
Tak Hoffman
411494faa8 fix(regression): guard malformed telegram reaction payloads 2026-03-27 23:34:09 -05:00
Ayaan Zaidi
8465ddc1cc refactor(telegram): tighten helper field readers 2026-03-28 09:57:46 +05:30
Ayaan Zaidi
f9aa226d93 refactor(telegram): simplify action button parsing 2026-03-28 09:57:46 +05:30
Ayaan Zaidi
ed441b180b refactor(telegram): simplify message helper parsing 2026-03-28 09:57:46 +05:30
Ayaan Zaidi
39829b5dc6 refactor(telegram): unify inline button capability parsing 2026-03-28 09:52:21 +05:30
Ayaan Zaidi
4a014083ff refactor(telegram): tighten api result typings 2026-03-28 09:52:21 +05:30
Ayaan Zaidi
9905f39e9d refactor(telegram): unify chat metadata parsing 2026-03-28 09:52:21 +05:30
Tak Hoffman
a4c64d82f8 fix(regression): preserve telegram pairing account context 2026-03-27 23:15:23 -05:00
Ayaan Zaidi
efef319496 refactor(telegram): tighten chat action typings 2026-03-28 09:41:18 +05:30
Ayaan Zaidi
4018d04d56 refactor(telegram): simplify runtime handler typing 2026-03-28 09:41:18 +05:30
Ayaan Zaidi
3a2bf0aa1f refactor(telegram): share chat lookup types 2026-03-28 09:41:18 +05:30
Peter Steinberger
cc9b2df97c test: stabilize telegram stalled-runner restart assertion 2026-03-28 03:51:16 +00:00
Peter Steinberger
550c51bb6e refactor: route telegram bot deps through channel runtime 2026-03-28 03:42:37 +00:00
Peter Steinberger
b34b03dd9e refactor: move channel dedupe helpers onto core sdk 2026-03-28 02:58:45 +00:00
Peter Steinberger
68416fdf83 refactor(acp): generalize message-channel binds 2026-03-28 02:53:54 +00:00
Peter Steinberger
491969efb0 refactor: route channel activity through channel runtime 2026-03-28 02:53:03 +00:00
Peter Steinberger
b171e42117 refactor: move telegram timing helpers onto runtime-env 2026-03-28 02:43:29 +00:00
Peter Steinberger
6a2c5b2b54 refactor: move telegram error formatting onto ssrf runtime 2026-03-28 02:38:02 +00:00
Peter Steinberger
6b4d097b25 refactor: route telegram env helpers through runtime-env 2026-03-28 02:34:11 +00:00
Peter Steinberger
4031bb1914 refactor: trim secret and ssrf helper runtime seams 2026-03-28 02:25:28 +00:00
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