states

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package schema contains a stateful schema-v2 for AgentBase, Mem, and Tool.

Index

Constants

View Source
const TagManual = "manual"

TagManual is for stories that CANNOT be triggered by the LLM orienting story.

View Source
const TagPrompt = "prompt"

TagPrompt is for states with LLM prompts.

View Source
const TagTrigger = "trigger"

TagTrigger is for stories that can be triggered by the LLM orienting story.

Variables

View Source
var (

	// AgentBaseStates contains all the states for the Agent machine.
	AgentBaseStates = ssA
	// AgentBaseGroups contains all the state groups for the Agent machine.
	AgentBaseGroups = sgA
)
View Source
var (

	// MemStates contains all the states for the Mem machine.
	MemStates = ssM
	// MemGroups contains all the state groups for the Mem machine.
	MemGroups = sgM
)
View Source
var (

	// ToolStates contains all the states for the Tool machine.
	ToolStates = ssT
	// ToolGroups contains all the state groups for the Tool machine.
	ToolGroups = sgT
)
View Source
var AgentSchema = SchemaMerge(

	ssam.BasicSchema,

	ssam.DisposedSchema,

	ssrpc.StateSourceSchema,
	am.Schema{

		ssA.ErrAI: {
			Multi:   true,
			Require: S{Exception},
		},
		ssA.ErrDB: {
			Multi:   true,
			Require: S{Exception},
		},
		ssA.ErrMem: {
			Multi:   true,
			Require: S{Exception},
		},
		ssA.ErrUI: {
			Multi:   true,
			Require: S{ssA.UIMode},
		},
		ssA.ErrWeb: {
			Multi:   true,
			Require: S{ssA.UIMode},
		},
		ssA.ErrWebPTY: {
			Multi:   true,
			Require: S{ssA.UIMode},
		},

		ssA.Start: {Add: S{ssA.BaseDBStarting, ssA.HistoryDBStarting}},
		ssA.Ready: {
			Require: S{ssA.Start},
			Add:     S{ssA.Loop},
		},

		ssA.ConfigUpdate: {
			Multi:  true,
			Remove: S{ssA.ConfigValid, ssA.ConfigValidating},
		},
		ssA.ConfigValidating: {
			Auto:    true,
			Require: S{ssA.Start},
			Remove:  S{ssA.ConfigValid},
		},
		ssA.ConfigValid: {Remove: S{ssA.ConfigValidating}},

		ssA.Loop:         {Require: S{ssA.Ready}},
		ssA.InputPending: {Remove: S{ssA.Prompt}},
		ssA.InputBlocked: {Remove: S{ssA.Prompt}},
		ssA.Requesting:   {},
		ssA.RequestingAI: {
			Multi:   true,
			Require: S{ssA.Start},
		},
		ssA.RequestedAI: {
			Multi:   true,
			Require: S{ssA.Start},
		},
		ssA.RequestingTool: {
			Multi:   true,
			Require: S{ssA.Start},
		},
		ssA.RequestedTool: {
			Multi:   true,
			Require: S{ssA.Start},
		},
		ssA.Mock: {},

		ssA.BaseDBStarting: {
			Remove: S{ssA.BaseDBReady},
		},
		ssA.BaseDBReady: {
			Remove: S{ssA.BaseDBStarting},
		},
		ssA.BaseDBSaving: {Multi: true},
		ssA.DBStarting: {
			Require: S{ssA.Start},
			Remove:  S{ssA.DBReady},
		},
		ssA.DBReady: {
			Require: S{ssA.Start},
			Remove:  S{ssA.DBStarting},
		},
		ssA.HistoryDBStarting: {
			Remove: S{ssA.HistoryDBReady},
		},
		ssA.HistoryDBReady: {
			Remove: S{ssA.HistoryDBStarting},
		},

		ssA.Prompt: {
			Multi:   true,
			Require: S{ssA.Start},
			Remove:  S{ssA.InputPending},
		},
		ssA.Interrupted: {
			Add:    S{ssA.InputPending},
			Remove: S{ssA.Resume},
		},
		ssA.Resume: {
			Remove: S{ssA.Interrupted},
		},
		ssA.UIMsg: {
			Multi:   true,
			Require: S{ssA.Start},
		},

		ssA.CheckStories: {
			Multi:   true,
			Require: S{ssA.Start},
		},
		ssA.StoryChanged: {
			Multi: true,
			After: S{ssA.CheckStories},
		},

		ssA.UIMode:        {Require: S{ssA.Start}},
		ssA.UIReady:       {Require: S{ssA.UIMode}},
		ssA.UIButtonSend:  {Require: S{ssA.UIMode}},
		ssA.UIButtonInter: {Require: S{ssA.UIMode}},
		ssA.UISaveOutput:  {Require: S{ssA.UIMode}},
		ssA.UICleanOutput: {
			Multi:   true,
			Require: S{ssA.UIMode},
		},
		ssA.UIRenderStories: {
			Multi:   true,
			Require: S{ssA.UIMode},
		},
		ssA.UIRenderClock: {
			Multi:   true,
			Require: S{ssA.UIMode},
		},
		ssA.UIUpdateClock: {
			Require: S{ssA.UIMode},
		},
		ssA.StoryAction: {
			Multi:   true,
			Require: S{ssA.UIMode},
		},
		ssA.SSHConn: {
			Multi:   true,
			Require: S{ssA.UIMode},
		},
		ssA.SSHDisconn: {
			Multi:   true,
			Require: S{ssA.UIMode},
		},
		ssA.SSHReady: {Require: S{ssA.UIMode}},
		ssA.WebSSHReady: {
			Auto:    true,
			Require: S{ssA.SSHReady},
		},

		ssA.Debugger: {},
		ssA.REPL:     {},

		ssA.WebHTTPReady: {Require: S{ssA.UIMode}},
		ssA.WebRPCReady:  {Require: S{ssA.UIMode}},
		ssA.WebConnected: {
			Multi:   true,
			Require: S{ssA.WebHTTPReady},
		},
		ssA.RemoteDashReady: {
			Multi:   true,
			Require: S{ssA.WebHTTPReady},
		},
		ssA.RemoteUIReady: {
			Multi:   true,
			Require: S{ssA.WebHTTPReady},
		},
	})

AgentSchema represents all relations and properties of AgentBaseStates.

View Source
var Exception = am.StateException

Exception is a type alias for the exception state.

View Source
var MemSchema = am.Schema{}

MemSchema represents all relations and properties of MemStates.

View Source
var SAdd = am.SAdd

SAdd is a func alias for merging lists of states.

View Source
var SchemaMerge = am.SchemaMerge

SchemaMerge is a func alias for extending an existing state structure.

View Source
var StateAdd = am.StateAdd

StateAdd is a func alias for adding to an existing state definition.

View Source
var StateSet = am.StateSet

StateSet is a func alias for replacing parts of an existing state definition.

View Source
var ToolSchema = SchemaMerge(

	ssam.BasicSchema,

	ssam.DisposedSchema,

	ssrpc.StateSourceSchema,
	am.Schema{

		ssT.Working: {
			Require: S{ssT.Ready},
			Remove:  S{ssT.Idle},
		},
		ssT.Idle: {
			Auto:    true,
			Require: S{ssT.Ready},
			Remove:  S{ssT.Working},
		},
	})

ToolSchema represents all relations and properties of ToolStates.

Functions

This section is empty.

Types

type AgentBaseGroupsDef

type AgentBaseGroupsDef struct {
	UI am.S
}

AgentBaseGroupsDef contains all the state groups Agent state machine.

type AgentBaseStatesDef

