Spectre.Stack (Spectre v0.4.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, optional tool descriptors and caller-owned resources. Secrets and live clients belong in runtime configuration, not this definition.

defmodule MyApp.AI do
  use Spectre.Stack

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

Selecting stack: MyApp.AI in Spectre.Agent connects package-declared Agent extensions. Selecting tools: MyApp.AI in Spectre.Server generates private helpers from installed Spectre.Stack.Installable.tools/1 descriptors. Packages do not need to export those helper functions themselves.

Helpers append commands; runtime adapters resolve named Stack resources, return cognitive results or normalize bound consequences to GAM proposals. Installation and bind: configuration do not grant authority. Governed operations need authenticated host scope, contracts, mandate and executors. See the Stack Tools and GAM guides.

Spectre.Stack.Runtime supervises declared resources when explicitly started by the host. Pass its stable name as stack_runtime: to resource-using Servers. Standalone package APIs and older Instance/Run integrations remain separate compatibility paths.

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.