Skip to content

feat(typescript-web): implement browser and Workers runtimes - #4006

Merged
sxlijin merged 1 commit into
canaryfrom
sam/bridge-web
Jul 20, 2026
Merged

sxlijin merged 1 commit into
canaryfrom
sam/bridge-web

Conversation

@sxlijin

@sxlijin sxlijin commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • integrate the TypeScript Web bridge with the shared engine and TypeScript runtime APIs
  • fill out browser and Cloudflare Workers system operations and connect generated SDKs to the functional runtime
  • remove the Web and Workers Vitest ignore annotations once the complete SDK surface is available

Stack

This PR is based on #4091. The parent provides the independently buildable raw WebAssembly runtime, target-gated CFFI hooks, packaging, and focused browser/workerd tests. This PR layers the shared engine and TypeScript API changes plus full generated SDK parity on top.

Validation

  • cargo nextest run -p sdk_test_typescript_web -E all() --no-fail-fast: 26 passed, 0 skipped
  • TypeScript Web SDK matrix passes on Linux, macOS, and Windows
  • mise run fmt, mise run stow, and mise run clippy pass

Summary by CodeRabbit

  • New Features
    • Added Web runtime sysops for HTTP _fetch/_send and synchronous filesystem reads.
    • Expanded the Web bridge with runtime initialization, plus exported handle/media utilities and host-call lifecycle support.
    • Added getVersion/flushEvents and strengthened call-context lifecycle handling for Web.
  • Bug Fixes
    • Improved host-value/callable validation, stricter error/panic decoding, and safer cancellation/detach behavior.
    • Enhanced type-context conversions for arrays/maps/instance fields.
  • Tests
    • Expanded SDK Web test coverage (Web + Workers) and improved fixture harness generation.
  • Chores
    • Refreshed size-gate baselines and updated Web wasm/type declaration sync tooling.

@vercel

vercel Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment Jul 20, 2026 10:14am
promptfiddle Ready Ready Preview, Comment Jul 20, 2026 10:14am
promptfiddle2 Ready Ready Preview, Comment Jul 20, 2026 10:14am

Request Review

@vercel
vercel Bot temporarily deployed to Preview – beps July 13, 2026 21:52 Inactive
@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@vercel
vercel Bot temporarily deployed to Preview – beps July 13, 2026 21:53 Inactive

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4b0211ed7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread baml_language/Cargo.toml Resolved
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds browser system operations, WASM runtime and host-value bindings, handle/media lifecycle support, TypeScript Web and Workers execution, typed SDK runtime integration, expanded cross-runtime tests, and refreshed size-gate records.

Changes

WASM runtime and bridge

Layer / File(s) Summary
Runtime conversion and handle foundations
baml_language/crates/{bex_engine,bridge_cffi,bridge_ctypes,sys_ops}/...
Threads declared types through host-value conversion, adds callable validation, centralizes CFFI handle/media operations, tracks originating runtimes for cancellation, and adds targeted SysOps overrides.
Host-value dispatch and browser SysOps
baml_language/crates/sys_wasm/..., baml_language/crates/bridge_wasm/...
Adds in-flight host-call bookkeeping, release callbacks, direct/runtime dispatch modes, browser HTTP and filesystem-read operations, structured result parsing, and expanded WASM exports.
WASM Web bindings
baml_language/sdks/typescript/bridge_typescript_web/src/..., .../wasm/bridge_web_core.d.ts
Exposes runtime staging/calls, handle and media operations, host-value functions, stable setup errors, typed initialization, and generated declaration synchronization.

TypeScript SDK integration

