feat(auth): guided credential flow — prompt for token and retry

When a thread completes with authentication_required, the router
enters "auth mode" for that user:

1. Detects credential_name from the error in the thread response
2. Looks up setup_instructions from the skill's credential spec
3. Emits AuthRequired to CLI/gateway with instructions
4. Stores PendingAuth — next user message is treated as a token
5. Stores the token in SecretsStore
6. Retries the original user request automatically

CLI flow:
  › create an issue in github
    ⚿ Authentication required: github_token
      Create a PAT at https://github.com/settings/tokens
    Paste your token below (or type 'cancel'):
  › ghp_abc123...
    ✓ github_token authenticated: Credential stored. Retrying...
    ● http(https://api.github.com/repos/.../issues)
    Issue created: https://github.com/...

Gateway flow: same but AuthRequired SSE event shows the auth modal.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
2026-03-28 00:32:14 -07:00
co-authored by Claude Opus 4.6
parent 4d643f47c7
commit 5563b53e52
2 changed files with 165 additions and 0 deletions
+5
View File
@@ -133,6 +133,11 @@ impl ToolRegistry {
self.credential_registry.as_ref()
}
/// Get a reference to the secrets store (for credential storage during auth flows).
pub fn secrets_store(&self) -> Option<&Arc<dyn SecretsStore + Send + Sync>> {
self.secrets_store.as_ref()
}
/// Get the shared rate limiter for checking built-in tool limits.
pub fn rate_limiter(&self) -> &RateLimiter {
&self.rate_limiter