Documentation
¶
Overview ¶
Package httpapi is the product's HTTP delivery layer. It streams run events over Server-Sent Events and accepts prompts and permission answers over POST requests.
Everything it serves lives below the application composition root, so another client can drive the same conversations without owning product construction.
Index ¶
- func ProjectEvent(ev engine.Event) ([]byte, bool)
- func ProjectHistory(items []engine.HistoryItem) []wireEvent
- type ApprovalBroker
- func (b *ApprovalBroker) Decide(ctx context.Context, req permission.ApprovalRequest) (permission.ApprovalResponse, error)
- func (b *ApprovalBroker) HasPending() bool
- func (b *ApprovalBroker) PendingEvents() []wireEvent
- func (b *ApprovalBroker) Resolve(id string, choice permission.ApprovalChoice) bool
- type BrowserBroker
- func (b *BrowserBroker) BrowserTabs(ctx context.Context) (tools.BrowserTabsResult, error)
- func (b *BrowserBroker) Close()
- func (b *BrowserBroker) HasPending() bool
- func (b *BrowserBroker) InspectBrowser(ctx context.Context, tabID string) (tools.BrowserInspectionResult, error)
- func (b *BrowserBroker) OpenBrowser(ctx context.Context, request tools.BrowserRequest) (tools.BrowserResult, error)
- func (b *BrowserBroker) PendingEvents() []wireEvent
- func (b *BrowserBroker) Resolve(id string, result tools.BrowserResult) bool
- func (b *BrowserBroker) ResolveInspection(id string, result tools.BrowserInspectionResult) bool
- func (b *BrowserBroker) ResolveTabs(id string, result tools.BrowserTabsResult) bool
- type Hub
- type Options
- type QuestionBroker
- type Server
- type SessionTransports
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProjectEvent ¶
ProjectEvent maps a UI-neutral coding event to the HTTP wire protocol.
func ProjectHistory ¶
func ProjectHistory(items []engine.HistoryItem) []wireEvent
ProjectHistory maps a UI-neutral conversation snapshot to the same event shapes the browser already renders for live activity.
Types ¶
type ApprovalBroker ¶
type ApprovalBroker struct {
// contains filtered or unexported fields
}
ApprovalBroker asks the browser to decide one permission request and waits until it responds or the active run is cancelled.
func NewApprovalBroker ¶
func NewApprovalBroker(hub *Hub) *ApprovalBroker
func (*ApprovalBroker) Decide ¶
func (b *ApprovalBroker) Decide(ctx context.Context, req permission.ApprovalRequest) (permission.ApprovalResponse, error)
Decide implements permission.Approver.
func (*ApprovalBroker) HasPending ¶
func (b *ApprovalBroker) HasPending() bool
func (*ApprovalBroker) PendingEvents ¶
func (b *ApprovalBroker) PendingEvents() []wireEvent
PendingEvents returns the approvals a refreshed browser must restore.
func (*ApprovalBroker) Resolve ¶
func (b *ApprovalBroker) Resolve(id string, choice permission.ApprovalChoice) bool
Resolve atomically claims and answers a pending approval.
type BrowserBroker ¶
type BrowserBroker struct {
// contains filtered or unexported fields
}
BrowserBroker delivers one session's agent navigation commands to its connected desktop client and waits for the first terminal acknowledgement.
func NewBrowserBroker ¶
func NewBrowserBroker(hub *Hub) *BrowserBroker
func (*BrowserBroker) BrowserTabs ¶
func (b *BrowserBroker) BrowserTabs(ctx context.Context) (tools.BrowserTabsResult, error)
func (*BrowserBroker) Close ¶
func (b *BrowserBroker) Close()
Close releases every waiter when its session transport is replaced or shut down. The hub is closed immediately afterwards, so no terminal event is sent.
func (*BrowserBroker) HasPending ¶
func (b *BrowserBroker) HasPending() bool
func (*BrowserBroker) InspectBrowser ¶
func (b *BrowserBroker) InspectBrowser(ctx context.Context, tabID string) (tools.BrowserInspectionResult, error)
func (*BrowserBroker) OpenBrowser ¶
func (b *BrowserBroker) OpenBrowser( ctx context.Context, request tools.BrowserRequest, ) (tools.BrowserResult, error)
OpenBrowser implements tools.BrowserController.
func (*BrowserBroker) PendingEvents ¶
func (b *BrowserBroker) PendingEvents() []wireEvent
PendingEvents returns commands a history snapshot must restore after a renderer reconnects.
func (*BrowserBroker) Resolve ¶
func (b *BrowserBroker) Resolve(id string, result tools.BrowserResult) bool
Resolve atomically claims one pending command. Unknown and duplicate IDs do not mutate broker state.
func (*BrowserBroker) ResolveInspection ¶
func (b *BrowserBroker) ResolveInspection(id string, result tools.BrowserInspectionResult) bool
func (*BrowserBroker) ResolveTabs ¶
func (b *BrowserBroker) ResolveTabs(id string, result tools.BrowserTabsResult) bool
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub fans one session's events out to every connected browser over SSE. Each client has a buffered channel; a slow client is disconnected so EventSource can reconnect and replay from its Last-Event-ID without blocking the run.
type Options ¶
type Options struct {
Conversations *conversation.Manager
Transports *SessionTransports
Ledger *usage.Store
Workspaces *workspace.Registry
Registry *llm.ProviderRegistry
Providers *provider.Store
ProviderTests *provider.ConnectionTester
MCP *mcp.Manager
MCPConfigPath string
ObservabilityLogPath string
RequestSnapshots snapshot.Reader
}
Options contains the product services exposed through HTTP. Construction belongs to internal/app; this package only translates between HTTP and those services.
type QuestionBroker ¶
type QuestionBroker struct {
// contains filtered or unexported fields
}
QuestionBroker asks the browser to answer one set of agent questions and waits until it responds or the active run is cancelled. It is the question counterpart to ApprovalBroker: same pending-and-resolve shape, but the reply carries the user's choices rather than a permission verdict.
There is deliberately no timeout. A question can sit unanswered for as long as the user needs to think; abandoning it is what aborting the run is for.
func NewQuestionBroker ¶
func NewQuestionBroker(hub *Hub) *QuestionBroker
func (*QuestionBroker) Ask ¶
func (b *QuestionBroker) Ask( ctx context.Context, questions []tools.Question, ) ([]tools.Answer, error)
Ask implements tools.Asker.
func (*QuestionBroker) HasPending ¶
func (b *QuestionBroker) HasPending() bool
func (*QuestionBroker) PendingEvents ¶
func (b *QuestionBroker) PendingEvents() []wireEvent
PendingEvents returns the questions a refreshed browser must restore.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wires the multi-session API: session discovery plus scoped history, SSE, prompt, approval, and abort endpoints. Each field is the store one group of routes actually reads. Handlers reach for the store they need and never through another component to find it.
type SessionTransports ¶
type SessionTransports struct {
// contains filtered or unexported fields
}
SessionTransports owns the HTTP delivery links created for conversations. The conversation manager controls each link's lifetime through Transport.Close; handlers only look up an existing link by session ID.
func NewSessionTransports ¶
func NewSessionTransports() *SessionTransports
NewSessionTransports returns an empty session transport registry.
func (*SessionTransports) New ¶
func (r *SessionTransports) New(sessionID string) conversation.Transport
New creates and registers one conversation transport.
func (*SessionTransports) PreviewHandler ¶ added in v0.6.15
func (s *SessionTransports) PreviewHandler() http.Handler
PreviewHandler serves grant-scoped workspace files on the unauthenticated, preview-only loopback origin. It intentionally exposes no product API.