# P8-012 Scratchpad — Gateway /agent, /provider, /mission, /prdy, /tools Commands

## Objective

Add gateway-executed commands: `/agent`, `/provider`, `/mission`, `/prdy`, `/tools`.
Key feature: `/provider login` OAuth flow with Valkey poll token.

## Plan

1. Read all relevant files (done)
2. Update `command-registry.service.ts` — add 5 new command registrations
3. Update `commands.module.ts` — wire Redis injection for executor
4. Update `command-executor.service.ts` — add 5 new command handlers + Redis injection
5. Write spec file for new commands
6. Run quality gates (typecheck, lint, format:check, test)
7. Commit and push

## Key Decisions

- Redis pattern: same as GCModule — use `REDIS` token injected from a QueueHandle factory
- `CommandDef` type fields: `scope: 'core'|'agent'|'skill'|'plugin'|'admin'`, `args?: CommandArgDef[]`, `execution: 'local'|'socket'|'rest'|'hybrid'`
- No `category` or `usage` fields — instruction spec was wrong on that
- `SlashCommandResultPayload.conversationId` is typed as `string` (not `string | undefined`) per the type
- Provider commands are `scope: 'agent'` since they relate to agent configuration
- Redis injection: add a `COMMANDS_REDIS` token in commands module, inject via factory pattern same as GCModule

## Progress

- [ ] command-registry.service.ts updated
- [ ] commands.module.ts updated (add Redis provider)
- [ ] command-executor.service.ts updated (add Redis injection + handlers)
- [ ] spec file written
- [ ] quality gates pass
- [ ] commit + push + PR

## Risks

- `conversationId` typing: `SlashCommandResultPayload.conversationId` is `string`, but some handler calls pass `undefined`. Need to check if it's optional.

After reviewing types: `conversationId: string` in `SlashCommandResultPayload` — not optional. Must pass empty string or actual ID. Looking at existing code: `message: 'Start a new conversation...'` returns `{ command, conversationId, ... }` where conversationId comes from payload which is always a string per `SlashCommandPayload`. For provider commands that don't have a conversationId, pass empty string `''` or the payload's conversationId.

Actually looking at the spec more carefully: `handleProvider` returns `conversationId: undefined`. But the type says `string`. This would be a TypeScript error. I'll use `''` as a fallback or adjust. Let me re-examine...

The `SlashCommandResultPayload` interface says `conversationId: string` — not optional. But the spec says `conversationId: undefined`. I'll use `payload.conversationId` (passing it through) since it comes from the payload.
