agent

package
v0.1.4349 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 80 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 agent describes every coding agent magpie can drive: where its config lives, which fields matter (model, effort, …) and which values to offer.

Index

Constants

View Source
const (
	AttributionOn     = "on"
	AttributionOff    = "off"
	AttributionCustom = "custom" // the user's own trailer text: magpie never writes over it
)

Claude Code adds a Co-Authored-By trailer to the commits it makes (9_bishi on X wanted it off). Its own setting for that is attribution.commit in settings.json: unset keeps the trailer, "" hides it, other text replaces it; `attribution: false` hides all attribution, and the deprecated includeCoAuthoredBy: false does until attribution sets commit or pr. The pull request text (attribution.pr) is left alone.

View Source
const (
	TuneCompact  = "compact"            // when the agent compacts its conversation, in tokens
	TuneCache    = "cache_ttl"          // Claude Code: the main conversation's cache, 5m or 1h
	TuneSubCache = "subagent_cache_ttl" // Claude Code: its subagents', workflows' and helpers'
	// Codex (0.163 on): the share of a model's window past which it
	// compacts in the background while the turn goes on, 1–100; its
	// foreground limit stays where it is, as the backstop
	TuneAsync = "async_compact"
)

The settings tune knows.

View Source
const AionUiScheme = "aionui://add-provider?"

AionUiScheme begins every AionUi add-provider link.

View Source
const CherryStudioScheme = "cherrystudio://providers/api-keys?"

CherryStudioScheme begins every Cherry Studio add-provider link.

View Source
const CindyScheme = "cindy://provider/import?"

CindyScheme begins every Cindy import link.

View Source
const ClaudeLaunchID = "claude#launch"

ClaudeLaunchID is the launch file's agent id: claude's lists (ListsFor cuts at #), its stash keys under its own name.

View Source
const CursorLocalID = "cursor-local"

CursorLocalID is the agent's id, which its key names (TokenFor).

View Source
const DesktopTwinID = "claude-desktop#magpie"

DesktopTwinID is the id the library knows Claude Magpie, the isolated Desktop, by.

View Source
const DryRunArg = "agent-disconnect-dry-run"

DryRunArg is the command line's first word for the process that disconnects an agent on a copy of its files (main.go).

View Source
const FollowRemoteEvery = 5 * time.Minute

FollowRemoteEvery is how often a Remote magpie's picks are asked.

View Source
const LodyScheme = "lody://provider/import?"

LodyScheme opens Lody's local-machine provider confirmation dialog.

View Source
const RoutingGroups = "Routing groups"

RoutingGroups is the picker's group of routing groups.

View Source
const ScienceID = gateway.ScienceID

ScienceID is the agent's id.

View Source
const TuneAsyncSource = "async"

TuneAsyncSource is the Source of the background compaction's share.

View Source
const TuneLong = "long"

TuneLong is the Source of a window that is magpie's Long conversations, which Apply and Undo change in magpie's settings, not in the agent's file.

Variables

View Source
var (
	ErrDesktopIsolatedOS = errors.New("Claude Desktop runs in a folder of its own on macOS only")
	ErrDesktopNoApp      = errors.New("Claude Desktop (Claude.app) isn't installed")
)

Why the isolated Desktop can't be turned on.

View Source
var CodexDesktopList func() (b []byte, ok bool)

CodexDesktopList is the list a Codex beside its ChatGPT sign-in is handed, as the file the Codex app reads it from (deskList); ok false while it isn't known. Set to gateway.CodexDesktopCatalog; nil writes none.

View Source
var ErrNoTelemetry = errors.New("magpie knows no switch for this agent's telemetry")

ErrNoTelemetry: the agent has no telemetry switch magpie knows.

View Source
var ErrTelemetryAllOff = errors.New("Settings › Privacy turns off every agent's telemetry; turn that off first")

ErrTelemetryAllOff: an agent's own row while Settings › Privacy turns every agent's telemetry off.

View Source
var Rewired func(id string)

Rewired, when set, is told of an agent that Connect or Disconnect changed: the library gives Codex its servers another way on magpie.

View Source
var Running = func(patterns ...string) bool {
	if runtime.GOOS == "windows" {
		return len(patterns) > 0
	}
	for _, pat := range patterns {
		if err := proc.Command("pgrep", "-f", pat).Run(); err == nil {
			return true
		}
	}
	return false
}

Running reports whether a process whose command line matches any pattern (an extended regexp, as for pgrep -f) is alive. Windows can't be asked what runs, so anything may be: every caller is the advice an agent's own lists need after magpie changed what it reads at start ("restart Codex", "open a new dsh session"), and a Windows that answered no here dropped that advice silently — a model picked in magpie looked like it had done nothing at all. claudeRunning and Pencil's own check already say they can't be told, and say yes for the same reason. A var so tests can say what runs, as claudeRunning is: magpie's own CLI tests printed "restart the Codex app" on a Mac with Codex open, and on every Windows.

Functions

func AgyLaunch added in v0.1.404

func AgyLaunch(model string) string

AgyLaunch is the command that starts agy on magpie's gateway and one of its custom models, in the shell of this system. Its key names agy: its requests go out as Google's Gemini SDK's (User-Agent google-genai-sdk/…), with nothing of agy's own, so the gateway knows them by the key (x-goog-api-key) alone. A command copied before, with the plain token, still reaches magpie.

func AionUiLink(gw string) string

AionUiLink is the link that opens AionUi's add-model form with the gateway at gw as an OpenAI-compatible provider named magpie, keyed so that its requests are counted as AionUi's. AionUi's OpenAI-compatible base URLs end in /v1, as its own OpenAI preset does.

func CLIs added in v0.1.397

func CLIs(wait time.Duration) (out map[string]CLI, pending bool)

CLIs is every detected agent's CLI, as far as it is known within wait; pending says some are still being asked, and will be ready next time.

func CherryStudioLink(gw string) string

CherryStudioLink is the link that opens Cherry Studio's add-provider dialog with the gateway at gw as an OpenAI-compatible provider named magpie, keyed so that its requests are counted as Cherry Studio's.

Cherry Studio reads data as standard base64: before URLSearchParams sees the query it turns a raw + into _ and / into -, and back again after, so URL-safe base64 (whose - and _ mean + and /) would decode wrong. The data is query-escaped, which its URLSearchParams undoes. The base URL ends in /v1, as its own example's does; its formatApiHost keeps a URL that already has a version, and type openai is its OpenAI chat completions endpoint, whose models it lists from <base>/models.

func CindyLink(url string) string

CindyLink is the link that adds the gateway at url to Cindy as the provider Magpie, keyed so that its requests are counted as Cindy's.

func ClassifierStandIn added in v0.1.1393

func ClassifierStandIn(agent, model string) string

ClassifierStandIn is the model Claude Code's auto mode classifier goes to in place of the one it named, while the sonnet tier it named follows a main model that /model has moved since magpie last wrote the tiers. Claude Code 2.1.310 runs the classifier, with CLAUDE_CODE_AUTO_MODE_MODEL unset, on ANTHROPIC_DEFAULT_SONNET_MODEL ($Xe, BB in its bundle), not on the session's model. A pick in /model saves the main model alone, and the tiers following it move only when magpie next looks (Follow), so the first classifier request after a switch named the model before it (CyberCaius on Discord). "" leaves the model as asked. For gateway.ClassifierStandIn.

func ClaudeAttribution

func ClaudeAttribution(home string) string

ClaudeAttribution reads whether Claude Code adds its commit trailer.

func ClaudeAttributionSet

func ClaudeAttributionSet(home string, on bool) error

ClaudeAttributionSet turns Claude Code's commit trailer on (Claude Code's own default: what hid it is taken out) or off (attribution.commit = ""). A trailer text the user wrote is left as it is, whatever is asked.

func ClaudeCacheSet added in v0.1.3202

func ClaudeCacheSet(home, knob, value string) error

ClaudeCacheSet is one of Claude Code's prompt-cache lifetimes as the user picks it in Claude Code's settings, beside its compaction (Linka on Discord: the card offers no way to change a lifetime that is already the cheapest): "5m" or "1h", written where the card writes it (promptCacheTtl, subagentPromptCacheTtl in settings.json), or "" taking the key out, so Claude Code's own default holds. Claude Code reads the variables before the setting (FORCE_PROMPT_CACHING_5M, then CLAUDE_CODE_PROMPT_CACHE_TTL or CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL), so with one set nothing is written. The pick is the user's own: a value the card stashed is forgotten, so its Undo never puts an older one back over it.

func ClaudeLaunch added in v0.1.3147

func ClaudeLaunch(home string) (string, error)

ClaudeLaunch writes the launch file for a start: connected the first time as Connect connects Claude Code (the model it would pick, the tiers following it), brought up to the catalog after that (Sync), the gateway's address and key as they are now, and the blanks. It answers the file's path.

func ClaudeLaunchAfter added in v0.1.3147

func ClaudeLaunchAfter(home string, was ClaudeModelMark) error

ClaudeLaunchAfter is what a claude-magpie session's /model leaves: Claude Code saves a pick there to the user's settings.json, never to a --settings file (tried with 2.1.318). A model of magpie's picked goes to the launch file, for claude-magpie's next session, and the user's file gets its model back while magpie isn't wired into it: a plain `claude` would ask Anthropic for a model only magpie serves. A Claude model of its own (sonnet) is a pick plain claude can run, and stays.

func ClaudeLaunchPath added in v0.1.3147

func ClaudeLaunchPath() string

ClaudeLaunchPath is the settings file `magpie claude run` hands claude.

func CodexAppInstalled

func CodexAppInstalled() bool

CodexAppInstalled says whether the Codex desktop app is installed here and magpie can open it: ChatGPT.app or Codex.app on macOS, the Store app on Windows. Linux's package has no launcher magpie starts.

func CodexDaemonRestarted added in v0.1.1151

func CodexDaemonRestarted()

CodexDaemonRestarted forgets the daemon last found behind, once the user has restarted it.

func CodexModel added in v0.1.2289

func CodexModel(home string) string

CodexModel is the magpie model this machine's Codex config runs (home "" is the user's): the profile's the config picks, else the top-level one, as Codex reads them; "" when Codex runs a model of its own provider. Long conversations can't compact past that model's own window: Codex compacts at 90% of it (zgjfjfl on Discord, 10-31: a relay's gpt-6-A).

func CodexModelNow

func CodexModelNow() string

CodexModelNow is the model this machine's Codex is set to, whoever's it is (gateway.CodexModelNow); "" when it can't be read.

func CodexOwnOnly added in v0.1.1138

func CodexOwnOnly() bool

