GitHubCommencer

La référence API provient des commentaires de documentation Go du code source et est rédigée en anglais.

package agentdir

import "github.com/nsgo-dev/game/pkg/editor/agentdir"

Vue d’ensemble

Package agentdir is experimental: its API and documented formats may change in a minor release. See the API stability policy. is experimental: its API and documented formats may change in a minor release. See the API stability policy. Package agentdir discovers local coding-agent binaries without sending prompts.

Index

Fonctions

func EncodeCache(c Cache) ([]byte, error)

EncodeCache writes c as YAML with two-space indentation, setting a zero Version to 1 and listing the agents sorted by name, so the same agents always encode to the same bytes. It refuses a cache DecodeCache would refuse.

func ValidateModelID(v string) error

ValidateModelID reports an error unless v is a model ID safe to pass to an agent's command line: 1 to 128 letters, digits and the characters . _ : / @ + -.

Types

type Cache struct {
	Version int    `yaml:"version"`
	Agents  []Info `yaml:"agents,omitempty"`
}

Cache is the editor's saved list of discovered agents, a YAML file whose version is 1.

func DecodeCache(data []byte) (Cache, error)

DecodeCache reads a cache from YAML, refusing unknown fields, a second document, any version but 1, a sign-in state other than signed_in, signed_out or unknown, and a model ID or effort level ValidateModelID refuses, so a value read back from the file is safe to pass to an agent's command line. Its errors are *loaderr.Error values with the line and field at fault.

type Info struct {
	Name    string      `yaml:"name"`
	Path    string      `yaml:"path"`
	Version string      `yaml:"version,omitempty"`
	SignIn  SignInState `yaml:"signIn"`
	Models  []Model     `yaml:"models,omitempty"`
	Checked time.Time   `yaml:"checked"`
}

Info describes one agent binary found on this machine: its name, path and version, whether it is signed in, the models it offers and when it was last checked.

func Probe(ctx context.Context, name, path string) (Info, error)

Probe runs the binary at path with --version, waiting at most three seconds, and describes it under name with the version it printed and the time it was checked (UTC, whole seconds). It never sends a prompt. A version answer says nothing about signing in, so the sign-in state is always Unknown. A binary that fails returns an Info with an unknown sign-in state and the error.

type Model struct {
	ID     string   `yaml:"id"`
	Label  string   `yaml:"label,omitempty"`
	Effort []string `yaml:"effort,omitempty"`
}

Model is one model an agent offers: its ID, the label to show and the reasoning-effort levels it accepts.

type SignInState string

SignInState is whether a probed agent's command-line tool is signed in to its provider.

const (
	// SignedIn is an agent whose own protocol answered as signed in.
	SignedIn SignInState = "signed_in"
	// SignedOut is an agent whose own protocol answered with an authentication error.
	SignedOut SignInState = "signed_out"
	// Unknown is an agent no probe has asked about signing in yet.
	Unknown SignInState = "unknown"
)