backend

package
v0.2.47 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 79 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	GoalStatusActive          = "active"
	GoalStatusProgress        = "progress"
	GoalStatusComplete        = "complete"
	GoalStatusBlocked         = "blocked"
	GoalStatusStopped         = "stopped"
	GoalStatusBudgetExhausted = "budget_exhausted"
)

Variables

View Source
var (
	ErrInvalidRevertMessage = errors.New("invalid revert message ID")
	ErrRevertMessageGone    = errors.New("revert message is no longer in the session")
)
View Source
var (
	ErrNotChat     = errors.New("only Web chats and Slack threads can be deleted")
	ErrSessionBusy = errors.New("this session has a running turn, queued or stashed work, a Background Job, or a scheduled message; stop or clear it first")
)
View Source
var ErrRemoteSession = errors.New("a remote OpenCode session's history stays on its server")
View Source
var ErrRestartRequested = errors.New("restart requested")
View Source
var ErrSpaceRejected = errors.New("another space has that name, or it is the last space")
View Source
var ErrTagNotAllowed = errors.New("the session's agent does not allow this tag")

Functions

func AddOpenCodeSessionBridge added in v0.2.44

func AddOpenCodeSessionBridge(ctx context.Context, cfg *config.LockedConfig, name, session string) error

func AgentDraftTemplates added in v0.2.41

func AgentDraftTemplates() []string

func AgentTags added in v0.1.47

func AgentTags(agents harness.Agents) map[string][]string

func CronStem added in v0.2.31

func CronStem(path string) string

func DecideOrigin added in v0.1.27

func DecideOrigin(facts *ChatOriginFacts) (origin any, text string)

func EasyUploadDir added in v0.2.20

func EasyUploadDir(cfg *config.Config, conversationID string) string

func ExternalMCPAgentsIn

func ExternalMCPAgentsIn(cfg *config.LockedConfig, runtimeDir string) ([]string, error)

func GenerateHandoff added in v0.1.3

func GenerateHandoff(ctx context.Context, locked *config.LockedConfig, agent, transcript string) (document string, err error)

func GenerateTitle added in v0.2.44

func GenerateTitle(ctx context.Context, cfg *config.Config, request, recent string) (string, error)

func LoadRuntimeDefinitions

func LoadRuntimeDefinitions(cfg *config.LockedConfig, runtimeDir string) (harness.Agents, harness.Skills, error)

func MentionedIDs added in v0.1.27

func MentionedIDs(hits []MessageSearchHit, mentions map[string]string) []string

func PromptPrincipal added in v0.1.40

func PromptPrincipal(header string) string

func ReplayInputMessageRoleText added in v0.1.0

func ReplayInputMessageRoleText(item *responses.ResponseInputItemUnionParam, raw json.RawMessage) (role, text string, ok bool, err error)

func Run

func Run(ctx context.Context, cfg *config.Config, logger *slog.Logger, logLevel *slog.LevelVar, assemble FrontendAssembler, sandboxes sandboxPreparer) error

func SetLogLevel added in v0.2.41

func SetLogLevel(level *slog.LevelVar, text string)

func TabConversation added in v0.2.9

func TabConversation(path string) string

func TestModel added in v0.2.41

func TestModel(ctx context.Context, cfg *config.Config, ref string) (time.Duration, error)

Types

type AgentDraft added in v0.2.41

type AgentDraft struct {
	ID          string                `json:"-"`
	Revision    int64                 `json:"-"`
	Name        string                `json:"name"`
	Mode        harness.AgentMode     `json:"mode"`
	Variants    []AgentDraftVariant   `json:"variants"`
	ExternalMCP AgentDraftExternalMCP `json:"externalMcp,omitzero"`
	TestChat    string                `json:"testChat,omitempty"`
	SaveState   AgentDraftSaveState   `json:"saveState"`
	Bases       map[string]*string    `json:"bases"`
	Pending     *AgentDraftPending    `json:"pending,omitempty"`
}

type AgentDraftAsk added in v0.2.41

type AgentDraftAsk struct {
	Request, Answer, Variant, Transcript string
}

type AgentDraftExternalMCP added in v0.2.41

