Skip to main content

Module interface

Module interface 

Source
Expand description

Injectable contracts — the traits a host implements to replace part of the engine.

The entry requirement is narrow on purpose: every module here defines at least one trait the engine holds as a dyn object. Data types, configuration and the shared data live at the crate root instead (base::event, base::prompt, base::memory, base::permission); the settings file model is the settings crate’s.

§What is reachable from here, and what is not

This crate depends on no other crate of this workspace — that is what keeps it at the bottom of the graph. So this directory can only host contracts defined in base itself:

ContractReplaces
model::Modelthe LLM backend / wire protocol
model_factory::ModelFactoryhow a protocol is built from config
model_interceptor::ModelInterceptorthe request out, the message back
credentials::CredentialSourcewhere a provider’s API key comes from
config_source::ConfigSourcewhere the settings layers come from
tool::Tool / tool::ToolRegistrya tool, or the whole tool set
tool_middleware::ToolMiddlewarea ring around every tool call
tool_result::ToolResultTransformerwhat a result may look like
scene::SceneSpecsystem prompt, tool surface, budgets
turn_policy::TurnPolicywhen a turn has gone on long enough
recovery_policy::RecoveryPolicywhat to do when a call goes wrong
budget_policy::BudgetPolicywhat a turn may spend and how much it may carry
environment::Environmentkept time and kept identifiers
exec::Processwhere a program runs
exec::FileSystemwhere a tool’s files are
exec::Networkevery request that leaves the process
exec::Sandboxhow a process is constrained
backoff::BackoffPolicywhether a failed request is sent again, and when
permission::PermissionPolicywhether a tool call runs
permission::PermissionGrantsthe allows handed out during a session
delegate::Delegatorhow sub-agents are launched
event_sink::EventSinkwhere the engine’s events go
health::HealthCheckwhether a subsystem is working
elicitation::Elicitationhow the engine asks a person something
host_call::HostCallshow a call only the host can make reaches it
host_js::HostFna function of a JavaScript library the host gives plugin code
token_counter::TokenCounterhow big the context is judged to be
prompt_registry::PromptRegistrywhat goes into the system prompt
prompt_assembler::PromptAssemblerhow the whole prompt is put together
prompt_assembly::AssemblyHooka last pass over the assembled prompt
script::ScriptEnginerunning the operator’s own code at a hook point
memory_contracts::MemoryStoragewhere durable memories are kept
memory_contracts::MemoryRetrieverwhich of them a turn sees
skill_provider::SkillProviderwhere a session’s skills come from
instruction_provider::InstructionProviderwhere standing instructions come from
instruction_provider::RuleProviderwhere the rule index comes from

catalog is the whole picture, including the contracts below that this directory cannot re-export: every extension point as data, with when it fires, what it may change, how often, and who is allowed to use it.

The engine’s other replaceable contracts live in the crate that owns them and cannot be re-exported here without pointing a dependency edge downward: Compactor (compaction), HistoryStore (history), Plugin (runtime), TelemetryRecorder (telemetry), McpClient (mcp), AnthropicClient (model), SearchProvider (tools). Anyone looking for the full map wants the extension-point index, not this directory.

Modules§

backoff
BackoffPolicy — whether a failed request is tried again, and how long the caller waits first.
budget_policy
What a turn is allowed to spend, and how much context it may carry: the engine’s ceilings (SpendNode) and the deployment’s own judgement (BudgetPolicy).
catalog
The extension points, as data.
config_source
ConfigSource — where the settings layers come from.
credentials
CredentialSource — where the engine’s API keys come from.
delegate
Delegation: one request type for every way a session starts a sub-agent — the model’s Agent call, a team member, an "agent" hook, a forked skill, a host’s session.startAgent — and the one trait that serves it. The mode says how the delegate runs; everything else about it is in the request.
elicitation
Elicitation — the one way the engine asks a human something.
environment
Environment — the two inputs that make a run different from the last one.
event_sink
EventSink — where the engine’s events go.
exec
The execution layer — how a tool touches the machine.
health
HealthCheck — whether the engine, and what a host wired into it, is working.
host_call
HostCalls — how the engine hands the host something only the host can do, and waits for its one answer: a tool the host declared, or a hook a host connection registered. Both share the wait, timeout, cancellation and disconnect handling; a call that names its HostId is answered by that connection alone.
host_js
HostJsLib — a JavaScript library the host gives plugin code: a namespace of async functions, JSON in and JSON out, that becomes a global in the runtime of every plugin command and function whose package uses it (docs/agix-sdk.md §10「宿主 JS 库」). The host never sees the script engine: the engine writes the stubs, and each call reaches the host through HostFn with who made it and a cancellation signal.
inline_command
A skill’s !`cmd`, run as a Bash call of the session — through the same dispatch a model’s call takes — with nobody to ask about it.
instruction_provider
InstructionProvider and RuleProvider — where the project’s standing instructions come from.
mcp_servers
McpServers — the MCP servers a session is connected to, as the turn loop uses them.
memory_contracts
Where memories live, how they are found, and who decides what to keep.
model
Model trait — protocol-agnostic LLM backend interface.
model_factory
ModelFactory — how a wire protocol gets built from configuration.
model_interceptor
ModelInterceptor — the request on its way out, and the message on its way back.
permission
Tool authorization, in two parts: PermissionPolicy decides whether a call runs, PermissionGrants keeps the allows a person or a skill hands out along the way. A session holds the two together as a PermissionSet. What a policy weighs about a call is its ToolFacts.
plugin_call
A host’s call of a tool object outside any turn, through the session’s whole tool pipeline — permission, PreToolUse, tool.around, the call, PostToolUse, telemetry — the way the model’s calls go, beside a turn that may be running. The tool is handed over, so it need not be one the model can call.
prompt_assembler
PromptAssembler — the algorithm that turns every contribution into the blocks one request carries.
prompt_assembly
The assembly hook point: a last pass over the whole prompt, with authority that depends on where the pass came from.
prompt_middleware
PromptMiddleware — what an embedding program says about a user message before it enters the conversation.
prompt_registry
PromptRegistry — contributing to the system prompt instead of replacing it.
recovery_policy
RecoveryPolicy — what to do when a model call goes wrong.
scene
SceneSpec — what a scene is: its identity, tool and module surface, budgets and per-turn reminders, as data, plus the one behavior a scene supplies itself, its prompt (ScenePrompt). Bound at session creation and immutable thereafter.
script
ScriptEngine — the cheap tier of extension backend.
skill_catalog
SkillCatalog — the skills a session can list, invoke and be reminded of.
skill_provider
SkillProvider — where a session’s skills come from.
token_counter
TokenCounter — how the engine decides how big a conversation is.
tool
Tool trait. All tools implement this single trait.
tool_dispatch
How a tool calls other tools of its session — through the same dispatch a model’s own tool call takes (validation, hooks, middleware, telemetry, permission), so a sub-call can do nothing its caller could not have done directly. Handed to tools that ask for it (ToolSpec::needs_dispatch); a skill’s inline command takes the same dispatch through crate::interface::inline_command::InlineCommands.
tool_middleware
ToolMiddleware — the ring around tool dispatch.
tool_result
ToolResultTransformer — the last hands on a tool’s output before the model reads it.
tool_selector
Which tools a session may have, as allow and deny lists that only ever narrow: one matching semantics for a scene’s lists, an agent type’s and a caller’s. A deny always holds, whether or not an allow list is given, and an MCP server is named by its configured name and matched on the tool’s origin, never parsed out of the tool’s name.
turn_policy
TurnPolicy — when a turn has gone on long enough.