Layer / File(s) Summary
TypeScript runtime lifecycle
baml_language/sdks/typescript/bridge_typescript/{typescript_src,tests}/..., baml_language/sdks/typescript/bridge_typescript_web/typescript_src/...
Adds reusable call-context bindings, validates cancellation IDs, preserves structured error details, rolls back host values transactionally, wires native runtime calls to WASM, and rejects unsupported synchronous stream pulls on Web.
Generated SDK runtime ownership
baml_language/sdks/typescript/sdkgen_typescript_shared/src/...
Generated function options now carry $ctx; runtime-owned built-ins re-export from configured bridge packages; typemap tests verify constructor identity and leaf mappings.
Web and Workers harness
baml_language/sdk_tests/crates/typescript_web/*, baml_language/sdk_tests/harness_setup/src/*, baml_language/sdks/typescript/bridge_typescript_web/{package.json,scripts/*,vitest*.ts,wrangler.test.jsonc}
Adds browser and Workers configurations, Workerd preparation and declaration checks, active Vitest fixture tests, updated setup scripts, and expanded Web runtime test execution.
Cross-runtime SDK coverage
baml_language/sdk_tests/crates/typescript/*, baml_language/sdk_tests/crates/typescript_web/tests/*, baml_language/sdk_tests/fixtures/*
Expands cancellation, host-callable, media, handle, typemap, bridge-surface, Web SysOps, runtime-error, and WASM-export coverage.

Supporting updates

Layer / File(s) Summary
Artifact size-gate refresh
baml_language/.cargo/size-gate.toml, baml_language/.ci/size-gate/*
Updates platform ceilings, build metadata, and measured artifact sizes.
Documentation and public surface
baml_language/sdk_tests/{README.md,DEVELOPMENT.md}, baml_language/crates/sys_wasm/src/send_wrapper.rs, baml_language/crates/bex_vm_types/src/bytecode.rs
Documents active Web/Workers coverage, promotes send wrappers, and changes the no-stack-trace sentinel to u32::MAX as usize.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SDK
  participant WebBridge
  participant BridgeCffi
  participant SysWasm
  participant HostCallable
  SDK->>WebBridge: initialize runtime and configure sysops
  WebBridge->>BridgeCffi: stage sources or bytecode
  BridgeCffi->>SysWasm: build browser HTTP/filesystem sysops
  SDK->>WebBridge: call function
  WebBridge->>BridgeCffi: execute call
  BridgeCffi->>SysWasm: dispatch host/sysop operation
  SysWasm->>HostCallable: invoke fetch or readFileSync
  HostCallable-->>SysWasm: return structured result
  SysWasm-->>BridgeCffi: complete call
  BridgeCffi-->>SDK: encoded result or structured error
Loading

Possibly related PRs

Poem

A rabbit hops where WASM streams,
With handles, calls, and browser dreams.
Errors land with traces bright,
Web tests run in morning light.
“Hop hop!” says Bunny—bridge done right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: implementing browser and Workers runtimes for the TypeScript web bridge.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ 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 sam/bridge-web

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.

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 13, 2026 22:00 Inactive
@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 25.3 MB 10.7 MB file 25.3 MB +1.5 KB (+0.0%) OK
✅ packed-program Linux 🔒 17.0 MB 7.0 MB file 17.0 MB +4.1 KB (+0.0%) OK
✅ baml-cli macOS 🔒 19.6 MB 9.3 MB file 19.5 MB +16.5 KB (+0.1%) OK
✅ packed-program macOS 🔒 13.2 MB 6.2 MB file 13.2 MB +0 B (+0.0%) OK
✅ baml-cli Windows 🔒 21.1 MB 9.5 MB file 21.1 MB +1.0 KB (+0.0%) OK
✅ packed-program Windows 🔒 14.1 MB 6.2 MB file 14.1 MB +1.0 KB (+0.0%) OK
✅ bridge_wasm WASM 16.2 MB 🔒 4.4 MB gzip 4.4 MB +4.9 KB (+0.1%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 13, 2026 22:13 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (6)
baml_language/sdks/web/bridge_web/Cargo.toml (1)

1-6: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Consider publish = false for this internal-only wasm crate.

bridge_web is built for browser distribution via wasm-pack/npm, not crates.io. The sibling new crate sdkgen_typescript_web/Cargo.toml explicitly sets publish = false; this crate lacks it, risking an accidental cargo publish.

♻️ Suggested fix
 [package]
 name = "bridge_web"
 version.workspace = true
 edition.workspace = true
 authors.workspace = true
 license.workspace = true
+publish = false
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/web/bridge_web/Cargo.toml` around lines 1 - 6, Mark the
internal-only bridge_web package as non-publishable by adding the Cargo
publish=false setting in its [package] metadata, matching the existing
sdkgen_typescript_web crate configuration.
baml_language/crates/bridge_cffi/src/lib.rs (1)

12-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Module-level wasm32 gate blocks native unit testing of the new bridge scaffold. wasm.rs only depends on std::sync::atomic, but gating mod wasm; itself (not just the re-export) to target_arch = "wasm32" means its logic is excluded from ordinary host builds/tests.

  • baml_language/crates/bridge_cffi/src/lib.rs#L12-L15: only gate pub use wasm::*; to wasm32; leave mod wasm; ungated so it compiles (and can be tested) on the host toolchain too.
  • baml_language/crates/bridge_cffi/src/wasm.rs#L15-L35: once the gate is relaxed, add #[cfg(test)] unit tests for stage_runtime_bytecode (empty vs. non-empty bytecode) and call_function_in_wasm (before/after staging) — this logic has no wasm-only dependency and is trivially testable on the host.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/crates/bridge_cffi/src/lib.rs` around lines 12 - 15, Make the
wasm module declaration in baml_language/crates/bridge_cffi/src/lib.rs lines
12-15 unconditional, while keeping only pub use wasm::* gated to target_arch =
"wasm32". In baml_language/crates/bridge_cffi/src/wasm.rs lines 15-35, add
#[cfg(test)] unit tests covering stage_runtime_bytecode with empty and non-empty
bytecode, plus call_function_in_wasm before and after staging.

Source: Coding guidelines

baml_language/sdk_tests/harness_runner/src/lib.rs (1)

278-288: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a unit test for import_from_specifier.

This is a pure, easily-testable function (no fixtures needed) backing a new correctness guard; a #[cfg(test)] unit test covering quoted/single-quoted imports and non-matching lines would catch regressions cheaply.

Separately, note it only matches lines with " from ", so side-effect-only imports (import "pkg";) or dynamic import("pkg") calls bypass the extensionless-import check — likely fine given generated code conventions, but worth confirming generated SDKs never emit those forms.

As per coding guidelines, "Prefer writing Rust unit tests over integration tests where possible."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdk_tests/harness_runner/src/lib.rs` around lines 278 - 288,
Add a #[cfg(test)] unit test module for import_from_specifier covering
double-quoted imports, single-quoted imports, and non-matching lines, including
lines without the exact " from " pattern. Keep the test focused on this pure
helper and assert the expected Option<&str> results.

Source: Coding guidelines

baml_language/sdks/web/bridge_web/typescript_src/index.ts (1)

58-66: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

BamlStream.next()/final() aren't gated behind the same "not implemented" guard as the async iterator.

[Symbol.asyncIterator] explicitly throws "bridge_cffi WASM streaming is not implemented yet", but next()/final() (Lines 59, 61) will attempt a real invoke() call and cast the raw bytes as TPartial/as TFinal. Calling these directly today will fail confusingly deep inside invoke() rather than with the same clear "not implemented" message.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/web/bridge_web/typescript_src/index.ts` around lines 58 -
66, Update BamlStream.next() and BamlStream.final() to use the same immediate
“bridge_cffi WASM streaming is not implemented yet” guard as
[Symbol.asyncIterator], instead of calling invoke and casting a result. Keep
nextAsync() and finalAsync() delegating to those guarded methods so all stream
accessors fail consistently.
baml_language/sdk_tests/harness_setup/src/typescript_web.rs (1)

109-169: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider unit tests for the pure helper functions.

rewrite_test_bridge_imports and has_vitest_tests are self-contained filesystem-predicate/transform helpers that don't need the full build-script context to test (e.g. against a tempdir fixture tree). As per coding guidelines, **/*.rs: "Prefer writing Rust unit tests over integration tests where possible" — currently this module has no unit tests, only implicit coverage via the full harness build.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdk_tests/harness_setup/src/typescript_web.rs` around lines 109
- 169, The pure helpers rewrite_test_bridge_imports and has_vitest_tests
currently lack direct unit coverage. Add Rust unit tests in this module using
temporary fixture directories to verify bridge import rewriting, exclusion of
baml_sdk directories, recursive .test.ts detection, and the no-match case,
without relying on the full harness build.

Source: Coding guidelines

baml_language/sdks/web/sdkgen_typescript_web/src/lib.rs (1)

1-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a unit test for the bridge-import rewrite.

This crate has zero tests. The core behavior (to_source_code rewriting @boundaryml/baml-bridge → @boundaryml/baml-bridge-web) is small and pure, and is a good candidate for a fast unit test rather than relying solely on the browser harness build-script integration test to catch a regression here.

✅ Example unit test
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn rewrites_node_bridge_import_to_web_bridge() {
        let mut pool = SymbolPool::default(); // adjust to actual construction
        let out = to_source_code(&pool, &[], NamingConvention::PreserveCase);
        for source in out.values() {
            assert!(!source.contains(NODE_BRIDGE) || source.contains(WEB_BRIDGE));
        }
    }
}

As per coding guidelines, **/*.rs: "Prefer writing Rust unit tests over integration tests where possible". Additionally, per "Always run cargo test --lib if you changed any Rust code", please run cargo test --lib -p sdkgen_typescript_web (and for the other Rust crates touched in this PR) before merging — note this sandbox has no Rust toolchain to execute it here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/web/sdkgen_typescript_web/src/lib.rs` around lines 1 - 32,
Add a Rust unit test module in this crate covering to_source_code’s bridge
rewrite, constructing a valid SymbolPool and invoking it with representative
bytecode or the empty input as supported. Assert generated sources do not retain
NODE_BRIDGE without also containing WEB_BRIDGE, and run cargo test --lib -p
sdkgen_typescript_web plus tests for any other modified Rust crates.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/sdk_tests/harness_setup/src/typescript_web.rs`:
- Around line 109-125: Update rewrite_test_bridge_imports to skip node_modules
during recursive traversal, matching the cleanup logic in codegen_fixture.
Preserve the existing baml_sdk exclusion and TypeScript import-rewrite behavior
for all other directories.

In `@baml_language/sdks/web/bridge_web/typescript_src/index.ts`:
- Around line 103-119: Thread serialized arguments through the invocation path:
update invoke to accept and pass the encoded Uint8Array to callCffiFunction, and
update BamlRuntime.callFunctionSync and callFunction to forward their _args
instead of an empty array. For defineFunction callers that still provide
unknown[] arguments, encode them into the expected byte buffer before invoking.

---

Nitpick comments:
In `@baml_language/crates/bridge_cffi/src/lib.rs`:
- Around line 12-15: Make the wasm module declaration in
baml_language/crates/bridge_cffi/src/lib.rs lines 12-15 unconditional, while
keeping only pub use wasm::* gated to target_arch = "wasm32". In
baml_language/crates/bridge_cffi/src/wasm.rs lines 15-35, add #[cfg(test)] unit
tests covering stage_runtime_bytecode with empty and non-empty bytecode, plus
call_function_in_wasm before and after staging.

In `@baml_language/sdk_tests/harness_runner/src/lib.rs`:
- Around line 278-288: Add a #[cfg(test)] unit test module for
import_from_specifier covering double-quoted imports, single-quoted imports, and
non-matching lines, including lines without the exact " from " pattern. Keep the
test focused on this pure helper and assert the expected Option<&str> results.

In `@baml_language/sdk_tests/harness_setup/src/typescript_web.rs`:
- Around line 109-169: The pure helpers rewrite_test_bridge_imports and
has_vitest_tests currently lack direct unit coverage. Add Rust unit tests in
this module using temporary fixture directories to verify bridge import
rewriting, exclusion of baml_sdk directories, recursive .test.ts detection, and
the no-match case, without relying on the full harness build.

In `@baml_language/sdks/web/bridge_web/Cargo.toml`:
- Around line 1-6: Mark the internal-only bridge_web package as non-publishable
by adding the Cargo publish=false setting in its [package] metadata, matching
the existing sdkgen_typescript_web crate configuration.

In `@baml_language/sdks/web/bridge_web/typescript_src/index.ts`:
- Around line 58-66: Update BamlStream.next() and BamlStream.final() to use the
same immediate “bridge_cffi WASM streaming is not implemented yet” guard as
[Symbol.asyncIterator], instead of calling invoke and casting a result. Keep
nextAsync() and finalAsync() delegating to those guarded methods so all stream
accessors fail consistently.

In `@baml_language/sdks/web/sdkgen_typescript_web/src/lib.rs`:
- Around line 1-32: Add a Rust unit test module in this crate covering
to_source_code’s bridge rewrite, constructing a valid SymbolPool and invoking it
with representative bytecode or the empty input as supported. Assert generated
sources do not retain NODE_BRIDGE without also containing WEB_BRIDGE, and run
cargo test --lib -p sdkgen_typescript_web plus tests for any other modified Rust
crates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a2c7b192-da8d-4f57-9ae9-3223977cdc51

📥 Commits

Reviewing files that changed from the base of the PR and between a05ec5a and ec9ede3.

⛔ Files ignored due to path filters (2)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/sdks/web/bridge_web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (28)
  • baml_language/.config/nextest.toml
  • baml_language/Cargo.toml
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_cffi/src/wasm.rs
  • baml_language/sdk_tests/crates/typescript_web/.gitignore
  • baml_language/sdk_tests/crates/typescript_web/Cargo.toml
  • baml_language/sdk_tests/crates/typescript_web/build.rs
  • baml_language/sdk_tests/crates/typescript_web/setup.ps1
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • baml_language/sdk_tests/crates/typescript_web/src/lib.rs
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • baml_language/sdk_tests/harness_setup/Cargo.toml
  • baml_language/sdk_tests/harness_setup/src/lib.rs
  • baml_language/sdk_tests/harness_setup/src/templates/package_web.json
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.json
  • baml_language/sdk_tests/harness_setup/src/templates/vitest_web.config.ts
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
  • baml_language/sdks/web/bridge_web/.gitignore
  • baml_language/sdks/web/bridge_web/Cargo.toml
  • baml_language/sdks/web/bridge_web/package.json
  • baml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjs
  • baml_language/sdks/web/bridge_web/src/lib.rs
  • baml_language/sdks/web/bridge_web/tsconfig.json
  • baml_language/sdks/web/bridge_web/typescript_src/index.ts
  • baml_language/sdks/web/bridge_web/typescript_src/wasm/bridge_web_core.d.ts
  • baml_language/sdks/web/sdkgen_typescript_web/Cargo.toml
  • baml_language/sdks/web/sdkgen_typescript_web/src/lib.rs

@vercel
vercel Bot temporarily deployed to Preview – beps July 13, 2026 23:57 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 14, 2026 00:04 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
baml_language/crates/bridge_cffi/src/wasm.rs (1)

15-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add unit tests for decode_call
Cover the call_id == 0 guard and the type-args/kwargs decoding paths in baml_language/crates/bridge_cffi/src/wasm.rs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/crates/bridge_cffi/src/wasm.rs` around lines 15 - 60, Add unit
tests for decode_call covering rejection of call_id == 0 and successful decoding
of type_args and kwargs. Build encoded CallFunctionArgs inputs using the
existing bridge ctypes helpers, initialize the runtime and handle table as
required, and assert both the InvalidCallId error and the decoded
context/arguments for valid calls.

Source: Path instructions

baml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjs (1)

20-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Redundant patch on distProto/baml_cffi.js.

The baml_cffi.js patch loop (lines 23-27) rewrites the protobufjs import in both shared/proto and distProto copies, but the subsequent esbuild call (lines 28-34) bundles from shared/proto/baml_cffi.js and writes its output to the exact same distProto/baml_cffi.js path, overwriting the patch just applied there. The second loop iteration's read/patch/write on distProto is dead work.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjs` around lines
20 - 34, Remove the redundant distProto iteration from the baml_cffi.js patch
loop, leaving the import rewrite applied only to shared/proto before build
bundles it into distProto. Keep the existing build invocation and output
behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/crates/bridge_cffi/src/wasm.rs`:
- Around line 70-72: Update call_function_in_wasm_sync to avoid
futures::executor::block_on on wasm32; route callers through the async
call_function_in_wasm entry point instead, or gate this synchronous wrapper
behind an explicitly enforced invariant that the operation never suspends.

In `@baml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjs`:
- Around line 14-19: The Buffer replacement in the file-copy loop must be
token-aware so it only rewrites the intended type references, not runtime usages
such as Buffer.from(...) or instanceof Buffer. Update the replacement logic
around the files loop to preserve real Buffer operations in define_function.ts
and proto.ts while converting only the browser-compatible type tokens.

In `@baml_language/sdks/web/bridge_web/src/lib.rs`:
- Around line 50-54: Remove the `call_function_sync` function and its
`callFunctionSync` WASM binding from the web bridge, leaving the async export as
the only browser-call path. Ensure no other browser-facing code references this
synchronous entry point; do not alter synchronous behavior outside the WASM web
bridge.

---

Nitpick comments:
In `@baml_language/crates/bridge_cffi/src/wasm.rs`:
- Around line 15-60: Add unit tests for decode_call covering rejection of
call_id == 0 and successful decoding of type_args and kwargs. Build encoded
CallFunctionArgs inputs using the existing bridge ctypes helpers, initialize the
runtime and handle table as required, and assert both the InvalidCallId error
and the decoded context/arguments for valid calls.

In `@baml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjs`:
- Around line 20-34: Remove the redundant distProto iteration from the
baml_cffi.js patch loop, leaving the import rewrite applied only to shared/proto
before build bundles it into distProto. Keep the existing build invocation and
output behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 44bef224-d1b8-4477-9b97-b3e1aff51814

📥 Commits

Reviewing files that changed from the base of the PR and between ec9ede3 and 7afb489.

⛔ Files ignored due to path filters (2)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/sdks/web/bridge_web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (35)
  • baml_language/.config/nextest.toml
  • baml_language/Cargo.toml
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_cffi/src/wasm.rs
  • baml_language/crates/bridge_wasm/src/host_value.rs
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_web/.gitignore
  • baml_language/sdk_tests/crates/typescript_web/Cargo.toml
  • baml_language/sdk_tests/crates/typescript_web/build.rs
  • baml_language/sdk_tests/crates/typescript_web/setup.ps1
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • baml_language/sdk_tests/crates/typescript_web/src/lib.rs
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • baml_language/sdk_tests/harness_setup/Cargo.toml
  • baml_language/sdk_tests/harness_setup/src/lib.rs
  • baml_language/sdk_tests/harness_setup/src/templates/package_web.json
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.json
  • baml_language/sdk_tests/harness_setup/src/templates/vitest_web.config.ts
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
  • baml_language/sdks/web/bridge_web/.gitignore
  • baml_language/sdks/web/bridge_web/Cargo.toml
  • baml_language/sdks/web/bridge_web/package.json
  • baml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjs
  • baml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjs
  • baml_language/sdks/web/bridge_web/src/lib.rs
  • baml_language/sdks/web/bridge_web/tsconfig.json
  • baml_language/sdks/web/bridge_web/typescript_src/index.ts
  • baml_language/sdks/web/bridge_web/typescript_src/native.ts
  • baml_language/sdks/web/bridge_web/typescript_src/wasm/bridge_web_core.d.ts
  • baml_language/sdks/web/sdkgen_typescript_web/Cargo.toml
  • baml_language/sdks/web/sdkgen_typescript_web/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (19)
  • baml_language/sdk_tests/harness_setup/src/templates/package_web.json
  • baml_language/sdks/web/bridge_web/tsconfig.json
  • baml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjs
  • baml_language/sdk_tests/crates/typescript_web/build.rs
  • baml_language/sdk_tests/harness_setup/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_web/.gitignore
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.json
  • baml_language/sdk_tests/harness_setup/src/templates/vitest_web.config.ts
  • baml_language/sdks/web/sdkgen_typescript_web/Cargo.toml
  • baml_language/sdks/web/bridge_web/.gitignore
  • baml_language/sdks/web/bridge_web/package.json
  • baml_language/sdk_tests/crates/typescript_web/src/lib.rs
  • baml_language/sdks/web/sdkgen_typescript_web/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_web/Cargo.toml
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • baml_language/Cargo.toml
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
  • baml_language/crates/bridge_cffi/src/lib.rs

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 14, 2026 00:24 Inactive
@sxlijin
sxlijin force-pushed the sam/bridge-web branch 2 times, most recently from 8268b66 to d249623 Compare July 15, 2026 18:15
@vercel
vercel Bot temporarily deployed to Preview – beps July 15, 2026 18:16 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 15, 2026 18:23 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 15, 2026 18:37 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 15, 2026 23:00 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 15, 2026 23:07 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

♻️ Duplicate comments (1)
baml_language/crates/bridge_cffi/src/wasm.rs (1)

105-107: 🩺 Stability & Availability | 🔴 Critical

Avoid block_on on the wasm32 path.

futures::executor::block_on can panic or hang on wasm32 as soon as call_function_in_wasm yields. Use the async entry point here, or keep this wrapper only behind a proven "never suspends" invariant and enforce it. As seen in past review comments, this behavior causes a crash or infinite hang because WebAssembly lacks OS-level threading primitives.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/crates/bridge_cffi/src/wasm.rs` around lines 105 - 107, Update
call_function_in_wasm_sync to avoid futures::executor::block_on on wasm32; route
callers through the existing async call_function_in_wasm entry point instead, or
gate this synchronous wrapper behind an enforced invariant that it never
suspends. Preserve the current function arguments and returned bytes while
preventing wasm execution from blocking or hanging.
🧹 Nitpick comments (2)
baml_language/sdks/nodejs/bridge_nodejs/src/runtime.rs (1)

54-60: 📐 Maintainability & Code Quality | 🔵 Trivial

Use a build image with the C toolchain for cargo test --lib The workspace test run stops in aws-lc-sys here because standard headers like stdlib.h and linux/random.h are unavailable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/nodejs/bridge_nodejs/src/runtime.rs` around lines 54 - 60,
Update the test/build environment to use an image with the required C toolchain
and standard Linux headers so cargo test --lib can compile aws-lc-sys. The
affected code sites
baml_language/sdks/nodejs/bridge_nodejs/src/runtime.rs:54-60,
baml_language/sdks/python/rust/bridge_python/src/runtime.rs:75-82,
baml_language/crates/bridge_cffi/src/error.rs:43-54,
baml_language/sdks/sdkgen_typescript/src/emit/method.rs:10, and
baml_language/sdks/sdkgen_typescript/src/emit/enum_.rs:7-14 require no direct
code changes; they are only covered by the environment fix.

Source: Coding guidelines

workers-demo/src/baml_sdk/baml/csv/index.ts (1)

324-324: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Deduplicate primitive types in generated unions. The generator emits union types containing duplicate primitives (e.g., number appears twice), likely because multiple distinct BAML types map to the same TypeScript type. The shared root cause is a lack of deduplication in the generator's union stringification.

  • workers-demo/src/baml_sdk/baml/csv/index.ts#L324-L324: deduplicate the mapped primitives when generating CsvValue$stream.
  • workers-demo/src/baml_sdk/baml/csv/index.ts#L546-L546: deduplicate the mapped primitives when generating CsvValue.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@workers-demo/src/baml_sdk/baml/csv/index.ts` at line 324, Deduplicate mapped
primitive types in the generator’s union stringification so each TypeScript
union member appears only once. Apply the fix to the CsvValue$stream declaration
at workers-demo/src/baml_sdk/baml/csv/index.ts:324-324 and the CsvValue
declaration at workers-demo/src/baml_sdk/baml/csv/index.ts:546-546, preserving
all distinct union members.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/publish2-web-sdk.yaml:
- Around line 99-103: Update the tag-selection logic in the publish workflow so
stable releases use the latest npm dist-tag, while canary and other channel
releases use their $CHANNEL value. Preserve the existing CHANNEL-based
publishing flow and verify related SDK workflows follow the same convention.

In `@baml_language/sdks/web/bridge_web/scripts/prepare-workerd-package.mjs`:
- Around line 41-49: Update the WASM-loader transformation in the preparation
script to validate each rewrite independently: assert that every expected source
pattern exists before replacing it, including the default import and await
initWasm() call. After all replacements, verify the generated workerdNative
contains the workerd core import and contains neither the original default
import nor the initialization call, throwing the existing preparation error when
any check fails.

In `@workers-demo/src/baml_sdk/baml/csv/index.ts`:
- Around line 689-690: Update the TypeScript generator’s return-type mappings
used by defineInstanceFunction so complex and generic generated methods no
longer emit unknown. At workers-demo/src/baml_sdk/baml/csv/index.ts:689-690,
emit IterableIterator<CsvRecord> for CsvReader.iter; at
workers-demo/src/baml_sdk/baml/csv/index.ts:737-748, emit CsvRows<T> for rows;
and at workers-demo/src/baml_sdk/baml/csv/index.ts:835-836, emit
IterableIterator<T> for CsvRows.iter.
- Line 472: Update the TypeScript generator’s Ty::Union rendering so callable
members are parenthesized before union separators, producing a function-or-null
type rather than a function returning null. Apply the fix to the generator logic
responsible for these declarations; the affected sites in
workers-demo/src/baml_sdk/baml/csv/index.ts at lines 472-472, 491-491, 679-679,
and 684-684 require no direct changes because they should be regenerated with
the corrected output.

In `@workers-demo/src/baml_sdk/baml/future/index.ts`:
- Around line 151-162: Update the future combinator type assertions in
all_complete, all_complete_async, all, race, any, and __await_any so they expose
their intended generic Future-based input and output types. Use homogeneous
Future value/error parameters: all_complete and all return a Future of an array
of values, race returns a Future of one value, any returns a Future with the
AllFailed error wrapper, and __await_any returns a number. Keep the existing
runtime definitions unchanged while replacing the null-based signatures.

---

Duplicate comments:
In `@baml_language/crates/bridge_cffi/src/wasm.rs`:
- Around line 105-107: Update call_function_in_wasm_sync to avoid
futures::executor::block_on on wasm32; route callers through the existing async
call_function_in_wasm entry point instead, or gate this synchronous wrapper
behind an enforced invariant that it never suspends. Preserve the current
function arguments and returned bytes while preventing wasm execution from
blocking or hanging.

---

Nitpick comments:
In `@baml_language/sdks/nodejs/bridge_nodejs/src/runtime.rs`:
- Around line 54-60: Update the test/build environment to use an image with the
required C toolchain and standard Linux headers so cargo test --lib can compile
aws-lc-sys. The affected code sites
baml_language/sdks/nodejs/bridge_nodejs/src/runtime.rs:54-60,
baml_language/sdks/python/rust/bridge_python/src/runtime.rs:75-82,
baml_language/crates/bridge_cffi/src/error.rs:43-54,
baml_language/sdks/sdkgen_typescript/src/emit/method.rs:10, and
baml_language/sdks/sdkgen_typescript/src/emit/enum_.rs:7-14 require no direct
code changes; they are only covered by the environment fix.

In `@workers-demo/src/baml_sdk/baml/csv/index.ts`:
- Line 324: Deduplicate mapped primitive types in the generator’s union
stringification so each TypeScript union member appears only once. Apply the fix
to the CsvValue$stream declaration at
workers-demo/src/baml_sdk/baml/csv/index.ts:324-324 and the CsvValue declaration
at workers-demo/src/baml_sdk/baml/csv/index.ts:546-546, preserving all distinct
union members.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 180242c2-7be3-4125-867b-fbcbcd37daf4

📥 Commits

Reviewing files that changed from the base of the PR and between d249623 and 57cbc4c.

⛔ Files ignored due to path filters (6)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/sdks/web/bridge_web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • workers-demo/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • workers-demo2/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • workers-demo3/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • workers-npm-demo/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (139)
  • .github/workflows/build2-web-sdk.reusable.yaml
  • .github/workflows/ci.yaml
  • .github/workflows/publish2-web-sdk.yaml
  • .github/workflows/release-baml-language.yml
  • baml_language/.config/nextest.toml
  • baml_language/Cargo.toml
  • baml_language/crates/baml_cli/Cargo.toml
  • baml_language/crates/baml_cli/src/generate.rs
  • baml_language/crates/baml_codegen_types/src/generator_fields.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/crates/bridge_cffi/src/buffer.rs
  • baml_language/crates/bridge_cffi/src/error.rs
  • baml_language/crates/bridge_cffi/src/ffi/objects.rs
  • baml_language/crates/bridge_cffi/src/ffi/runtime.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_cffi/src/sysop_impl.rs
  • baml_language/crates/bridge_cffi/src/wasm.rs
  • baml_language/crates/bridge_wasm/src/host_value.rs
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/crates/sys_wasm/src/web_sysops.rs
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_web/.gitignore
  • baml_language/sdk_tests/crates/typescript_web/Cargo.toml
  • baml_language/sdk_tests/crates/typescript_web/build.rs
  • baml_language/sdk_tests/crates/typescript_web/function_calls/customizable/host_callables.test.ts
  • baml_language/sdk_tests/crates/typescript_web/function_calls/customizable/web_sysops.test.ts
  • baml_language/sdk_tests/crates/typescript_web/setup.ps1
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • baml_language/sdk_tests/crates/typescript_web/src/lib.rs
  • baml_language/sdk_tests/fixtures/function_calls/baml_src/main.baml
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • baml_language/sdk_tests/harness_setup/Cargo.toml
  • baml_language/sdk_tests/harness_setup/src/lib.rs
  • baml_language/sdk_tests/harness_setup/src/templates/package_web.json
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.json
  • baml_language/sdk_tests/harness_setup/src/templates/vitest_web.config.ts
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
  • baml_language/sdks/nodejs/bridge_nodejs/src/runtime.rs
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • baml_language/sdks/nodejs/sdkgen_typescript_node/Cargo.toml
  • baml_language/sdks/nodejs/sdkgen_typescript_node/src/lib.rs
  • baml_language/sdks/python/rust/bridge_python/src/runtime.rs
  • baml_language/sdks/sdkgen_typescript/Cargo.toml
  • baml_language/sdks/sdkgen_typescript/src/emit/class.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/enum_.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/function.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/method.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/mod.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/type_alias.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/typemap_file.rs
  • baml_language/sdks/sdkgen_typescript/src/leaf.rs
  • baml_language/sdks/sdkgen_typescript/src/lib.rs
  • baml_language/sdks/sdkgen_typescript/src/routing.rs
  • baml_language/sdks/sdkgen_typescript/src/translate_ty.rs
  • baml_language/sdks/web/bridge_web/.gitignore
  • baml_language/sdks/web/bridge_web/Cargo.toml
  • baml_language/sdks/web/bridge_web/package.json
  • baml_language/sdks/web/bridge_web/pnpm-workspace.yaml
  • baml_language/sdks/web/bridge_web/scripts/build-wasm-release.mjs
  • baml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjs
  • baml_language/sdks/web/bridge_web/scripts/prepare-workerd-package.mjs
  • baml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjs
  • baml_language/sdks/web/bridge_web/src/lib.rs
  • baml_language/sdks/web/bridge_web/tsconfig.json
  • baml_language/sdks/web/bridge_web/typescript_src/index.ts
  • baml_language/sdks/web/bridge_web/typescript_src/native.ts
  • baml_language/sdks/web/bridge_web/typescript_src/wasm/bridge_web_core.d.ts
  • baml_language/sdks/web/sdkgen_typescript_workers/Cargo.toml
  • baml_language/sdks/web/sdkgen_typescript_workers/src/lib.rs
  • mise.toml
  • scripts/baml-language-version
  • workers-demo/.gitignore
  • workers-demo/baml.toml
  • workers-demo/baml_src/main.baml
  • workers-demo/package.json
  • workers-demo/pnpm-workspace.yaml
  • workers-demo/src/baml_sdk/_inlinedbaml.ts
  • workers-demo/src/baml_sdk/_typemap.ts
  • workers-demo/src/baml_sdk/baml/csv/index.ts
  • workers-demo/src/baml_sdk/baml/env/index.ts
  • workers-demo/src/baml_sdk/baml/errors/index.ts
  • workers-demo/src/baml_sdk/baml/fs/index.ts
  • workers-demo/src/baml_sdk/baml/future/index.ts
  • workers-demo/src/baml_sdk/baml/glob/index.ts
  • workers-demo/src/baml_sdk/baml/host/index.ts
  • workers-demo/src/baml_sdk/baml/http/index.ts
  • workers-demo/src/baml_sdk/baml/id/index.ts
  • workers-demo/src/baml_sdk/baml/index.ts
  • workers-demo/src/baml_sdk/baml/io/index.ts
  • workers-demo/src/baml_sdk/baml/iter/index.ts
  • workers-demo/src/baml_sdk/baml/json/index.ts
  • workers-demo/src/baml_sdk/baml/llm/index.ts
  • workers-demo/src/baml_sdk/baml/media/index.ts
  • workers-demo/src/baml_sdk/baml/net/index.ts
  • workers-demo/src/baml_sdk/baml/ops/index.ts
  • workers-demo/src/baml_sdk/baml/panics/index.ts
  • workers-demo/src/baml_sdk/baml/spawn/index.ts
  • workers-demo/src/baml_sdk/baml/stream/index.ts
  • workers-demo/src/baml_sdk/baml/sys/index.ts
  • workers-demo/src/baml_sdk/baml/time/index.ts
  • workers-demo/src/baml_sdk/baml/toml/index.ts
  • workers-demo/src/baml_sdk/baml/yaml/index.ts
  • workers-demo/src/baml_sdk/index.ts
  • workers-demo/src/index.ts
  • workers-demo/tsconfig.json
  • workers-demo/worker-configuration.d.ts
  • workers-demo/wrangler.jsonc
  • workers-demo2/.gitignore
  • workers-demo2/README.md
  • workers-demo2/package.json
  • workers-demo2/pnpm-workspace.yaml
  • workers-demo2/scripts/assert-node-fs-rejected.mjs
  • workers-demo2/src/index.ts
  • workers-demo2/tsconfig.json
  • workers-demo2/worker-configuration.d.ts
  • workers-demo2/wrangler.jsonc
  • workers-demo3/.gitignore
  • workers-demo3/README.md
  • workers-demo3/package.json
  • workers-demo3/pnpm-workspace.yaml
  • workers-demo3/scripts/assert-process-env.mjs
  • workers-demo3/src/index.ts
  • workers-demo3/tsconfig.json
  • workers-demo3/worker-configuration.d.ts
  • workers-demo3/wrangler.jsonc
  • workers-demo3/wrangler.node-compat.jsonc
  • workers-npm-demo/.gitignore
  • workers-npm-demo/README.md
  • workers-npm-demo/package.json
  • workers-npm-demo/pnpm-workspace.yaml
  • workers-npm-demo/src/index.ts
  • workers-npm-demo/tsconfig.json
  • workers-npm-demo/worker-configuration.d.ts
  • workers-npm-demo/worker-startup.cpuprofile
  • workers-npm-demo/wrangler.jsonc
💤 Files with no reviewable changes (1)
  • baml_language/crates/bridge_cffi/src/ffi/objects.rs
🚧 Files skipped from review as they are similar to previous changes (23)
  • baml_language/sdk_tests/harness_setup/src/templates/package_web.json
  • baml_language/sdk_tests/crates/typescript_web/Cargo.toml
  • baml_language/sdks/web/bridge_web/.gitignore
  • baml_language/sdk_tests/crates/typescript_web/src/lib.rs
  • baml_language/sdks/web/bridge_web/Cargo.toml
  • baml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjs
  • baml_language/sdk_tests/crates/typescript_web/build.rs
  • baml_language/sdks/web/bridge_web/tsconfig.json
  • baml_language/crates/baml_cli/Cargo.toml
  • baml_language/sdks/web/bridge_web/package.json
  • baml_language/sdk_tests/crates/typescript_web/.gitignore
  • baml_language/sdk_tests/harness_setup/src/lib.rs
  • baml_language/crates/baml_cli/src/generate.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.json
  • baml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjs
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/Cargo.toml
  • baml_language/.config/nextest.toml
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • baml_language/sdks/web/bridge_web/typescript_src/index.ts
👮 Files not reviewed due to content moderation or server errors (7)
  • workers-demo/src/baml_sdk/_inlinedbaml.ts
  • workers-demo/.gitignore
  • workers-demo2/pnpm-workspace.yaml
  • workers-demo2/.gitignore
  • mise.toml
  • baml_language/sdks/sdkgen_typescript/src/translate_ty.rs
  • workers-demo/src/baml_sdk/baml/env/index.ts

Comment thread .github/workflows/publish2-web-sdk.yaml Resolved
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 15, 2026 23:25 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 15, 2026 23:49 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 15, 2026 23:57 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/crates/bridge_cffi/src/lib_wasm.rs`:
- Around line 61-63: Remove the synchronous wrapper function
call_function_in_wasm_sync from the WASM target rather than invoking
futures::executor::block_on; keep call_function_in_wasm as the async-only entry
point, or make the wrapper explicitly return an error if the API must remain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0be0752b-3cb0-4b3f-989f-b426252dcbd0

📥 Commits

Reviewing files that changed from the base of the PR and between 57cbc4c and f983ada.

⛔ Files ignored due to path filters (6)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/sdks/web/bridge_web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • workers-demo/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • workers-demo2/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • workers-demo3/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • workers-npm-demo/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (140)
  • .github/workflows/build2-web-sdk.reusable.yaml
  • .github/workflows/ci.yaml
  • .github/workflows/publish2-web-sdk.yaml
  • .github/workflows/release-baml-language.yml
  • baml_language/.config/nextest.toml
  • baml_language/Cargo.toml
  • baml_language/crates/baml_cli/Cargo.toml
  • baml_language/crates/baml_cli/src/generate.rs
  • baml_language/crates/baml_codegen_types/src/generator_fields.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/crates/bridge_cffi/src/buffer.rs
  • baml_language/crates/bridge_cffi/src/error.rs
  • baml_language/crates/bridge_cffi/src/ffi/objects.rs
  • baml_language/crates/bridge_cffi/src/ffi/runtime.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_cffi/src/lib_native.rs
  • baml_language/crates/bridge_cffi/src/lib_wasm.rs
  • baml_language/crates/bridge_cffi/src/sysop_impl.rs
  • baml_language/crates/bridge_wasm/src/host_value.rs
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/crates/sys_wasm/src/web_sysops.rs
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript_web/.gitignore
  • baml_language/sdk_tests/crates/typescript_web/Cargo.toml
  • baml_language/sdk_tests/crates/typescript_web/build.rs
  • baml_language/sdk_tests/crates/typescript_web/function_calls/customizable/host_callables.test.ts
  • baml_language/sdk_tests/crates/typescript_web/function_calls/customizable/web_sysops.test.ts
  • baml_language/sdk_tests/crates/typescript_web/setup.ps1
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • baml_language/sdk_tests/crates/typescript_web/src/lib.rs
  • baml_language/sdk_tests/fixtures/function_calls/baml_src/main.baml
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • baml_language/sdk_tests/harness_setup/Cargo.toml
  • baml_language/sdk_tests/harness_setup/src/lib.rs
  • baml_language/sdk_tests/harness_setup/src/templates/package_web.json
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.json
  • baml_language/sdk_tests/harness_setup/src/templates/vitest_web.config.ts
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
  • baml_language/sdks/nodejs/bridge_nodejs/src/runtime.rs
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • baml_language/sdks/nodejs/sdkgen_typescript_node/Cargo.toml
  • baml_language/sdks/nodejs/sdkgen_typescript_node/src/lib.rs
  • baml_language/sdks/python/rust/bridge_python/src/runtime.rs
  • baml_language/sdks/sdkgen_typescript/Cargo.toml
  • baml_language/sdks/sdkgen_typescript/src/emit/class.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/enum_.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/function.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/method.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/mod.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/type_alias.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/typemap_file.rs
  • baml_language/sdks/sdkgen_typescript/src/leaf.rs
  • baml_language/sdks/sdkgen_typescript/src/lib.rs
  • baml_language/sdks/sdkgen_typescript/src/routing.rs
  • baml_language/sdks/sdkgen_typescript/src/translate_ty.rs
  • baml_language/sdks/web/bridge_web/.gitignore
  • baml_language/sdks/web/bridge_web/Cargo.toml
  • baml_language/sdks/web/bridge_web/package.json
  • baml_language/sdks/web/bridge_web/pnpm-workspace.yaml
  • baml_language/sdks/web/bridge_web/scripts/build-wasm-release.mjs
  • baml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjs
  • baml_language/sdks/web/bridge_web/scripts/prepare-workerd-package.mjs
  • baml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjs
  • baml_language/sdks/web/bridge_web/src/lib.rs
  • baml_language/sdks/web/bridge_web/tsconfig.json
  • baml_language/sdks/web/bridge_web/typescript_src/index.ts
  • baml_language/sdks/web/bridge_web/typescript_src/native.ts
  • baml_language/sdks/web/bridge_web/typescript_src/wasm/bridge_web_core.d.ts
  • baml_language/sdks/web/sdkgen_typescript_workers/Cargo.toml
  • baml_language/sdks/web/sdkgen_typescript_workers/src/lib.rs
  • mise.toml
  • scripts/baml-language-version
  • workers-demo/.gitignore
  • workers-demo/baml.toml
  • workers-demo/baml_src/main.baml
  • workers-demo/package.json
  • workers-demo/pnpm-workspace.yaml
  • workers-demo/src/baml_sdk/_inlinedbaml.ts
  • workers-demo/src/baml_sdk/_typemap.ts
  • workers-demo/src/baml_sdk/baml/csv/index.ts
  • workers-demo/src/baml_sdk/baml/env/index.ts
  • workers-demo/src/baml_sdk/baml/errors/index.ts
  • workers-demo/src/baml_sdk/baml/fs/index.ts
  • workers-demo/src/baml_sdk/baml/future/index.ts
  • workers-demo/src/baml_sdk/baml/glob/index.ts
  • workers-demo/src/baml_sdk/baml/host/index.ts
  • workers-demo/src/baml_sdk/baml/http/index.ts
  • workers-demo/src/baml_sdk/baml/id/index.ts
  • workers-demo/src/baml_sdk/baml/index.ts
  • workers-demo/src/baml_sdk/baml/io/index.ts
  • workers-demo/src/baml_sdk/baml/iter/index.ts
  • workers-demo/src/baml_sdk/baml/json/index.ts
  • workers-demo/src/baml_sdk/baml/llm/index.ts
  • workers-demo/src/baml_sdk/baml/media/index.ts
  • workers-demo/src/baml_sdk/baml/net/index.ts
  • workers-demo/src/baml_sdk/baml/ops/index.ts
  • workers-demo/src/baml_sdk/baml/panics/index.ts
  • workers-demo/src/baml_sdk/baml/spawn/index.ts
  • workers-demo/src/baml_sdk/baml/stream/index.ts
  • workers-demo/src/baml_sdk/baml/sys/index.ts
  • workers-demo/src/baml_sdk/baml/time/index.ts
  • workers-demo/src/baml_sdk/baml/toml/index.ts
  • workers-demo/src/baml_sdk/baml/yaml/index.ts
  • workers-demo/src/baml_sdk/index.ts
  • workers-demo/src/index.ts
  • workers-demo/tsconfig.json
  • workers-demo/worker-configuration.d.ts
  • workers-demo/wrangler.jsonc
  • workers-demo2/.gitignore
  • workers-demo2/README.md
  • workers-demo2/package.json
  • workers-demo2/pnpm-workspace.yaml
  • workers-demo2/scripts/assert-node-fs-rejected.mjs
  • workers-demo2/src/index.ts
  • workers-demo2/tsconfig.json
  • workers-demo2/worker-configuration.d.ts
  • workers-demo2/wrangler.jsonc
  • workers-demo3/.gitignore
  • workers-demo3/README.md
  • workers-demo3/package.json
  • workers-demo3/pnpm-workspace.yaml
  • workers-demo3/scripts/assert-process-env.mjs
  • workers-demo3/src/index.ts
  • workers-demo3/tsconfig.json
  • workers-demo3/worker-configuration.d.ts
  • workers-demo3/wrangler.jsonc
  • workers-demo3/wrangler.node-compat.jsonc
  • workers-npm-demo/.gitignore
  • workers-npm-demo/README.md
  • workers-npm-demo/package.json
  • workers-npm-demo/pnpm-workspace.yaml
  • workers-npm-demo/src/index.ts
  • workers-npm-demo/tsconfig.json
  • workers-npm-demo/worker-configuration.d.ts
  • workers-npm-demo/worker-startup.cpuprofile
  • workers-npm-demo/wrangler.jsonc
💤 Files with no reviewable changes (1)
  • baml_language/crates/bridge_cffi/src/ffi/objects.rs
🚧 Files skipped from review as they are similar to previous changes (128)
  • baml_language/sdks/web/bridge_web/pnpm-workspace.yaml
  • baml_language/sdk_tests/crates/typescript_web/Cargo.toml
  • baml_language/sdk_tests/crates/typescript_web/src/lib.rs
  • workers-demo3/package.json
  • workers-demo/pnpm-workspace.yaml
  • workers-demo/baml.toml
  • workers-demo/wrangler.jsonc
  • workers-demo/.gitignore
  • workers-npm-demo/README.md
  • workers-demo3/README.md
  • baml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.json
  • workers-demo3/wrangler.node-compat.jsonc
  • workers-npm-demo/worker-startup.cpuprofile
  • workers-demo2/package.json
  • baml_language/sdk_tests/crates/typescript_node/function_calls/customizable/main.test.ts
  • baml_language/sdk_tests/harness_setup/src/templates/package_web.json
  • baml_language/sdk_tests/harness_setup/src/templates/vitest_web.config.ts
  • baml_language/sdks/web/sdkgen_typescript_workers/Cargo.toml
  • baml_language/sdk_tests/crates/typescript_web/build.rs
  • baml_language/sdk_tests/crates/typescript_web/function_calls/customizable/host_callables.test.ts
  • workers-demo2/tsconfig.json
  • baml_language/sdks/web/bridge_web/tsconfig.json
  • workers-demo/package.json
  • workers-demo3/wrangler.jsonc
  • baml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjs
  • baml_language/sdks/web/bridge_web/Cargo.toml
  • workers-demo/tsconfig.json
  • workers-npm-demo/pnpm-workspace.yaml
  • workers-demo3/pnpm-workspace.yaml
  • .github/workflows/publish2-web-sdk.yaml
  • workers-demo2/pnpm-workspace.yaml
  • workers-npm-demo/src/index.ts
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/sdks/web/bridge_web/.gitignore
  • baml_language/sdks/nodejs/bridge_nodejs/src/runtime.rs
  • baml_language/crates/bridge_cffi/src/buffer.rs
  • mise.toml
  • workers-demo/baml_src/main.baml
  • baml_language/sdk_tests/crates/typescript_web/.gitignore
  • workers-npm-demo/tsconfig.json
  • baml_language/crates/baml_codegen_types/src/generator_fields.rs
  • baml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.ts
  • workers-demo2/README.md
  • baml_language/sdks/sdkgen_typescript/src/emit/type_alias.rs
  • baml_language/sdks/web/bridge_web/scripts/build-wasm-release.mjs
  • baml_language/sdk_tests/fixtures/function_calls/baml_src/main.baml
  • workers-npm-demo/package.json
  • workers-npm-demo/.gitignore
  • workers-demo/src/baml_sdk/index.ts
  • workers-demo3/.gitignore
  • baml_language/sdk_tests/harness_setup/src/lib.rs
  • workers-demo/src/baml_sdk/baml/media/index.ts
  • workers-demo3/src/index.ts
  • baml_language/sdks/web/bridge_web/package.json
  • workers-demo/src/baml_sdk/baml/ops/index.ts
  • workers-demo2/scripts/assert-node-fs-rejected.mjs
  • workers-demo3/tsconfig.json
  • workers-demo2/wrangler.jsonc
  • baml_language/crates/bridge_cffi/src/error.rs
  • workers-demo/src/baml_sdk/baml/id/index.ts
  • baml_language/sdks/sdkgen_typescript/Cargo.toml
  • baml_language/sdks/sdkgen_typescript/src/emit/function.rs
  • baml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjs
  • workers-demo/src/baml_sdk/baml/stream/index.ts
  • baml_language/sdk_tests/harness_setup/Cargo.toml
  • baml_language/sdks/sdkgen_typescript/src/translate_ty.rs
  • baml_language/crates/baml_cli/src/generate.rs
  • baml_language/Cargo.toml
  • workers-demo/src/baml_sdk/baml/io/index.ts
  • workers-demo2/src/index.ts
  • workers-demo/src/baml_sdk/_typemap.ts
  • baml_language/sdks/web/sdkgen_typescript_workers/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_web/function_calls/customizable/web_sysops.test.ts
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/sdks/sdkgen_typescript/src/routing.rs
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • workers-demo/src/baml_sdk/baml/glob/index.ts
  • baml_language/sdks/web/bridge_web/typescript_src/wasm/bridge_web_core.d.ts
  • baml_language/crates/baml_cli/Cargo.toml
  • baml_language/.config/nextest.toml
  • .github/workflows/release-baml-language.yml
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
  • workers-demo/src/baml_sdk/baml/host/index.ts
  • baml_language/sdks/sdkgen_typescript/src/emit/class.rs
  • scripts/baml-language-version
  • baml_language/sdk_tests/crates/typescript_web/setup.ps1
  • baml_language/sdks/sdkgen_typescript/src/emit/enum_.rs
  • workers-demo/src/baml_sdk/baml/yaml/index.ts
  • workers-demo/src/baml_sdk/baml/sys/index.ts
  • baml_language/sdks/nodejs/sdkgen_typescript_node/src/lib.rs
  • baml_language/crates/sys_ops/src/lib.rs
  • workers-demo3/scripts/assert-process-env.mjs
  • .github/workflows/build2-web-sdk.reusable.yaml
  • baml_language/sdks/python/rust/bridge_python/src/runtime.rs
  • baml_language/crates/bridge_cffi/src/sysop_impl.rs
  • baml_language/sdks/sdkgen_typescript/src/emit/mod.rs
  • workers-demo3/worker-configuration.d.ts
  • workers-demo/src/baml_sdk/baml/toml/index.ts
  • workers-demo/src/baml_sdk/baml/errors/index.ts
  • workers-demo/src/baml_sdk/baml/future/index.ts
  • baml_language/sdks/web/bridge_web/scripts/prepare-workerd-package.mjs
  • baml_language/sdks/sdkgen_typescript/src/lib.rs
  • workers-demo/src/baml_sdk/baml/spawn/index.ts
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • .github/workflows/ci.yaml
  • baml_language/sdks/web/bridge_web/typescript_src/index.ts
  • baml_language/crates/bridge_cffi/Cargo.toml
  • workers-demo/src/baml_sdk/baml/panics/index.ts
  • baml_language/sdks/sdkgen_typescript/src/emit/typemap_file.rs
  • workers-demo/src/baml_sdk/baml/time/index.ts
  • baml_language/sdks/web/bridge_web/src/lib.rs
  • workers-demo/src/baml_sdk/baml/fs/index.ts
  • baml_language/crates/sys_wasm/src/web_sysops.rs
  • workers-demo/src/baml_sdk/baml/net/index.ts
  • workers-demo/src/baml_sdk/baml/iter/index.ts
  • workers-demo/src/baml_sdk/baml/env/index.ts
  • baml_language/crates/bridge_cffi/src/ffi/runtime.rs
  • baml_language/sdk_tests/harness_runner/src/lib.rs
  • workers-demo/src/baml_sdk/baml/index.ts
  • baml_language/sdks/web/bridge_web/typescript_src/native.ts
  • workers-demo/src/baml_sdk/baml/json/index.ts
  • workers-demo/worker-configuration.d.ts
  • workers-demo/src/baml_sdk/baml/csv/index.ts
  • workers-demo/src/baml_sdk/baml/http/index.ts
  • workers-demo2/worker-configuration.d.ts
  • workers-demo/src/baml_sdk/baml/llm/index.ts
  • baml_language/sdks/sdkgen_typescript/src/leaf.rs
👮 Files not reviewed due to content moderation or server errors (5)
  • workers-demo/src/baml_sdk/_inlinedbaml.ts
  • workers-npm-demo/worker-configuration.d.ts
  • baml_language/crates/bridge_cffi/src/lib_native.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_wasm/src/host_value.rs

@sxlijin
sxlijin force-pushed the sam/typescript-web-scaffold branch from fa1d751 to 30b7aec Compare July 16, 2026 07:14
@vercel
vercel Bot temporarily deployed to Preview – beps July 16, 2026 07:15 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 16, 2026 07:21 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 16, 2026 07:35 Inactive
@sxlijin
sxlijin force-pushed the sam/typescript-web-scaffold branch from 30b7aec to 38782ae Compare July 16, 2026 19:22
@vercel
vercel Bot temporarily deployed to Preview – beps July 16, 2026 19:24 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 16, 2026 19:30 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 16, 2026 19:44 Inactive
@sxlijin
sxlijin changed the base branch from sam/typescript-web-scaffold to sam/typescript-vitest-runtimes July 16, 2026 20:03
@vercel
vercel Bot temporarily deployed to Preview – beps July 16, 2026 20:04 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 16, 2026 20:10 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 16, 2026 20:24 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
baml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_handles.test.ts (1)

29-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove duplicate assertion.

The expectation expect(img.base64()).toBe(PNG_B64); is repeated on consecutive lines.

♻️ Proposed fix
-    expect(img.base64()).toBe(PNG_B64);
     expect(img.base64()).toBe(PNG_B64);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@baml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_handles.test.ts`
around lines 29 - 30, Remove the duplicate consecutive expect assertion in the
image roundtrip test, keeping a single expect(img.base64()).toBe(PNG_B64) check.
baml_language/crates/bridge_cffi/src/handle.rs (1)

1-157: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add unit tests directly in this module.

This new module's pure functions (resolve_media's type-mismatch/unsupported-type branches, clone_handle/release_handle's not-found paths, validate_media_input) currently have no #[cfg(test)] coverage here; the only exercise in this PR is indirect, through the C-ABI-level tests in ffi/handle.rs. Adding focused #[test]s in this file (mirroring the style used for function_type_accepts_only_callables in host_return.rs) would pin this module's contract independently of the FFI wrapper layer.

As per path instructions, **/*.rs: "Prefer writing Rust unit tests over integration tests where possible."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/crates/bridge_cffi/src/handle.rs` around lines 1 - 157, Add a
#[cfg(test)] module in this file with focused unit tests for
validate_media_input, resolve_media’s type-mismatch and unsupported-type
branches, and the invalid-handle paths of clone_handle and release_handle. Use
the existing seed helpers and live-handle cleanup patterns as needed, and keep
coverage independent of the C-ABI wrapper layer.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@baml_language/sdks/typescript/bridge_typescript/typescript_src/define_function.ts`:
- Around line 236-241: Import wrapNativeError from ./errors.js and wrap each
native rt.callFunctionSync or await rt.callFunction invocation in
define_function.ts with an inner try/catch that rethrows wrapNativeError(err),
while preserving the surrounding call-context cleanup. Apply this to
define_function.ts ranges 236-241, 252-257, 306-311, and 322-327; also update
stream.ts methods _callSync and _callAsync with the same handling.

---

Nitpick comments:
In `@baml_language/crates/bridge_cffi/src/handle.rs`:
- Around line 1-157: Add a #[cfg(test)] module in this file with focused unit
tests for validate_media_input, resolve_media’s type-mismatch and
unsupported-type branches, and the invalid-handle paths of clone_handle and
release_handle. Use the existing seed helpers and live-handle cleanup patterns
as needed, and keep coverage independent of the C-ABI wrapper layer.

In
`@baml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_handles.test.ts`:
- Around line 29-30: Remove the duplicate consecutive expect assertion in the
image roundtrip test, keeping a single expect(img.base64()).toBe(PNG_B64) check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8d7a8cfb-9606-4375-b81f-81844424a16c

📥 Commits

Reviewing files that changed from the base of the PR and between c90ccf2 and 674c272.

⛔ Files ignored due to path filters (31)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/sdks/typescript/bridge_typescript/dist/call_context.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/call_context.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/call_context.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/call_context.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/define_function.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/define_function.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/define_function.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/errors.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/errors.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/errors.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/errors.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/index.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/index.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/index.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/platform.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/platform.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/platform.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/platform.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/proto.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/proto.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/proto.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/stream.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/stream.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/stream.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript_web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (86)
  • baml_language/.cargo/size-gate.toml
  • baml_language/.ci/size-gate/aarch64-apple-darwin.toml
  • baml_language/.ci/size-gate/wasm32-unknown-unknown.toml
  • baml_language/.ci/size-gate/x86_64-pc-windows-msvc.toml
  • baml_language/.ci/size-gate/x86_64-unknown-linux-gnu.toml
  • baml_language/Cargo.toml
  • baml_language/crates/bex_engine/src/conversion.rs
  • baml_language/crates/bex_engine/src/lib.rs
  • baml_language/crates/bex_engine/tests/host_value_callable.rs
  • baml_language/crates/bex_external_types/src/host_return.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/crates/bridge_cffi/src/baml_to_host.rs
  • baml_language/crates/bridge_cffi/src/ffi/handle.rs
  • baml_language/crates/bridge_cffi/src/handle.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_ctypes/src/handle_table.rs
  • baml_language/crates/bridge_wasm/Cargo.toml
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/crates/sys_wasm/src/host_value.rs
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/crates/sys_wasm/src/send_wrapper.rs
  • baml_language/crates/sys_wasm/src/web_sysops.rs
  • baml_language/sdk_tests/DEVELOPMENT.md
  • baml_language/sdk_tests/README.md
  • baml_language/sdk_tests/crates/typescript/docstrings_etc/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/cancellation.test.ts
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/host_callables.test.ts
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/stdlib_entrypoints.test.ts
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/web_sysops.test.ts
  • baml_language/sdk_tests/crates/typescript/llm_functions/customizable/streaming_e2e.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/bridge_handles_media.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/bridge_surface.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_handles.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_media.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/typemap.test.ts
  • baml_language/sdk_tests/crates/typescript_web/setup.ps1
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • baml_language/sdk_tests/fixtures/function_calls/baml_src/ns_host_callable_tests/main.baml
  • baml_language/sdk_tests/fixtures/function_calls/baml_src/ns_methods_on_classes/types.baml
  • baml_language/sdk_tests/harness_setup/src/typescript.rs
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
  • baml_language/sdks/typescript/bridge_typescript/src/baml_call_context.rs
  • baml_language/sdks/typescript/bridge_typescript/tests/test_decode_call_result.test.ts
  • baml_language/sdks/typescript/bridge_typescript/tests/test_typemap.test.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/call_context.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/define_function.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/errors.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/host_value_registry.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/index.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/platform.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/proto.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/stream.ts
  • baml_language/sdks/typescript/bridge_typescript_web/Cargo.toml
  • baml_language/sdks/typescript/bridge_typescript_web/package.json
  • baml_language/sdks/typescript/bridge_typescript_web/pnpm-workspace.yaml
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-node-runtime.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/src/errors.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/handle.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/host_value.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/lib.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/media.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/runtime.rs
  • baml_language/sdks/typescript/bridge_typescript_web/tests/bridge-web-core.d.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/call_context.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/host_value_registry.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/runtime_errors.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/typemap_builtins.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/wasm_exports.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/worker.js
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/platform.ts
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/wasm/bridge_web_core.d.ts
  • baml_language/sdks/typescript/bridge_typescript_web/vitest.web.config.ts
  • baml_language/sdks/typescript/bridge_typescript_web/vitest.workers.config.ts
  • baml_language/sdks/typescript/bridge_typescript_web/wrangler.test.jsonc
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/emit/typemap_file.rs
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rs
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript.rs
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript_web.rs
💤 Files with no reviewable changes (1)
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
🚧 Files skipped from review as they are similar to previous changes (13)
  • baml_language/.ci/size-gate/x86_64-unknown-linux-gnu.toml
  • baml_language/.ci/size-gate/x86_64-pc-windows-msvc.toml
  • baml_language/.ci/size-gate/wasm32-unknown-unknown.toml
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/.cargo/size-gate.toml
  • baml_language/.ci/size-gate/aarch64-apple-darwin.toml
  • baml_language/Cargo.toml
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • baml_language/crates/sys_wasm/src/web_sysops.rs

coderabbitai[bot]
coderabbitai Bot previously requested changes Jul 20, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
baml_language/sdk_tests/README.md (1)

188-211: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Distinguish the two Web parity gates.

The section calls the cargo nextest command the “full Web parity gate,” but the raw bridge boundary tests below require separate pnpm commands. Label the cargo command as the fixture-driven gate and explicitly state that the bridge package commands are also required for complete coverage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdk_tests/README.md` around lines 188 - 211, The README’s Web
parity section conflates the fixture-driven and raw bridge test gates. Update
the section around the cargo nextest commands to label them as the
fixture-driven gate, and explicitly state that the bridge package commands
(`pnpm build:debug`, `pnpm test:web`, and `pnpm test:workers`) are also required
for complete Web coverage.
baml_language/crates/bex_external_types/src/host_return.rs (1)

192-198: 📐 Maintainability & Code Quality | 🔵 Trivial

Run cargo test --lib from baml_language with a working C toolchain.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/crates/bex_external_types/src/host_return.rs` around lines 192
- 198, Run cargo test --lib from the baml_language workspace with a working C
toolchain, and resolve any test failures affecting the RuntimeTy::Function
handling in the host return type logic.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts`:
- Line 7: Update the package-root export in index.ts to re-export LLMCall from
native.js alongside the other public bridge symbols, preserving the existing
public API exports.

In
`@baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts`:
- Around line 186-293: Add a public deterministic release method, such as
dispose() or release(), to BamlHandle and exported BamlMedia-derived types.
Reuse the existing _releaseForTest() state transition and
finalizer-unregistration logic so release is idempotent, rejects further use
through assertLive(), and frees wasm-backed handles immediately; retain
_releaseForTest() compatibility if existing tests depend on it.

---

Nitpick comments:
In `@baml_language/crates/bex_external_types/src/host_return.rs`:
- Around line 192-198: Run cargo test --lib from the baml_language workspace
with a working C toolchain, and resolve any test failures affecting the
RuntimeTy::Function handling in the host return type logic.

In `@baml_language/sdk_tests/README.md`:
- Around line 188-211: The README’s Web parity section conflates the
fixture-driven and raw bridge test gates. Update the section around the cargo
nextest commands to label them as the fixture-driven gate, and explicitly state
that the bridge package commands (`pnpm build:debug`, `pnpm test:web`, and `pnpm
test:workers`) are also required for complete Web coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 05a23c33-b72b-4f60-8235-253ef578b3d1

📥 Commits

Reviewing files that changed from the base of the PR and between 674c272 and 4f5835d.

⛔ Files ignored due to path filters (31)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/sdks/typescript/bridge_typescript/dist/call_context.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/call_context.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/call_context.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/call_context.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/define_function.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/define_function.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/define_function.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/errors.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/errors.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/errors.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/errors.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/index.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/index.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/index.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/platform.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/platform.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/platform.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/platform.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/proto.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/proto.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/proto.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/stream.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/stream.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/stream.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript_web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (86)
  • baml_language/.cargo/size-gate.toml
  • baml_language/.ci/size-gate/aarch64-apple-darwin.toml
  • baml_language/.ci/size-gate/wasm32-unknown-unknown.toml
  • baml_language/.ci/size-gate/x86_64-pc-windows-msvc.toml
  • baml_language/.ci/size-gate/x86_64-unknown-linux-gnu.toml
  • baml_language/Cargo.toml
  • baml_language/crates/bex_engine/src/conversion.rs
  • baml_language/crates/bex_engine/src/lib.rs
  • baml_language/crates/bex_engine/tests/host_value_callable.rs
  • baml_language/crates/bex_external_types/src/host_return.rs
  • baml_language/crates/bex_vm_types/src/bytecode.rs
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/crates/bridge_cffi/src/baml_to_host.rs
  • baml_language/crates/bridge_cffi/src/ffi/handle.rs
  • baml_language/crates/bridge_cffi/src/handle.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_ctypes/src/handle_table.rs
  • baml_language/crates/bridge_wasm/Cargo.toml
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/crates/sys_wasm/src/host_value.rs
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/crates/sys_wasm/src/send_wrapper.rs
  • baml_language/crates/sys_wasm/src/web_sysops.rs
  • baml_language/sdk_tests/DEVELOPMENT.md
  • baml_language/sdk_tests/README.md
  • baml_language/sdk_tests/crates/typescript/docstrings_etc/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/cancellation.test.ts
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/host_callables.test.ts
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/stdlib_entrypoints.test.ts
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/web_sysops.test.ts
  • baml_language/sdk_tests/crates/typescript/llm_functions/customizable/streaming_e2e.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/bridge_handles_media.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/bridge_surface.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_handles.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_media.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/typemap.test.ts
  • baml_language/sdk_tests/crates/typescript_web/setup.ps1
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • baml_language/sdk_tests/fixtures/function_calls/baml_src/ns_host_callable_tests/main.baml
  • baml_language/sdk_tests/fixtures/function_calls/baml_src/ns_methods_on_classes/types.baml
  • baml_language/sdk_tests/harness_setup/src/typescript.rs
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
  • baml_language/sdks/typescript/bridge_typescript/src/baml_call_context.rs
  • baml_language/sdks/typescript/bridge_typescript/tests/test_decode_call_result.test.ts
  • baml_language/sdks/typescript/bridge_typescript/tests/test_typemap.test.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/call_context.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/define_function.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/errors.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/host_value_registry.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/index.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/platform.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/proto.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/stream.ts
  • baml_language/sdks/typescript/bridge_typescript_web/Cargo.toml
  • baml_language/sdks/typescript/bridge_typescript_web/package.json
  • baml_language/sdks/typescript/bridge_typescript_web/pnpm-workspace.yaml
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-node-runtime.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/src/errors.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/handle.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/host_value.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/lib.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/media.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/runtime.rs
  • baml_language/sdks/typescript/bridge_typescript_web/tests/bridge-web-core.d.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/call_context.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/host_value_registry.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/runtime_errors.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/typemap_builtins.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/wasm_exports.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/worker.js
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/platform.ts
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/wasm/bridge_web_core.d.ts
  • baml_language/sdks/typescript/bridge_typescript_web/vitest.web.config.ts
  • baml_language/sdks/typescript/bridge_typescript_web/vitest.workers.config.ts
  • baml_language/sdks/typescript/bridge_typescript_web/wrangler.test.jsonc
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/emit/typemap_file.rs
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rs
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript.rs
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript_web.rs
💤 Files with no reviewable changes (1)
  • baml_language/sdk_tests/harness_setup/src/typescript_web.rs
🚧 Files skipped from review as they are similar to previous changes (71)
  • baml_language/sdks/typescript/bridge_typescript_web/wrangler.test.jsonc
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/platform.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/bridge-web-core.d.ts
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/.ci/size-gate/wasm32-unknown-unknown.toml
  • baml_language/sdk_tests/fixtures/function_calls/baml_src/ns_methods_on_classes/types.baml
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/typemap.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/vitest.workers.config.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/call_context.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/worker.js
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/main.test.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_media.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/vitest.web.config.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_handles.test.ts
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • baml_language/sdks/typescript/bridge_typescript_web/tests/typemap_builtins.test.ts
  • baml_language/crates/bridge_wasm/Cargo.toml
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/host_value_registry.ts
  • baml_language/sdk_tests/crates/typescript/type_shapes/customizable/bridge_handles_media.test.ts
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/emit/typemap_file.rs
  • baml_language/.ci/size-gate/aarch64-apple-darwin.toml
  • baml_language/.ci/size-gate/x86_64-pc-windows-msvc.toml
  • baml_language/sdk_tests/fixtures/function_calls/baml_src/ns_host_callable_tests/main.baml
  • baml_language/sdk_tests/DEVELOPMENT.md
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/platform.ts
  • baml_language/crates/sys_wasm/src/send_wrapper.rs
  • baml_language/sdks/typescript/bridge_typescript_web/pnpm-workspace.yaml
  • baml_language/sdks/typescript/bridge_typescript_web/tests/call_context.test.ts
  • baml_language/sdk_tests/harness_setup/src/typescript.rs
  • baml_language/sdks/typescript/bridge_typescript_web/Cargo.toml
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/web_sysops.test.ts
  • baml_language/.ci/size-gate/x86_64-unknown-linux-gnu.toml
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript_web.rs
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/stdlib_entrypoints.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/runtime_errors.test.ts
  • baml_language/sdks/typescript/bridge_typescript/tests/test_decode_call_result.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/src/errors.rs
  • baml_language/sdks/typescript/bridge_typescript/tests/test_typemap.test.ts
  • baml_language/sdks/typescript/bridge_typescript/src/baml_call_context.rs
  • baml_language/Cargo.toml
  • baml_language/sdks/typescript/bridge_typescript_web/package.json
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjs
  • baml_language/.cargo/size-gate.toml
  • baml_language/sdks/typescript/bridge_typescript_web/src/runtime.rs
  • baml_language/crates/bridge_cffi/src/baml_to_host.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/lib.rs
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/errors.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/define_function.ts
  • baml_language/crates/bridge_cffi/src/handle.rs
  • baml_language/crates/bex_engine/tests/host_value_callable.rs
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/stream.ts
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/sdks/typescript/bridge_typescript_web/tests/wasm_exports.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-node-runtime.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/src/host_value.rs
  • baml_language/crates/bex_engine/src/lib.rs
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rs
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/host_callables.test.ts
  • baml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript.rs
  • baml_language/crates/bex_engine/src/conversion.rs
  • baml_language/crates/bridge_cffi/src/ffi/handle.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/media.rs
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjs
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/proto.ts
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/crates/sys_wasm/src/web_sysops.rs
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/index.ts
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/wasm/bridge_web_core.d.ts
  • baml_language/crates/sys_wasm/src/host_value.rs

installHostCallableDispatchFactory(makeHostCallableDispatch);

export { BamlAudio, BamlCallContext, BamlHandle, BamlImage, BamlPdf, BamlRuntime, BamlVideo, Collector, FunctionLog, HostSpanManager, LLMCall, Timing, Usage, flushEvents, getRuntime, getVersion, newFunctionCall } from "./native.js";
export { BamlAudio, BamlCallContext, BamlHandle, BamlImage, BamlPdf, BamlRuntime, BamlVideo, Collector, FunctionLog, HostSpanManager, Timing, Usage, _seedFunctionRefHandle, _seedGenericMediaHandle, flushEvents, getRuntime, getVersion, newFunctionCall } from "./native.js";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C 2 '\bLLMCall\b' baml_language

Repository: BoundaryML/baml

Length of output: 15073


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the web entrypoint and nearby type files first
ast-grep outline baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts --view expanded || true
ast-grep outline baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts --view expanded || true
ast-grep outline baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.d.ts --view expanded || true

# Read the relevant slices with line numbers
sed -n '1,80p' baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts
printf '\n--- native.ts slice ---\n'
sed -n '360,390p' baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts
printf '\n--- native.d.ts slice ---\n'
sed -n '140,180p' baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.d.ts

# Inspect package entrypoints for the web SDK
printf '\n--- package files ---\n'
git ls-files 'baml_language/sdks/typescript/bridge_typescript_web/**/package.json' 'baml_language/sdks/typescript/bridge_typescript_web/**/tsconfig*.json' 'baml_language/sdks/typescript/bridge_typescript_web/**/index.ts' | sort

