agentintegration

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 29 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 agentintegration owns Sidecar's bundled provider integrations: the assets that are installed beside a provider, and the handlers that define what those assets are supposed to do.

The handler is a pure state machine, deliberately separate from the shipped JavaScript that runs inside OpenCode. Keeping a Go mirror of the mapping is what lets the recorded traces be replayed against it in an ordinary test: a bug in "which event becomes which lane" is then a failing assertion rather than something discovered when a pane freezes on someone's machine. The asset and the handler are held together by TestBundledAssetMatchesTheHandler.

Index

Constants

View Source
const (
	ClaudeProvider = "claude"
	ClaudeSource   = "sidecar.claude.hooks"

	// ClaudeAssetVersion is the bundled entry's version. Bump it whenever the
	// canonical entry changes, and append the superseded entry to
	// claudeEntrySpec's canonical history so installed copies read as
	// outdated rather than damaged.
	ClaudeAssetVersion = "1"

	// ClaudeAssetSchema is the plan/marker schema the asset declares.
	ClaudeAssetSchema = 1

	// ClaudeBackupSuffix names the recoverable copy kept beside settings.json
	// before any rewrite of a pre-existing file.
	ClaudeBackupSuffix = ".sidecar-backup"
)

Claude integration identity.

View Source
const (
	CodexProvider = "codex"
	CodexSource   = "sidecar.codex.hooks"

	// CodexAssetVersion is the bundled entry's version. Bump it whenever the
	// canonical entry changes, and append the superseded entry to
	// codexEntrySpec's canonical history so installed copies read as outdated
	// rather than damaged.
	CodexAssetVersion = "1"

	// CodexAssetSchema is the plan/marker schema the asset declares.
	CodexAssetSchema = 1

	// CodexBackupSuffix names the recoverable copy kept beside each file
	// before any rewrite of a pre-existing file.
	CodexBackupSuffix = ".sidecar-backup"
)

Codex integration identity.

View Source
const (
	OpenCodeProvider = "opencode"
	OpenCodeSource   = "sidecar.opencode.plugin"

	// OpenCodeAssetVersion is the bundled asset's version. Authority is granted
	// to a source at a version, so this changing is what makes an installed
	// copy "outdated" rather than merely different.
	//
	// Bump it whenever assets/opencode/sidecar-lifecycle.js changes, once a
	// release has shipped `agent integration install`. The rule is stated here
	// rather than only in the plan because this constant and that file are what
	// someone making the change is actually looking at. Version 1's bytes were
	// revised twice during Phase C without a bump, which was safe only because
	// no release had ever installed them: there was no earlier copy of version 1
	// anywhere to be misread. Once there is, an unbumped change makes every
	// installed copy report `needs-repair` — its marker claims the current
	// version while its checksum matches nothing — and a source that has not
	// been requalified at its new version should not keep the authority the old
	// one earned.
	OpenCodeAssetVersion = "1"

	// OpenCodeAssetName is the filename the asset is installed as.
	OpenCodeAssetName = "sidecar-lifecycle.js"
)

OpenCode integration identity.

View Source
const (
	OpenCodeOwnedDir    = "plugin"
	OpenCodeConflictDir = "plugins"
)

OpenCodeOwnedDir is the single plugin directory Sidecar installs into, relative to the OpenCode config directory.

OpenCodeConflictDir is the *other* directory OpenCode also loads. Both `plugin/` and `plugins/` are read, and an asset present in both fires every event twice — which would double every sequence number and make ordering meaningless. Sidecar therefore owns exactly one and treats a copy in the other as damage to be reported, never as a second install to keep in step.

View Source
const InstallSchemaVersion = 1

InstallSchemaVersion is the wire version of the plan and status records this installer emits. It is separate from agentlifecycle.SchemaVersion because the report contract and the installer contract change for different reasons.

View Source
const OpenCodeAbortedError = "MessageAbortedError"

OpenCodeAbortedError is the error class name a user interrupt produces. Traced on 1.18.25; see docs/reference/agent-lifecycle-capability-matrix.md.

View Source
const OpenCodeAssetSchema = 1

OpenCodeAssetSchema is the marker schema version the bundled asset declares. It changes only when the marker line's own format changes, which is why it is separate from the asset version.

View Source
const OpenCodeBackupSuffix = ".sidecar-backup"

OpenCodeBackupSuffix is appended to the asset's name for the recoverable copy kept when an installed asset is replaced.

Variables

This section is empty.

Functions

func Apply

func Apply(p Plan) error

Apply executes a plan's operations in order.

Every safety question was answered while the plan was built, so this function deliberately makes no policy decisions: it creates, copies, writes, and removes exactly what it was given. A failure part-way through leaves the completed operations in place, which is why a replacement is ordered backup-then-write and why the write itself is a rename over the existing file rather than a truncate: there is no moment at which the asset is half a file.

The remaining time-of-check-to-time-of-use window is named rather than closed, and it is narrower than "safety is decided at plan time" makes it sound. A plan is built and applied inside one process, microseconds apart, with no user interaction in between; the only paths involved are files under the user's own configuration directory; and every destructive operation was gated on ownership proved from the file's own bytes at plan time. Re-proving that here would not make the window disappear, only move it — a file that stopped being Sidecar's between the two checks is a file something else is rewriting at this exact moment, and no ordering of checks inside this loop can win that race. What is worth having instead is that a lost race fails safe, which is why OpRemove tolerates an already-absent path and OpRmdir tolerates a directory that is no longer empty.

func ClaudePaths

func ClaudePaths(env Env) []string

ClaudePaths returns the paths the Claude adapter inspects and touches.

func CodexPaths

func CodexPaths(env Env) []string

CodexPaths returns the paths the Codex adapter inspects and touches.

func IsAction

func IsAction(s string) bool

IsAction reports whether s names a known action.

func Marker

func Marker(a Asset) string

Marker renders the line an asset carries.

func OpenCodeAsset

func OpenCodeAsset() string

OpenCodeAsset returns the bundled plugin source.

func OpenCodePaths

func OpenCodePaths(env Env) []string

OpenCodePaths returns the paths the OpenCode adapter would inspect and touch.

It is exported because "show the exact paths before mutating" is a rule, and a surface that wants to name them before asking for confirmation should not have to reconstruct them.

func PaneIdentity

func PaneIdentity(namespace, session string) agentlifecycle.Identity

PaneIdentity reports the live host, tmux server incarnation, and first pane of a managed session, in exactly the form the report command records them.

It exists for `sidecar agent explain --shell TARGET`, which asks about a pane it is not running in and therefore cannot derive identity from its own environment. Everything here is observed now, from live tmux — nothing is read out of a stored record, because a stored claim checked against itself is not a check.

A pane that cannot be resolved yields an identity with an empty PaneID, which every caller reads as "no lifecycle evidence applies".

func ReportArgs

func ReportArgs(action OpenCodeAction, seq uint64, sessionID string) []string

ReportArgs builds the exact CLI argv one action becomes.

It mirrors buildArgs in the bundled asset. Both exist because the asset must construct argv in JavaScript at runtime, and the equivalence test compares the two lists element for element -- so this is the Go statement of the same contract, not a convenience wrapper.

Types

type Action

type Action string

Action is one mutating integration operation.

const (
	ActionInstall   Action = "install"
	ActionUpdate    Action = "update"
	ActionRepair    Action = "repair"
	ActionUninstall Action = "uninstall"
)

func Actions

func Actions() []Action

Actions is the frozen, ordered action vocabulary.

type Adapter

type Adapter interface {
	// Provider is the catalog agent kind.
	Provider() string
	// Source is the integration identifier reports carry.
	Source() string
	// Assets are the bundled units this integration installs, one per file it
	// touches, each declaring its own [Ownership]. The order is the order a
	// surface should show them in.
	Assets() []Asset
	// Inspect reads the current state. It never mutates anything and never
	// fails: an unreadable path becomes a FileState carrying the reason.
	Inspect(Env) Status
	// Plan describes what one action would do against the current state, or
	// refuses with a [Refusal].
	Plan(Env, Action) (Plan, error)
}

