Help us shape the future of Go! Take the 2026 Go Developer Survey

jev

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 14 Imported by: 0

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

View Source
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
)
View Source
const PathPlaceholder = "<path>"

PathPlaceholder replaces a path outside the workspace.

Variables

View Source
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

func Redact(s string) string

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

func RedactAll(s, workspace string) string

RedactAll is Redact (secrets) and RedactPaths (file paths): what any text sent off the machine goes through.

func RedactPaths

func RedactPaths(s, workspace string) string

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

func RedactValue(v any, workspace string) any

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

func NewFromEnv() (*Client, error)

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.

func (*Client) Nouls

func (c *Client) Nouls(ctx context.Context, state any, qs map[string]Noul) (map[string]float64, string, error)

Nouls asks yes/no questions only and returns P(yes) per question id.

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

Jump to

Keyboard shortcuts

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