Documentation
¶
Overview ¶
Package jev is a minimal client for TypeSafe's System One API (Jev), used as an optional judge where celeste's own rules are a guess (#175). Every caller must treat an error as "no opinion" and fall back to its rules.
API: POST https://api.typesafe.ai/v1/systemone, verified against the live docs and endpoint on 2026-09-25. A missing key returns 403, not the 401 the docs list.
Index ¶
Constants ¶
const ( DefaultModel = "jev-latest" // Timeout bounds every call; callers fall back to their rules after it. // Measured latency is ~0.2-0.45 s for up to ~11k input tokens. Timeout = 2500 * time.Millisecond )
const PathPlaceholder = "<path>"
PathPlaceholder replaces a path outside the workspace.
Variables ¶
var ErrNoKey = errors.New("jev: no TypeSafe API key (set TYPESAFE_API_KEY or ~/.celeste/typesafe.key)")
ErrNoKey means no key is configured; Jev stays off.
Functions ¶
func Redact ¶
Redact replaces likely secrets with [REDACTED]. It errs toward redacting: a lost word costs Jev a little accuracy, a leaked key costs much more.
func RedactAll ¶
RedactAll is Redact (secrets) and RedactPaths (file paths): what any text sent off the machine goes through.
func RedactPaths ¶
RedactPaths rewrites file paths before text leaves the machine (2.0 W3): a path inside workspace becomes workspace-relative ("." for the workspace itself); any other absolute or ~ path becomes <path>. An empty workspace makes every absolute path <path>.
func RedactValue ¶
RedactValue applies RedactAll to every string in v, a JSON-shaped value (a string, or anything that marshals to JSON). It returns v unchanged when v does not marshal (the request that would carry it fails anyway).
Types ¶
type Answer ¶
type Answer struct {
Type string `json:"type"`
Noul *float64 `json:"noul,omitempty"`
Choice string `json:"choice,omitempty"`
Score *float64 `json:"score,omitempty"`
Probabilities map[string]float64 `json:"probabilities,omitempty"`
Confidence float64 `json:"confidence,omitempty"`
}
Answer is one typed answer. Noul carries P(yes); Choice the most likely option; Score the probability-weighted level (0-based, can fall between levels). Probabilities and Confidence come with choice and score answers.
type Client ¶
type Client struct {
Key string
Model string
URL string
HTTP *http.Client
// Workspace makes paths inside it workspace-relative in what Ask sends;
// every other absolute or ~ path is sent as <path> (RedactPaths).
Workspace string
}
Client calls the System One endpoint.
func NewFromEnv ¶
NewFromEnv loads the key from TYPESAFE_API_KEY, else ~/.celeste/typesafe.key.
func (*Client) Ask ¶
func (c *Client) Ask(ctx context.Context, state any, qs map[string]Question) (map[string]Answer, string, error)
Ask asks every question against state in one request and returns the answers by question id, with the response's model version for logging. The API shape was checked against https://docs.typesafe.ai/api.md (Choice, Score, Noul) on 2026-10-01.
type Noul ¶
type Noul struct {
Instructions string
True, False string // optional criteria: what yes and no mean
}
Noul is a yes/no question; the answer is P(yes).
type Question ¶
type Question struct {
Type string `json:"type"`
Instructions string `json:"instructions"`
Criteria any `json:"criteria,omitempty"`
}
Question is one typed System One question: "noul" (yes/no), "choice" (Criteria maps each option to its description, nil for none) or "score" (Criteria is the ordered list of level descriptions, 2 to 10).