gateway

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWorkspaceID = "default"

Variables

This section is empty.

Functions

func NormalizeWorkspaceID

func NormalizeWorkspaceID(workspaceID string) string

Types

type AgentExecutor

type AgentExecutor interface {
	Info() AgentInfo
	Execute(ctx context.Context, req ExecuteRequest) (string, error)
}

type AgentInfo

type AgentInfo struct {
	Name               string   `json:"name"`
	Description        string   `json:"description,omitempty"`
	Enabled            bool     `json:"enabled"`
	Kind               string   `json:"kind,omitempty"`
	Source             string   `json:"source,omitempty"`
	Entry              string   `json:"entry,omitempty"`
	PolicyMode         string   `json:"policy_mode"`
	ToolsAllow         []string `json:"tools_allow,omitempty"`
	ToolsAllowCount    int      `json:"tools_allow_count"`
	ToolsDeny          []string `json:"tools_deny,omitempty"`
	ToolsDenyCount     int      `json:"tools_deny_count"`
	ToolsRiskMax       string   `json:"tools_risk_max,omitempty"`
	ToolsAllowGroups   []string `json:"tools_allow_groups,omitempty"`
	ToolsAllowPatterns []string `json:"tools_allow_patterns,omitempty"`
	SessionRoutingMode string   `json:"session_routing_mode,omitempty"`
	SessionFixedID     string   `json:"session_fixed_id,omitempty"`
}

type BrowserProfile

type BrowserProfile struct {
	Name               string `json:"name"`
	Driver             string `json:"driver"`
	Default            bool   `json:"default"`
	Running            bool   `json:"running"`
	ExtensionConnected bool   `json:"extension_connected,omitempty"`
}

type BrowserState

type BrowserState struct {
	Running            bool   `json:"running"`
	Profile            string `json:"profile,omitempty"`
	Driver             string `json:"driver,omitempty"`
	CurrentURL         string `json:"current_url,omitempty"`
	LastSnapshot       string `json:"last_snapshot,omitempty"`
	LastAction         string `json:"last_action,omitempty"`
	LastScreenshot     string `json:"last_screenshot,omitempty"`
	ExtensionConnected bool   `json:"extension_connected,omitempty"`
	AttachedTabs       int    `json:"attached_tabs,omitempty"`
	LastError          string `json:"last_error,omitempty"`
}

type ChannelMessage

type ChannelMessage struct {
	ID          string         `json:"id"`
	WorkspaceID string         `json:"-"`
	ChannelID   string         `json:"channel_id"`
	ThreadID    string         `json:"thread_id,omitempty"`
	Direction   string         `json:"direction"`
	Source      string         `json:"source"`
	Text        string         `json:"text"`
	Payload     map[string]any `json:"payload,omitempty"`
	Timestamp   string         `json:"timestamp"`
}

type CommandExecutor

type CommandExecutor struct {
	// contains filtered or unexported fields
}

func NewCommandExecutor

func NewCommandExecutor(opts CommandExecutorOptions) (*CommandExecutor, error)

func (*CommandExecutor) Execute

func (e *CommandExecutor) Execute(ctx context.Context, req ExecuteRequest) (string, error)

func (*CommandExecutor) Info

func (e *CommandExecutor) Info() AgentInfo

type CommandExecutorOptions

type CommandExecutorOptions struct {
	Name        string
	Description string
	Source      string
	Entry       string
	Command     string
	Args        []string
	Env         map[string]string
	WorkDir     string
	Timeout     time.Duration
}

type ExecuteRequest

type ExecuteRequest struct {
	RunID        string
	WorkspaceID  string
	SessionID    string
	ProjectID    string
	Prompt       string
	AllowedTools []string
}

type GatewayStatus

