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:
| Contract | Replaces |
|---|---|
model::Model | the LLM backend / wire protocol |
model_factory::ModelFactory | how a protocol is built from config |
model_interceptor::ModelInterceptor | the request out, the message back |
credentials::CredentialSource | where a provider’s API key comes from |
config_source::ConfigSource | where the settings layers come from |
tool::Tool / tool::ToolRegistry | a tool, or the whole tool set |
tool_middleware::ToolMiddleware | a ring around every tool call |
tool_result::ToolResultTransformer | what a result may look like |
scene::SceneSpec | system prompt, tool surface, budgets |
turn_policy::TurnPolicy | when a turn has gone on long enough |
recovery_policy::RecoveryPolicy | what to do when a call goes wrong |
budget_policy::BudgetPolicy | what a turn may spend and how much it may carry |
environment::Environment | kept time and kept identifiers |
exec::Process | where a program runs |
exec::FileSystem | where a tool’s files are |
exec::Network | every request that leaves the process |
exec::Sandbox | how a process is constrained |
backoff::BackoffPolicy | whether a failed request is sent again, and when |
permission::PermissionPolicy | whether a tool call runs |
permission::PermissionGrants | the allows handed out during a session |
delegate::Delegator | how sub-agents are launched |
event_sink::EventSink | where the engine’s events go |
health::HealthCheck | whether a subsystem is working |
elicitation::Elicitation | how the engine asks a person something |
host_call::HostCalls | how a call only the host can make reaches it |
host_js::HostFn | a function of a JavaScript library the host gives plugin code |
token_counter::TokenCounter | how big the context is judged to be |
prompt_registry::PromptRegistry | what goes into the system prompt |
prompt_assembler::PromptAssembler | how the whole prompt is put together |
prompt_assembly::AssemblyHook | a last pass over the assembled prompt |
script::ScriptEngine | running the operator’s own code at a hook point |
memory_contracts::MemoryStorage | where durable memories are kept |
memory_contracts::MemoryRetriever | which of them a turn sees |
skill_provider::SkillProvider | where a session’s skills come from |
instruction_provider::InstructionProvider | where standing instructions come from |
instruction_provider::RuleProvider | where 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
Agentcall, a team member, an"agent"hook, a forked skill, a host’ssession.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 itsHostIdis 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 packageusesit (docs/agix-sdk.md§10「宿主 JS 库」). The host never sees the script engine: the engine writes the stubs, and each call reaches the host throughHostFnwith who made it and a cancellation signal.- inline_
command - A skill’s
!`cmd`, run as aBashcall of the session — through the same dispatch a model’s call takes — with nobody to ask about it. - instruction_
provider InstructionProviderandRuleProvider— 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
Modeltrait — 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:
PermissionPolicydecides whether a call runs,PermissionGrantskeeps the allows a person or a skill hands out along the way. A session holds the two together as aPermissionSet. What a policy weighs about a call is itsToolFacts. - 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 throughcrate::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.