Documentation
¶
Overview ¶
Package localapi is the daemon's loopback HTTP surface on localhost:7777: the OpenAI-compatible /v1 endpoints (Phase 0 exit criterion) and the management /api/v1 REST+SSE API that the CLI, TUI and embedded web dashboard all consume (SPEC §A1.2: one source of truth).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadOrCreateToken ¶
LoadOrCreateToken returns the per-install bearer token, generating it with 0600 on first run.
TODO(keychain): store in macOS Keychain / Windows DPAPI / secret service instead of a file (SPEC §A1.2); file+0600 is the Phase 0 baseline.
Types ¶
type Deps ¶
type Deps struct {
Engine *engine.Engine
Governor *governor.Governor // may be nil
Models *models.Manager // may be nil
LogRing *logging.Ring // may be nil
Hardware *typesv1.CapabilityProfile
Log *slog.Logger
WebFS fs.FS // embedded dashboard dist; may be nil
NodeID string
Version string
Standalone bool
// RequireAuthV1 extends bearer auth to the OpenAI /v1 endpoints.
RequireAuthV1 bool
// Token authenticates /api/v1 (and /v1 when RequireAuthV1).
Token string
}
Deps wires the server to the daemon internals.
type EarningsResponse ¶
type EarningsResponse struct {
EarnedMicrocredits int64 `json:"earned_microcredits"`
EarnedCredits float64 `json:"earned_credits"`
EstUSD float64 `json:"est_usd"`
EstUSDPerDay float64 `json:"est_usd_per_day"`
LifetimeTokens int64 `json:"lifetime_tokens"`
Escrow float64 `json:"escrow_credits"`
Note string `json:"note"`
}
EarningsResponse is standalone/demo accounting until the ledger exists (Phase 2). Numbers are honest simulations, labelled as such.
type GPUSummary ¶
type HardwareSummary ¶
type Limits ¶
type Limits struct {
ServePolicy string `json:"serve_policy"`
IdleAfterSec int `json:"idle_after_seconds"`
YieldGraceSec int `json:"yield_grace_seconds"`
ServeOnBattery bool `json:"serve_on_battery"`
MaxTempCelsius float64 `json:"max_temp_celsius"`
Schedule []string `json:"schedule"`
}
Limits mirrors the governor policy knobs exposed to operators.
type ModelRow ¶
type ModelRow struct {
ID string `json:"id"`
SizeBytes int64 `json:"size_bytes"`
Pinned bool `json:"pinned"`
LastUsed time.Time `json:"last_used"`
State string `json:"state"`
Loaded bool `json:"loaded"`
Default bool `json:"default"`
}
ModelRow merges cache state with loaded state.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the loopback HTTP server.
type StatusResponse ¶
type StatusResponse struct {
NodeID string `json:"node_id"`
Version string `json:"version"`
Standalone bool `json:"standalone"`
State string `json:"state"`
UptimeSeconds int64 `json:"uptime_seconds"`
DefaultModel string `json:"default_model"`
ModelsLoaded int `json:"models_loaded"`
Inflight int `json:"inflight"`
OnBattery bool `json:"on_battery"`
TempCelsius float64 `json:"temp_celsius"`
Hardware *HardwareSummary `json:"hardware,omitempty"`
Stats telemetry.Snapshot `json:"stats"`
}
StatusResponse is GET /api/v1/status (also streamed on /api/v1/events).