Skip to content

feat(sdk): make token optional and accept relative baseUrl in TS SDK#1509

Closed
jsell-rh wants to merge 4 commits intomainfrom
jsell/feat/sdk-browser-support
Closed

feat(sdk): make token optional and accept relative baseUrl in TS SDK#1509
jsell-rh wants to merge 4 commits intomainfrom
jsell/feat/sdk-browser-support

Conversation

@jsell-rh
Copy link
Copy Markdown
Contributor

@jsell-rh jsell-rh commented May 5, 2026

Summary

  • Make token and project optional in AmbientClientConfig to enable browser-side SDK usage (where auth is handled by cookies/proxy)
  • Accept relative baseUrl paths (e.g. /api/proxy) by skipping new URL() validation for paths starting with /
  • Conditionally send Authorization and X-Ambient-Project headers only when values are present
  • Sub-resource APIs (Agent, Credential, InboxMessage, ScheduledSession, SessionMessage) throw a clear error when project is needed but absent
  • Fix template drift: templates now match generated output for optional project
  • fromEnv() still requires AMBIENT_TOKEN (server-side use case) but makes AMBIENT_PROJECT optional
  • Fix pre-existing Go SDK compilation: add missing Timeout, InactivityTimeout, StopOnRunFinished, RunnerType fields to ScheduledSession types

Test plan

  • All existing jest tests pass (npm test in ts-sdk/)
  • TypeScript compiles cleanly (tsc --noEmit)
  • Go SDK compiles cleanly (go vet ./...)
  • CLI compiles cleanly (go vet ./... in ambient-cli/)
  • New tests added: client without token (browser mode), client without project, client with relative baseUrl, fromEnv() without AMBIENT_PROJECT
  • Manual verification: import SDK in a browser context with relative baseUrl and no token

🤖 Generated with Claude Code

jsell-rh and others added 3 commits May 5, 2026 15:34
Enable browser-side usage of the TS SDK by making token and project
optional in AmbientClientConfig, conditionally sending Authorization
and X-Ambient-Project headers only when values are present, and
accepting relative baseUrl paths (e.g. "/api/proxy") that skip URL
parsing. Sub-resource APIs throw a clear error when project is needed
but absent. Templates are updated to fix drift with generated output.

Includes full SDK regeneration (Go, Python, TS) from latest spec.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The full SDK regeneration introduced conflicts with hand-written Go
extension files (agent_extensions.go, session_messages.go) that depend
on client methods not present in the generator templates. Reverting
Go and Python SDKs to main state; this PR focuses on TS SDK changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Timeout, InactivityTimeout, StopOnRunFinished, and RunnerType
fields to ScheduledSession, ScheduledSessionPatch, and their builders.
These fields exist in the OpenAPI spec but were missing from the Go
SDK, causing compilation failures in the CLI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 65f6c8ec-d86f-4cef-9644-f985ca72fcf8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jsell/feat/sdk-browser-support
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch jsell/feat/sdk-browser-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for cheerful-kitten-f556a0 canceled.

Name Link
🔨 Latest commit 8f593e5
🔍 Latest deploy log https://app.netlify.com/projects/cheerful-kitten-f556a0/deploys/69fa121cb4b9be00080aa464

…col-relative URLs

Templates are the source of truth for SDK generation. The prior commit
updated generated output but not templates, which would be reverted on
next regeneration. Also rejects // URLs to prevent protocol-relative
URL exploitation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jsell-rh
Copy link
Copy Markdown
Contributor Author

jsell-rh commented May 5, 2026

Superseded by #1513 (consolidated SDK PR with full regeneration)

@jsell-rh jsell-rh closed this May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant