Repository navigation
feat(typescript-web): implement browser and Workers runtimes - #4006
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
There was a problem hiding this comment.
💡 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".
📝 WalkthroughWalkthroughThe 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. ChangesWASM runtime and bridge
TypeScript SDK integration
Supporting updates
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
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Binary size checks passed✅ 7 passed
Generated by |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (6)
baml_language/sdks/web/bridge_web/Cargo.toml (1)
1-6: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winConsider
publish = falsefor this internal-only wasm crate.
bridge_webis built for browser distribution viawasm-pack/npm, not crates.io. The sibling new cratesdkgen_typescript_web/Cargo.tomlexplicitly setspublish = false; this crate lacks it, risking an accidentalcargo 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 winModule-level wasm32 gate blocks native unit testing of the new bridge scaffold.
wasm.rsonly depends onstd::sync::atomic, but gatingmod wasm;itself (not just the re-export) totarget_arch = "wasm32"means its logic is excluded from ordinary host builds/tests.
baml_language/crates/bridge_cffi/src/lib.rs#L12-L15: only gatepub use wasm::*;to wasm32; leavemod 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 forstage_runtime_bytecode(empty vs. non-empty bytecode) andcall_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 winAdd 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 dynamicimport("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", butnext()/final()(Lines 59, 61) will attempt a realinvoke()call and cast the raw bytesas TPartial/as TFinal. Calling these directly today will fail confusingly deep insideinvoke()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 winConsider unit tests for the pure helper functions.
rewrite_test_bridge_importsandhas_vitest_testsare self-contained filesystem-predicate/transform helpers that don't need the full build-script context to test (e.g. against atempdirfixture 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 winAdd a unit test for the bridge-import rewrite.
This crate has zero tests. The core behavior (
to_source_coderewriting@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 runcargo test --libif you changed any Rust code", please runcargo 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
⛔ Files ignored due to path filters (2)
baml_language/Cargo.lockis excluded by!**/*.lockbaml_language/sdks/web/bridge_web/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (28)
baml_language/.config/nextest.tomlbaml_language/Cargo.tomlbaml_language/crates/bridge_cffi/Cargo.tomlbaml_language/crates/bridge_cffi/src/lib.rsbaml_language/crates/bridge_cffi/src/wasm.rsbaml_language/sdk_tests/crates/typescript_web/.gitignorebaml_language/sdk_tests/crates/typescript_web/Cargo.tomlbaml_language/sdk_tests/crates/typescript_web/build.rsbaml_language/sdk_tests/crates/typescript_web/setup.ps1baml_language/sdk_tests/crates/typescript_web/setup.shbaml_language/sdk_tests/crates/typescript_web/src/lib.rsbaml_language/sdk_tests/harness_runner/src/lib.rsbaml_language/sdk_tests/harness_setup/Cargo.tomlbaml_language/sdk_tests/harness_setup/src/lib.rsbaml_language/sdk_tests/harness_setup/src/templates/package_web.jsonbaml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.jsonbaml_language/sdk_tests/harness_setup/src/templates/vitest_web.config.tsbaml_language/sdk_tests/harness_setup/src/typescript_web.rsbaml_language/sdks/web/bridge_web/.gitignorebaml_language/sdks/web/bridge_web/Cargo.tomlbaml_language/sdks/web/bridge_web/package.jsonbaml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjsbaml_language/sdks/web/bridge_web/src/lib.rsbaml_language/sdks/web/bridge_web/tsconfig.jsonbaml_language/sdks/web/bridge_web/typescript_src/index.tsbaml_language/sdks/web/bridge_web/typescript_src/wasm/bridge_web_core.d.tsbaml_language/sdks/web/sdkgen_typescript_web/Cargo.tomlbaml_language/sdks/web/sdkgen_typescript_web/src/lib.rs
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
baml_language/crates/bridge_cffi/src/wasm.rs (1)
15-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd unit tests for
decode_call
Cover thecall_id == 0guard and the type-args/kwargs decoding paths inbaml_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 valueRedundant patch on
distProto/baml_cffi.js.The
baml_cffi.jspatch loop (lines 23-27) rewrites the protobufjs import in bothshared/protoanddistProtocopies, but the subsequentesbuildcall (lines 28-34) bundles fromshared/proto/baml_cffi.jsand writes its output to the exact samedistProto/baml_cffi.jspath, overwriting the patch just applied there. The second loop iteration's read/patch/write ondistProtois 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
⛔ Files ignored due to path filters (2)
baml_language/Cargo.lockis excluded by!**/*.lockbaml_language/sdks/web/bridge_web/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (35)
baml_language/.config/nextest.tomlbaml_language/Cargo.tomlbaml_language/crates/bex_vm_types/src/bytecode.rsbaml_language/crates/bridge_cffi/Cargo.tomlbaml_language/crates/bridge_cffi/src/lib.rsbaml_language/crates/bridge_cffi/src/wasm.rsbaml_language/crates/bridge_wasm/src/host_value.rsbaml_language/crates/bridge_wasm/src/lib.rsbaml_language/crates/sys_wasm/Cargo.tomlbaml_language/crates/sys_wasm/src/lib.rsbaml_language/sdk_tests/crates/typescript_web/.gitignorebaml_language/sdk_tests/crates/typescript_web/Cargo.tomlbaml_language/sdk_tests/crates/typescript_web/build.rsbaml_language/sdk_tests/crates/typescript_web/setup.ps1baml_language/sdk_tests/crates/typescript_web/setup.shbaml_language/sdk_tests/crates/typescript_web/src/lib.rsbaml_language/sdk_tests/harness_runner/src/lib.rsbaml_language/sdk_tests/harness_setup/Cargo.tomlbaml_language/sdk_tests/harness_setup/src/lib.rsbaml_language/sdk_tests/harness_setup/src/templates/package_web.jsonbaml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.jsonbaml_language/sdk_tests/harness_setup/src/templates/vitest_web.config.tsbaml_language/sdk_tests/harness_setup/src/typescript_web.rsbaml_language/sdks/web/bridge_web/.gitignorebaml_language/sdks/web/bridge_web/Cargo.tomlbaml_language/sdks/web/bridge_web/package.jsonbaml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjsbaml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjsbaml_language/sdks/web/bridge_web/src/lib.rsbaml_language/sdks/web/bridge_web/tsconfig.jsonbaml_language/sdks/web/bridge_web/typescript_src/index.tsbaml_language/sdks/web/bridge_web/typescript_src/native.tsbaml_language/sdks/web/bridge_web/typescript_src/wasm/bridge_web_core.d.tsbaml_language/sdks/web/sdkgen_typescript_web/Cargo.tomlbaml_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
8268b66 to
d249623
Compare
There was a problem hiding this comment.
Actionable comments posted: 5
♻️ Duplicate comments (1)
baml_language/crates/bridge_cffi/src/wasm.rs (1)
105-107: 🩺 Stability & Availability | 🔴 CriticalAvoid
block_onon the wasm32 path.
futures::executor::block_oncan panic or hang onwasm32as soon ascall_function_in_wasmyields. 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 | 🔵 TrivialUse a build image with the C toolchain for
cargo test --libThe workspace test run stops inaws-lc-syshere because standard headers likestdlib.handlinux/random.hare 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 valueDeduplicate primitive types in generated unions. The generator emits union types containing duplicate primitives (e.g.,
numberappears 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 generatingCsvValue$stream.workers-demo/src/baml_sdk/baml/csv/index.ts#L546-L546: deduplicate the mapped primitives when generatingCsvValue.🤖 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
⛔ Files ignored due to path filters (6)
baml_language/Cargo.lockis excluded by!**/*.lockbaml_language/sdks/web/bridge_web/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlworkers-demo/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlworkers-demo2/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlworkers-demo3/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlworkers-npm-demo/pnpm-lock.yamlis 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.ymlbaml_language/.config/nextest.tomlbaml_language/Cargo.tomlbaml_language/crates/baml_cli/Cargo.tomlbaml_language/crates/baml_cli/src/generate.rsbaml_language/crates/baml_codegen_types/src/generator_fields.rsbaml_language/crates/bex_vm_types/src/bytecode.rsbaml_language/crates/bridge_cffi/Cargo.tomlbaml_language/crates/bridge_cffi/src/buffer.rsbaml_language/crates/bridge_cffi/src/error.rsbaml_language/crates/bridge_cffi/src/ffi/objects.rsbaml_language/crates/bridge_cffi/src/ffi/runtime.rsbaml_language/crates/bridge_cffi/src/lib.rsbaml_language/crates/bridge_cffi/src/sysop_impl.rsbaml_language/crates/bridge_cffi/src/wasm.rsbaml_language/crates/bridge_wasm/src/host_value.rsbaml_language/crates/bridge_wasm/src/lib.rsbaml_language/crates/sys_ops/src/lib.rsbaml_language/crates/sys_wasm/Cargo.tomlbaml_language/crates/sys_wasm/src/lib.rsbaml_language/crates/sys_wasm/src/web_sysops.rsbaml_language/sdk_tests/crates/typescript_node/function_calls/customizable/main.test.tsbaml_language/sdk_tests/crates/typescript_web/.gitignorebaml_language/sdk_tests/crates/typescript_web/Cargo.tomlbaml_language/sdk_tests/crates/typescript_web/build.rsbaml_language/sdk_tests/crates/typescript_web/function_calls/customizable/host_callables.test.tsbaml_language/sdk_tests/crates/typescript_web/function_calls/customizable/web_sysops.test.tsbaml_language/sdk_tests/crates/typescript_web/setup.ps1baml_language/sdk_tests/crates/typescript_web/setup.shbaml_language/sdk_tests/crates/typescript_web/src/lib.rsbaml_language/sdk_tests/fixtures/function_calls/baml_src/main.bamlbaml_language/sdk_tests/harness_runner/src/lib.rsbaml_language/sdk_tests/harness_setup/Cargo.tomlbaml_language/sdk_tests/harness_setup/src/lib.rsbaml_language/sdk_tests/harness_setup/src/templates/package_web.jsonbaml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.jsonbaml_language/sdk_tests/harness_setup/src/templates/vitest_web.config.tsbaml_language/sdk_tests/harness_setup/src/typescript_web.rsbaml_language/sdks/nodejs/bridge_nodejs/src/runtime.rsbaml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.tsbaml_language/sdks/nodejs/sdkgen_typescript_node/Cargo.tomlbaml_language/sdks/nodejs/sdkgen_typescript_node/src/lib.rsbaml_language/sdks/python/rust/bridge_python/src/runtime.rsbaml_language/sdks/sdkgen_typescript/Cargo.tomlbaml_language/sdks/sdkgen_typescript/src/emit/class.rsbaml_language/sdks/sdkgen_typescript/src/emit/enum_.rsbaml_language/sdks/sdkgen_typescript/src/emit/function.rsbaml_language/sdks/sdkgen_typescript/src/emit/method.rsbaml_language/sdks/sdkgen_typescript/src/emit/mod.rsbaml_language/sdks/sdkgen_typescript/src/emit/type_alias.rsbaml_language/sdks/sdkgen_typescript/src/emit/typemap_file.rsbaml_language/sdks/sdkgen_typescript/src/leaf.rsbaml_language/sdks/sdkgen_typescript/src/lib.rsbaml_language/sdks/sdkgen_typescript/src/routing.rsbaml_language/sdks/sdkgen_typescript/src/translate_ty.rsbaml_language/sdks/web/bridge_web/.gitignorebaml_language/sdks/web/bridge_web/Cargo.tomlbaml_language/sdks/web/bridge_web/package.jsonbaml_language/sdks/web/bridge_web/pnpm-workspace.yamlbaml_language/sdks/web/bridge_web/scripts/build-wasm-release.mjsbaml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjsbaml_language/sdks/web/bridge_web/scripts/prepare-workerd-package.mjsbaml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjsbaml_language/sdks/web/bridge_web/src/lib.rsbaml_language/sdks/web/bridge_web/tsconfig.jsonbaml_language/sdks/web/bridge_web/typescript_src/index.tsbaml_language/sdks/web/bridge_web/typescript_src/native.tsbaml_language/sdks/web/bridge_web/typescript_src/wasm/bridge_web_core.d.tsbaml_language/sdks/web/sdkgen_typescript_workers/Cargo.tomlbaml_language/sdks/web/sdkgen_typescript_workers/src/lib.rsmise.tomlscripts/baml-language-versionworkers-demo/.gitignoreworkers-demo/baml.tomlworkers-demo/baml_src/main.bamlworkers-demo/package.jsonworkers-demo/pnpm-workspace.yamlworkers-demo/src/baml_sdk/_inlinedbaml.tsworkers-demo/src/baml_sdk/_typemap.tsworkers-demo/src/baml_sdk/baml/csv/index.tsworkers-demo/src/baml_sdk/baml/env/index.tsworkers-demo/src/baml_sdk/baml/errors/index.tsworkers-demo/src/baml_sdk/baml/fs/index.tsworkers-demo/src/baml_sdk/baml/future/index.tsworkers-demo/src/baml_sdk/baml/glob/index.tsworkers-demo/src/baml_sdk/baml/host/index.tsworkers-demo/src/baml_sdk/baml/http/index.tsworkers-demo/src/baml_sdk/baml/id/index.tsworkers-demo/src/baml_sdk/baml/index.tsworkers-demo/src/baml_sdk/baml/io/index.tsworkers-demo/src/baml_sdk/baml/iter/index.tsworkers-demo/src/baml_sdk/baml/json/index.tsworkers-demo/src/baml_sdk/baml/llm/index.tsworkers-demo/src/baml_sdk/baml/media/index.tsworkers-demo/src/baml_sdk/baml/net/index.tsworkers-demo/src/baml_sdk/baml/ops/index.tsworkers-demo/src/baml_sdk/baml/panics/index.tsworkers-demo/src/baml_sdk/baml/spawn/index.tsworkers-demo/src/baml_sdk/baml/stream/index.tsworkers-demo/src/baml_sdk/baml/sys/index.tsworkers-demo/src/baml_sdk/baml/time/index.tsworkers-demo/src/baml_sdk/baml/toml/index.tsworkers-demo/src/baml_sdk/baml/yaml/index.tsworkers-demo/src/baml_sdk/index.tsworkers-demo/src/index.tsworkers-demo/tsconfig.jsonworkers-demo/worker-configuration.d.tsworkers-demo/wrangler.jsoncworkers-demo2/.gitignoreworkers-demo2/README.mdworkers-demo2/package.jsonworkers-demo2/pnpm-workspace.yamlworkers-demo2/scripts/assert-node-fs-rejected.mjsworkers-demo2/src/index.tsworkers-demo2/tsconfig.jsonworkers-demo2/worker-configuration.d.tsworkers-demo2/wrangler.jsoncworkers-demo3/.gitignoreworkers-demo3/README.mdworkers-demo3/package.jsonworkers-demo3/pnpm-workspace.yamlworkers-demo3/scripts/assert-process-env.mjsworkers-demo3/src/index.tsworkers-demo3/tsconfig.jsonworkers-demo3/worker-configuration.d.tsworkers-demo3/wrangler.jsoncworkers-demo3/wrangler.node-compat.jsoncworkers-npm-demo/.gitignoreworkers-npm-demo/README.mdworkers-npm-demo/package.jsonworkers-npm-demo/pnpm-workspace.yamlworkers-npm-demo/src/index.tsworkers-npm-demo/tsconfig.jsonworkers-npm-demo/worker-configuration.d.tsworkers-npm-demo/worker-startup.cpuprofileworkers-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
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (6)
baml_language/Cargo.lockis excluded by!**/*.lockbaml_language/sdks/web/bridge_web/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlworkers-demo/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlworkers-demo2/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlworkers-demo3/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlworkers-npm-demo/pnpm-lock.yamlis 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.ymlbaml_language/.config/nextest.tomlbaml_language/Cargo.tomlbaml_language/crates/baml_cli/Cargo.tomlbaml_language/crates/baml_cli/src/generate.rsbaml_language/crates/baml_codegen_types/src/generator_fields.rsbaml_language/crates/bex_vm_types/src/bytecode.rsbaml_language/crates/bridge_cffi/Cargo.tomlbaml_language/crates/bridge_cffi/src/buffer.rsbaml_language/crates/bridge_cffi/src/error.rsbaml_language/crates/bridge_cffi/src/ffi/objects.rsbaml_language/crates/bridge_cffi/src/ffi/runtime.rsbaml_language/crates/bridge_cffi/src/lib.rsbaml_language/crates/bridge_cffi/src/lib_native.rsbaml_language/crates/bridge_cffi/src/lib_wasm.rsbaml_language/crates/bridge_cffi/src/sysop_impl.rsbaml_language/crates/bridge_wasm/src/host_value.rsbaml_language/crates/bridge_wasm/src/lib.rsbaml_language/crates/sys_ops/src/lib.rsbaml_language/crates/sys_wasm/Cargo.tomlbaml_language/crates/sys_wasm/src/lib.rsbaml_language/crates/sys_wasm/src/web_sysops.rsbaml_language/sdk_tests/crates/typescript_node/function_calls/customizable/main.test.tsbaml_language/sdk_tests/crates/typescript_web/.gitignorebaml_language/sdk_tests/crates/typescript_web/Cargo.tomlbaml_language/sdk_tests/crates/typescript_web/build.rsbaml_language/sdk_tests/crates/typescript_web/function_calls/customizable/host_callables.test.tsbaml_language/sdk_tests/crates/typescript_web/function_calls/customizable/web_sysops.test.tsbaml_language/sdk_tests/crates/typescript_web/setup.ps1baml_language/sdk_tests/crates/typescript_web/setup.shbaml_language/sdk_tests/crates/typescript_web/src/lib.rsbaml_language/sdk_tests/fixtures/function_calls/baml_src/main.bamlbaml_language/sdk_tests/harness_runner/src/lib.rsbaml_language/sdk_tests/harness_setup/Cargo.tomlbaml_language/sdk_tests/harness_setup/src/lib.rsbaml_language/sdk_tests/harness_setup/src/templates/package_web.jsonbaml_language/sdk_tests/harness_setup/src/templates/tsconfig_web.jsonbaml_language/sdk_tests/harness_setup/src/templates/vitest_web.config.tsbaml_language/sdk_tests/harness_setup/src/typescript_web.rsbaml_language/sdks/nodejs/bridge_nodejs/src/runtime.rsbaml_language/sdks/nodejs/bridge_nodejs/typescript_src/proto.tsbaml_language/sdks/nodejs/sdkgen_typescript_node/Cargo.tomlbaml_language/sdks/nodejs/sdkgen_typescript_node/src/lib.rsbaml_language/sdks/python/rust/bridge_python/src/runtime.rsbaml_language/sdks/sdkgen_typescript/Cargo.tomlbaml_language/sdks/sdkgen_typescript/src/emit/class.rsbaml_language/sdks/sdkgen_typescript/src/emit/enum_.rsbaml_language/sdks/sdkgen_typescript/src/emit/function.rsbaml_language/sdks/sdkgen_typescript/src/emit/method.rsbaml_language/sdks/sdkgen_typescript/src/emit/mod.rsbaml_language/sdks/sdkgen_typescript/src/emit/type_alias.rsbaml_language/sdks/sdkgen_typescript/src/emit/typemap_file.rsbaml_language/sdks/sdkgen_typescript/src/leaf.rsbaml_language/sdks/sdkgen_typescript/src/lib.rsbaml_language/sdks/sdkgen_typescript/src/routing.rsbaml_language/sdks/sdkgen_typescript/src/translate_ty.rsbaml_language/sdks/web/bridge_web/.gitignorebaml_language/sdks/web/bridge_web/Cargo.tomlbaml_language/sdks/web/bridge_web/package.jsonbaml_language/sdks/web/bridge_web/pnpm-workspace.yamlbaml_language/sdks/web/bridge_web/scripts/build-wasm-release.mjsbaml_language/sdks/web/bridge_web/scripts/prepare-wasm-package.mjsbaml_language/sdks/web/bridge_web/scripts/prepare-workerd-package.mjsbaml_language/sdks/web/bridge_web/scripts/sync-node-runtime.mjsbaml_language/sdks/web/bridge_web/src/lib.rsbaml_language/sdks/web/bridge_web/tsconfig.jsonbaml_language/sdks/web/bridge_web/typescript_src/index.tsbaml_language/sdks/web/bridge_web/typescript_src/native.tsbaml_language/sdks/web/bridge_web/typescript_src/wasm/bridge_web_core.d.tsbaml_language/sdks/web/sdkgen_typescript_workers/Cargo.tomlbaml_language/sdks/web/sdkgen_typescript_workers/src/lib.rsmise.tomlscripts/baml-language-versionworkers-demo/.gitignoreworkers-demo/baml.tomlworkers-demo/baml_src/main.bamlworkers-demo/package.jsonworkers-demo/pnpm-workspace.yamlworkers-demo/src/baml_sdk/_inlinedbaml.tsworkers-demo/src/baml_sdk/_typemap.tsworkers-demo/src/baml_sdk/baml/csv/index.tsworkers-demo/src/baml_sdk/baml/env/index.tsworkers-demo/src/baml_sdk/baml/errors/index.tsworkers-demo/src/baml_sdk/baml/fs/index.tsworkers-demo/src/baml_sdk/baml/future/index.tsworkers-demo/src/baml_sdk/baml/glob/index.tsworkers-demo/src/baml_sdk/baml/host/index.tsworkers-demo/src/baml_sdk/baml/http/index.tsworkers-demo/src/baml_sdk/baml/id/index.tsworkers-demo/src/baml_sdk/baml/index.tsworkers-demo/src/baml_sdk/baml/io/index.tsworkers-demo/src/baml_sdk/baml/iter/index.tsworkers-demo/src/baml_sdk/baml/json/index.tsworkers-demo/src/baml_sdk/baml/llm/index.tsworkers-demo/src/baml_sdk/baml/media/index.tsworkers-demo/src/baml_sdk/baml/net/index.tsworkers-demo/src/baml_sdk/baml/ops/index.tsworkers-demo/src/baml_sdk/baml/panics/index.tsworkers-demo/src/baml_sdk/baml/spawn/index.tsworkers-demo/src/baml_sdk/baml/stream/index.tsworkers-demo/src/baml_sdk/baml/sys/index.tsworkers-demo/src/baml_sdk/baml/time/index.tsworkers-demo/src/baml_sdk/baml/toml/index.tsworkers-demo/src/baml_sdk/baml/yaml/index.tsworkers-demo/src/baml_sdk/index.tsworkers-demo/src/index.tsworkers-demo/tsconfig.jsonworkers-demo/worker-configuration.d.tsworkers-demo/wrangler.jsoncworkers-demo2/.gitignoreworkers-demo2/README.mdworkers-demo2/package.jsonworkers-demo2/pnpm-workspace.yamlworkers-demo2/scripts/assert-node-fs-rejected.mjsworkers-demo2/src/index.tsworkers-demo2/tsconfig.jsonworkers-demo2/worker-configuration.d.tsworkers-demo2/wrangler.jsoncworkers-demo3/.gitignoreworkers-demo3/README.mdworkers-demo3/package.jsonworkers-demo3/pnpm-workspace.yamlworkers-demo3/scripts/assert-process-env.mjsworkers-demo3/src/index.tsworkers-demo3/tsconfig.jsonworkers-demo3/worker-configuration.d.tsworkers-demo3/wrangler.jsoncworkers-demo3/wrangler.node-compat.jsoncworkers-npm-demo/.gitignoreworkers-npm-demo/README.mdworkers-npm-demo/package.jsonworkers-npm-demo/pnpm-workspace.yamlworkers-npm-demo/src/index.tsworkers-npm-demo/tsconfig.jsonworkers-npm-demo/worker-configuration.d.tsworkers-npm-demo/worker-startup.cpuprofileworkers-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
fa1d751 to
30b7aec
Compare
30b7aec to
38782ae
Compare
There was a problem hiding this comment.
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 valueRemove 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 winAdd 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 inffi/handle.rs. Adding focused#[test]s in this file (mirroring the style used forfunction_type_accepts_only_callablesinhost_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
⛔ Files ignored due to path filters (31)
baml_language/Cargo.lockis excluded by!**/*.lockbaml_language/sdks/typescript/bridge_typescript/dist/call_context.d.tsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/call_context.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/call_context.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/call_context.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/define_function.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/define_function.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/define_function.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/errors.d.tsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/errors.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/errors.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/errors.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.d.tsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/index.d.tsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/index.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/index.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/index.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/platform.d.tsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/platform.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/platform.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/platform.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/proto.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/proto.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/proto.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/stream.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/stream.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/stream.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript_web/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (86)
baml_language/.cargo/size-gate.tomlbaml_language/.ci/size-gate/aarch64-apple-darwin.tomlbaml_language/.ci/size-gate/wasm32-unknown-unknown.tomlbaml_language/.ci/size-gate/x86_64-pc-windows-msvc.tomlbaml_language/.ci/size-gate/x86_64-unknown-linux-gnu.tomlbaml_language/Cargo.tomlbaml_language/crates/bex_engine/src/conversion.rsbaml_language/crates/bex_engine/src/lib.rsbaml_language/crates/bex_engine/tests/host_value_callable.rsbaml_language/crates/bex_external_types/src/host_return.rsbaml_language/crates/bex_vm_types/src/bytecode.rsbaml_language/crates/bridge_cffi/Cargo.tomlbaml_language/crates/bridge_cffi/src/baml_to_host.rsbaml_language/crates/bridge_cffi/src/ffi/handle.rsbaml_language/crates/bridge_cffi/src/handle.rsbaml_language/crates/bridge_cffi/src/lib.rsbaml_language/crates/bridge_ctypes/src/handle_table.rsbaml_language/crates/bridge_wasm/Cargo.tomlbaml_language/crates/bridge_wasm/src/lib.rsbaml_language/crates/sys_ops/src/lib.rsbaml_language/crates/sys_wasm/Cargo.tomlbaml_language/crates/sys_wasm/src/host_value.rsbaml_language/crates/sys_wasm/src/lib.rsbaml_language/crates/sys_wasm/src/send_wrapper.rsbaml_language/crates/sys_wasm/src/web_sysops.rsbaml_language/sdk_tests/DEVELOPMENT.mdbaml_language/sdk_tests/README.mdbaml_language/sdk_tests/crates/typescript/docstrings_etc/customizable/main.test.tsbaml_language/sdk_tests/crates/typescript/function_calls/customizable/cancellation.test.tsbaml_language/sdk_tests/crates/typescript/function_calls/customizable/host_callables.test.tsbaml_language/sdk_tests/crates/typescript/function_calls/customizable/stdlib_entrypoints.test.tsbaml_language/sdk_tests/crates/typescript/function_calls/customizable/web_sysops.test.tsbaml_language/sdk_tests/crates/typescript/llm_functions/customizable/streaming_e2e.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/bridge_handles_media.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/bridge_surface.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/main.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_handles.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_media.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/typemap.test.tsbaml_language/sdk_tests/crates/typescript_web/setup.ps1baml_language/sdk_tests/crates/typescript_web/setup.shbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_host_callable_tests/main.bamlbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_methods_on_classes/types.bamlbaml_language/sdk_tests/harness_setup/src/typescript.rsbaml_language/sdk_tests/harness_setup/src/typescript_web.rsbaml_language/sdks/typescript/bridge_typescript/src/baml_call_context.rsbaml_language/sdks/typescript/bridge_typescript/tests/test_decode_call_result.test.tsbaml_language/sdks/typescript/bridge_typescript/tests/test_typemap.test.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/call_context.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/define_function.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/errors.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/host_value_registry.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/index.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/platform.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/proto.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/stream.tsbaml_language/sdks/typescript/bridge_typescript_web/Cargo.tomlbaml_language/sdks/typescript/bridge_typescript_web/package.jsonbaml_language/sdks/typescript/bridge_typescript_web/pnpm-workspace.yamlbaml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjsbaml_language/sdks/typescript/bridge_typescript_web/scripts/sync-node-runtime.mjsbaml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjsbaml_language/sdks/typescript/bridge_typescript_web/src/errors.rsbaml_language/sdks/typescript/bridge_typescript_web/src/handle.rsbaml_language/sdks/typescript/bridge_typescript_web/src/host_value.rsbaml_language/sdks/typescript/bridge_typescript_web/src/lib.rsbaml_language/sdks/typescript/bridge_typescript_web/src/media.rsbaml_language/sdks/typescript/bridge_typescript_web/src/runtime.rsbaml_language/sdks/typescript/bridge_typescript_web/tests/bridge-web-core.d.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/call_context.test.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/host_value_registry.test.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/runtime_errors.test.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/typemap_builtins.test.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/wasm_exports.test.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/worker.jsbaml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.tsbaml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.tsbaml_language/sdks/typescript/bridge_typescript_web/typescript_src/platform.tsbaml_language/sdks/typescript/bridge_typescript_web/typescript_src/wasm/bridge_web_core.d.tsbaml_language/sdks/typescript/bridge_typescript_web/vitest.web.config.tsbaml_language/sdks/typescript/bridge_typescript_web/vitest.workers.config.tsbaml_language/sdks/typescript/bridge_typescript_web/wrangler.test.jsoncbaml_language/sdks/typescript/sdkgen_typescript_shared/src/emit/typemap_file.rsbaml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rsbaml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript.rsbaml_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
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
baml_language/sdk_tests/README.md (1)
188-211: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDistinguish the two Web parity gates.
The section calls the
cargo nextestcommand the “full Web parity gate,” but the raw bridge boundary tests below require separatepnpmcommands. 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 | 🔵 TrivialRun
cargo test --libfrombaml_languagewith 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
⛔ Files ignored due to path filters (31)
baml_language/Cargo.lockis excluded by!**/*.lockbaml_language/sdks/typescript/bridge_typescript/dist/call_context.d.tsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/call_context.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/call_context.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/call_context.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/define_function.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/define_function.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/define_function.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/errors.d.tsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/errors.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/errors.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/errors.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.d.tsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/host_value_registry.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/index.d.tsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/index.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/index.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/index.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/platform.d.tsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/platform.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/platform.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/platform.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/proto.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/proto.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/proto.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/stream.d.ts.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript/dist/stream.jsis excluded by!**/dist/**baml_language/sdks/typescript/bridge_typescript/dist/stream.js.mapis excluded by!**/dist/**,!**/*.mapbaml_language/sdks/typescript/bridge_typescript_web/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (86)
baml_language/.cargo/size-gate.tomlbaml_language/.ci/size-gate/aarch64-apple-darwin.tomlbaml_language/.ci/size-gate/wasm32-unknown-unknown.tomlbaml_language/.ci/size-gate/x86_64-pc-windows-msvc.tomlbaml_language/.ci/size-gate/x86_64-unknown-linux-gnu.tomlbaml_language/Cargo.tomlbaml_language/crates/bex_engine/src/conversion.rsbaml_language/crates/bex_engine/src/lib.rsbaml_language/crates/bex_engine/tests/host_value_callable.rsbaml_language/crates/bex_external_types/src/host_return.rsbaml_language/crates/bex_vm_types/src/bytecode.rsbaml_language/crates/bridge_cffi/Cargo.tomlbaml_language/crates/bridge_cffi/src/baml_to_host.rsbaml_language/crates/bridge_cffi/src/ffi/handle.rsbaml_language/crates/bridge_cffi/src/handle.rsbaml_language/crates/bridge_cffi/src/lib.rsbaml_language/crates/bridge_ctypes/src/handle_table.rsbaml_language/crates/bridge_wasm/Cargo.tomlbaml_language/crates/bridge_wasm/src/lib.rsbaml_language/crates/sys_ops/src/lib.rsbaml_language/crates/sys_wasm/Cargo.tomlbaml_language/crates/sys_wasm/src/host_value.rsbaml_language/crates/sys_wasm/src/lib.rsbaml_language/crates/sys_wasm/src/send_wrapper.rsbaml_language/crates/sys_wasm/src/web_sysops.rsbaml_language/sdk_tests/DEVELOPMENT.mdbaml_language/sdk_tests/README.mdbaml_language/sdk_tests/crates/typescript/docstrings_etc/customizable/main.test.tsbaml_language/sdk_tests/crates/typescript/function_calls/customizable/cancellation.test.tsbaml_language/sdk_tests/crates/typescript/function_calls/customizable/host_callables.test.tsbaml_language/sdk_tests/crates/typescript/function_calls/customizable/stdlib_entrypoints.test.tsbaml_language/sdk_tests/crates/typescript/function_calls/customizable/web_sysops.test.tsbaml_language/sdk_tests/crates/typescript/llm_functions/customizable/streaming_e2e.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/bridge_handles_media.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/bridge_surface.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/main.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_handles.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/roundtrip_media.test.tsbaml_language/sdk_tests/crates/typescript/type_shapes/customizable/typemap.test.tsbaml_language/sdk_tests/crates/typescript_web/setup.ps1baml_language/sdk_tests/crates/typescript_web/setup.shbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_host_callable_tests/main.bamlbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_methods_on_classes/types.bamlbaml_language/sdk_tests/harness_setup/src/typescript.rsbaml_language/sdk_tests/harness_setup/src/typescript_web.rsbaml_language/sdks/typescript/bridge_typescript/src/baml_call_context.rsbaml_language/sdks/typescript/bridge_typescript/tests/test_decode_call_result.test.tsbaml_language/sdks/typescript/bridge_typescript/tests/test_typemap.test.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/call_context.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/define_function.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/errors.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/host_value_registry.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/index.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/platform.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/proto.tsbaml_language/sdks/typescript/bridge_typescript/typescript_src/stream.tsbaml_language/sdks/typescript/bridge_typescript_web/Cargo.tomlbaml_language/sdks/typescript/bridge_typescript_web/package.jsonbaml_language/sdks/typescript/bridge_typescript_web/pnpm-workspace.yamlbaml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjsbaml_language/sdks/typescript/bridge_typescript_web/scripts/sync-node-runtime.mjsbaml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjsbaml_language/sdks/typescript/bridge_typescript_web/src/errors.rsbaml_language/sdks/typescript/bridge_typescript_web/src/handle.rsbaml_language/sdks/typescript/bridge_typescript_web/src/host_value.rsbaml_language/sdks/typescript/bridge_typescript_web/src/lib.rsbaml_language/sdks/typescript/bridge_typescript_web/src/media.rsbaml_language/sdks/typescript/bridge_typescript_web/src/runtime.rsbaml_language/sdks/typescript/bridge_typescript_web/tests/bridge-web-core.d.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/call_context.test.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/host_value_registry.test.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/runtime_errors.test.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/typemap_builtins.test.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/wasm_exports.test.tsbaml_language/sdks/typescript/bridge_typescript_web/tests/worker.jsbaml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.tsbaml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.tsbaml_language/sdks/typescript/bridge_typescript_web/typescript_src/platform.tsbaml_language/sdks/typescript/bridge_typescript_web/typescript_src/wasm/bridge_web_core.d.tsbaml_language/sdks/typescript/bridge_typescript_web/vitest.web.config.tsbaml_language/sdks/typescript/bridge_typescript_web/vitest.workers.config.tsbaml_language/sdks/typescript/bridge_typescript_web/wrangler.test.jsoncbaml_language/sdks/typescript/sdkgen_typescript_shared/src/emit/typemap_file.rsbaml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rsbaml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript.rsbaml_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"; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n -C 2 '\bLLMCall\b' baml_languageRepository: 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' | sortRepository: 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_webRepository: 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.tsRepository: 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_languageRepository: 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.
| 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); | ||
| } | ||
| } |
There was a problem hiding this comment.
🩺 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.tsRepository: 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_webRepository: 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_webRepository: 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:
- 1: https://blog.cloudflare.com/we-shipped-finalizationregistry-in-workers-why-you-should-never-use-it/
- 2: https://developers.cloudflare.com/workers/configuration/compatibility-flags/
- 3: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry
- 4: https://developers.cloudflare.com/changelog/post/2025-05-08-finalization-registry/
- 5: https://git.jeffas.net/cloudflare-docs/files/src/content/changelog/workers/2025-05-08-finalization-registry.mdx.html
- 6: https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
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.
Summary
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
Summary by CodeRabbit
_fetch/_sendand synchronous filesystem reads.getVersion/flushEventsand strengthened call-context lifecycle handling for Web.