Documentation
¶
Overview ¶
Package server is the HTTP face of the memcode gateway: bearer-token auth in front of the metered LLM engine (router → Fireworks + the frontier vendor APIs). The wire protocol IS the OpenAI-compat surface (one-wire): POST /v1/chat/completions + GET /v1/models at the natural paths — one completion (or SSE stream) per call, with the memcode extensions riding as ignorable headers/fields (see internal/compat). The agent loop stays client-side; a future server-side loop (cloud workspaces, bots) can layer on without breaking CLI clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Port string // PORT (Cloud Run convention), default 8080
// InternalToken (MEMCODE_INTERNAL_TOKEN) gates the /internal/* admin surface
// (cooldown, audit log) — Cloud Scheduler + operators only, NEVER in the CLI.
// The user token must NOT open these: it's distributed to every client, so a
// user could otherwise stop the pool or read lifecycle data. Fails CLOSED:
// if unset, /internal/* denies everything.
InternalToken string
BackendName string // for the startup log: "hybrid" | "anthropic" | "fireworks"
// SystemPrefix is the server-owned doctrine prepended to every system
// prompt — the first concrete piece of "prompts live server-side". The full
// prompt library migrates here incrementally; this proves the seam.
SystemPrefix string // MEMCODE_SYSTEM_PREFIX (optional)
// WebAppURL is the memcode web app base URL (e.g. https://memcode.ai).
// The gateway calls {WebAppURL}/api/cli/verify to check org subscriptions
// and {WebAppURL}/api/cli/record-usage to report usage. CLOUD mode: every
// request authenticates as an org-scoped memcode_ key via this endpoint.
WebAppURL string // MEMCODE_WEB_APP_URL
// SelfHostToken enables SELF-HOST mode: a single shared bearer that
// authenticates every request as one always-entitled local identity — no
// accounts, no billing, your own provider keys. Mutually exclusive with
// WebAppURL (exactly one auth mode must be configured).
SelfHostToken string // MEMCODE_SELFHOST_TOKEN
Provider provider.ModelProvider
}
Config is the service configuration, env-only (keys NEVER in files).
func ConfigFromEnv ¶
ConfigFromEnv builds the service config. Backend selection reuses the same env contract as the engine: MEMCODE_PROVIDER=anthropic|fireworks|hybrid plus ANTHROPIC_API_KEY / MEMCODE_FIREWORKS_URL / _MODEL / _KEY (legacy MEMCODE_VLLM_* names still honored).