Documentation
¶
Overview ¶
Package client is the HTTP client of kōjō's API. The CLI's remote commands (kojo run, kojo sessions, kojo eval, kojo config) and the MCP server are built on it.
Index ¶
- func IsNotFound(err error) bool
- type ApplyResult
- type Client
- func (c *Client) ApplyConfig(ctx context.Context, doc []byte, dryRun bool) ([]ApplyResult, error)
- func (c *Client) Call(ctx context.Context, method, path string, query url.Values, body any) ([]byte, error)
- func (c *Client) Cancel(ctx context.Context, id string) error
- func (c *Client) ConfirmHistoryEval(ctx context.Context, id string, maxCostUSD float64) (*store.EvalRun, error)
- func (c *Client) Doctor(ctx context.Context) (json.RawMessage, error)
- func (c *Client) Eval(ctx context.Context, id string) (*store.EvalRun, error)
- func (c *Client) ExportConfig(ctx context.Context) ([]byte, error)
- func (c *Client) MinEvalPassRate(ctx context.Context) (float64, error)
- func (c *Client) Proposals(ctx context.Context, scope, skill string, open bool, limit int) ([]store.Proposal, error)
- func (c *Client) Run(ctx context.Context, in NewSession) (*store.Session, error)
- func (c *Client) SendMessage(ctx context.Context, id, text string) (*store.SessionMessage, error)
- func (c *Client) Session(ctx context.Context, id string) (*store.Session, error)
- func (c *Client) Sessions(ctx context.Context, status, repo string, limit int) ([]store.Session, error)
- func (c *Client) Skills(ctx context.Context, repo string) ([]Skill, map[string]string, error)
- func (c *Client) StartEval(ctx context.Context, skill string) (string, error)
- func (c *Client) StartHistoryEval(ctx context.Context, in HistoryEval) (string, error)
- func (c *Client) StartProposal(ctx context.Context, scope, skill string) (*store.Proposal, error)
- func (c *Client) Steps(ctx context.Context, id string) ([]store.Step, error)
- func (c *Client) Wait(ctx context.Context, id string, onStep func(store.Step)) (*store.Session, error)
- type Error
- type HistoryEval
- type NewSession
- type Option
- type Skill
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApplyResult ¶
type ApplyResult struct {
Scope string `json:"scope"`
Object string `json:"object"`
Revision string `json:"revision"`
Changed bool `json:"changed"`
}
ApplyResult is what applying one object did.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one kōjō server.
func New ¶
New returns a client for the server at base, authenticating with an API token (server.auth.tokens in kojo.yaml).
func (*Client) ApplyConfig ¶
ApplyConfig loads an export. With dryRun nothing is written.
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, method, path string, query url.Values, body any) ([]byte, error)
Call makes one API request and returns the response body as it came. path is relative to /api/v1 and starts with a slash. A []byte body is sent as YAML, anything else as JSON. It is for callers that pass the API through, such as the MCP server; the typed methods below are for everything else.
func (*Client) ConfirmHistoryEval ¶
func (c *Client) ConfirmHistoryEval(ctx context.Context, id string, maxCostUSD float64) (*store.EvalRun, error)
ConfirmHistoryEval starts the model runs of a validated eval from history. maxCostUSD is the bound the caller agreed to.
func (*Client) ExportConfig ¶
ExportConfig returns the day-2 state as YAML.
func (*Client) MinEvalPassRate ¶
MinEvalPassRate returns the pass rate the server's activation policy requires of an eval.
func (*Client) Proposals ¶
func (c *Client) Proposals(ctx context.Context, scope, skill string, open bool, limit int) ([]store.Proposal, error)
Proposals lists the changes kōjō proposed to its skills, newest first. Empty scope and skill list them all; open lists only those not decided.
func (*Client) SendMessage ¶
SendMessage gives a session at work a message its next model step reads.
func (*Client) Sessions ¶
func (c *Client) Sessions(ctx context.Context, status, repo string, limit int) ([]store.Session, error)
Sessions lists sessions, newest first.
func (*Client) StartHistoryEval ¶
StartHistoryEval starts mining and validating the cases of an eval from a repository's history and returns the run's ID. No model runs until ConfirmHistoryEval.
func (*Client) StartProposal ¶
StartProposal asks kōjō to propose a change to one skill of a scope (org or repo:<forge/owner/name>) from the evidence it has gathered.
type HistoryEval ¶
type HistoryEval struct {
Skill string `json:"skill"`
Repo string `json:"repo"`
TestCmd string `json:"test_cmd"`
Limit int `json:"limit"`
// Since is a date (2026-06-01) or an RFC 3339 time; empty is the
// server's default.
Since string `json:"since,omitempty"`
}
HistoryEval asks for an eval of a skill from a repository's history.
type NewSession ¶
type NewSession struct {
Repo string `json:"repo,omitempty"`
Text string `json:"text,omitempty"`
Skill string `json:"skill,omitempty"`
Number int `json:"number,omitempty"`
IsPR bool `json:"is_pr,omitempty"`
DryRun bool `json:"dry_run,omitempty"`
DraftID string `json:"draft_id,omitempty"`
Inputs map[string]string `json:"inputs,omitempty"`
}
NewSession is the body of a session request.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithSurface ¶
WithSurface names the surface requests are attributed to: cli or mcp.
func WithTransport ¶
func WithTransport(rt http.RoundTripper) Option
WithTransport replaces the HTTP transport. The MCP endpoint of a running server uses it to call its own API in process.