Tools
Tool exports are globals. Call them directly from scripts, routes, and hooks — no prefix, no namespace wrapper.
// src/scripts/triage.ts
const tasks = await kanban.list("open")
const session = await axon.prompt("session", { tasks })
const { stream } = axon.stream({ prompt: session })
Why globals
Tools are primarily called by the agent during its cognitive loop. But scripts often need to call tools directly — to load state before constructing a prompt, to act on the agent's output, or to run work without the loop.
Since tools are globals in every execution context, the same call works from a script, a route handler, a hook, or the agent itself. No import, no accessor.
What becomes a global
Each top-level export from src/tools/*.ts lands on the global scope with its exact name.
// src/tools/kanban.ts
export const kanban = {
list: async (status?: string) => ...,
add: async (title: string) => ...,
}
// src/tools/time.ts
export async function now() { return new Date().toISOString() }
export async function format(date: string) { ... }
The agent and all scripts see: kanban, now, format — each directly callable.
Typing
axon prepare generates .agent/tool-globals.d.ts — a declare global block with a typed const for each export. Full autocomplete with no imports required.
For src/tools/*.ts exports, types are indexed directly from your source:
// .agent/tool-globals.d.ts — generated, do not edit
declare global {
const kanban: typeof import("../src/tools/kanban")["kanban"]
const now: typeof import("../src/tools/time")["now"]
const format: typeof import("../src/tools/time")["format"]
}
Run axon prepare after adding or modifying tool files to refresh types.
Example — load state before prompting
const issues = await kanban.list({ status: "open" })
const session = await axon.prompt("session", { issues })
const { stream } = axon.stream({ prompt: session })
Loading state explicitly before the prompt is more reliable than letting the agent call the tool itself — you control exactly what data the agent sees.