Deno:
deno add npm:@neabyte/agent-toolnpm:
npm install @neabyte/agent-toolCDN (jsDelivr/esm.sh):
<script type="module">
import Tool from 'https://cdn.jsdelivr.net/npm/@neabyte/agent-tool/dist/index.mjs'
</script>Or via esm.sh:
<script type="module">
import Tool from 'https://esm.sh/@neabyte/agent-tool'
</script>Import the default export, define a tool with name, description, schema, and handler, then call execute with input and an optional signal.
import Tool, { type ToolPlugin } from '@neabyte/agent-tool'
// Define a tool that returns the weather for a city
const weather: ToolPlugin = Tool.define({
name: 'get_weather',
description: 'Get the current weather for a city',
parameters: {
type: 'object',
properties: {
city: { type: 'string' }
},
required: ['city']
},
execute(args) {
return {
success: true,
json: { temp: 28, condition: 'sunny' },
text: 'Sunny, 28C'
}
}
})
// Inspect the JSON Schema that the API consumes
console.log(weather.schema)
// Call the tool with input, optional signal, and optional event callback
const result = await weather.execute({ city: 'Jakarta' })
console.log(result.text)Read docs/README.md for full API reference, schema shapes, abort flows, and type definitions.
Note
Prerequisites: Deno for all development tasks.
Check - format, lint, and typecheck source:
deno task checkUnit tests - run all tests:
deno task test- Defining Tools -
Tool.define()configuration shape and execute function contract - Executing Tools -
ToolPlugin.execute()flow, abort handling, error translation - Schemas -
ToolDefunion, OpenAI flat and nested layouts, Anthropic layout
- Anthropic Tool Use - Anthropic Messages API tool use reference
- OpenAI Function Calling - OpenAI tool calling reference for function definitions
- JSON Schema Specification - The schema vocabulary used by
ToolSchema
Code in this repository is licensed under Apache 2.0, documentation is licensed under CC-BY-4.0.