fix(gateway/auth): Implement proper auth/init flow with automatic background userId generation
- Fix getUserId() to use placeholder that triggers auth/init if the auth/init endpoint is down for whatever reason - Add silent auth/init attempt in AI services - Improve hosted mode error handling - Remove fake userId/email generation from init.js
This commit is contained in:
@@ -6278,6 +6278,19 @@
|
||||
],
|
||||
"priority": "medium",
|
||||
"subtasks": []
|
||||
},
|
||||
{
|
||||
"id": 94,
|
||||
"title": "Enhance Models Command with Mode Selection",
|
||||
"description": "Improve the `task-master models --setup` command to allow users to choose between BYOK (Bring Your Own Key) mode and hosted mode, not just configure AI models. Currently, users can only change modes during initial project setup, but they should be able to switch between modes at any time.",
|
||||
"details": "**Current State:**\n- Mode selection (BYOK vs hosted) only available during `task-master init` process\n- `task-master models --setup` only configures AI model selections within current mode\n- Mode is stored in `.taskmasterconfig` under `config.account.mode`\n- Error messages suggest using `task-master models --setup` to switch to BYOK mode, but this doesn't actually work\n\n**Required Implementation:**\n\n1. **Update `runInteractiveSetup()` function in `scripts/modules/commands.js`:**\n - Add mode selection as first step before model configuration\n - Show current mode and allow switching\n - Use same UI pattern as `scripts/init.js` `selectAccessMode()` function\n - Option to keep current mode or change to the other mode\n\n2. **Add mode switching logic:**\n - If switching from hosted to BYOK: Clear hosted tokens, show API key setup instructions\n - If switching from BYOK to hosted: Register with gateway, get user token\n - Update `config.account.mode` in `.taskmasterconfig`\n - Update `config.account.telemetryEnabled` (true for hosted, false for BYOK)\n\n3. **Add non-interactive mode switching flags:**\n - Add `--switch-to-byok` flag to models command\n - Add `--switch-to-hosted` flag to models command \n - Allow direct mode switching without interactive prompts\n\n4. **Update command help and examples:**\n - Add examples showing mode switching\n - Update description to mention mode selection capability\n\n**Technical Details:**\n\n- Import needed functions from `user-management.js`: `updateUserConfig`, `getUserMode`, `registerUserWithGateway`\n- Use existing `selectAccessMode()` logic from `scripts/init.js` as reference\n- Ensure mode changes are reflected immediately in subsequent AI calls\n- Handle gateway registration gracefully with proper error messages\n- Show clear confirmation of mode changes with next steps\n\n**User Experience Flow:**\n```\n$ task-master models --setup\n✓ Current Mode: BYOK\n? Do you want to:\n > Keep current mode (BYOK) and configure models\n Switch to Hosted mode\n Cancel\n\n[If switching to hosted]\n🎯 Hosted API Gateway Selected\n→ Registering with gateway...\n✅ Successfully switched to hosted mode\n→ All AI models are now available through the gateway\n→ No API keys needed in .env file\n\n[Then continue with model selection as normal]\n```\n\n**Files to Modify:**\n- `scripts/modules/commands.js` (main implementation)\n- `scripts/modules/task-manager/models.js` (if needed for MCP support)\n- Tests in `tests/integration/cli/` for new functionality\n\n**Success Criteria:**\n- Users can switch between BYOK and hosted mode via `task-master models --setup`\n- Non-interactive flags work: `--switch-to-byok` and `--switch-to-hosted`\n- Mode changes persist in `.taskmasterconfig`\n- Error handling for gateway connectivity issues\n- Clear user feedback about mode changes and next steps",
|
||||
"testStrategy": "**Testing Approach:**\n\n1. **Integration Tests:**\n - Test mode switching from BYOK to hosted and vice versa\n - Verify `.taskmasterconfig` updates correctly with new mode\n - Test non-interactive flags `--switch-to-byok` and `--switch-to-hosted`\n - Test error handling when gateway is unavailable\n\n2. **Manual Testing:**\n - Run `task-master models --setup` in both modes\n - Verify UI flow and user experience\n - Test AI calls work correctly after mode switches\n - Verify API key requirements/removal after mode changes\n\n3. **Unit Tests:**\n - Test mode detection and switching logic\n - Test configuration updates\n - Test error scenarios (gateway down, invalid config)\n\n4. **End-to-End Testing:**\n - Full workflow: init in one mode → switch mode → configure models → test AI calls\n - Verify MCP tool equivalents work correctly after mode changes",
|
||||
"status": "pending",
|
||||
"dependencies": [
|
||||
16
|
||||
],
|
||||
"priority": "high",
|
||||
"subtasks": []
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user