memcode

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package memcode is the memcode PROTOCOL's provider: the OpenAI-compat chat/completions dialect PLUS the memcode extensions — the two-system stable/volatile convention, the memcode_opaque reasoning round-trip, the `memcode` response object, the enforced `memcode_billing` lane, session affinity via `user`, and the GET /v1/models routing CONTROL PLANE the CLI-side selection policy runs on. It is a configuration of the shared generic engine (providers/compat) — same wire, extensions on — plus the control-plane client. One implementation, consumed by the CLI; the gateway SERVES this dialect (api/internal/compat + api/internal/server).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// BaseURL is the gateway ROOT (e.g. https://code.memcode.ai); the /v1
	// compat surface is mounted beneath it.
	BaseURL string
	// Token is the memcode_ org key.
	Token string
	// Compose renders legacy-shaped side calls (Mode stamped, doctrine not yet
	// composed) — the CALLER owns doctrine.
	Compose func(wire.Request) (wire.Request, error)
}

Config configures the memcode-dialect transport.

type ModelFact

type ModelFact struct {
	Label     string
	Name      string // friendly display name ("Sonnet 5")
	Desc      string // one-line picker description
	Group     string // display family — presentation only
	Vendor    string // authoritative serving vendor — the selection/steering identity
	Window    int
	Vision    bool
	PDF       bool
	Reasoning bool
	Pinnable  bool // offered in the /model picker (every listed label serves)
	Byok      bool // this model's vendor is covered by the user's own key
}

ModelFact is one servable model with the control-plane facts selection reads. Label is the wire model id (the value sent in `model`).

type ModelsInfo

type ModelsInfo struct {
	Backend          string      // gateway provider mode ("hybrid" in prod)
	Vendors          []string    // configured strong vendors; [0] is the deployment default
	Models           []ModelFact // every servable label, catalog order
	CreditsExhausted bool        // empty wallet → selection must prefer keyed lanes

	// SubVendors is CLIENT-STAMPED (never decoded from the wire): vendors
	// served by attached subscription lanes, i.e. $0 serving paths that
	// selection should prefer. Empty on every wire-decoded snapshot, so all
	// gateway-parity behavior is byte-identical when no subs are attached.
	SubVendors map[string]bool `json:"-"`
}

ModelsInfo is the decoded control plane: everything CLI-side selection needs for one hosted org, from one GET /v1/models call.

func FetchModels

func FetchModels(ctx context.Context, baseURL, token string) (ModelsInfo, error)

FetchModels asks the gateway for the routing control plane, decoding the SHARED wire types (providers/compat ModelList — the same declarations the gateway serves with). Network-bound; pass a bounded context.

func (ModelsInfo) ByokVendorSet

func (m ModelsInfo) ByokVendorSet() map[string]bool

ByokVendorSet returns the vendors the user has keys for, derived from the per-model byok stamps (a vendor is keyed iff any of its models is).

func (ModelsInfo) DefaultVendor

func (m ModelsInfo) DefaultVendor() string

DefaultVendor is the deployment's default strong vendor (vendors[0]), "openai" when the gateway didn't report one.

func (ModelsInfo) Fact

func (m ModelsInfo) Fact(label string) (ModelFact, bool)

Fact returns the servable entry for a label.

type PinnableModel

type PinnableModel struct {
	Label  string
	Name   string
	Desc   string
	Group  string
	Window int
	Vision bool
	Byok   bool
}

PinnableModel is one /model picker entry — the pinnable subset of the servable list, in the shape the picker renders.

type Transport

type Transport struct {
	*compat.Transport
}

Transport is the memcode-dialect turn transport. A named wrapper over the shared compat engine so this package's public surface is its OWN type — that the dialect rides the generic engine is an implementation detail, free to change without touching consumers.

func New

func New(cfg Config) *Transport

New returns the memcode-dialect turn transport: the shared compat engine with the memcode extensions on, mounted at {base}/v1.

Jump to

Keyboard shortcuts

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