@spendgraph/tools
v0.15.0
Published
Declare a tool once, offer the right few, and record what was called.
Downloads
1,254
Maintainers
Readme
@spendgraph/tools
Declare a tool once, offer the right few, and record what was called.
npm install @spendgraph/toolsimport { calculate, tool, toolbus } from "@spendgraph/tools";
const lookup = tool({
name: "lookup_contract",
description: "Finds a contract clause by its reference, such as MSA 2.4.",
args: [{ name: "ref", type: "string", required: true }] as const,
run: ({ ref }) => search(ref),
});
const bus = toolbus([lookup, calculate()], { limit: 6 });
const turn = bus.trace(question);What you get
- A description and a handler in one object, so a rename is a compile error
rather than an
undefinedmid-loop. - A shortlist, not a catalogue. Fifty tools is 7.5k tokens before the user has said anything, and more tools makes a model worse at picking.
- Effects, so a gate can refuse what it must not retry — and name the tools nobody labelled.
- Twenty-two builtins and twelve mocks, none registered for you. Four of them are one memory set, with an in-process store for testing it offline.
Docs
| | | | --- | --- | | Overview | A tool, a bus, and a turn | | Declaring a tool | Args, as const, and what is checked at import | | A stored tool | Wording in the dashboard, handler in code | | Effects | What running one does to the world outside | | The bus | Holds, picks, converts, runs — and nests | | Selecting | The shortlist, and why it is a shortlist | | A turn | Offered, called, and what the rollout keeps | | Builtins | Sixteen factories, none registered for you | | Bogus tools | Twelve mocks for testing the pipeline, not the provider |
License
Apache-2.0
