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 ¶
const MetaKey = "aiToolCall"
MetaKey is the message-metadata key under which the tool-call context (id, name, arguments) travels the tool flow.
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).
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 ¶
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 ¶
ToolNode is the ai-tool executor — a pass-through entry that stamps the tool-call context into message metadata.
func NewToolNode ¶
NewToolNode creates a new ai-tool node.
func (*ToolNode) Execute ¶
func (n *ToolNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
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.