Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix: fix typegen api (#2968)
Eric Hayescaba7e1ef9b1
diff --git a/rust/cloud-storage/ai_tools/src/lib.rs b/rust/cloud-storage/ai_tools/src/lib.rsindex ade2fda6a5..884daddd43 100644--- a/rust/cloud-storage/ai_tools/src/lib.rs+++ b/rust/cloud-storage/ai_tools/src/lib.rs@@ -69,30 +69,15 @@ pub fn all_tools() -> ToolSetWithPrompt {}/// Combined schema with shared, deduplicated `$defs`.-///-/// Uses a single [`schemars::SchemaGenerator`] so types referenced by-/// multiple tools (e.g. `CodeExecutionErrorCode`) appear exactly once.pub fn all_tool_combined_schema() -> CombinedToolSchemas {- use ai_toolset::schema::NormaliseRefSiblings;- use schemars::transform::RecursiveTransform;-- let mut generator = schemars::generate::SchemaSettings::draft2020_12()- .with(|s| s.meta_schema = None)- .with_transform(RecursiveTransform(NormaliseRefSiblings))- .into_generator();-- let mut tools = Vec::new();- tools.extend(all_tools().register_schemas(&mut generator));- tools.extend(anthropic_tools::web_search().register_schemas(&mut generator));- tools.extend(anthropic_tools::web_fetch().register_schemas(&mut generator));- tools.extend(anthropic_tools::bash_code_execution().register_schemas(&mut generator));- tools.extend(anthropic_tools::text_editor_code_execution().register_schemas(&mut generator));- tools.extend(read::read_thread().register_schemas(&mut generator));-- let defs = generator.take_definitions(true);- let mut combined = CombinedToolSchemas { defs, tools };- combined.mangle_collisions();- combined+ CombinedToolSchemas::builder()+ .merge(&all_tools())+ .merge(&anthropic_tools::web_search())+ .merge(&anthropic_tools::web_fetch())+ .merge(&anthropic_tools::bash_code_execution())+ .merge(&anthropic_tools::text_editor_code_execution())+ .merge(&read::read_thread())+ .build()}pub fn no_tools() -> ToolSetWithPrompt {diff --git a/rust/cloud-storage/ai_toolset/src/schema/generate.rs b/rust/cloud-storage/ai_toolset/src/schema/generate.rsindex d019de77d8..e37c466814 100644--- a/rust/cloud-storage/ai_toolset/src/schema/generate.rs+++ b/rust/cloud-storage/ai_toolset/src/schema/generate.rs@@ -111,6 +111,22 @@ pub struct CombinedToolSchemas {}impl CombinedToolSchemas {+ /// Returns a builder that uses a shared [`schemars::SchemaGenerator`]+ /// (with [`NormaliseRefSiblings`]) so types referenced by multiple tools+ /// appear exactly once in the final `$defs`.+ pub fn builder() -> CombinedToolSchemasBuilder {+ use schemars::transform::RecursiveTransform;++ let generator = schemars::generate::SchemaSettings::draft2020_12()+ .with(|s| s.meta_schema = None)+ .with_transform(RecursiveTransform(NormaliseRefSiblings))+ .into_generator();+ CombinedToolSchemasBuilder {+ generator,+ tools: Vec::new(),+ }+ }+/// Replaces schemars' numeric collision suffixes (e.g. `ReadContent2`)/// with tool-name-prefixed names (e.g. `ReadThreadReadContent`).///@@ -238,6 +254,34 @@ pub trait ToolSchemaGenerator {-> Vec<CombinedToolEntry>;}+/// Builder for [`CombinedToolSchemas`] that accumulates tools from multiple+/// [`ToolSchemaGenerator`]s while sharing a single [`schemars::SchemaGenerator`]+/// for deduplication.+pub struct CombinedToolSchemasBuilder {+ generator: schemars::SchemaGenerator,+ tools: Vec<CombinedToolEntry>,+}++impl CombinedToolSchemasBuilder {+ /// Registers all tools from the given generator.+ pub fn merge(mut self, schema_generator: &dyn ToolSchemaGenerator) -> Self {+ self.tools+ .extend(schema_generator.register_schemas(&mut self.generator));+ self+ }++ /// Consumes the builder and returns the combined schema.+ pub fn build(mut self) -> CombinedToolSchemas {+ let defs = self.generator.take_definitions(true);+ let mut combined = CombinedToolSchemas {+ defs,+ tools: self.tools,+ };+ combined.mangle_collisions();+ combined+ }+}+impl<Context> ToolSchemaGenerator for AsyncToolSet<Context> {fn generate_schemas(&self) -> ToolSchemas {let schemas = self