Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Add invoke_cli() and version() functions to test FFI linkage - Fix FFI binding signature (env_vars_json instead of env_vars_len) - Add staticlib output to CFFI crate for static linking - Fix setup-ffi.sh to detect platform and copy to correct arch dir - Add build.rs link directives for CFFI library and macOS frameworks - Add .gitignore for vendored .a/.lib files
Add channel-based callback infrastructure matching Go client pattern: - CallbackResult enum for partial/final/error responses - Global callback storage with mutex protection - Sequential ID generation with collision checking - result_callback, error_callback, on_tick_callback FFI handlers
…nd derive macros Implements the type serialization layer for the Rust BAML client: - Add codec.rs with BamlEncode/BamlDecode traits for proto serialization - Primitive implementations: String, i64, i32, f64, bool, &str - Container implementations: Vec<T>, Option<T>, HashMap<String, V> - Helper traits: BamlClass, BamlEnum for generated code - Helper functions: encode_class, encode_enum, decode_field, decode_optional_field - Create baml-macros proc-macro crate with derive macros: - #[derive(BamlEncode)] for Rust -> BAML serialization - #[derive(BamlDecode)] for BAML -> Rust deserialization - #[baml(name = "...")] attribute for type/field/variant renaming - #[baml(skip)] attribute for skipping fields during encoding - Reorganize tests into structured tests/ directory: - tests/codec.rs: 19 encode/decode tests - tests/derive.rs: 8 derive macro tests - tests/ffi.rs: 3 FFI smoke tests - tests/common/mod.rs: shared test fixtures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add special type wrappers for BAML's @check and @stream.with_state features: - Checked<T>: Wrapper for values with @check constraints, contains value and HashMap of Check results with name, expression, and CheckStatus (Passed/Failed) - StreamState<T>: Wrapper for @stream.with_state values, contains value and StreamingState enum (Pending/Started/Done) Also optimizes codec by moving unwrap_single_pattern_union() call to only Option<T> decode implementation since union wrappers are only used for optionals. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add the raw_objects module that provides the base infrastructure for FFI-backed BAML objects. This is the foundation for Media types, Collector, TypeBuilder, and related types. Key additions: - RawObject struct: wraps FFI pointer (ptr: i64), runtime, and object type - Method call infrastructure (call_method_for_value/object/objects/void) - Drop implementation that calls ~destructor via FFI - BamlObjectHandle encoding/decoding for protobuf serialization - RawObjectTrait for polymorphic access to wrapped types - define_raw_object_wrapper! macro to reduce boilerplate Placeholder wrapper types (to be fully implemented in Phase 11-13): - Media: Image, Audio, Pdf, Video - Collector: Collector, FunctionLog, Usage - TypeBuilder: TypeBuilder, TypeDef, EnumBuilder, EnumValueBuilder, ClassBuilder, ClassPropertyBuilder
- Add Image, Audio, Pdf, Video media types via define_media_type! macro - Add baml_unreachable! macro for internal errors with reporting links - Add IntoKwargs trait for ergonomic kwargs encoding (tuples instead of HostMapEntry) - Add BamlRuntime factory methods for media types (new_image_from_url, etc.) - Make media methods infallible (return direct types, panic on internal errors) - Consolidate BamlEncode impl into define_raw_object_wrapper macro - Fix leaky public interfaces (RawObject, RawObjectTrait, IntoKwargs now internal) - Add 64 comprehensive tests for all media types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implement full Collector, FunctionLog, Usage, and LogType types with ergonomic Rust API: - LogType enum (Call, Stream) with Copy/Clone/PartialEq/Eq/Debug - Usage struct with input_tokens() and output_tokens() methods - FunctionLog struct with id(), function_name(), log_type(), usage(), tags() methods - Collector struct with name(), clear(), usage(), logs(), last(), get_by_id() methods - BamlRuntime.new_collector() factory method - FunctionArgs.with_collector() to attach collectors to function calls - FunctionArgs.with_type_builder() for typed TypeBuilder references Includes 28 tests covering: - Collector creation and properties - LogType enum behavior - Usage tracking - Thread safety (Send + Sync) - Integration tests with real LLM calls (when OPENAI_API_KEY set) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
… decoding Restructure codec.rs into a module directory and add foundational types for the upcoming BamlValue dynamic type decoding feature. Changes: - Add BamlTypeName trait for compile-time type names in error messages - Add FullTypeName trait for runtime type name reporting - Add TypeCheck error variant for expected type mismatches (vs Internal for bugs) - Add KnownTypes trait for CodeGen'd type enums (at crate root to avoid cycles) - Restructure codec.rs into codec/ module with: - traits.rs: BamlDecode, BamlEncode, BamlClass, BamlEnum, IntoKwargs - primitives.rs: Primitive encode/decode implementations - containers.rs: Vec, Option, HashMap implementations - helpers.rs: Helper functions and BamlClass blanket impl - known_types.rs: Re-export of KnownTypes - baml_value.rs: BamlValue<T, S> enum (stub) - dynamic_types.rs: DynamicClass, DynamicEnum, DynamicUnion - from_baml_value.rs: FromBamlValue trait (stub) - from_baml_value_ref.rs: FromBamlValueRef trait (stub) - Export new types from lib.rs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…lementations Add the foundational type conversion implementations for BamlValue: - FullTypeName impl for BamlValue: Enables descriptive error messages with type names like "String", "Int", "DynamicClass(PersonInfo)" - FromBamlValue impls for primitives: String, i64, f64, bool, () Extract owned values from BamlValue with proper type checking - FromBamlValueRef impls for primitives: &str, i64, f64, bool Zero-copy borrowing for read-only access to BamlValue contents 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ntations - Add identity FromBamlValue impl for BamlValue<T, S> - Add FromBamlValue impls for DynamicClass, DynamicEnum, DynamicUnion - Add container blanket impls: Option<V>, Vec<V>, HashMap<String, V> - Add FromBamlValueRef impls for raw container refs and dynamic types - Add BamlTypeName impls for dynamic types and reference types - Remove type_check_raw in favor of consistent type_check::<T> API
Implement BamlDecode trait for BamlValue<T, S> to enable decoding CFFI protobuf values into dynamically-typed BAML values. This handles all CFFI value variants including primitives, containers, dynamic types (class, enum, union), wrappers (Checked, StreamState), and literals. Add 107 comprehensive tests covering: - Primitive decoding with edge cases (empty strings, max/min ints, special floats) - Container types (lists, maps) including deeply nested structures - Dynamic types (DynamicClass, DynamicEnum, DynamicUnion) - Checked wrapper with various check states - StreamState wrapper with all streaming states - Literal values (string, int, bool) - FromBamlValue/FromBamlValueRef extraction - DynamicClass accessors (get, get_ref, pop, iterate) - Error cases for type mismatches
Phase 1: Template Infrastructure - Create template directory structure with placeholder .j2 files - Templates organized into functions/, types/, stream_types/, type_builder/ Phase 2: TypeRust Method Extensions - Add zero_value() for generating default values - Add is_optional(), inner_type(), is_primitive(), is_string() helpers - Add decode_from_value() for type decoding expressions Test Infrastructure: - Add Rust support to test_harness with dynamic Cargo.toml/main.rs generation - Add on_generate commands: rustfmt + cargo check - Add RUN_GENERATOR_TESTS=1 support to run cargo test -v - Minimal generate_sdk_files() that creates placeholder mod.rs All 149 tests pass (34 rust_tests + 115 type_gen tests). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| "Failed to find openapi-generator-cli in your PATH, defaulting to using npx: {}", | ||
| e | ||
| ); | ||
| if matches!(output_type, GeneratorOutputType::OpenApi) { |
There was a problem hiding this comment.
Missing Rust project auto-detection in baml init
Medium Severity
The detect_project_type function auto-detects Python (via pyproject.toml), TypeScript (via package.json), Ruby (via Gemfile), and Go (via go.mod) projects, but does not detect Rust projects by checking for Cargo.toml. This means when users run baml init in a Rust project directory, the auto-detection fails and they must manually specify --client-type rust, unlike all other supported languages where detection is automatic.
| } => error.context(format!( | ||
| "Invalid parameters for BAML function {function_name}" | ||
| } => anyhow::anyhow!(format!( | ||
| "Invalid parameters for BAML function {function_name}: {error}" |
There was a problem hiding this comment.
Error chain lost when converting PrepareFunctionError
Medium Severity
The into_error() method was changed from using error.context(...) to anyhow::anyhow!(format!("...: {error}")). This loses the error chain - the original error's cause, backtrace, and downcasting capability are discarded. Only the stringified message is preserved. This makes debugging harder since nested errors and their context cannot be inspected. The idiomatic approach with .context() preserves the full error chain while adding context.
Note
Introduces first-class Rust client generation and test fixtures, plus minor compiler/runtime cleanups and CI setup tweaks.
rusttoGeneratorOutputTypewith defaults; updates CLIinit/generateto support Rust (incl.on_generate "cargo fmt") and user messaginggenerators-rustcrate and extensive Rust test projects underengine/generators/data/**/rust(arrays, maps, enums, primitives, nested/recursive, optional/nullable, media, mixed, dynamic types, sample, semantic_streaming).github/actions/setup-rustprepare_function), adjust streaming error forwarding, fix result unwrap logic, display/type_builder fmt cleanupWritten by Cursor Bugbot for commit 4852870. This will update automatically on new commits. Configure here.