{"modulePath":"github.com/css521/agentenv","version":"v0.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package protocol\n\nPackage protocol defines the wire types for the agentenv daemon's newline-delimited JSON API. Server (internal/api) and client (internal/cli's ctl) BOTH import this — having a single typed shape on both sides means the client can \\`json.NewDecoder(conn).Decode(\u0026Response)\\` directly into a struct, instead of unmarshalling into map\\[string]any and doing fragile type assertions on every field.\n\nProtocol shape:\n\n  - 1 line of JSON in = 1 Request from the client.\n  - For all ops except \"exec\": exactly 1 line of JSON out = 1 Response.\n  - For \"exec\": multiple Response frames stream back — output frames carry Stdout/Stderr only; the terminal frame carries OK=true (and Exit/Node/ Head) or Error=\"...\". Clients keep reading frames until OK or Error.\n\n## Types\n\n```go\ntype Change struct {\n\tKind string `json:\"kind\"`\n\tPath string `json:\"path\"`\n}\n```\nChange is one entry in a diff/show response.\n\n```go\ntype Node struct {\n\tID      string `json:\"id\"`\n\tParent  string `json:\"parent,omitempty\"`\n\tMessage string `json:\"message\"`\n\tHead    bool   `json:\"head,omitempty\"`\n\tLeaf    bool   `json:\"leaf,omitempty\"`\n}\n```\nNode is one DAG node summary (log/branches output).\n\n```go\ntype Proc struct {\n\tPID  int    `json:\"pid\"`\n\tArgs string `json:\"args\"`\n\tLog  string `json:\"log\"`\n}\n```\nProc is one tracked background process (ps output).\n\n```go\ntype Request struct {\n\tOp         string                `json:\"op\"`\n\tCmd        string                `json:\"cmd,omitempty\"`\n\tNode       string                `json:\"node,omitempty\"`\n\tMessage    string                `json:\"message,omitempty\"`\n\tA          string                `json:\"a,omitempty\"`\n\tB          string                `json:\"b,omitempty\"`\n\tPid        int                   `json:\"pid,omitempty\"`\n\tKeep       int                   `json:\"keep,omitempty\"`\n\tName       string                `json:\"name,omitempty\"`       // tag: name to set/get\n\tRef        string                `json:\"ref,omitempty\"`        // tag: target ref\n\tBase       string                `json:\"base,omitempty\"`       // tournament: base ref\n\tTest       string                `json:\"test,omitempty\"`       // tournament: test command\n\tCandidates []TournamentCandidate `json:\"candidates,omitempty\"` // tournament: candidates\n\tVersion    string                `json:\"version,omitempty\"`    // upgrade: explicit target version (empty = latest)\n\tForce      bool                  `json:\"force,omitempty\"`      // upgrade: bypass the maintenance window\n}\n```\nRequest is one operation the client wants to perform.\n\n```go\ntype Response struct {\n\tOK         bool               `json:\"ok,omitempty\"`\n\tError      string             `json:\"error,omitempty\"`\n\tMessage    string             `json:\"message,omitempty\"` // human-readable status (e.g. upgrade progress)\n\tTags       map[string]string  `json:\"tags,omitempty\"`\n\tBranches   []TournamentBranch `json:\"branches,omitempty\"`\n\tWinner     string             `json:\"winner,omitempty\"`\n\tWinnerNode string             `json:\"winner_node,omitempty\"`\n\tExit       *int               `json:\"exit,omitempty\"`\n\tStdout     string             `json:\"stdout,omitempty\"`\n\tStderr     string             `json:\"stderr,omitempty\"`\n\tNode       string             `json:\"node,omitempty\"`\n\tHead       string             `json:\"head,omitempty\"`\n\tParent     string             `json:\"parent,omitempty\"`\n\tPid        int                `json:\"pid,omitempty\"`\n\tLog        string             `json:\"log,omitempty\"`\n\tNodes      []Node             `json:\"nodes,omitempty\"`\n\tChanges    []Change           `json:\"changes,omitempty\"`\n\tProcs      []Proc             `json:\"procs,omitempty\"`\n\tRemoved    []string           `json:\"removed,omitempty\"`\n\tDropped    []string           `json:\"dropped,omitempty\"`\n}\n```\nResponse is one frame the server emits. For non-exec ops it's the only frame. For exec it can be either a streaming output frame (only Stdout/Stderr set) or the terminal frame (OK or Error set; for OK, Exit/Node/Head also).\n\n```go\nfunc (r *Response) Streaming() bool\n```\nStreaming returns true if this exec frame is a streaming output frame (i.e. the server is still sending — the client should keep reading until Terminal).\n\n```go\nfunc (r *Response) Terminal() bool\n```\nTerminal returns true if this frame ends the exec stream (OK or Error).\n\n```go\ntype TournamentBranch struct {\n\tName     string `json:\"name\"`\n\tCmd      string `json:\"cmd\"`\n\tNode     string `json:\"node\"`\n\tTestExit int    `json:\"test_exit\"`\n}\n```\nTournamentBranch is one tournament result entry.\n\n```go\ntype TournamentCandidate struct {\n\tName string `json:\"name\"`\n\tCmd  string `json:\"cmd\"`\n}\n```\nTournamentCandidate is one branch to try in a tournament.\n\n","path":"github.com/css521/agentenv/internal/protocol","name":"protocol","synopsis":"Package protocol defines the wire types for the agentenv daemon's newline-delimited JSON API.","isRedistributable":true}
