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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// The Tool contract.
//
// nanny-core defines the shapes.
// Concrete tool implementations live in nanny-tools.
//
// The executor programs against ToolExecutor: not against any specific tool.
// This means: add a new tool, replace a tool, sandbox a tool in WASM,
// the executor never changes.
use HashMap;
use Error;
// ── ToolArgs ──────────────────────────────────────────────────────────────────
/// The arguments passed to a tool call.
///
/// A flat key-value map. Tools declare which keys they expect
/// and validate them inside `execute()`.
/// The executor passes whatever the agent provided: no pre-filtering.
pub type ToolArgs = ;
// ── ToolOutput ────────────────────────────────────────────────────────────────
/// The result of a successful tool execution.
///
/// Kept intentionally simple: structured output parsing belongs
/// to the agent layer above, not the executor.
// ── ToolError ─────────────────────────────────────────────────────────────────
/// Errors a tool can produce during execution.
///
/// These represent tool-level failures: bad args, network errors, timeouts.
/// They are distinct from policy denials: a tool error means the tool was
/// permitted but failed during execution. A policy denial means the tool
/// was never called at all.
// ── Tool trait ────────────────────────────────────────────────────────────────
/// The contract for a single tool.
///
/// Any type that implements this can be registered and called by the executor.
// ── ToolCallError ─────────────────────────────────────────────────────────────
/// What can go wrong when the executor calls a tool via the registry.
///
/// Two cases only:
/// - The tool name is not registered (config allows it but nobody registered it)
/// - The tool is registered but failed during execution
///
/// Policy denial is not represented here: that stops the executor
/// before `call()` is ever invoked.
// ── ToolExecutor trait ────────────────────────────────────────────────────────
/// The contract for a collection of tools.
///
/// The executor programs against this: not against ToolRegistry directly.
/// This separation means ToolRegistry can live in nanny-tools without
/// nanny-core needing to import it.
///
/// Implementations: ToolRegistry in nanny-tools.
/// In tests: inline NoOpToolExecutor or similar test doubles.