type AgentBaseStatesDef struct {
	*am.StatesBase

	ErrAI  string
	ErrDB  string
	ErrMem string
	ErrUI  string
	// Generic web UI err
	ErrWeb string
	// Sharing PTY over web err
	ErrWebPTY string

	ConfigUpdate     string
	ConfigValidating string
	ConfigValid      string
	// Agent is waiting for user input.
	InputPending string
	// User input is blocked by the agent.
	InputBlocked string
	// Requesting implies either RequestingTool or RequestingAI being active
	Requesting string
	// Agent is currently requesting >=1 LLMs
	RequestingAI string
	// AI request ended
	RequestedAI string
	// Agent is currently requesting >=1 tools
	RequestingTool string
	// Tool request ended
	RequestedTool string
	// The machine has been mocked.
	Mock string

	BaseDBStarting string
	BaseDBReady    string
	// BaseDBSaving is lazy query execution.
	BaseDBSaving      string
	DBStarting        string
	DBReady           string
	HistoryDBStarting string
	HistoryDBReady    string

	// Loop is the agent-user loop (eg dialogue).
	Loop string
	// Prompt is the text the user has sent us.
	Prompt string
	// Interrupted is when the user interrupts the agent, until Resume.
	Interrupted string
	// Resume is the signal from the user to resume after an Interrupted.
	Resume string

	// Check the status of all the stories.
	CheckStories string
	// At least one of the stories has changed its status (active / inactive).
	StoryChanged string
	// Call an action with a specified ID.
	StoryAction string

	UIMode  string
	UIReady string
	// UI button "Send" has been pressed
	UIButtonSend string
	// UI button "Interrupt" has been pressed
	UIButtonInter string
	// TODO
	UISaveOutput  string
	UICleanOutput string
	// UIMsg will output the passed text into the UI.
	UIMsg           string
	UIRenderStories string
	// debounce state for UIRenderClock
	UIUpdateClock string
	UIRenderClock string
	// new SSH session connected
	SSHConn string
	// SSH session disconnected
	SSHDisconn string
	// TODO SSHSessChange?
	// SSH server listening
	SSHReady string
	// web SSH fwrder listening
	WebSSHReady string
	// web server listening
	WebHTTPReady string
	// web aRPC listening for both WebSocket servers
	WebRPCReady string
	// at least one browser is currently connected
	WebConnected string
	// agent is connected to the browser RPC server
	RemoteDashReady string
	RemoteUIReady   string

	// embedded am-dbg running
	Debugger string
	// embedded REPL running
	REPL string

	// inherit from BasicStatesDef
	*ssam.BasicStatesDef
	// inherit from DisposedStatesDef
	*ssam.DisposedStatesDef
	// inherit from StateSourceStatesDef
	*ssrpc.StateSourceStatesDef
}

AgentBaseStatesDef contains all the states of the Agent state machine.

type MemGroupsDef

type MemGroupsDef struct {
}

MemGroupsDef contains all the state groups Mem state machine.

type MemStatesDef

type MemStatesDef struct {
	*am.StatesBase
}

MemStatesDef contains all the states of the Mem state machine.

type S

type S = am.S

S is a type alias for a list of state names.

type State

type State = am.State

State is a type alias for a state definition. See am.State.

type ToolGroupsDef

type ToolGroupsDef struct {
}

ToolGroupsDef contains all the state groups Tool state machine.

type ToolStatesDef

type ToolStatesDef struct {
	*am.StatesBase

	Working string
	Idle    string

	// inherit from BasicStatesDef
	*ssam.BasicStatesDef
	// inherit from DisposedStatesDef
	*ssam.DisposedStatesDef
	// inherit from StateSourceStatesDef
	*ssrpc.StateSourceStatesDef
}

ToolStatesDef contains all the states of the Tool state machine.

type Website

type Website struct {
	URL     string `description:"The URL of the website."`
	Title   string `description:"The title of the website."`
	Content string `description:"The content or a snippet of the website."`
}

Jump to

Keyboard shortcuts

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