CodexOwnOnly reports whether the Codex that asks the gateway for its model list there (/backend-api/codex/models) reaches magpie for account failover alone (FailingOver), to be handed only its own models (#1385). That is this machine's Codex; a request doesn't say whether it came from a Codex in a WSL distro instead, so one there connected to magpie (what magpie set on it, or its joined/beside mark in the stash) keeps magpie's models in the list. No distro is probed for it.

func CodexSideModel added in v0.1.1432

func CodexSideModel() string

CodexSideModel is the model this machine's Codex is set to when it is one of magpie's, picked beside its ChatGPT sign-in (SideModel), for the gateway to answer the Codex app's side turns on (gateway.CodexSideModel).

func CodexSideSet added in v0.1.1576

func CodexSideSet(which string) bool

CodexSideSet says whether this machine's Codex config names the model for a side call itself: "memories" for [memories] extract_model or consolidation_model. A config that can't be read counts as set, so the gateway leaves the call as Codex sent it (gateway.CodexSideSet).

func CodexSubAgentsV1Warning added in v0.1.1223

func CodexSubAgentsV1Warning() string

CodexSubAgentsV1Warning is codexSubAgentsV1Warning for the Codex config here, as the Settings row asks it (the page can't reach the config itself). "" when there is no Codex, or no conflict.

func ConnectCodexTwins

func ConnectCodexTwins()

ConnectCodexTwins connects Codex in each running WSL distro when Codex on Windows is connected. The Codex app's work mode on a project whose run environment is WSL starts its app-server inside the distro, on the distro's ~/.codex, not Windows' (the app resolves CODEX_HOME there with `bash -lc 'printf %s "${CODEX_HOME:-$HOME/.codex}"'`): a Codex connected only on Windows listed OpenAI's models alone there (@not_4O4 on X).

It runs once per distro, and not at all for one the user disconnected, one not running (asking a stopped distro starts it), one whose config names a provider or base URL that isn't magpie's, or while Windows' Codex isn't connected. Off Windows there are no distros and nothing happens.

func ConnectsAgents

func ConnectsAgents() map[string]bool

ConnectsAgents reports, by Remote magpie id, whose switch is on.

func CursorLocalLaunch added in v0.1.877

func CursorLocalLaunch(app, gw string) string

CursorLocalLaunch is the command that starts the build at app on the gateway at gw, in the shell of this system. Started so, from a shell, the app has the variables; opened from the Dock or Finder it has only the login shell's.

func DesktopConfigs3p added in v0.1.1156

func DesktopConfigs3p(home string) []string

DesktopConfigs3p are the claude_desktop_config.json files Claude Desktop reads in its 3p mode: there its whole userData is Claude-3p, its MCP servers too (%LOCALAPPDATA%\Claude-3p on Windows, and the MSIX package's; Claude-3p beside Claude elsewhere). The isolated Desktop's Claude-Magpie-3p is not one of them: the library gives it servers of its own (DesktopTwinApp).

func DesktopTwinCode

func DesktopTwinCode(a *Agent) bool

DesktopTwinCode says a is the Claude Code row of Claude Magpie's Code tab folder (#6459) while Claude Magpie is on magpie. That tab runs its Claude Code with the provider managed by the host, so its requests go to magpie through Claude Magpie's own gateway whatever the row's settings.json says: the row isn't "not connected, on its own settings" then (xMopf7RF on X, 0.1.4111: right after Use Claude Magpie it read so, as if Claude Magpie had been left off).

func DropCodexCompactHolds added in v0.1.2289

func DropCodexCompactHolds(home string) error

DropCodexCompactHolds takes those keys out of the config, so Codex compacts where Long conversations says.

func DryRun added in v0.1.780

func DryRun(id string) error

DryRun disconnects an agent in the process DisconnectPreview starts, on the copy under its temporary home.

func DshPatchFiles added in v0.1.182

func DshPatchFiles(dir string) []string

DshPatchFiles are the patch lists of the dsh whose home is dir, as magpie writes them: every profile's (web's first), else config.yaml.

func DshThrough

func DshThrough(a *Agent, prefix string) error

DshThrough points magpie's route in dsh's patch lists (a, DeepSeek Harness) at the gateway through prefix, an address a local proxy takes the gateway's after (billion-context's http://127.0.0.1:8787/bili/), "" for the gateway itself. dsh must be on magpie already. bili's own plugin for dsh (dsh plugin add billion-context) rides proxy settings of dsh's process, which a provider at http://127.0.0.1 never takes; its docs' /bili/ prefix takes any client whose model address can be edited. A sync, a pick and the serving round keep the prefix (dshReach).

func DshURL

func DshURL(a *Agent) string

DshURL is the baseURL of magpie's first route in dsh's connected patch list (a, DeepSeek Harness), "" without one.

func EndCodexFailover added in v0.1.1192

func EndCodexFailover() (ended bool, err error)

EndCodexFailover takes account failover out of this machine's Codex as the magpie serving its gateway quits (EndFailover): Codex goes straight to OpenAI again rather than retrying a gateway that's gone. The app-server codex sessions share read the old base URL as it started and keeps it, and KeepCodexDaemonCurrent ends with magpie, so it is restarted here, when no session is on it (thisisvainxx on X: back on its own config, Codex took "several restarts"). ended says it took failover out: a thread open in the Codex app still sends to the gateway's address, which the caller leaves a relay at (codexrelay).

func FakeWSL added in v0.1.512

func FakeWSL(probes, roots map[string]string) func()

FakeWSL, for other packages' tests, stands in for wsl.exe on any system: each distro named in probes is installed and running, answers the probe with what probes has for it (wslProbeScript()'s output: "home:/ home/me\ndir:.codex\n…") and is opened at roots' folder for it. What magpie remembers of WSL is forgotten, before and after; the returned func puts everything back.

func FakeWSLDrives added in v0.1.2403

func FakeWSLDrives(roots map[string]string) func()

FakeWSLDrives, for other packages' tests, has Windows' drives ("C:") opened at roots' folder for each, where a link in a FakeWSL distro to /mnt/c leads (distro.open); the returned func puts it back.

func FakeWSLRealLinks() (restore func())

FakeWSLRealLinks, for a test on Windows with a real distro behind FakeWSL's root (\\wsl.localhost\<distro>), has the links in it made, read and removed by the real wsl.exe, in that distro alone.

func FakeWSLRuns added in v0.1.2043

func FakeWSLRuns(name string) int

FakeWSLRuns is how many commands magpie ran in FakeWSL's distro name (wsl.exe -d name …), each of which starts a stopped distro.

func FollowRemotePicks

func FollowRemotePicks(ctx context.Context)

FollowRemotePicks puts each connected agent's field that is on a Remote magpie's pick onto that pick's change, at most every FollowRemoteEvery.

func HermesThrough

func HermesThrough(a *Agent, prefix string) error

HermesThrough points magpie's providers in Hermes's configs (a, Hermes) at the gateway through prefix, an address a local proxy takes the gateway's after (billion-context's http://127.0.0.1:8787/bili/), "" for the gateway itself. Hermes must be on magpie already. bili's own plugin for Hermes (bili plugin install hermes) sets HTTPS_PROXY in Hermes's process and nothing else, so a provider at http://127.0.0.1 (magpie's) never passes it; its docs' /bili/ prefix, which bili start answers, takes any client whose address can be edited.

func HermesURL

func HermesURL(a *Agent) string

HermesURL is the base_url of magpie's provider in Hermes's connected config (a, Hermes), "" without one.

func KeepClaudeScience added in v0.1.1238

func KeepClaudeScience(ctx context.Context)

KeepClaudeScience starts the daemon on the gateway, while Claude Science is connected, whenever it isn't running (after a restart of the computer, or after it was stopped), and in place of one running that magpie didn't start or that is older than the program installed now (stale), once no session runs in it. It reads the lock file every few seconds and asks status (most of a second of a 130 MB Bun program) when the lock's pid changed or a minute went by. It does the same for each running WSL distro's Claude Science magpie connected (wslScienceHosts), and never starts a stopped distro.

func KeepCodexDaemonCurrent added in v0.1.1151

func KeepCodexDaemonCurrent(ctx context.Context)

KeepCodexDaemonCurrent restarts this machine's Codex daemon whenever it is behind what Codex reads at start and no codex session is on it, until ctx ends. It looks again when magpie writes a file (what Codex reads is among them), every so often while the daemon is behind, and otherwise only now and then, for another process's write (#3185: a look every 15s woke an idle magpie).

func KeepCodexRolloutsPortable added in v0.1.1303

func KeepCodexRolloutsPortable(ctx context.Context)

KeepCodexRolloutsPortable makes this machine's Codex rollouts portable every so often until ctx ends.

func KeepCursorLocalEnv added in v0.1.885

func KeepCursorLocalEnv(context.Context)

KeepCursorLocalEnv sets the variables again when the gateway is served, with its address now, while Cursor Private Inference is connected: the Mac's launchctl ones are gone after a restart, and the port may have changed. The app takes them when it is next opened.

func KeepDshWired added in v0.1.641

func KeepDshWired(ctx context.Context)

KeepDshWired keeps magpie's route in dsh's patch lists as magpie's catalog is now, for as long as magpie serves the gateway. dsh reads a patch list live, so one left behind by something else writing the file — dsh's own Models page, an older magpie — fails every session there with no such configured model until the route is written again. What is written is magpie's own list, never the model a session starts on.

func KeepFollowingRemote

func KeepFollowingRemote(ctx context.Context, interval time.Duration)

KeepFollowingRemote runs FollowRemotePicks until ctx ends, for a magpie with no app: the app's Library loop runs it there (library.KeepLinked), and a headless `magpie serve` client of a Remote magpie followed its model list and efforts but never a pick changed on the remote (KoiLx0 on X).

func KeepOpenMausBotListed added in v0.1.3297

func KeepOpenMausBotListed(ctx context.Context)

KeepOpenMausBotListed writes magpie's models into OpenMausBot's engine again, while the gateway serves, when OpenMausBot wrote a list over them (ombListStale). The model picked in it stays.

func KeepTelemetryAllOff

func KeepTelemetryAllOff(ctx context.Context)

KeepTelemetryAllOff turns off, while the switch for every agent is on, the telemetry of an agent found since: with no window open to read the state, the gateway's own look.

func KeepTelemetryOff

func KeepTelemetryOff(a *Agent) error

KeepTelemetryOff turns a's telemetry off when the switch for every agent is on and it isn't off yet, marking it as the switch's. It says why it couldn't (a value of the user's own, a file that doesn't read).

func KeyAt added in v0.1.1159

func KeyAt(gw string) string

KeyAt is keyAt, for what else magpie gives an agent that reaches the gateway at gw (the library's MCP servers relayed through it).

func KimiDir added in v0.1.470

func KimiDir(home string) (dir string, legacy bool)

KimiDir is the folder Kimi Code keeps its config.toml in, and whether it is the old kimi-cli's. kimi-cli (1.50 on) hands over to the new Kimi Code, which reads only ~/.kimi-code: it offers to copy ~/.kimi's config over when it first starts, and once that's done never reads ~/.kimi again, so a model written there is one it never sees (#290). ~/.kimi is kimi-cli's only where the new one isn't: no ~/.kimi-code, nor $KIMI_CODE_HOME.

func LodyLink(base string) string

LodyLink offers all supported runtimes. Lody accepts only loopback HTTP and its public attribution token, never a LAN key or a vendor credential.

func MarkWritten added in v0.1.2034

func MarkWritten()

MarkWritten has every TOML, YAML and dotenv line magpie writes that points an agent at it carry a comment saying so and how to undo it (lineNote). A Codex left with openai_base_url on a gateway that no longer ran, after magpie's folders were deleted by hand, failed every turn with nothing in its config naming magpie (Jevik_AI on X). Set by main; tests of an agent's exact bytes run without it.

func MiniMaxDir added in v0.1.535

func MiniMaxDir(home string) string

MiniMaxDir is the folder MiniMax Code keeps its config.yaml in: $MINIMAX_DATA_DIR, the folder its desktop app moved it to, or ~/.minimax (appdir.MiniMaxDirIn).

func ModelIcon added in v0.1.466

func ModelIcon(model string) string

ModelIcon is the logo of a model's maker, known by its id's (or name's) family alone; "" when it isn't one of them.

func MoveAntigravityEfforts added in v0.1.299

func MoveAntigravityEfforts()

MoveAntigravityEfforts does the same for Antigravity's ids at a level (antigravity/gemini-3.7-flash-high → antigravity/gemini-3.7-flash, at high when the agent's effort is unset and it has that one).

func MoveCursorEfforts added in v0.1.297

func MoveCursorEfforts()

MoveCursorEfforts moves an agent set to one of Cursor's ids at an effort (cursor/grok-4.7-low), from before magpie offered each family as one model, to that model (cursor/grok-4.7) spelled the same way, and — when the agent's effort is unset and it has that one — to the effort the id was at. A model the picker doesn't offer is left: the gateway still takes Cursor's id. It runs at start-up; errors are swallowed as RenameLegacy's.

func MoveOffAccountIDs added in v0.1.399

func MoveOffAccountIDs()

MoveOffAccountIDs moves each of the user's providers saved on a subscription's id (provider.OnAccountIDs) to a free one, the agents on it with it, so the subscription is listed once signed in: a "WorkBuddy" key saved as workbuddy before WorkBuddy's plan was a subscription hid it, and signing in to it said "signed in, but magpie can't list it". Run at start-up; errors are swallowed as RenameLegacy's are.

func Newer added in v0.1.397

func Newer(a, b string) bool

Newer says whether version a is after b: by their numbers, then a release after its pre-releases (1.0.87 after 1.0.87-0).

func Notices added in v0.1.1171

func Notices() []string

Notices are the templates of every notice magpie's own agents give.

func OpenAppLink(link string, open func(string) error) error

OpenAppLink hands an app's import link (Cindy's, Lody's, AionUi's, Cherry Studio's) to open, after checking that something here opens it. The system starts the opener and never says whether it found a program, so without the check a click on Add magpie does nothing at all when the app never registered its scheme or was moved since (sungt, 10-29). A check that can't be read is unknown, and the link is handed over anyway.

func OpenCodexApp

func OpenCodexApp(ctx context.Context) error

OpenCodexApp opens the Codex desktop app, which brings its window up when it is running already (Yink88564391 on X). On macOS it opens the bundle whose Info.plist says com.openai.codex; on Windows it starts the Store package's app by its AppUserModelID, as a restart does.

func OpenLody added in v0.1.1489

func OpenLody(link string, open func(string) error) error

OpenLody hands Lody's import link to the Lody installed here. On Linux it runs that Lody with the link itself, as its desktop entry says, which is what xdg-open runs when lody:// is registered: Lody's AppImage makes itself the default only for its own channel's scheme (ai.lody.stable), and leaves lody:// to the desktop database, which nothing builds without update-desktop-database, so xdg-open, gio and a browser turn the link away though Lody is running (Atlas, 10-25: "failed to open uri"). A second Lody passes the link to the running one and quits. With no entry of Lody's, and on macOS and Windows, where Lody's bundle and installer claim lody:// themselves, open opens it.

func Own added in v0.1.1198

func Own(o Option) bool

Own reports whether o is a model the agent reaches on its own, not one of magpie's catalog: what Picks leaves out on the user's word. One magpie's list shows the agent too (Served) is the list's to show or not.

func PenguinRoot added in v0.1.1628

func PenguinRoot(home string) string

PenguinRoot is PenguinHarness's data root under home: $PENGUIN_HOME, else ~/.penguin/data.

func PluginAgentOf added in v0.1.1161

func PluginAgentOf(spec string) string

PluginAgentOf is the id of the agent the plugin spec adds, "" for none.

func PluginErrors added in v0.1.1161

func PluginErrors() map[string]string

PluginErrors is why an agent a plugin adds isn't listed, by plugin spec: its module didn't load, or its id is a built-in agent's.

func PluginPath added in v0.1.1177

func PluginPath(p string) string

PluginPath is a path an agent plugin gives, as it reads its config's: ~ and $VAR expanded against this user's home.

func PortCodexRollouts added in v0.1.1303

func PortCodexRollouts(d time.Duration)

PortCodexRollouts makes this machine's Codex rollouts portable, for up to d: as magpie quits.

func Rekey added in v0.1.1169

func Rekey(as []*Agent) (moved []string, err error)

Rekey sets again those of as, taken by OnGateway before LAN sharing was turned on or off or its key made anew, that reach the gateway from beyond loopback (an agent in a WSL distro under NAT): the key they send there is the sharing key while sharing is on (keyAt), so it changed with it. One connected while nothing was shared kept gateway.Token, which the gateway turns away from beyond loopback, after sharing was turned on for it.

func RelayOpenCodex added in v0.1.2030

func RelayOpenCodex() error

RelayOpenCodex leaves a relay at the gateway's address for the Codex processes running as magpie quits (codexrelay.Start), when the address is this computer's own and Codex is running at all.

func RenameGroup added in v0.1.1725

func RenameGroup(from, to string) ([]string, error)

RenameGroup gives a routing group another id (provider.RenameGroup) and moves the agents on it to group/<to>, as RenameProvider does a provider's: left on group/<from>, each agent named a group magpie no longer has, and the user had to pick the group again in every agent (lucis0116 on X). It answers the agents it moved.

func RenameLegacy

func RenameLegacy()

RenameLegacy rewrites what an older dial left in the agents' files so it says magpie: a model spelled dial/… becomes magpie/… (which also writes the magpie provider entry the agent needs), and then the dial entry, Codex's table and catalog file, and Claude Code's token go. It runs at start-up; once nothing says dial any more it changes nothing. Errors are swallowed on purpose — a file magpie cannot rewrite is one the user can still fix from the picker.

func RenameProvider added in v0.1.125

func RenameProvider(from, to string) ([]string, error)

RenameProvider gives a provider another id (provider.Rename) and moves the agents on one of its models to the same model by the new id, each spelled the way the agent spells it, and what else in their configs names it (RenameRefs). It answers the agents it moved.

func ReopenCodexApp added in v0.1.1334

func ReopenCodexApp(ctx context.Context, bundle string) error

ReopenCodexApp restarts the app-server of the Codex desktop app at bundle; the app starts a new one and its window stays. Only an app the Agents row lists as left on the old list is touched, never a path a request names otherwise.

func Rescan added in v0.1.937

func Rescan()

Rescan forgets what was found of the agents on this machine a while ago, so the next read of them looks again at once: the reader asked for it with the Agents page's refresh (#844), having just installed an agent, or removed one, or changed its settings outside magpie. What is read from an agent's files every time needs nothing forgotten; these are the answers kept for a while because asking was slow (the apps folder, wsl.exe, Alma's server), and where each command was found on PATH (proc.LookPath).

func RestartSwitchedCodexApp added in v0.1.2142

func RestartSwitchedCodexApp(ctx context.Context) error

RestartSwitchedCodexApp restarts the Codex desktop app's app-server after Codex's account was switched, so the app is on the new account (provider.RestartSwitchedCodexApp), and says in the reader's language what went wrong when it didn't.

func RestoreOnQuit

func RestoreOnQuit(as []*Agent) (restored []string, err error)

RestoreOnQuit disconnects each of as that has magpie in its config and that the user hasn't disconnected, and records which for RewireOnStart. An agent that can't be disconnected is left as it is and named in the error; the others go on.

func Rewire added in v0.1.950

func Rewire(as []*Agent) (moved []string, err error)

Rewire puts the gateway's address now into the configs of agents, taken by OnGateway before it moved: each one whose wiring is off now is set again, an agent joined to magpie beside its own models (Codex signed in with ChatGPT) joined again. It says the names of those it moved, and what one it couldn't move failed with. Cursor Private Inference's variables and dsh's routes, which magpie keeps on its own, follow too; Claude Science's daemon, started for the old address, is drift (scienceCheck) and is started again with the rest.

func RewireOnStart

func RewireOnStart(all []*Agent) (rewired []string, err error)

RewireOnStart connects again the agents RestoreOnQuit put back, among all (a list of All()). One connected again by hand meanwhile, or disconnected by the user since, is left as it is. The record is taken out first: an agent that can't be connected is said, not tried at every start.

func ScienceLaunch added in v0.1.1238

func ScienceLaunch(bin, gw string) string

ScienceLaunch is the command that starts the daemon at bin on the gateway at gw, in the shell of this system.

func SetConnectAgents

func SetConnectAgents(id string, on bool)

SetConnectAgents turns the switch of the Remote magpie id on or off. On, the next follow (FollowRemotePicks) is not waited for.

func SetDesktopIsolated

func SetDesktopIsolated(home string, on bool) (string, error)

SetDesktopIsolated turns the isolated Desktop on or off for home. On: Claude Magpie.app is made (made new, with a Claude Code folder of its own: desktopIsoClaudeDefault), and a Desktop on magpie moves there: the user's own Desktop is put back as it was before magpie (desktopOff), and Claude-Magpie-3p gets magpie's 3p mode. Off: the app is taken away, and Claude-Magpie-3p goes off magpie; the wiring goes back to the user's own Desktop only if it came from there (desktopIsolatedFrom), so a twin made beside a Desktop not on magpie never puts that one on it. Claude-Magpie-3p itself, with the chats in it, stays. It returns the app's path when on.

func SetDesktopIsolatedClaude

func SetDesktopIsolatedClaude(home string, on bool) error

SetDesktopIsolatedClaude gives the isolated Desktop's Code tab a Claude Code folder of its own, or takes it back to ~/.claude. On, the folder is made with a settings.json, so magpie writes Desktop's model windows there and the Agents page lists it. Claude Magpie.app, when magpie has made it, is made again with the new folder (or none); a Desktop running from it keeps the one it started with until it is quit and opened again. The folder itself, with what Claude Code keeps in it, stays when turned off.

func SetTelemetryAll

func SetTelemetryAll(off bool) error

SetTelemetryAll saves Settings › Privacy's switch and carries it out: on, every agent found here is turned off; off, each the switch turned off is turned back on. The setting is saved whatever an agent says; the error names each agent that couldn't follow, and why.

func SetToGroup added in v0.1.3374

func SetToGroup(agent, gid string) bool

SetToGroup reports whether magpie set one of the agent's fields to the routing group gid ("group/<id>"), by its id or its model's name (#750), at an effort or not: the user picked that group for the agent. The gateway then keeps a bare name the agent asks for by on the group, rather than on the agent's own subscription. For gateway.SetToGroup.

func SharedModels

func SharedModels() map[string]map[string]string

SharedModels is, by agent id, the catalog ref of each model field of every agent connected here: what another magpie with this one as its provider starts its agents on.

func StandIn added in v0.1.241

func StandIn(agent, model string) string

StandIn is the model Claude Code is set to use in place of one it named that magpie doesn't serve: claude-haiku-4-5-… for a title or a small task goes to its haiku tier's model, and a name of no tier to its main model. For Codex, the model it is set to (codexStandIn), in a WSL distro the distro's config names (wslCodexStandIn). "" when the agent isn't routed through magpie or is neither. For gateway.StandIn.

func StartFakeWSL added in v0.1.2043

func StartFakeWSL(name string)

StartFakeWSL has a distro StopFakeWSL stopped run again, as the user opening a WSL shell does.

func StopFakeWSL added in v0.1.1080

func StopFakeWSL(name string)

StopFakeWSL, for other packages' tests, has FakeWSL's distro name stop, as the user stopping it (wsl --shutdown) does: wsl.exe lists it as not running from now on.

func SyncCatalog added in v0.1.54

func SyncCatalog()

SyncCatalog brings every model list magpie wrote into an agent's files up to the catalog as it is now. It is what catalog.Changed is set to, so a provider saved or removed, or a vendor's list fetched anew, reaches the agents; one already running asks for another round rather than waiting. Errors are left for the picker: a file magpie can't write now is one the next change, or a pick, writes.

func SyncCatalogSettled added in v0.1.1426

func SyncCatalogSettled()

SyncCatalogSettled waits for every SyncCatalogSoon round started so far: a command that saved something ends with the agents' files written.

func SyncCatalogSoon added in v0.1.1426

func SyncCatalogSoon()

SyncCatalogSoon is SyncCatalog behind the caller, which is what catalog.Changed is set to: a group or a provider saved answers at once, and the agents' files follow a moment later. The sync builds every agent's lists and writes the ones that differ. On Windows a file another program holds open refuses the rename over it, and steady.Rename waits half a second on each such file before giving up; in WSL each file is read and written through wsl.exe and \\wsl.localhost. A save that waited on it took seconds now and then on Windows, while an agent was at work (CyberCaius on Discord: 路由组和供应商编辑保存有时候保存会卡很久). A sync already running takes the change in its next round, as SyncCatalog does.

func TakeCodexLeftovers added in v0.1.3099

func TakeCodexLeftovers() (bool, error)

TakeCodexLeftovers takes out of this machine's Codex config what magpie wrote that no Disconnect could name: the base URL at magpie's gateway, and magpie as its provider, where the marks magpie keeps them by are gone with magpie's own files (#3866). It answers whether it changed anything.

func Taken added in v0.1.469

func Taken(p string) bool

Taken reports whether something that isn't a folder is where the folder p, or one it is in, would be: nothing can be written under it.

func TelemetryAllOff

func TelemetryAllOff() bool

TelemetryAllOff says whether Settings › Privacy's switch is on, read without a copy (each poll asks).

func TuneApply added in v0.1.1158

func TuneApply(home, agent, knob, model, value string) error

TuneApply puts value in as an agent's setting, on the user's say. What was there before is kept, the first time only, for TuneUndo. A variable that takes precedence is an error: the setting would change nothing.

func TuneTakeOver

func TuneTakeOver(home, agent string) error

TuneTakeOver is the user's say that magpie sets what Codex's config.toml sets before it, the Locked of TuneRead (sufeng1894 on X: the Usage page's Codex card was locked by a model_auto_compact_token_limit, with no way to adjust it from magpie). The limit moves into Long conversations for Codex (codexLongTakes, as tuneMigrateCodex moves tune's own) and out of the file; a background compaction threshold of the user's in [features.async_compaction] becomes Background compaction's, in Settings, and stays in the file as magpie's. Undo puts both back as they were. Nothing of the user's is taken without this.

func TuneUndo added in v0.1.1158

func TuneUndo(home, agent, knob, model string) error

TuneUndo puts back what a setting was before tune put one in, unless the user has changed it since: then it is theirs, and only forgotten.

func UnwirePlugin added in v0.1.1668

func UnwirePlugin(spec string) error

UnwirePlugin takes magpie out of the config of the agent the plugin spec adds and puts back what the user had, as `magpie <agent> default` does (Disconnect), before the plugin is turned off or removed. The agent is the one listed while the plugin is on, else its module read as it is (a plugin off already); with no module that loads, each file stashed as the plugin's is put back from the stash alone. An agent not on magpie is left as it is.

func WSLInDistro added in v0.1.2851

func WSLInDistro(a *Agent, local string) bool

WSLInDistro is whether local, a path of a's as magpie opens it, is in the distro's own files (under \\wsl.localhost\<distro>), not on a Windows drive a link there leads to: where the distro can make a link magpie reads back.

func WSLKeep added in v0.1.2043

func WSLKeep(name, key, v string)

WSLKeep has magpie remember v under key for the WSL distro name, in wsl.json beside what its probe found, for while the distro is stopped: what another package learnt of the distro's files while it ran (the library's places for each agent there), which it can't read again then without starting it (#3896). Nothing is kept for a distro never found.

func WSLKept added in v0.1.2043

func WSLKept(name, key string) string

WSLKept is what WSLKeep last kept under key for the distro; "" for nothing.

func WSLOpen added in v0.1.2403

func WSLOpen(a *Agent, path string) (string, error)

WSLOpen is path, under the home of a, an agent in a WSL distro, where magpie can open it (distro.open): below a link of the distro's, where the link leads. The error says a link there couldn't be resolved. Any other agent's path is as it is.

func WSLReadlink(local string) (string, bool)

WSLReadlink is where the link at local, a path in a running distro as magpie opens it, leads, as magpie opens that: false when local is in no running distro or isn't a link there. It is asked where Windows can't read the link itself (Readlink fails through \\wsl.localhost).

func WSLRemoveLink(local string) error

WSLRemoveLink takes the link at local, a path in a running distro as magpie opens it, away from inside the distro; what it leads to stays. Anything there but a link is refused.

func WSLRunning added in v0.1.1080

func WSLRunning(distro string) bool

WSLRunning is whether the WSL distro runs now (wslUp); false off Windows. What another package does in a distro on its own, rather than at the user's asking, asks it first.

func WSLSymlink(a *Agent, target, link string) error

WSLSymlink makes link a link to target, both in a's distro as magpie opens them, from inside the distro: a link the agent there follows. A link at link already is replaced; a folder or file there is refused.

func ZedThrough

func ZedThrough(a *Agent, prefix string) error

ZedThrough points Zed's magpie provider (a, Zed) at the gateway through prefix, an address a proxy takes the gateway's after (billion-context's http://127.0.0.1:8787/bili/), "" for the gateway itself, and saves its key for that address in the system's credential store, where Zed looks it up by the address. Zed must be on magpie already.

func ZedURL

func ZedURL(a *Agent) string

ZedURL is the api_url of Zed's magpie provider (a, Zed), "" without one.

Types

type AdminError added in v0.1.1174

type AdminError struct {
	Agent, Prefix, Command, Via string
	Canceled                    bool
	Err                         error
}

AdminError is an install or update that needs an administrator and didn't get one: the prompt declined (Canceled), or none to be had (Err). The command never ran. Agent is what it installs (an agent, or RTK); Prefix the folder only an administrator can change, "" when not known; Via the tool, npm or winget, whose fix is said.

func (*AdminError) Error added in v0.1.1174

func (e *AdminError) Error() string

func (*AdminError) Unwrap added in v0.1.1174

func (e *AdminError) Unwrap() error

type Agent

type Agent struct {
	ID      string
	Name    string
	Icon    string // bundled icon name (internal/gui/assets/icons)
	Aliases []string
	Bin     string // executable name, used for detection
	Dir     string // config directory, used for detection
	Path    string // config file magpie edits
	// Plugin is the spec of the plugin that adds this agent (plugged.go),
	// "" for magpie's own
	Plugin string
	Fields []Field
	Native *NativeConnection
	// Notice, if set, is advice worth showing after a change: agents that
	// read their config once at start-up need a restart to see it.
	Notice func() string
	// UA is what the agent's User-Agent begins with, lower-case: how the
	// gateway tells its requests from others'
	UA []string
	// ListsModels: the agent's own model menu is magpie's models as picked
	// on the Agents page for it (settings.HiddenModels, PickedModels),
	// though no field of its picks among the catalog: the gateway's
	// /v1/models as asked with its key (Cursor Private Inference), or the
	// list magpie writes into its files, magpieModels(id), where its only
	// field puts magpie in its picker (ZCode, Pencil: #1508)
	ListsModels bool
	// NoNames: the agent's own list doesn't name magpie's models as
	// Names in agents' lists says (provider.Labels): magpie hands it the
	// models' ids alone, its format having no name for one (Goose, Hermes,
	// jcode …), it lists no models of magpie's at all (Gemini CLI, Snow),
	// or it reads the gateway's /v1/models itself, whose display_name is
	// the name alone (Empryo, Cursor Private Inference). The setting says
	// so for each one connected, rather than seeming to do nothing.
	NoNames bool
	// Nested: the agent is a part of another one (a Hermes profile,
	// hermes#<name>) that the Library gives its own skills and servers. No
	// list of agents or model picker shows it (DetectedIn leaves it out); its
	// model is a line of the parent's row, and All and Find still reach it.
	Nested bool
	// Sync, for an agent that reads magpie's models from a file of its own
	// rather than asking the gateway, rewrites that list as the catalog is
	// now — where magpie wrote one; nothing else changes (see SyncCatalog).
	Sync func() error
	// ListOnly: Sync does nothing but bring a block of magpie's name in the
	// agent's files up to the catalog. A catalog sync runs it only while
	// the agent is connected (Wired), as its switch on the Agents page
	// says: switched off, nothing of magpie's writes its files. A custom
	// provider the user named magpie in the agent, with a few models picked
	// by hand (yyddbds on Discord, Xiaomi MiMo), was written over with the
	// whole catalog at every start. A list magpie wrote while connected
	// waits, while the agent runs a model of its own, until a model of
	// magpie's is picked again.
	ListOnly bool
	// Unwire, for an agent whose fields' default is the agent as installed
	// rather than what it had before magpie (Codex, Claude Code, Gemini
	// CLI), takes magpie out of its config and puts back what the stash
	// kept: the endpoint, provider and model the user had. Disconnect runs
	// it before the fields' defaults.
	Unwire func() error
	// Restore, for an agent whose files magpie copied aside before its
	// first write (beforeMagpie), puts them back as they were where what
	// Disconnect left says the same. Disconnect runs it last.
	Restore func() error
	// Join, for an agent that can have magpie's models in its own list
	// while it stays on the model it was on (Codex signed in with ChatGPT),
	// connects it so, its model left as its own last pick; false where it
	// can't, and Connect then picks one of magpie's.
	Join func() (bool, error)
	// Joined reports an agent Join connected: magpie is in its config
	// though no field is on one of magpie's models.
	Joined func() bool
	// Beside reports an agent set on one of magpie's models beside its own
	// (Codex by the base URL beside its ChatGPT sign-in), now on one of its
	// own written in by the agent: still connected, as joined (#940), and
	// a pick in the agent rather than drift (#2424).
	Beside func() bool
	// OwnVia is the catalog id magpie serves one of the agent's own models
	// by on a sign-in of the user's, which its model field lists as its
	// own rather than as magpie's ("codex/gpt-5.5" for Codex's gpt-5.5),
	// "" for none: Connect keeps the agent on that model through magpie
	// where it can't Join (#940: Codex went to an unrelated model).
	OwnVia func(model string) string
	// AppOut reports magpie made Codex's provider for a ChatGPT sign-in
	// whose account is used up (codex.out): the Codex app, which reads
	// its sign-in only as it opens, sends nothing on it till it is opened
	// again (MasterYi on Discord).
	AppOut func() bool
	// AppOutOff reports the user has turned the takeover (AppOut) off:
	// Codex's sign-in set to Always ChatGPT, or Codex not connected. The
	// takeover ending so is the user's change, not the reset's, and the
	// Codex app's app-server is restarted for it (CodexTakeoverOff).
	AppOutOff func() bool
	// DeskAt is when magpie named its model list for the Codex app in
	// Codex's config (deskList's model_catalog_json), zero while it
	// names none or the time isn't known (named by a magpie before it
	// was kept). The app-server reads the list only as it starts, so one
	// running from before shows Codex's own models alone (CodexAppDesk).
	DeskAt func() time.Time
	// HoldMatters reports Codex takes magpie's models beside a ChatGPT
	// sign-in, so that magpie is its provider while the Codex app holds
	// the account (out), or is that already: what the app holds is read
	// for it even with Codex switched off in magpie
	// (provider.CodexHoldMatters).
	HoldMatters func() bool
	// SideModel is the model Codex is set to when it is one of magpie's,
	// picked beside its ChatGPT sign-in (by the base URL, magpie not its
	// provider), "" otherwise: the gateway answers the Codex app's hidden
	// side turns (titles, descriptions, summaries), which it asks for on a
	// model of its own, on it rather than on the ChatGPT account.
	SideModel func() string
	// Routed reports that the agent's config sends whatever model it
	// names to magpie's gateway (Codex's openai_base_url or magpie as its
	// provider), so a model's name the gateway takes as a routing group
	// is that group's (#750).
	Routed func() bool
	// FailingOver reports an agent that isn't connected whose requests
	// still go through magpie's gateway, for account failover alone: what
	// a magpie from before wrote in Codex's config by itself (#1385), till
	// Sync takes it out (TylerBai_loveai on X). The Agents page says so,
	// and the gateway lists it only its own models.
	FailingOver func() bool
	// EndFailover takes out what account failover wrote, for magpie
	// quitting: left there, the agent would be pointed at a gateway that
	// no longer answers, and retry till magpie is open again (Leon920717
	// on X).
	EndFailover func() error
	// TakeLeftovers takes out what magpie wrote that no Disconnect could
	// name: an address at magpie's gateway whose marks are gone (magpie's
	// folder deleted by hand, a fresh install beside an old config), which
	// reads as not connected, so uninstalling would leave it pointing at a
	// gateway that is gone for good (#3866). Uninstall runs it after the
	// disconnects. It answers whether it changed anything.
	TakeLeftovers func() (bool, error)
	// Follow, for an agent whose own picker moves its main model where
	// magpie keeps other settings following it (Claude Code's /model and
	// its tiers), brings those along to the model picked there. Run as the
	// Agents page is drawn.
	Follow func() error
	// RenameRefs, for an agent whose config names magpie's models beyond
	// its fields (omp's other roles and fallback chains), moves those names
	// off provider from onto to, the rest of each kept; it answers whether
	// any moved. The fields themselves are RenameProvider's.
	RenameRefs func(from, to string) (bool, error)
	// Check, for an agent magpie wires in beyond its model field, says what
	// of that wiring is gone while the model is still one of magpie's —
	// something else rewrote the config — or "" when it is all there
	// (see Drift).
	Check func() string
	// LastUsed, for an agent that keeps a log of its own prompts, is when
	// it was last used — each prompt a request the gateway should have
	// seen, so one it didn't went round magpie (see Drift). Zero if unknown.
	LastUsed func() time.Time
	// Reached, for an agent that logs where its model requests go, is its
	// newest one since a time: when, the address it went to, and whether
	// nothing answered there. Zero if there is none.
	Reached func(since time.Time) (at time.Time, to string, refused bool)
	// WSL is the distro an agent inside WSL lives in, "" for this
	// machine's own (see wsl.go).
	WSL string
	// Home is a WSL agent's $HOME in its distro as magpie opens it
	// (\\wsl.localhost\<distro>\home\me), where its other files are; ""
	// for this machine's, and while the distro is stopped: opening it
	// would start it.
	Home string
	// Gateway is the gateway's address as the agent reaches it, a WSL
	// distro's own way to it; nil is gateway.URL.
	Gateway func() string
	// Import, for an app that takes magpie only through an import link of
	// its own, which the user confirms there (Cindy), is that link; the app
	// has no fields magpie sets. Added says whether it has magpie already,
	// known false when what it is read from couldn't be read: unknown,
	// never "not added". nil means the app exposes no way to read that
	// status.
	Import func() string
	Added  func() (added, known bool)
	// Launch, for an agent that takes the gateway only from its
	// environment (agy), is the command that starts it on magpie, while
	// it is on one of magpie's models; "" otherwise.
	Launch func() string
	// Typed, for such an agent, is what the user types in a new terminal
	// to start it on magpie, a function magpie gave their shells (agy);
	// "" when there is none, and Launch is the way.
	Typed func() string
	// Start, for such an agent, is what `magpie <id> run` starts it with:
	// its command, the variables and its model flag, the model "" while
	// it isn't on magpie's, when it starts as it is.
	Start func() Starting
	// SplitSuffix, for an agent whose model values carry something of its
	// own after the model that varies from value to value (omp's thinking
	// level, "…:max"), splits a value into the model the picker offers and
	// that suffix, "" when there is none. What matches a value against the
	// picker (drift, Reseat, RenameProvider, Spell) matches the model and
	// puts the suffix back after the one it moves to. A mark that is always
	// the same for a model (Claude Code's [1m]) rides on the option instead.
	// one is false for a value that is no one model but a list the agent
	// falls back through (omp's "a,b"): that is the user's own whatever it
	// names, never taken for one of magpie's models nor moved by what
	// matches the picker (RenameRefs moves the names in it).
	SplitSuffix func(v string) (model, suffix string, one bool)
	// Spelled, when set, says whether a value of the agent's fields is
	// spelled as one of magpie's there (prefixed: it starts with
	// "magpie/", its provider in the agent): one that isn't is a model of
	// one of the agent's own providers, never magpie's, even when magpie
	// has a provider of the same name (OpenHanako's own
	// deepseek/deepseek-v4-pro read as magpie's deepseek, #835).
	Spelled func(v string) bool
	// ModelAliases are the names the agent's model takes besides ids
	// (Claude Code's opus, best, opusplan). One that names a field as well
	// is the model's on the command line: magpie claude opus sets the
	// model, where another field's name alone shows that field.
	ModelAliases []string
	// Telemetry, when set, turns the agent's own telemetry to its vendor
	// off in its config (telemetry.go). It is not a field: a profile
	// saved before would turn it back on.
	Telemetry *Telemetry
	// contains filtered or unexported fields
}

Agent is one supported coding agent.

func All

func All() []*Agent

All returns every agent magpie knows about, detected or not: its own, then those plugins add.

func AllKnown

func AllKnown() []*Agent

AllKnown is All() with the agents in WSL's distros as they were last listed: it starts a listing but never waits on wsl.exe, for a page's path (whether the Sessions page reads this machine's sessions), where a hung wsl.exe held the first open for its timeouts (shangyuan0818 on X).

func Clients added in v0.1.43

func Clients() []*Agent

Clients is everyone whose requests the gateway knows by name: every agent, detected or not, and the others. It is what the Usage and Routing views draw a request's client with.

It leaves WSL's distros unasked: their agents are never clients, and a wsl.exe that hangs held the Sessions and Usage pages' first open (Looks) and the gateway's naming of a request's agent for its timeouts, ~10s to 20s (shangyuan0818 on X).

func ClientsIn

func ClientsIn(all []*Agent) []*Agent

ClientsIn is Clients among all, a list of All() the caller has built already.

func DesktopApp

func DesktopApp(home, dir, path string) *Agent

DesktopApp is Claude Desktop as the library knows it, with its file at path in dir: on Windows listed only while its program is installed (desktopInstalled), as the folder its uninstall leaves behind is no sign of it; elsewhere by that folder, as any agent is.

func DesktopTwinApp

func DesktopTwinApp(home string) *Agent

DesktopTwinApp is Claude Magpie, the isolated Desktop (desktopiso), as an app of its own to the library, as an Android app's twin is (xMopf7RF on X): its MCP servers in Claude-Magpie-3p's claude_desktop_config.json, the only file it reads them from, and its Cowork skills in that folder's skills-plugin, neither shared with the user's own Desktop. nil where it can't be (only on a Mac); here only while it is on and its folder there.

func Detected

func Detected() []*Agent

Detected returns the agents present on this machine, in display order.

func DetectedIn

func DetectedIn(all []*Agent) []*Agent

DetectedIn is Detected among all, a list of All() the caller has built already: a page that lists the agents and looks them up by name builds All once, not once for each.

func Find

func Find(q string) (*Agent, error)

Find resolves a user-typed name (id, alias, or unique prefix).

func FindIn added in v0.1.2457

func FindIn(all []*Agent, q string) (*Agent, error)

FindIn is Find among all, a list of All() the caller has built already.

func OnGateway added in v0.1.950

func OnGateway() []*Agent

OnGateway are the agents connected to magpie whose configs reach the gateway at its address now: none of their wiring is off.

func Starter

func Starter(q string) *Agent

Starter is the agent on this machine typed as q, by its id or an alias (no prefix: every argument after it is the agent's), that magpie starts from the command line (Agent.Start); nil for none.

func (*Agent) AppBehind added in v0.1.1423

func (a *Agent) AppBehind() *AppRun

AppBehind is the agent's desktop app when it runs here and started before magpie last changed what it reads at start; nil when it isn't running, has started since, or magpie doesn't restart it here. Only for an agent connected to magpie, or one disconnected from it in magpie: those are the changes magpie made.

func (*Agent) AppVersion added in v0.1.1123

func (a *Agent) AppVersion() string

AppVersion is the version of the agent's desktop app installed here, "" for an agent without one magpie knows, one not installed, or an Info.plist that doesn't say (a binary one isn't read).

func (*Agent) Apply added in v0.1.91

func (a *Agent) Apply(key, v string) error

Apply sets one of the agent's fields and remembers it as magpie's, so it can be told apart from what something else writes there later. Every setting of a field by the user goes through here. A field magpie set before that this one moves too is magpie's doing as well: Claude Code's Default takes its tiers and subagent model out with magpie's endpoint, which read as changed outside magpie, and the drift kept the row up among the connected ones while it said Not connected (#834).

func (*Agent) BinPath added in v0.1.2254

func (a *Agent) BinPath() string

BinPath is where the agent's own program is, as Detected finds its Bin, else where cliBin looks for one with no Bin (Grok Build's); "" for an agent in a WSL distro and one with no program here (a desktop app).

func (*Agent) CLI added in v0.1.397

func (a *Agent) CLI() (c CLI, ok bool)

CLI is the agent's CLI: its version, the newest, and whether magpie can update it, with its desktop app's version. ok is false for an agent with neither a CLI magpie knows nor its app.

func (*Agent) CLIMissing added in v0.1.936

func (a *Agent) CLIMissing() bool

CLIMissing reports an agent that is here by its settings alone: its folder or config is, its command-line program isn't — not on PATH nor where users' tools go (proc.FindTool) nor where its own installer puts it — and nothing else that reads the folder is either (cliHeld): no desktop app of its (DeepSeek Harness Desktop, star on Discord), no editor extension, no IDE. That is an uninstall that left ~/.dsh (#843), ~/.claude (#2177) or ~/.hermes/config.yaml (#2173) behind. The Agents page shows it as gone, with none of its settings, and Install another agent offers it again where magpie knows how. Only for an agent that is its CLI: one magpie knows an install command for, or cliOnly; never one detected its own way (detect), but for Goose, whose is its folder or its program.

func (*Agent) Connect added in v0.1.780

func (a *Agent) Connect() error

func (*Agent) ConnectHow added in v0.1.806

func (a *Agent) ConnectHow() (c Connection, err error)

ConnectHow is Connect, saying how the model was chosen.

func (*Agent) Detected

func (a *Agent) Detected() bool

Detected reports whether the agent seems to be installed or configured.

func (*Agent) Disconnect added in v0.1.682

func (a *Agent) Disconnect() (err error)

Disconnect takes magpie out of the agent's config and puts back what the user had, the Agents page's "Disconnect from magpie" (Fate on Discord: picking the agent's default did it, but nothing said so). Unwire first, for an agent whose default would leave it as installed; then each field still on magpie goes to its default, as picking it does, and so does each one magpie set that reads as magpie set it (an effort). What magpie remembered setting is forgotten.

func (*Agent) DisconnectOffline added in v0.1.972

func (a *Agent) DisconnectOffline() error

DisconnectOffline restores a native agent's saved files only after an explicit offline choice. Legacy callers of Disconnect keep live semantics.

func (*Agent) Disconnected added in v0.1.1162

func (a *Agent) Disconnected() bool

Disconnected reports whether the user disconnected the agent and hasn't connected it since.

func (*Agent) Drift added in v0.1.91

func (a *Agent) Drift() *Drift

Drift says what, if anything, keeps the agent off what magpie set: its config first (wiring, then each field against magpie's record), then — the config being right — whether its latest use actually came through. A field moved from one magpie model to another (the agent's own picker) isn't drift; one moved off magpie is.

func (*Agent) DriftShown

func (a *Agent) DriftShown() *Drift

DriftShown is Drift for the window's poll, which only shows it: whether a value is one of magpie's models is remembered per value while provider.StampNow stays the same, shownValuesFor at most. Each poll asked every field's whole option list for it, built again once a minute: 27 MB of the 50 MB a magpie with real accounts allocated in three minutes with the window up. What the stamp can't see (a provider resting, a model retired by its date) shows within shownValuesFor; Reapply, rewiring and a launch ask Drift, which reads them now.

func (*Agent) FailoverSaid added in v0.1.1138

func (a *Agent) FailoverSaid() string

FailoverSaid is, for an agent not connected whose requests still go through magpie for account failover alone (FailingOver), what the CLI and the TUI say of it, the Agents page's line in words of their own: why it goes through magpie, and what turns that off (#1385). "" when it doesn't.

func (*Agent) Field

func (a *Agent) Field(key string) *Field

Field looks a field up by key, in any case, as Find looks an agent up (magpie codex Model was written as the model).

func (*Agent) HasApp added in v0.1.1135

func (a *Agent) HasApp() bool

HasApp reports whether the agent's desktop app is installed here: its bundle on macOS (AppVersion), its executable on Windows: under %LOCALAPPDATA%\Programs, or in the folder its installer registered; on Linux the folder its package installed (desktopApp.linux), or one a packager's install or an AppImage's desktop entry names (linuxApp).

func (*Agent) InstalledVersion added in v0.1.443

func (a *Agent) InstalledVersion() string

InstalledVersion is what the agent's CLI on PATH says its version is: "" for an agent without a CLI magpie knows, one not on PATH, or one that didn't say. Asked once per binary, like CLI's; nothing is fetched. An agent in a WSL distro's is what the distro's own CLI said at its probe, for the kinds that ask (wslKind.version), never this machine's.

func (*Agent) Keep added in v0.1.91

func (a *Agent) Keep()

Keep takes the agent's config as it is now: what magpie set before is forgotten, and no longer said to have been changed. The agent stays one magpie set up (setUp): an entry with no fields is kept for it, so one whose magpie is spelled as a provider of its own config still reads as connected.

func (*Agent) ListsFor added in v0.1.1051

func (a *Agent) ListsFor() string

ListsFor is whose model lists an agent's are (provider.CatalogFor): its own id's, or, for one in a WSL distro, its Windows twin's (claude for claude@wsl:Ubuntu). A distro's agent is written magpie's models under that id and sends the gateway that id's key, so the models picked for its row are the ones it is shown only when kept under that id too (#927).

func (*Agent) Models added in v0.1.1118

func (a *Agent) Models() []string

Models are magpie's models the agent is set to, as catalog ids (provider/model, group/<id>), each once: the agent's own models aside. Usage stats count them (internal/stats).

func (*Agent) OwnModels added in v0.1.1198

func (a *Agent) OwnModels(cur map[string]string) bool

OwnModels reports whether one of a's pickers that picks among magpie's catalog offers models of the agent's own too, which Picks can leave out.

func (*Agent) Pick added in v0.1.780

func (a *Agent) Pick(key, v string) error

Pick sets a field from the Agents page's model picker. One of magpie's models picked on an agent not connected yet connects it first, as its switch does, then starts it on that model (the owner: the switch, and a model picked in magpie in one click, both): the agent gets magpie's whole list, and Disconnect puts back what it had before.

func (*Agent) Picks added in v0.1.1198

func (a *Agent) Picks(f Field, cur map[string]string) []Option

Picks are the options f's picker offers: all of them, unless the user asked a's pickers to offer magpie's models alone (#1642, MizuIro-H). Then a field that picks among magpie's catalog leaves out the models the agent reaches on its own (DeepSeek Harness's DeepSeek ones), but for its default and the one it is set to.

func (*Agent) Reapply added in v0.1.91

func (a *Agent) Reapply() error

Reapply sets again what magpie set on the agent: what drifted, else its fields as they read now — for a config taken off magpie in a way no check catches. A replaced field brings back the others magpie set with it. Either way the record is renewed, so a use before now no longer counts.

func (*Agent) RestartApp added in v0.1.1423

func (a *Agent) RestartApp(ctx context.Context) error

RestartApp quits the agent's desktop app and opens it again, so it reads what magpie wrote. Only the Agents row's Restart calls it, after the user confirmed, and only an app AppBehind lists is quit. macOS: asked to quit as ⌘Q does, every process of its bundle waited for (but a script run on it, runsScript); one still open then (it may be asking something) is left, never forced, and not opened a second time. Windows: its windows are asked to close; an app still running then (Electron apps stay in the tray) is ended with its tree.

func (*Agent) SetTelemetry

func (a *Agent) SetTelemetry(off bool) error

SetTelemetry turns a's own telemetry off, or back to what it was.

func (*Agent) SharedHere added in v0.1.1263

func (a *Agent) SharedHere() bool

SharedHere reports whether the folder the agent shares with its vendor's other app is here (Cursor CLI's ~/.cursor, made by the Cursor editor), whether the agent is or not. The agent isn't Detected for it (dirShared), but what the other app reads there too, the Library's MCP servers and skills, is still given.

func (*Agent) SharedName added in v0.1.1263

func (a *Agent) SharedName() string

SharedName is the agent's name over what it keeps where another app of its vendor's reads it too (the Library's MCP servers and skills, the chats Sessions lists): Cursor for Cursor CLI, whose ~/.cursor the Cursor editor shares; Name for any other.

func (*Agent) SharedRead

func (a *Agent) SharedRead() bool

SharedRead reports whether an app of the agent's vendor that reads its shared folder is here (sharedApp): VS Code, or GitHub Copilot's JetBrains plugin, for Copilot CLI's ~/.copilot. A folder left by the CLI's uninstall is then no leftover: that app still reads it.

func (*Agent) Source added in v0.1.780

func (a *Agent) Source() string

Source is what an agent not connected to magpie runs on now: "sub" (a Claude subscription), "chatgpt" (a ChatGPT sign-in), "key" (an API key of its own), "providers:N" (N providers of its own); "" when unknown.

With account discovery off (#1535) no sign-in is read for it: Claude Code's account in .claude.json, Codex's auth.json and OpenCode's are left alone, and only what the agent's own settings say is told.

func (*Agent) Spell added in v0.1.41

func (a *Agent) Spell(key, v string) (string, error)

Spell puts a value typed for field key the way this agent spells it: a catalog model is "copilot/gpt-6" in some agents and "magpie/copilot/gpt-6" in others, and either is taken in both. A value the picker offers as is stays, and so does one it doesn't know (a model the agent reaches on its own that isn't listed); a "magpie/…" value the catalog doesn't have is an error rather than a model the agent would ask its own vendor for, and so is one of magpie's the agent isn't shown (notOffered). The agent's suffix after the model (SplitSuffix) stays as typed, and so does a list of models, the user's own.

func (*Agent) Stale added in v0.1.780

func (a *Agent) Stale() int

Stale is how many copies of the agent are running that started before magpie last changed what it reads at start: they still have the list they started with until reopened. On Windows only the Codex daemon is told.

func (*Agent) StaleCopies added in v0.1.1110

func (a *Agent) StaleCopies() []StaleCopy

StaleCopies are the copies Stale counts. Reopening one kind doesn't end another: on macOS the Codex app keeps running, its app-server with it, when its window is closed (its window-all-closed doesn't quit a packaged app on darwin), an editor's Codex runs until the editor's window is reloaded, and the CLI's managed daemon runs on with ppid 1 until it is restarted itself. So each is told apart for the row to say which one is left. One app's processes (its app-server, its exec-server) are one copy. One run from another home's agent dir (an app-server daemon Codex left running for a CODEX_HOME of its own, under its packages) reads other files, and isn't counted.

func (*Agent) Unreached added in v0.1.2403

func (a *Agent) Unreached() error

Unreached is why magpie can't open the folder of a, an agent in a WSL distro: a link there the distro couldn't resolve; nil for any other.

func (*Agent) UpdateCLI added in v0.1.397

func (a *Agent) UpdateCLI() (CLI, error)

UpdateCLI brings the agent's CLI up to date the way it was installed, and says what it is afterwards.

func (*Agent) Values

func (a *Agent) Values() map[string]string

Values reads every field.

func (*Agent) Wired added in v0.1.682

func (a *Agent) Wired() bool

Wired reports whether magpie is in the agent's config: a field on one of magpie's models, or on magpie itself (an app whose one setting is magpie as its provider). A model on a provider of the agent's own config named magpie counts only where magpie set the agent up (handWired).

type AllHiddenError added in v0.1.1230

type AllHiddenError struct{ Agent string }

AllHiddenError is Connect's answer when magpie has models but none of them is left in the agent's lists: the only ones picked for it are gone with their provider, or every one is turned off for it (#1989). Saying it can't be connected sent the user looking at the agent, when its model list is what emptied it. The GUI says it in the reader's language by its code (all_hidden).

func (*AllHiddenError) Error added in v0.1.1230

func (e *AllHiddenError) Error() string

type AppRun added in v0.1.1423

type AppRun struct {
	Since time.Time `json:"since"`
}

AppRun is a desktop app running on what it read before magpie's last change to it: when it started, for the row to offer a Restart.

type CLI added in v0.1.397

type CLI struct {
	Version string `json:"version,omitempty"`
	// Latest is the newest there is, from where it would be updated:
	// Homebrew's for one Homebrew installed, npm's otherwise
	Latest string `json:"latest,omitempty"`
	// Via is what updates it: npm, bun, pnpm, brew, or self (its own
	// updater); "" when magpie can't tell how it was installed
	Via string `json:"via,omitempty"`
	// Command is the update as a person would type it
	Command string `json:"command,omitempty"`
	// Update: Latest is after Version, and magpie knows how to get it
	Update bool `json:"update,omitempty"`
	// App is the version of the agent's desktop app installed beside it
	// (the Codex app, AppVersion); shown even with no CLI on PATH
	App string `json:"app,omitempty"`
	// Admin: the update needs an administrator, which Windows asks for
	// first (npm's global folder under Program Files)
	Admin bool `json:"admin,omitempty"`
	// Path is where the CLI was found: the file magpie runs, as PATH
	// reached it
	Path string `json:"path,omitempty"`
	// OffPath says the CLI was found in a folder magpie adds to its own
	// PATH (proc.UserPath: ~/.local/bin, npm's prefixes, nvm's default
	// Node, bun, Homebrew, ...) that a terminal opened now doesn't have,
	// so that `which` there doesn't find it. A row of an agent the user
	// believed uninstalled, with a version and nothing to say where it
	// came from, read as magpie making it up (悠悠哥 on Discord: Codex
	// 0.162.1 listed with no codex on PATH and no ~/.codex). False when
	// the terminal's PATH can't be told.
	OffPath bool `json:"offPath,omitempty"`
	// InDesktop: no Claude Code of its own is found here, and Claude
	// Desktop is, which includes one for its Code tab that reads the
	// same ~/.claude (cybercaius: the card stayed after Claude Code was
	// uninstalled and Desktop installed again, with nothing saying why).
	// DesktopVersion is that copy's newest version, "" until Desktop has
	// fetched it.
	InDesktop      bool   `json:"inDesktop,omitempty"`
	DesktopVersion string `json:"desktopVersion,omitempty"`
}

CLI is what magpie knows of an agent's command-line program.

type ClaudeModelMark added in v0.1.3147

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

ClaudeModelMark is what the user's settings.json says of its model before a claude-magpie session, for ClaudeLaunchAfter.

func ClaudeLaunchBefore added in v0.1.3147

func ClaudeLaunchBefore(home string) ClaudeModelMark

ClaudeLaunchBefore marks the user's model before a session.

type CodexCompactHold added in v0.1.2289

type CodexCompactHold struct {
	Path    string `json:"path"`
	Key     string `json:"key"`
	Profile string `json:"profile,omitempty"`
	Value   string `json:"value"`
}

CodexCompactHold is one such key in a Codex config: at the top level, or in the profile the config picks ([profiles.<Profile>]).

func CodexCompactHeld added in v0.1.2289

func CodexCompactHeld(home string) []CodexCompactHold

CodexCompactHeld is the keys this machine's Codex config (home "" is the user's) has that come before Long conversations.

type CodexReader added in v0.1.1408

type CodexReader struct {
	Kind    string `json:"kind"`
	Version string `json:"version,omitempty"`
}

CodexReader is a Codex that reads a config: what it is ("cli", "app", "ide", "wsl") and its version, "" when that isn't known.

func CodexAsyncHeld added in v0.1.1408

func CodexAsyncHeld() []CodexReader

CodexAsyncHeld is the Codexes here that kept the background compaction's table, and with it its threshold, out at the last sync: one too old for the feature, or one whose version isn't known.

func CodexAsyncHeldHere added in v0.1.2363

func CodexAsyncHeldHere(home string) []CodexReader

CodexAsyncHeldHere is the Codexes on this machine that would keep the background compaction's threshold out of its config (one before codexAsyncTableFrom, or of no known version), asked now rather than at the last sync, which asks only while the setting is on.

type Connection added in v0.1.806

type Connection struct {
	How   string `json:"how"`
	Field string `json:"field,omitempty"`
	Value string `json:"value,omitempty"`
}

Connection is how Connect chose the model an agent starts on, for the Agents page to say it (#726: Codex showed its last pick, Claude Code a Sonnet through magpie and Antigravity some model, with nothing saying why). How is one of:

  • "kept": it was connected already, left as it was
  • "again": the models it was on when it was switched off, put back
  • "joined": the model it is on stays its own (Codex signed in with ChatGPT), magpie's models join its list
  • "magpie": an app whose one setting is magpie as its provider
  • "same": the model it is on now, through magpie
  • "alike": the model its alias (opus) stands for, through magpie
  • "default": on its own default with no model set: the first of its own models in its list (the newest, for Claude Code), through magpie
  • "first": magpie has none of the model it is on: the first on the account it is signed in to, else a subscription's, else the first
  • "remote": the models a Remote magpie's same agent is on (remote_picks.go)

Field and Value are the field set and what it was set to, where Connect picked one model ("" for kept, again and joined).

type DesktopIsolated

type DesktopIsolated struct {
	On        bool   `json:"on"`
	Launcher  string `json:"launcher,omitempty"`
	Claude    bool   `json:"claude"`
	ClaudeDir string `json:"claudeDir"`
}

DesktopIsolated is the isolated Desktop as it is here: whether it can be (only on a Mac), whether it is on, and the app that starts it, "" while magpie hasn't made it. Claude is whether its Code tab has a Claude Code folder of its own, ClaudeDir that folder.

func DesktopIsolatedHere

func DesktopIsolatedHere() (DesktopIsolated, bool)

DesktopIsolatedHere is the isolated Desktop on this computer; false where Desktop can't run so.

type DisconnectPlan added in v0.1.972

type DisconnectPlan struct {
	Files    []PlannedFile
	Settings []PlannedSetting
}

func (*DisconnectPlan) CheckFiles added in v0.1.972

func (p *DisconnectPlan) CheckFiles() error

func (*DisconnectPlan) Preview added in v0.1.972

func (p *DisconnectPlan) Preview() []FileChange

func (*DisconnectPlan) Revision added in v0.1.972

func (p *DisconnectPlan) Revision(agent string) string

Revision binds confirmation to file preconditions and restoration values, without accepting a serialized plan from the client.

type Drift added in v0.1.91

type Drift struct {
	// Kind says what is off:
	//   "unwired"  the model is magpie's but the config no longer sends it
	//              through magpie (Check);
	//   "replaced" a magpie model magpie set was replaced by the agent's own;
	//   "bypassed" the config is right, yet the agent was used since and
	//              nothing of it reached the gateway — it runs on an old
	//              config, or something outside the file overrides it;
	//   "unreachable" the config is right, but the address off loopback
	//              it names the gateway at doesn't answer (#1013);
	//   "proxied"  the config is right, but the agent sends its requests
	//              for the gateway through a proxy (Addr) that doesn't
	//              pass them on to it (codex_proxy.go).
	Kind   string `json:"kind"`
	Field  string `json:"field"`         // the field it shows on
	Now    string `json:"now,omitempty"` // what that field says now
	Want   string `json:"want"`          // what setting it again sets
	Detail string `json:"detail"`        // what exactly is off, for a tooltip
	// Addr is where an unreachable agent is pointed; Move, when set, the
	// address WSL reaches Windows at now, which Reapply points it at.
	Addr string `json:"addr,omitempty"`
	Move string `json:"move,omitempty"`
}

Drift is how an agent differs from what magpie set on it.

type Field

type Field struct {
	Key     string
	Label   string
	Get     func() string
	Set     func(string) error
	Options func(cur map[string]string) []Option
	// Quiet fields are left out of listings while empty: they follow
	// another field until set (Claude Code's per-tier models).
	Quiet bool
	// Live fields are magpie's own settings, read by the gateway on each
	// request (Claude Desktop's subagent model): a change to one needs no
	// restart of the agent, so its Notice isn't shown after it, unless
	// the pick connected the agent to magpie as well.
	Live bool
	// Follows is the key of the field a Quiet one takes after while empty
	// ("model" for Claude Code's tiers and subagents): a profile's details
	// say so, and Drift reads the field as on that one's model (#1050).
	Follows string
	// Own fields are the user's own settings of the agent's, never
	// magpie's wiring (Claude Code's permission mode): magpie writes one
	// only when the user picks it, so Disconnect, Reapply and a restore
	// leave it as it is, and a profile neither keeps nor writes it. A
	// value the user then sets in the agent itself stays theirs.
	Own bool
}

Field is one tunable setting of an agent. Set with an empty value puts the field back to the agent's own default: anything magpie wired in (the gateway as a provider, its model catalog) comes out and the key is removed.

type FileChange added in v0.1.780

type FileChange struct {
	Path    string     `json:"path"`              // as the user knows it, ~ for home
	Removed bool       `json:"removed,omitempty"` // the file goes
	Created bool       `json:"created,omitempty"` // the file is made
	Lines   []LineDiff `json:"lines,omitempty"`
}

FileChange is how disconnecting changes one of the agent's files.

func DisconnectPreview added in v0.1.780

func DisconnectPreview(a *Agent, exe string) ([]FileChange, error)

DisconnectPreview is what Disconnect would change in the agent's files, found by running it on a copy. An error is a preview not to be had (the agent's files outside home, a WSL agent): the dialog then says it in words.

type Gone added in v0.1.1668

type Gone struct {
	Put, Off  []string
	PluginOff string
}

Gone is what RestoreGone did: the files it put back as the user had them, and those magpie was already out of. PluginOff names the agent of a plugin switched off with nothing stashed: magpie is out of it already.

func RestoreGone added in v0.1.1668

func RestoreGone(id string) (g Gone, ok bool, err error)

RestoreGone puts back what the user had in each file magpie wired for the agent id of a plugin that is gone (deleted on disk, or taken out of plugins.json by hand), from the stash alone, for `magpie <id> default`. ok is false when id is an agent here, or nothing is stashed for it and no plugin switched off adds it.

type Install added in v0.1.801

type Install struct {
	ID       string       `json:"id"`
	Name     string       `json:"name"`
	Icon     string       `json:"icon,omitempty"`
	Commands []InstallCmd `json:"commands"`
	// Missing: the agent's settings are here but its CLI isn't (CLIMissing),
	// so it is listed on the Agents page and offered here again too
	Missing bool `json:"missing,omitempty"`
}

Install is an agent not on this machine, and how to install it.

func Installs added in v0.1.801

func Installs() []Install

Installs is every agent magpie knows a command for that isn't on this machine, in the Agents page's order.

type InstallCmd added in v0.1.801

type InstallCmd struct {
	// Via is what runs it: script (the vendor's installer, in a shell),
	// powershell (the vendor's installer, on Windows), brew or npm
	Via     string `json:"via"`
	Command string `json:"command"`
	// Node is how the command installs Node.js before npm, where none is
	// here: nvm (Linux), nvm-mac (a Mac, where nvm's installer wants the
	// Xcode Command Line Tools) or winget (Windows); "" when it doesn't
	Node string `json:"node,omitempty"`
	// Admin is npm's global folder, for an npm command run where only an
	// administrator can change it (Windows' Program Files); "" otherwise
	Admin string `json:"admin,omitempty"`
}

InstallCmd is one way to install an agent's CLI.

type LineDiff added in v0.1.780

type LineDiff struct {
	Op   string `json:"op"`
	Text string `json:"text"`
	Was  string `json:"was,omitempty"`
}

LineDiff is a line of a file disconnecting changes: Op is "-" for a line taken out, "+" for one put in, "~" for a line whose value goes back to another (Was is the line now).

type Look

type Look struct {
	ID, Name, Shared, Icon string
}

Look is how an agent of Clients() is named and drawn.

func Looks

func Looks() []Look

Looks is each agent of Clients() as it is named and drawn, in that order, for pages that only name and draw rows by agent: the Sessions and Usage pages ask on every poll, and Clients() builds every agent, ~2.5 ms and ~380 KB of stats, paths and environment each time. It is built again after looksFresh, or at once when the plugins' agents change. What it returns is shared: callers only read it.

type Move added in v0.1.397

type Move struct {
	Agent string `json:"agent"` // the agent's name
	Field string `json:"field"` // model, or a tier (Claude Code's haiku …)
	From  string `json:"from"`  // the catalog model it was on
	To    string `json:"to"`    // the one it is on now; "" its own default
	// Error is why the agent couldn't be moved (its file unwritable, say):
	// it stays on From, which magpie no longer serves
	Error string `json:"error,omitempty"`
}

Move is one of an agent's fields moved off a model magpie no longer serves.

func Reseat added in v0.1.397

func Reseat(change func() error) ([]Move, error)

Reseat makes a change to the providers (change) and moves every agent whose model it stopped serving: to that model from another provider that serves it, else to the agent's own default. It answers the moves. Its error is the change's alone: once the change is made, an agent that can't be moved is a move with its Error and the others are still moved. An error then would say the change failed when it was made — the panel, told so, kept a removed provider's editor open and listed, and a second Remove said there was no such provider.

func (Move) String added in v0.1.397

func (m Move) String() string

String is the move as the CLI and the TUI say it.

type NativeConnection added in v0.1.972

type NativeConnection struct {
	Read           func() NativeState
	Connect        func() error
	Apply          func(key, value string) error
	Stage          func(key, value string) error
	Disconnect     func() (*DisconnectPlan, error)
	Execute        func(*DisconnectPlan) error
	ExecuteOffline func(*DisconnectPlan) error
}

NativeConnection registers a provider independently of model selection. Its plan describes file and runtime changes without performing either.

type NativeField added in v0.1.972

type NativeField struct {
	Value  string `json:"value"`
	Status string `json:"status"`
	Detail string `json:"detail,omitempty"`
}

type NativeState added in v0.1.972

type NativeState struct {
	Provider string                 `json:"provider"`
	Detail   string                 `json:"detail,omitempty"`
	Runtime  string                 `json:"runtime"`
	Fields   map[string]NativeField `json:"fields"`
}

type NoLinkHandlerError added in v0.1.1984

type NoLinkHandlerError struct {
	App, Scheme, Exe string
}

NoLinkHandlerError says that nothing on this computer opens App's links (Scheme://), so handing one to the system opens nothing and says nothing: Windows' rundll32, macOS' open and xdg-open are started, not waited on. With Exe set, the scheme is registered to a program that is gone.

func (*NoLinkHandlerError) Error added in v0.1.1984

func (e *NoLinkHandlerError) Error() string

type NoModelsError added in v0.1.1024

type NoModelsError struct{ Agent string }

Connect puts magpie into the agent's config, the Agents page's switch (the owner: an agent is connected to magpie, and its models are picked in the agent): the agent's main field goes to one of magpie's models — the one serving the model it is on now, else the first — or to magpie itself for an app whose one setting is magpie as its provider. Setting it writes the provider and the whole catalog in, so the agent's own model list has every one of magpie's models. An agent that can keep the model it is on (Join) keeps it. An agent already connected is left as it is. NoModelsError is Connect's answer while magpie has no models to give the agent: no provider or subscription has been added yet. The GUI says it in the reader's language by its code (no_models).

func (*NoModelsError) Error added in v0.1.1024

func (e *NoModelsError) Error() string

type OfflineAction added in v0.1.972

type OfflineAction string
const (
	OfflineStage      OfflineAction = "stage"
	OfflineDisconnect OfflineAction = "disconnect"
)

type Option

type Option struct {
	Value string   `json:"value"`
	Label string   `json:"label,omitempty"` // display name, when the value is an id
	Note  string   `json:"note"`
	Icon  string   `json:"icon,omitempty"`  // bundled icon name
	Icons []string `json:"icons,omitempty"` // a routing group's providers' icons, stacked
	Group string   `json:"group,omitempty"` // section header in the picker
	// GroupIcon is the group's own logo in the picker's rail, when it is
	// not the first model's (a provider serving other vendors' models)
	GroupIcon string `json:"groupIcon,omitempty"`
	Ref       string `json:"ref,omitempty"`  // the catalog model, the same in every agent
	Free      bool   `json:"free,omitempty"` // costs its subscription nothing
	// Zero is a model its provider lists at $0 (provider.PricedFree), where
	// Free is the vendor's own word: the picker says free by it too
	// (jiangguochao666 on X)
	Zero bool `json:"zero,omitempty"`
	// Rate and RateWas are the credits a request costs its subscription,
	// as a multiple, and before a discount running now (Qoder's 0.5×,
	// WorkBuddy's x0.03), when its vendor lists them
	Rate    float64 `json:"rate,omitempty"`
	RateWas float64 `json:"rateWas,omitempty"`
	// Context is the tokens the model takes, when known; the picker marks
	// the large ones
	Context int `json:"context,omitempty"`
	// Takes, on an effort field's default (Value ""), is the level the
	// agent takes for the model with none set (Codex: the catalog entry's
	// default_reasoning_level), shown beside "default"
	Takes string `json:"takes,omitempty"`
	// Direct names who the agent asks for this model itself, on its own
	// sign-in or key, with magpie not in the way ("Anthropic"): its config
	// then names no magpie endpoint, which is right, not a failed setup
	Direct string `json:"direct,omitempty"`
	// Via is a model of the agent's own it asks through magpie's gateway,
	// on its own sign-in all the same (Codex's while routed by its base
	// URL): the picker says via magpie by it, as by a catalog model's
	Via bool `json:"via,omitempty"`
	// Same is a model magpie serves on the very account the agent is
	// signed in to itself, so the agent reaches it on its own too: the
	// picker folds these into one row a click opens (Claude Code, #496)
	Same bool `json:"same,omitempty"`
	// Served is a model of the agent's own that magpie's list shows it
	// too, on the very account it is signed in to (Codex's ChatGPT
	// models, its list's Codex section): not left out with the agent's
	// own models (Picks), as the list's tick decides it (shiqi_40904: a
	// routing group switched on took every one out of Codex's picker)
	Served bool `json:"served,omitempty"`
	// Alias is the value of the option a dated id is another name of
	// (claude-opus-4-5-20251101 → claude-opus-4-5): the picker shows one
	// row for the two, the alias, unless the dated one is the value set
	Alias string `json:"alias,omitempty"`
	// FastFor is the agent a catalog model with a fast mode (provider.
	// CanFast) is switched fast or not for, by the model in the picker
	// (#954): the one whose requests the gateway sends it on; Fast is
	// whether it is now (provider.IsFastPick)
	FastFor string `json:"fastFor,omitempty"`
	Fast    bool   `json:"fast,omitempty"`
	// OwnFast: its fast mode is a GPT model's on a provider the user added
	// by its address (provider.OwnFast, #1615), asked for there as OpenAI's
	// priority, which the provider may or may not serve
	OwnFast bool `json:"ownFast,omitempty"`
	// UltraOK: an account offers the model as Ultrafast (provider.CanUltra,
	// #1954), so the fast switch has a third setting; Ultra is whether it
	// is on (provider.IsUltraPick)
	UltraOK bool `json:"ultraOk,omitempty"`
	Ultra   bool `json:"ultra,omitempty"`
	// contains filtered or unexported fields
}

Option is one value the picker offers for a field.

type PlannedFile added in v0.1.972

type PlannedFile struct {
	Path   string
	Before []byte
	After  []byte
}

type PlannedSetting added in v0.1.972

type PlannedSetting struct {
	Key    string
	Before json.RawMessage
	After  json.RawMessage
}

type RuntimeUnavailableError added in v0.1.972

type RuntimeUnavailableError struct {
	Agent     string
	Operation string
	Offline   OfflineAction
	Cause     error
}

RuntimeUnavailableError is created only for an initial runtime read, before the operation has written either runtime settings or local files.

func (*RuntimeUnavailableError) Error added in v0.1.972

func (e *RuntimeUnavailableError) Error() string

func (*RuntimeUnavailableError) Unwrap added in v0.1.972

func (e *RuntimeUnavailableError) Unwrap() error

type StaleCopy added in v0.1.1110

type StaleCopy struct {
	// Kind, for Codex: "app" (the ChatGPT or Codex desktop app, its
	// app-server and helpers), "ide" (an editor extension's), "daemon"
	// (the background app-server the CLI leaves running), "helper" (a
	// subcommand the daemon spawns beside itself, no copy to reopen) or
	// "cli"; "" for other agents; "embedded" is another app's own Codex,
	// named by App
	Kind string `json:"kind,omitempty"`
	App  string `json:"app,omitempty"`
	// Bundle is the desktop app's own, for "app": what the row's Restart
	// quits and opens again
	Bundle string    `json:"bundle,omitempty"`
	Since  time.Time `json:"since"`
}

StaleCopy is a copy of an agent still running on the list it started with: what kind of copy it is, which says how it is reopened, and when it started.

type Starting

type Starting struct {
	Bin   string
	Env   []string
	Args  []string
	Model string
	Flag  string
	Plain []string
}

Starting is what starts an agent on magpie (Agent.Start): the command on PATH, the variables, the flags with their values put before the user's arguments (Args, flag then value: agy's --settings <file>), and the model after Flag (none when Flag is ""); Model "" while it isn't on magpie's, and it starts as it is. With one of Plain among the user's arguments (alone or with "=value") it starts as it is too.

func (Starting) Given

func (s Starting) Given(a string) bool

Given says a is the model's flag in one of its forms (--model, -model), alone or with "=value".

func (Starting) Names

func (s Starting) Names() []string

Names are the variables' names.

func (Starting) Plained

func (s Starting) Plained(a string) bool

Plained says a is one of Plain, alone or with "=value".

type Telemetry

type Telemetry struct {
	Get func() (TelemetryState, error)
	Set func(off bool) error
	// contains filtered or unexported fields
}

Telemetry is an agent's switch for its own telemetry.

type TelemetryState

type TelemetryState struct {
	// Off: every key of the switch turns telemetry off
	Off bool `json:"off"`
	// Own: keys the user wrote that keep it off, which on leaves in
	Own []string `json:"own,omitempty"`
	// Keys: what the switch writes, as the file spells it
	Keys []string `json:"keys"`
	// File: the config it writes
	File string `json:"file"`
	// Error: why the config couldn't be read, when it couldn't (the
	// state is then unknown)
	Error string `json:"error,omitempty"`
	// All: Settings › Privacy turns every agent's off, which holds this
	// agent's row (telemetry_all.go); AllError why it couldn't here
	All      bool   `json:"all,omitempty"`
	AllError string `json:"allError,omitempty"`
}

TelemetryState is an agent's telemetry as its config has it.

type TuneKnob added in v0.1.3120

type TuneKnob struct {
	Knob    string
	Model   string
	Setting TuneSetting
}

TuneKnob is one setting of an agent's, the model a window is for, and how the agent has it now.

func TuneCacheHere added in v0.1.3156

func TuneCacheHere(home string) []TuneKnob

TuneCacheHere is Claude Code's two prompt-cache lifetimes as this computer's Claude Code reads them, whoever set them, when its folder is here: the main conversation's always, the subagents' when something sets it. They change what this computer's Claude Code sends, whichever magpie its requests go on to (linkaww on Discord: Claude Code through a Remote magpie, too few calls read here to advise on, and the card had no row to tell the cache it keeps, or a way back to 5 minutes).

func TuneKept added in v0.1.3120

func TuneKept(home, agent string) []TuneKnob

TuneKept are the settings in agent's own config that tune put in and that still hold its value (Ours), so Undo can put back what was there: Claude Code's cache lifetimes and per-model windows. The Usage page's card keeps them there when a range has too few calls to advise on (linkaww on Discord: a 1-hour cache put in, with no way back to 5 minutes). The cache lifetimes are also picked in Claude Code's own settings (ClaudeCacheSet), which makes them the user's. One in magpie's Long conversations or Codex's background compaction is left out: Settings shows and changes those.

type TuneSetting added in v0.1.1158

type TuneSetting struct {
	Value string `json:"value,omitempty"` // "" when nothing sets it
	// Where Value comes from: settings (the agent's own config file),
	// model (Claude Code's modelSettings for the model), env, or long
	// (TuneLong: magpie's Long conversations, "" under Full window)
	Source string `json:"source,omitempty"`
	// Locked names the variable that takes precedence over the setting,
	// which tune leaves as it is: putting the advice in would change nothing
	Locked string `json:"locked,omitempty"`
	// Ours: tune put Value in, and Undo puts back what was there
	Ours bool `json:"ours,omitempty"`
	// Take: what is Locked is one magpie can take over on the user's say
	// (TuneTakeOver)
	Take bool `json:"take,omitempty"`
}

TuneSetting is one of those settings as an agent has it now.

func TuneRead added in v0.1.1158

func TuneRead(home, agent, knob, model string) (TuneSetting, error)

TuneRead is how an agent has a setting tune advises now.

Source Files

Jump to

Keyboard shortcuts

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