Commit Graph

2669 Commits

Author SHA1 Message Date
Peter Steinberger b568ccee7c refactor: route litellm sdk through public api barrel 2026-03-27 17:23:40 +00:00
Peter Steinberger e599cb26de refactor: route provider catalogs through public api barrels 2026-03-27 17:23:40 +00:00
Peter Steinberger ef1784d264 refactor: move bundled plugin policy into manifests 2026-03-27 16:40:27 +00:00
Peter Steinberger ed055f44ae refactor: route plugin runtime through bundled seams 2026-03-27 16:40:27 +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 9098e948ac fix(ci): route extension tests through public test bridges 2026-03-27 15:20:01 +00:00
Peter Steinberger 6a0f9afc4e style: normalize test and sdk formatting 2026-03-27 15:15:04 +00:00
Peter Steinberger 8ddeada97d test: move extension-owned coverage into plugins 2026-03-27 15:11:33 +00:00
Peter Steinberger 97297049e7 fix(ci): restore boundary and test seams 2026-03-27 15:08:33 +00:00
Peter Steinberger 87dddb818d fix(ci): restore plugin runtime boundaries 2026-03-27 14:38:40 +00:00
Peter Steinberger 66a2e72bee fix: restore CI runtime seams 2026-03-27 14:07:01 +00:00
Peter Steinberger 9d10a2e242 refactor: shrink remaining test seam reach-ins 2026-03-27 13:46:17 +00:00
Peter Steinberger f217a10780 refactor: route more runtime-boundary tests through public seams 2026-03-27 13:46:17 +00:00
Peter Steinberger 9917f3b3a1 refactor: route ollama sdk through public barrels 2026-03-27 13:46:17 +00:00
Peter Steinberger 858b1dffb8 refactor: route zalouser payload mocks through test api 2026-03-27 13:46:17 +00:00
Peter Steinberger b70b99d46d refactor: route telegram gateway test through test api 2026-03-27 13:46:17 +00:00
Peter Steinberger 169bf6adba refactor: route outbound payload tests through extension test seams 2026-03-27 13:46:17 +00:00
Peter Steinberger c7b4c34e89 refactor: route provider test seams through extension barrels 2026-03-27 13:46:17 +00:00
Peter Steinberger 4019671331 refactor: add runtime-boundary plugin test seams 2026-03-27 13:46:17 +00:00
Peter Steinberger c2b28753e7 refactor: route more test seams through public plugin APIs 2026-03-27 13:46:17 +00:00
Peter Steinberger 4d630b7e92 refactor: expose dm policy test seams 2026-03-27 13:46:17 +00:00
Peter Steinberger 45849eb757 refactor: remove remaining core extension reach-ins 2026-03-27 13:46:16 +00:00
Peter Steinberger fc3246d8fd refactor: add public channel contract test seams 2026-03-27 13:46:16 +00:00
Peter Steinberger 04bde8c2b1 refactor: route session-binding contract tests through public seams 2026-03-27 13:46:16 +00:00
Peter Steinberger 8d39fe5a76 refactor: route channel contract tests through public barrels 2026-03-27 13:46:16 +00:00
Peter Steinberger 051d6f9342 refactor: remove onboarding gateway compat shims 2026-03-27 13:46:16 +00:00
Peter Steinberger 7999577ce1 refactor: route plugin sdk through extension barrels 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 bcfddcc768
refactor: pluginize litellm auth onboarding 2026-03-27 12:26:01 +00:00
Anmol Ahuja c40884d306
Prefer non-user writeable paths (#54346)
* infra: trust system binary roots

* infra: isolate windows install root overrides

* infra: narrow windows reg lookup

* browser: restore windows executable comments

---------

Co-authored-by: Jacob Tomlinson <jtomlinson@nvidia.com>
2026-03-27 11:29:32 +00:00
Ted Li 4d5f762b7d
fix: fall back from synthetic tool accounts (#55627) (thanks @MonkeyLeeT)
* feishu: fall back from synthetic tool accounts

* feishu: validate implicit tool accounts by config id

* fix: fall back from synthetic tool accounts (#55627) (thanks @MonkeyLeeT)

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-03-27 15:09:36 +05:30
Ayaan Zaidi ae72977076
fix(agents): restore ollama public seam 2026-03-27 12:46:34 +05:30
Tak Hoffman 23fae00fad
Reduce script logging suppressions and Feishu any casts 2026-03-27 02:12:56 -05:00
Tak Hoffman f5643544c2
Reduce lint suppressions in core tests and runtime 2026-03-27 02:11:26 -05:00
Peter Steinberger 7c00cc9d0a test: fix feishu batch insert test syntax 2026-03-27 07:10:55 +00:00
Peter Steinberger 854b71a4b0 test: fix feishu test typings 2026-03-27 07:10:55 +00:00
Ayaan Zaidi cfddce4196
fix(feishu): restore tsgo test typing 2026-03-27 12:13:59 +05:30
Peter Steinberger a3e73daa6b refactor: remove ollama legacy shims 2026-03-27 06:38:23 +00:00
Ayaan Zaidi bd2c208689
refactor(mattermost): type config seams 2026-03-27 11:59:02 +05:30
Ayaan Zaidi f2b2b12af4
test(feishu): type bot interaction fixtures 2026-03-27 11:54:23 +05:30
Ayaan Zaidi 59a25978dd
test(feishu): type reply lifecycle fixtures 2026-03-27 11:54:23 +05:30
Ayaan Zaidi 6ad50ce474
test(feishu): type tool harness fixtures 2026-03-27 11:54:23 +05:30
Ayaan Zaidi 1042710e3b
test(feishu): type policy fixtures 2026-03-27 11:54:23 +05:30
Ayaan Zaidi b23dc5073f
test(feishu): type basic fixtures 2026-03-27 11:54:23 +05:30
Peter Steinberger e3e9a56b02 fix: export matrix account helpers in runtime api 2026-03-27 06:06:37 +00:00
Ayaan Zaidi 9db096a98f
refactor(feishu): remove docx explicit-any escapes 2026-03-27 11:34:35 +05:30
Ayaan Zaidi 571d4d52e9
refactor(feishu): remove stale explicit-any escapes 2026-03-27 11:34:35 +05:30
Ayaan Zaidi f248fc8f86
refactor(feishu): type runtime payload seams 2026-03-27 11:34:35 +05:30