Extensions #
An extension is a named bundle of plugins. The registry in extensions.gleam declares installed extensions and defaults. The extension types define their contributions. See plugins for the host contracts, Write an extension for a working Gleam example, and the extension API reference for function-level documentation and generated signatures.
Installed and enabled #
Installation makes an extension known to the daemon. Session selection combines
global defaults with stored session overrides. selection.select preserves
registry order and handles exclusive compaction strategies.
selection.validate_selection checks requirements before the selection is used.
A quarantined extension appears in summaries with its reason and no
capabilities. See
selection.gleam.
Session composition #
composition.compose loads
static contributions and prepares managed contributions for each selected
extension. A failed load, failed preparation, module clash, or duplicate tool,
command, or route leaves that extension inactive and adds a warning. Dependents
whose requirements are inactive are removed as well.
A composition is immutable. A refresh prepares a replacement, and the host
closes the composition that loses. Managed resources close in reverse
preparation order. Adoption failure closes the candidate. Owned callbacks return
an optional opaque Owned value with explicitly attached adoption and close
callbacks. None contributes nothing. The ownership contract is defined by
PreparationOwner and OwnedManagedPlugin in
extension.gleam.
During reload, application workers borrow the adopted candidate and previous session. The runtime settles their results and closes the losing resources. See reload ownership for rejection, worker death, and late-result cleanup.
Extension settings #
SettingsPlugin registers an extension's settings declaration.
settings/declared.gleam
collects declarations and validates declared values. The daemon exposes them
through its settings resources. See persisted settings for
conditional updates and recovery, and plugins for contribution
types.
SDK imports and native bindings #
An extension belongs to one directory under src/albedo/harness/extensions/.
Use albedo/harness/sdk/* for shared extension helpers and contracts, and
import modules within your own extension for feature behavior. Standard library
and other declared dependency imports remain available.
The allowed direct daemon imports are albedo/daemon/store and
albedo/daemon/http_api. The allowed harness domain imports are location,
ssh, worktree, compaction, cache_ttl, capabilities, project_files,
instruction_files, context_limits, links, and extension/selection, each
under albedo/harness/. Shared helpers outside the SDK are
albedo/clock,
albedo/text_scalars, and
albedo/actor_call. Use supplied host or
session callbacks for daemon effects that the SDK does not expose. Follow the
shared contribution rules.
The existing SDK modules are:
sdk/extension: Extension declarations, contributions, and preparation ownership.sdk/service: Buffered JSON extension HTTP services.sdk/worker: Owned worker startup and adoption.sdk/host: Context and routes for kernel host calls.sdk/rpc: Host-call dispatch and argument decoding.sdk/command: Session command declarations and state operations.sdk/hook: Turn and tool hook events and verdicts.sdk/tool: Retrieval tool schemas, paging, and rendering.sdk/client_api: Declarative client HTTP operations.sdk/imagegen: Provider-neutral image generation contracts.sdk/web_search: Web search provider contracts and selection.sdk/search: Transcript search with bounded database reads.sdk/page: Sidebar rows and command argument parsing.sdk/http: Buffered HTTP requests and timeout settings.requestreturns status, headers, and bytes, including non-2xx responses.failureformats status errors;locationsfollows redirect locations concurrently.sdk/settings: Extension settings declarations and decoding.sdk/credentials: Credential recovery, persistence, and notifications.textandlenient_texttreat missing or non-string credential fields as empty strings.sdk/key_accounts: Typed snapshots of profile-bound key accounts.fast_modeselects the current connection before invoking the provider's support callback. A selection failure returnsFastUnknownwith the provider's error prefix. The callback owns model and endpoint eligibility, mode, source, and unavailable reasons.sdk/accounts: Pure account pool ordering.sdk/rotation: Rate-limit account rotation.sdk/oauth: OAuth sign-in and token helpers. BuildDeviceFlowinsideoauth.device's start callback so runtime environment overrides are read after sealed declarations load.sdk/google_oauth: Shared Google token renewal.sdk/model_lists: Provider model-list helpers.sdk/concurrent: Linked concurrent calls with caller lifetime.sdk/protect: Callback crash recovery as a result value.sdk/usage_feed: Usage driver execution and bounded I/O.
The SDK also provides these helpers.
-
sdk/digest: Hash, hex, base64, HMAC, and constant-time comparison helpers. -
sdk/ids: Random and unique identifier helpers, including a version-4-shaped UUID derived from a seed. -
sdk/env: Environment variable lookup, returning an empty string when unset. Read it during resolution or startup callbacks, never while constructing cached declarations. -
sdk/file: File reads and private atomic cache writes.home_read_optionaldistinguishes absence from read failure so a save can preserve an unreadable existing file. Bounded prefix and range reads close descriptors on every outcome.with_lockserializes a complete cache update within this daemon; it is separate from credential transactions and does not coordinate other OS processes. -
sdk/subprocess: Credential helpers with bounded stdout and timeouts. -
sdk/helper: Python helper subprocess execution with explicit outcomes. -
sdk/rsa: RS256 signing for provider authentication. -
sdk/memo: Typed cache handles with explicit expiry clocks and decoded reads. The owner sweeps expired entries every second. Each namespace keeps at most 1024 entries and evicts its oldest write when full. -
sdk/once: Single-flight work shared by concurrent callers. The returned process runs the job; killing it cancels that job. -
sdk/subscriptions: One-shot keyed wakeups with owner-death and explicit close cleanup. Subscribe before reading state and publish after commit. Handles belong to their creating process; callers must bound concurrent subscriptions.
Four lint rules enforce extension boundaries in the commit and review profiles:
albedo_extension_daemon_importflags daemon imports outsidestoreandhttp_api. Use SDK helpers or supplied callbacks instead.albedo_extension_harness_importflags harness imports outside the SDK, extension directories, and the domain allow-list above. Use an SDK contract.albedo_extension_externalflags@external(erlang, M, _)unlessMhas an.erlfile within the same extension directory, including its subdirectories. OTP modules also violate this rule. Call an SDK Gleam helper instead of its native implementation, or keep feature-specific natives with their owner.albedo_extension_cross_importrejects another extension's private modules. Deliberate feature dependencies use the public entrypoints below. Provider contributions still resolve from the active composition.
The rules do not restrict SDK implementation imports or JavaScript external bindings. The lint profiles run the same boundary checks.
Session data and effects #
sdk/history exposes durable history
observations, including generic folds and session metadata lists. Keep the
captured snapshot through related reads. The daemon retains storage authority;
sdk/transcript and
sdk/session_info own the
shared value types. Replay projection, note encoding, and image validation use
sdk/projection,
sdk/message_content,
sdk/note, and
sdk/image.
sdk/request_history.last_turn
returns the latest successful transcript turn's input identity. Background pings
do not replace that observation.
Give a session something to read through
sdk/input with the shared
sdk/letter kinds and deliveries:
describe the input and post it. input.post_in takes the caller's connection,
so feature changes and their input commit together, and the session hears of it
after the commit. Do not reach into the inbox's storage or the session's actor.
See inbox. Agents' letters to each other go through
sdk/mail.
sdk/images.store_images likewise
retains the caller's transaction.
sdk/image_codec owns historical
image row packing, validated loading with lazy readers, and legacy compaction
fingerprints. The daemon retains blob storage and migration transactions.
Publish notifications after commit. extension.Daemon.invalidate announces
service changes; host.Context.progress is bound to its session.
host.Context.read_shell_output reads only that session's captured user-command
output. Background services without a request context use
sdk/notifications.invalidate
after commit. sdk/notice decodes the
completion notices a kernel posts under its own keys and withdraws them by key
once their result was read.
sdk/webhook_address
supplies the daemon intake listener's port and delivery addresses.
sdk/session_control exposes
typed session operations without daemon message constructors.
sdk/family owns the extension-facing
family operations, while the daemon retains durable family state.
sdk/session_identity owns
the shared family member, address, stub, and local or remote destination values.
sdk/session_transfer keeps
forwarding and refusal behavior with the daemon's transfer owner.
sdk/editor_overlay resolves
an authorized editor overlay for MCP preparation. The returned
sdk/editor_mcp.Overlay captures
its catalogue revision in lookup/save callbacks. A stale preparation cannot
publish into a newer revision. Keep resource adoption with the MCP preparation
owner; obtaining this value does not allocate a client.
sdk/profiles owns provider-profile
validation and decoding, including generic settings reads. It does not require a
session context. Native persistence and settings locking retain their existing
owners. sdk/bytes,
sdk/text, and
sdk/term provide binary framing,
native text conversion, and legacy term-order operations. Keep those conversions
at foreign-data boundaries.
sdk/opencode_gateway
shares gateway request encoding, Responses replay reduction, and charged,
allowance, and list-cost interpretation. Provider routing, account identity, and
headers remain with each provider.
Public feature dependencies #
These entrypoints expose intentional feature dependencies. Importing one does not enable that extension or substitute for selection of a provider:
models/catalogueowns shared model enrichment and its existing cache refresh policy.lcm/coreandlcm/graphexpose the compaction graph shared with persistent-agent. LCM remains its table owner.rolling/strategyowns the rolling strategy used by snapcompact's fallback.python/jobsowns live and saved job reads and fallback rules;python/resourcesexposes the supported kernel resource types.memory/linkedexposes the memory operation used when linking workspaces.
The exact public module list lives in
extension_cross_import.
Do not import declaration modules or private workers to reach these features.
Boundaries to preserve #
extension.invoke catches a tool crash and returns a refusal that says its
effects are unknown. A Fatal failure ends the turn when the host could not
record what a call did. Inspect effects before retrying an interrupted or
crashed operation. Tool output can contain text and images. Consumers must use
the provider's image limits. See
extension.gleam.
Extensions can expose Python bindings, such as MCP, skills, and image generation. A binding is an interface to its host routes, not a separate permission grant.
An extension owns the tables it creates. Keep SQL that names those tables inside
the owning extension and expose operations through its interfaces. The
albedo_table_ownership lint rule
checks that boundary. Use migration and cleanup plugins for extension-owned
storage. Follow the
extension change rules
when changing selection, discovery, or resource lifetime.