runtimekit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 17 Imported by: ? 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 runtimekit composes agentic-moe into a batteries-included planning runtime.

Index

Examples

Constants

View Source
const ConfigVersion = 1

ConfigVersion is the latest supported on-disk configuration version.

Variables

This section is empty.

Functions

func Migrate

func Migrate(body []byte) ([]byte, error)

Migrate upgrades supported legacy configuration to the current schema. Versionless v0 files are the only legacy form and map directly to v1.

func Schema

func Schema() map[string]any

Schema returns the JSON Schema for the current configuration version.

func SchemaJSON

func SchemaJSON() ([]byte, error)

SchemaJSON renders the schema deterministically enough for CLI output.

Types

type Config

type Config struct {
	Version int            `json:"version" yaml:"version"`
	Runtime RuntimeConfig  `json:"runtime" yaml:"runtime"`
	Models  ModelConfig    `json:"models" yaml:"models"`
	Experts []ExpertConfig `json:"experts" yaml:"experts"`
	Ollama  OllamaConfig   `json:"ollama" yaml:"ollama"`
	HTTP    HTTPConfig     `json:"http" yaml:"http"`
}

Config is the portable YAML or JSON configuration contract.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a safe local configuration with general-purpose experts.

func Load

func Load(path string, getenv func(string) string, overrides Overrides) (Config, error)

Load reads a strict YAML/JSON config and applies env then CLI overrides.

func Parse

func Parse(body []byte, getenv func(string) string) (Config, error)

Parse decodes strict YAML or JSON content, applies environment overrides, and validates it.

func (Config) Validate

func (c Config) Validate() error

Validate checks all configuration invariants without contacting providers.

type Duration

type Duration time.Duration

Duration is a human-readable time.Duration used consistently by YAML and JSON.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON renders a quoted human-readable duration.

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

MarshalText renders a duration in Go's stable duration syntax.

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(body []byte) error

UnmarshalJSON requires a quoted human-readable duration.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText accepts values such as "5s" and "250ms".

type ExpertConfig

type ExpertConfig struct {
	ID               string   `json:"id" yaml:"id"`
	Name             string   `json:"name" yaml:"name"`
	Description      string   `json:"description" yaml:"description"`
	Keywords         []string `json:"keywords" yaml:"keywords"`
	NegativeKeywords []string `json:"negative_keywords,omitempty" yaml:"negative_keywords,omitempty"`
	Prompt           string   `json:"prompt,omitempty" yaml:"prompt,omitempty"`
	DefaultTier      string   `json:"default_tier" yaml:"default_tier"`
	Priority         int      `json:"priority" yaml:"priority"`
	CanSynthesize    bool     `json:"can_synthesize,omitempty" yaml:"can_synthesize,omitempty"`
	MaxIterations    int      `json:"max_iterations,omitempty" yaml:"max_iterations,omitempty"`
	MaxToolCalls     int      `json:"max_tool_calls,omitempty" yaml:"max_tool_calls,omitempty"`
}

ExpertConfig describes a declarative expert available through every SDK.

type ExpertView

type ExpertView struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Description   string `json:"description,omitempty"`
	DefaultTier   string `json:"default_tier"`
	CanSynthesize bool   `json:"can_synthesize,omitempty"`
}

ExpertView is a stable public projection of an expert definition.

type HTTPConfig

type HTTPConfig struct {
	Address        string   `json:"address" yaml:"address"`
	BearerTokenEnv string   `json:"bearer_token_env,omitempty" yaml:"bearer_token_env,omitempty"`
	AllowedHosts   []string `json:"allowed_hosts,omitempty" yaml:"allowed_hosts,omitempty"`
	AllowedOrigins []string `json:"allowed_origins,omitempty" yaml:"allowed_origins,omitempty"`
	MaxBodyBytes   int64    `json:"max_body_bytes" yaml:"max_body_bytes"`
	MaxConcurrent  int      `json:"max_concurrent" yaml:"max_concurrent"`
	RequestTimeout Duration `json:"request_timeout" yaml:"request_timeout"`
	ShutdownGrace  Duration `json:"shutdown_grace" yaml:"shutdown_grace"`
}

HTTPConfig controls the optional stateless MCP HTTP endpoint.

type HealthReport

type HealthReport struct {
	Status    string           `json:"status"`
	CheckedAt time.Time        `json:"checked_at"`
	Providers []ProviderStatus `json:"providers"`
}

HealthReport describes runtime and provider readiness.

type Manifest

type Manifest struct {
	SchemaVersion      int          `json:"schema_version"`
	Experts            []ExpertView `json:"experts"`
	Providers          []string     `json:"providers,omitempty"`
	SideEffectsEnabled bool         `json:"side_effects_enabled"`
	Transports         []string     `json:"transports"`
}

Manifest describes capabilities without initiating provider access.

type ModelConfig

type ModelConfig struct {
	Fast     string `json:"fast" yaml:"fast"`
	Balanced string `json:"balanced" yaml:"balanced"`
	Strong   string `json:"strong" yaml:"strong"`
}

ModelConfig maps abstract planner tiers to host-owned model identifiers.

type OllamaConfig

type OllamaConfig struct {
	Enabled       bool     `json:"enabled" yaml:"enabled"`
	BaseURL       string   `json:"base_url" yaml:"base_url"`
	AllowRemote   bool     `json:"allow_remote" yaml:"allow_remote"`
	Timeout       Duration `json:"timeout" yaml:"timeout"`
	MaxBodyBytes  int64    `json:"max_body_bytes" yaml:"max_body_bytes"`
	ContextWindow int      `json:"context_window" yaml:"context_window"`
	MaxParallel   int      `json:"max_parallel" yaml:"max_parallel"`
}

OllamaConfig enables read-only discovery against an Ollama API.

type Options

type Options struct {
	Skills          *skills.Registry
	ProviderSources []ProviderSource
}

Options supplies optional host-owned integrations.

type Overrides

type Overrides struct {
	HTTPAddress string
}

Overrides are explicit CLI values applied after environment variables.

type PlanOptions

type PlanOptions struct {
	ToolCallModel       string `json:"tool_call_model,omitempty"`
	SynthesisModel      string `json:"synthesis_model,omitempty"`
	ResponseTokenBudget int    `json:"response_token_budget"`
	EnableChunking      bool   `json:"enable_chunking"`
	MaxIterations       int    `json:"max_iterations"`
	MaxToolCalls        int    `json:"max_tool_calls"`
}

PlanOptions are execution limits for the host-owned model loop.

type PlanView

type PlanView struct {
	Expert                   ExpertView    `json:"expert"`
	Selection                SelectionView `json:"selection"`
	SystemPromptAugmentation string        `json:"system_prompt_augmentation,omitempty"`
	ToolNames                []string      `json:"tool_names,omitempty"`
	LoadedSkills             []string      `json:"loaded_skills,omitempty"`
	OmittedSkills            []string      `json:"omitted_skills,omitempty"`
	Options                  PlanOptions   `json:"options"`
	Tier                     TierView      `json:"tier"`
	PolicyVersion            string        `json:"policy_version,omitempty"`
	CatalogVersion           string        `json:"catalog_version,omitempty"`
	ContextDigest            string        `json:"context_digest,omitempty"`
}

PlanView is the stable, serializable planner result used by all adapters.

type ProviderSource

type ProviderSource interface {
	Name() string
	Discover(context.Context) ([]moe.ProviderCandidate, error)
}

ProviderSource discovers model candidates without transferring credentials.

type ProviderStatus

type ProviderStatus struct {
	Name           string `json:"name"`
	Ready          bool   `json:"ready"`
	CandidateCount int    `json:"candidate_count"`
	Error          string `json:"error,omitempty"`
}

ProviderStatus is one provider's health result.

type RoutingInput

type RoutingInput struct {
	Topics          []string `json:"topics,omitempty"`
	HasTraceContext bool     `json:"has_trace_context,omitempty"`
	HasBuildContext bool     `json:"has_build_context,omitempty"`
	HasIssueContext bool     `json:"has_issue_context,omitempty"`
	HasCodeContext  bool     `json:"has_code_context,omitempty"`
	HistoryDepth    int      `json:"history_depth,omitempty"`
}

RoutingInput is the transport-safe routing context.

type Runtime

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

Runtime is the production composition facade shared by SDK and MCP surfaces.

func New

func New(cfg Config, opts Options) (*Runtime, error)

New validates config and constructs the canonical planner.

func (*Runtime) Close

func (r *Runtime) Close() error

Close releases composition resources. It is idempotent.

func (*Runtime) Health

func (r *Runtime) Health(ctx context.Context) HealthReport

Health checks configured read-only providers and reports degraded state without hiding it.

func (*Runtime) Manifest

func (r *Runtime) Manifest() Manifest

Manifest returns the stable capabilities offered by the composition layer.

func (*Runtime) Plan

func (r *Runtime) Plan(_ context.Context, query string, routing RoutingInput) (PlanView, error)

Plan routes a task and returns a transport-safe plan.

Example
package main

import (
	"context"
	"fmt"

	"github.com/Anurag607/amoeba/runtimekit"
)

func main() {
	cfg := runtimekit.DefaultConfig()
	runtime, err := runtimekit.New(cfg, runtimekit.Options{})
	if err != nil {
		panic(err)
	}
	defer func() { _ = runtime.Close() }()

	plan, err := runtime.Plan(context.Background(), "Review this API", runtimekit.RoutingInput{HasCodeContext: true})
	if err != nil {
		panic(err)
	}
	fmt.Println(plan.Expert.ID)
}
Output:
coding

func (*Runtime) PlanForExpert

func (r *Runtime) PlanForExpert(_ context.Context, id string) (PlanView, error)

PlanForExpert selects an expert explicitly inside the default fail-closed tool ceiling.

func (*Runtime) Validate

func (r *Runtime) Validate() error

Validate validates the runtime's immutable configuration.

type RuntimeConfig

type RuntimeConfig struct {
	MaxIterations          int `json:"max_iterations" yaml:"max_iterations"`
	MaxToolCalls           int `json:"max_tool_calls" yaml:"max_tool_calls"`
	ResponseTokenBudget    int `json:"response_token_budget" yaml:"response_token_budget"`
	MaxInjectedSkillTokens int `json:"max_injected_skill_tokens" yaml:"max_injected_skill_tokens"`
}

RuntimeConfig controls deterministic planner limits.

type SelectionView

type SelectionView struct {
	Primary     string             `json:"primary"`
	Secondary   []string           `json:"secondary,omitempty"`
	Confidences map[string]float64 `json:"confidences"`
	Reasoning   string             `json:"reasoning"`
}

SelectionView describes a routing decision without leaking mutable engine pointers.

type TierView

type TierView struct {
	ToolCall  string `json:"tool_call"`
	Synthesis string `json:"synthesis"`
	Reasoning string `json:"reasoning"`
}

TierView contains the abstract model-tier decision.

Jump to

Keyboard shortcuts

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