Documentation
¶
Overview ¶
Package factoryload runs the compiled-in extension factories of a binary: Go code that the source of the binary's own main package passes to it by value (docs/specs/extension-factory-trust.md). It is the Go port of the in-process half of upstream's extension loader.
Nothing the subprocess side imports may import this package. The factory types live in package extension, beside the API; the loader, the registering API and the built-in rows do not.
Ports packages/coding-agent/src/core/extensions/loader.ts (createExtensionAPI, initializeExtension, loadExtensionFromFactory).
Index ¶
Constants ¶
const DefaultExtensionPath = "<inline>"
DefaultExtensionPath is the path of an extension whose factory was given without one. upstream: loader.ts:662-668 (loadExtensionFromFactory extensionPath = "<inline>")
Variables ¶
This section is empty.
Functions ¶
func LoadExtensionFromFactory ¶
func LoadExtensionFromFactory(factory extension.ExtensionFactory, cwd string, eventBus extension.EventBus, runtime *extension.ExtensionRuntime, extensionPath string, options ...Option) (loaded extension.Extension, err error)
LoadExtensionFromFactory runs factory against a registering API and returns the extension it registered. The extension's handlers, tools and registries are the factory's writes to that API; its runtime changes (provider, MCP server and virtual-model registrations, flag defaults) reach runtime only if the factory returns without error. A factory that fails leaves runtime as it was, drops the event-bus subscriptions it made, and its API reports `Extension "<path>" failed to load and its API is no longer active.` from then on.
A panic in the factory is a load error: upstream catches every exception a factory throws. The caller sets the extension's name and source info. LoadExtensionFromFactory is safe for concurrent calls on one runtime; each call applies only its own changes.
Async contract: upstream awaits the factory (`await factory(load.api)`), so this call blocks until the factory returns.
upstream: loader.ts:613-632 (initializeExtension), :662-671 (loadExtensionFromFactory)
Types ¶
type Option ¶
Option adjusts how LoadExtensionFromFactory builds the extension.
func WithSourceInfo ¶
func WithSourceInfo(info extension.SourceInfo) Option
WithSourceInfo gives the extension its source before the factory runs, so every command and tool the factory registers, during loading or later, carries it. upstream: loader.ts:604-611 (createExtension sets sourceInfo before the factory runs), resource-loader.ts:906-918 (applyExtensionSourceInfo)