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
- func AgyLaunch(model string) string
- func CLIs(wait time.Duration) (out map[string]CLI, pending bool)
- func CindyLink(url string) string
- func DesktopConfig3p(home string) string
- func DshPatchFiles(dir string) []string
- func KimiDir(home string) (dir string, legacy bool)
- func ModelIcon(model string) string
- func MoveAntigravityEfforts()
- func MoveCursorEfforts()
- func MoveOffAccountIDs()
- func Newer(a, b string) bool
- func RenameLegacy()
- func RenameProvider(from, to string) ([]string, error)
- func Running(patterns ...string) bool
- func StandIn(agent, model string) string
- func SyncCatalog()
- func Taken(p string) bool
- type Agent
- func (a *Agent) Apply(key, v string) error
- func (a *Agent) CLI() (c CLI, ok bool)
- func (a *Agent) Detected() bool
- func (a *Agent) Drift() *Drift
- func (a *Agent) Field(key string) *Field
- func (a *Agent) InstalledVersion() string
- func (a *Agent) Keep()
- func (a *Agent) Reapply() error
- func (a *Agent) Spell(key, v string) (string, error)
- func (a *Agent) UpdateCLI() (CLI, error)
- func (a *Agent) Values() map[string]string
- type CLI
- type Drift
- type Field
- type Move
- type Option
Constants ¶
const CindyScheme = "cindy://provider/import?"
CindyScheme begins every Cindy import link.
const RoutingGroups = "Routing groups"
RoutingGroups is the picker's group of routing groups.
Variables ¶
This section is empty.
Functions ¶
func AgyLaunch ¶ added in v0.1.404
AgyLaunch is the command that starts agy on magpie's gateway and one of its custom models, in the shell of this system.
func CLIs ¶ added in v0.1.397
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 CindyLink ¶ added in v0.1.281
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 DesktopConfig3p ¶ added in v0.1.474
DesktopConfig3p is the claude_desktop_config.json Claude Desktop reads in its 3p mode: there its whole userData is Claude-3p, its MCP servers too (%LOCALAPPDATA%\Claude-3p on Windows, Claude-3p beside Claude elsewhere).
func DshPatchFiles ¶ added in v0.1.182
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 KimiDir ¶ added in v0.1.470
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 ModelIcon ¶ added in v0.1.466
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
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 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
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. It answers the agents it moved.
func Running ¶
Running reports whether a process whose command line matches any pattern (an extended regexp, as for pgrep -f) is alive. Unknown on Windows.
func StandIn ¶ added in v0.1.241
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. "" when Claude Code isn't routed through magpie or asked for isn't Claude Code. For gateway.StandIn.
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.
Types ¶
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
Fields []Field
// 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
// 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
// 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
// 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.
Import func() string
Added func() 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
// contains filtered or unexported fields
}
Agent is one supported coding agent.
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.
func Detected ¶
func Detected() []*Agent
Detected returns the agents present on this machine, in display order.
func (*Agent) Apply ¶ added in v0.1.91
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.
func (*Agent) CLI ¶ added in v0.1.397
CLI is the agent's CLI: its version, the newest, and whether magpie can update it. ok is false for an agent without a CLI magpie knows.
func (*Agent) Drift ¶ added in v0.1.91
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) InstalledVersion ¶ added in v0.1.443
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.
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.
func (*Agent) Reapply ¶ added in v0.1.91
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) Spell ¶ added in v0.1.41
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.
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"`
}
CLI is what magpie knows of an agent's command-line program.
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.
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
}
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
}
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 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
}
Move is one of an agent's fields moved off a model magpie no longer serves.
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
// Context is the tokens the model takes, when known; the picker marks
// the large ones
Context int `json:"context,omitempty"`
}
Option is one value the picker offers for a field.
Source Files
¶
- agent.go
- agents.go
- agy.go
- alma.go
- applied.go
- cindy.go
- claude.go
- claudedesktop.go
- cline.go
- cliupdate.go
- codex.go
- commandcode.go
- devin.go
- droid.go
- dsh.go
- fx.go
- gemini.go
- grok.go
- hanako.go
- hermes.go
- icons.go
- kimi.go
- legacy.go
- omo.go
- omp.go
- pi.go
- qoder.go
- rename.go
- reseat.go
- route.go
- stash.go
- sync.go
- workbuddy.go
- writable_other.go
- wsl.go
- zcode.go