provider

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package provider is the service provider that installs the hex/ai 'agent' Lua module into the shared hex/lua environment.

Add to app/boot.go AFTER both hex/ai/provider (binds "ai") and hex/lua/provider (binds "lua"):

provider.Config(),
provider.Log(),
provider.Lua(),        // hex/lua/provider
provider.AI(),         // hex/ai/provider
provider.LuaAI(),      // this package — bridges the two

Register order: Lua and AI must both have Registered before this provider's Register runs (both bindings must exist in the container).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	provider.Base

	// LuaBinding is the container key for the *hex/lua.Environment.
	// Defaults to "lua".
	LuaBinding string

	// AgentBinding is the container key for the ai.Agent. Defaults to
	// "ai".
	AgentBinding string

	// RegistryBinding is the container key for the ai.ToolRegistry.
	// Defaults to "ai.tools". Falls back to Registry when the binding
	// is missing.
	RegistryBinding string

	// ModuleName is the Lua module name registered via
	// env.PreloadModule. Defaults to "agent". Change when the
	// consumer wants to expose multiple agents under distinct names.
	ModuleName string

	// Registry is a fallback exposed to Lua via agent.tools() when the
	// container has no RegistryBinding. Typical usage relies on the
	// container-bound registry from hex/ai/provider; this field is
	// only useful when wiring the Lua module without the standard AI
	// provider.
	Registry ai.ToolRegistry

	// Store persists conversation history keyed by the first argument
	// to agent.ask. Optional; when nil each call is single-turn.
	Store ai.ConversationStore

	// Mutex is locked around every Generate call so concurrent
	// agent.ask invocations from event handlers do not race on the
	// shared *lua.LState. When nil, the provider allocates its own
	// mutex — this is the correct default for event-bus dispatched
	// scripts (see PLAT-3545).
	Mutex *sync.Mutex
}

Provider wires the 'agent' Lua module into hex/lua's shared env.

func (*Provider) Register

func (p *Provider) Register(app provider.Application) error

Register resolves both bindings and installs the module.

Jump to

Keyboard shortcuts

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