release: accept organizationId on POST /api/sessions (#620)
Merged
SW
6mo ago+140+140+012345678901234567890123456789-228-228-012345678901234567890123456789
Releases #620 to production.
Summary
POST /api/sessions now has the minimal body shape { title?, organizationId? }. The api derives the workspace clone URL itself via ensurePersonalRepo for both personal (auth.accountId) and org (auth.orgId) sessions. Callers no longer construct GitHub URLs.
Smoke tests on preview
- Brand-new agent (api key) → 200, creates
recoupable/<accountId>✓ - Privy Bearer + empty body → 200, returns existing
recoupable/<accountId>✓ - Privy Bearer +
{organizationId}for a real org → 200, returnsrecoupable/<orgId>✓ - Two different orgIds → two different cloneUrls ✓
- Cross-tenant attempt (other agent against Recoup org) → 403 ✓
- Non-UUID organizationId → 400 ✓
- Idempotency on both personal + org branches ✓
3,321 / 3,321 tests pass. Full audit trail in the PR comments.
Pairs with recoupable/docs#226 (already merged).
🤖 Generated with Claude Code
Summary by cubic
POST /api/sessions now accepts { title?, organizationId? } and derives the workspace repo URL server-side. Removed cloneUrl, branch, and sandboxType; the API auto‑provisions recoupable/<accountId | organizationId>.
-
Refactors
- Handler uses
ensurePersonalRepoand always setsclone_url; returns 502 on provisioning failure. - Validation requires
organizationIdto be a UUID and forwards it tovalidateAuthContextto setauth.orgId. buildSessionInsertRowhard-codesbranch: nullandsandbox_state: { type: "vercel" }; removedresolveSessionCloneUrland its tests.
- Handler uses
-
Migration
- Stop sending
cloneUrl,branch,sandboxType(and any repo fields). Onlytitleand optionalorganizationIdare accepted. - Send
organizationIdto create org-scoped sessions; omit it for personal sessions. - Invalid
organizationId→ 400; no org access → 403. Docs: recoupable/docs#226.
- Stop sending