Adapter is one provider's integration.

The interface is intentionally small and read-heavy: three of its methods answer questions and the fourth returns a description of a mutation rather than performing one. Nothing in an adapter writes to disk.

func DefaultAdapters

func DefaultAdapters() []Adapter

DefaultAdapters returns the adapters this build ships.

type Asset

type Asset struct {
	// Name is the filename the asset is installed as.
	Name string `json:"name"`
	// Source is the integration identifier reports carry.
	Source string `json:"source"`
	// SchemaVersion is the marker schema the asset declares. It is meaningful
	// only for [OwnsFile].
	SchemaVersion int `json:"schemaVersion"`
	// Version is the asset version. Authority is granted to a source at a
	// version, so this changing is what makes an installed copy outdated.
	Version string `json:"version"`
	// Ownership is what installing this asset does to the file at its path.
	Ownership Ownership `json:"ownership"`
	// Content is the exact bytes installed for [OwnsFile]. For [OwnsEntry] it
	// is the canonical file Sidecar would create in an empty tree, which is a
	// description of the entry rather than something ever written verbatim over
	// a user's file.
	Content string `json:"-"`
}

Asset is one bundled unit an integration installs.

An integration has one asset per file it touches. A file-drop integration therefore has exactly one; an integration that must edit two configuration files has two, and each declares its own Ownership. Plurality is not speculative generality: Codex genuinely edits hooks.json and config.toml, and describing that as one asset meant describing one of the two files and staying quiet about the other.

func (Asset) Checksum

func (a Asset) Checksum() string

Checksum is the sha256 of the asset's bytes, hex encoded.

type ClaudeAdapter

type ClaudeAdapter struct{}

ClaudeAdapter installs Sidecar's Claude Code session-identity hook.

func (ClaudeAdapter) Assets

func (ClaudeAdapter) Assets() []Asset

Assets returns the one entry asset this integration installs.

It is OwnsEntry: ~/.claude/settings.json belongs to the user, Sidecar owns one hook entry inside it, and Content is the canonical file Sidecar would create in an empty tree -- a description of the entry, shown so a surface can name exactly what an install adds, never bytes written over a user's file.

func (ClaudeAdapter) Inspect

