orca

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 25 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 orca implements workspace.Manager over Orca's runtime socket and the orca CLI.

Index

Constants

View Source
const (
	HandleVar   = "ORCA_TERMINAL_HANDLE"
	PaneVar     = "ORCA_PANE_KEY"
	WorktreeVar = "ORCA_WORKTREE_ID"
)
View Source
const (
	KindUnavailable = "unavailable"
	KindProtocol    = "protocol"
)
View Source
const LiveVar = "LOOP_LIVE_ORCA"

LiveVar set to "1" lets a test binary discover the user's running Orca runtime.

Variables

View Source
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 Agent

type Agent struct {
	WorkspaceID, Pane, LastMessage string
	State                          turn.AgentState
	StateSince                     time.Time
	UserActive                     bool
}

type Exec

type Exec struct{ Bin string }

func (Exec) Run

func (e Exec) Run(ctx context.Context, args ...string) ([]byte, error)

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 New

func New() *Manager

func (*Manager) AddRepo

func (m *Manager) AddRepo(ctx context.Context, path string) (wsdomain.Repo, error)

func (*Manager) AgentActivity

func (m *Manager) AgentActivity(ctx context.Context) (map[string]wsdomain.Activity, error)

func (*Manager) AgentIdentity

func (m *Manager) AgentIdentity(kind string) string

AgentIdentity is the identity Orca reports for the terminals of an agent.

func (*Manager) Agents

func (m *Manager) Agents(ctx context.Context) ([]Agent, error)

func (*Manager) AllTerminals

func (m *Manager) AllTerminals(ctx context.Context) ([]wsdomain.Terminal, wsdomain.Scope, error)

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

func (m *Manager) CloseTerminal(ctx context.Context, handle string) error

CloseTerminal closes the terminal; one already gone, which Orca reports as a stale handle, is closed.

func (*Manager) Create

func (*Manager) Fallbacks

func (m *Manager) Fallbacks() int64

Fallbacks is how many calls this process sent to the CLI because the runtime drifted.

func (*Manager) Focus

func (m *Manager) Focus(ctx context.Context, id string) error

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) Hosts

func (m *Manager) Hosts(string) bool

Hosts is true for every agent: Orca runs any command in a terminal.

func (*Manager) LinkUnit

func (m *Manager) LinkUnit(ctx context.Context, id string, u unit.Unit) error

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) List

func (m *Manager) List(ctx context.Context) ([]wsdomain.Workspace, error)

func (*Manager) LiveAgentSession

func (m *Manager) LiveAgentSession(ctx context.Context, workspaceID, agent string) (workspace.Session, bool, error)

func (*Manager) MarkUnread

func (m *Manager) MarkUnread(ctx context.Context, id string) error

func (*Manager) Name

func (m *Manager) Name() string

func (*Manager) Panes

func (m *Manager) Panes(ctx context.Context) ([]wsdomain.Pane, error)

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

func (m *Manager) ProfileHomes(userHome, kind string) []string

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) Reachable

func (m *Manager) Reachable(ctx context.Context) error

func (*Manager) ReadScreen

func (m *Manager) ReadScreen(ctx context.Context, handle string) (string, error)

func (*Manager) Remove

func (m *Manager) Remove(ctx context.Context, id string, force bool) error

func (*Manager) Rename

func (m *Manager) Rename(ctx context.Context, id, displayName string) error

func (*Manager) Repos

func (m *Manager) Repos(ctx context.Context) ([]wsdomain.Repo, error)

func (*Manager) SendPrompt

func (m *Manager) SendPrompt(ctx context.Context, handle, prompt string, queued bool) (bool, error)

func (*Manager) SetCard

func (m *Manager) SetCard(ctx context.Context, id, status, comment string, unread bool) error

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) SetStatus

func (m *Manager) SetStatus(ctx context.Context, id, status string) error

func (*Manager) StartAgentSession

func (m *Manager) StartAgentSession(ctx context.Context, req workspace.StartRequest) (string, error)

func (*Manager) Terminals

func (m *Manager) Terminals(ctx context.Context, workspaceID string) ([]Terminal, error)

Terminals lists the workspace's usable terminals.

func (*Manager) TrustsAtLaunch

func (m *Manager) TrustsAtLaunch(kind, home string) bool

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) Unregister

func (m *Manager) Unregister(ctx context.Context, id string) error

func (*Manager) WaitIdle

func (m *Manager) WaitIdle(ctx context.Context, handle string, timeout time.Duration) (bool, error)

WaitIdle waits up to timeout for the agent's TUI in handle to take input.

func (*Manager) Wake

func (m *Manager) Wake(ctx context.Context, req workspace.WakeRequest) (string, error)

Wake resumes a dormant session in a new terminal of its workspace with the resume line the request carries.

func (*Manager) Workspaces

func (m *Manager) Workspaces(ctx context.Context) ([]wsdomain.Workspace, wsdomain.Scope, error)

type MeteredRPC

type MeteredRPC struct{ Next RPC }

MeteredRPC records one meter.Workspace sample per runtime call of Next, op "rpc <method>".

func (MeteredRPC) Call

func (m MeteredRPC) Call(ctx context.Context, method string, params any) ([]byte, error)

type MeteredRunner

type MeteredRunner struct{ Next Runner }

MeteredRunner records one meter.Workspace sample, a spawn, per CLI command of Next.

func (MeteredRunner) Run

func (m MeteredRunner) Run(ctx context.Context, args ...string) ([]byte, error)

type RPC

type RPC interface {
	Call(ctx context.Context, method string, params any) ([]byte, error)
}

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 Runner

type Runner interface {
	// Run returns stdout even when the command exits non-zero: orca reports
	// failures inside its JSON envelope.
	Run(ctx context.Context, args ...string) ([]byte, error)
}

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

func (r *Runtime) Call(ctx context.Context, method string, params any) ([]byte, error)

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

type RuntimeError struct {
	Kind   string
	Method string
	Err    error
}

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) Handle

func (SessionEnv) Handle(getenv func(string) string) string

func (SessionEnv) Pane

func (SessionEnv) Pane(getenv func(string) string) string

func (SessionEnv) WorktreeID

func (SessionEnv) WorktreeID(getenv func(string) string) string

type Terminal

type Terminal struct {
	Handle, TabID, Title, Agent string
	LastOutput                  time.Time
}

Directories

Path Synopsis
Package orcatest serves a fake Orca runtime on a local socket, for tests that run the real orca.Manager and count its calls.
Package orcatest serves a fake Orca runtime on a local socket, for tests that run the real orca.Manager and count its calls.
cmd/orca-stub command
Command orca-stub serves an Orca runtime with no repository, worktree or terminal, for scripts/isolated-daemon.sh: its daemon finds a reachable workspace manager, so the sweep runs its workflows, and every write a session would need is refused.
Command orca-stub serves an Orca runtime with no repository, worktree or terminal, for scripts/isolated-daemon.sh: its daemon finds a reachable workspace manager, so the sweep runs its workflows, and every write a session would need is refused.

Jump to

Keyboard shortcuts

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