cg

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseToolArgs

func ParseToolArgs[T any](args map[string]any) (T, error)

Types

type Agent

type Agent interface {
	AddPlugin(Plugin)
	RemovePlugin(string) bool
	RemoveAllPlugins()
	Events() chan<- Event
	Run() error
	CleanStop()
}

An agent can run (blocking) and respond to events with tool calls.

type Event

type Event interface {
	Kind() string
	Content() JsonObject
}

An event is somthing that happens that can trigger the agent to respond.

type JsonObject

type JsonObject map[string]any

type Plugin

type Plugin interface {
	// Get the unique name of this plugin.
	Name() string
	// Is this plugin internal / required by the agent to function? Internal plugins cannot be removed.
	// Internal plugins will also not be removed when calling RemoveAllPlugins. and their cleanup method will neveer be called.
	Internal() bool
	// Load the plugin, returning tools, a channel of events, a function to call to cleanup the plugin, and an error if the plugin failed to load.
	Load() ([]Tool, <-chan Event, func(), error)
}

A plugin is somthing that provides tools to the agent. A plugin can be loaded all-or-nothing, so if one tool fails none will be added. A plugin may also have an event channel (can be nil) that will be forwarded to the agent.

type Tool

type Tool interface {
	Def() ToolDef
	Call(map[string]any) (string, error)
}

A tool is somthing the agent can call to perform an action.

type ToolDef

type ToolDef struct {
	Name string `json:"name"`
	Desc string `json:"desc"`
}

A tool definition specifies how a tool should be used.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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