Skip to content

feat(trigger-sdk): add streamBaseURL to TriggerChatTransport#3641

Open
ericallam wants to merge 1 commit into
mainfrom
feat/chat-transport-stream-base-url
Open

feat(trigger-sdk): add streamBaseURL to TriggerChatTransport#3641
ericallam wants to merge 1 commit into
mainfrom
feat/chat-transport-stream-base-url

Conversation

@ericallam
Copy link
Copy Markdown
Member

@ericallam ericallam commented May 16, 2026

TriggerChatTransport had a single baseURL option covering both the .in/append POSTs and the long-lived .out SSE subscription. Customers wanting to route the SSE through a proxy (e.g. a Cloudflare worker capturing JA4 fingerprints for bot detection) had to send every append through the proxy too, adding a hop to every user message.

New optional streamBaseURL overrides the SSE base URL only; appends keep using baseURL. Falls back to baseURL when unset, so existing transports are unchanged.

const transport = new TriggerChatTransport({
  task: "ai-chat",
  baseURL: "https://api.trigger.dev",
  streamBaseURL: "https://chat-proxy.example.com",
  accessToken,
  startSession,
});

Verified with a new test in chat.test.ts that asserts .in/append routes through baseURL and .out SSE routes through streamBaseURL. All existing tests still pass.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 16, 2026

⚠️ No Changeset found

Latest commit: 9cba92b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ericallam ericallam marked this pull request as draft May 16, 2026 08:04
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1315ab4f-67c5-42e6-bcb9-4ca698b687f6

📥 Commits

Reviewing files that changed from the base of the PR and between ef6e907 and 9cba92b.

📒 Files selected for processing (2)
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/trigger-sdk/src/v3/chat.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (25)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: sdk-compat / Node.js 20.20 (ubuntu-latest)
  • GitHub Check: sdk-compat / Deno Runtime
  • GitHub Check: sdk-compat / Node.js 22.12 (ubuntu-latest)
  • GitHub Check: sdk-compat / Cloudflare Workers
  • GitHub Check: sdk-compat / Bun Runtime
  • GitHub Check: packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)

Walkthrough

This PR adds an optional streamBaseURL configuration option to TriggerChatTransport to route long-lived SSE subscriptions to a separate base URL while keeping other session API calls on baseURL. The transport stores streamBaseURL (defaulting to baseURL when unset) and uses it when constructing the /realtime/v1/sessions/{chatId}/out SSE URL. A new test verifies .in/append requests use baseURL and .out subscriptions use streamBaseURL.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a streamBaseURL option to TriggerChatTransport.
Description check ✅ Passed The description covers the rationale, implementation details, usage example, and testing approach; all key template sections are addressed with substantive content.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/chat-transport-stream-base-url

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.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@ericallam ericallam marked this pull request as ready for review May 16, 2026 08:22
@ericallam ericallam enabled auto-merge (squash) May 16, 2026 15:34
Splits the SSE subscription URL from the append URL so the long-lived
session.out stream can be routed through a custom proxy (e.g. a
Cloudflare worker capturing JA4 fingerprints for bot detection) while
keeping .in/append POSTs direct to baseURL.

Falls back to baseURL when unset, so existing transports are unchanged.
@ericallam ericallam force-pushed the feat/chat-transport-stream-base-url branch from ef6e907 to 9cba92b Compare May 16, 2026 15:57
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