1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! [`AnyToolFactory`] — object-safe factory submitted to inventory at compile time.
//!
//! Each `#[reflect_trait(their::Trait)]` invocation generates one factory and
//! submits it via `inventory::submit!(ToolFactoryRegistration { ... })`.
//!
//! At runtime, [`DynamicToolRegistry`](super::DynamicToolRegistry) collects all
//! registrations from inventory and uses them to:
//!
//! 1. Expose factory meta-tools in `list_tools` (always visible).
//! 2. Instantiate [`DynamicToolDescriptor`](super::DynamicToolDescriptor)s when
//! an agent calls the meta-tool.
use ;
use ErrorData;
/// Object-safe factory that knows how to produce tools for one third-party trait.
///
/// # Object Safety
///
/// This trait is intentionally object-safe: no generic methods, no `Self`
/// requirements. Factories live behind `&'static dyn AnyToolFactory`.
///
/// # Implementation
///
/// Implement this trait manually (or via `#[reflect_trait]` once the macro
/// exists) and submit to inventory:
///
/// ```rust,ignore
/// inventory::submit!(ToolFactoryRegistration {
/// trait_name: "my_crate::MyTrait",
/// factory: &MyToolFactory,
/// });
/// ```
/// Inventory key connecting a static factory to the global registry.
///
/// Submit via `inventory::submit!` in the crate that defines the factory.
/// Collected by [`DynamicToolRegistry::new`](super::DynamicToolRegistry::new)
/// at server startup.
collect!;