fix(cli): canonicalize cloud URL and rewrite agent-relay error hints#117
Conversation
The customer hit two stacked CLI bugs in one deploy: - ensureAuthenticated occasionally returns auth.apiUrl pointing at the SST edge-bypass hostname (origin.agentrelay.cloud). Persisting that into active.json sends every subsequent API call cross-subdomain, where session cookies and Bearer tokens don't validate, so every call 401s. - The 401 hint then told `agentworkforce` users to run `agent-relay cloud whoami` / `agent-relay cloud login`, which they don't have. Add canonicalizeCloudUrl() and apply it at every CLI write/consume site for the cloud URL (login --cloud-url, ensureAuthenticated result, writeActiveWorkspace, resolveWorkspaceToken). Known-bypass hostnames (origin.*, *.agentrelay.cloud) remap to https://agentrelay.com/cloud; localhost and unrelated tenants pass through untouched. Rewrite the 401 / 403 error strings in relayfileIntegrationResolver so they point at `agentworkforce login` instead of `agent-relay cloud whoami`, and drop the hardcoded origin.agentrelay.cloud URL from the hint text. Same sweep across help / usage strings. Tests cover the canonicalization table, the login-time canonicalization end-to-end (origin.* apiUrl -> public canonical written), and a relayfileIntegrationResolver 401 surfacing the new agentworkforce-native hint (regex match so future copy-edits don't break it). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThis PR introduces cloud URL canonicalization to normalize ChangesCloud URL Canonicalization
🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
The first customer (proactive-agents) hit two stacked deploy-time bugs:
Bug A — error messages tell `agentworkforce` users to run `agent-relay` commands they don't have. Rewritten across `connect.ts` / `deploy-command.ts` (help / usage strings) so users are only ever pointed at `agentworkforce login --workspace `. `origin.agentrelay.cloud` hardcoded URL stripped from the hint.
Bug B — `ensureAuthenticated` occasionally returns `auth.apiUrl` pointing at the SST edge-bypass hostname (`origin.agentrelay.cloud`). Persisting that into `active.json` sends every subsequent API call cross-subdomain where session cookies and Bearer tokens don't validate, so every call 401s. CLI-side mitigation: `canonicalizeCloudUrl()` maps known-bypass hostnames (`origin.`, `.agentrelay.cloud`) → `https://agentrelay.com/cloud\` and is applied at every CLI write/consume site for the cloud URL.
The proper structural fix is cloud-side (handler should emit a configured public URL, never `request.url`). Tracking issue: AgentWorkforce/cloud#TBD.
Test plan
Sites where canonicalizeCloudUrl is now called
Error-message rewrites
🤖 Generated with Claude Code