Spectre.Stack (Spectre v0.3.0)

Copy Markdown View Source

Compile-time installer and resolver for Spectre packages.

A Stack describes one immutable environment. Packages contribute manifests, local DSL compilers, and optional caller-owned runtime resources without importing package verbs globally or registering capabilities in a process registry.

defmodule MyApp.AI do
  use Spectre.Stack

  install MyApp.Inference do
    provider :openrouter, MyApp.OpenRouter
    model :fast, id: "small-model"
  end
end

Selecting the Stack from use Spectre.Agent, stack: MyStack activates every package-declared Agent extension. Installed operations and planner-visible actions still require explicit Flow, Work, Skill, or policy binding before they are visible or authorized.

Summary

Functions

Initializes a Stack definition.

Returns immutable configuration for a package bound to an Agent.

Returns the immutable definition for a Stack module.

Installs and compiles one package.

Installs a package with explicit options and a package-local DSL block.

Returns the immutable installation selected through an Agent's Stack.

Resolves a logical capability from a Stack module.

Starts a caller-owned runtime for a Stack.

Functions

__using__(opts \\ [])

(macro)

Initializes a Stack definition.

config(agent, package_or_installation)

@spec config(module(), term()) :: {:ok, map() | keyword()} | {:error, term()}

Returns immutable configuration for a package bound to an Agent.

definition(stack)

@spec definition(module()) :: Spectre.Stack.Definition.t()

Returns the immutable definition for a Stack module.

install(package, opts \\ [])

(macro)

Installs and compiles one package.

install(package, opts, list)

(macro)

Installs a package with explicit options and a package-local DSL block.

installation(agent, package_or_installation)

@spec installation(module(), term()) ::
  {:ok, Spectre.Stack.Installation.t()} | {:error, term()}

Returns the immutable installation selected through an Agent's Stack.

resolve(stack, kind, id)

@spec resolve(module(), Spectre.Stack.Definition.capability_kind(), term()) ::
  {:ok, Spectre.Stack.Ref.t()} | {:error, term()}

Resolves a logical capability from a Stack module.

start_link(stack, opts \\ [])

@spec start_link(
  module(),
  keyword()
) :: Supervisor.on_start()

Starts a caller-owned runtime for a Stack.