type AgentDraftExternalMCP struct {
	On       bool              `json:"on,omitempty"`
	Caller   string            `json:"caller,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type AgentDraftLayers added in v0.2.41

type AgentDraftLayers struct {
	Layers                   []AgentLayer
	HiddenBy, Replaces       string
	Recreated                bool
	Next, Branch, Unpushable string
}

type AgentDraftMessage added in v0.2.41

type AgentDraftMessage struct {
	InputID     string                `json:"-"`
	Text        string                `json:"text"`
	Labels      map[string]int64      `json:"labels"`
	Live        string                `json:"live,omitempty"`
	NotRun      []AgentDraftProblem   `json:"notRun,omitempty"`
	ExternalMCP AgentDraftExternalMCP `json:"externalMcp"`
}

type AgentDraftNameError added in v0.2.41

type AgentDraftNameError struct{ Name string }

func (*AgentDraftNameError) Error added in v0.2.41

func (e *AgentDraftNameError) Error() string

type AgentDraftNotValidError added in v0.2.41

type AgentDraftNotValidError struct{ Line int }

func (*AgentDraftNotValidError) Error added in v0.2.41

func (e *AgentDraftNotValidError) Error() string

type AgentDraftOp added in v0.2.41

type AgentDraftOp struct {
	Revision     int64                 `json:"revision,omitempty"`
	At           time.Time             `json:"at,omitzero"`
	BaseRevision int64                 `json:"baseRevision"`
	OpID         string                `json:"opId"`
	Author       string                `json:"author"`
	Kind         AgentDraftOpKind      `json:"kind"`
	Variant      string                `json:"variant,omitempty"`
	Key          string                `json:"key,omitempty"`
	Value        string                `json:"value,omitempty"`
	Splices      []AgentDraftSplice    `json:"splices,omitempty"`
	ExternalMCP  AgentDraftExternalMCP `json:"externalMcp,omitzero"`
	From         int64                 `json:"from,omitempty"`
	FromFile     string                `json:"fromFile,omitempty"`
	Bases        map[string]*string    `json:"bases,omitempty"`
}

type AgentDraftOpError added in v0.2.41

type AgentDraftOpError struct{ Problem string }

func (*AgentDraftOpError) Error added in v0.2.41

func (e *AgentDraftOpError) Error() string

type AgentDraftOpKind added in v0.2.41

type AgentDraftOpKind string
const (
	AgentDraftCreate         AgentDraftOpKind = "create"
	AgentDraftSetField       AgentDraftOpKind = "set_field"
	AgentDraftEditBody       AgentDraftOpKind = "edit_body"
	AgentDraftAddVariant     AgentDraftOpKind = "add_variant"
	AgentDraftRenameVariant  AgentDraftOpKind = "rename_variant"
	AgentDraftRemoveVariant  AgentDraftOpKind = "remove_variant"
	AgentDraftSetMode        AgentDraftOpKind = "set_mode"
	AgentDraftSetExternalMCP AgentDraftOpKind = "set_external_mcp"
	AgentDraftSetTestChat    AgentDraftOpKind = "set_test_chat"
	AgentDraftSetSaveState   AgentDraftOpKind = "set_save_state"
	AgentDraftRename         AgentDraftOpKind = "rename"
	AgentDraftEditFile       AgentDraftOpKind = "edit_file"
	AgentDraftRestore        AgentDraftOpKind = "restore"
)

type AgentDraftOrigin added in v0.2.41

type AgentDraftOrigin struct {
	Name     string
	Mode     harness.AgentMode
	Template string
	Copy     bool
}

type AgentDraftPending added in v0.2.41

type AgentDraftPending struct {
	Destination string            `json:"destination"`
	Base        string            `json:"base"`
	Branch      string            `json:"branch"`
	Commit      string            `json:"commit"`
	Number      int               `json:"number,omitempty"`
	Link        string            `json:"link,omitempty"`
	File        string            `json:"file"`
	Revision    int64             `json:"revision"`
	Ended       AgentDraftWaitEnd `json:"ended,omitempty"`
}

type AgentDraftPresence added in v0.2.41

type AgentDraftPresence struct {
	Client, Username, Variant, Place string
}

type AgentDraftProblem added in v0.2.41

type AgentDraftProblem struct {
	Variant, Key, Sentence string
}

type AgentDraftProposal added in v0.2.41

type AgentDraftProposal struct {
	ID           string                      `json:"-"`
	BaseRevision int64                       `json:"-"`
	State        AgentDraftProposalState     `json:"-"`
	Message      string                      `json:"message"`
	Settings     []AgentDraftProposedSetting `json:"settings"`
	Bodies       []AgentDraftProposedBody    `json:"bodies"`
}

type AgentDraftProposalState added in v0.2.41

type AgentDraftProposalState string
const (
	AgentDraftProposalOpen     AgentDraftProposalState = "open"
	AgentDraftProposalAccepted AgentDraftProposalState = "accepted"
	AgentDraftProposalRejected AgentDraftProposalState = "rejected"
)

type AgentDraftProposedBody added in v0.2.41

type AgentDraftProposedBody struct {
	Variant string `json:"variant"`
	Body    string `json:"body"`
	Reason  string `json:"reason"`
}

type AgentDraftProposedSetting added in v0.2.41

type AgentDraftProposedSetting struct {
	Variant   string `json:"variant"`
	Key       string `json:"key"`
	ValueYAML string `json:"value_yaml"`
	Reason    string `json:"reason"`
}

type AgentDraftRefusedError added in v0.2.41

type AgentDraftRefusedError struct {
	Problem  string
	Restart  bool
	Problems []AgentDraftProblem
}

func (*AgentDraftRefusedError) Error added in v0.2.41

func (e *AgentDraftRefusedError) Error() string

type AgentDraftReview added in v0.2.41

type AgentDraftReview struct {
	Revision   int64
	Base, Live *string
	Draft      string
	Settings   []AgentDraftReviewSetting
	Splices    []AgentDraftSplice
}

type AgentDraftReviewSetting added in v0.2.41

type AgentDraftReviewSetting struct {
	Key, Base, Live, Draft string
	Theirs, Both           bool
}

type AgentDraftSave added in v0.2.41

type AgentDraftSave struct {
	ID, Variant, Destination, Author string
	Reviewed, PullRequest            bool
	ReviewedFile                     *string
}

type AgentDraftSaveError added in v0.2.41

type AgentDraftSaveError struct {
	Problem  string
	Problems []AgentDraftProblem
	Review   *AgentDraftReview
}

func (*AgentDraftSaveError) Error added in v0.2.41

func (e *AgentDraftSaveError) Error() string

type AgentDraftSaveState added in v0.2.41

type AgentDraftSaveState string
const (
	AgentDraftEditing AgentDraftSaveState = "editing"
	AgentDraftSaving  AgentDraftSaveState = "saving"
	AgentDraftWaiting AgentDraftSaveState = "waiting"
	AgentDraftLive    AgentDraftSaveState = "live"
)

type AgentDraftSend added in v0.2.41

type AgentDraftSend struct {
	ID, Username, Principal string
	Restart, Replay         bool
	Texts                   []string
}

type AgentDraftSetting added in v0.2.41

type AgentDraftSetting struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type AgentDraftSplice added in v0.2.41

type AgentDraftSplice struct {
	At     int    `json:"at"`
	Remove int    `json:"remove,omitzero"`
	Insert string `json:"insert,omitzero"`
}

type AgentDraftVariant added in v0.2.41

type AgentDraftVariant struct {
	Name     string              `json:"name"`
	Settings []AgentDraftSetting `json:"settings"`
	Body     string              `json:"body"`
}

type AgentDraftWaitEnd added in v0.2.41

type AgentDraftWaitEnd string
const (
	AgentDraftWaitClosed  AgentDraftWaitEnd = "closed"
	AgentDraftWaitStopped AgentDraftWaitEnd = "stopped"
	AgentDraftWaitEdited  AgentDraftWaitEnd = "edited"
)

type AgentLayer added in v0.2.41

type AgentLayer struct {
	Layer, Ref string
	File       *string
}

type AgentPausedError added in v0.2.40

type AgentPausedError struct{}

func (AgentPausedError) Error added in v0.2.40

func (AgentPausedError) Error() string

type Attention added in v0.2.31

type Attention struct {
	Path          string
	UnreadAt      time.Time
	Quiet, Parked bool
	Until         time.Time
	UntilDone     bool
	Note          string
}

type AttentionAction added in v0.2.31

type AttentionAction string
const (
	AttentionRead          AttentionAction = "read"
	AttentionUnread        AttentionAction = "unread"
	AttentionPark          AttentionAction = "park"
	AttentionParkUntilDone AttentionAction = "park_done"
	AttentionUnpark        AttentionAction = "unpark"
	AttentionAutoPark      AttentionAction = "auto_park"
	AttentionNoAutoPark    AttentionAction = "no_auto_park"
	AttentionSent          AttentionAction = "sent"
)

type Bridge

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

func NewConversation

func NewConversation(cfg *config.LockedConfig, publisher protocol.OutboundPublisher, bridgeCfg *Config, logger *slog.Logger) *Bridge

func (*Bridge) AppendChildEntry added in v0.1.44

func (b *Bridge) AppendChildEntry(ctx context.Context, key harness.ChildKey, entry *harness.SessionEntry) error

func (*Bridge) AwaitSubagent added in v0.1.44

func (b *Bridge) AwaitSubagent(ctx context.Context, key, callKey string) (string, harness.ReplayAttribution, error)

func (*Bridge) Drain added in v0.1.33

func (b *Bridge) Drain(ctx context.Context, responseID string, phase harness.TurnPhase, applied []string) ([]harness.PromptInput, error)

func (*Bridge) InterruptActiveTurn

func (b *Bridge) InterruptActiveTurn() *protocol.InboundMessage

func (*Bridge) PickLaterWork

func (b *Bridge) PickLaterWork(ctx context.Context) error

func (*Bridge) ResetScheduledMessages

func (b *Bridge) ResetScheduledMessages(origin *protocol.InboundMessage) error

func (*Bridge) Run added in v0.1.14

func (b *Bridge) Run(ctx context.Context) error

func (*Bridge) ScheduleMessage

func (b *Bridge) ScheduleMessage(origin *protocol.InboundMessage, delay time.Duration, message string, recurring bool) error

func (*Bridge) Stop

func (b *Bridge) Stop()

func (*Bridge) Submit

func (b *Bridge) Submit(ctx context.Context, msg *protocol.InboundMessage) error

func (*Bridge) SwitchAgent

func (b *Bridge) SwitchAgent(agent string)

func (*Bridge) WriteSubagent added in v0.1.44

func (b *Bridge) WriteSubagent(ctx context.Context, write *harness.SubagentWrite) (bool, error)

type ChatOriginFacts added in v0.1.14

type ChatOriginFacts struct {
	ConversationID         string
	CreatedBy              ThreadCreator
	ExternalConversationID string
	Binding                ExternalMCPSessionState
	CreatingSource         string
	ProducerAgent          string
	Run                    *protocol.CronRun
}

type Config

type Config struct {
	ConversationID, Agent string
	RequestRestart        runtimeRestarter
	RequestReload         runtimeReloader
	UserQuestionAsker     protocol.UserQuestionAsker
	SessionService        *SessionService
	Secrets               config.SecretFetcher
}

type ConversationKind added in v0.2.0

type ConversationKind string
const (
	KindWebChat        ConversationKind = "web_chat"
	KindSlackThread    ConversationKind = "slack_thread"
	KindCronRun        ConversationKind = "cron_run"
	KindOneOffCronRun  ConversationKind = "one_off_cron_run"
	KindExternalMCPRun ConversationKind = "external_mcp_run"
	KindSubagent       ConversationKind = "subagent"
	KindReview         ConversationKind = "review"
	KindShadow         ConversationKind = "shadow"
	KindRemote         ConversationKind = "remote"
	KindAgentDraft     ConversationKind = "agent_draft"
)

type CronRunSource added in v0.1.27

type CronRunSource struct {
	ConversationID       string
	SourceConversationID string
	Run                  protocol.CronRun
}

type CronScheduleState

type CronScheduleState struct {
	ScheduleID   string
	RelativePath string
	NextDue      time.Time
}

type Delegation added in v0.2.0

type Delegation struct {
	ID, Parent, CallID string
	Legacy             bool
	Kind               ConversationKind
}

type ExternalMCPSessionState

type ExternalMCPSessionState struct {
	Agent                 string            `json:"agent,omitempty"`
	PrivateConversationID string            `json:"private_conversation_id,omitempty"`
	ManagedConversationID string            `json:"managed_conversation_id,omitempty"`
	OriginPairs           map[string]string `json:"origin_pairs,omitempty"`
}

type FrontendAssembler added in v0.1.0

type FrontendAssembler interface {
	Assemble(*Runtime) (<-chan struct{}, []func(context.Context) error, error)
	ValidateAssets(*config.Config, string) error
}

type GoalState

type GoalState struct {
	Objective      string    `json:"objective,omitempty"`
	MaxTurns       int       `json:"max_turns,omitempty"`
	TurnsUsed      int       `json:"turns_used,omitempty"`
	Status         string    `json:"status,omitempty"`
	Note           string    `json:"note,omitempty"`
	CreatedAt      time.Time `json:"created_at,omitzero"`
	UpdatedAt      time.Time `json:"updated_at,omitzero"`
	PrincipalName  string    `json:"principal_name,omitempty"`
	PrincipalEmail string    `json:"principal_email,omitempty"`
	Origin         string    `json:"origin,omitempty"`
}

type HistoryInventory added in v0.1.17

type HistoryInventory struct {
	ConversationID string            `json:"conversation_id"`
	Source         string            `json:"source"`
	Entries        map[string]string `json:"entries"`
	From           int64             `json:"from,omitempty"`
	Oldest         int64             `json:"oldest,omitempty"`
	Marker         string            `json:"revert_message_id,omitempty"`
	Shadows        string            `json:"shadows,omitempty"`
}

type HistorySnapshot added in v0.1.17

type HistorySnapshot struct {
	Inventory   HistoryInventory
	Entries     []ObservedSessionEntry
	Delegations []Delegation
	Lineage     []SidebarSession
	Reviews     []string
	Shadows     []protocol.ShadowBinding
	Eligible    bool
	Predecessor string
	Floor       string
	Reset       bool
}

type KeyedConversationLocks

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

func NewKeyedConversationLocks

func NewKeyedConversationLocks() *KeyedConversationLocks

func (*KeyedConversationLocks) Lock

func (l *KeyedConversationLocks) Lock(key string) func()

type MessageSearchHit added in v0.1.24

type MessageSearchHit struct {
	ConversationID, Role, Text string
	MessageID                  string
}

type ObservedSessionEntry

type ObservedSessionEntry struct {
	ID                   int64
	Entry                harness.SessionEntry
	Key                  string
	Revision             string
	SourceConversationID string
	Synced               bool
	Active               bool
	Terminal             protocol.Terminal
}

type Page added in v0.1.52

type Page struct {
	Agent        string
	Kind         PageKind
	Name         string
	ContentType  string
	Body         []byte
	Size         int
	UpdatedAt    time.Time
	Conversation string
	Space        string
}

type PageKind added in v0.1.52

type PageKind string
const (
	PageFile PageKind = "file"
	PageData PageKind = "data"
)

type PruneStateStats

type PruneStateStats struct {
	Threads, ExternalMCPSessions int
	SessionRows                  int64
}

type QuestionNotPendingError added in v0.1.27

type QuestionNotPendingError struct{ ConversationID, QuestionID string }

func (*QuestionNotPendingError) Error added in v0.1.27

func (e *QuestionNotPendingError) Error() string

type RawRunProgress

type RawRunProgress struct {
	ConversationID  string
	Run             *protocol.CronRun
	SyncDestination string
	Cronjob         *protocol.CronjobMessage
}

type Runtime

type Runtime struct {
	Cfg *config.LockedConfig
	Log *slog.Logger

	RunCtx            context.Context
	Sessions          *SessionService
	ExternalMCPAgents runtimeRefresher
	CronJobs          runtimeRefresher
	Assemble          FrontendAssembler

	TextRouter protocol.PrimaryTextRouter
	// contains filtered or unexported fields
}

func (*Runtime) AgentPaused added in v0.2.40

func (r *Runtime) AgentPaused(ctx context.Context, conversationID string) (bool, error)

func (*Runtime) AnswerQuestion added in v0.1.27

func (r *Runtime) AnswerQuestion(ctx context.Context, conversationID, questionID string, answer protocol.AskUserQuestionAnswer) error

func (*Runtime) AttachSlack

func (r *Runtime) AttachSlack(slack slackLookup)

func (*Runtime) BackgroundJobs added in v0.1.19

func (r *Runtime) BackgroundJobs(ctx context.Context, conversationID string) ([]protocol.BackgroundJob, bool, error)

func (*Runtime) ClearRevert added in v0.1.17

func (r *Runtime) ClearRevert(ctx context.Context, conversationID string) error

func (*Runtime) CompletionNotes added in v0.1.19

func (r *Runtime) CompletionNotes(ctx context.Context, history string, jobIDs []string) ([]protocol.BackgroundJob, error)

func (*Runtime) ContinueRun added in v0.2.0

func (r *Runtime) ContinueRun(ctx context.Context, run, conversationID string, shared bool) (string, error)

func (*Runtime) CreateConversation added in v0.1.0

func (r *Runtime) CreateConversation(ctx context.Context, conversation protocol.Conversation) error

func (*Runtime) DeleteQueueItem added in v0.1.0

func (r *Runtime) DeleteQueueItem(ctx context.Context, conversationID, id string) (bool, error)

func (*Runtime) EditQueueItem added in v0.1.63

func (r *Runtime) EditQueueItem(ctx context.Context, conversationID, id, text string) (bool, error)

func (*Runtime) MoveToBackground added in v0.1.19

func (r *Runtime) MoveToBackground(ctx context.Context, conversationID string) (bool, error)

func (*Runtime) OpenCodeMCP added in v0.2.11

func (r *Runtime) OpenCodeMCP() http.Handler

func (*Runtime) PendingQuestions added in v0.1.27

func (r *Runtime) PendingQuestions(ctx context.Context, conversationID string) ([]protocol.AskUserQuestionRequest, error)

func (*Runtime) PopQueueItem added in v0.1.0

func (r *Runtime) PopQueueItem(ctx context.Context, conversationID, id string) (bool, error)

func (*Runtime) PostPausedMessage added in v0.2.40

func (r *Runtime) PostPausedMessage(ctx context.Context, inbound *protocol.InboundMessage) error

func (*Runtime) PromoteQueueItem added in v0.1.0

func (r *Runtime) PromoteQueueItem(ctx context.Context, conversationID, id string) (bool, error)

func (*Runtime) PublishOutbound added in v0.1.0

func (r *Runtime) PublishOutbound(ctx context.Context, message *protocol.OutboundMessage) error

func (*Runtime) QueueItems added in v0.1.0

func (r *Runtime) QueueItems(conversationID string) ([]protocol.ThreadQueueItem, error)

func (*Runtime) Reload

func (r *Runtime) Reload(reason string) (string, error)

func (*Runtime) ReorderQueueItems added in v0.1.0

func (r *Runtime) ReorderQueueItems(conversationID string, ids []string) error

func (*Runtime) RunTurn added in v0.1.0

func (r *Runtime) RunTurn(ctx context.Context, inbound *protocol.InboundMessage) error

func (*Runtime) RunningAgent added in v0.2.26

func (r *Runtime) RunningAgent(conversationID string) string

func (*Runtime) SandboxError added in v0.2.24

func (r *Runtime) SandboxError() string

func (*Runtime) SaveBehavior added in v0.2.41

func (r *Runtime) SaveBehavior(behavior *config.Behavior) error

func (*Runtime) SetAgentPaused added in v0.2.40

func (r *Runtime) SetAgentPaused(ctx context.Context, conversationID, by string, paused bool) error

func (*Runtime) StageRevert added in v0.1.17

func (r *Runtime) StageRevert(ctx context.Context, conversationID, before string) (marker, prompt string, err error)

func (*Runtime) StartGoal added in v0.1.12

func (r *Runtime) StartGoal(ctx context.Context, inbound *protocol.InboundMessage, goal protocol.GoalRequest) error

func (*Runtime) StashQueueItem added in v0.1.0

func (r *Runtime) StashQueueItem(ctx context.Context, conversationID string, item *protocol.ThreadQueueItem) error

func (*Runtime) StopBackgroundJob added in v0.1.19

func (r *Runtime) StopBackgroundJob(ctx context.Context, conversationID, jobID string) (bool, error)

func (*Runtime) Subscribe added in v0.1.0

func (r *Runtime) Subscribe(ctx context.Context) iter.Seq[protocol.Event]

func (*Runtime) SwitchConversationAgent added in v0.1.0

func (r *Runtime) SwitchConversationAgent(conversationID, agent string) (bool, error)

func (*Runtime) ValidateAgentFile added in v0.2.41

func (r *Runtime) ValidateAgentFile(name string, data []byte) error

type SavedSearch added in v0.2.31

type SavedSearch struct {
	ID    string `json:"id,omitempty"`
	Name  string `json:"name,omitempty"`
	Query string `json:"query,omitempty"`
}

type SearchKey added in v0.1.27

type SearchKey string

type SearchPage added in v0.2.31

type SearchPage struct {
	Name     string        `json:"name,omitempty"`
	Active   string        `json:"active,omitempty"`
	Searches []SavedSearch `json:"searches,omitempty"`
}

func (*SearchPage) Scan added in v0.2.31

func (p *SearchPage) Scan(src any) error

type SearchScope added in v0.1.62

type SearchScope int
const (
	SearchFields SearchScope = iota
	SearchMessages
	SearchFilters
)

type SearchTerm added in v0.1.27

type SearchTerm struct {
	Key         SearchKey
	Text, Value string
	Start, End  int
}

type SessionField added in v0.1.27

type SessionField string

type SessionMatch added in v0.1.27

type SessionMatch struct {
	Chat  SidebarChat
	Field SessionField
	Text  string
}

type SessionSearch added in v0.1.27

type SessionSearch struct {
	Terms        []SearchTerm
	Text, Needle string
	Matches      []SessionMatch
	Hits         []MessageSearchHit
	MentionIDs   []string
	Principals   []string
}

type SessionService

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

func NewSessionServiceIn

func NewSessionServiceIn(ctx context.Context, cfg *config.Config, logger *slog.Logger) (*SessionService, error)

func (*SessionService) ActiveGoalThreads

func (s *SessionService) ActiveGoalThreads() (map[string]ThreadState, error)

func (*SessionService) AgentDraftLayers added in v0.2.41

func (s *SessionService) AgentDraftLayers(ctx context.Context, id, variant, destination string) (*AgentDraftLayers, error)

func (*SessionService) AgentDraftMessages added in v0.2.41

func (s *SessionService) AgentDraftMessages(ctx context.Context, chat string) ([]AgentDraftMessage, error)

func (*SessionService) AgentDraftOps added in v0.2.41

func (s *SessionService) AgentDraftOps(ctx context.Context, id string, since int64) ([]AgentDraftOp, error)

func (*SessionService) AgentDraftPresences added in v0.2.41

func (s *SessionService) AgentDraftPresences(ctx context.Context, id string) ([]AgentDraftPresence, error)

func (*SessionService) AgentDraftProposals added in v0.2.41

func (s *SessionService) AgentDraftProposals(ctx context.Context, id string) ([]AgentDraftProposal, error)

func (*SessionService) AppendEntryID

func (s *SessionService) AppendEntryID(ctx context.Context, conversationID string, entry *harness.SessionEntry) (int64, error)

func (*SessionService) ApplyAgentDraftOp added in v0.2.41

func (s *SessionService) ApplyAgentDraftOp(ctx context.Context, id string, op *AgentDraftOp) (int64, error)

func (*SessionService) AttachmentMetadata added in v0.1.0

func (s *SessionService) AttachmentMetadata(ctx context.Context, conversationID, id string, uploadOnly bool) (protocol.OutboundAttachment, error)

func (*SessionService) AutoParkAll added in v0.2.31

func (s *SessionService) AutoParkAll(ctx context.Context, username string) (bool, error)

func (*SessionService) BeginGoal

func (s *SessionService) BeginGoal(conversationID string, goal *GoalState) error

func (*SessionService) ChangeAttention added in v0.2.31

func (s *SessionService) ChangeAttention(ctx context.Context, username string, paths []string, action AttentionAction, until *time.Time) error

func (*SessionService) Changes added in v0.1.12

func (s *SessionService) Changes(ctx context.Context, conversationID string) iter.Seq2[protocol.ConversationChange, error]

func (*SessionService) ChannelFact added in v0.1.0

func (s *SessionService) ChannelFact(ctx context.Context, workspaceID, channelID string) (name string, found bool, err error)

func (*SessionService) ChatOriginFacts added in v0.1.14

func (s *SessionService) ChatOriginFacts(ctx context.Context, id string) iter.Seq2[ChatOriginFacts, error]

func (*SessionService) CheckAgentDraftMerge added in v0.2.41

func (s *SessionService) CheckAgentDraftMerge(ctx context.Context, rt agentDraftRuntime, id, author string) (AgentDraftSaveState, error)

func (*SessionService) ClaimCronSchedule

func (s *SessionService) ClaimCronSchedule(due CronScheduleState, nextDue, now time.Time) (bool, error)

func (*SessionService) ClaimScheduledMessage

func (s *SessionService) ClaimScheduledMessage(id, conversationID string, dueAt, now time.Time) (message protocol.ScheduledMessageState, claimed bool, err error)

func (*SessionService) ClosedTabs added in v0.2.25

func (s *SessionService) ClosedTabs(ctx context.Context, username string) ([]Tab, error)

func (*SessionService) ConversationKind added in v0.2.0

func (s *SessionService) ConversationKind(ctx context.Context, id string) (kind ConversationKind, found bool, err error)

func (*SessionService) CreateAgentDraft added in v0.2.41

func (s *SessionService) CreateAgentDraft(ctx context.Context, author string, origin AgentDraftOrigin) (*AgentDraft, error)

func (*SessionService) CreateLimitSpaces added in v0.2.26

func (s *SessionService) CreateLimitSpaces(ctx context.Context, names []string) error

func (*SessionService) CreateOpenCodeSession added in v0.1.47

func (s *SessionService) CreateOpenCodeSession(ctx context.Context, name string, server config.OpenCodeConfig, directory, spaceID string) (string, error)

func (*SessionService) CreateSpace added in v0.1.53

func (s *SessionService) CreateSpace(ctx context.Context, name string) error

func (*SessionService) CreateStickyConversation added in v0.2.30

func (s *SessionService) CreateStickyConversation(ctx context.Context, conversation protocol.Conversation, sticky harness.AgentSticky) (id string, resumed bool, err error)

func (*SessionService) CronRun added in v0.2.0

func (s *SessionService) CronRun(ctx context.Context, conversationID string) (path string, run bool, err error)

func (*SessionService) CronRunSources added in v0.1.27

func (s *SessionService) CronRunSources(ctx context.Context) ([]CronRunSource, error)

func (*SessionService) DecideAgentDraftProposal added in v0.2.41

func (s *SessionService) DecideAgentDraftProposal(ctx context.Context, id, proposalID, username string, accept bool) (*AgentDraftProposal, error)

func (*SessionService) Delegations added in v0.1.11

func (s *SessionService) Delegations(ctx context.Context, conversationID, sourceConversationID string, from, before int64) ([]Delegation, error)

func (*SessionService) DeleteChat added in v0.2.44

func (s *SessionService) DeleteChat(ctx context.Context, conversationID string) error

func (*SessionService) DeletePage added in v0.1.52

func (s *SessionService) DeletePage(ctx context.Context, agent string, kind PageKind, name string) (bool, error)

func (*SessionService) DeleteSession added in v0.1.0

func (s *SessionService) DeleteSession(ctx context.Context, conversationID string) (int64, error)

func (*SessionService) DeleteSpace added in v0.1.53

func (s *SessionService) DeleteSpace(ctx context.Context, id string) error

func (*SessionService) DeleteThreadQueueItem

func (s *SessionService) DeleteThreadQueueItem(ctx context.Context, conversationID, id string) (removed bool, owner string, err error)

func (*SessionService) DueCronSchedules

func (s *SessionService) DueCronSchedules(now time.Time) ([]CronScheduleState, error)

func (*SessionService) EditSharedSearch added in v0.2.14

func (s *SessionService) EditSharedSearch(ctx context.Context, space, path string, base, search *SearchPage) (bool, error)

func (*SessionService) ExternalMCPSession

func (s *SessionService) ExternalMCPSession(externalConversationID string) (ExternalMCPSessionState, bool, error)

func (*SessionService) ExternalMCPSessionByConversationID

func (s *SessionService) ExternalMCPSessionByConversationID(conversationID string) (externalConversationID string, session ExternalMCPSessionState, ok bool, err error)

func (*SessionService) ForkConversation added in v0.1.3

func (s *SessionService) ForkConversation(ctx context.Context, source string, destination protocol.Conversation, before string) (string, error)

func (*SessionService) ForkOpenCodeSession added in v0.2.8

func (s *SessionService) ForkOpenCodeSession(ctx context.Context, name string, server config.OpenCodeConfig, source, before string) (string, error)

func (*SessionService) Goal

func (s *SessionService) Goal(conversationID string) (GoalState, bool, error)

func (*SessionService) HasActiveTurn added in v0.1.14

func (s *SessionService) HasActiveTurn(ctx context.Context, conversationID string) (bool, error)

func (*SessionService) InputAttachments added in v0.1.24

func (s *SessionService) InputAttachments(ctx context.Context, producer, text string) (string, []protocol.OutboundAttachment, error)

func (*SessionService) ListAgentDrafts added in v0.2.41

func (s *SessionService) ListAgentDrafts(ctx context.Context) ([]AgentDraft, error)

func (*SessionService) LoadAgentDraft added in v0.2.41

func (s *SessionService) LoadAgentDraft(ctx context.Context, id string) (*AgentDraft, error)

func (*SessionService) LoadAttachment added in v0.1.0

func (s *SessionService) LoadAttachment(ctx context.Context, conversationID, id string, uploadOnly bool) (protocol.OutboundAttachment, error)

func (*SessionService) LoadTurnStep added in v0.1.14

func (s *SessionService) LoadTurnStep(ctx context.Context, conversationID, key string) (value json.RawMessage, found bool, err error)

func (*SessionService) MarkSearchFinished added in v0.2.31

func (s *SessionService) MarkSearchFinished(ctx context.Context, username, path string) error

func (*SessionService) ObserveEntries

func (s *SessionService) ObserveEntries(ctx context.Context, conversationID string) ([]ObservedSessionEntry, error)

func (*SessionService) ObserveHistory added in v0.1.17

func (s *SessionService) ObserveHistory(ctx context.Context, id, source string, from, before int64, limit int, prior *HistoryInventory) (view HistorySnapshot, err error)

func (*SessionService) Page added in v0.1.52

func (s *SessionService) Page(ctx context.Context, agent string, kind PageKind, name string) (Page, bool, error)

func (*SessionService) Pages added in v0.1.52

func (s *SessionService) Pages(ctx context.Context, agent string) ([]Page, error)

func (*SessionService) PollAttention added in v0.2.31

func (s *SessionService) PollAttention(ctx context.Context, username, path string, hold bool) (int64, error)

func (*SessionService) ProposeAgentDraftChanges added in v0.2.41

func (s *SessionService) ProposeAgentDraftChanges(ctx context.Context, id, username string, ask *AgentDraftAsk) (_ *AgentDraftProposal, err error)

func (*SessionService) PruneStateBefore

func (s *SessionService) PruneStateBefore(ctx context.Context, cutoff time.Time, pace time.Duration) (PruneStateStats, error)

func (*SessionService) PutPage added in v0.1.52

func (s *SessionService) PutPage(ctx context.Context, page *Page) error

func (*SessionService) PutScheduledMessage

func (s *SessionService) PutScheduledMessage(id string, message *protocol.ScheduledMessageState) error

func (*SessionService) PutThreadQueueItem

func (s *SessionService) PutThreadQueueItem(id string, item *protocol.ThreadQueueItem) error

func (*SessionService) RecordChannelFact added in v0.1.0

func (s *SessionService) RecordChannelFact(ctx context.Context, workspaceID, channelID, name string, observedAt time.Time) error

func (*SessionService) RegisterExternalMCPConversation

func (s *SessionService) RegisterExternalMCPConversation(externalConversationID, managedAgent string, session *ExternalMCPSessionState) error

func (*SessionService) RemoveExternalMCPConversation

func (s *SessionService) RemoveExternalMCPConversation(externalConversationID string) error

func (*SessionService) RenameSpace added in v0.1.53

func (s *SessionService) RenameSpace(ctx context.Context, id, name string) error

func (*SessionService) ReplayAttachments added in v0.1.0

func (s *SessionService) ReplayAttachments(ctx context.Context, conversationID string, root *os.Root, raw json.RawMessage, calls map[string]string) ([]protocol.OutboundAttachment, error)

func (*SessionService) ResetCronSchedules

func (s *SessionService) ResetCronSchedules() error

func (*SessionService) ResetScheduledMessages

func (s *SessionService) ResetScheduledMessages(conversationID string) error

func (*SessionService) RevertAttachmentMetadata added in v0.1.17

func (s *SessionService) RevertAttachmentMetadata(ctx context.Context, conversationID, id string) (protocol.OutboundAttachment, error)

func (*SessionService) RevertState added in v0.1.17

func (s *SessionService) RevertState(ctx context.Context, conversationID string) (marker string, eligible bool, predecessor string, err error)

func (*SessionService) SaveAgentDraft added in v0.2.41

func (s *SessionService) SaveAgentDraft(ctx context.Context, rt agentDraftRuntime, save *AgentDraftSave) (AgentDraftSaveState, error)

func (*SessionService) SaveAttachment added in v0.1.0

func (s *SessionService) SaveAttachment(ctx context.Context, conversationID, turnID string, attachment *protocol.OutboundAttachment, upload bool) error

func (*SessionService) SaveStripLayout added in v0.2.44

func (s *SessionService) SaveStripLayout(ctx context.Context, username string, layout *StripLayout) error

func (*SessionService) SaveTabState added in v0.1.53

func (s *SessionService) SaveTabState(ctx context.Context, username string, state *TabState, revision int64) (bool, error)

func (*SessionService) SaveTurnStep added in v0.1.14

func (s *SessionService) SaveTurnStep(ctx context.Context, conversationID, key string, value json.RawMessage) error

func (*SessionService) ScheduleAgents added in v0.2.40

func (s *SessionService) ScheduleAgents(agents []string)

func (*SessionService) ScheduledMessagesForConversation

func (s *SessionService) ScheduledMessagesForConversation(conversationID string) (map[string]protocol.ScheduledMessageState, error)

func (*SessionService) SearchMessages added in v0.1.24

func (s *SessionService) SearchMessages(ctx context.Context, needle string, tagPrefixes []string) ([]MessageSearchHit, error)

func (*SessionService) SearchMessagesMentioning added in v0.1.27

func (s *SessionService) SearchMessagesMentioning(ctx context.Context, needle string, slack slackLookup) (hits []MessageSearchHit, mentions map[string]string, err error)

func (*SessionService) SearchSessions added in v0.1.27

func (s *SessionService) SearchSessions(ctx context.Context, username, query string, scope SearchScope, slack slackLookup) (*SessionSearch, error)

func (*SessionService) SendAgentDraft added in v0.2.41

func (s *SessionService) SendAgentDraft(ctx context.Context, queue agentDraftQueue, send *AgentDraftSend) (string, []AgentDraftProblem, error)

func (*SessionService) SetAgentDraftPresence added in v0.2.41

func (s *SessionService) SetAgentDraftPresence(ctx context.Context, id string, presence AgentDraftPresence) error

func (*SessionService) SetAutoParkAll added in v0.2.31

func (s *SessionService) SetAutoParkAll(ctx context.Context, username string, on bool) error

func (*SessionService) SetThreadAgentIfExists

func (s *SessionService) SetThreadAgentIfExists(conversationID, agent string) (bool, error)

func (*SessionService) ShadowParent added in v0.1.33

func (s *SessionService) ShadowParent(ctx context.Context, id string) (string, error)

func (*SessionService) ShareTab added in v0.2.9

func (s *SessionService) ShareTab(ctx context.Context, space, path string, search *SearchPage) error

func (*SessionService) SharedTabs added in v0.2.9

func (s *SessionService) SharedTabs(ctx context.Context) ([]SharedTab, error)

func (*SessionService) SidebarChats added in v0.1.27

func (s *SessionService) SidebarChats(ctx context.Context, username string, slack slackLookup, chats []string) iter.Seq2[SidebarChat, error]

func (*SessionService) SlackChannelIDs added in v0.1.0

func (s *SessionService) SlackChannelIDs(ctx context.Context) ([]string, error)

func (*SessionService) SlackThread added in v0.2.0

func (s *SessionService) SlackThread(ctx context.Context, conversationID string) (channelID, threadTS string, err error)

func (*SessionService) SpaceLimitFor added in v0.2.26

func (s *SessionService) SpaceLimitFor(ctx context.Context, spaces []string) (SpaceLimit, error)

func (*SessionService) Spaces added in v0.1.53

func (s *SessionService) Spaces(ctx context.Context) ([]Space, error)

func (*SessionService) StickySessions added in v0.2.30

func (s *SessionService) StickySessions(ctx context.Context, username string, agents harness.Agents) (map[string]string, error)

func (*SessionService) Stop

func (s *SessionService) Stop() error

func (*SessionService) StopAgentDraftWaiting added in v0.2.41

func (s *SessionService) StopAgentDraftWaiting(ctx context.Context, id, author string, reason AgentDraftWaitEnd) (AgentDraftSaveState, error)

func (*SessionService) StopGoal

func (s *SessionService) StopGoal(conversationID string) error

func (*SessionService) StripLayout added in v0.2.44

func (s *SessionService) StripLayout(ctx context.Context, username string) (StripLayout, error)

func (*SessionService) SyncCronSchedules

func (s *SessionService) SyncCronSchedules(schedules []CronScheduleState) error

func (*SessionService) SyncOpenCode added in v0.1.47

func (s *SessionService) SyncOpenCode(ctx context.Context, cfg *config.LockedConfig)

func (*SessionService) TabAttention added in v0.2.31

func (s *SessionService) TabAttention(ctx context.Context, username string) ([]Attention, error)

func (*SessionService) TabState added in v0.1.53

func (s *SessionService) TabState(ctx context.Context, username string) (TabState, int64, error)

func (*SessionService) Thread

func (s *SessionService) Thread(conversationID string) (ThreadState, bool, error)

func (*SessionService) ThreadQueueForConversation

func (s *SessionService) ThreadQueueForConversation(conversationID string) ([]protocol.ThreadQueueItem, error)

func (*SessionService) ToggleManualTag added in v0.1.47

func (s *SessionService) ToggleManualTag(ctx context.Context, agents harness.Agents, id, tag string) error

func (*SessionService) TopLevelSession added in v0.2.26

func (s *SessionService) TopLevelSession(ctx context.Context, conversationID string) (SidebarSession, error)

func (*SessionService) TurnAttachments added in v0.1.31

func (s *SessionService) TurnAttachments(ctx context.Context, conversationID, turnID string) ([]protocol.OutboundAttachment, error)

func (*SessionService) TurnProgress added in v0.2.26

func (s *SessionService) TurnProgress(ctx context.Context, conversationID, turnID string) (protocol.TurnProgress, error)

func (*SessionService) UnshareTab added in v0.2.9

func (s *SessionService) UnshareTab(ctx context.Context, space, path string) (*SearchPage, error)

func (*SessionService) UpdateConversationDetails added in v0.1.0

func (s *SessionService) UpdateConversationDetails(ctx context.Context, conversationID string, name *string) (bool, error)

func (*SessionService) UpdateGoalStatus

func (s *SessionService) UpdateGoalStatus(conversationID, status, note string) (GoalState, error)

func (*SessionService) UpdateVoiceSettings added in v0.1.36

func (s *SessionService) UpdateVoiceSettings(ctx context.Context, username string, agent, voice *string, transcript *bool) error

func (*SessionService) UpsertThread

func (s *SessionService) UpsertThread(conversationID string, thread ThreadState) error

func (*SessionService) ValidateAgentDraft added in v0.2.41

func (s *SessionService) ValidateAgentDraft(draft *AgentDraft) ([]AgentDraftProblem, error)

func (*SessionService) VoiceSettings added in v0.1.36

func (s *SessionService) VoiceSettings(ctx context.Context, username string) (VoiceSettings, error)

func (*SessionService) WakeParks added in v0.2.44

func (s *SessionService) WakeParks(ctx context.Context)

type SharedTab added in v0.2.9

type SharedTab struct {
	Space, Path string
	Search      *SearchPage
}

type SidebarChat added in v0.1.27

type SidebarChat struct {
	Session  SidebarSession
	Room     string
	Cron     bool
	CronName string
}

type SidebarSession added in v0.1.0

type SidebarSession struct {
	Conversation  protocol.Conversation
	Kind          ConversationKind
	RemoteSession string
	Summary       *protocol.SessionSummary
	Running       bool
	Background    bool
	Asking        bool
	Paused        bool
	Name          string
	ForkedFrom    string
	Tags          []string
	Server        string
	Directory     string
	Offline       bool
	SpaceID       string
	SlackChannel  string
	CronPath      string
	Reply         string
	Model         string
	Attention     Attention
	AutoPark      bool
	Origin        ChatOriginFacts
	StateSince    time.Time
	Queued        bool
	External      bool
	Pausable      bool
	ArrivedAt     time.Time
}

func (*SidebarSession) Label added in v0.2.0

func (row *SidebarSession) Label() string

type Space added in v0.1.53

type Space struct{ ID, Name string }

type SpaceLimit added in v0.2.26

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

func (SpaceLimit) AllowsAgent added in v0.2.26

func (l SpaceLimit) AllowsAgent(agent string) bool

func (SpaceLimit) AllowsSession added in v0.2.26

func (l SpaceLimit) AllowsSession(session *SidebarSession) bool

func (SpaceLimit) AllowsSpaceID added in v0.2.26

func (l SpaceLimit) AllowsSpaceID(id string) bool

func (SpaceLimit) AllowsSpaceName added in v0.2.26

func (l SpaceLimit) AllowsSpaceName(name string) bool

func (SpaceLimit) Limited added in v0.2.26

func (l SpaceLimit) Limited() bool

type StripLayout added in v0.2.44

type StripLayout struct {
	Folded map[string]bool
	Order  []string
}

type Tab added in v0.2.2

type Tab struct {
	Path         string
	Group, Space string
	Search       *SearchPage
}

type TabGroup added in v0.2.2

type TabGroup struct {
	ID, Name, Color string
	Collapsed       bool
}

type TabState added in v0.2.2

type TabState struct {
	Tabs        []Tab
	Groups      []TabGroup
	Space       string
	Last        map[string]string
	SharedOrder []string
}

type ThreadCreator

type ThreadCreator string
const ThreadCreatedByCron ThreadCreator = "cron"

type ThreadState

type ThreadState struct {
	Agent     string        `json:"agent,omitempty"`
	CreatedBy ThreadCreator `json:"created_by,omitempty"`
	// contains filtered or unexported fields
}

func (ThreadState) Sticky added in v0.2.30

func (t ThreadState) Sticky() harness.AgentSticky

type VoiceSettings added in v0.1.36

type VoiceSettings struct {
	Agent      string
	Voice      string
	Transcript bool
}

Directories

Path Synopsis
Package harnessbridgetest holds test helpers for backend.
Package harnessbridgetest holds test helpers for backend.

Jump to

Keyboard shortcuts

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