Documentation
¶
Index ¶
- Constants
- func Main()
- func Register(fn RegisterFunc)
- func RegisterProfile(p Profile)
- type Adapter
- type ApprovalAction
- type ApprovalFunc
- type ApprovalRequest
- type AudioFormat
- type AuxiliaryTask
- type Blueprint
- type CLICommand
- type Command
- type Cron
- func (c Cron) ClaimFire(ctx context.Context, jobID string, force, manual bool) (map[string]any, error)
- func (c Cron) FireClaimed(ctx context.Context, claimed map[string]any, cancel *Event) error
- func (c Cron) FireDue(ctx context.Context, jobID string, force, manual bool) (bool, error)
- func (c Cron) RecoverInterrupted(ctx context.Context) (int, error)
- type CronScheduler
- type DirEntry
- type DoctorCheck
- type EnvCredentials
- type EnvHomeChannel
- type EnvReplyMode
- type EnvSpec
- type EnvStep
- type Error
- type Event
- type ExecApprovalPrompt
- type ExecApprovalRequest
- type Func
- type Gateway
- func (g *Gateway) HandleMessage(ctx context.Context, event MessageEvent) error
- func (g *Gateway) MarkConnected(ctx context.Context, listenerBase string) error
- func (g *Gateway) MarkDisconnected(ctx context.Context) error
- func (g *Gateway) RunHandler(ctx context.Context, event MessageEvent) (any, error)
- func (g *Gateway) SetFatalError(ctx context.Context, code, message string, retryable bool) error
- type HTTPRequest
- type HTTPResponse
- type Handle
- type HookFunc
- type Host
- type HostFunc
- type HostObject
- type ImageRef
- type Locale
- type LoginBackend
- type MediaRequest
- type Message
- type MessageEvent
- type MessageResult
- type Object
- type Opaque
- type Ordered
- type Pair
- type Platform
- type Profile
- type ProviderRequest
- type Record
- type RegisterFunc
- type Section
- type SendRequest
- type SendResult
- type SessionSource
- type SetupVar
- type SlackActionFunc
- type StandaloneSendPolicy
- type StandaloneSendRequest
- type StreamEvent
- type StreamSink
- type TTSStream
- type TargetSyntax
- type TerminalBackend
- type TerminalCommand
- type TerminalEnvironment
- type TerminalOptions
- type TerminalResult
- type Tool
- type ToolCall
- type ToolPreview
- type ToolSendRequest
- type VaultItem
- type WarningRequest
- type Widget
- type WidgetFrame
- type WidgetInput
- type WidgetLine
- type WidgetSpan
- type WidgetView
Constants ¶
const ExtractProfilesFlag = "--extract-profiles"
Argument that makes a program plugin print its profiles as JSON and exit without serving the wire
const ProtocolVersion = 1
Version of the frame protocol this library speaks
Variables ¶
This section is empty.
Functions ¶
func Main ¶
func Main()
Serves the plugin wire on standard input and output until icebath closes it, then exits
func Register ¶
func Register(fn RegisterFunc)
Names the function the host runs when it loads this plugin, called from an init function
func RegisterProfile ¶
func RegisterProfile(p Profile)
Names a model provider profile the plugin offers, called from an init function
Types ¶
type Adapter ¶
type Adapter struct {
// Display name of the adapter, the platform name when empty
Name string
// Opens the connection and starts what listens for messages, false when it could not, a WebAssembly plugin running only while icebath calls it
Connect func(ctx context.Context, reconnect bool) (bool, error)
Disconnect func(ctx context.Context) error
Send func(ctx context.Context, req SendRequest) (SendResult, error)
// Name and type of a chat, a direct message named by its id when unset
GetChatInfo func(ctx context.Context, chatID string) (map[string]any, error)
EditMessage func(ctx context.Context, chatID, messageID, content string, finalize bool) (SendResult, error)
DeleteMessage func(ctx context.Context, chatID, messageID string) (bool, error)
CreateHandoffThread func(ctx context.Context, parentChatID, name string) (threadID string, ok bool, err error)
SendTyping func(ctx context.Context, chatID string, metadata map[string]any) error
StopTyping func(ctx context.Context, chatID string) error
SendImage func(ctx context.Context, req MediaRequest) (SendResult, error)
SendAnimation func(ctx context.Context, req MediaRequest) (SendResult, error)
SendImageFile func(ctx context.Context, req MediaRequest) (SendResult, error)
SendVoice func(ctx context.Context, req MediaRequest) (SendResult, error)
SendVideo func(ctx context.Context, req MediaRequest) (SendResult, error)
SendDocument func(ctx context.Context, req MediaRequest) (SendResult, error)
PlayTTS func(ctx context.Context, req MediaRequest) (SendResult, error)
SendMultipleImages func(ctx context.Context, chatID string, images []ImageRef, metadata map[string]any, humanDelay float64) (SendResult, error)
// Notice only one user of a chat sees, an empty user id addressing the chat
SendPrivateNotice func(ctx context.Context, chatID, userID, content, replyTo string, metadata map[string]any) (SendResult, error)
SendDraft func(ctx context.Context, chatID string, draftID int, content string, metadata map[string]any) (SendResult, error)
SendExecApproval func(ctx context.Context, req ExecApprovalRequest) (SendResult, error)
SendSlashConfirm func(ctx context.Context, chatID, title, message, sessionKey, confirmID string, metadata map[string]any) (SendResult, error)
SendClarify func(ctx context.Context, chatID, question string, choices []string, clarifyID, sessionKey string, metadata map[string]any) (SendResult, error)
FormatMessage func(ctx context.Context, content string) (string, error)
// Longest message a chat takes
MaxMessageLengthForChat func(ctx context.Context, chatID string) (int, error)
// Length the platform counts a text as, the chat id empty when none is known
MessageLength func(ctx context.Context, chatID, text string) (int, error)
EnforcesOwnAccessPolicy func(ctx context.Context) bool
AuthorizationIsUpstream func(ctx context.Context) bool
SupportsDraftStreaming func(ctx context.Context, chatType string, metadata map[string]any, chatID string) bool
PrefersFreshFinalStreaming func(ctx context.Context, content string, metadata map[string]any) bool
StreamingOverflowLimit func(ctx context.Context) (limit int, ok bool)
SendPathDegraded func(ctx context.Context) bool
IsConnected func(ctx context.Context) bool
PrepareTTSText func(ctx context.Context, text string) (string, error)
OnProcessingStart func(ctx context.Context, event MessageEvent) error
OnProcessingComplete func(ctx context.Context, event MessageEvent, outcome string) error
// Takes over a message the gateway routes to the adapter, Gateway.HandleMessage continuing into the gateway pipeline
HandleMessage func(ctx context.Context, event MessageEvent) error
ToolsetsForSource func(ctx context.Context, source SessionSource) (toolsets []string, ok bool)
CancelBackgroundTasks func(ctx context.Context) error
RenderMessageEvent func(ctx context.Context, event StreamEvent, sink *StreamSink) error
FormatToolEvent func(ctx context.Context, event StreamEvent, mode string, previewMaxLen int) (line string, ok bool, err error)
FormatToolPreview func(ctx context.Context, preview ToolPreview) (string, error)
TextBatchKey func(ctx context.Context, event MessageEvent) (string, error)
EnqueueTextEvent func(ctx context.Context, event MessageEvent) error
// Seconds a text batch waits for more parts, pending nil before any part arrived
TextBatchDelay func(ctx context.Context, pending *MessageEvent) float64
PopTextBatch func(ctx context.Context, key string) (*MessageEvent, error)
DispatchTextBatch func(ctx context.Context, event MessageEvent) error
FlushTextBatch func(ctx context.Context, key string) error
ApprovalHeader func(ctx context.Context) string
ApprovalReasonLabel func(ctx context.Context) string
ApprovalSmartDenyLine func(ctx context.Context) string
ApprovalActionLabels func(ctx context.Context) map[string]string
ApprovalEscape func(ctx context.Context, text string) string
ApprovalCommandBudget func(ctx context.Context, description string, smartDenied bool) int
SendExecApprovalPrompt func(ctx context.Context, prompt ExecApprovalPrompt) (SendResult, error)
// Shows a warning, nil when the platform shows none
EmitWarning func(ctx context.Context, req WarningRequest) (*SendResult, error)
EmitMediaWarning func(ctx context.Context, req WarningRequest) (SendResult, error)
WarningText func(ctx context.Context, req WarningRequest) (text string, ok bool, err error)
WarningNotificationsOn func(ctx context.Context, req WarningRequest) bool
SupportsStreamingTTS func(ctx context.Context, chatID string, format AudioFormat) bool
// Begins a speech playback, nil when the chat cannot play one
BeginStreamingTTS func(ctx context.Context, chatID string, format AudioFormat, metadata map[string]any) (*TTSStream, error)
WriteStreamingTTS func(ctx context.Context, stream *TTSStream, chunk []byte) error
FinishStreamingTTS func(ctx context.Context, stream *TTSStream, interrupted bool) error
AbortStreamingTTS func(ctx context.Context, stream *TTSStream, errText string) error
// Whether a failed send is final and must not be retried
SendRetryIsFinal func(ctx context.Context, result SendResult) bool
// Runs after the gateway marked the adapter connected
Connected func(ctx context.Context, listenerBase string) error
// Runs after the gateway marked the adapter disconnected
Disconnected func(ctx context.Context) error
// Runs after the gateway recorded a fatal connection error
FatalError func(ctx context.Context, code, message string, retryable bool) error
}
Adapter of one platform connection, every hook optional except Connect, Disconnect and Send, an unset one keeping the gateway behaviour
type ApprovalAction ¶
One button of an approval prompt
type ApprovalFunc ¶
type ApprovalFunc func(ctx context.Context, req ApprovalRequest) (choice string, err error)
Presents an approval request and returns the choice made, empty when none was made
type ApprovalRequest ¶
type ApprovalRequest struct {
SchemaVersion int64
RequestID string
Digest string
Command string
Description string
PatternKey string
PatternKeys []string
Surface string
TimeoutSeconds float64
AllowedChoices []string
}
Approval request a transport presents to the user
type AudioFormat ¶
PCM format of streamed speech
type AuxiliaryTask ¶
type AuxiliaryTask struct {
DisplayName string
Description string
Defaults map[string]any
InheritFrom string
}
Auxiliary model task a plugin declares
type Blueprint ¶
type Blueprint struct {
Title string
Description string
ScheduleTemplate string
PromptTemplate string
Category string
Slots []any
DeliverDefault string
Skills []string
Tags []string
}
Scheduled automation a user can instantiate
type CLICommand ¶
type CLICommand struct {
Name string
Help string
Description string
// Runs the command and returns what it prints on standard output with its exit code, the plugin having no terminal of its own
Run func(ctx context.Context, argv []string, options map[string]any) (output string, code int, err error)
}
One `icebath <name>` subcommand of a plugin, run with the arguments after its name and the options given before it
type Command ¶
type Command struct {
Name string
Description string
ArgsHint string
ArgumentMode string
Handler func(ctx context.Context, args string) (string, error)
}
One slash command
type Cron ¶
type Cron struct {
// contains filtered or unexported fields
}
Cron operations of the profile a scheduler fires its jobs through, each fire claimed once across every machine
func (Cron) ClaimFire ¶
func (c Cron) ClaimFire(ctx context.Context, jobID string, force, manual bool) (map[string]any, error)
Claims one fire of a job and returns its snapshot, nil when another claim holds it or the job is gone, manual marking a run now that is not the scheduled occurrence
func (Cron) FireClaimed ¶
Runs a claimed snapshot through the run and delivery path of icebath, a set cancel event stopping the run
type CronScheduler ¶
type CronScheduler struct {
// Value of cron.provider that selects the scheduler
Name string
// Whether the scheduler can run here, true when unset, a cheap check that makes no network call
IsAvailable func(ctx context.Context) bool
// Begins firing due jobs and returns once stop is set or at once when its work goes on elsewhere, interval the seconds between ticks icebath asks for
Start func(ctx context.Context, stop *Event, cron Cron, interval float64) error
// Eager teardown, stop being the primary signal
Stop func(ctx context.Context) error
// Runs after the job store changed, for a scheduler that mirrors it elsewhere
OnJobsChanged func(ctx context.Context) error
// Registers the trigger of a newly saved job before icebath reports it as scheduled
RegisterJob func(ctx context.Context, job map[string]any) error
}
Trigger a plugin offers for scheduled jobs, deciding when a due job fires while icebath runs and delivers it
type DoctorCheck ¶
One row of a backend health report
type EnvCredentials ¶
type EnvCredentials struct {
// Platform the step enables, the registering platform when empty
Platform string
// Groups of variable names, one name of every group having to be set
Credentials [][]string
// Variable copied into the platform token
TokenEnv string
// Variables always written into the extra config, a default standing in for an unset one
Fixed []EnvSpec
// Variables written into the extra config when set
Optional []EnvSpec
// Variables written into the extra config when set, surrounding space removed
OptionalStripped []EnvSpec
// Variable whose absence logs WarnMissingText
WarnMissingEnv string
WarnMissingText string
// Variable base of the home channel, read as <HomeEnv>_HOME_CHANNEL
HomeEnv string
HomeStrip bool
// Runs once the platform is enabled, changing the gateway config or the platform config in place
Then func(ctx context.Context, gatewayConfig, platformConfig map[string]any) error
}
Enables a platform when its credential variables are set and copies the listed variables into its config
type EnvHomeChannel ¶
Step reading the home channel of a platform from <EnvBase>_HOME_CHANNEL and its name
type EnvReplyMode ¶
Step reading the reply mode of a platform from one variable
type EnvSpec ¶
type EnvSpec struct {
Key string
Env string
// Variables read in order in place of Env, the first one set winning
AnyOf []string
// Value of a fixed spec whose variable is unset
Default string
// Whether an optional spec stores a whole number, a malformed one skipped
Integer bool
// Value stored for the variable text
Convert func(ctx context.Context, value string) (any, error)
}
One variable copied into the extra config of a platform
type EnvStep ¶
type EnvStep struct {
Credentials *EnvCredentials
HomeChannel *EnvHomeChannel
ReplyMode *EnvReplyMode
// Changes the gateway config document in place
Apply func(ctx context.Context, gatewayConfig map[string]any) error
}
One environment to config step, exactly one of its forms set
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Flag living in icebath that a plugin reads, waits on and sets, the form a stop or cancel signal reaches a plugin in
type ExecApprovalPrompt ¶
type ExecApprovalPrompt struct {
ChatID string
SessionKey string
Text string
Actions []ApprovalAction
Command string
Description string
SmartDenied bool
Metadata map[string]any
RequestID string
}
Rendered approval prompt with its action buttons
type ExecApprovalRequest ¶
type ExecApprovalRequest struct {
ChatID string
Command string
SessionKey string
Description string
Metadata map[string]any
AllowPermanent bool
AllowSession bool
SmartDenied bool
RequestID string
}
Approval a dangerous command waits on
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway side of one platform adapter, taking its inbound messages and its connection state
func (*Gateway) HandleMessage ¶
func (g *Gateway) HandleMessage(ctx context.Context, event MessageEvent) error
Hands an inbound message to the gateway pipeline with its access checks, batching and busy session queueing
func (*Gateway) MarkConnected ¶
Marks the adapter connected, listenerBase naming its webhook listener when it has one
func (*Gateway) MarkDisconnected ¶
Marks the adapter disconnected
func (*Gateway) RunHandler ¶
Runs the gateway message handler directly for an adapter that dispatches its own messages and returns the reply
type HTTPRequest ¶
type HTTPRequest struct {
Method string
URL string
Headers map[string]string
Body []byte
TimeoutSeconds float64
}
HTTP request the host performs for the plugin
type HTTPResponse ¶
HTTP response the host returned
type Host ¶
type Host interface {
// Id icebath knows the plugin by
PluginID() string
// Key of the plugin among the loaded plugins of its profile
PluginKey() string
// Name the plugin manifest declares
Name() string
// Directory the plugin was loaded from
Dir() string
// Name of the profile the plugin runs for
ProfileName() string
// Fields of the plugin manifest
Manifest() map[string]any
// Value of one key of the plugin settings, def when it is unset
Config(ctx context.Context, key string, def any) (any, error)
// Stores one key of the plugin settings
SetConfig(ctx context.Context, key string, value any) error
// Whether another plugin of that id or name is loaded and enabled
HasPlugin(ctx context.Context, id string) (bool, error)
// Whether a capability is granted to the plugin
HasCapability(ctx context.Context, capability string) (bool, error)
// Adds a tool the model can call
RegisterTool(tool Tool) (*Handle, error)
// Runs fn on every firing of a lifecycle hook, holdStream keeping the reply stream open while it runs
RegisterHook(name string, fn HookFunc, holdStream bool) (*Handle, error)
// Runs fn as middleware of one kind
RegisterMiddleware(kind string, fn HookFunc) (*Handle, error)
// Adds a slash command of a session
RegisterCommand(cmd Command) (*Handle, error)
// Adds an `icebath <name>` subcommand
RegisterCLICommand(cmd CLICommand) (*Handle, error)
// Registers a provider object of one kind, the members that kind leaves optional filled with their base behaviour: image_gen, video_gen, web_search, browser, terminal_environment, secret_source, tts, transcription, delegation, context_engine, context_reference, memory, login_backend, browser_page_backend, cron_scheduler or computer_use
RegisterProvider(kind string, provider *Object) (*Handle, error)
// Registers a browser vault backend that resolves saved logins
RegisterLoginBackend(backend LoginBackend) (*Handle, error)
// Registers a terminal backend whose environments run the commands of the terminal, code and file tools
RegisterTerminalBackend(backend TerminalBackend) (*Handle, error)
// Registers a cron scheduler that decides when due jobs fire
RegisterCronScheduler(scheduler CronScheduler) (*Handle, error)
// Adds a messaging platform to the gateway
RegisterPlatform(platform Platform) (*Handle, error)
// Runs fn for a Slack interactive action whose id matches a string, a *regexp.Regexp or a mapping of constraints
RegisterSlackActionHandler(actionID any, fn SlackActionFunc) (*Handle, error)
// Adds a transport that presents command approvals to the user
RegisterApprovalTransport(name string, present ApprovalFunc) error
// Adds a view the terminal UI renders
RegisterWidget(widget Widget) (*Handle, error)
// Adds a read only skill resolvable as <plugin>:<name>
RegisterSkill(name, path, description string, frontmatter map[string]any) (*Handle, error)
// Adds messages of one language from a YAML file path or a mapping of dotted keys
RegisterLocale(lang string, source any, locale Locale) (*Handle, error)
// Adds every language file of a directory
RegisterLocaleDir(path string, metadata map[string]map[string]any) error
// Adds a section to the system prompt, its content a string or a func(context.Context, map[string]any) (string, error)
RegisterSystemPromptSection(id string, content any, section Section) (*Handle, error)
// Adds a scheduled automation users can instantiate
RegisterAutomationBlueprint(key string, blueprint Blueprint) (*Handle, error)
// Declares an auxiliary model task with its own settings
RegisterAuxiliaryTask(key string, task AuxiliaryTask) (*Handle, error)
// Adds patterns whose matches are masked in output and returns how many were accepted
RegisterRedactionPatterns(patterns []string) (int, error)
// Runs fn for every event of a qualified name such as <plugin>:<event>
Subscribe(event string, fn HookFunc) error
// Publishes an event under the name of the plugin and returns how many subscribers it was scheduled for
Emit(ctx context.Context, event string, payload map[string]any) (int, error)
// Runs fn when the plugin unloads, the last one added first
OnUnload(fn func() error)
// Runs a tool by name and returns its result text
DispatchTool(ctx context.Context, name string, args map[string]any) (string, error)
// Calls a tool of a connected MCP server
CallMCP(ctx context.Context, server, tool string, args map[string]any, timeoutSeconds float64) (map[string]any, error)
// Queues a message for the session of the call or the one a session key names, true when a host accepted it
InjectMessage(ctx context.Context, content, role, sessionKey string) (bool, error)
// Queues a message for a new session at a chat of the plugin's own profile, true when a host accepted it
InjectMessageAt(ctx context.Context, content, role string, origin SessionSource) (bool, error)
// Posts text into the session of the call and returns its handle, a refusal reported by the handle and never as an error
PostMessage(ctx context.Context, text string) (*Message, error)
// Asks the user of a slash command to pick one choice, ok false when nobody can answer
AskChoice(ctx context.Context, question string, choices []string) (choice string, ok bool, err error)
// Asks the agent of the session about the turn that just ended, with the token its post_llm_call hook received, ok false when it gave no answer
SideQuestion(ctx context.Context, token, prompt string, timeoutSeconds float64) (answer string, ok bool, err error)
// Working directory of the session of the call
SessionCwd(ctx context.Context) (string, error)
// Client or messaging platform of the session of the call
SessionSurface(ctx context.Context) (string, error)
// Scheduled run the call belongs to, nil outside one
CurrentCronExecution(ctx context.Context) (any, error)
// Rewrites the latest user message into one retrieval question, served to a memory provider plugin only, empty when the message itself is the better query
RewriteMemoryQuery(ctx context.Context, userMessage string) (string, error)
// Reads an attribute or calls a method of one facade: state, llm, platform_actions, subagent_lifecycle or delegation_backends
Facade(ctx context.Context, facade, method string, args []any, kwargs map[string]any) (any, error)
// Calls one method of the plugin context by its wire name
Call(ctx context.Context, method string, args []any, kwargs map[string]any) (any, error)
// Reads a file the manifest grants read access to
ReadFile(ctx context.Context, path string) ([]byte, error)
// Writes a file the manifest grants write access to
WriteFile(ctx context.Context, path string, data []byte) error
// Lists a directory the manifest grants read access to
ListDir(ctx context.Context, path string) ([]DirEntry, error)
// Removes a file the manifest grants write access to
Remove(ctx context.Context, path string) error
// Performs an HTTP request to a host the manifest grants
HTTP(ctx context.Context, req HTTPRequest) (*HTTPResponse, error)
// Sends a provider request with the sign in of the plugin attached
ProviderRequest(ctx context.Context, req ProviderRequest) (*HTTPResponse, error)
// Value of an environment variable the manifest grants, ok false when it is unset
Env(ctx context.Context, name string) (value string, ok bool, err error)
}
Everything a plugin can register on icebath and ask of it
type HostFunc ¶
type HostFunc struct {
// contains filtered or unexported fields
}
Host callable handed to the plugin as an argument
type HostObject ¶
type HostObject struct {
// Type name icebath reports for the object
Type string
// contains filtered or unexported fields
}
Object living in icebath that the plugin reads and calls by name
func (*HostObject) Call ¶
func (o *HostObject) Call(ctx context.Context, method string, args []any, kwargs map[string]any) (any, error)
Calls one method of the host object
type LoginBackend ¶
type LoginBackend struct {
// Lowercase identifier the vault settings and every handle of the backend carry
Name string
DisplayName string
ListItems func(ctx context.Context) ([]VaultItem, error)
// Item of a handle, nil when the backend holds none
GetMeta func(ctx context.Context, handle string) (*VaultItem, error)
ResolvePassword func(ctx context.Context, handle string) (string, error)
// Current one time code of a login that stores a seed, ok false when it stores none
ResolveOTP func(ctx context.Context, handle string) (code string, ok bool, err error)
// Full payload of a payment or address item, the password alone when unset
ResolveSecret func(ctx context.Context, handle string) (map[string]string, error)
// Holds whatever one fill needs until the returned release runs
Fill func(ctx context.Context) (release func() error, err error)
}
Browser vault backend resolving saved logins by handle, its handles all starting with the name and a colon
type MediaRequest ¶
type MediaRequest struct {
ChatID string
URL string
Path string
Caption string
FileName string
ReplyTo string
Metadata map[string]any
// Further keywords the caller passed, such as the thread of a forum topic
Extra map[string]any
}
Media send of an adapter, URL for a remote image and Path for a local file
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message a plugin posted into the session of the call, its text replaceable in place
func (*Message) Edit ¶
Replaces the text of the message, posting it anew where the surface cannot edit
func (*Message) Refresh ¶
func (m *Message) Refresh(ctx context.Context) (MessageResult, error)
Reads the outcome the gateway holds for the message, the one of an operation that finished after it timed out included
func (*Message) Result ¶
func (m *Message) Result() MessageResult
Outcome of the last operation this handle ran
type MessageEvent ¶
type MessageEvent struct {
Text string
// Kind of message, text when empty
MessageType string
Source *SessionSource
UserID string
UserName string
MessageID string
LedgerMessageID string
ReplyAnchorOverride string
PlatformUpdateID *int64
RawMessage any
MediaURLs []string
MediaTypes []string
MediaFilenames []string
MediaTextInlined []*bool
ReplyToMessageID string
ReplyToText string
ReplyToAuthorID string
ReplyToAuthorName string
ReplyToIsOwnMessage bool
PromptResponse map[string]any
AutoSkill any
ChannelPrompt string
ChannelContext string
Internal bool
Metadata map[string]any
// Time the message was sent, the time the gateway receives it when zero
Timestamp time.Time
// Whether the message may not run gateway control commands
DenyGatewayControl bool
ReplyExpected *bool
InheritChannelPin bool
EditRevision string
}
One inbound or replayed message
type MessageResult ¶
type MessageResult struct {
// Whether the operation succeeded
OK bool
// Id of the message the handle follows, empty before any message landed
MessageID string
// Code of a refusal or failure such as no_conversation, gateway_unavailable, timeout, send_failed or edit_failed
Error string
// Text explaining a refusal or failure
Detail string
// Whether an edit replaced the message in place
Edited bool
// Whether an edit posted a new message because the surface cannot edit
Fallback bool
// Whether an operation the gateway has not finished is still running, its outcome read later with Refresh
Pending bool
// Every field the gateway answered
Fields map[string]any
}
Outcome of one post or edit of a plugin message
type Object ¶
type Object struct {
Type string
Attrs map[string]any
Methods map[string]Func
// Yields the next item each time the host steps through the object, ok false once it has no more
Next func(ctx context.Context) (item any, ok bool, err error)
// contains filtered or unexported fields
}
Object the host calls by method name and reads by attribute name, the form every provider takes
func Self ¶
Object the host addressed with the call the context serves, nil outside a call on an object
type Ordered ¶
type Ordered []Pair
Mapping that crosses with its keys in the order given, for the places icebath reads that order such as tool schema properties
type Platform ¶
type Platform struct {
Name string
Label string
RequiredEnv []string
InstallHint string
// Plain registry fields such as allowed_users_env, allow_all_env, max_message_length, emoji, platform_hint, pii_safe or display_tier
Extra map[string]any
// Whether the platform can run here, true when unset
Check func(ctx context.Context) bool
// Whether a platform config holds what the adapter needs
ValidateConfig func(ctx context.Context, config map[string]any) (bool, error)
// Whether a platform config counts as connected in status listings
IsConnected func(ctx context.Context, config map[string]any) (bool, error)
// Whether a platform config alone, without the environment, counts as connected
ConfigConnected func(ctx context.Context, config map[string]any) (bool, error)
// Installs what the platform needs when Check answered false, true once it can run
EnsureDeps func(ctx context.Context) (bool, error)
// Extra config the environment enables the platform with, empty leaving it off
EnvEnablement func(ctx context.Context) (map[string]any, error)
// Reads the platform block of config.yaml, changing either document in place and returning extra config to seed
ApplyYAMLConfig func(ctx context.Context, yamlConfig, block map[string]any) (map[string]any, error)
// Chat and thread a send target names, ok false leaving the reference to the built in rules
ParseTargetRef func(ctx context.Context, ref string) (chatID, threadID string, ok bool, err error)
// Whether a chat id is a valid send target, the reason shown when it is not
ValidateTargetRef func(ctx context.Context, chatID string) (ok bool, reason string, err error)
// Native syntax of a send target
TargetRefSyntax func(ctx context.Context, ref string) (TargetSyntax, error)
// Send the send_message tool makes when no adapter of the platform runs
SendMessage func(ctx context.Context, req ToolSendRequest) (map[string]any, error)
// Send cron jobs and the send command make with no gateway running
StandaloneSend func(ctx context.Context, req StandaloneSendRequest) (map[string]any, error)
// How cron and the send command use StandaloneSend
StandaloneSendPolicy *StandaloneSendPolicy
// Steps that turn environment variables into gateway config
EnvOverrides []EnvStep
// Lines the setup of the platform shows before its questions
SetupInstructions []string
// Questions icebath asks when the platform is set up, the first variable of RequiredEnv counting as the token the platform cannot work without
SetupVars []SetupVar
// Builds the adapter of one connection, nil for a config the platform does not serve
Adapter func(ctx context.Context, config map[string]any, gw *Gateway) (*Adapter, error)
}
Messaging platform a plugin adds to the gateway, every hook optional except the adapter
type Profile ¶
Model provider profile of a plugin, its data fields read by the host and its calls run here
type ProviderRequest ¶
type ProviderRequest struct {
Provider string
Method string
URL string
Headers map[string]string
JSON any
TimeoutSeconds float64
}
Request icebath sends to a provider with the sign in the plugin declares in requires_auth or oauth attached
type RegisterFunc ¶
Entry point of a plugin, run once per load with the host it registers on
type SendRequest ¶
Text send of an adapter
type SendResult ¶
type SendResult struct {
Success bool
MessageID any
Error any
RawResponse any
Retryable bool
RetryAfter *float64
ContinuationMessageIDs []any
ErrorKind string
}
Outcome of one send
type SessionSource ¶
type SessionSource struct {
Platform string
ChatID string
ChatName string
ChatType string
UserID string
UserName string
ThreadID string
ChatTopic string
UserIDAlt string
ChatIDAlt string
ScopeID string
ParentChatID string
MessageID string
Profile string
AutoThreadCreated bool
AutoThreadInitialName string
ProspectiveThreadID string
}
Chat a message arrived in, the routing identity of a session
type SetupVar ¶
type SetupVar struct {
// Variable the answer is saved under
Env string
// Question shown, the variable name when empty
Prompt string
// Line shown above the question
Help string
// Whether the answer is typed hidden
Secret bool
// Whether the answer lists the users allowed to talk to the platform
Allowlist bool
}
One question of a platform setup, asked by icebath in the terminal UI and its answer saved as an environment variable of the profile
type SlackActionFunc ¶
type SlackActionFunc func(ctx context.Context, ack func(payload map[string]any) error, body, action map[string]any) error
Slack interactive action callback, ack answering Slack with an optional payload
type StandaloneSendPolicy ¶
type StandaloneSendPolicy struct {
Label string
Media bool
AllSends bool
Captionable bool
EmptyListBetweenChunks bool
ForwardForceDocument bool
Mentions bool
TextDirect bool
}
How cron and the send command use the standalone sender of a platform
type StandaloneSendRequest ¶
type StandaloneSendRequest struct {
Config map[string]any
ChatID string
Message string
Options map[string]any
}
Send made with no running gateway, Options holding the thread, media and other keywords of the caller
type StreamEvent ¶
type StreamEvent struct {
// One of message_chunk, message_stop, commentary, tool_call_chunk, tool_call_finished, long_tool_hint or gateway_notice
Kind string
Text string
Final bool
ToolName string
Preview string
Args map[string]any
Index int
Duration float64
OK bool
// Kind of a gateway notice
Notice string
Extra map[string]any
}
One streamed reply event
type StreamSink ¶
type StreamSink struct {
// contains filtered or unexported fields
}
Sink a stream renderer writes the reply through
func (*StreamSink) Commentary ¶
func (s *StreamSink) Commentary(ctx context.Context, text string) error
Writes commentary beside the message
func (*StreamSink) Delta ¶
func (s *StreamSink) Delta(ctx context.Context, text string) error
Appends text to the current message
func (*StreamSink) SegmentBreak ¶
func (s *StreamSink) SegmentBreak(ctx context.Context) error
Ends the current message segment
type TTSStream ¶
type TTSStream struct {
ChatID string
Format AudioFormat
Audible bool
Aborted bool
// Platform state the adapter keeps for the playback
State any
}
Streaming speech playback an adapter began, Audible and Aborted kept in step with the gateway around every call
type TargetSyntax ¶
type TargetSyntax struct {
// Whether the parser recognized the reference, false leaving it to the built in rules
Matched bool
// Whether a recognized reference is a name to look up in place of an explicit target
NotExplicit bool
// Chat an explicit reference names, empty for none
ChatID string
// Thread an explicit reference names, empty for none
ThreadID string
}
Verdict of a target syntax parser
type TerminalBackend ¶
type TerminalBackend struct {
// Value of terminal.backend that selects the backend, lower case letters, digits and underscores
Name string
DisplayName string
// One line shown in backend pickers
Description string
// Where commands run, named in the system prompt when the live probe fails
EnvDescription string
// Whether commands run on the machine icebath runs on, a backend running them elsewhere when false
Local bool
// Whether commands see the files of the machine icebath runs on, a backend with a filesystem of its own when false
HostFilesystem bool
// Whether dangerous commands still ask for approval in a backend with a filesystem of its own, for one that can reach paths of the machine
KeepApprovals bool
// Directory inside the backend that holds the synced cache files, such as ~/.icebath, empty when the paths of the machine stay correct
CachePathBase string
// Directory commands start in when terminal.cwd is unset or unusable there, an absolute path or ~ for the home each environment resolves
DefaultCwd string
// Environment variables holding the credentials of the backend, removed from every process the agent starts
StripEnvKeys []string
// Whether a session gets an environment of its own when the backend does not persist
SessionIsolatedWhenNonpersistent bool
// Whether environments answer ExecPrefix, letting the bot desktop, computer use and the browser follow the terminal into the backend
SupportsStreams bool
// Whether the backend can run commands, a cheap check that makes no network call
IsAvailable func(ctx context.Context) bool
// Full requirements check with the merged terminal settings, the availability check when unset
CheckRequirements func(ctx context.Context, config map[string]any) (bool, error)
// Lines shown after the backend is picked in setup
SetupInstructions func(ctx context.Context) []string
// Rows the doctor command shows, the availability row when unset
DoctorChecks func(ctx context.Context) []DoctorCheck
// Creates or resumes the environment of a task
CreateEnvironment func(ctx context.Context, opts TerminalOptions) (*TerminalEnvironment, error)
}
Terminal backend a plugin adds, selected by terminal.backend, its environments running the commands of the terminal, code and file tools
type TerminalCommand ¶
type TerminalCommand struct {
Command string
// Directory the command runs in, the directory the session is in
Cwd string
// Seconds the command may run
TimeoutSeconds int
// Text the command reads on its standard input, nil for none
Stdin *string
// Whether the output may be cut to its head and tail while it is read, set only for a command the model sees the output of
BoundedCapture bool
}
One command an environment runs
type TerminalEnvironment ¶
type TerminalEnvironment struct {
// Absolute directory the environment starts in, the home it resolved when it was created with ~
Cwd string
// Directory for scratch files inside the environment, /tmp when empty
TempDir string
// Whether the environment outlives its session
Persistent bool
// Whether the file tools may read and write the files of the environment straight on the machine icebath runs on
UsesHostFilesystem bool
// Directory of the machine mounted into the environment and the path it is mounted at, empty for none
HostCwd string
HostCwdMount string
// Runs one command and returns its output and exit code, stopping the command when ctx ends
Execute func(ctx context.Context, cmd TerminalCommand) (TerminalResult, error)
// Releases the environment, force removing what a persistent one would keep
Cleanup func(ctx context.Context, force bool) error
// Argv on the machine icebath runs on that runs what follows it inside the environment with its input and output open, empty when it cannot now
ExecPrefix func(ctx context.Context, user string, interactive bool) ([]string, error)
// Bytes of a regular file inside the environment, read through Execute when unset
FetchFile func(ctx context.Context, path string, maxBytes int) ([]byte, error)
// Path a file of the environment resolves to, read through Execute when unset
FetchRealpath func(ctx context.Context, path string) (string, error)
}
One environment of a terminal backend, the place commands of a task run
type TerminalOptions ¶
type TerminalOptions struct {
// Directory commands start in, ~ when the backend declared that default
Cwd string
// Seconds a command may run when it names no timeout
Timeout int
// Key the environment is reused and persisted under
TaskID string
// Image override of one task, empty for the setting of the backend
Image string
// Resource and persistence settings of a backend with a filesystem of its own
ContainerConfig map[string]any
// Directory of the machine the session works in
HostCwd string
// Whether the environment is created only to check that it can be
ProbeOnly bool
}
What icebath asks an environment to be created with
type TerminalResult ¶
type TerminalResult struct {
// Standard output and standard error merged
Output string
ExitCode int
// Directory the session is in after the command, empty to keep the one it ran in
Cwd string
// Whether the environment stopped the command at its timeout
TimedOut bool
}
Outcome of one command
type Tool ¶
type Tool struct {
Name string
Toolset string
Description string
Emoji string
Schema map[string]any
RequiresEnv []string
Override bool
Check func(ctx context.Context) bool
Handler func(ctx context.Context, call ToolCall) (string, error)
}
One tool the model can call
type ToolPreview ¶
Preview of one tool call a tool progress line shows
type ToolSendRequest ¶
type ToolSendRequest struct {
Args map[string]any
ChatID string
Platform string
Config map[string]any
}
Send the send_message tool asks of a platform without a running adapter
type VaultItem ¶
type VaultItem struct {
// Handle of the item, starting with the backend name and a colon
ID string
// One of login, payment or address
Kind string
Label string
// Site the item belongs to, empty for none
Origin string
CreatedAt string
// What the identifier is, such as username or email, empty for none
IdentifierType string
Identifier string
HasOTP bool
AllowedOrigins []string
}
Metadata of one saved item a login backend lists, secrets excluded
type WarningRequest ¶
type WarningRequest struct {
ChatID string
Content string
// Text a surface that hides warnings shows in place of Content
Hidden string
ReplyTo string
Caption string
Metadata map[string]any
ShownMetadata map[string]any
LogicalPlatform string
}
Warning a platform shows the user, LogicalPlatform naming the surface it renders on
type Widget ¶
type Widget struct {
ID string
Help string
Usage string
Mode string
Zone string
Width int
// Interval the terminal UI refreshes the widget at, running Tick when set and rendering again, zero for input only
Refresh time.Duration
Open func(ctx context.Context, arg string) (state any, ok bool, err error)
Input func(ctx context.Context, state any, in WidgetInput) (next any, open bool, err error)
// Next state at each refresh, nil for a widget that only renders again
Tick func(ctx context.Context, state any) (next any, err error)
Render func(ctx context.Context, frame WidgetFrame) (WidgetView, error)
}
Named view the terminal UI renders, its state a JSON value the UI holds between calls
type WidgetFrame ¶
Size and state a widget renders for
type WidgetInput ¶
type WidgetInput struct {
Text string `json:"text"`
Key string `json:"key"`
Ctrl bool `json:"ctrl"`
Alt bool `json:"alt"`
Shift bool `json:"shift"`
}
One key press or text input delivered to a widget
type WidgetSpan ¶
type WidgetSpan struct {
Text string `json:"text"`
Role string `json:"role,omitempty"`
Bold bool `json:"bold,omitempty"`
Dim bool `json:"dim,omitempty"`
Italic bool `json:"italic,omitempty"`
Underline bool `json:"underline,omitempty"`
Inverse bool `json:"inverse,omitempty"`
}
Run of text in one theme role and style
type WidgetView ¶
type WidgetView struct {
Lines []WidgetLine `json:"lines"`
}
Rendered lines of a widget