* Create state tools from a StateBackend.
(backend: StateBackend)
| 12 | * Create state tools from a StateBackend. |
| 13 | */ |
| 14 | function createStateToolProvider(backend: StateBackend): ToolProvider { |
| 15 | const tools: Record< |
| 16 | string, |
| 17 | { description: string; execute: (...args: unknown[]) => Promise<unknown> } |
| 18 | > = {}; |
| 19 | |
| 20 | for (const method of STATE_METHOD_NAMES) { |
| 21 | const fn = backend[method as StateMethodName]; |
| 22 | if (typeof fn !== "function") continue; |
| 23 | |
| 24 | tools[method] = { |
| 25 | description: `state.${method}`, |
| 26 | execute: (fn as (...args: unknown[]) => Promise<unknown>).bind(backend) |
| 27 | }; |
| 28 | } |
| 29 | |
| 30 | return { |
| 31 | name: "state", |
| 32 | tools, |
| 33 | types: STATE_TYPES, |
| 34 | positionalArgs: true |
| 35 | }; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Creates a `ToolProvider` that exposes `state.*` inside any |
no outgoing calls
no test coverage detected