type GatewayStatus struct {
	Enabled                    bool         `json:"enabled"`
	Version                    int64        `json:"version"`
	RunsTotal                  int          `json:"runs_total"`
	RunsActive                 int          `json:"runs_active"`
	AgentsCount                int          `json:"agents_count"`
	AgentsWatchEnabled         bool         `json:"agents_watch_enabled"`
	AgentsReloadVersion        int64        `json:"agents_reload_version"`
	AgentsLastReloadAt         string       `json:"agents_last_reload_at,omitempty"`
	ChannelsLocal              bool         `json:"channels_local_enabled"`
	ChannelsWebhook            bool         `json:"channels_webhook_enabled"`
	ChannelsTelegram           bool         `json:"channels_telegram_enabled"`
	PersistenceEnabled         bool         `json:"persistence_enabled"`
	RunsPersistenceEnabled     bool         `json:"runs_persistence_enabled"`
	ChannelsPersistenceEnabled bool         `json:"channels_persistence_enabled"`
	RestoreOnStartup           bool         `json:"restore_on_startup"`
	PersistenceDir             string       `json:"persistence_dir,omitempty"`
	RunsRestored               int          `json:"runs_restored"`
	ChannelsRestored           int          `json:"channels_restored"`
	LastPersistAt              string       `json:"last_persist_at,omitempty"`
	LastRestoreAt              string       `json:"last_restore_at,omitempty"`
	LastRestoreError           string       `json:"last_restore_error,omitempty"`
	LastReloadAt               string       `json:"last_reload_at,omitempty"`
	LastRestartAt              string       `json:"last_restart_at,omitempty"`
	Browser                    BrowserState `json:"browser"`
	Nodes                      []NodeInfo   `json:"nodes"`
}

type NodeInfo

type NodeInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

type ProjectTaskRunner added in v0.3.0

type ProjectTaskRunner struct {
	// contains filtered or unexported fields
}

func NewProjectTaskRunner added in v0.3.0

func NewProjectTaskRunner(runtime projectTaskRuntime, workspaceID string) *ProjectTaskRunner

func (*ProjectTaskRunner) Start added in v0.3.0

func (*ProjectTaskRunner) Wait added in v0.3.0

func (r *ProjectTaskRunner) Wait(ctx context.Context, runID string) (project.TaskRun, error)

type PromptExecutor

type PromptExecutor struct {
	// contains filtered or unexported fields
}

func NewPromptExecutor

func NewPromptExecutor(name, description string, runPrompt func(ctx context.Context, runLabel string, prompt string) (string, error)) (*PromptExecutor, error)

func NewPromptExecutorWithOptions

func NewPromptExecutorWithOptions(opts PromptExecutorOptions) (*PromptExecutor, error)

func (*PromptExecutor) Execute

func (e *PromptExecutor) Execute(ctx context.Context, req ExecuteRequest) (string, error)

func (*PromptExecutor) Info

func (e *PromptExecutor) Info() AgentInfo

type PromptExecutorOptions

type PromptExecutorOptions struct {
	Name               string
	Description        string
	Source             string
	Entry              string
	PolicyMode         string
	ToolsAllow         []string
	ToolsDeny          []string
	ToolsRiskMax       string
	ToolsAllowGroups   []string
	ToolsAllowPatterns []string
	SessionRoutingMode string
	SessionFixedID     string
	RunPrompt          func(ctx context.Context, runLabel string, prompt string, allowedTools []string) (string, error)
}

type ReportChannels

type ReportChannels struct {
	GeneratedAt    string                      `json:"generated_at"`
	ArchiveEnabled bool                        `json:"archive_enabled"`
	Count          int                         `json:"count"`
	Messages       map[string][]ChannelMessage `json:"messages"`
}

type ReportRuns

type ReportRuns struct {
	GeneratedAt    string `json:"generated_at"`
	ArchiveEnabled bool   `json:"archive_enabled"`
	Count          int    `json:"count"`
	Runs           []Run  `json:"runs"`
}

type ReportSummary

type ReportSummary struct {
	GeneratedAt      string         `json:"generated_at"`
	SummaryEnabled   bool           `json:"summary_enabled"`
	ArchiveEnabled   bool           `json:"archive_enabled"`
	RunsTotal        int            `json:"runs_total"`
	RunsActive       int            `json:"runs_active"`
	RunsByStatus     map[string]int `json:"runs_by_status"`
	ChannelsTotal    int            `json:"channels_total"`
	MessagesTotal    int            `json:"messages_total"`
	MessagesBySource map[string]int `json:"messages_by_source"`
}

type Run

type Run struct {
	ID                 string    `json:"run_id"`
	WorkspaceID        string    `json:"-"`
	SessionID          string    `json:"session_id,omitempty"`
	ProjectID          string    `json:"project_id,omitempty"`
	Agent              string    `json:"agent,omitempty"`
	Prompt             string    `json:"prompt,omitempty"`
	Status             RunStatus `json:"status"`
	Accepted           bool      `json:"accepted"`
	Response           string    `json:"response,omitempty"`
	Error              string    `json:"error,omitempty"`
	DiagnosticCode     string    `json:"diagnostic_code,omitempty"`
	DiagnosticReason   string    `json:"diagnostic_reason,omitempty"`
	PolicyBlockedTool  string    `json:"policy_blocked_tool,omitempty"`
	PolicyAllowedTools []string  `json:"policy_allowed_tools,omitempty"`
	PolicyDeniedTools  []string  `json:"policy_denied_tools,omitempty"`
	PolicyRiskMax      string    `json:"policy_risk_max,omitempty"`
	CreatedAt          string    `json:"created_at"`
	StartedAt          string    `json:"started_at,omitempty"`
	CompletedAt        string    `json:"completed_at,omitempty"`
	UpdatedAt          string    `json:"updated_at"`
}

type RunStatus

type RunStatus string
const (
	RunStatusAccepted  RunStatus = "accepted"
	RunStatusRunning   RunStatus = "running"
	RunStatusCompleted RunStatus = "completed"
	RunStatusFailed    RunStatus = "failed"
	RunStatusCanceled  RunStatus = "canceled"
)

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

func NewRuntime

func NewRuntime(opts RuntimeOptions) *Runtime

func (*Runtime) Agents

func (r *Runtime) Agents() []map[string]any

func (*Runtime) BrowserAct

func (r *Runtime) BrowserAct(action string, target string, value string) (BrowserState, error)

func (*Runtime) BrowserCheck

func (r *Runtime) BrowserCheck(ctx context.Context, siteID string, profile string) (browser.CheckResult, error)

func (*Runtime) BrowserLogin

func (r *Runtime) BrowserLogin(ctx context.Context, siteID string, profile string) (browser.LoginResult, error)

func (*Runtime) BrowserOpen

func (r *Runtime) BrowserOpen(url string) (BrowserState, error)

func (*Runtime) BrowserProfiles

func (r *Runtime) BrowserProfiles() []BrowserProfile

func (*Runtime) BrowserRun

func (r *Runtime) BrowserRun(ctx context.Context, siteID string, flowAction string, profile string) (browser.RunResult, error)

func (*Runtime) BrowserScreenshot

func (r *Runtime) BrowserScreenshot(name string) (BrowserState, error)

func (*Runtime) BrowserSnapshot

func (r *Runtime) BrowserSnapshot() (BrowserState, error)

func (*Runtime) BrowserStart

func (r *Runtime) BrowserStart() BrowserState

func (*Runtime) BrowserStartWithProfile

func (r *Runtime) BrowserStartWithProfile(profile string) BrowserState

func (*Runtime) BrowserStatus

func (r *Runtime) BrowserStatus() BrowserState

func (*Runtime) BrowserStop

func (r *Runtime) BrowserStop() BrowserState

func (*Runtime) Cancel

func (r *Runtime) Cancel(runID string) (Run, error)

func (*Runtime) CancelByWorkspace

func (r *Runtime) CancelByWorkspace(workspaceID, runID string) (Run, error)

func (*Runtime) Close

func (r *Runtime) Close(ctx context.Context) error

func (*Runtime) Enabled

func (r *Runtime) Enabled() bool

func (*Runtime) Get

func (r *Runtime) Get(runID string) (Run, bool)

func (*Runtime) GetByWorkspace

func (r *Runtime) GetByWorkspace(workspaceID, runID string) (Run, bool)

func (*Runtime) GetOrZero

func (r *Runtime) GetOrZero(runID string) Run

func (*Runtime) InboundTelegram

func (r *Runtime) InboundTelegram(botID, threadID, text string, payload map[string]any) (ChannelMessage, error)

func (*Runtime) InboundTelegramByWorkspace

func (r *Runtime) InboundTelegramByWorkspace(workspaceID, botID, threadID, text string, payload map[string]any) (ChannelMessage, error)

func (*Runtime) InboundWebhook

func (r *Runtime) InboundWebhook(channelID, threadID, text string, payload map[string]any) (ChannelMessage, error)

func (*Runtime) InboundWebhookByWorkspace

func (r *Runtime) InboundWebhookByWorkspace(workspaceID, channelID, threadID, text string, payload map[string]any) (ChannelMessage, error)

func (*Runtime) List

func (r *Runtime) List(limit int) []Run

func (*Runtime) ListByWorkspace

func (r *Runtime) ListByWorkspace(workspaceID string, limit int) []Run

func (*Runtime) MessageRead

func (r *Runtime) MessageRead(channelID string, limit int) ([]ChannelMessage, error)

func (*Runtime) MessageReadByWorkspace

func (r *Runtime) MessageReadByWorkspace(workspaceID, channelID string, limit int) ([]ChannelMessage, error)

func (*Runtime) MessageSend

func (r *Runtime) MessageSend(channelID, threadID, text string) (ChannelMessage, error)

func (*Runtime) MessageSendByWorkspace

