Commit Graph

716 Commits

Author SHA1 Message Date
Peter Steinberger
48b2eb2604 test: fix media and channel regression expectations 2026-03-28 08:10:47 +00:00
Peter Steinberger
f4fb45f1ee test: dedupe channel helper suites 2026-03-28 08:10:47 +00:00
Peter Steinberger
71a3ad153a fix(ci): stabilize bundled capability contract loading 2026-03-28 07:33:19 +00:00
Peter Steinberger
f36354e401 test: dedupe pairing and channel contract suites 2026-03-28 07:31:40 +00:00
Peter Steinberger
d69f20f451 fix: harden bundled channel runtime bootstrap 2026-03-28 07:10:05 +00:00
Peter Steinberger
83135c31c9 refactor(acp): extract generic current conversation binding store 2026-03-28 05:53:07 +00:00
Peter Steinberger
687d23ae8d test: restore extension boundary guardrails 2026-03-28 04:47:31 +00:00
Peter Steinberger
49968982a5 fix(plugin-sdk): avoid testing export drift 2026-03-28 03:53:38 +00:00
Peter Steinberger
ec9f96cb2a refactor(plugin-sdk): align binding contract imports 2026-03-28 03:53:38 +00:00
Peter Steinberger
d0d4b73d25 refactor(acp): centralize conversation binding context 2026-03-28 03:53:38 +00:00
Peter Steinberger
68416fdf83 refactor(acp): generalize message-channel binds 2026-03-28 02:53:54 +00:00
Peter Steinberger
c69a70714c test: harden contract registry fixtures 2026-03-28 02:49:49 +00:00
Peter Steinberger
c42ec81e37 feat(acp): add conversation binds for message channels 2026-03-28 01:54:25 +00:00
Peter Steinberger
fef688fb7a test: dedupe utility and config suites 2026-03-28 00:26:55 +00:00
Peter Steinberger
fc5e5f1e8e fix: resolve loader and test fallout after sdk split 2026-03-27 23:27:55 +00:00
Peter Steinberger
c52f89bd60 test: dedupe helper-heavy test suites 2026-03-27 22:35:27 +00:00
Peter Steinberger
c815bddce7 test: debrand debounce and acp lifecycle fixtures 2026-03-27 22:03:51 +00:00
Peter Steinberger
d27b99c6af test: debrand helper fixture ids 2026-03-27 22:01:15 +00:00
Peter Steinberger
884247f8d8 test: debrand generic setup helper fixtures 2026-03-27 21:57:58 +00:00
Peter Steinberger
2019b649af test: debrand generic session binding fixtures 2026-03-27 21:54:56 +00:00
Peter Steinberger
a9cc830ded test: debrand generic outbound channel fixtures 2026-03-27 21:53:19 +00:00
Peter Steinberger
a50455452d test: debrand plumbing labels and restore skill compat 2026-03-27 21:50:39 +00:00
Peter Steinberger
03e7e3cd27 test: debrand generic channel fixture names 2026-03-27 21:48:05 +00:00
Peter Steinberger
76d3c67a88 test: debrand session and allowlist placeholders 2026-03-27 21:45:29 +00:00
Peter Steinberger
992b30604d refactor: move extension-owned tests to extensions 2026-03-27 21:37:09 +00:00
Peter Steinberger
d73dbb6753 fix: restore provider auth and build checks 2026-03-27 20:20:31 +00:00
Peter Steinberger
c9d68fb9c2 fix: repair ci test and loader regressions 2026-03-27 18:41:47 +00:00
Peter Steinberger
8d054e7892 test: move shared seams into contract suites 2026-03-27 16:33:53 +00:00
Peter Steinberger
8ff39007c4 test: remove moved core duplicates 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
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
b5a8d5a230 fix: stabilize plugin-sdk test loading 2026-03-27 13:46:17 +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
858b1dffb8 refactor: route zalouser payload mocks through test api 2026-03-27 13:46:17 +00:00
Peter Steinberger
d0c77c9dfd refactor: narrow outbound payload runtime mock reach-ins 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
c2b28753e7 refactor: route more test seams through public plugin APIs 2026-03-27 13:46:17 +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
a10763e118 refactor: generate bundled channel seams 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
ef56d79a6a refactor: collapse zod setup validators 2026-03-27 03:48:15 +00:00
Peter Steinberger
e6c5ce136e refactor: share zod setup validators across channels 2026-03-27 03:41:40 +00:00
Peter Steinberger
40bd36e35d refactor: move channel config metadata into plugin-owned manifests 2026-03-27 01:59:30 +00:00
Peter Steinberger
bfad32aa16 refactor: share directory config listers 2026-03-26 23:20:26 +00:00