#17054: Gateway: add commands.list method
gateway
stale
size: S
trusted-contributor
Cluster:
Gateway and Hooks Enhancements
## 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
#13537: Gateway: add commands.list slash command metadata API
by Pyiner · 2026-02-10
83.5%
#12802: fix(gateway): default unscoped operator connections to read-only
by yubrew · 2026-02-09
75.0%
#23410: Gateway: require prefixes for hook request session-key overrides
by bmendonca3 · 2026-02-22
74.8%
#21651: fix(gateway): token fallback + operator.admin scope superset in pai...
by lan17 · 2026-02-20
73.6%
#22926: feat(gateway): add Windows-native watch DX and tool/channel observa...
by Kansodata · 2026-02-21
73.3%
#22091: docs(readme): add Windows-native dev gateway command
by Kansodata · 2026-02-20
73.2%
#12635: Gateway: add inbound webhook dispatch framework
by jhs129 · 2026-02-09
73.0%
#20381: feat(gateway): make chat history byte limit configurable via `gatew...
by mgratch · 2026-02-18
72.4%
#21622: fix(gateway): include read/write in CLI default operator scopes
by zerone0x · 2026-02-20
72.1%
#20541: fix(hooks): clear internal hooks before plugins register
by ramarnat · 2026-02-19
72.0%