memcode

package
v0.22.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	Roles            []RoleModel // which label plays which routing role
	Models           []ModelFact // every servable label, catalog order
	CreditsExhausted bool        // empty wallet → selection must prefer keyed lanes
}

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.

func (ModelsInfo) Role

func (m ModelsInfo) Role(name string) string

Role returns the label configured for a routing role, "" when unset.

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 RoleModel

type RoleModel struct {
	Role   string `json:"role"`
	ID     string `json:"id"`
	Label  string `json:"label"`
	Window int    `json:"window,omitempty"`
	Vision bool   `json:"vision,omitempty"`
}

RoleModel is one configured routing role: which model (label) plays which job (planner/reviewer/standard/classify).

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