omniroute

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 24 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 omniroute reads an OmniRoute data directory read-only and converts it into a remora.yaml document, its secrets and the OAuth credential files remora's accounts import.

Index

Constants

This section is empty.

Variables

View Source
var ErrUndecryptable = errors.New("value does not decrypt with this STORAGE_ENCRYPTION_KEY")

ErrUndecryptable is returned for a well-formed value that no derived key opens.

Functions

func LoadSecret

func LoadSecret(dataDir string, env func(string) (string, bool)) ([]string, error)

LoadSecret lists the STORAGE_ENCRYPTION_KEY values to try, in order: the environment variable, then the STORAGE_ENCRYPTION_KEY= line of <dataDir>/server.env, then of <dataDir>/.env. For a file value, quotes around it are stripped; when it contains "=", the forms OmniRoute's own loader produces (it keeps only the text up to the second "=" of the line: split("=", 2)[1]) follow, with and without a leftover opening quote. Missing files are skipped.

Types

type APIKey

type APIKey struct {
	ID, Name, Key                string
	AllowedModels, AllowedCombos []string
	AccessMode                   string // "all" | "restricted"
	Revoked, Expired             bool
	Disabled                     bool // is_active = 0 or is_banned = 1
}

APIKey is an api_keys row: a client key, kept in plaintext by OmniRoute.

type Combo

type Combo struct {
	Name string
	Data json.RawMessage
}

Combo is a combos row; Data is its JSON definition.

type Connection

type Connection struct {
	ID, Provider, AuthType, Name, Email, ProjectID string
	APIKey, AccessToken, RefreshToken, IDToken     string
	ExpiresAt                                      string
	ExpiresIn                                      int
	Active                                         bool
	Specific                                       map[string]any // provider_specific_data
}

Connection is a provider_connections row with its secrets decrypted.

type Credential

type Credential struct {
	Provider, FileName string
	JSON               []byte
}

Credential is an OAuth credential file in the shape the accounts engine stores, ready for POST /api/accounts/import.

type Decrypter

type Decrypter struct {
	// contains filtered or unexported fields
}

Decrypter opens OmniRoute's encrypted fields.

func NewDecrypter

func NewDecrypter(secret string) *Decrypter

NewDecrypter derives both keys OmniRoute may have used: the current one (static salt) and the legacy one (salt = the first 16 bytes of sha256(secret)). scrypt parameters are Node's scryptSync defaults: N=16384, r=8, p=1.

func PickSecret

func PickSecret(cands []string, probe string) (*Decrypter, error)

PickSecret returns a Decrypter for the first candidate that opens probe, any encrypted value from the database.

func (*Decrypter) Decrypt

func (d *Decrypter) Decrypt(v string) (string, error)

Decrypt returns a value without the "enc:v1:" prefix unchanged, and otherwise the plaintext. A malformed value is an error; a well-formed one that neither key opens is ErrUndecryptable.

type Node

type Node struct{ ID, Type, Name, Prefix, BaseURL string }

Node is a provider_nodes row: a custom provider such as an OpenAI-compatible endpoint.

type Result

type Result struct {
	Doc         config.File
	Secrets     config.Secrets
	Credentials []Credential
	Warnings    []string
}

Result is what an OmniRoute snapshot becomes: a remora.yaml document whose secrets are env: references, the values of those references, the OAuth credential files to import as accounts, and what could not be carried over.

func Convert

func Convert(s Snapshot, now time.Time) Result

Convert maps a snapshot onto remora. It never drops something silently: what it cannot carry over is a warning, and a combo member naming a provider remora does not have is kept verbatim for the server's plan to reject.

type Snapshot

type Snapshot struct {
	Nodes       []Node
	Connections []Connection
	Keys        []APIKey
	Combos      []Combo
}

Snapshot is what Read finds in an OmniRoute database.

func Read

func Read(ctx context.Context, dataDir string, env func(string) (string, bool), now time.Time) (Snapshot, error)

Read opens <dataDir>/storage.sqlite read-only and immutable (no write, no journal, no WAL checkpoint), decrypts connection secrets with the STORAGE_ENCRYPTION_KEY that LoadSecret finds, and returns every row the importer converts. Columns later OmniRoute versions added are optional. now decides which client keys have expired.

Jump to

Keyboard shortcuts

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