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) ApprovePlan(ctx context.Context, id string) (*store.Session, error)
- func (c *Client) Call(ctx context.Context, method, path string, query url.Values, body any) ([]byte, error)
- func (c *Client) Campaign(ctx context.Context, id string) (*store.CampaignView, error)
- func (c *Client) Campaigns(ctx context.Context, status string, limit int) ([]store.CampaignView, error)
- func (c *Client) Cancel(ctx context.Context, id string) error
- func (c *Client) CancelCampaign(ctx context.Context, id string) (*store.Campaign, error)
- func (c *Client) ConfirmCampaign(ctx context.Context, id string, maxCostUSD float64) (*store.Campaign, error)
- func (c *Client) ConfirmHistoryEval(ctx context.Context, id string, maxCostUSD float64) (*store.EvalRun, error)
- func (c *Client) ContinueCampaign(ctx context.Context, id string, maxCostUSD float64) (*store.Campaign, error)
- func (c *Client) CreateCampaign(ctx context.Context, in NewCampaign) (*store.Campaign, error)
- func (c *Client) DeclinePlan(ctx context.Context, id string) (*store.Session, 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) ReportHTML(ctx context.Context, id string) ([]byte, error)
- func (c *Client) RetryCampaign(ctx context.Context, id string) (*store.Campaign, error)
- func (c *Client) RevokeReports(ctx context.Context, id string) 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) ShareReport(ctx context.Context, id string, ttl time.Duration) (*ReportLink, 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 NewCampaign
- type NewSession
- type Option
- type ReportLink
- 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) ApprovePlan ¶ added in v0.3.0
ApprovePlan gives the go-ahead on the plan a session waits on.
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) Campaign ¶ added in v0.4.0
Campaign returns a campaign and where each of its repositories stands.
func (*Client) Campaigns ¶ added in v0.4.0
func (c *Client) Campaigns(ctx context.Context, status string, limit int) ([]store.CampaignView, error)
Campaigns lists campaigns, newest first, with their totals. An empty status lists all.
func (*Client) CancelCampaign ¶ added in v0.4.0
CancelCampaign cancels a campaign and asks its open sessions to stop.
func (*Client) ConfirmCampaign ¶ added in v0.4.0
func (c *Client) ConfirmCampaign(ctx context.Context, id string, maxCostUSD float64) (*store.Campaign, error)
ConfirmCampaign starts a pending campaign. maxCostUSD is the bound the caller agreed to.
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) ContinueCampaign ¶ added in v0.4.0
func (c *Client) ContinueCampaign(ctx context.Context, id string, maxCostUSD float64) (*store.Campaign, error)
ContinueCampaign starts a paused campaign again; maxCostUSD raises its bound (0 keeps it).
func (*Client) CreateCampaign ¶ added in v0.4.0
CreateCampaign creates a pending campaign: nothing runs until it is confirmed with its cost bound.
func (*Client) DeclinePlan ¶ added in v0.3.0
DeclinePlan declines the plan a session waits on: it ends without changing anything.
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) ReportHTML ¶ added in v0.3.0
ReportHTML returns a session's report page, as a link would show it.
func (*Client) RetryCampaign ¶ added in v0.4.0
RetryCampaign runs a campaign's failed repositories again.
func (*Client) RevokeReports ¶ added in v0.3.0
RevokeReports ends every link to a session's report made so far.
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) ShareReport ¶ added in v0.3.0
func (c *Client) ShareReport(ctx context.Context, id string, ttl time.Duration) (*ReportLink, error)
ShareReport makes a link to a session's report. A zero ttl takes the lifetime settings/reports sets.
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 NewCampaign ¶ added in v0.4.0
type NewCampaign struct {
Title string `json:"title,omitempty"`
Task string `json:"task"`
Skill string `json:"skill,omitempty"`
Inputs map[string]string `json:"inputs,omitempty"`
Repos []string `json:"repos,omitempty"`
Team string `json:"team,omitempty"`
Match string `json:"match,omitempty"`
MaxParallel *int `json:"max_parallel,omitempty"`
Pilot *int `json:"pilot,omitempty"`
}
NewCampaign is the body of POST /campaigns: a task and the repositories to run it in, by list, team and pattern together.
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"`
// Plan asks for a plan and a person's go-ahead before code changes.
Plan bool `json:"plan,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.