Documentation
¶
Index ¶
- Constants
- Variables
- func Abbreviate(s string, maxLen int) string
- func Cat(a, b, sep string) string
- func DataURL(mime string, raw []byte) string
- func DecodeDataURL(dataURL string) (string, error)
- func GetArrayProp(key string, props map[string]any) ([]string, error)
- func GetBoolProp(key string, props map[string]any) (bool, error)
- func GetIntProp(key string, props map[string]any) (int, error)
- func GetMapProp(key string, props map[string]any) (map[string]any, error)
- func GetStrProp(key string, props map[string]any) (string, error)
- func IsRequired(key string, props map[string]any) bool
- func IsTemplate(v any) bool
- func IsURI(s string) bool
- func LoadURIContent(ws Workspace, uri string) (string, error)
- func LogLevelToString(level LogLevel) string
- func MimeToString(mime string, content []byte) string
- func NewBadRequestError(msg string) error
- func NewInternalServerError(msg string) error
- func NewNotFoundError(msg string) error
- func NewUnauthorizedError(msg string) error
- func NewUnsupportedError(msg string) error
- func ParseMimeType(s string) (string, string)
- func ParseStringArray(s string) []string
- func ToError(v any) error
- func ToInt(data any) int
- func ToMap(obj any) (map[string]any, error)
- func ToString(data any) string
- func ToStringArray(obj any) []string
- type ATMSupport
- type Action
- type ActionRTEnv
- type ActionRunner
- type AdapterRegistry
- type Agent
- type AgentConfig
- type App
- type AppConfig
- type ArgMap
- func (a ArgMap) Action() *Action
- func (a ArgMap) Actions() []string
- func (a ArgMap) Agent() *Agent
- func (a ArgMap) Arg(key string) any
- func (a ArgMap) DeleteHitory()
- func (a ArgMap) FlowType() FlowType
- func (v ArgMap) Get(key string) any
- func (v ArgMap) GetBool(key string) bool
- func (v ArgMap) GetDuration(key string) time.Duration
- func (v ArgMap) GetFloat64(key string) float64
- func (v ArgMap) GetInt(key string) int
- func (v ArgMap) GetInt32(key string) int32
- func (v ArgMap) GetInt64(key string) int64
- func (v ArgMap) GetIntSlice(key string) []int
- func (v ArgMap) GetString(key string) string
- func (v ArgMap) GetStringMap(key string) map[string]any
- func (v ArgMap) GetStringMapString(key string) map[string]string
- func (v ArgMap) GetStringMapStringSlice(key string) map[string][]string
- func (v ArgMap) GetStringSlice(key string) []string
- func (v ArgMap) GetTime(key string) time.Time
- func (v ArgMap) GetUint(key string) uint
- func (v ArgMap) GetUint8(key string) uint8
- func (v ArgMap) GetUint16(key string) uint16
- func (v ArgMap) GetUint32(key string) uint32
- func (v ArgMap) GetUint64(key string) uint64
- func (a ArgMap) HasHistory() bool
- func (a ArgMap) HasPrompt() bool
- func (a ArgMap) HasQuery() bool
- func (a ArgMap) History() []*Message
- func (a ArgMap) Kitname() Kitname
- func (a ArgMap) Message() string
- func (a ArgMap) Prompt() string
- func (a ArgMap) Query() string
- func (a ArgMap) SetArg(key string, value any) ArgMap
- func (a ArgMap) SetHistory(messages []*Message) ArgMap
- func (a ArgMap) SetPrompt(prompt any) ArgMap
- func (a ArgMap) SetQuery(query any) ArgMap
- func (a ArgMap) Type() string
- type Arguments
- func (r Arguments) AddArgs(args map[string]any) Arguments
- func (r Arguments) Clone() Arguments
- func (r Arguments) Copy(dst map[string]any) Arguments
- func (r Arguments) Get2(key string) (any, bool)
- func (r Arguments) GetArgs(keys []string) map[string]any
- func (r Arguments) SetArgs(args map[string]any) Arguments
- type AssetFS
- type AssetManager
- type AssetStore
- type BadRequestError
- type Blob
- type BlobStore
- type CallLogEntry
- type CallLogger
- type ClipboardProvider
- type ConnectorConfig
- type ContextKey
- type DHNTConfig
- type DirEntry
- type DirEntryInfo
- type EditorProvider
- type Environment
- func (g *Environment) AddEnvs(src map[string]any)
- func (g *Environment) Apply(fn func(map[string]any) error) error
- func (g *Environment) Clone() *Environment
- func (g *Environment) Copy(dst map[string]any)
- func (g *Environment) Get(key string) (any, bool)
- func (g *Environment) GetAllEnvs() map[string]any
- func (g *Environment) GetEnvs(keys []string) map[string]any
- func (g *Environment) GetInt(key string) int
- func (g *Environment) GetString(key string) string
- func (g *Environment) Set(key string, val any)
- func (g *Environment) SetEnvs(envs map[string]any)
- func (g *Environment) Unset(key string)
- func (g *Environment) UnsetEnvs(keys []string)
- type FileInfo
- func (r *FileInfo) IsDir() bool
- func (fi FileInfo) MarshalJSON() ([]byte, error)
- func (r *FileInfo) ModTime() time.Time
- func (r *FileInfo) Mode() fs.FileMode
- func (r *FileInfo) Name() string
- func (r *FileInfo) Size() int64
- func (r *FileInfo) Sys() any
- func (fi *FileInfo) UnmarshalJSON(data []byte) error
- type FlowType
- type FuncBody
- type Handler
- type HandlerFunc
- type InputConfig
- type InternalServerError
- type Kitname
- type LLMAdapter
- type Level
- type LogLevel
- type MemOption
- type MemStore
- type Message
- type Middleware
- type Model
- type ModelConfig
- type NotFoundError
- type Output
- type Packname
- type Parameters
- type Record
- type Request
- type Resource
- type ResourceConfig
- type Response
- type Result
- type Root
- type Roots
- type SecretStore
- type Setlevel
- type State
- type System
- type TemplateFuncMap
- type ToolCall
- type ToolCallEntry
- type ToolConfig
- type ToolEnv
- type ToolFunc
- type ToolGuard
- type ToolKit
- type ToolSystem
- type ToolType
- type UnauthorizedError
- type UnsupportedError
- type User
- type UserInput
- type Vars
- type Workspace
Constants ¶
const ( RoleSystem = "system" RoleAssistant = "assistant" RoleUser = "user" )
const ( VarsEnvContainer = "container" VarsEnvHost = "host" )
const (
ContentTypeImageB64 = "img/base64"
)
Variables ¶
var TemplateMimeTypes = []string{"text/x-go-template", "x-go-template", "template", "tpl"}
Functions ¶
func Abbreviate ¶ added in v0.1.1
Abbreviate trims the string, keeping the beginning and end if exceeding maxLen. after replacing newlines with '.'
func DataURL ¶ added in v0.1.1
https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data data:[<media-type>][;base64],<data>
func DecodeDataURL ¶ added in v0.1.1
DecodeDataURL decodes a data URL and extracts the data as a string. It supports optional media types and base64 encoding, ensuring the "data:" prefix is present.
func GetArrayProp ¶ added in v0.1.1
func GetMapProp ¶ added in v0.1.1
func IsRequired ¶ added in v0.1.1
if required properties is not missing and is an array of strings check if the required properties are present
func IsTemplate ¶ added in v0.1.1
check #! or // magic for large block of text {{ contained within for oneliner
func IsURI ¶ added in v0.1.1
Check if ':' exists within the first 8 characters e.g: data:, file:/// https://
func LoadURIContent ¶ added in v0.1.1
Load data from uri. Support file:// and data: protocols TODO enforce protocol requiremnt? If no protocol is specified, assumse local file path.
func LogLevelToString ¶ added in v0.1.1
func MimeToString ¶ added in v0.1.1
func NewBadRequestError ¶ added in v0.1.1
func NewInternalServerError ¶ added in v0.1.1
func NewNotFoundError ¶ added in v0.1.1
func NewUnauthorizedError ¶ added in v0.1.1
func NewUnsupportedError ¶ added in v0.1.1
func ParseMimeType ¶ added in v0.1.1
Check for mime-type specification. Returns content and mime type. remove first line for multiline text
func ParseStringArray ¶ added in v0.1.1
try parse string into an array of string in the following formats: a,b,c... [a,b,c,] intended for parsing commandline actins list
func ToStringArray ¶ added in v0.1.1
return an array of strings. try unmarshal obj if it is encoded in json format. return an empty array if obj is neither an array nor json array.
Types ¶
type ATMSupport ¶ added in v0.1.1
type ATMSupport interface {
AssetStore
RetrieveAgent(owner, pack string) (*Record, error)
ListAgents(owner string) ([]*Record, error)
// SearchAgent(owner, pack string) (*Record, error)
RetrieveTool(owner, kit string) (*Record, error)
ListTools(owner string) ([]*Record, error)
RetrieveModel(owner, alias string) (*Record, error)
ListModels(owner string) ([]*Record, error)
}
agent/tool/model methods
type Action ¶ added in v0.1.1
type Action struct {
// unique tool call identifier
ID string `json:"id"`
// command name: (agent/tool/command)
// agent:pack/sub
// kit:name
// bin:/command
Name string `json:"name"`
// arguments including name
Arguments Arguments `json:"arguments"`
}
TODO split name into kit, name|pack/sub|command command line: [ACTION] [OPTIONS] MESSAGE...
type ActionRTEnv ¶ added in v0.12.1
type ActionRTEnv struct {
Base string
ID string
User *User
Roots *Roots
Workspace Workspace
OS System
Secrets SecretStore
Assets AssetManager
Blobs BlobStore
Tools ToolSystem
Adapters AdapterRegistry
// OS vos.System
// Workspace vfs.Workspace
History MemStore
Log CallLogger
}
func (*ActionRTEnv) DefaultPrompt ¶ added in v0.12.1
func (r *ActionRTEnv) DefaultPrompt(argm ArgMap) (string, error)
Return default prompt using instruction. Return error if instruction is a template Return empty string if no instruction if found Preprocessing is required for templates using [ai:build_prompt]
func (*ActionRTEnv) DefaultQuery ¶ added in v0.12.1
func (r *ActionRTEnv) DefaultQuery(argm ArgMap) (string, error)
Return default query from message and content. Return error if either message or content is a template Preprocessing is required for templates using [ai:build_query]
func (*ActionRTEnv) LoadScript ¶ added in v0.12.1
func (r *ActionRTEnv) LoadScript(v string) (string, error)
type ActionRunner ¶ added in v0.1.1
type AdapterRegistry ¶ added in v0.1.1
type AdapterRegistry interface {
Get(key string) (LLMAdapter, error)
}
type Agent ¶
type Agent struct {
// Package name
Pack string `json:"pack"`
// Agent name
Name string `json:"name"`
Display string `json:"display"`
Description string `json:"description"`
// templated values
// these should not be in the args map
Instruction string `json:"instruction"`
Context string `json:"context"`
Message string `json:"message"`
// The model to be used by the agent
// TODO map or list for supporting multi features
Model *Model `json:"model"`
// Functions that the agent can call
Tools []*ToolFunc `json:"tools"`
// LLM adapter
Adapter string `json:"adapter"`
// inheritance
Embed []*Agent `json:"-"`
// exported global values
// Environment map[string]any
Environment *Environment `json:"environment"`
// default values
Arguments Arguments `json:"arguments"`
Parameters Parameters `json:"parameters"`
// assigned at buildtime/runtime
Parent *Agent `json:"-"`
Runner ActionRunner `json:"-"`
Shell ActionRunner `json:"-"`
Template *template.Template `json:"-"`
Config *AppConfig `json:"-"`
}
type AgentConfig ¶
type AgentConfig struct {
Display string `yaml:"display" json:"display"`
Description string `yaml:"description" json:"description"`
// tools defined in tools config
// kit:name
Functions []string `yaml:"functions" json:"functions"`
// chat|image|docker/aider oh gptr
Adapter string `yaml:"adapter" json:"adapter"`
// default agents config
// sub name only
Name string `yaml:"name" json:"name"`
Arguments map[string]any `yaml:"arguments" json:"arguments"`
//
Instruction string `yaml:"instruction" json:"instruction"`
Context string `yaml:"context" json:"context"`
Message string `yaml:"message" json:"message"`
Model string `yaml:"model" json:"model"`
//
MaxTurns int `yaml:"max_turns" json:"max_turns"`
MaxTime int `yaml:"max_time" json:"max_time"`
// memory
// max history: 0 max span: 0
// New *bool `yaml:"new,omitempty"`
MaxHistory int `yaml:"max_history" json:"max_history"`
MaxSpan int `yaml:"max_span" json:"max_span"`
// logging: quiet | info[rmative] | verbose | trace
LogLevel string `yaml:"log_level" json:"log_level"`
// agent as tool
Parameters Parameters `yaml:"parameters" json:"parameters"`
// agent global vars
Environment map[string]any `yaml:"environment" json:"environment"`
// inherit from embedded parent:
// + environment
// + instruction
// + context
//
// + model
// + functions
// local scope:
// - arguments
// - message
// - parameters
Embed []string `yaml:"embed" json:"embed"`
//
Entrypoint []string `yaml:"entrypoint" json:"entrypoint"`
Config *AppConfig `json:"-"`
}
func (*AgentConfig) ToMap ¶ added in v0.1.1
func (ac *AgentConfig) ToMap() map[string]any
type AppConfig ¶
type AppConfig struct {
// ActionConfig
//
// kit specifies a namespace for the action
// examples:
// class name
// MCP server name
// file system
// container name
// virtual machine name
// tool/function (Gemini)
Kit string `yaml:"kit" json:"kit"`
// action type:
// func, system, agent...
Type string `yaml:"type" json:"type"`
// user message
Message string `yaml:"message" json:"message"`
// system prompt
Instruction string `yaml:"instruction" json:"instruction"`
// set/level key - not the LLM model
Model string `yaml:"model" json:"model"`
//
MaxTurns int `yaml:"max_turns" json:"max_turns"`
MaxTime int `yaml:"max_time" json:"max_time"`
// output format: json | text
Format string `yaml:"format" json:"format"`
// memory context
MaxHistory int `yaml:"max_history" json:"max_history"`
MaxSpan int `yaml:"max_span" json:"max_span"`
Context string `yaml:"context" json:"context"`
// logging: quiet | informative | verbose
LogLevel string `yaml:"log_level" json:"log_level"`
//
Pack string `yaml:"pack" json:"pack"`
Agents []*AgentConfig `yaml:"agents" json:"agents"`
// tool / model provider
Provider string `yaml:"provider" json:"provider"`
BaseUrl string `yaml:"base_url" json:"base_url"`
// api token lookup key
ApiKey string `yaml:"api_key" json:"api_key"`
// action type:
// func, system, agent...
// Type string `yaml:"type"`
Tools []*ToolConfig `yaml:"tools" json:"tools"`
// modelset name
Set string `yaml:"set" json:"set"`
Models map[string]*ModelConfig `yaml:"models" json:"models"`
// The raw data for this config
RawContent []byte `yaml:"-" json:"-"`
// TODO for debugging
Source string `yaml:"-" json:"-"`
Store AssetStore `yaml:"-" json:"-"`
// relative to store root
BaseDir string `yaml:"-" json:"-"`
}
func (*AppConfig) IsInformative ¶ added in v0.1.1
type ArgMap ¶ added in v0.1.1
func (ArgMap) DeleteHitory ¶ added in v0.1.1
func (a ArgMap) DeleteHitory()
func (ArgMap) GetFloat64 ¶ added in v0.1.1
func (ArgMap) GetIntSlice ¶ added in v0.1.1
func (ArgMap) GetStringMap ¶ added in v0.1.1
func (ArgMap) GetStringMapString ¶ added in v0.1.1
func (ArgMap) GetStringMapStringSlice ¶ added in v0.1.1
func (ArgMap) GetStringSlice ¶ added in v0.1.1
func (ArgMap) HasHistory ¶ added in v0.1.1
func (ArgMap) SetHistory ¶ added in v0.1.1
type Arguments ¶ added in v0.1.1
type Arguments = ArgMap
func NewArguments ¶ added in v0.1.1
func NewArguments() Arguments
type AssetManager ¶ added in v0.1.1
type AssetManager interface {
// GetStore(key string) (AssetStore, error)
AddStore(store AssetStore)
// SearchAgent(owner, pack string) (*Record, error)
ListAgent(owner string) (map[string]*AppConfig, error)
FindAgent(owner, pack string) (*AppConfig, error)
ListToolkit(owner string) (map[string]*AppConfig, error)
FindToolkit(owner string, kit string) (*AppConfig, error)
ListModels(owner string) (map[string]*AppConfig, error)
FindModels(owner string, alias string) (*AppConfig, error)
}
type AssetStore ¶
type AssetStore any
type BadRequestError ¶ added in v0.1.1
type BadRequestError struct {
Message string
}
func (*BadRequestError) Error ¶ added in v0.1.1
func (e *BadRequestError) Error() string
type Blob ¶ added in v0.1.1
type Blob struct {
ID string `json:"id"`
MimeType string `json:"mime_type"`
Content []byte `json:"content"`
Meta map[string]any `json:"meta"`
}
https://en.wikipedia.org/wiki/Media_type https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types https://mimesniff.spec.whatwg.org/
type BlobStore ¶ added in v0.1.1
type BlobStore interface {
Put(ID string, blob *Blob) error
Get(ID string) (*Blob, error)
Presign(ID string) (string, error)
}
Object store
type CallLogEntry ¶ added in v0.1.1
type CallLogEntry struct {
// tool call
Kit string `json:"kit"`
Name string `json:"name"`
Arguments map[string]any `json:"arguments"`
// active agent
Agent string `json:"agent"`
// failure
Error error `json:"error"`
// success
Result *Result `json:"result"`
Started time.Time `json:"started"`
Ended time.Time `json:"ended"`
}
type CallLogger ¶ added in v0.1.1
type CallLogger interface {
Base() string
Save(*CallLogEntry)
}
type ClipboardProvider ¶
type ConnectorConfig ¶ added in v0.0.2
type ContextKey ¶ added in v0.1.1
type ContextKey string
const SwarmUserContextKey ContextKey = "swarm_user"
type DHNTConfig ¶ added in v0.1.1
type DHNTConfig struct {
// base where this config loaded from. default $HOME/.ai/
// filename: dhnt.json
Base string `json:"-"`
// additional work spaces
Roots *Roots `json:"roots"`
Blob *ResourceConfig `json:"blob"`
Assets []*ResourceConfig `json:"assets"`
}
func LoadDHNTConfig ¶ added in v0.1.1
func LoadDHNTConfig(conf string) (*DHNTConfig, error)
func (*DHNTConfig) GetRoots ¶ added in v0.1.1
func (r *DHNTConfig) GetRoots() ([]*Root, error)
Return root paths
type DirEntryInfo ¶
type DirEntryInfo struct {
// contains filtered or unexported fields
}
func FsDirEntryInfo ¶
func FsDirEntryInfo(de fs.DirEntry) *DirEntryInfo
func (*DirEntryInfo) IsDir ¶
func (r *DirEntryInfo) IsDir() bool
func (DirEntryInfo) MarshalJSON ¶
func (r DirEntryInfo) MarshalJSON() ([]byte, error)
func (*DirEntryInfo) Name ¶
func (r *DirEntryInfo) Name() string
func (*DirEntryInfo) Type ¶
func (r *DirEntryInfo) Type() fs.FileMode
func (*DirEntryInfo) UnmarshalJSON ¶
func (r *DirEntryInfo) UnmarshalJSON(data []byte) error
type EditorProvider ¶
type Environment ¶ added in v0.1.1
type Environment struct {
Env map[string]any `json:"env"`
// contains filtered or unexported fields
}
func NewEnvironment ¶ added in v0.1.1
func NewEnvironment() *Environment
func (*Environment) AddEnvs ¶ added in v0.1.1
func (g *Environment) AddEnvs(src map[string]any)
copy all src values to the environment env
func (*Environment) Apply ¶ added in v0.1.1
func (g *Environment) Apply(fn func(map[string]any) error) error
thread safe access to the env
func (*Environment) Clone ¶ added in v0.11.1
func (g *Environment) Clone() *Environment
func (*Environment) Copy ¶ added in v0.1.1
func (g *Environment) Copy(dst map[string]any)
copy all environment env to dst
func (*Environment) Get ¶ added in v0.1.1
func (g *Environment) Get(key string) (any, bool)
Return value for key
func (*Environment) GetAllEnvs ¶ added in v0.1.1
func (g *Environment) GetAllEnvs() map[string]any
Return all envs
func (*Environment) GetEnvs ¶ added in v0.1.1
func (g *Environment) GetEnvs(keys []string) map[string]any
Return envs specified by keys
func (*Environment) GetInt ¶ added in v0.1.1
func (g *Environment) GetInt(key string) int
Return int value for key, 0 if key is not set or value can not be converted to int
func (*Environment) GetString ¶ added in v0.1.1
func (g *Environment) GetString(key string) string
Return string value for key, empty if key it not set or value can not be converted to string
func (*Environment) Set ¶ added in v0.1.1
func (g *Environment) Set(key string, val any)
func (*Environment) SetEnvs ¶ added in v0.1.1
func (g *Environment) SetEnvs(envs map[string]any)
Clear all entries from the map and copy the new values while maintaining the same old reference.
func (*Environment) Unset ¶ added in v0.1.1
func (g *Environment) Unset(key string)
func (*Environment) UnsetEnvs ¶ added in v0.1.1
func (g *Environment) UnsetEnvs(keys []string)
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
func FsFileInfo ¶
func NewFileInfo ¶
func (FileInfo) MarshalJSON ¶
func (*FileInfo) UnmarshalJSON ¶
type FlowType ¶ added in v0.1.1
type FlowType string
const ( // FlowTypeSequence executes actions one after another, where each // subsequent action uses the previous action's response as input. FlowTypeSequence FlowType = "sequence" // FlowTypeChain Executes a series of actions consecutively, similar to the `sequence` flow. // The chain returns the result or error from the final action executed. // Chain actions ["a1", "a2", "a3", ...] translate to nested function calls: a1(a2(a3(...))). // Each action in the chain should accept a sub-action through the "action" parameter. FlowTypeChain FlowType = "chain" // FlowTypeChoice randomly selects and executes a single action. FlowTypeChoice FlowType = "choice" // FlowTypeParallel executes actions simultaneously, returning the combined results as a list. // This allows for concurrent processing of independent actions. FlowTypeParallel FlowType = "parallel" )
func ToFlowType ¶ added in v0.30.0
type FuncBody ¶ added in v0.1.1
type FuncBody struct {
// A MIME type (now properly called "media type", but also sometimes "content type")
// is a string sent along with a file indicating the type of the file
// (describing the content format, for example, a sound file might be labeled audio/ogg,
// or an image file image/png).
// https://developer.mozilla.org/en-US/docs/Glossary/MIME_type
// tpl text/x-go-template
// uri text/uri-list
// md text/markdown
// txt text/plain
// go application/x-go
// yaml application/yaml
// sh application/x-sh
// json application/json
// js text/javascript
MimeType string `yaml:"mime_type" json:"mime_type"`
Script string `yaml:"script" json:"script"`
}
type HandlerFunc ¶ added in v0.1.1
type InputConfig ¶ added in v0.1.1
type InternalServerError ¶ added in v0.1.1
type InternalServerError struct {
Message string
}
func (*InternalServerError) Error ¶ added in v0.1.1
func (e *InternalServerError) Error() string
type Kitname ¶ added in v0.1.1
type Kitname string
Took Kit and Name ^[a-z0-9_]+$
func NewKitname ¶ added in v0.1.1
type LLMAdapter ¶ added in v0.1.1
type Level ¶ added in v0.0.3
type Level = string
Level represents the "intelligence" level of the model. i.e. basic, regular, advanced for example, OpenAI: gpt-4.1-mini, gpt-4.1, o3
type Message ¶
type Message struct {
// message id
ID string `json:"id"`
// thread id
Session string `json:"session"`
Created time.Time `json:"created"`
// data
ContentType string `json:"content_type"`
Content string `json:"content"`
// system | assistant | user
Role string `json:"role"`
// user/provider
Sender string `json:"sender"`
// active/responsible agent
Agent Packname `json:"agent"`
//
// TODO
// context of recursive irrelevant historical context messages
// rot the real intent of user
// new context messages are created and sent as user role message to LLM but persisteed as "context"
Context bool `json:"context"`
}
func ToMessages ¶ added in v0.1.1
type Middleware ¶ added in v0.1.1
type Model ¶
type Model struct {
Set string `json:"set"`
Level Level `json:"level"`
Description string `json:"description"`
// model @agent or resolved provider model name
// example:
// @model
// gemini-2.0-flash-lite
Model string `json:"model"`
Provider string `json:"provider"`
BaseUrl string `json:"base_url"`
// api token lookup key
ApiKey string `json:"api_key"`
}
type ModelConfig ¶
type ModelConfig struct {
// LLM model
Model string `yaml:"model" json:"model"`
// LLM service provider: openai | gemini | anthropic
Provider string `yaml:"provider" json:"provider"`
BaseUrl string `yaml:"base_url" json:"base_url"`
// name of api key for looking up api access token
ApiKey string `yaml:"api_key" json:"api_key"`
Description string `json:"description"`
}
type NotFoundError ¶ added in v0.1.1
type NotFoundError struct {
Message string
}
func (*NotFoundError) Error ¶ added in v0.1.1
func (e *NotFoundError) Error() string
type Packname ¶ added in v0.1.1
type Packname string
@pack[/sub] agent:pack[/sub] @* name: ^[a-z0-9_:/]+$ id: ^[a-z0-9_]+$
func NewPackname ¶ added in v0.1.1
func (Packname) Clean ¶ added in v0.1.1
Return a normalized version: pack/sub after removing slash command char '/', prefix and suffix [/]@pack[/sub] [/]agent:pack[/sub] ^[a-z0-9_/]+$
func (Packname) Decode ¶ added in v0.1.1
return normalized pack/sub after cleaning. sub is the same as pack if empty
type Parameters ¶ added in v0.1.1
type Request ¶
type Request struct {
// parent agent
Agent *Agent `json:"-"`
// active action name
Name string `json:"name"`
Arguments Arguments `json:"arguments"`
// LLM
Model *Model `json:"model"`
Tools []*ToolFunc `json:"tools"`
Messages []*Message `json:"messages"`
Runner ActionRunner `json:"-"`
// get api token for LLM model
Token func() string `json:"-"`
//
Prompt string `json:"prompt"`
Query string `json:"query"`
History []*Message `json:"history"`
// contains filtered or unexported fields
}
func NewRequest ¶ added in v0.1.1
func (*Request) Clone ¶
Clone returns a shallow copy of r while ensuring proper copying of slices and maps
func (*Request) Context ¶
Context returns the request's context. To change the context, use Request.WithContext.
The returned context is always non-nil; it defaults to the background context.
For outgoing client requests, the context controls cancellation.
For incoming server requests, the context is canceled when the client's connection closes, the request is canceled (with HTTP/2), or when the ServeHTTP method returns.
func (*Request) SetMaxTurns ¶ added in v0.1.1
func (*Request) WithContext ¶
WithContext returns a shallow copy of r with its context changed to ctx. The provided ctx must be non-nil.
For outgoing client request, the context controls the entire lifetime of a request and its response: obtaining a connection, sending the request, and reading the response headers and body.
To create a new request with a context, use NewRequest. To make a deep copy of a request with a new context, use Request.Clone.
type Resource ¶
type Resource struct {
// web resource base url
// http://localhost:18080/resource
// https://ai.dhnt.io/resource
Base string `json:"base"`
// access token
Token string `json:"token"`
}
type ResourceConfig ¶ added in v0.1.1
type Result ¶
type Result struct {
// author of the reponse: assistant
Role string `json:"role"`
// The result value as a string
Value string `json:"value"`
// media content
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types
MimeType string `json:"mime_type"`
Content []byte `json:"content"`
// transition
// The agent state
State State `json:"state"`
// The agent name to transfer to for StateTransfer
NextAgent string `json:"next_agent"`
//
Actions []*ToolCall `json:"actions"`
}
Result encapsulates the possible return values for agent/function.
type Root ¶ added in v0.1.1
type Root struct {
Name string `json:"name"`
Description string `json:"description"`
// Scheme string `json:"scheme"`
Path string `json:"path"`
}
https://modelcontextprotocol.io/specification/2025-06-18/client/roots https://www.rfc-editor.org/rfc/rfc3986 https://en.wikipedia.org/wiki/Uniform_Resource_Identifier URI = scheme ":" ["//" authority] path ["?" query] ["#" fragment]
type Roots ¶ added in v0.1.1
type Roots struct {
// primary working directory for the agents
Workspace *Root `json:"workspace"`
// Add the current working directory to the root list
// where ai is started
Cwd *Root `json:"cwd"`
// Add system temporary directory to the root list
Temp *Root `json:"temp"`
// Additional paths
Dirs []*Root `json:"dirs"`
}
func (*Roots) AllowedDirs ¶ added in v0.1.1
convenience helper for collecting all accessible paths including symlink of the original path
func (*Roots) ResolveRoots ¶ added in v0.12.1
type SecretStore ¶ added in v0.1.1
type Setlevel ¶ added in v0.1.1
type Setlevel string
Model set and level ^[a-zA-Z0-9_]+$
func NewSetlevel ¶ added in v0.1.1
type TemplateFuncMap ¶
type ToolCall ¶ added in v0.1.1
type ToolCall Action
openai: ChatCompletionMessageToolCallUnion genai: FunctionCall anthropic: ToolUseBlock
type ToolCallEntry ¶ added in v0.1.1
type ToolCallEntry struct {
ID string `json:"id"`
Kit string `json:"kit"`
Name string `json:"name"`
Arguments map[string]any `json:"arguments"`
Error error `json:"error"`
Result any `json:"result"`
Timestamp time.Time `json:"timestamp"`
}
func (*ToolCallEntry) ToJSON ¶ added in v0.1.1
func (r *ToolCallEntry) ToJSON() (string, error)
type ToolConfig ¶
type ToolConfig struct {
Type string `yaml:"type" json:"type"`
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Parameters Parameters `yaml:"parameters" json:"parameters"`
Body *FuncBody `yaml:"body" json:"body"`
// agent name for agent tool type
// description/parameters defined here take precedence
Agent string `yaml:"agent" json:"agent"`
//
Provider string `yaml:"provider" json:"provider"`
BaseUrl string `yaml:"base_url" json:"base_url"`
// api lookup key
ApiKey string `yaml:"api_key" json:"api_key"`
// filter by match key=values (comma, separated)
// include all tools that match
Filter map[string]string `yaml:"filter" json:"filter"`
//
Config *AppConfig `json:"-"`
}
type ToolEnv ¶ added in v0.9.0
type ToolEnv struct {
// User string
Agent *Agent
}
per tool call vars
type ToolFunc ¶
type ToolFunc struct {
Type ToolType `json:"type"`
Kit string `json:"kit"` // kit
Name string `json:"name"` // name
Description string `json:"description"` // description
Parameters Parameters `json:"parameters"` // parameters
Body *FuncBody `json:"body"` // body
// agent name if this tool references an agent
Agent string `json:"agent"`
//
State State `json:"state"`
//
Provider string `json:"provider"`
BaseUrl string `json:"base_url"` // base url
// name of api key - used to resolve api key/token before tool call
ApiKey string `json:"api_key"`
// extra features.
// e.g labels for mcp for filtering tools
Extra map[string]any `json:"extra"`
// default arguments
Arguments map[string]any `json:"arguments"`
//
Config *AppConfig `json:"-"`
}
type ToolSystem ¶ added in v0.0.2
type ToolType ¶ added in v0.1.1
type ToolType string
TODO revisit real type func/web/system/*, mcp, agent, bin, ai???
type UnauthorizedError ¶ added in v0.1.1
type UnauthorizedError struct {
}
func (*UnauthorizedError) Error ¶ added in v0.1.1
func (e *UnauthorizedError) Error() string
type UnsupportedError ¶ added in v0.1.1
type UnsupportedError struct {
Message string
}
func (*UnsupportedError) Error ¶ added in v0.1.1
func (e *UnsupportedError) Error() string
type User ¶
type Vars ¶
type Vars struct {
Global *Environment `json:"global"`
RootAgent *Agent `json:"root_agent"`
RTE *ActionRTEnv `json:"-"`
// contains filtered or unexported fields
}
global context