func (a ClaudeAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (ClaudeAdapter) Plan

func (a ClaudeAdapter) Plan(env Env, act Action) (Plan, error)

Plan implements Adapter.

func (ClaudeAdapter) Provider

func (ClaudeAdapter) Provider() string

func (ClaudeAdapter) Source

func (ClaudeAdapter) Source() string

type CodexAdapter

type CodexAdapter struct{}

CodexAdapter installs Sidecar's Codex session-identity hook.

func (CodexAdapter) Assets

func (CodexAdapter) Assets() []Asset

Assets returns the two entry assets this integration installs.

This is the adapter that made assets plural. Codex needs an entry in hooks.json *and* two regions of config.toml, and both files are the user's. While an integration could describe only one bundled thing, the second file was simply absent from everything an asset feeds: a surface asking "what does this integration install" was answered with hooks.json and told nothing about the feature flag and trust record that make hooks.json do anything at all.

func (CodexAdapter) Inspect

func (a CodexAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (CodexAdapter) Plan

func (a CodexAdapter) Plan(env Env, act Action) (Plan, error)

Plan implements Adapter.

func (CodexAdapter) Provider

func (CodexAdapter) Provider() string

func (CodexAdapter) Source

func (CodexAdapter) Source() string

type Env

type Env struct {
	// Home is $HOME.
	Home string
	// ConfigHome is $XDG_CONFIG_HOME when set, and empty otherwise.
	ConfigHome string
	// LookPath finds a provider executable. Defaults to exec.LookPath.
	LookPath func(file string) (string, error)
	// ProviderVersion reports an installed provider's version string.
	ProviderVersion func(provider string) string
	// UID is the user this process runs as, compared against file ownership.
	UID int
	// StateDir is Sidecar's host-local state directory, where the lifecycle log
	// lives. Empty means the last report is simply not reported: an integration
	// that has never been used has none anyway, and a status command must not
	// fail because a log is missing.
	StateDir string
}

Env is the machine an adapter inspects and mutates.

Every field is injectable so the whole installer can be exercised against a temporary tree with no provider installed, which is the only way an adversarial-fixture suite is honest: a test that needs the real ~/.config/opencode is a test nobody can run twice.

func OSEnv

func OSEnv() Env

OSEnv returns the real machine.

type FileState

type FileState struct {
	Path   string `json:"path"`
	Exists bool   `json:"exists"`
	// Kind is file, dir, symlink, or other. It is reported for an existing path
	// even when that path is unusable, because "it is a symlink" is the answer
	// to why an install refused.
	Kind string `json:"kind,omitempty"`
	// Owned reports that Sidecar has something of its own in this file. A file
	// that merely has the right name is never owned.
	//
	// What "something of its own" means is not a second meaning smuggled behind
	// one boolean: it is whatever [Asset.Ownership] declares for the asset that
	// installs here, and [FileState.Ownership] repeats it so a reader of this
	// value never has to guess. For [OwnsFile] the whole file is Sidecar's and
	// ownership is the marker its bytes carry. For [OwnsEntry] the file is the
	// user's, Sidecar owns one entry inside it, and ownership is that entry's
	// content.
	//
	// The distinction is not cosmetic. It is the difference between "remove
	// this file" and "remove this entry and leave the file", which is why the
	// two are named rather than inferred.
	Owned bool `json:"owned"`
	// Ownership is what Owned means here. It is meaningful only when the path
	// is one an asset installs to; it is zero for a path no asset claims, such
	// as a directory or a backup.
	Ownership Ownership `json:"ownership,omitempty"`
	// Version is the asset version, parsed from the marker where there is one.
	Version string `json:"version,omitempty"`
	// Checksum is the sha256 of the file's bytes.
	Checksum string `json:"checksum,omitempty"`
	Mode     string `json:"mode,omitempty"`
	Size     int64  `json:"size,omitempty"`
	// Unsafe names why this path may not be written or removed, when it may
	// not. An empty value means the path is safe to operate on.
	Unsafe RefusalCode `json:"unsafe,omitempty"`
	// UnsafeDetail is the sanitized sentence behind Unsafe.
	UnsafeDetail string `json:"unsafeDetail,omitempty"`
}

FileState is the inspected state of one path.

type Op

type Op struct {
	Kind OpKind `json:"kind"`
	Path string `json:"path"`
	// From is the source path for a backup.
	From string `json:"from,omitempty"`
	// Mode is the mode a created path is given, rendered as "0755".
	Mode string `json:"mode,omitempty"`
	// Bytes and Checksum describe the content a write produces.
	Bytes    int    `json:"bytes,omitempty"`
	Checksum string `json:"checksum,omitempty"`
	// Note is a one-line human explanation of why this operation is here.
	Note   string    `json:"note"`
	Before FileState `json:"before"`
	After  FileState `json:"after"`
	// contains filtered or unexported fields
}

Op is one ordered file operation in a Plan.

Before and After are the inspected state of Path on either side of the operation, which is what the plan's "before/after ownership status" means: a reader can see that a write lands on nothing, or replaces a file Sidecar owns, without having to take the verb's word for it.

type OpKind

type OpKind string

OpKind is one primitive file operation.

const (
	// OpMkdir creates a directory that does not exist.
	OpMkdir OpKind = "mkdir"
	// OpBackup copies a Sidecar-owned file aside before it is replaced.
	OpBackup OpKind = "backup"
	// OpWrite writes the bundled asset atomically.
	OpWrite OpKind = "write"
	// OpRemove removes a Sidecar-owned file.
	OpRemove OpKind = "remove"
	// OpRmdir removes a directory that is empty once Sidecar's own files are
	// gone. It is never planned for a directory that still holds anything.
	OpRmdir OpKind = "rmdir"
)

type OpenCodeAction

type OpenCodeAction struct {
	Kind    agentlifecycle.Kind
	State   agentactivity.State
	Outcome agentlifecycle.Outcome
	Reason  agentlifecycle.ReasonCode
}

OpenCodeAction is one report the handler wants made.

type OpenCodeAdapter

type OpenCodeAdapter struct{}

OpenCodeAdapter installs Sidecar's OpenCode lifecycle plugin.

func (OpenCodeAdapter) Assets

func (OpenCodeAdapter) Assets() []Asset

Asset returns the bundled plugin with the identity a marker check compares against.

func (OpenCodeAdapter) Inspect

func (a OpenCodeAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (OpenCodeAdapter) Plan

func (a OpenCodeAdapter) Plan(env Env, act Action) (Plan, error)

Plan implements Adapter.

func (OpenCodeAdapter) Provider

func (OpenCodeAdapter) Provider() string

func (OpenCodeAdapter) Source

func (OpenCodeAdapter) Source() string

type OpenCodeEvent

type OpenCodeEvent struct {
	// Type is the bus event or hook name, e.g. "session.status".
	Type string
	// Status is the session.status discriminator, e.g. `{"type":"busy"}`.
	Status string
	// ErrorName is the error class name on session.error. It is the only thing
	// separating a cancelled turn from a failed one.
	ErrorName string
	// SessionID is the provider session identifier the event carried, if any.
	//
	// It is read rather than merely recorded: session.created fires on a new
	// id, which covers both the first session and a rotation mid-process. An
	// earlier version carried only a "has a session" boolean that nothing ever
	// consulted, which let this handler and the shipped asset disagree about
	// when a baseline lane is established.
	SessionID string
}

OpenCodeEvent is one sanitized event from OpenCode's plugin bus.

It carries only what the mapping needs, which is the same set the trace fixtures record: no message content ever reaches this type, so no handler bug can leak any.

type OpenCodeHandler

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

OpenCodeHandler maps OpenCode's event stream onto lifecycle reports.

The zero value is ready. It is a state machine rather than a pure function per event because two of the mappings are stateful: a repeated lane must not be re-reported, and permission.replied means nothing unless a permission.asked preceded it.

func (*OpenCodeHandler) Handle

Handle returns the actions one event should produce, in order. Most events produce none.

func (*OpenCodeHandler) Session

func (h *OpenCodeHandler) Session() string

Session returns the provider session id the handler has adopted, which the asset also carries on every report.

type Ownership

type Ownership string

Ownership is the shape of one bundled asset: what installing it does to the file at its path, and therefore how Sidecar recognizes its own work there again afterwards.

There are exactly two shapes because there are exactly two things a provider can ask for. Either it loads whole files from a directory it scans, in which case Sidecar's integration *is* a file; or it reads one configuration file the user owns, in which case Sidecar's integration is an entry inside a file it must otherwise leave alone. Every rule that differs between adapters -- how ownership is decided, whether a checksum means anything, what uninstall removes, what a surface should call it -- follows from this one distinction, so it is declared once here rather than rediscovered per adapter.

const (
	// OwnsFile: the whole file at the asset's path is Sidecar's. It is
	// recognized by the integration marker its own bytes carry, it is written
	// byte-for-byte from the bundled content, its checksum is meaningful, and
	// uninstall removes the file.
	OwnsFile Ownership = "file"
	// OwnsEntry: the file at the asset's path belongs to the user and Sidecar
	// owns one entry inside it. It is recognized by that entry's content -- a
	// user-owned config format has no comment syntax to carry a marker -- the
	// file's checksum says nothing about ownership, and uninstall removes the
	// entry and leaves every other byte alone.
	OwnsEntry Ownership = "entry"
)

type Plan

type Plan struct {
	SchemaVersion int    `json:"schemaVersion"`
	Provider      string `json:"provider"`
	Source        string `json:"source"`
	Action        Action `json:"action"`

	StatusBefore agentlifecycle.IntegrationStatus `json:"statusBefore"`
	StatusAfter  agentlifecycle.IntegrationStatus `json:"statusAfter"`

	Ops []Op `json:"ops"`

	DryRun  bool `json:"dryRun"`
	Applied bool `json:"applied"`
	// Unchanged reports that the action was a no-op because the world already
	// matched what it would have produced. It is how idempotency becomes
	// visible rather than merely true.
	Unchanged bool `json:"unchanged"`
}

Plan is the complete, ordered description of one mutation.

Ops, StatusBefore, and StatusAfter are the parts a dry run and a real run are required to agree on byte for byte. DryRun, Applied, and Unchanged describe this particular invocation and are deliberately outside that comparison.

type Refusal

type Refusal struct {
	Code    RefusalCode `json:"code"`
	Message string      `json:"message"`
	Path    string      `json:"path,omitempty"`
}

Refusal is a planning-time refusal. It always names what was refused and, where a path is involved, which one.

func AsRefusal

func AsRefusal(err error) (*Refusal, bool)

AsRefusal extracts a Refusal from err, if there is one.

func (*Refusal) Error

func (r *Refusal) Error() string

type RefusalCode

type RefusalCode string

RefusalCode is the frozen vocabulary of reasons a mutation is refused.

These are codes rather than prose so an agent can branch on them, and so the CLI and the Configuration surface can each say it in their own words without either inventing a new category.

const (
	// RefuseUnknownProvider means no provider by that name is recorded at all.
	RefuseUnknownProvider RefusalCode = "unknown_provider"
	// RefuseUnsupported means Sidecar ships no integration asset for it.
	RefuseUnsupported RefusalCode = "unsupported"
	// RefuseProviderMissing means the provider CLI was not found on PATH.
	RefuseProviderMissing RefusalCode = "provider_missing"
	// RefuseNotInstalled means the action needs an installed asset.
	RefuseNotInstalled RefusalCode = "not_installed"
	// RefuseAlreadyInstalled means install found an existing installation that
	// is not merely current, and a different verb is the honest one.
	RefuseAlreadyInstalled RefusalCode = "already_installed"
	// RefuseNeedsRepair means the installation is damaged in a way this verb
	// does not address.
	RefuseNeedsRepair RefusalCode = "needs_repair"
	// RefuseForeignFile means a file Sidecar does not own occupies a path it
	// would otherwise write or remove. Sidecar never adopts or deletes it.
	RefuseForeignFile RefusalCode = "foreign_file"
	// RefuseUnsafePath means a path is a symlink or a non-regular file where a
	// regular file was required.
	RefuseUnsafePath RefusalCode = "unsafe_path"
	// RefuseUnsafeOwner means a path is owned by a different user.
	RefuseUnsafeOwner RefusalCode = "unsafe_owner"
	// RefuseUnsafeMode means a directory is group- or world-writable, so
	// installing an executable asset into it would broaden who can change it.
	RefuseUnsafeMode RefusalCode = "unsafe_mode"
	// RefuseUnreadable means a path exists but could not be inspected.
	RefuseUnreadable RefusalCode = "unreadable"
)

func RefusalCodes

func RefusalCodes() []RefusalCode

RefusalCodes is the frozen, ordered refusal vocabulary.

type ReportSummary

type ReportSummary struct {
	Kind     agentlifecycle.Kind       `json:"kind"`
	State    agentactivity.State       `json:"state,omitempty"`
	Outcome  agentlifecycle.Outcome    `json:"outcome,omitempty"`
	Reason   agentlifecycle.ReasonCode `json:"reason,omitempty"`
	Sequence uint64                    `json:"sequence"`
	// ObservedAt and Age are both reported: the timestamp for a caller
	// computing against it, the rendered age for a human reading it.
	ObservedAt time.Time `json:"observedAt"`
	Age        string    `json:"age"`
	PaneID     string    `json:"paneId,omitempty"`
	Version    string    `json:"sourceVersion,omitempty"`
}

ReportSummary is what a surface shows about a source's newest report.

It is a summary rather than the record because a record carries identity fields — a salted session fingerprint, a run id — that answer no question a human is asking here, and the rule for this data is to carry the minimum that serves the purpose.

type Service

type Service struct {
	Env      Env
	Adapters []Adapter
}

Service is the application service behind the CLI and the Configuration route.

func NewService

func NewService() Service

NewService returns the service operating on the real machine.

func (Service) Apply

func (s Service) Apply(provider string, act Action) (Plan, error)

Apply performs one action.

It plans through exactly the same call Plan uses and then executes the result, which is why a preview cannot describe something different from what happens. The returned plan is the one that ran.

func (Service) List

func (s Service) List() []Status

List returns every provider Sidecar knows about, sorted by name.

The list is drawn from the capability registry rather than from the adapters, so a provider Sidecar has recorded evidence for but ships no asset for still appears — reported as unsupported, with its known gaps. Omitting it would make "Sidecar does not integrate with Codex yet" indistinguishable from "Sidecar has never heard of Codex", and the second is a bug report while the first is a roadmap.

func (Service) Plan

func (s Service) Plan(provider string, act Action) (Plan, error)

Plan describes one action without performing it.

func (Service) Status

func (s Service) Status(provider string) (Status, error)

Status returns one provider's state.

type Status

type Status struct {
	agentlifecycle.IntegrationReport

	// ProviderPath is where the provider CLI was found, when it was.
	ProviderPath string `json:"providerPath,omitempty"`
	// Files is every path this adapter inspected, in the order it considers
	// them. A path that does not exist is still reported, because "nothing is
	// there" is the answer to where an install would put something.
	Files []FileState `json:"files,omitempty"`
	// Offered lists the actions that would not be refused right now.
	Offered []Action `json:"offered,omitempty"`
	// LastReport is the newest record this source has written on this machine.
	//
	// It is the difference between "the integration is installed" and "the
	// integration is working", which are not the same claim and are exactly what
	// someone opens this surface to tell apart.
	LastReport *ReportSummary `json:"lastReport,omitempty"`
}

Status is one provider integration's inspected state.

It embeds the frozen agentlifecycle.IntegrationReport rather than restating it, so the wire contract Phase A froze is the wire contract both surfaces render. The added fields are what only the installer can see: the individual paths, what is actually in them, and which verbs are offered right now.

type StoreSource

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

StoreSource supplies lifecycle evidence to the shared resolver by reading the host-local JSONL log.

It is read-only by construction: it uses lifecyclestore.ReadAll, which never locks, compacts, repairs, or creates anything. A polling surface must not be able to rewrite the log that hook processes are appending to, and it must not contend with them for a lock either.

Why the fold is cached behind a stat

Every surface calls this on its own polling cadence, for every pane. Reading and parsing the whole log each time would put a file read per pane per poll on a path that runs continuously. Instead the fold is reused until the file's size or modification time changes, which costs one stat. That is the same no-change gate livewatch uses, for the same reason.

func NewStoreSource

func NewStoreSource(stateDir string) *StoreSource

NewStoreSource returns a source reading the lifecycle log in stateDir, resolving tmux through whichever server this process is already talking to.

func NewStoreSourceOn

func NewStoreSourceOn(stateDir, namespace string) *StoreSource

NewStoreSourceOn is NewStoreSource bound to a specific tmux socket.

The distinction is not theoretical. A caller asking about a pane it is not running in — `sidecar agent explain --shell TARGET` — knows which namespace that shell belongs to, and a bare `tmux` invocation would instead answer from $TMUX or the default socket. On a machine with more than one tmux server that silently reads the wrong server: the pane lookup returns a pane id from somewhere else, the server incarnation is somebody else's, and the pane being asked about resolves to screen fallback with no indication that the question was answered about the wrong machine's worth of state. That was found by running the Phase C gate from inside a tmux session, which is where anyone using Sidecar runs everything.

func (*StoreSource) Evidence

Evidence implements agentresolve.Source.

Jump to

Keyboard shortcuts

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