func (r *Runtime) MessageSendByWorkspace(workspaceID, channelID, threadID, text string) (ChannelMessage, error)

func (*Runtime) NodeDescribe

func (r *Runtime) NodeDescribe(name string) (NodeInfo, error)

func (*Runtime) NodeInvoke

func (r *Runtime) NodeInvoke(name string, args map[string]any) (map[string]any, error)

func (*Runtime) Nodes

func (r *Runtime) Nodes() []NodeInfo

func (*Runtime) OutboundTelegram

func (r *Runtime) OutboundTelegram(botID, chatID, threadID, text string, payload map[string]any) (ChannelMessage, error)

func (*Runtime) OutboundTelegramByWorkspace

func (r *Runtime) OutboundTelegramByWorkspace(workspaceID, botID, chatID, threadID, text string, payload map[string]any) (ChannelMessage, error)

func (*Runtime) Reload

func (r *Runtime) Reload() GatewayStatus

func (*Runtime) ReportsChannels

func (r *Runtime) ReportsChannels(limit int) (ReportChannels, error)

func (*Runtime) ReportsChannelsByWorkspace

func (r *Runtime) ReportsChannelsByWorkspace(workspaceID string, limit int) (ReportChannels, error)

func (*Runtime) ReportsRuns

func (r *Runtime) ReportsRuns(limit int) (ReportRuns, error)

func (*Runtime) ReportsRunsByWorkspace

func (r *Runtime) ReportsRunsByWorkspace(workspaceID string, limit int) (ReportRuns, error)

func (*Runtime) ReportsSummary

func (r *Runtime) ReportsSummary() (ReportSummary, error)

func (*Runtime) ReportsSummaryByWorkspace

func (r *Runtime) ReportsSummaryByWorkspace(workspaceID string) (ReportSummary, error)

func (*Runtime) Restart

func (r *Runtime) Restart() GatewayStatus

func (*Runtime) SetAgentsWatchEnabled

func (r *Runtime) SetAgentsWatchEnabled(enabled bool)

func (*Runtime) SetExecutors

func (r *Runtime) SetExecutors(executors []AgentExecutor, defaultAgent string)

func (*Runtime) Spawn

func (r *Runtime) Spawn(ctx context.Context, req SpawnRequest) (Run, error)

func (*Runtime) Status

func (r *Runtime) Status() GatewayStatus

func (*Runtime) ThreadReply

func (r *Runtime) ThreadReply(channelID, threadID, text string) (ChannelMessage, error)

func (*Runtime) ThreadReplyByWorkspace

func (r *Runtime) ThreadReplyByWorkspace(workspaceID, channelID, threadID, text string) (ChannelMessage, error)

func (*Runtime) Wait

func (r *Runtime) Wait(ctx context.Context, runID string) (Run, error)

type RuntimeOptions

type RuntimeOptions struct {
	Enabled                              bool
	WorkspaceDir                         string
	SessionStore                         *session.Store
	SessionStoreForWorkspace             func(workspaceID string) *session.Store
	RunPrompt                            func(ctx context.Context, runLabel string, prompt string) (string, error)
	Executors                            []AgentExecutor
	DefaultAgent                         string
	GatewayAgentsWatchEnabled            bool
	ChannelsLocalEnabled                 bool
	ChannelsWebhookEnabled               bool
	ChannelsTelegramEnabled              bool
	GatewayPersistenceEnabled            bool
	GatewayRunsPersistenceEnabled        bool
	GatewayChannelsPersistenceEnabled    bool
	GatewayRunsMaxRecords                int
	GatewayChannelsMaxMessagesPerChannel int
	GatewayPersistenceDir                string
	GatewayRestoreOnStartup              bool
	GatewayReportSummaryEnabled          bool
	GatewayArchiveEnabled                bool
	GatewayArchiveDir                    string
	GatewayArchiveRetentionDays          int
	GatewayArchiveMaxFileBytes           int
	BrowserDefaultProfile                string
	BrowserManagedHeadless               bool
	BrowserManagedExecutablePath         string
	BrowserManagedUserDataDir            string
	BrowserSiteFlowsDir                  string
	BrowserAutoLoginSiteAllowlist        []string
	BrowserVaultReader                   browser.SecretReader
	BrowserService                       *browser.Service
	Now                                  func() time.Time
}

type SpawnRequest

type SpawnRequest struct {
	WorkspaceID string
	SessionID   string
	ProjectID   string
	Title       string
	Prompt      string
	Agent       string
}

Jump to

Keyboard shortcuts

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