viewapi

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 7 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

Overview

Package viewapi defines the window-scoped service contracts shared between live Desktop windows and compiled view modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLegacyPackage

func IsLegacyPackage(name, digest string) bool

IsLegacyPackage recognizes a captured official package by its immutable content.

func WithServices

func WithServices(ctx context.Context, services Services) context.Context

Types

type Change

type Change struct {
	Cursor    string `json:"cursor"`
	Connected bool   `json:"connected"`
}

type Conversation

type Conversation struct {
	Render func(*ui.Context)
	Header func(*ui.Context, string)
	Close  func()
}

type ConversationSpec

type ConversationSpec struct {
	Match func(Session) bool
	// Config supplies a draft configuration. Its resource, if any, is
	// captured at mount time by calling Config with a default configuration.
	Config func(SessionConfig) SessionConfig
	// Tools is optional. Its callback runs on the UI thread while mounted.
	Tools *ConversationToolObserver
}

type ConversationToolCall

type ConversationToolCall struct {
	Key         string          `json:"key"`
	Name        string          `json:"name"`
	Arguments   json.RawMessage `json:"arguments"`
	State       string          `json:"state"`
	TimestampMs int64           `json:"timestamp_ms"`
	Result      json.RawMessage `json:"result"`
	Sequence    *string         `json:"sequence"`
}

type ConversationToolHistory

type ConversationToolHistory struct {
	Connected bool                   `json:"connected"`
	Session   *protocol.SessionID    `json:"session,omitempty"`
	Revision  string                 `json:"revision,omitempty"`
	Latest    *string                `json:"latest,omitempty"`
	Calls     []ConversationToolCall `json:"calls"`
}

type ConversationToolObserver

type ConversationToolObserver struct {
	Names         []string
	LegacyPackage string
	Publish       func(ConversationToolHistory)
}

ConversationToolObserver projects only the named calls of the mounted conversation, never calls from another session. Names also apply to the aliases of LegacyPackage when a saved conversation predates the module.

type Destination

type Destination struct {
	Writer  io.WriteCloser
	Publish func(context.Context) error
	Close   func()
}

type NodeInfo

type NodeInfo struct {
	ID             protocol.NodeID
	Label          string
	Connected      bool
	Local          bool
	ProjectSources []string
	Tools          []protocol.HostTool
	CanClone       bool
}

NodeInfo describes an execution Node visible to this window.

type ProviderAccount

type ProviderAccount struct {
	Authentication     protocol.Authentication
	ProviderRevision   uint64
	Credential         protocol.CredentialID
	CredentialKnown    bool
	CredentialRevision uint64
}

ProviderAccount identifies a connected provider's credential binding. CredentialKnown is false until its credential metadata has loaded.

type Receipt

type Receipt struct {
	State  string
	Output protocol.Output
	Fault  *protocol.Fault
}

type Services

type Services struct {
	Node      protocol.NodeID
	Connected func() bool
	Next      func(context.Context, string) (Change, error)
	Post      func(func(*ui.Context)) bool
	Wake      func()
	Async     func(func()) bool

	Prepare func(protocol.Command) protocol.Request
	Execute func(context.Context, protocol.Request) (protocol.Output, error)
	Settle  func(context.Context, protocol.Request) (protocol.Output, error)
	Resolve func(context.Context, protocol.Request) (Receipt, error)
	Outcome func(context.Context, protocol.Request) (protocol.RequestOutcome, error)

	// Multi-node discovery, execution, snapshots and window-wide notifications.
	Nodes func() []NodeInfo
	// NodeLabel resolves the canonical localized display name for any Node ID:
	// the local host name in the window's active locale, the peer's canonical
	// name when known or remembered, or a consistent short ID fallback.
	NodeLabel func(protocol.NodeID) string
	// ModelOptions returns the canonical kit.ModelSelect options for enabled
	// model channels on the given Node (zero NodeID selects the local Node),
	// with Mark, Brand, BrandName, Efforts, DefaultEffort, and Score populated.
	ModelOptions    func(protocol.NodeID) []kit.ModelOption
	PrepareOn       func(protocol.NodeID, protocol.Command) (protocol.Request, error)
	ExecuteOn       func(context.Context, protocol.NodeID, protocol.Request) (protocol.Output, error)
	SettleOn        func(context.Context, protocol.NodeID, protocol.Request) (protocol.Output, error)
	ResolveOn       func(context.Context, protocol.NodeID, protocol.Request) (Receipt, error)
	OutcomeOn       func(context.Context, protocol.NodeID, protocol.Request) (protocol.RequestOutcome, error)
	Snapshot        func(protocol.NodeID) (*protocol.Snapshot, bool)
	ProviderAccount func(protocol.NodeID, protocol.ProviderID) (ProviderAccount, bool)
	Credentials     func(protocol.NodeID) map[protocol.CredentialID]protocol.Credential
	OpenSession     func(protocol.NodeID, protocol.SessionID)
	RevealDetails   func()
	OnChange        func(func()) func()
	Usage           *UsageServices

	// Mounting and interacting with these elements run on the window's UI thread.
	TerminalLaunch    func(*ui.Context) any
	MountTerminal     func(protocol.TerminalID, func(TerminalInfo) bool) Terminal
	MountConversation func(ConversationSpec) Conversation

	// Native pickers wait for a choice; call them outside the UI thread.
	PickFiles       func(context.Context) ([]string, error)
	PickFolder      func(context.Context) (string, error)
	PickDestination func(context.Context, string) (string, error)
	PickSecret      func(context.Context, string) ([]byte, string, error)
	WriteClipboard  func(string) error
	Preview         func(string, func(context.Context, uint64, func(uint64, uint64)) ([]byte, error)) error
	// File paths are captured by a native picker or drop, not by the template.
	OpenSource      func(context.Context, string, uint64) (SourceFile, error)
	OpenDestination func(string) (Destination, error)
	Upload          func(context.Context, protocol.StreamID, uint64, string, io.ReadCloser, func(uint64)) error
	Download        func(context.Context, protocol.StreamID, uint64, string, io.WriteCloser, func(uint64)) error
	ReleaseStream   func(protocol.StreamID)
}

