← Back to PRs

#17054: Gateway: add commands.list method

by advaitpaliwal open 2026-02-15 10:54 View on GitHub →
gateway stale size: S trusted-contributor
## Summary - Problem: Web hook currently needs to hit an orchestrator HTTP route to list chat commands. - Why it matters: We want the web hook to call through the gateway WebSocket instead, and delete the HTTP route. - What changed: - Added gateway WS method `commands.list` that returns the chat command registry. - The payload now includes `args[]` (when present) and normalizes static `choices` values to `{ value, label }` pairs. - Wired it into method discovery + read-scope allowlists. - What did NOT change (scope boundary): No changes to web hook wiring, no removal of the existing orchestrator HTTP route yet. ## Change Type (select all) - [ ] Bug fix - [x] Feature - [ ] Refactor - [ ] Docs - [ ] Security hardening - [ ] Chore/infra ## Scope (select all touched areas) - [x] Gateway / orchestration - [ ] Skills / tool execution - [ ] Auth / tokens - [ ] Memory / storage - [ ] Integrations - [x] API / contracts - [ ] UI / DX - [ ] CI/CD / infra ## Linked Issue/PR - Related: (follow-up PR will remove orchestrator HTTP route) ## User-visible / Behavior Changes - Adds gateway WS method `commands.list` (read-scoped) and includes it in the gateway method list. - `commands.list` now returns command `args` and static arg `choices` (dynamic/function choices are omitted). ## Security Impact (required) - New permissions/capabilities? (`No`) - Secrets/tokens handling changed? (`No`) - New/changed network calls? (`No`) - Command/tool execution surface changed? (`No`) - Data access scope changed? (`No`) ## Repro + Verification ### Environment - OS: macOS - Runtime/container: Node 22+ ### Steps 1. Call gateway WS method `commands.list` as an `operator` client with `operator.read`. ### Expected - Returns an array of command descriptors, including `args` and static `choices`. ## Evidence - [x] Passing tests: `pnpm build && pnpm check && pnpm test` ## Human Verification (required) - Verified scenarios: unit test for scope gating + payload mapping (`src/gateway/server-methods/commands.test.ts`). - Edge cases checked: fallback name to `key`, fallback category to `general`, and normalization of string choices. - What you did **not** verify: manual web hook integration (done in follow-up). ## Compatibility / Migration - Backward compatible? (`Yes`) - Config/env changes? (`No`) - Migration needed? (`No`) ## Failure Recovery (if this breaks) - Revert commit(s) that introduce/extend `commands.list`. ## Risks and Mitigations - Risk: exposing a method without correct scoping. - Mitigation: `commands.list` is in `READ_METHODS` with a unit test verifying `operator.read` is required. ## AI-assisted disclosure This PR was authored with AI assistance (Codex). Tests were run locally. <!-- greptile_comment --> <h3>Greptile Summary</h3> Added gateway WebSocket method `commands.list` that returns chat command registry metadata. The method is properly scoped to `operator.read`, included in gateway method discovery, and normalizes command args by: - Using `nativeName` as fallback to `key` for the command name - Defaulting missing `category` to `"general"` - Converting static string choices to `{ value, label }` pairs - Filtering out dynamic/function choices (sets to `undefined`) The implementation includes comprehensive test coverage verifying scope gating and payload mapping. No changes to web hook wiring or orchestrator HTTP route removal (intentionally deferred to follow-up PR). <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The implementation is clean, well-tested, and follows existing patterns. Scope gating is correctly implemented, the method is read-only (no side effects), and test coverage verifies both authorization and payload mapping. The changes are additive (no breaking changes) and properly integrate with the existing gateway method registration system. - No files require special attention <sub>Last reviewed commit: 2fdbe86</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs