aitool

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package aitool contains the ai-tool node implementation: the entry point of a flow exposed to an ai-agent as a callable tool. The node declares the tool's name, description and parameter schema; the agent injects a call message (arguments in the payload, correlation via the stamped message id) which travels the wired flow and is answered by an ai-tool-return node.

Index

Constants

View Source
const MetaKey = "aiToolCall"

MetaKey is the message-metadata key under which the tool-call context (id, name, arguments) travels the tool flow.

View Source
const MsgIDKey = "msgId"

MsgIDKey is the metadata key the host stamps onto injected messages; ai-tool-return reads it to resolve the pending call (same convention as linkOut's return mode).

View Source
const Type = "ai-tool"

Type is the registered node type id.

Variables

This section is empty.

Functions

func DecodeArguments

func DecodeArguments(raw string) interface{}

DecodeArguments decodes a tool call's raw JSON argument string into a message payload: objects decode to map[string]interface{}, other JSON values to their natural types, and non-JSON input passes through as a string.

func NameFor

func NameFor(node nodestore.NodeInterface, c *Config) string

NameFor resolves the effective tool name off a stored node definition: the configured name, else the node id.

func ParseRef

func ParseRef(ref, defaultWorkflowID string) (workflowID, nodeID string, err error)

ParseRef splits a tool reference of the form "workflowID/nodeID" or a bare "nodeID" (same workflow as the agent). Whitespace is trimmed; an empty segment is an error.

func ToolForNode

func ToolForNode(node nodestore.NodeInterface) (llm.Tool, error)

ToolForNode builds the llm.Tool declaration an ai-agent advertises for this ai-tool node.

Types

type Config

type Config struct {
	// ToolName is the function identifier the model calls; empty
	// defaults to the node id.
	ToolName string `json:"toolName"`
	// Description tells the model when to use the tool.
	Description string `json:"description"`
	// Parameters is the JSON Schema object describing the arguments.
	Parameters map[string]interface{} `json:"parameters"`
}

Config holds the ai-tool configuration.

func ConfigForNode

func ConfigForNode(node nodestore.NodeInterface) (*Config, error)

ConfigForNode decodes the ai-tool config off a stored node definition — the path ai-agent takes after LookupNode.

type ToolNode

type ToolNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

ToolNode is the ai-tool executor — a pass-through entry that stamps the tool-call context into message metadata.

func NewToolNode

func NewToolNode(node nodestore.NodeInterface, config *Config, host nodebase.NodeHost) *ToolNode

NewToolNode creates a new ai-tool node.

func (*ToolNode) Execute

Execute stamps the tool-call metadata and passes the call message down the tool flow. The agent's injected message already carries the arguments as payload plus the stamped pending message id; ai-tool-return answers it downstream.

func (*ToolNode) Name

func (n *ToolNode) Name() string

Name resolves the effective tool name (configured name, else node id).

func (*ToolNode) Validate

func (n *ToolNode) Validate() error

Validate requires nothing beyond structural sanity — the tool name defaults to the node id when empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL