Documentation
¶
Overview ¶
Package agentprofile is the agent editor both front ends share: what an editor is shown of each agent in the configuration, and how the profiles it sends back become the agents that are written.
The Desktop GUI and the web gateway each had their own copy. The desktop's kept every field the form cannot show; the gateway's rebuilt each agent from the form alone, so every save there dropped each agent's environment variables and turned a shell agent into `command: [<id>]`. One resolver means one set of rules for what a save may change.
Index ¶
- Constants
- Variables
- func EffectiveAdapter(spec agent.Spec) string
- func ExecutableLabel(profile toolcatalog.ProfileID) string
- func LockedReason(spec agent.Spec) string
- func ProfileForExecutable(executable string) toolcatalog.ProfileID
- func Resolve(inputs []Input, current []agent.Spec, baseDir, defaultBackend string) ([]agent.Spec, error)
- type Input
- type Profile
Constants ¶
const ( // MinProfiles and MaxProfiles bound the agents a save may configure. MinProfiles = 1 MaxProfiles = 8 )
const ( ReasonShell = "advanced_shell" ReasonEnvironment = "advanced_environment" ReasonInvalidCommand = "invalid_command" ReasonAdapter = "advanced_adapter" ReasonLegacyFields = "legacy_profile_fields" )
Read-only reasons, which the interface explains to the user.
Variables ¶
var ErrInvalid = errors.New("one or more agent profiles are invalid")
ErrInvalid is the error of every refused save. Its detail names an agent by its position and says what is wrong, never a value: argv and environment values can be credentials.
Functions ¶
func EffectiveAdapter ¶
EffectiveAdapter is the adapter an agent runs with: its own, or the default of the catalogue tool its executable names, or the generic one.
func ExecutableLabel ¶
func ExecutableLabel(profile toolcatalog.ProfileID) string
ExecutableLabel is the name an editor shows for an agent's executable. It names only a catalogue tool, never a path or a custom executable, which can be a credential or name the user's home directory.
func LockedReason ¶
LockedReason says why the editor cannot represent spec without loss, or is empty when it can. A locked agent is shown read-only, and a save must send it back with Preserve and nothing else: it is then copied as it is.
func ProfileForExecutable ¶
func ProfileForExecutable(executable string) toolcatalog.ProfileID
ProfileForExecutable is the catalogue tool an executable names, or Custom.
func Resolve ¶
func Resolve(inputs []Input, current []agent.Spec, baseDir, defaultBackend string) ([]agent.Spec, error)
Resolve turns the profiles an editor sent back into the agents to write, against current, the agents of the configuration the editor was shown. The caller must have checked that the file still has that content, and must write only if it still has it: what a preserved agent keeps is what current holds.
- A locked agent must come back with Preserve, and is copied as it is: environment, shell script and every other field. One that is missing, or sent without Preserve, is refused: it cannot be removed or replaced from the form, only in the YAML.
- An agent sent with Preserve keeps its command and adapter; only its name, working directory and backend are taken from the form. Preserve for an ID the file does not have is refused.
- Any other profile is a new agent, built from the form alone. It inherits nothing from an agent of the same ID, and never matches one by position: an agent removed and added again is a new one.
Types ¶
type Input ¶
type Input struct {
ID string
Name string
PresetID string
Cwd string
Backend string
Adapter string
Argv []string
Preserve bool
}
Input is one profile an editor sends back. Preserve says the agent is the existing one of that ID, whose command, adapter and every field the form does not show are kept; without it the profile is a new agent that inherits nothing from the file, whatever its ID.
type Profile ¶
type Profile struct {
ID string
Name string
PresetID string
Cwd string
Backend string
Adapter string
Argv []string
ExecutableLabel string
ArgumentCount int
Locked bool
ReadOnlyReason string
PreserveOnSave bool
}
Profile is what an editor is shown of one agent. It deliberately has no environment values and no shell body, and never carries an existing agent's argv: a credential passed as an argument is found by no heuristic reliably, so the command stays in Go until the user replaces it as a whole.
Its fields are those of each front end's own DTO, in the same order, so a front end converts it with a plain type conversion.