Documentation
¶
Overview ¶
Package orca implements workspace.Manager over Orca's runtime socket and the orca CLI.
Index ¶
- Constants
- Variables
- type Agent
- type Exec
- type Manager
- func (m *Manager) AddRepo(ctx context.Context, path string) (wsdomain.Repo, error)
- func (m *Manager) AgentActivity(ctx context.Context) (map[string]wsdomain.Activity, error)
- func (m *Manager) AgentIdentity(kind string) string
- func (m *Manager) Agents(ctx context.Context) ([]Agent, error)
- func (m *Manager) AllTerminals(ctx context.Context) ([]wsdomain.Terminal, wsdomain.Scope, error)
- func (m *Manager) CloseTerminal(ctx context.Context, handle string) error
- func (m *Manager) Create(ctx context.Context, req workspace.CreateRequest) (wsdomain.Workspace, string, error)
- func (m *Manager) Fallbacks() int64
- func (m *Manager) Focus(ctx context.Context, id string) error
- func (m *Manager) Hosts(string) bool
- func (m *Manager) LinkUnit(ctx context.Context, id string, u unit.Unit) error
- func (m *Manager) List(ctx context.Context) ([]wsdomain.Workspace, error)
- func (m *Manager) LiveAgentSession(ctx context.Context, workspaceID, agent string) (workspace.Session, bool, error)
- func (m *Manager) MarkUnread(ctx context.Context, id string) error
- func (m *Manager) Name() string
- func (m *Manager) Panes(ctx context.Context) ([]wsdomain.Pane, error)
- func (m *Manager) ProfileHomes(userHome, kind string) []string
- func (m *Manager) Reachable(ctx context.Context) error
- func (m *Manager) ReadScreen(ctx context.Context, handle string) (string, error)
- func (m *Manager) Remove(ctx context.Context, id string, force bool) error
- func (m *Manager) Rename(ctx context.Context, id, displayName string) error
- func (m *Manager) Repos(ctx context.Context) ([]wsdomain.Repo, error)
- func (m *Manager) SendPrompt(ctx context.Context, handle, prompt string, queued bool) (bool, error)
- func (m *Manager) SetCard(ctx context.Context, id, status, comment string, unread bool) error
- func (m *Manager) SetStatus(ctx context.Context, id, status string) error
- func (m *Manager) StartAgentSession(ctx context.Context, req workspace.StartRequest) (string, error)
- func (m *Manager) Terminals(ctx context.Context, workspaceID string) ([]Terminal, error)
- func (m *Manager) TrustsAtLaunch(kind, home string) bool
- func (m *Manager) Unregister(ctx context.Context, id string) error
- func (m *Manager) WaitIdle(ctx context.Context, handle string, timeout time.Duration) (bool, error)
- func (m *Manager) Wake(ctx context.Context, req workspace.WakeRequest) (string, error)
- func (m *Manager) Workspaces(ctx context.Context) ([]wsdomain.Workspace, wsdomain.Scope, error)
- type MeteredRPC
- type MeteredRunner
- type RPC
- type Runner
- type Runtime
- type RuntimeError
- type SessionEnv
- type Terminal
Constants ¶
const ( HandleVar = "ORCA_TERMINAL_HANDLE" PaneVar = "ORCA_PANE_KEY" WorktreeVar = "ORCA_WORKTREE_ID" )
const ( KindProtocol = "protocol" )
const LiveVar = "LOOP_LIVE_ORCA"
LiveVar set to "1" lets a test binary discover the user's running Orca runtime.
Variables ¶
var ErrProtocol = errors.New("orca runtime protocol mismatch")
ErrProtocol is a runtime answer this client cannot read: Orca's protocol drifted.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
R Runner
// RPC carries every call that has a runtime method; without it every call goes
// through the CLI, and workspaces from a pull request keep Orca's generated branch name.
RPC RPC
// Identities maps an agent's name to the agent identity Orca
// reports for its terminals; a kind missing from it is its own identity.
Identities map[string]string
// DefaultBranch reads a local checkout's default branch; nil reads origin/HEAD.
DefaultBranch func(path string) string
// contains filtered or unexported fields
}
func (*Manager) AgentActivity ¶
func (*Manager) AgentIdentity ¶
AgentIdentity is the identity Orca reports for the terminals of an agent.
func (*Manager) AllTerminals ¶
AllTerminals lists the terminals of every worktree from one terminal.list. The scope is complete only when the list is whole and Orca reports its graph ready.
func (*Manager) CloseTerminal ¶
CloseTerminal closes the terminal; one already gone, which Orca reports as a stale handle, is closed.
func (*Manager) Fallbacks ¶
Fallbacks is how many calls this process sent to the CLI because the runtime drifted.
func (*Manager) Focus ¶
Focus switches to the live agent terminal, else to any terminal of the worktree, else opens its README. Orca rejects directories and "." as paths for file open, so a worktree without terminals or a README cannot be focused.
func (*Manager) LinkUnit ¶
LinkUnit sets a pull request as the worktree's linkedPR; another unit's label goes on a line of the worktree comment, beside other units' labels. LinkUnit shows a pull request on the worktree's card; Orca shows no other unit, whose link the loop's store keeps alone.
func (*Manager) LiveAgentSession ¶
func (*Manager) Panes ¶
Panes lists every agent of every worktree from one worktree.ps, plus a bare pane for the worktree open in the app when no agent runs there.
func (*Manager) ProfileHomes ¶
ProfileHomes lists the agent homes of Orca's profiles of kind in Orca's user data directory for userHome, which ORCA_USER_DATA_PATH overrides.
func (*Manager) ReadScreen ¶
func (*Manager) SendPrompt ¶
func (*Manager) SetCard ¶
SetCard writes the card's column, comment and unread in one call; an empty status or comment and a false unread leave that part as it is.
func (*Manager) StartAgentSession ¶
func (*Manager) TrustsAtLaunch ¶
TrustsAtLaunch matches Orca's profile homes of kind, where Orca trusts the workspace when it launches an agent itself and its agent workspace trust setting is on.
func (*Manager) WaitIdle ¶
WaitIdle waits up to timeout for the agent's TUI in handle to take input.
type MeteredRPC ¶
type MeteredRPC struct{ Next RPC }
MeteredRPC records one meter.Workspace sample per runtime call of Next, op "rpc <method>".
type MeteredRunner ¶
type MeteredRunner struct{ Next Runner }
MeteredRunner records one meter.Workspace sample, a spawn, per CLI command of Next.
type RPC ¶
RPC calls an Orca runtime method directly. Some parameters the app uses, such as the branch name of a worktree created from a pull request, have no `orca` CLI flag.
type Runtime ¶
type Runtime struct {
// UserDataPath holds orca-runtime.json; "" resolves ORCA_USER_DATA_PATH, then the
// platform default (darwin: ~/Library/Application Support/orca; else
// $XDG_CONFIG_HOME/orca or ~/.config/orca). A test binary may resolve it only
// with LiveVar set: Orca exports ORCA_USER_DATA_PATH into its own terminals.
UserDataPath string
// Timeout bounds one call; 0 is 60 s. A keepalive frame restarts it. terminal.wait
// uses params.timeoutMs + 10 s when that is larger.
Timeout time.Duration
// Dial is net.Dialer.DialContext on "unix"; tests replace it.
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
// Observe receives one call's method, duration, response bytes and error.
Observe func(method string, d time.Duration, bytes int, err error)
}
Runtime calls Orca's runtime over its local socket, as Orca's own CLI does.
func (*Runtime) Call ¶
Call returns the response frame as bytes, in the envelope decode() reads. Errors: *RuntimeError with Kind Unavailable wraps workspace.ErrUnreachable (no or incomplete metadata, dial refused, closed before a frame, no answer in time, runtimeId changed); Kind Protocol wraps ErrProtocol (unparseable frame, id mismatch, success frame without _meta.runtimeId); a context error is returned as is. The auth token never appears in an error.
type RuntimeError ¶
RuntimeError is a failed runtime call. It matches workspace.ErrUnreachable when Kind is KindUnavailable and ErrProtocol when Kind is KindProtocol.
func (*RuntimeError) Error ¶
func (e *RuntimeError) Error() string
func (*RuntimeError) Unwrap ¶
func (e *RuntimeError) Unwrap() []error
type SessionEnv ¶
type SessionEnv struct{}
SessionEnv reads the identity Orca gives a terminal's session.
func (SessionEnv) WorktreeID ¶
func (SessionEnv) WorktreeID(getenv func(string) string) string