agentintegration

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 33 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 (
	AntigravityProvider = "antigravity"
	// AntigravityCommand is the executable. The family id is `antigravity` and
	// the binary is `agy`, which is also Herdr's label for this agent.
	AntigravityCommand = "agy"
	AntigravitySource  = "sidecar.antigravity.hooks"

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

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

	// AntigravityBlockName is the named hook block Sidecar owns in hooks.json.
	AntigravityBlockName = "sidecar"

	// AntigravityEvent is the event the entry is registered on. Antigravity has
	// no session event; PreInvocation is the earliest one that fires on every
	// turn and carries the conversation id.
	AntigravityEvent = "PreInvocation"
)

Antigravity integration identity.

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 (
	CopilotProvider = "copilot"
	CopilotCommand  = "copilot"
	CopilotSource   = "sidecar.copilot.hooks"

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

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

	// CopilotCommandKey is the entry member Copilot reads the command from on
	// Unix. See the note above on why the Windows spelling is not written.
	CopilotCommandKey = "bash"
)

Copilot integration identity.

View Source
const (
	CursorProvider = "cursor"
	// CursorCommand is the executable. `cursor` is the IDE launcher on a
	// machine with Cursor installed, and `cursor --version` is recorded in
	// source.go as a probe that never exits; `cursor-agent` is the CLI this
	// integration is for, and it is what the catalog family names too.
	CursorCommand = "cursor-agent"
	CursorSource  = "sidecar.cursor.hooks"

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

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

	// CursorEvent is the event the entry is registered on. Cursor spells the
	// session start camelCase.
	CursorEvent = "sessionStart"

	// CursorSchemaVersion is the `version` number Cursor's own writer puts at
	// the top of a hooks.json it generates. Herdr adds it to any file lacking
	// one; Sidecar writes it only into a file it creates itself, because
	// 2026.08.25's hook loader never reads the key.
	CursorSchemaVersion = 1
)

Cursor integration identity.

View Source
const (
	DevinProvider = "devin"
	DevinSource   = "sidecar.devin.hooks"

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

	// DevinAssetSchema is the plan/marker schema the asset declares.
	DevinAssetSchema = 1
)

Devin integration identity.

View Source
const (
	DroidProvider = "droid"
	DroidSource   = "sidecar.droid.hooks"

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

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

	// DroidShadowFile is the file whose presence makes settings.json's hooks
	// key inert. See the note above.
	DroidShadowFile = "hooks.json"
)

Droid integration identity.

View Source
const (
	GrokProvider = "grok"
	GrokCommand  = "grok"
	GrokSource   = "sidecar.grok.hooks"

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

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

	// GrokHookFileName is the file Sidecar owns inside grok's hooks directory.
	// grok globs every *.json there and merges what it finds.
	GrokHookFileName = "sidecar.json"
)

grok integration identity.

View Source
const (
	HermesProvider = "hermes"
	// HermesCommand is the executable. Hermes installs a shim on PATH that
	// execs the interpreter inside its own virtualenv, so this is the name to
	// look up rather than a path into the home directory.
	HermesCommand = "hermes"
	HermesSource  = "sidecar.hermes.plugin"

	// HermesAssetVersion 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 anything under assets/hermes/ changes, once a release
	// has shipped `agent integration install hermes`. Until then the bytes may
	// be revised in place, because there is no earlier copy of version 1
	// anywhere to be misread. See asset_golden_test.go, which states the whole
	// bump order.
	HermesAssetVersion = "1"

	// HermesAssetSchema is the marker schema the assets declare. It changes
	// only when the marker line's own format changes, which is why it is
	// separate from the asset version.
	HermesAssetSchema = 1

	// HermesPluginName is the directory Sidecar owns under <hermes home>/plugins,
	// and also the name that goes in `plugins.enabled`.
	//
	// The two are the same string because Hermes accepts either the
	// path-derived key or the manifest's own name in that list, and a plugin
	// whose directory and manifest disagree is one whose enable line matches
	// for a reason its reader cannot see. Herdr's directory is
	// `herdr-agent-state`; a machine with both installed has two directories
	// and two enable lines, and neither tool touches the other's.
	HermesPluginName = "sidecar-agent-state"

	// HermesInitName and HermesManifestName are the two files Hermes requires
	// of a directory plugin. A directory holding one without the other is
	// skipped by the loader with no error at all, which is why they are
	// installed and removed together.
	HermesInitName     = "__init__.py"
	HermesManifestName = "plugin.yaml"

	// HermesConfigName is the configuration file the enable line lives in. It
	// belongs to the user and Sidecar owns one line inside it.
	HermesConfigName = "config.yaml"
)

Hermes integration identity.

View Source
const (
	KiloProvider = "kilo"
	KiloSource   = "sidecar.kilo.plugin"

	// KiloAssetVersion 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/kilo/sidecar-lifecycle.js changes, once a release
	// has shipped `agent integration install kilo`. Until then the bytes may be
	// revised in place, because there is no earlier copy of version 1 anywhere to
	// be misread. See asset_golden_test.go, which states the whole bump order.
	KiloAssetVersion = "1"

	// KiloAssetName is the filename the asset is installed as.
	//
	// Kilo globs `{plugin,plugins}/*.{ts,js}` inside every config directory it
	// discovers, so the extension may be either and .js is chosen: node cannot
	// import a .ts module, and the equivalence harness has to run the shipped
	// file itself.
	KiloAssetName = "sidecar-lifecycle.js"
)

Kilo integration identity.

View Source
const (
	KiloOwnedDir    = "plugin"
	KiloConflictDir = "plugins"
)

KiloOwnedDir is the single plugin directory Sidecar installs into, and KiloConflictDir is the other one Kilo also loads.