Repository: BoundaryML/baml

Length of output: 15505


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the web package manifest and any explicit exports map.
git ls-files 'baml_language/sdks/typescript/bridge_typescript_web/**/package.json' 'baml_language/sdks/typescript/bridge_typescript_web/**/tsconfig*.json' 'baml_language/sdks/typescript/bridge_typescript_web/**/README*' | sort

printf '\n--- package.json ---\n'
sed -n '1,220p' baml_language/sdks/typescript/bridge_typescript_web/package.json

printf '\n--- tsconfig files ---\n'
for f in $(git ls-files 'baml_language/sdks/typescript/bridge_typescript_web/**/tsconfig*.json'); do
  printf '\n### %s ###\n' "$f"
  sed -n '1,220p' "$f"
done

printf '\n--- search for package root exports ---\n'
rg -n --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' '\bLLMCall\b|export \{.*LLMCall|from "./native\.js"|from '\''\.\/native\.js'\''' baml_language/sdks/typescript/bridge_typescript_web

Repository: BoundaryML/baml

Length of output: 2258


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search the web package for public-facing LLMCall exports/usages.
rg -n -C 2 --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' \
  'export \{[^}]*\bLLMCall\b|from "\./native\.js"|from '\''\./native\.js'\''|\bLLMCall\b' \
  baml_language/sdks/typescript/bridge_typescript_web

printf '\n--- non-web bridge comparison ---\n'
sed -n '1,40p' baml_language/sdks/typescript/bridge_typescript/typescript_src/index.ts

printf '\n--- web index excerpt ---\n'
sed -n '1,30p' baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts

printf '\n--- web native excerpt around LLMCall ---\n'
sed -n '372,384p' baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts

Repository: BoundaryML/baml

Length of output: 7343


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find any consumer code importing LLMCall from the web package root.
rg -n --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' \
  '`@boundaryml/baml-bridge-web`.*LLMCall|from [\'\"]`@boundaryml/baml-bridge-web`[\'\"].*LLMCall|import .*LLMCall.*`@boundaryml/baml-bridge-web`' \
  baml_language

Repository: BoundaryML/baml

Length of output: 213


Re-export LLMCall from baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts:7. native.ts still exposes LLMCall, but the package root only publishes dist/index.js/dist/index.d.ts, so omitting it here removes it from the public @boundaryml/baml-bridge-web API and breaks existing imports.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts`
at line 7, Update the package-root export in index.ts to re-export LLMCall from
native.js alongside the other public bridge symbols, preserving the existing
public API exports.

Comment on lines +186 to 293
const ordinaryHandleFinalizer = new FinalizationRegistry<bigint>((key) => {
try {
releaseWasmHandle(key);
} catch {
// Finalizers may run during isolate teardown. Eventual cleanup is best-effort.
}
});

export class BamlHandle {
constructor(public readonly key: HandleKey, public readonly handleType: number) {}
clone(): BamlHandle { return new BamlHandle(this.key, this.handleType); }
_cloneKeyForWire(): HandleKey { return this.key; }
private readonly rawKey: bigint;
private readonly finalizerToken: object | undefined;
private released = false;

constructor(key: HandleKey, public readonly handleType: number) {
this.rawKey = keyToBigint(key);
if (isHostValueHandleType(handleType)) {
this.finalizerToken = undefined;
} else {
this.finalizerToken = {};
ordinaryHandleFinalizer.register(this, this.rawKey, this.finalizerToken);
}
}

get key(): HandleKey {
this.assertLive();
return keyFromBigint(this.rawKey);
}

private assertLive(): void {
if (this.released) throw new Error("BamlHandle has been released");
}

_keyForBridge(): bigint {
this.assertLive();
return this.rawKey;
}

clone(): BamlHandle {
this.assertLive();
if (isHostValueHandleType(this.handleType)) return new BamlHandle(this.key, this.handleType);
return new BamlHandle(keyFromBigint(cloneWasmHandle(this.rawKey)), this.handleType);
}

_cloneKeyForWire(): HandleKey {
this.assertLive();
if (isHostValueHandleType(this.handleType)) return keyFromBigint(this.rawKey);
return keyFromBigint(cloneWasmHandle(this.rawKey));
}

_releaseForTest(): boolean {
if (isHostValueHandleType(this.handleType) || this.released) return false;
this.released = true;
if (this.finalizerToken) ordinaryHandleFinalizer.unregister(this.finalizerToken);
return releaseWasmHandle(this.rawKey);
}
}

class BamlMedia {
protected constructor(private readonly handle: BamlHandle) {}
static fromUrl(_url: string, _mimeType?: string | null): BamlMedia { throw new Error("browser media construction is not implemented yet"); }
static fromFile(_file: string, _mimeType?: string | null): BamlMedia { throw new Error("browser media construction is not implemented yet"); }
static fromBase64(_base64: string, _mimeType?: string | null): BamlMedia { throw new Error("browser media construction is not implemented yet"); }
static _fromHandle(handle: BamlHandle): BamlMedia { return new this(handle); }
_toHandle(): BamlHandle { return this.handle.clone(); }
url(): string | null { return null; }
file(): string | null { return null; }
base64(): string { throw new Error("browser media access is not implemented yet"); }
mimeType(): string | null { return null; }
abstract class BamlMedia {
private readonly finalizerToken = {};
private released = false;

protected constructor(private readonly rawKey: bigint, private readonly handleType: number) {
ordinaryHandleFinalizer.register(this, rawKey, this.finalizerToken);
}

protected static cloneKeyFromHandle(handle: BamlHandle, expectedHandleType: number, className: string): bigint {
if (handle.handleType !== expectedHandleType) {
throw new TypeError(`${className} requires handle type ${expectedHandleType}, got ${handle.handleType}`);
}
return cloneWasmHandle(handle._keyForBridge());
}

private assertLive(): void {
if (this.released) throw new Error(`${this.constructor.name} has been released`);
}

_toHandle(): BamlHandle {
this.assertLive();
return new BamlHandle(keyFromBigint(cloneWasmHandle(this.rawKey)), this.handleType);
}

url(): string | null {
this.assertLive();
return mediaWasmUrl(this.rawKey, this.handleType) ?? null;
}

file(): string | null {
this.assertLive();
return mediaWasmFile(this.rawKey, this.handleType) ?? null;
}

base64(): string {
this.assertLive();
return mediaWasmBase64(this.rawKey, this.handleType);
}

mimeType(): string | null {
this.assertLive();
return mediaWasmMimeType(this.rawKey, this.handleType) ?? null;
}

_releaseForTest(): boolean {
if (this.released) return false;
this.released = true;
ordinaryHandleFinalizer.unregister(this.finalizerToken);
return releaseWasmHandle(this.rawKey);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the relevant file and search for related release/dispose APIs.
git ls-files | rg 'baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native\.ts|BamlHandle|BamlMedia|releaseWasmHandle|dispose|releaseForTest|FinalizationRegistry'

echo '--- outline native.ts ---'
ast-grep outline baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts --view expanded || true

echo '--- search for public disposal/lifetime APIs ---'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' \
  '\b(dispose|release)\b|FinalizationRegistry|releaseWasmHandle|_releaseForTest|BamlHandle|BamlMedia' \
  baml_language/sdks/typescript/bridge_typescript_web/typescript_src

echo '--- surrounding lines in native.ts ---'
sed -n '1,360p' baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts

Repository: BoundaryML/baml

Length of output: 26957


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check how the public SDK surfaces these types and whether callers can realistically release them.
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' \
  '\bnew BamlHandle\b|\bnew BamlMedia\b|\bdispose\b|\brelease\b|using\b|Symbol\.dispose|Symbol\.asyncDispose' \
  baml_language/sdks/typescript/bridge_typescript_web

Repository: BoundaryML/baml

Length of output: 1634


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read only the most relevant file sections and look for consumer patterns.
file='baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts'
wc -l "$file"
sed -n '1,260p' "$file" | nl -ba | sed -n '1,260p'

echo '--- consumer search ---'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' \
  '\bBamlHandle\b|\bBamlMedia\b|\._releaseForTest\(' \
  baml_language/sdks/typescript/bridge_typescript_web

Repository: BoundaryML/baml

Length of output: 274


🌐 Web query:

Cloudflare Workers FinalizationRegistry GC may not even run cleanup callbacks workers blog

💡 Result:

Yes, it is accurate that FinalizationRegistry cleanup callbacks may not run in Cloudflare Workers [1][2]. The FinalizationRegistry API is inherently non-deterministic [1][2]. Because it relies on the JavaScript engine's garbage collection process—which is unpredictable and outside of developer control—there is no guarantee that a cleanup callback will ever execute [1][2][3]. Key points regarding FinalizationRegistry in Cloudflare Workers include: Non-deterministic execution: Garbage collection may not be triggered, or the Worker environment may be evicted before the collector runs, meaning your cleanup callbacks might never be called [1][2]. Not for critical logic: Because of this uncertainty, Cloudflare explicitly advises against using FinalizationRegistry for essential program logic [2]. It is intended specifically for non-critical resource cleanup, such as releasing memory allocated by WebAssembly (e.g., via Emscripten or wasm-bindgen) [1][4][5]. Execution environment: When these callbacks do run, they do not have an associated async context, and performing I/O within them is prohibited [1][2]. They are queued to run only after the microtask queue has drained, typically between I/O phases of the event loop [1]. Compatibility flag: To use this feature, you must opt-in by enabling the enable_weak_ref compatibility flag [4][2]. Given these limitations, Cloudflare recommends that developers should not rely on FinalizationRegistry for managing critical resources and suggests using alternatives like Explicit Resource Management (via Symbol.dispose) when available for more predictable lifecycle handling [1][2][6].

Citations:


Add a public release path for wasm-backed handles
BamlHandle and the exported media types only free wasm state through FinalizationRegistry; _releaseForTest() is test-only. In Workers, GC timing is unpredictable, so these resources can linger until isolate teardown. Expose dispose()/release() so callers can free them deterministically.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts`
around lines 186 - 293, Add a public deterministic release method, such as
dispose() or release(), to BamlHandle and exported BamlMedia-derived types.
Reuse the existing _releaseForTest() state transition and
finalizer-unregistration logic so release is idempotent, rejects further use
through assertLive(), and frees wasm-backed handles immediately; retain
_releaseForTest() compatibility if existing tests depend on it.

This branch was previously deployed

3 inactive deployments
Preview – promptfiddle — 4f5835d7 Deployed Jul 20, 2026 by vercel[bot]
Preview – promptfiddle2 — 4f5835d7 Deployed Jul 20, 2026 by vercel[bot]
Preview – beps — 4f5835d7 Deployed Jul 20, 2026 by vercel[bot]
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