client

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is the API's 404.

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

func New(base, token string, opts ...Option) (*Client, error)

New returns a client for the server at base, authenticating with an API token (server.auth.tokens in kojo.yaml).

func (*Client) ApplyConfig

func (c *Client) ApplyConfig(ctx context.Context, doc []byte, dryRun bool) ([]ApplyResult, error)

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) Cancel

func (c *Client) Cancel(ctx context.Context, id string) error

Cancel asks a session to stop.

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) Doctor

func (c *Client) Doctor(ctx context.Context) (json.RawMessage, error)

Doctor runs the server's doctor checks and returns the report as JSON.

func (*Client) Eval

func (c *Client) Eval(ctx context.Context, id string) (*store.EvalRun, error)

Eval returns an eval run.

func (*Client) ExportConfig

func (c *Client) ExportConfig(ctx context.Context) ([]byte, error)

ExportConfig returns the day-2 state as YAML.

func (*Client) MinEvalPassRate

func (c *Client) MinEvalPassRate(ctx context.Context) (float64, error)

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) Run

func (c *Client) Run(ctx context.Context, in NewSession) (*store.Session, error)

Run starts a session.

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, id, text string) (*store.SessionMessage, error)

SendMessage gives a session at work a message its next model step reads.

func (*Client) Session

func (c *Client) Session(ctx context.Context, id string) (*store.Session, error)

Session returns one session.

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) Skills

func (c *Client) Skills(ctx context.Context, repo string) ([]Skill, map[string]string, error)

Skills lists the skills a repository (or the org, when empty) resolves to.

func (*Client) StartEval

func (c *Client) StartEval(ctx context.Context, skill string) (string, error)

StartEval starts an eval of a skill and returns the run's ID.

func (*Client) StartHistoryEval

func (c *Client) StartHistoryEval(ctx context.Context, in HistoryEval) (string, error)

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

func (c *Client) StartProposal(ctx context.Context, scope, skill string) (*store.Proposal, error)

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.

func (*Client) Steps

func (c *Client) Steps(ctx context.Context, id string) ([]store.Step, error)

Steps returns a session's recorded steps.

func (*Client) Wait

func (c *Client) Wait(ctx context.Context, id string, onStep func(store.Step)) (*store.Session, error)

Wait polls a session until it ends or waits for a human, calling onStep for every new step.

type Error

type Error struct {
	Status  int
	Message string
}

Error is an error answer of the API.

func (*Error) Error

func (e *Error) Error() string

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

func WithSurface(s string) Option

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.

type Skill

type Skill struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Layer       string   `json:"layer"`
	Tier        string   `json:"tier"`
	Tools       []string `json:"tools"`
	Overrides   []string `json:"overrides"`
	Writes      bool     `json:"writes"`
}

Skill is a resolved skill, as listed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL