loom.ai.registry¶
Engine and provider resolution for the AI pillar.
Resolves the configured engine through loom.core.plugins.entrypoints
(group loom.ai.engines, duplicates rejected — FR-021) and offers the two
helpers engines use to fail fast on missing provider SDKs and settings.
This module never imports a concrete engine: the entry point is loaded by
name and the handshake is a getattr on the loaded object, never an
isinstance check, so the contract stays structural.
Module Attributes
Entry-point group every engine distribution registers under. |
|
Attribute a provider declares its handshake version on. |
|
Handshake versions this release of loom accepts. |
Functions
|
Check the handshake attribute on the constructed provider, fail-closed. |
Hand the deployment's published MCP handshake budget to the resolved engine. |
|
|
Return the |
|
Return the oracle a provider supplies for provider-run tools. |
|
Return the capability kinds an engine can actually be trusted to serve. |
|
Import a provider SDK module, failing with the extra to install. |
|
Require a provider setting to be present and non-empty. |
|
Resolve the engine provider registered under |
- loom.ai.registry.ENGINE_ENTRY_POINT_GROUP = 'loom.ai.engines'¶
Entry-point group every engine distribution registers under.
- loom.ai.registry.ENGINE_API_ATTRIBUTE = 'LOOM_AI_ENGINE_API'¶
Attribute a provider declares its handshake version on.
- loom.ai.registry.SUPPORTED_ENGINE_APIS: frozenset[int] = frozenset({2})¶
Handshake versions this release of loom accepts.
- loom.ai.registry.resolve_engine_provider(name)[source]¶
Resolve the engine provider registered under
name.Loads the entry point in group
loom.ai.engineswith duplicates rejected, instantiates it when it targets a class, and verifies theENGINE_API_ATTRIBUTEhandshake viagetattron the resulting object, so an engine declaring its version in__init__is accepted.- Parameters:
name (str) – Entry-point name from
ai.engine.- Returns:
The provider instance, handshake verified.
- Raises:
AgentCompilationError – With
ENGINE_NOT_FOUND(listing the installed engines),ENGINE_DUPLICATE(listing every claiming distribution) orENGINE_API_MISMATCH(missing or unsupported handshake version).- Return type:
- loom.ai.registry.require_provider_sdk(provider, module, extra)[source]¶
Import a provider SDK module, failing with the extra to install.
- Parameters:
- Returns:
The imported module.
- Raises:
AgentCompilationError – With
PROVIDER_NOT_INSTALLEDnaming the extra when the import fails.- Return type:
- loom.ai.registry.require_provider_setting(provider, setting, value)[source]¶
Require a provider setting to be present and non-empty.
Noneand the empty string count as missing; any other value — including0andFalse— is accepted, since those can be legitimate settings.- Parameters:
- Raises:
AgentCompilationError – With
PROVIDER_SETTING_MISSINGnaming the setting when the value is absent.- Return type:
None
- loom.ai.registry.engine_supported_kinds(provider, engine)[source]¶
Return the capability kinds an engine can actually be trusted to serve.
An engine advertising
nativewithout the oracle the compiler needs to check a grant against its model would let the grant through unchecked, so the kind is dropped and the artifact is refused for the right reason.
- loom.ai.registry.engine_native_tool_support(provider)[source]¶
Return the oracle a provider supplies for provider-run tools.
Read off the resolved provider with
getattr, the same handshake shape as the client factories: the compiler learns what a model binding admits without importing an engine.- Parameters:
provider (object) – Engine provider resolved from the entry point group.
- Returns:
The oracle, or
Nonewhen the engine serves nonativegrant.- Return type:
Callable[[InferenceTarget], frozenset[str]] | None
Example:
support = engine_native_tool_support(resolve_engine_provider("pydantic-ai"))
- loom.ai.registry.engine_client_factories(provider)[source]¶
Return the
(mcp, a2a)live-client factories a provider supplies.Read off the resolved provider, never imported from an engine package: the composition root importing
loom.ai.engines.<engine>directly is what would makecreate_appfail on a deployment running a third-party engine without that one installed, undoing the entry-point seam the pillar exists for (FR-016, FR-051).Optional by design and read with
getattr, the same handshake shape asLOOM_AI_ENGINE_API: an engine that serves neithermcpnora2agrants declares neither factory, and the compiler already refuses those grants throughsupported_capability_kinds.- Parameters:
provider (object) – Engine provider resolved from the entry point group.
- Returns:
The MCP client factory and the A2A client factory, each
Nonewhen the engine does not supply it.- Return type:
tuple[McpClientFactory | None, A2AClientFactory | None]
Example:
mcp, a2a = engine_client_factories(resolve_engine_provider("pydantic-ai"))
- loom.ai.registry.configure_engine_mcp_connect_timeout(provider, seconds)[source]¶
Hand the deployment’s published MCP handshake budget to the resolved engine.
Read structurally with
getattr, the same optional shape asengine_client_factories: an engine that declares noconfigure_mcp_connect_timeoutmethod is silently left at its own default.resolve_engine_provider()constructs every provider with no arguments, soai.startup_timeout_mscan only reach the engine after resolution, through this call (FR-051).