Services belong to one window and its local Node. They are for compiled contributions, which expose only their scoped operations to a template. Requests and local file paths must come from those native operations, not directly from a template. Persistent operations outlive a template.

func WindowServices

func WindowServices(ctx context.Context) (Services, bool)

type Session

type Session = protocol.Session

type SessionConfig

type SessionConfig = protocol.SessionConfig

type SourceFile

type SourceFile struct {
	Reader   io.ReadCloser
	Size     uint64
	Revision string
}

type Terminal

type Terminal struct {
	Render func(*ui.Context)
	Focus  func()
	Close  func()
}

type TerminalInfo

type TerminalInfo = protocol.TerminalInfo

type UsageInventory

type UsageInventory struct {
	Node      protocol.NodeID
	Label     string
	Projects  []protocol.Project
	Providers []protocol.ConversationProvider
}

UsageInventory holds the filter options available on one Node.

type UsageNodeSource

type UsageNodeSource struct {
	Node  protocol.NodeID
	Entry protocol.NodeID
	View  UsageNodeView
}

UsageNodeSource pairs a Node route with its observed usage view.

type UsageNodeView

type UsageNodeView struct {
	Report     *protocol.UsageReport
	Connected  bool
	Refreshing bool
	Error      *protocol.Fault
}

UsageNodeView is the current observation state of one Node in a usage overview.

type UsageOverview

type UsageOverview struct {
	Sources  []UsageNodeSource
	Summary  *UsageSummary
	Complete bool
	Error    *protocol.Fault
}

UsageOverview is one consistent snapshot produced by WatchOverview.

type UsageSample

type UsageSample struct {
	Revision  uint64
	Report    func(protocol.NodeID, protocol.UsageQuery) (protocol.UsageReport, error)
	Inventory func() ([]protocol.Project, []protocol.ConversationProvider)
}

UsageSample serves in-memory Demo usage reports and filter inventory without contacting any Node. Revision advances whenever the demo ledger changes.

type UsageScopedGroup

type UsageScopedGroup struct {
	Node  protocol.NodeID
	Entry protocol.NodeID
	Group protocol.UsageGroup
}

UsageScopedGroup tags a usage breakdown group with the Node that reported it.

type UsageScopedPage

type UsageScopedPage struct {
	Items   []UsageScopedRequest
	HasMore bool
}

UsageScopedPage is one cursor-paginated slice of merged usage requests.

type UsageScopedRequest

type UsageScopedRequest struct {
	Request protocol.UsageRequest
	Entry   protocol.NodeID
}

UsageScopedRequest tags a usage request record with its entry Node.

type UsageServices

type UsageServices struct {
	Sources func() []UsageSource
	// WatchOverview observes usage for target, or across all active Sources
	// when target is the zero NodeID. onUpdate runs off the UI thread. Call
	// Close to release the watch; closing the window also stops active watches.
	WatchOverview func(context.Context, protocol.NodeID, protocol.UsageQuery, func(UsageOverview, error)) (UsageWatch, error)
	ReadUsage     func(context.Context, protocol.NodeID, protocol.UsageQuery) (protocol.UsageReport, error)
	Inventory     func(protocol.NodeID) (UsageInventory, bool)
	Sample        func() (*UsageSample, bool)
}

UsageServices exposes multi-node and Demo usage operations to native modules.

type UsageSource

type UsageSource struct {
	ID    protocol.NodeID
	Label string
	Local bool
}

UsageSource identifies a Node included in usage reads and overviews.

type UsageSummary

type UsageSummary struct {
	Totals   protocol.UsageMetrics
	Days     []protocol.UsagePoint
	Recent   []protocol.UsagePoint
	Groups   []UsageScopedGroup
	Requests UsageScopedPage
}

UsageSummary aggregates totals, time buckets, breakdown groups and requests across the Nodes observed by a usage overview.

type UsageWatch

type UsageWatch struct {
	Refresh func(context.Context) error
	Close   func()
}

UsageWatch owns a live or sample usage overview subscription.

Jump to

Keyboard shortcuts

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