View Source
const (
	KimiProvider = "kimi"
	KimiSource   = "sidecar.kimi.hooks"

	// KimiAssetVersion is the bundled block'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 the rendered block changes, once a release has shipped
	// `agent integration install kimi`. Until then the bytes may be revised in
	// place, because there is no earlier copy of version 1 anywhere to be
	// misread. asset_golden_test.go states the whole bump order.
	KimiAssetVersion = "1"

	// KimiAssetSchema is the marker schema the managed block declares. It
	// changes only when the marker line's own format changes, which is why it is
	// separate from the asset version.
	KimiAssetSchema = 1

	// KimiConfigName is the file Kimi Code CLI reads its hooks from.
	KimiConfigName = "config.toml"

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

Kimi integration identity.

View Source
const (
	MastracodeProvider = "mastracode"
	MastracodeSource   = "sidecar.mastracode.hooks"

	// MastracodeAssetVersion is the bundled entry set'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 the rendered entries change, once a release has shipped
	// `agent integration install mastracode`. Until then the bytes may be revised
	// in place, because there is no earlier copy of version 1 anywhere to be
	// misread. asset_golden_test.go states the whole bump order.
	MastracodeAssetVersion = "1"

	// MastracodeAssetSchema is the plan schema the asset declares.
	MastracodeAssetSchema = 1

	// MastracodeConfigName is the file Mastra Code reads its global hooks from.
	MastracodeConfigName = "hooks.json"

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

	// MastracodeDirName is the directory Mastra Code keeps its global
	// configuration in, under the home directory.
	//
	// It is a bare directory NAME rather than a path because that is what Mastra
	// Code itself treats it as: `configDirName` is validated by
	// validateConfigDirName, which rejects an absolute path, either separator,
	// "." and "..", and the global hooks path is
	// path.join(os.homedir(), configDirName, "hooks.json").
	MastracodeDirName = ".mastracode"
)

Mastracode integration identity.

View Source
const (
	OmpProvider = "omp"
	OmpSource   = "sidecar.omp.extension"

	// OmpAssetVersion 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/omp/sidecar-omp-lifecycle.js changes, once a
	// release has shipped `agent integration install omp`. See
	// asset_golden_test.go, which states the whole bump order.
	OmpAssetVersion = "1"

	// OmpAssetName is the filename the asset is installed as.
	//
	// It is deliberately NOT sidecar-lifecycle.js, which is what every other
	// file-shaped Sidecar asset is called. OMP and Pi read the same
	// PI_CODING_AGENT_DIR, so with that variable set the two providers resolve
	// to one extensions directory (see ompExtensionsCollision), and a shared
	// name would put Sidecar's OMP asset exactly where Sidecar's Pi asset lives.
	// The marker rule would still refuse to overwrite it -- ownership compares
	// the source id, not the filename -- but a refusal is a worse outcome than
	// two files that were never going to collide in the first place. Herdr names
	// its own OMP asset apart for the same reason.
	OmpAssetName = "sidecar-omp-lifecycle.js"

	// OmpIdleDebounceMS and OmpRetryGraceMS are upstream's two constants,
	// unchanged, and the asset carries the same values.
	//
	// The debounce is why an ended run does not publish idle immediately: OMP can
	// end a run and start another at once, and a pane that flickered through idle
	// between two halves of one piece of work is a notification a user did not
	// want. The grace is how long a retryable provider error is held at working
	// before it is admitted to be a block, because OMP retries by itself and a
	// failure it is about to clear is still work in progress.
	OmpIdleDebounceMS = 250
	OmpRetryGraceMS   = 2500
)

OMP 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 (
	PiProvider = "pi"
	PiSource   = "sidecar.pi.extension"

	// PiAssetVersion 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/pi/sidecar-lifecycle.js changes, once a release
	// has shipped `agent integration install pi`. Until then the bytes may be
	// revised in place, because there is no earlier copy of version 1 anywhere
	// to be misread. See the same note on OpenCodeAssetVersion, and
	// asset_golden_test.go, which states the whole bump order.
	PiAssetVersion = "1"

	// PiAssetName is the filename the asset is installed as.
	//
	// Pi's loader takes any bare *.ts or *.js file in an extension directory
	// (isExtensionFile, dist/core/extensions/loader.js:528-530), so the
	// extension is free and .js is chosen: node cannot import a .ts module, and
	// the equivalence harness has to run the shipped file itself.
	PiAssetName = "sidecar-lifecycle.js"
)

Pi integration identity.

View Source
const (
	QoderCLIProvider = "qodercli"
	QoderCLICommand  = "qoder"
	QoderCLISource   = "sidecar.qodercli.hooks"

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

	// QoderCLIAssetSchema is the plan/marker schema the asset declares.
	QoderCLIAssetSchema = 1
)

Qoder CLI integration identity.

View Source
const (
	QwenProvider = "qwen"
	QwenSource   = "sidecar.qwen.hooks"

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

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

	// QwenHookTimeoutMillis is the entry's timeout, in the unit Qwen counts in.
	//
	// It is ten seconds, the same budget every other Sidecar hook entry gets,
	// and it is a separate constant from hookTimeoutSec precisely so the unit
	// change is visible at the point of use rather than hidden in a number.
	QwenHookTimeoutMillis = hookTimeoutSec * 1000
)

Qwen Code integration identity.

View Source
const HermesBackupSuffix = ".sidecar-backup"

HermesBackupSuffix names the recoverable copy kept beside a file before it is replaced or edited.

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 KiloAssetSchema = 1

KiloAssetSchema 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 KiloBackupSuffix = ".sidecar-backup"

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

View Source
const OmpAssetSchema = 1

OmpAssetSchema 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 OmpBackupSuffix = ".sidecar-backup"

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

View Source
const OmpExtensionsDir = "extensions"

OmpExtensionsDir is the directory name OMP scans inside its agent directory.

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.

View Source
const PiAssetSchema = 1

PiAssetSchema 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 PiBackupSuffix = ".sidecar-backup"

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

View Source
const PiExtensionsDir = "extensions"

PiExtensionsDir is the directory name Pi scans inside its agent directory.

View Source
const UnknownPortedVersion = "unknown"

UnknownPortedVersion is the Version of a Sidecar asset whose upstream starting point could not be established. The sync report then renders the whole upstream file rather than a diff.

View Source
const UpstreamGeneratedNotice = "generated by internal/tools/herdrsync"

UpstreamGeneratedNotice is the Origin recorded for upstream/NOTICE, which Sidecar writes rather than copies.

View Source
const UpstreamLockSchemaVersion = 1

UpstreamLockSchemaVersion is the shape version of upstream.lock.json. Bump it when a field changes meaning, so a stale lock fails loudly.

Variables

This section is empty.

Functions

func AntigravityConfigHome added in v1.14.0

func AntigravityConfigHome(home string) string

AntigravityConfigHome resolves the directory Antigravity CLI reads its global customizations from.

It is `~/.gemini/config` and nothing else, deliberately. Herdr honours an `ANTIGRAVITY_CLI_CONFIG_DIR` override here; agy 1.1.22 does not read that variable -- it appears nowhere in the shipped binary -- so honouring it would put Sidecar's entry in a directory the provider never opens, which is worse than having no override at all. A proof run redirects Antigravity by moving HOME, which moves the provider and the installer together.

`~/.gemini/antigravity-cli` is runtime data and is never read for hooks. The distinction is not academic: agy's own changelog records fixing a bug where its `/hooks` command wrote to that directory instead of the shared config one, which is the release the capability entry means when it says the path has already moved.

func AntigravityPaths added in v1.14.0

func AntigravityPaths(env Env) []string

AntigravityPaths returns the paths the Antigravity adapter inspects and touches.

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 ClaudeConfigHome added in v1.14.0

func ClaudeConfigHome(home, configDir string) string

ClaudeConfigHome resolves Claude Code's configuration home the way Claude itself does: the raw CLAUDE_CONFIG_DIR value when it names one, and <home>/.claude otherwise.

Two readings are deliberate and both follow the provider rather than Sidecar's taste. Claude's own resolver takes the variable verbatim and then refuses the run when the result is not absolute, so a relative value names no configuration home at all; treating it as an override would send an install into a directory relative to whatever Sidecar's working directory happened to be, which is the one place Claude will certainly not look. And a value that is only whitespace is a variable somebody exported without a value rather than a directory named " ", which is the same reading agentsession.PiAgentDir already takes of PI_CODING_AGENT_DIR. In both cases the default stands, so the installer keeps writing where an unconfigured Claude reads.

No tilde expansion, because Claude does none: it requires an absolute path, and "~/x" is not one.

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 CopilotConfigHome added in v1.14.0

func CopilotConfigHome(home, copilotHome string) string

CopilotConfigHome resolves the directory GitHub Copilot CLI keeps its settings in: $COPILOT_HOME when that names one, ~/.copilot otherwise.

The variable is Herdr's, and unlike Antigravity's seam it is honoured here rather than ignored, because there is no shipped binary to check it against and a plausible provider override is the better guess than none: a user who has set it has a Copilot that reads there, and an installer that ignored it would write where nothing reads. If a released Copilot turns out not to read it, the fix is to drop this the way Antigravity's was dropped, and the capability entry records that this is unverified.

func CopilotPaths added in v1.14.0

func CopilotPaths(env Env) []string

CopilotPaths returns the paths the Copilot adapter inspects and touches.

func CursorHooksHome added in v1.14.0

func CursorHooksHome(home string) string

CursorHooksHome resolves the directory cursor-agent reads its user hooks from. See the note above on why no environment override is honoured.

func CursorPaths added in v1.14.0

func CursorPaths(env Env) []string

CursorPaths returns the paths the Cursor adapter inspects and touches.

func DevinConfigDir added in v1.14.0

func DevinConfigDir(env Env) string

DevinConfigDir resolves the directory the Devin CLI keeps its configuration in: $XDG_CONFIG_HOME/devin when that variable names one, ~/.config/devin otherwise. It is the one provider in this group whose directory hangs off $XDG_CONFIG_HOME rather than off $HOME directly, which is Herdr's devin_dir.

func DevinPaths added in v1.14.0

func DevinPaths(env Env) []string

DevinPaths returns the paths the Devin adapter inspects and touches.

func DroidConfigDir added in v1.14.0

func DroidConfigDir(home string) string

DroidConfigDir resolves the directory the Factory CLI keeps its settings in. There is no override to honour; see the note above.

func DroidPaths added in v1.14.0

func DroidPaths(env Env) []string

DroidPaths returns the paths the Droid adapter inspects and touches.

func GrokHooksDir added in v1.14.0

func GrokHooksDir(home, grokHome string) string

GrokHooksDir resolves the directory grok reads its personal hook files from: `$GROK_HOME/hooks` when that is set, `~/.grok/hooks` otherwise.

GROK_HOME is grok's own variable rather than Herdr's seam -- the shipped binary carries the string and the error "no user grok home (set $GROK_HOME or $HOME)" -- so honouring it puts the file where a relocated grok reads. Herdr also honours a `GROK_CONFIG_DIR`, and its own comment says the grok CLI does not read that one; Sidecar does not follow it, for the same reason it does not follow Antigravity's or Cursor's.

func GrokPaths added in v1.14.0

func GrokPaths(env Env) []string

GrokPaths returns the paths the grok adapter inspects and touches.

func HermesHome added in v1.14.0

func HermesHome(env Env) string

HermesHome resolves Hermes's home directory the way Hermes does: $HERMES_HOME when it is set, ~/.hermes otherwise.

The trim is Sidecar's own and is deliberate, for the reason agentsession.PiAgentDir records: a variable somebody exported without a value is not a directory named " ".

func HermesInitAsset added in v1.14.0

func HermesInitAsset() string

HermesInitAsset returns the bundled plugin source.

func HermesManifestAsset added in v1.14.0

func HermesManifestAsset() string

HermesManifestAsset returns the bundled plugin manifest.

func HermesPaths added in v1.14.0

func HermesPaths(env Env) []string

HermesPaths returns the paths the Hermes 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 HermesReportArgs added in v1.14.0

func HermesReportArgs(sessionID string) []string

HermesReportArgs builds the exact CLI argv one binding becomes.

It mirrors build_args in the bundled asset. Both exist because the asset must construct argv in Python 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.

There is no --seq and no --source-version, and neither is an omission: a session binding is not a lifecycle report, so it never reaches the sequenced store and the verb accepts neither flag.

func IsAction

func IsAction(s string) bool

IsAction reports whether s names a known action.

func KiloAsset added in v1.14.0

func KiloAsset() string

KiloAsset returns the bundled plugin source.

func KiloPaths added in v1.14.0

func KiloPaths(env Env) []string

KiloPaths returns the paths the Kilo 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 KiloReportArgs added in v1.14.0

func KiloReportArgs(action KiloAction, sessionID string) []string

KiloReportArgs 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.

NEITHER VERB CARRIES --seq, and there is no sequence parameter to pass. The store assigns under the exclusive lock it already takes for the append, which is the only place the read and the write are atomic. The asset's buildArgs carries the full account of why holding a counter here was tried twice on the Pi asset and dropped reports both times.

func KimiHookArgv added in v1.14.0

func KimiHookArgv(h KimiHook) []string

KimiHookArgv is the exact `sidecar agent ...` argv one row invokes, with the binary name omitted so it lines up with what the CLI's own parser is handed.

NEITHER VERB CARRIES --seq. See the package comment above, and PiReportArgs, which carries the full account of why a per-event hook process must let the store assign.

No payload field ever reaches this argv. The session hook passes Kimi's own stdin straight through to --hook-stdin, where a bounded reader takes the two identifiers it wants; the state hooks pass nothing but a lane and a bounded code. Prompt text, tool names, tool arguments and question text never appear on a command line Sidecar wrote.

func KimiHookArgvCorpus added in v1.14.0

func KimiHookArgvCorpus() [][]string

KimiHookArgvCorpus is every argv the installed integration can spawn, in the order the hooks are declared.

It is exported for TestBundledAssetsSpawnArgvTheShippedCLIAccepts in internal/cli, which pushes each one through the real flag parser, the real report construction, agentlifecycle.Validate and an append to a real store. For an asset that is a file of JavaScript that test has to run the file to learn what it spawns; for an asset that is a table of commands the table is the answer, and taking it from here rather than re-deriving it is what makes the test about the shipped bytes.

func KimiHookCommand added in v1.14.0

func KimiHookCommand(h KimiHook) string

KimiHookCommand is the command string one row installs into config.toml.

It relies on PATH rather than embedding an absolute binary location, for the reason reportSessionCommand states: the hook only matters inside a Sidecar-managed shell, where Sidecar is on PATH by construction, and an embedded path would silently break every hook the next time the binary moved.

Every argv element is a single shell word, so joining on a space round-trips through strings.Fields exactly. TestKimiCommandsRoundTripThroughFields pins that, because the ownership rule below reads a command by splitting it.

func KimiPaths added in v1.14.0

func KimiPaths(env Env) []string

KimiPaths returns the paths the Kimi adapter would inspect and touch.

func Marker

func Marker(a Asset) string

Marker renders the line an asset carries.

func MastracodeHookArgv added in v1.14.0

func MastracodeHookArgv(h MastracodeHook) []string

MastracodeHookArgv is the exact `sidecar agent ...` argv one row invokes, with the binary name omitted so it lines up with what the CLI's own parser is handed, and without the shell guard, which is not part of the argv.

NEITHER VERB CARRIES --seq. See the package comment above, and PiReportArgs, which carries the full account of why a per-event hook process must let the store assign.

No payload field ever reaches this argv. The session hook passes Mastra Code's own stdin straight through to --hook-stdin, where a bounded reader takes the identifier it wants; the state hooks pass nothing but a lane and a bounded code. Prompt text, tool names, tool arguments and the user_message Mastra Code puts on UserPromptSubmit never appear on a command line Sidecar wrote.

func MastracodeHookArgvCorpus added in v1.14.0

func MastracodeHookArgvCorpus() [][]string

MastracodeHookArgvCorpus is every argv the installed integration can spawn, in the order the hooks are declared.

It is exported for TestBundledAssetsSpawnArgvTheShippedCLIAccepts in internal/cli, which pushes each one through the real flag parser, the real report construction, agentlifecycle.Validate and an append to a real store. For an asset that is a file of JavaScript that test has to run the file to learn what it spawns; for an asset that is a table of commands the table is the answer, and taking it from here rather than re-deriving it is what makes the test about the shipped bytes.

func MastracodeHookCommand added in v1.14.0

func MastracodeHookCommand(h MastracodeHook) string

MastracodeHookCommand is the command string one row installs into hooks.json.

Mastra Code runs it through `/bin/sh -c`, which is what makes the fail-open guard on a blocking event expressible at all.

It relies on PATH rather than embedding an absolute binary location, for the reason reportSessionCommand states: the hook only matters inside a Sidecar-managed shell, where Sidecar is on PATH by construction, and an embedded path would silently break every hook the next time the binary moved.

func MastracodePaths added in v1.14.0

func MastracodePaths(env Env) []string

MastracodePaths returns the paths the Mastra Code adapter would inspect and touch.

func OmpAsset added in v1.14.0

func OmpAsset() string

OmpAsset returns the bundled extension source.

func OmpPaths added in v1.14.0

func OmpPaths(env Env) []string

OmpPaths returns the paths the OMP 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 OmpReportArgs added in v1.14.0

func OmpReportArgs(action OmpAction, sessionID string) []string

OmpReportArgs 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. A timer instruction is not an argv and returns none; the runtime switches on the kind before it ever gets here.

NEITHER VERB CARRIES --seq, and there is no sequence parameter to pass. `agent report-session` never had the flag. `agent report` has it and it is omitted, which is what its own help names as the right thing for a per-event hook process to do: the store assigns under the exclusive lock it already takes for the append (lifecyclestore.AppendNext), which is the only place the read and the write are atomic. Upstream numbers every message it sends, seeded from the clock; Sidecar's store bounds the field at MaxSequence and that seed is about 1600x over it, which is how every Pi report was silently rejected once already.

The blocked label, the question text and the provider error string are all deliberately absent from every argv: they are unbounded text authored by a model or a provider, and nothing but lanes, bounded codes and conversation identifiers goes over this wire.

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 PiAsset added in v1.13.0

func PiAsset() string

PiAsset returns the bundled extension source.

func PiPaths added in v1.13.0

func PiPaths(env Env) []string

PiPaths returns the paths the Pi 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 PiReportArgs added in v1.13.0

func PiReportArgs(action PiAction, sessionID string) []string

PiReportArgs 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.

NEITHER VERB CARRIES --seq, and there is no sequence parameter to pass. `agent report-session` never had the flag. `agent report` has it and it is omitted, which is what its own help names as the right thing for a per-event hook process to do: the store assigns under the exclusive lock it already takes for the append (lifecyclestore.AppendNext), which is the only place the read and the write are atomic.

The asset held a counter twice and dropped reports both times -- opening at zero dropped a reloaded instance's reports, and seeding at Date.now()*1000 dropped every report by exceeding MaxSequence -- and both were silent because reports spawn with stdio "ignore". The asset's buildArgs carries the full account. What matters here is that this mirror has no sequence to drift on.

The blocked label is deliberately absent from every argv: it is unbounded text authored by another extension, and nothing but lanes, bounded codes and conversation identifiers goes over this wire.

func QoderCLIConfigDir added in v1.14.0

func QoderCLIConfigDir(home, configDir string) string

QoderCLIConfigDir resolves the directory the Qoder CLI keeps its settings in: $QODER_CONFIG_DIR when that names one, ~/.qoder otherwise. The override moves the whole directory rather than being joined under a provider-named child, which is Herdr's config_dir_from_env_or_home rule.

func QoderCLIPaths added in v1.14.0

func QoderCLIPaths(env Env) []string

QoderCLIPaths returns the paths the Qoder CLI adapter inspects and touches.

func QwenHomeDir added in v1.14.0

func QwenHomeDir(home, qwenHome string) string

QwenHome resolves Qwen Code's global directory: $QWEN_HOME when that names one, ~/.qwen otherwise. It is Qwen's own documented override -- Storage's getGlobalQwenDir resolves it in place of ~/.qwen -- so honouring it is what finds a relocated Qwen and what lets a proof run redirect the provider.

func QwenPaths added in v1.14.0

func QwenPaths(env Env) []string

QwenPaths returns the paths the Qwen adapter inspects and touches.

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.

func SessionHookArgvCorpus added in v1.14.0

func SessionHookArgvCorpus() [][]string

SessionHookArgvCorpus is every argv the installed session-identity entries can spawn, one row per event each registered provider installs under.

Every event spawns the identical command -- the payload on stdin is what differs, and the CLI never sees the event name as an argument -- so the rows for one provider repeat. That repetition is the point for Devin: six entries mean six processes, and a change that made one of them spawn something the CLI refuses would fail here.

It is exported for TestBundledAssetsSpawnArgvTheShippedCLIAccepts in internal/cli, which pushes each one through the real flag parser and the real kind resolution. The argv is read out of each adapter's canonical asset -- the bytes an install writes -- rather than rebuilt from the provider id, because a test about what the shipped entry spawns has to read the shipped entry. That is the same reason KimiHookArgvCorpus reads its table rather than a copy of it.

The one piece of shell any of these commands carries is a trailing `; printf ...`, which Antigravity's stdout contract requires. Splitting on the first `;` is therefore the whole of the shell parsing needed here, and TestASessionHookCommandIsOneInvocationPlusAtMostOneSuffix pins that it stays that way.

func SessionHookArgvCorpusFor added in v1.14.0

func SessionHookArgvCorpusFor(provider string) [][]string

SessionHookArgvCorpusFor is one registered provider's rows of that corpus, for a test that wants to name the provider a failure belongs to.

func SessionHookProviders added in v1.14.0

func SessionHookProviders() []string

SessionHookProviders names every provider whose integration is one of these session-identity hook entries, in registration order.

func UpstreamAssetBytes added in v1.12.0

func UpstreamAssetBytes(name string) ([]byte, error)

UpstreamAssetBytes reads one vendored file by its path relative to upstream/.

func UpstreamAssets added in v1.12.0

func UpstreamAssets() (fs.FS, error)

UpstreamAssets returns the vendored Herdr integration assets as a filesystem rooted at the upstream directory, so a caller opens "claude/herdr-agent-state.sh" rather than "upstream/claude/herdr-agent-state.sh".

The embed itself costs nothing at init; only this sub-filesystem is built, and only on first use, per the startup-latency rule.

func UpstreamLockJSON added in v1.12.0

func UpstreamLockJSON() []byte

UpstreamLockJSON returns the raw upstream.lock.json bytes.

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 AntigravityAdapter added in v1.14.0

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

AntigravityAdapter installs Sidecar's Antigravity session-identity hook.

func NewAntigravityAdapter added in v1.14.0

func NewAntigravityAdapter() AntigravityAdapter

NewAntigravityAdapter returns the adapter this build ships.

func (AntigravityAdapter) Assets added in v1.14.0

func (a AntigravityAdapter) Assets() []Asset

Assets returns the one entry asset this integration installs.

It is OwnsEntry for every one of them, including grok, whose file Sidecar is the only writer of. Declaring OwnsFile there would say "every byte here is Sidecar's", and the consequence of that claim is that uninstall deletes the file: a user who added a hook of their own beside Sidecar's, in a file named after Sidecar, would lose it. The entry rule costs nothing and cannot do that.

func (AntigravityAdapter) Inspect added in v1.14.0

func (a AntigravityAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (AntigravityAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (AntigravityAdapter) Provider added in v1.14.0

func (a AntigravityAdapter) Provider() string

func (AntigravityAdapter) Source added in v1.14.0

func (a AntigravityAdapter) Source() string

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"`
	// CommentPrefix is the comment syntax the marker line is written in, for
	// an [OwnsFile] asset whose file is not JavaScript. Empty means "//",
	// which is what every asset shipped before a Python one existed uses.
	//
	// It is a property of the asset rather than a per-adapter rule for the
	// same reason [Ownership] is: [inspectFile] decides ownership for every
	// provider through one code path, and a second marker syntax reached by
	// asking which adapter is calling would be a rule that lives in the
	// caller. The sentinel itself never changes; only the characters that
	// make it a comment in that file's language do.
	CommentPrefix string `json:"commentPrefix,omitempty"`
	// 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 CopilotAdapter added in v1.14.0

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

CopilotAdapter installs Sidecar's Copilot session-identity hook.

func NewCopilotAdapter added in v1.14.0

func NewCopilotAdapter() CopilotAdapter

NewCopilotAdapter returns the adapter this build ships.

func (CopilotAdapter) Assets added in v1.14.0

func (a CopilotAdapter) Assets() []Asset

Assets returns the one entry asset this integration installs.

It is OwnsEntry for every one of them, including grok, whose file Sidecar is the only writer of. Declaring OwnsFile there would say "every byte here is Sidecar's", and the consequence of that claim is that uninstall deletes the file: a user who added a hook of their own beside Sidecar's, in a file named after Sidecar, would lose it. The entry rule costs nothing and cannot do that.

func (CopilotAdapter) Inspect added in v1.14.0

func (a CopilotAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (CopilotAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (CopilotAdapter) Provider added in v1.14.0

func (a CopilotAdapter) Provider() string

func (CopilotAdapter) Source added in v1.14.0

func (a CopilotAdapter) Source() string

type CursorAdapter added in v1.14.0

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

CursorAdapter installs Sidecar's Cursor session-identity hook.

func NewCursorAdapter added in v1.14.0

func NewCursorAdapter() CursorAdapter

NewCursorAdapter returns the adapter this build ships.

func (CursorAdapter) Assets added in v1.14.0

func (a CursorAdapter) Assets() []Asset

Assets returns the one entry asset this integration installs.

It is OwnsEntry for every one of them, including grok, whose file Sidecar is the only writer of. Declaring OwnsFile there would say "every byte here is Sidecar's", and the consequence of that claim is that uninstall deletes the file: a user who added a hook of their own beside Sidecar's, in a file named after Sidecar, would lose it. The entry rule costs nothing and cannot do that.

func (CursorAdapter) Inspect added in v1.14.0

func (a CursorAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (CursorAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (CursorAdapter) Provider added in v1.14.0

func (a CursorAdapter) Provider() string

func (CursorAdapter) Source added in v1.14.0

func (a CursorAdapter) Source() string

type DevinAdapter added in v1.14.0

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

DevinAdapter installs Sidecar's Devin session-identity hook entries.

func NewDevinAdapter added in v1.14.0

func NewDevinAdapter() DevinAdapter

NewDevinAdapter returns the adapter this build ships.

func (DevinAdapter) Assets added in v1.14.0

func (a DevinAdapter) Assets() []Asset

Assets returns the one entry asset this integration installs.

It is OwnsEntry for every one of them, including grok, whose file Sidecar is the only writer of. Declaring OwnsFile there would say "every byte here is Sidecar's", and the consequence of that claim is that uninstall deletes the file: a user who added a hook of their own beside Sidecar's, in a file named after Sidecar, would lose it. The entry rule costs nothing and cannot do that.

func (DevinAdapter) Inspect added in v1.14.0

func (a DevinAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (DevinAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (DevinAdapter) Provider added in v1.14.0

func (a DevinAdapter) Provider() string

func (DevinAdapter) Source added in v1.14.0

func (a DevinAdapter) Source() string

type DroidAdapter added in v1.14.0

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

DroidAdapter installs Sidecar's Droid session-identity hook entry.

func NewDroidAdapter added in v1.14.0

func NewDroidAdapter() DroidAdapter

NewDroidAdapter returns the adapter this build ships.

func (DroidAdapter) Assets added in v1.14.0

func (a DroidAdapter) Assets() []Asset

Assets returns the one entry asset this integration installs.

It is OwnsEntry for every one of them, including grok, whose file Sidecar is the only writer of. Declaring OwnsFile there would say "every byte here is Sidecar's", and the consequence of that claim is that uninstall deletes the file: a user who added a hook of their own beside Sidecar's, in a file named after Sidecar, would lose it. The entry rule costs nothing and cannot do that.

func (DroidAdapter) Inspect added in v1.14.0

func (a DroidAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (DroidAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (DroidAdapter) Provider added in v1.14.0

func (a DroidAdapter) Provider() string

func (DroidAdapter) Source added in v1.14.0

func (a DroidAdapter) Source() string

type Env

type Env struct {
	// Home is $HOME.
	Home string
	// ConfigHome is $XDG_CONFIG_HOME when set, and empty otherwise.
	ConfigHome string
	// PiAgentDir is $PI_CODING_AGENT_DIR when set, and empty otherwise.
	//
	// It is a field rather than a general environment accessor for the same
	// reason ConfigHome is: an adapter that read os.Getenv directly would make
	// every test in this package depend on the developer's own environment, and
	// the installer suite's whole premise is that it runs inside t.TempDir and
	// can be run twice. Empty means "no override", which is also what a test
	// that never sets it gets.
	PiAgentDir string
	// KiloConfigDir is $KILO_CONFIG_DIR when set, and empty otherwise.
	//
	// A field for the same reason PiAgentDir is one: an adapter reading
	// os.Getenv directly would make every test in this package depend on the
	// developer's own environment. Empty means "no override", which is also what
	// a test that never sets it gets.
	KiloConfigDir string
	// KimiCodeHome is $KIMI_CODE_HOME when set, and empty otherwise. It is Kimi
	// Code CLI's own documented override for its whole data directory, so
	// honouring it is what lets a relocated Kimi be found — and what lets a
	// proof run redirect the provider away from the user's real ~/.kimi-code.
	KimiCodeHome string
	// OmpConfigDir is $PI_CONFIG_DIR when set, and empty otherwise. It is OMP's
	// own override for the NAME of its config directory under $HOME, defaulting
	// to ".omp" — not a path, and not Pi's variable. Pi has no PI_CONFIG_DIR at
	// all; the spelling is a legacy of OMP being a rebranded fork.
	//
	// OMP's whole-directory override is PI_CODING_AGENT_DIR, which it shares with
	// Pi, so [Env.PiAgentDir] carries that one for both adapters. That sharing is
	// the collision OmpAdapter refuses.
	OmpConfigDir string
	// OmpProfile and OmpProfileSet are $OMP_PROFILE, and the second field is not
	// redundant. OMP consults $PI_PROFILE only when OMP_PROFILE is not set at
	// all, so an OMP_PROFILE exported with an empty value selects the default
	// profile and suppresses PI_PROFILE — and which profile is active decides
	// which directory the extension has to be installed into, so the difference
	// between "empty" and "absent" is the difference between installing where OMP
	// looks and installing where it does not.
	OmpProfile    string
	OmpProfileSet bool
	// PiProfile is $PI_PROFILE, OMP's legacy fallback for the same setting. It is
	// read by OMP, not by Pi.
	PiProfile string
	// CopilotHome is $COPILOT_HOME when set, and empty otherwise. It is the
	// override Herdr reads for GitHub Copilot CLI's configuration directory.
	// Unlike every other override in this struct it has NOT been checked
	// against a released provider binary, because Copilot is not installed on
	// any machine Sidecar has surveyed; the capability entry records that.
	CopilotHome string
	// GrokHome is $GROK_HOME when set, and empty otherwise. It is grok's own
	// variable for its configuration home -- the shipped binary carries the
	// string and the error "no user grok home (set $GROK_HOME or $HOME)" -- so
	// honouring it is what puts Sidecar's hook file where a relocated grok
	// reads, and what lets a proof run redirect the provider.
	GrokHome string
	// HermesHome is $HERMES_HOME when set, and empty otherwise. It is Hermes
	// Agent's own override for its whole home directory: hermes_constants.py's
	// get_hermes_home reads the variable and falls back to ~/.hermes, and every
	// other copy in that codebase imports it, so honouring it is what puts the
	// plugin where a relocated Hermes reads and what lets a proof run redirect
	// the provider away from the maintainer's real tree.
	HermesHome string
	// ClaudeConfigDir is $CLAUDE_CONFIG_DIR when set, and empty otherwise. It
	// is Claude Code's own override for its whole configuration home: the
	// binary resolves that home as the variable's value, falling back to
	// $HOME/.claude, so an installer that reads only $HOME writes into a
	// directory a relocated Claude never reads.
	ClaudeConfigDir string
	// QoderConfigDir is $QODER_CONFIG_DIR when set, and empty otherwise. It is
	// the variable Herdr's qodercli_dir consults, and Qoder's own published
	// hooks reference does not name it, so honouring it is a courtesy to a
	// relocated install rather than a proved lever. The capability entry says
	// so. Empty means "no override", which is also what a test that never sets
	// it gets.
	QoderConfigDir string
	// QwenHome is $QWEN_HOME when set, and empty otherwise. It is Qwen Code's
	// own documented override for its whole global directory -- Storage's
	// getGlobalQwenDir resolves it in place of ~/.qwen -- so honouring it is
	// what finds a relocated Qwen and what lets a proof run redirect the
	// provider. Empty means "no override", which is also what a test that never
	// sets it gets.
	QwenHome 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 GrokAdapter added in v1.14.0

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

GrokAdapter installs Sidecar's grok session-identity hook.

func NewGrokAdapter added in v1.14.0

func NewGrokAdapter() GrokAdapter

NewGrokAdapter returns the adapter this build ships.

func (GrokAdapter) Assets added in v1.14.0

func (a GrokAdapter) Assets() []Asset

Assets returns the one entry asset this integration installs.

It is OwnsEntry for every one of them, including grok, whose file Sidecar is the only writer of. Declaring OwnsFile there would say "every byte here is Sidecar's", and the consequence of that claim is that uninstall deletes the file: a user who added a hook of their own beside Sidecar's, in a file named after Sidecar, would lose it. The entry rule costs nothing and cannot do that.

func (GrokAdapter) Inspect added in v1.14.0

func (a GrokAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (GrokAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (GrokAdapter) Provider added in v1.14.0

func (a GrokAdapter) Provider() string

func (GrokAdapter) Source added in v1.14.0

func (a GrokAdapter) Source() string

type HermesAdapter added in v1.14.0

type HermesAdapter struct{}

HermesAdapter installs Sidecar's Hermes session-identity plugin.

func (HermesAdapter) Assets added in v1.14.0

func (HermesAdapter) Assets() []Asset

Assets returns the three units this integration installs, in the order a surface should show them: the plugin, its manifest, and the line that turns the plugin on.

func (HermesAdapter) Inspect added in v1.14.0

func (a HermesAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (HermesAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (HermesAdapter) Provider added in v1.14.0

func (HermesAdapter) Provider() string

func (HermesAdapter) Source added in v1.14.0

func (HermesAdapter) Source() string

type HermesGate added in v1.14.0

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

HermesGate decides which hook invocations bind a session.

The zero value is ready. `session` is the last id bound and exists only to suppress an exact repeat; see the note on _Reporter in the asset for why suppression belongs to the transport half.

func (*HermesGate) Bind added in v1.14.0

func (g *HermesGate) Bind(hook HermesHook) string

Bind returns the session id this hook should bind, or "" for none.

func (*HermesGate) Session added in v1.14.0

func (g *HermesGate) Session() string

Session returns the session id the gate has bound.

type HermesHook added in v1.14.0

type HermesHook struct {
	// Name is the Hermes hook name, e.g. "on_session_start".
	Name string
	// Platform is the `platform` kwarg. Absent is the empty string, which is
	// what the tool hooks pass and is why they bind nothing.
	Platform string
	// SessionID is the `session_id` kwarg.
	SessionID string
}

HermesHook is one flattened Hermes plugin hook invocation.

It carries only what the gate reads: which hook fired, the platform Hermes is driving, and the session id. No message content ever reaches this type, so no gate bug can leak any -- `user_message` and `conversation_history` arrive in pre_llm_call's kwargs on the Python side and are never read there either.

type KiloAction added in v1.14.0

type KiloAction struct {
	Kind   agentlifecycle.Kind
	State  agentactivity.State
	Reason agentlifecycle.ReasonCode
	// SessionID is the reference a KindSession action binds. Kilo reports an id
	// and never a transcript path, so there is no path variant here.
	SessionID string
}

KiloAction is one report the handler wants made.

type KiloAdapter added in v1.14.0

type KiloAdapter struct{}

KiloAdapter installs Sidecar's Kilo lifecycle plugin.

func (KiloAdapter) Assets added in v1.14.0

func (KiloAdapter) Assets() []Asset

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

func (KiloAdapter) Inspect added in v1.14.0

func (a KiloAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (KiloAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (KiloAdapter) Provider added in v1.14.0

func (KiloAdapter) Provider() string

func (KiloAdapter) Source added in v1.14.0

func (KiloAdapter) Source() string

type KiloEvent added in v1.14.0

type KiloEvent struct {
	// Type is the bus event name, or the literal "chat.message" for the hook of
	// that name. Kilo has no bus event called chat.message, so the two cannot
	// collide.
	Type string
	// SessionID is properties.sessionID, when the event carried one.
	SessionID string
	// StatusType is properties.status.type, the shape Kilo actually emits.
	StatusType string
	// StatusString is properties.status when the provider sends a bare string.
	//
	// Both shapes are modelled because upstream's asset reads only the second and
	// Kilo only sends the first: keeping them apart is what lets a fixture drive
	// the bug and the fix separately rather than asserting them by prose.
	StatusString string
}

KiloEvent is one flattened Kilo plugin event.

It carries only what the mapping reads: the event type, the session id, and the raw session.status value. No message content ever reaches this type, so no handler bug can leak any.

type KiloHandler added in v1.14.0

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

KiloHandler maps Kilo's plugin events onto lifecycle reports.

The zero value is ready.

func (*KiloHandler) Handle added in v1.14.0

func (h *KiloHandler) Handle(ev KiloEvent) []KiloAction

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

func (*KiloHandler) Session added in v1.14.0

func (h *KiloHandler) Session() string

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

type KimiAdapter added in v1.14.0

type KimiAdapter struct{}

KimiAdapter installs Sidecar's Kimi lifecycle hooks.

func (KimiAdapter) Assets added in v1.14.0

func (KimiAdapter) Assets() []Asset

Assets returns the single entry asset this integration installs.

Content is the canonical block Sidecar would write into an empty tree, which for an OwnsEntry asset is a description of the entry rather than something ever written verbatim over a user's file.

func (KimiAdapter) Inspect added in v1.14.0

func (a KimiAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (KimiAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (KimiAdapter) Provider added in v1.14.0

func (KimiAdapter) Provider() string

func (KimiAdapter) Source added in v1.14.0

func (KimiAdapter) Source() string

type KimiHook added in v1.14.0

type KimiHook struct {
	// Event is the Kimi hook event name.
	Event string
	// Matcher is Kimi's regular expression over the event's target, or empty
	// for "every target", which is how Kimi spells an absent matcher key.
	Matcher string
	// State is the lane this event reports, or empty for the session hook,
	// which reports a conversation reference rather than a lane.
	State agentactivity.State
	// Reason is the bounded reason code the report carries.
	Reason agentlifecycle.ReasonCode
	// Why records what this row means, in one line, so a reader of the
	// installed config.toml block is not left to infer it from an event name.
	Why string
}

KimiHook is one row of the provider half: which Kimi event, filtered by which matcher, becomes which Sidecar report.

func KimiHooks added in v1.14.0

func KimiHooks() []KimiHook

KimiHooks returns the provider half, copied so a caller cannot reorder the package's own table.

func (KimiHook) Session added in v1.14.0

func (h KimiHook) Session() bool

Session reports whether this row binds a conversation rather than a lane.

type MastracodeAdapter added in v1.14.0

type MastracodeAdapter struct{}

MastracodeAdapter installs Sidecar's Mastra Code lifecycle hooks.

func (MastracodeAdapter) Assets added in v1.14.0

func (MastracodeAdapter) Assets() []Asset

Assets returns the single entry asset this integration installs.

Content is the canonical hooks.json Sidecar would write into an empty tree, which for an OwnsEntry asset is a description of the entries rather than something ever written verbatim over a user's file.

func (MastracodeAdapter) Inspect added in v1.14.0

func (a MastracodeAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (MastracodeAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (MastracodeAdapter) Provider added in v1.14.0

func (MastracodeAdapter) Provider() string

func (MastracodeAdapter) Source added in v1.14.0

func (MastracodeAdapter) Source() string

type MastracodeHook added in v1.14.0

type MastracodeHook struct {
	// Event is the Mastra Code hook event name.
	Event string
	// State is the lane this event reports, or empty for the session hook,
	// which reports a conversation reference rather than a lane.
	State agentactivity.State
	// Reason is the bounded reason code the report carries.
	Reason agentlifecycle.ReasonCode
	// Why records what this row means, in one line. It is installed as the
	// entry's `description`, which Mastra Code's own `/hooks` command prints, so
	// a user looking at what a tool added to their configuration is told what
	// each row is for without reading Sidecar's source.
	Why string
}

MastracodeHook is one row of the provider half: which Mastra Code event becomes which Sidecar report.

func MastracodeHooks added in v1.14.0

func MastracodeHooks() []MastracodeHook

MastracodeHooks returns the provider half, copied so a caller cannot reorder the package's own table.

func (MastracodeHook) Blocking added in v1.14.0

func (h MastracodeHook) Blocking() bool

Blocking reports whether Mastra Code would read a non-zero exit from this row's command as a refusal of the agent's own work.

func (MastracodeHook) Session added in v1.14.0

func (h MastracodeHook) Session() bool

Session reports whether this row binds a conversation rather than a lane.

type OmpAction added in v1.14.0

type OmpAction struct {
	// Kind is the lifecycle kind for a report or a binding, and empty for a timer
	// instruction, which Timer names instead.
	Kind   agentlifecycle.Kind
	State  agentactivity.State
	Reason agentlifecycle.ReasonCode
	// SessionPath and SessionID are the reference a KindSession action binds.
	// Exactly one is set: a path identifies the transcript a restore would
	// resume, which an id alone does not, so a path wins when both are known.
	SessionPath string
	SessionID   string
	// Timer is OmpActionSchedule or OmpActionCancel for a timer instruction, and
	// empty otherwise.
	Timer OmpActionKind
	// TimerName is "idle" or "retry" on a schedule.
	TimerName string
	// DelayMS is the schedule's delay.
	DelayMS int
}

OmpAction is one thing the handler wants done.

It is a report, a session binding, or a timer instruction. The timer instructions exist because this provider's mapping has a clock in it and a pure function may not: the mapping decides when a timer should be armed and the runtime owns the setTimeout, so a fixture can drive the debounced idle and the retry admission deterministically in both implementations.

type OmpActionKind added in v1.14.0

type OmpActionKind string

OmpActionKind distinguishes the two things the mapping can ask the runtime to do that are not a report.

const (
	// OmpActionSchedule arms one of the two timers.
	OmpActionSchedule OmpActionKind = "schedule"
	// OmpActionCancel disarms both.
	OmpActionCancel OmpActionKind = "cancel"
)

type OmpAdapter added in v1.14.0

type OmpAdapter struct{}

OmpAdapter installs Sidecar's OMP lifecycle extension.

func (OmpAdapter) Assets added in v1.14.0

func (OmpAdapter) Assets() []Asset

Assets returns the bundled extension with the identity a marker check compares against.

func (OmpAdapter) Inspect added in v1.14.0

func (a OmpAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (OmpAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (OmpAdapter) Provider added in v1.14.0

func (OmpAdapter) Provider() string

func (OmpAdapter) Source added in v1.14.0

func (OmpAdapter) Source() string

type OmpEvent added in v1.14.0

type OmpEvent struct {
	// Type is the OMP event name -- session_start, session_switch, agent_start,
	// agent_end, tool_approval_requested, tool_approval_resolved,
	// tool_execution_start, tool_execution_end, session_shutdown -- or one of the
	// two synthetic names the mapping's own timers re-enter through, idle_timer
	// and retry_timer, or "blocked" for the untyped event-bus channel.
	Type string
	// Reason is session_switch's reason (new, resume, fork) and
	// tool_approval_requested's optional human label.
	Reason string
	// HasUI is ctx.hasUI, and it is the TUI gate. It is a tri-state because an
	// absent value is not a claim that the session has a UI.
	HasUI *bool
	// Idle is ctx.isIdle(), a tri-state on purpose: an absent isIdle is unknown,
	// and unknown must not open a turn.
	Idle *bool
	// SessionPath and SessionID are ctx.sessionManager's two answers.
	SessionPath string
	SessionID   string
	// Tool is the toolName on the four tool events.
	Tool string
	// Question is the first question text on an `ask` tool execution. It is used
	// only as a suppression key and is never transmitted.
	Question string
	// BlockedActive and BlockedLabel are the payload of the blocked bus channel.
	BlockedActive bool
	BlockedLabel  string
	// WillContinue is agent_end's flag, a tri-state because an older OMP build
	// omits the field entirely and that is not the same as "no continuation".
	WillContinue *bool
	// StopReason and ErrorMessage are the last assistant message's, read for the
	// retry classifier and for nothing else.
	StopReason   string
	ErrorMessage string
}

OmpEvent is one flattened OMP extension event.

It carries only what the mapping reads: a few of the events' own fields, and the three parts of `ctx` the asset touches. No message content, tool argument, tool result or file content ever reaches this type, so no handler bug can leak any. The two error fields are the exception that proves the rule: they are the last assistant message's stop reason and error string, they exist only so the retry classifier can run, and neither is ever put into an argv.

type OmpHandler added in v1.14.0

type OmpHandler struct {
	// IdleDebounceMS and RetryGraceMS override the defaults. Zero means the
	// default, which is why they are not settable to zero here -- the asset's own
	// environment lever can set zero, and this mirror does not need to, since a
	// replay never waits for a timer.
	IdleDebounceMS int
	RetryGraceMS   int
	// contains filtered or unexported fields
}

OmpHandler maps OMP's extension events onto lifecycle reports.

The zero value is ready and uses upstream's default durations. Every field is upstream's, because the ladder they feed is upstream's.

func (*OmpHandler) Handle added in v1.14.0

func (h *OmpHandler) Handle(ev OmpEvent) []OmpAction

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

func (*OmpHandler) Session added in v1.14.0

func (h *OmpHandler) Session() string

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

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 PiAction added in v1.13.0

type PiAction struct {
	Kind   agentlifecycle.Kind
	State  agentactivity.State
	Reason agentlifecycle.ReasonCode
	// SessionPath and SessionID are the reference a KindSession action binds.
	// Exactly one is set: a path identifies the transcript a restore would
	// resume, which an id alone does not, so a path wins when both are known.
	SessionPath string
	SessionID   string
}

PiAction is one report the handler wants made.

type PiAdapter added in v1.13.0

type PiAdapter struct{}

PiAdapter installs Sidecar's Pi lifecycle extension.

func (PiAdapter) Assets added in v1.13.0

func (PiAdapter) Assets() []Asset

Assets returns the bundled extension with the identity a marker check compares against.

func (PiAdapter) Inspect added in v1.13.0

func (a PiAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (PiAdapter) Plan added in v1.13.0

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

Plan implements Adapter.

func (PiAdapter) Provider added in v1.13.0

func (PiAdapter) Provider() string

func (PiAdapter) Source added in v1.13.0

func (PiAdapter) Source() string

type PiEvent added in v1.13.0

type PiEvent struct {
	// Type is the Pi event name: session_start, agent_start, agent_settled, or
	// the synthetic "blocked" for the event-bus channel.
	Type string
	// Reason is session_start's own reason: startup, reload, new, resume, fork.
	Reason string
	// Mode is ctx.mode. The TUI gate is on this and not on ctx.hasUI, because
	// an RPC session reports hasUI true while being headless.
	Mode string
	// Idle is ctx.isIdle(), and it is a tri-state on purpose. Pi's isIdle may be
	// absent, and both guards that read it distinguish "not idle" from "unknown":
	// unknown must neither start a turn nor complete one.
	Idle *bool
	// SessionPath and SessionID are ctx.sessionManager's two answers.
	SessionPath string
	SessionID   string
	// BlockedActive and BlockedLabel are the payload of the blocked channel.
	BlockedActive bool
	BlockedLabel  string
}

PiEvent is one flattened Pi extension event.

It carries only what the mapping reads: the event's own reason, and the three fields of `ctx` the asset touches. No message content ever reaches this type, so no handler bug can leak any.

type PiHandler added in v1.13.0

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

PiHandler maps Pi's extension events onto lifecycle reports.

The zero value is ready. Every field is upstream's, because the ladder they feed is upstream's.

func (*PiHandler) Handle added in v1.13.0

func (h *PiHandler) Handle(ev PiEvent) []PiAction

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

func (*PiHandler) Session added in v1.13.0

func (h *PiHandler) Session() string

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

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 PortedFrom added in v1.12.0

type PortedFrom struct {
	// Provider is the Sidecar provider id, matching Adapter.Provider().
	Provider string `json:"provider"`
	// UpstreamID is the Herdr agent id the upstream assets are vendored under,
	// which is what UpstreamLock.Provider is keyed by.
	UpstreamID string `json:"upstream_id"`
	// UpstreamDir is the directory name under Herdr's src/integration/assets.
	UpstreamDir string `json:"upstream_dir"`
	// Version is the HERDR_INTEGRATION_VERSION the port was written against, as
	// a string so UnknownPortedVersion is expressible in the same field.
	Version string `json:"version"`
	// Commit is the Herdr commit carrying that version, when one is known. The
	// sync tool reads the upstream files at this commit to diff them against
	// what it just vendored, so a byte change that upstream did not bump a
	// version for is still visible.
	Commit string `json:"commit,omitempty"`
	// Evidence says where Version and Commit come from. It is prose because the
	// provenance of a port is prose; the point is that a reader can check it.
	Evidence string `json:"evidence"`
}

PortedFrom records the Herdr integration version one Sidecar asset was written against.

func PortedFromProvider added in v1.12.0

func PortedFromProvider(provider string) (PortedFrom, bool)

PortedFromProvider returns one provider's record.

func PortedFromRecords added in v1.12.0

func PortedFromRecords() []PortedFrom

PortedFromRecords returns the provenance of every Sidecar integration asset.

The slice is copied, because it is data the sync tool ranges over and a caller that sorted it in place would reorder the package's own table.

type QoderCLIAdapter added in v1.14.0

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

QoderCLIAdapter installs Sidecar's Qoder CLI session-identity hook entry.

func NewQoderCLIAdapter added in v1.14.0

func NewQoderCLIAdapter() QoderCLIAdapter

NewQoderCLIAdapter returns the adapter this build ships.

func (QoderCLIAdapter) Assets added in v1.14.0

func (a QoderCLIAdapter) Assets() []Asset

Assets returns the one entry asset this integration installs.

It is OwnsEntry for every one of them, including grok, whose file Sidecar is the only writer of. Declaring OwnsFile there would say "every byte here is Sidecar's", and the consequence of that claim is that uninstall deletes the file: a user who added a hook of their own beside Sidecar's, in a file named after Sidecar, would lose it. The entry rule costs nothing and cannot do that.

func (QoderCLIAdapter) Inspect added in v1.14.0

func (a QoderCLIAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (QoderCLIAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (QoderCLIAdapter) Provider added in v1.14.0

func (a QoderCLIAdapter) Provider() string

func (QoderCLIAdapter) Source added in v1.14.0

func (a QoderCLIAdapter) Source() string

type QwenAdapter added in v1.14.0

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

QwenAdapter installs Sidecar's Qwen Code session-identity hook entry.

func NewQwenAdapter added in v1.14.0

func NewQwenAdapter() QwenAdapter

NewQwenAdapter returns the adapter this build ships.

func (QwenAdapter) Assets added in v1.14.0

func (a QwenAdapter) Assets() []Asset

Assets returns the one entry asset this integration installs.

It is OwnsEntry for every one of them, including grok, whose file Sidecar is the only writer of. Declaring OwnsFile there would say "every byte here is Sidecar's", and the consequence of that claim is that uninstall deletes the file: a user who added a hook of their own beside Sidecar's, in a file named after Sidecar, would lose it. The entry rule costs nothing and cannot do that.

func (QwenAdapter) Inspect added in v1.14.0

func (a QwenAdapter) Inspect(env Env) Status

Inspect implements Adapter.

func (QwenAdapter) Plan added in v1.14.0

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

Plan implements Adapter.

func (QwenAdapter) Provider added in v1.14.0

func (a QwenAdapter) Provider() string

func (QwenAdapter) Source added in v1.14.0

func (a QwenAdapter) Source() string

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.

type UpstreamFile added in v1.12.0

type UpstreamFile struct {
	// Path is relative to internal/agentintegration, e.g.
	// "upstream/claude/herdr-agent-state.sh".
	Path string `json:"path"`
	// Origin is the upstream path the bytes came from, or a description of what
	// generated them where Sidecar writes the file itself.
	Origin string `json:"origin"`
	SHA256 string `json:"sha256"`
	Bytes  int    `json:"bytes"`
	// Version is the HERDR_INTEGRATION_VERSION this file declares, or 0 when it
	// declares none. A test file carries no version; a hook asset does.
	Version int `json:"version,omitempty"`
}

UpstreamFile pins one vendored file.

type UpstreamLock added in v1.12.0

type UpstreamLock struct {
	SchemaVersion int                `json:"schema_version"`
	GeneratedAt   string             `json:"generated_at"`
	Herdr         UpstreamLockSource `json:"herdr"`
	// Providers is one entry per directory under src/integration/assets, sorted
	// by agent id.
	Providers []UpstreamProvider `json:"providers"`
	// Files pins everything vendored that does not belong to a provider: the
	// shared asset test at the top of the assets directory, the upstream
	// LICENSE, and the generated NOTICE.
	Files []UpstreamFile `json:"files"`
	Notes []string       `json:"notes,omitempty"`
}

UpstreamLock pins exactly which Herdr integration-asset bytes are vendored and where they came from.

func LoadUpstreamLock added in v1.12.0

func LoadUpstreamLock() (*UpstreamLock, error)

LoadUpstreamLock returns the parsed lock. It is decoded once, on first use, and shared; callers must not mutate the result.

func (*UpstreamLock) File added in v1.12.0

func (l *UpstreamLock) File(path string) (UpstreamFile, bool)

File returns the lock entry for a vendored non-provider file path, such as "upstream/LICENSE".

func (*UpstreamLock) Provider added in v1.12.0

func (l *UpstreamLock) Provider(id string) (UpstreamProvider, bool)

Provider returns the lock entry for a Herdr agent id.

type UpstreamLockSource added in v1.12.0

type UpstreamLockSource struct {
	Repository string `json:"repository"`
	Ref        string `json:"ref"`
	Commit     string `json:"commit,omitempty"`
	SourceDir  string `json:"source_dir,omitempty"`
	// AssetsDir is the upstream directory the tree mirrors.
	AssetsDir string `json:"assets_dir"`
}

UpstreamLockSource pins the Herdr source the assets were read from.

type UpstreamProvider added in v1.12.0

type UpstreamProvider struct {
	// ID is the Herdr agent id, which differs from Directory where Herdr's
	// directory name and its agent id disagree (antigravity_cli is agy).
	ID string `json:"id"`
	// Directory is the directory name under src/integration/assets, preserved
	// as the vendored subdirectory name.
	Directory string `json:"directory"`
	// Version is the HERDR_INTEGRATION_VERSION every file in the directory
	// agrees on, or 0 where none of them declares one.
	Version int            `json:"version"`
	Files   []UpstreamFile `json:"files"`
}

UpstreamProvider is one provider's vendored integration assets.

Jump to

Keyboard shortcuts

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