From cde079de580cd96598cd14bb64fc4a6d690ca4a0 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Tue, 17 Nov 2026 00:03:40 -0500 Subject: [PATCH] test(sdk): run the SDK's pure unit tests in its package, and follow its paths Thirteen root tests that import only the SDK and its dependencies, and need no store, host resources or test home, move to packages/albedo_sdk/test/albedo/harness/sdk with the transcript codec's golden rows. Tests that start a store with core's tables, install host resources, or share root test helpers stay in albedo's test/. test/e2e/areas.toml names the SDK's files in the package. The SDK files the harness wildcard used to cover get their own rule, after every specific SDK rule, so each SDK file selects the same tests as before the move. Wiki and API documentation links point at the package. --- docs/contributing-api.md | 8 +- docs/extension-api.md | 73 +- docs/extensions.md | 85 +-- docs/http-api-architecture.md | 15 +- docs/http-api-design.md | 12 +- .../albedo/harness/sdk}/cache_ttl_test.gleam | 0 .../albedo/harness/sdk}/client_api_test.gleam | 0 .../albedo/harness/sdk}/command_test.gleam | 0 .../sdk}/device_flow_encoding_test.gleam | 0 .../harness/sdk}/network_context_test.gleam | 0 .../albedo/harness/sdk}/network_test.gleam | 0 .../albedo/harness/sdk}/notice_test.gleam | 0 .../harness/sdk}/python_repair_test.gleam | 0 .../harness/sdk}/reasoning_text_test.gleam | 0 .../harness/sdk}/renderer_line_test.gleam | 0 .../harness/sdk}/summary_finish_test.gleam | 0 .../harness/sdk}/summary_thinking_test.gleam | 0 .../sdk}/transcript_codec_golden_test.gleam | 0 .../fixtures/transcript-codec-golden.txt | 0 robot-docs/agent-sessions.md | 15 +- robot-docs/auth.md | 99 +-- robot-docs/cache-ttl.md | 39 +- robot-docs/commands.md | 24 +- robot-docs/compaction.md | 72 +- robot-docs/contributing.md | 29 +- robot-docs/discord.md | 6 +- robot-docs/extensions.md | 655 +++++++++--------- robot-docs/gleam-lint.md | 32 +- robot-docs/hooks.md | 50 +- robot-docs/inbox.md | 86 +-- robot-docs/kernel.md | 13 +- robot-docs/mcp.md | 6 +- robot-docs/migrations.md | 24 +- robot-docs/models.md | 44 +- robot-docs/network.md | 27 +- robot-docs/plugins.md | 170 ++--- robot-docs/provider-requests.md | 22 +- robot-docs/runtime.md | 18 +- robot-docs/sessions.md | 6 +- robot-docs/settings.md | 42 +- robot-docs/skills.md | 31 +- robot-docs/usage-feed.md | 36 +- robot-docs/webhooks.md | 14 +- robot-docs/workspace-packages.md | 50 +- robot-docs/workspaces.md | 22 +- robot-docs/worktrees.md | 8 +- test/e2e/areas.toml | 126 ++-- 47 files changed, 1019 insertions(+), 940 deletions(-) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/cache_ttl_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/client_api_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/command_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/device_flow_encoding_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/network_context_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/network_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/notice_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/python_repair_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/reasoning_text_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/renderer_line_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/summary_finish_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/summary_thinking_test.gleam (100%) rename {test/harness => packages/albedo_sdk/test/albedo/harness/sdk}/transcript_codec_golden_test.gleam (100%) rename {test => packages/albedo_sdk/test}/fixtures/transcript-codec-golden.txt (100%) diff --git a/docs/contributing-api.md b/docs/contributing-api.md index 3d02892a7..a7e6044f6 100644 --- a/docs/contributing-api.md +++ b/docs/contributing-api.md @@ -85,10 +85,10 @@ undoing it. See [settings recovery](http-api-architecture.md#settings-crash-recovery). For login identity, keep secret comparison inside the sign-in service in -[`oauth_flows`](../src/albedo/harness/sdk/oauth_flows.gleam). Use its protected -keyed fingerprint rather than a public hash of low-entropy input. Do not persist -callback codes or access tokens in admission records. Let the credentials owner -retain resulting accounts. +[`oauth_flows`](../packages/albedo_sdk/src/albedo/harness/sdk/oauth_flows.gleam). +Use its protected keyed fingerprint rather than a public hash of low-entropy +input. Do not persist callback codes or access tokens in admission records. Let +the credentials owner retain resulting accounts. For live delivery, retain bounded queues before mailboxes and release subscriptions after disconnect. Capture status, progress, pending ownership, and diff --git a/docs/extension-api.md b/docs/extension-api.md index 488275d34..324882f90 100644 --- a/docs/extension-api.md +++ b/docs/extension-api.md @@ -1,7 +1,8 @@ # Extension API reference -The public functions in [`albedo/harness/sdk`](../src/albedo/harness/sdk) are -the shared Gleam API for extensions. Each function's `///` comment describes its +The public functions in +[`albedo/harness/sdk`](../packages/albedo_sdk/src/albedo/harness/sdk) are the +shared Gleam API for extensions. Each function's `///` comment describes its behavior beside its signature. Gleam generates the function reference, type definitions, and module search from those sources. The source comments are canonical; this page does not maintain a second copy of the signatures. @@ -56,49 +57,49 @@ and link the available modules by purpose. These are useful starting points for common tasks: -| Task | Starting API | Contract | -| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Declare contributions | [`extension.Extension`, `Plugin`](../src/albedo/harness/sdk/extension.gleam) | Declarations describe capabilities. Preparation and invocation callbacks perform effects. | -| Add a command | [`command.Command`](../src/albedo/harness/sdk/command.gleam) | `Invocation.state` reaches session operations through the actor's bridge, and `Invocation.storage` is the extension's handle. | -| Add a kernel host route | [`host.Route`, `Context`](../src/albedo/harness/sdk/host.gleam), [`rpc.args`](../src/albedo/harness/sdk/rpc.gleam) | Decode foreign arguments once. Return JSON or a code/message pair. | -| Serve a client resource | [`service.json`](../src/albedo/harness/sdk/service.gleam), [`http_api`](../src/albedo/harness/sdk/http_api.gleam), [`client_api`](../src/albedo/harness/sdk/client_api.gleam) | The service owns HTTP behavior; client declarations describe how to invoke it. | -| Read or change settings | [`settings.Section`, `load_section`, `update`](../src/albedo/harness/sdk/settings.gleam) | Use the same typed settings for schema and decoding. Update callbacks run under the settings lock. | -| Resolve provider credentials | [`credentials`](../src/albedo/harness/sdk/credentials.gleam), [`key_accounts`](../src/albedo/harness/sdk/key_accounts.gleam) | Keep the selected snapshot through the request, attribution, and cooldown update. | -| Observe session history | [`history.snapshot`, `fold_sources`](../src/albedo/harness/sdk/history.gleam) | Capture an append boundary once and retain it through related reads. | -| Give a session an input | [`input.Inbox`: `post`, `post_in`, `withdraw`](../src/albedo/harness/sdk/input.gleam), from the context's `inbox` | Post on the caller's transaction when effects must commit together. The session hears of it after the commit; never tell it yourself. | -| Start or stop other sessions | [`session_control`: `spawn`, `start`, `stop`, `close`](../src/albedo/harness/sdk/session_control.gleam), with the context's `control` | The daemon's coordinator owns admission and limits. A call runs in the caller's process and answers an error when the coordinator is unavailable. | -| Send mail between agents | [`host.Context.send_mail`](../src/albedo/harness/sdk/host.gleam) | Resolves the address and forwards to another daemon when needed. A receipt does not mean the recipient answered. | -| Reach session state | [`host.Context.session_state`](../src/albedo/harness/sdk/host.gleam), [`extension.Daemon.session_state`](../src/albedo/harness/sdk/extension.gleam) | The host supplies the `command.Context`. A route uses its own session's. A service looks up the session its request names. | -| Work with worktrees | [`worktree.Worktrees`](../src/albedo/harness/sdk/worktree.gleam), from the context's `worktrees` | Declare `Worktrees` and `Sessions`, and pass your own storage handle. The host owns the table, placement, providers, and removal. | -| Reach a workspace's host | [`hosts.Hosts`](../src/albedo/harness/sdk/hosts.gleam), from `Daemon.hosts` or `Preparation.hosts` | Declare `Hosts`. A preparation asks `exists` with a wait of 0, so opening a session never waits on a host. | -| Read a workspace group | [`links.group`, `members`](../src/albedo/harness/sdk/links.gleam), with the context's `origins` | The host's worktree records decide which worktrees join a group; pass the `Origins` your context carries. | -| Read a session's project files | `Preparation.project_files`, `instructions`, and `preferences` in [`extension`](../src/albedo/harness/sdk/extension.gleam) | The host owns discovery, the remote mirror, and selection. Read preferences only when there is something to choose among. | -| Own a session worker | [`worker.start`, `observer`](../src/albedo/harness/sdk/worker.gleam) | Monitor preparation and runtime owners; attach adoption and close callbacks. | -| Call external services | [`http`](../src/albedo/harness/sdk/http.gleam) with [`buffered.Timeouts`, `Body`](../packages/albedo_http/src/albedo_http/buffered.gleam), [`albedo_ports/subprocess`](../packages/albedo_ports/src/albedo_ports/subprocess.gleam), [`albedo_process/parallel`](../packages/albedo_process/src/albedo_process/parallel.gleam) | Choose explicit deadlines and preserve caller lifetime for concurrent work. | -| Read bounded file content | [`albedo_file.read_prefix`, `read_range`](../packages/albedo_file/src/albedo_file.gleam) | Bounds count bytes. EOF succeeds with empty bytes; `ReadError` distinguishes invalid ranges from unavailable files. Callers own path and identity validation. | -| Update a shared cache file | [`albedo_file.with_lock`, `write_private`](../packages/albedo_file/src/albedo_file.gleam) | Lock the complete read/merge/write operation. Wait `Within` a limit for finite admission. Locks are daemon-local and non-reentrant. | -| Poll a custom sign-in flow | [`oauth.Device`, `wait_for_input`](../src/albedo/harness/sdk/oauth.gleam) | Wait in the OAuth completion worker. Input wakes it. The sign-in service handles cancellation. | -| Wait for a keyed change | [`albedo_process/subscriptions`](../packages/albedo_process/src/albedo_process/subscriptions.gleam) | Subscribe before reading state, then wait or close in the same process. Owner death cleans up. Publish after commit and re-read state after waking. | +| Task | Starting API | Contract | +| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Declare contributions | [`extension.Extension`, `Plugin`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) | Declarations describe capabilities. Preparation and invocation callbacks perform effects. | +| Add a command | [`command.Command`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam) | `Invocation.state` reaches session operations through the actor's bridge, and `Invocation.storage` is the extension's handle. | +| Add a kernel host route | [`host.Route`, `Context`](../packages/albedo_sdk/src/albedo/harness/sdk/host.gleam), [`rpc.args`](../packages/albedo_sdk/src/albedo/harness/sdk/rpc.gleam) | Decode foreign arguments once. Return JSON or a code/message pair. | +| Serve a client resource | [`service.json`](../packages/albedo_sdk/src/albedo/harness/sdk/service.gleam), [`http_api`](../packages/albedo_sdk/src/albedo/harness/sdk/http_api.gleam), [`client_api`](../packages/albedo_sdk/src/albedo/harness/sdk/client_api.gleam) | The service owns HTTP behavior; client declarations describe how to invoke it. | +| Read or change settings | [`settings.Section`, `load_section`, `update`](../packages/albedo_sdk/src/albedo/harness/sdk/settings.gleam) | Use the same typed settings for schema and decoding. Update callbacks run under the settings lock. | +| Resolve provider credentials | [`credentials`](../packages/albedo_sdk/src/albedo/harness/sdk/credentials.gleam), [`key_accounts`](../packages/albedo_sdk/src/albedo/harness/sdk/key_accounts.gleam) | Keep the selected snapshot through the request, attribution, and cooldown update. | +| Observe session history | [`history.snapshot`, `fold_sources`](../packages/albedo_sdk/src/albedo/harness/sdk/history.gleam) | Capture an append boundary once and retain it through related reads. | +| Give a session an input | [`input.Inbox`: `post`, `post_in`, `withdraw`](../packages/albedo_sdk/src/albedo/harness/sdk/input.gleam), from the context's `inbox` | Post on the caller's transaction when effects must commit together. The session hears of it after the commit; never tell it yourself. | +| Start or stop other sessions | [`session_control`: `spawn`, `start`, `stop`, `close`](../packages/albedo_sdk/src/albedo/harness/sdk/session_control.gleam), with the context's `control` | The daemon's coordinator owns admission and limits. A call runs in the caller's process and answers an error when the coordinator is unavailable. | +| Send mail between agents | [`host.Context.send_mail`](../packages/albedo_sdk/src/albedo/harness/sdk/host.gleam) | Resolves the address and forwards to another daemon when needed. A receipt does not mean the recipient answered. | +| Reach session state | [`host.Context.session_state`](../packages/albedo_sdk/src/albedo/harness/sdk/host.gleam), [`extension.Daemon.session_state`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) | The host supplies the `command.Context`. A route uses its own session's. A service looks up the session its request names. | +| Work with worktrees | [`worktree.Worktrees`](../packages/albedo_sdk/src/albedo/harness/sdk/worktree.gleam), from the context's `worktrees` | Declare `Worktrees` and `Sessions`, and pass your own storage handle. The host owns the table, placement, providers, and removal. | +| Reach a workspace's host | [`hosts.Hosts`](../packages/albedo_sdk/src/albedo/harness/sdk/hosts.gleam), from `Daemon.hosts` or `Preparation.hosts` | Declare `Hosts`. A preparation asks `exists` with a wait of 0, so opening a session never waits on a host. | +| Read a workspace group | [`links.group`, `members`](../packages/albedo_sdk/src/albedo/harness/sdk/links.gleam), with the context's `origins` | The host's worktree records decide which worktrees join a group; pass the `Origins` your context carries. | +| Read a session's project files | `Preparation.project_files`, `instructions`, and `preferences` in [`extension`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) | The host owns discovery, the remote mirror, and selection. Read preferences only when there is something to choose among. | +| Own a session worker | [`worker.start`, `observer`](../packages/albedo_sdk/src/albedo/harness/sdk/worker.gleam) | Monitor preparation and runtime owners; attach adoption and close callbacks. | +| Call external services | [`http`](../packages/albedo_sdk/src/albedo/harness/sdk/http.gleam) with [`buffered.Timeouts`, `Body`](../packages/albedo_http/src/albedo_http/buffered.gleam), [`albedo_ports/subprocess`](../packages/albedo_ports/src/albedo_ports/subprocess.gleam), [`albedo_process/parallel`](../packages/albedo_process/src/albedo_process/parallel.gleam) | Choose explicit deadlines and preserve caller lifetime for concurrent work. | +| Read bounded file content | [`albedo_file.read_prefix`, `read_range`](../packages/albedo_file/src/albedo_file.gleam) | Bounds count bytes. EOF succeeds with empty bytes; `ReadError` distinguishes invalid ranges from unavailable files. Callers own path and identity validation. | +| Update a shared cache file | [`albedo_file.with_lock`, `write_private`](../packages/albedo_file/src/albedo_file.gleam) | Lock the complete read/merge/write operation. Wait `Within` a limit for finite admission. Locks are daemon-local and non-reentrant. | +| Poll a custom sign-in flow | [`oauth.Device`, `wait_for_input`](../packages/albedo_sdk/src/albedo/harness/sdk/oauth.gleam) | Wait in the OAuth completion worker. Input wakes it. The sign-in service handles cancellation. | +| Wait for a keyed change | [`albedo_process/subscriptions`](../packages/albedo_process/src/albedo_process/subscriptions.gleam) | Subscribe before reading state, then wait or close in the same process. Owner death cleans up. Publish after commit and re-read state after waking. | ## Read function and callback contracts A `Result(a, String)` carries the module's diagnostic, not a universal HTTP status. Host routes use `Result(Json, #(String, String))` for code and message. HTTP handlers use -[`http_api.Failure`](../src/albedo/harness/sdk/http_api.gleam). Identified OAuth -operations return `#(status, code, message)` errors. Keep those boundaries -explicit when adapting an operation. +[`http_api.Failure`](../packages/albedo_sdk/src/albedo/harness/sdk/http_api.gleam). +Identified OAuth operations return `#(status, code, message)` errors. Keep those +boundaries explicit when adapting an operation. Time parameters are documented where they are used. HTTP and worker timeouts are durations in milliseconds. Credential expiry and cooldown marks are Unix millisecond timestamps. History sequence numbers are positions, not times. An opaque handle does not imply a live lease or exclusive ownership. -[`credentials.Stored`](../src/albedo/harness/sdk/credentials.gleam) is an -immutable credential snapshot. -[`extension.Owned`](../src/albedo/harness/sdk/extension.gleam) attaches resource -callbacks; copies borrow the same resources. Only the composition owner adopts -or closes them. Follow the +[`credentials.Stored`](../packages/albedo_sdk/src/albedo/harness/sdk/credentials.gleam) +is an immutable credential snapshot. +[`extension.Owned`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +attaches resource callbacks; copies borrow the same resources. Only the +composition owner adopts or closes them. Follow the [shared lifecycle rules](../robot-docs/contributing.md#preserve-extension-lifecycle-boundaries). Some SDK functions support the host itself. For example, `extension.install`, @@ -111,9 +112,9 @@ The SDK functions that read or change core's tables, such as `sdk/history`, `sdk/sessions`, `sdk/family`, `sdk/mail`, `sdk/images`, `sdk/request_history`, and `transfer.occurred_in`, take your storage handle and check its capabilities. Core runs their statements: the records in -[`sdk/core_tables`](../src/albedo/harness/sdk/core_tables.gleam) are the -contract it implements, and `storage.core` is for the host and the SDK only. -Call the SDK functions, not those records. See +[`sdk/core_tables`](../packages/albedo_sdk/src/albedo/harness/sdk/core_tables.gleam) +are the contract it implements, and `storage.core` is for the host and the SDK +only. Call the SDK functions, not those records. See [core table operations](../robot-docs/extensions.md#core-table-operations). ## Maintain the reference diff --git a/docs/extensions.md b/docs/extensions.md index d2b94f1f6..b2c718167 100644 --- a/docs/extensions.md +++ b/docs/extensions.md @@ -60,7 +60,7 @@ would write them in. Create `src/albedo/harness/extensions//extension.gleam`. An extension belongs to that one directory. Its constructor returns an -[`extension.Extension`](../src/albedo/harness/sdk/extension.gleam): +[`extension.Extension`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam): ```gleam pub fn extension() -> extension.Extension { @@ -117,14 +117,15 @@ cleaner on the shared writer, where a full table scan holds up every other write. See [foreign-key indexes](../robot-docs/migrations.md#foreign-key-indexes). -Run SQL through [`sdk/storage`](../src/albedo/harness/sdk/storage.gleam), never -`sdk/store`. Use `storage.read` for a read on a reader, `storage.query` for work -on the writer, and `storage.transaction` inside a `query` for several statements -that commit together. `transaction` takes a body whose error is a `String`. -`storage.transaction_with(db, failed, body)` takes a body that fails with your -own error type, and `failed` turns a failure to begin or commit into it. Any -error of the body rolls the transaction back. `ledger.add` uses it to answer -`Full` for a full checklist. In outline: +Run SQL through +[`sdk/storage`](../packages/albedo_sdk/src/albedo/harness/sdk/storage.gleam), +never `sdk/store`. Use `storage.read` for a read on a reader, `storage.query` +for work on the writer, and `storage.transaction` inside a `query` for several +statements that commit together. `transaction` takes a body whose error is a +`String`. `storage.transaction_with(db, failed, body)` takes a body that fails +with your own error type, and `failed` turns a failure to begin or commit into +it. Any error of the body rolls the transaction back. `ledger.add` uses it to +answer `Full` for a full checklist. In outline: ```gleam storage.query(store, fn(db) { @@ -174,8 +175,8 @@ the extension. It has two halves. Answer `Ok(json)`, which the Python call returns, or `Error(#(code, message))`, which it raises as `api.HostError` with that message and a `code` attribute. Use - [`rpc.serve`](../src/albedo/harness/sdk/rpc.gleam) to map a domain error to - that pair and `rpc.args` to decode arguments. + [`rpc.serve`](../packages/albedo_sdk/src/albedo/harness/sdk/rpc.gleam) to map + a domain error to that pair and `rpc.args` to decode arguments. The context's `storage` is the extension's handle, bound to the calling session, and `session` is that session's ID. Key every row by `context.session`, and @@ -199,8 +200,8 @@ extension. ## Add a slash command `CommandPlugin` adds commands to the session's catalog. A -[`command.Command`](../src/albedo/harness/sdk/command.gleam) chooses who may -call it and what a call does: +[`command.Command`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam) +chooses who may call it and what a call does: - `model_callable: True` adds a method to the Python `commands` object, such as `await commands.greet("Ada")`. Its `run` answers `command.Data(json)`, which @@ -226,10 +227,11 @@ is `False`, because the model has the Python binding. An extension declares a `command.Command(command.Invocation)`. Its `run` and `skill_activation` receive a -[`command.Invocation`](../src/albedo/harness/sdk/command.gleam): the session ID, -a `state` callback that reaches session state through the session's actor, and -the extension's handle in `storage`, bound to that session. The host builds it -for each call, so read the handle there rather than capturing one. +[`command.Invocation`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam): +the session ID, a `state` callback that reaches session state through the +session's actor, and the extension's handle in `storage`, bound to that session. +The host builds it for each call, so read the handle there rather than capturing +one. A command receives no inbox, because commands rarely need one. A command acts on its own session through `state`, or by answering `command.Turn`. A `user_turn` @@ -273,7 +275,7 @@ what the model and the person see. Some context fields carry authority beyond the extension's own session data, such as `inbox`, `control`, or `session_state`. List the ones the extension's code reads in a `pub const uses` of -[`capability.Capability`](../src/albedo/harness/sdk/capability.gleam) +[`capability.Capability`](../packages/albedo_sdk/src/albedo/harness/sdk/capability.gleam) constructors, and pass it as `uses`. The host replaces each capability the extension does not declare with a stand-in that refuses. Pass `uses: []` when the extension reads none. @@ -290,8 +292,8 @@ data and need no declaration. See A session can move to another daemon. A `TransferPlugin` declares which of the extension's rows move with it. Without one, the rows stay behind. Build the adapter with `transfer.declare(owner, tables, exclusions)` from -[`albedo/harness/sdk/transfer`](../src/albedo/harness/sdk/transfer.gleam), and -set the fields you need with a record update: +[`albedo/harness/sdk/transfer`](../packages/albedo_sdk/src/albedo/harness/sdk/transfer.gleam), +and set the fields you need with a record update: ```gleam transfer.Adapter( @@ -405,8 +407,9 @@ that each scenario fails when its contribution is removed. Follow the ## Read settings An extension reads its own section of `extensions.json` through -[`sdk/settings`](../src/albedo/harness/sdk/settings.gleam). Declare the section -once, register it with `SettingsPlugin`, and load it when a callback runs: +[`sdk/settings`](../packages/albedo_sdk/src/albedo/harness/sdk/settings.gleam). +Declare the section once, register it with `SettingsPlugin`, and load it when a +callback runs: ```gleam fn configuration() -> settings.Section(String) { @@ -442,9 +445,9 @@ the daemon boots uses `prepare=lambda app: app.write_extensions(...)` and is ## Choose the contributions Choose plugin types from the current `Plugin` definition in -[`extension.gleam`](../src/albedo/harness/sdk/extension.gleam) instead of -copying an old inventory. Use `ToolPlugin` for static instructions, tools, -Python modules, and host routes, `CommandPlugin` for static commands, and +[`extension.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +instead of copying an old inventory. Use `ToolPlugin` for static instructions, +tools, Python modules, and host routes, `CommandPlugin` for static commands, and `HookPlugin` for a static hook. Use `ManagedPlugin` when a contribution must be prepared before use. Use `OwnedManagedPlugin` when allocated resources must survive preparation handoff safely. If a route needs only the values on @@ -457,13 +460,13 @@ extension that owns the data. See [migrations](../robot-docs/migrations.md) and ## Connect host routes -Use [`host.Route`](../src/albedo/harness/sdk/host.gleam) for Python-to-host -calls. A route receives `host.Context`, a method string, and dynamically typed -arguments. It returns JSON or an error pair. The context supplies the -extension's storage handle, the session ID, the loaded workspace, and the -providers from the active composition. Use its supplied callbacks for progress -and captured user-command output. The providers, the captured output, and the -other authority-bearing fields are +Use [`host.Route`](../packages/albedo_sdk/src/albedo/harness/sdk/host.gleam) for +Python-to-host calls. A route receives `host.Context`, a method string, and +dynamically typed arguments. It returns JSON or an error pair. The context +supplies the extension's storage handle, the session ID, the loaded workspace, +and the providers from the active composition. Use its supplied callbacks for +progress and captured user-command output. The providers, the captured output, +and the other authority-bearing fields are [capabilities](../robot-docs/extensions.md#extension-capabilities) the route's extension must declare in `uses`. Other session operations and durable observations use the @@ -487,7 +490,7 @@ conditional edits, and notifications. Use `ClientPlugin` for human commands that read or change an HTTP resource. Start with -[`client_api.operation_defaults`](../src/albedo/harness/sdk/client_api.gleam), +[`client_api.operation_defaults`](../packages/albedo_sdk/src/albedo/harness/sdk/client_api.gleam), then override the bindings and result constraints the operation needs. Reuse `text_field`, `integer_field`, `choice_field`, and `form_body` when their defaults fit. Preserve custom labels, defaults, validators, and success @@ -512,11 +515,11 @@ session ID. Start from `extension.empty()` and fill the contribution fields you need. For an `OwnedManagedPlugin` whose worker only observes session events, use -[`worker.observer`](../src/albedo/harness/sdk/worker.gleam). Pass the -preparation owner from the `extension.Preparation` it receives, the worker loop, -the message constructor that wraps a session handle and event, and the startup -wait in milliseconds. Wrap its owned result in `Some` and map its `Error(Nil)` -to the extension startup message: +[`worker.observer`](../packages/albedo_sdk/src/albedo/harness/sdk/worker.gleam). +Pass the preparation owner from the `extension.Preparation` it receives, the +worker loop, the message constructor that wraps a session handle and event, and +the startup wait in milliseconds. Wrap its owned result in `Some` and map its +`Error(Nil)` to the extension startup message: ```gleam worker.observer(preparation.owner, run, Observed, 5000) @@ -566,8 +569,8 @@ boundary. ## Expose a JSON service For a buffered JSON API authenticated with the daemon token, import -[`harness/sdk/service`](../src/albedo/harness/sdk/service.gleam) as -`http_service`. Add its result to the extension's plugin list: +[`harness/sdk/service`](../packages/albedo_sdk/src/albedo/harness/sdk/service.gleam) +as `http_service`. Add its result to the extension's plugin list: ```gleam extension.ServicePlugin(http_service.json(65_536, service.dispatch)) @@ -579,7 +582,7 @@ Choose a body limit for the service's operations. Implement matching, query and body decoding, and domain error mapping there. Follow the [work service](../src/albedo/harness/extensions/work/service.gleam) and reuse the decoders in -[`harness/sdk/http_api`](../src/albedo/harness/sdk/http_api.gleam). +[`harness/sdk/http_api`](../packages/albedo_sdk/src/albedo/harness/sdk/http_api.gleam). Read the [HTTP service contract](../robot-docs/plugins.md#http-services) for negotiation and admission behavior. Use `extension.Service` directly when routes diff --git a/docs/http-api-architecture.md b/docs/http-api-architecture.md index 2973091b0..5bc8b7f1e 100644 --- a/docs/http-api-architecture.md +++ b/docs/http-api-architecture.md @@ -13,9 +13,10 @@ lock, and the bounded bus own the state below. HTTP handlers call these owners and project their results. The runtime passes a generic -[`store.Store`](../src/albedo/harness/sdk/store.gleam) handle named `ledger`. An -extension owns the schema it initializes through that handle. A generic store -handle does not transfer domain ownership to the HTTP adapter. +[`store.Store`](../packages/albedo_sdk/src/albedo/harness/sdk/store.gleam) +handle named `ledger`. An extension owns the schema it initializes through that +handle. A generic store handle does not transfer domain ownership to the HTTP +adapter. | State | Implementation owner | Commit or lifetime boundary | | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -25,8 +26,8 @@ handle does not transfer domain ownership to the HTTP adapter. | Session configuration and workspace intent | [`session_configuration.gleam`](../src/albedo/daemon/session_configuration.gleam) | Desired state commits before runtime changes. A process that already stopped cannot be restored by rolling back a database write. | | Session watch | [Session actor](../src/albedo/daemon/session.gleam) and [`http_session_stream.gleam`](../src/albedo/daemon/http_session_stream.gleam) | A captured cursor belongs to one actor generation and its durable high-water mark. | | Collection watch | [`bus.gleam`](../src/albedo/daemon/bus.gleam) and [`http_events.gleam`](../src/albedo/daemon/http_events.gleam) | The bus bounds admission before subscriber mailboxes. | -| Settings and credentials | [`sdk/settings_store`](../src/albedo/harness/sdk/settings_store.gleam) and [settings adapter](../src/albedo/daemon/settings.gleam) | The home lock coordinates participating readers and durable publication. Runtime application is separate. | -| Provider login | [`oauth_flows.gleam`](../src/albedo/harness/sdk/oauth_flows.gleam) | Live listeners belong to the sign-in service, which the daemon passes to its handlers. Admission and terminal records are durable, but a restart does not recreate the listener. | +| Settings and credentials | [`sdk/settings_store`](../packages/albedo_sdk/src/albedo/harness/sdk/settings_store.gleam) and [settings adapter](../src/albedo/daemon/settings.gleam) | The home lock coordinates participating readers and durable publication. Runtime application is separate. | +| Provider login | [`oauth_flows.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/oauth_flows.gleam) | Live listeners belong to the sign-in service, which the daemon passes to its handlers. Admission and terminal records are durable, but a restart does not recreate the listener. | | Prepared context | [`context_snapshot.gleam`](../src/albedo/daemon/context_snapshot.gleam) | Only the latest immutable prepared snapshot is retained. Observation does not prepare a request. | | Extension data | [Owning extension](../robot-docs/extensions.md#boundaries-to-preserve) | Each extension owns its validation, permissions, migrations, and deletion behavior. | @@ -53,8 +54,8 @@ committed recovery before reading destination files. Replacement is sequential, so external filesystem readers do not receive an atomic snapshot across files. See [persisted settings](../robot-docs/settings.md#persistence-and-recovery). -[`sdk/settings_store`](../src/albedo/harness/sdk/settings_store.gleam) owns the -recovery sequence: +[`sdk/settings_store`](../packages/albedo_sdk/src/albedo/harness/sdk/settings_store.gleam) +owns the recovery sequence: 1. Under the home lock, the owner recovers a prior committed replacement before reading or changing settings. diff --git a/docs/http-api-design.md b/docs/http-api-design.md index 4920b745c..270a71281 100644 --- a/docs/http-api-design.md +++ b/docs/http-api-design.md @@ -128,8 +128,9 @@ Optional extension intake routes declare their own authentication policy. ### Encoding, limits, and pagination -The SDK [`http_api.gleam`](../src/albedo/harness/sdk/http_api.gleam) owns the -response limit, request decoding, and paging tokens. It decodes with +The SDK +[`http_api.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/http_api.gleam) +owns the response limit, request decoding, and paging tokens. It decodes with [`albedo_json`](../packages/albedo_json/src/albedo_json.gleam), which refuses duplicate keys and trailing content. The daemon [`http_api.gleam`](../src/albedo/daemon/http_api.gleam) owns request body @@ -195,9 +196,10 @@ have this limitation. ### Revisions and errors -The [SDK HTTP contract](../src/albedo/harness/sdk/http_api.gleam) encodes -problems and validators for the daemon and extension services. The domain owner -checks the validator at its commit boundary. +The +[SDK HTTP contract](../packages/albedo_sdk/src/albedo/harness/sdk/http_api.gleam) +encodes problems and validators for the daemon and extension services. The +domain owner checks the validator at its commit boundary. An `ETag` validates the complete selected JSON representation. Configuration has a separate representation from volatile session state. Session reads expose the diff --git a/test/harness/cache_ttl_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/cache_ttl_test.gleam similarity index 100% rename from test/harness/cache_ttl_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/cache_ttl_test.gleam diff --git a/test/harness/client_api_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/client_api_test.gleam similarity index 100% rename from test/harness/client_api_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/client_api_test.gleam diff --git a/test/harness/command_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/command_test.gleam similarity index 100% rename from test/harness/command_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/command_test.gleam diff --git a/test/harness/device_flow_encoding_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/device_flow_encoding_test.gleam similarity index 100% rename from test/harness/device_flow_encoding_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/device_flow_encoding_test.gleam diff --git a/test/harness/network_context_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/network_context_test.gleam similarity index 100% rename from test/harness/network_context_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/network_context_test.gleam diff --git a/test/harness/network_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/network_test.gleam similarity index 100% rename from test/harness/network_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/network_test.gleam diff --git a/test/harness/notice_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/notice_test.gleam similarity index 100% rename from test/harness/notice_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/notice_test.gleam diff --git a/test/harness/python_repair_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/python_repair_test.gleam similarity index 100% rename from test/harness/python_repair_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/python_repair_test.gleam diff --git a/test/harness/reasoning_text_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/reasoning_text_test.gleam similarity index 100% rename from test/harness/reasoning_text_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/reasoning_text_test.gleam diff --git a/test/harness/renderer_line_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/renderer_line_test.gleam similarity index 100% rename from test/harness/renderer_line_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/renderer_line_test.gleam diff --git a/test/harness/summary_finish_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/summary_finish_test.gleam similarity index 100% rename from test/harness/summary_finish_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/summary_finish_test.gleam diff --git a/test/harness/summary_thinking_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/summary_thinking_test.gleam similarity index 100% rename from test/harness/summary_thinking_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/summary_thinking_test.gleam diff --git a/test/harness/transcript_codec_golden_test.gleam b/packages/albedo_sdk/test/albedo/harness/sdk/transcript_codec_golden_test.gleam similarity index 100% rename from test/harness/transcript_codec_golden_test.gleam rename to packages/albedo_sdk/test/albedo/harness/sdk/transcript_codec_golden_test.gleam diff --git a/test/fixtures/transcript-codec-golden.txt b/packages/albedo_sdk/test/fixtures/transcript-codec-golden.txt similarity index 100% rename from test/fixtures/transcript-codec-golden.txt rename to packages/albedo_sdk/test/fixtures/transcript-codec-golden.txt diff --git a/robot-docs/agent-sessions.md b/robot-docs/agent-sessions.md index 1e9548bb9..08d3768f4 100644 --- a/robot-docs/agent-sessions.md +++ b/robot-docs/agent-sessions.md @@ -4,8 +4,8 @@ The agents extension exposes session relationships and operations to Python code. Its routes are implemented by [`agents/extension.gleam`](../src/albedo/harness/extensions/agents/extension.gleam), with daemon operations reached through -[`sdk/session_control`](../src/albedo/harness/sdk/session_control.gleam). The -host passes the daemon's coordinator as a `session_control.Control` in +[`sdk/session_control`](../packages/albedo_sdk/src/albedo/harness/sdk/session_control.gleam). +The host passes the daemon's coordinator as a `session_control.Control` in `host.Context.control` for kernel routes and `extension.Daemon.control` for the agents service. Pass that value to the typed functions, such as `spawn` and `stop`, and do not build `Op` values. Do not keep it in process-wide state. @@ -106,11 +106,12 @@ schema, and the statements on them belong to [`daemon/family`](../src/albedo/daemon/family.gleam), which the daemon initialises at startup. The reads and writes extensions use, with their capability checks, are in -[`sdk/family`](../src/albedo/harness/sdk/family.gleam), which calls core's -operations ([core table operations](extensions.md#core-table-operations)). -Remote lookups check the family's own `family_remote` stubs first. -Correspondents, sessions on another daemon that wrote to the caller, come from -mail storage, so the daemon supplies that lookup as `family.Correspondents` +[`sdk/family`](../packages/albedo_sdk/src/albedo/harness/sdk/family.gleam), +which calls core's operations +([core table operations](extensions.md#core-table-operations)). Remote lookups +check the family's own `family_remote` stubs first. Correspondents, sessions on +another daemon that wrote to the caller, come from mail storage, so the daemon +supplies that lookup as `family.Correspondents` ([`family.correspondents`](../src/albedo/daemon/family.gleam)). Use mail by session ID to reach another session rather than adding nesting solely for communication. diff --git a/robot-docs/auth.md b/robot-docs/auth.md index 6af522222..fd6324d0b 100644 --- a/robot-docs/auth.md +++ b/robot-docs/auth.md @@ -7,8 +7,8 @@ and [quota](quota.md) for consumers of those choices. ## Credentials -[`credential_store`](../src/albedo/harness/sdk/credential_store.gleam) owns -`creds.json` under the Albedo home. Its `accounts` section holds provider +[`credential_store`](../packages/albedo_sdk/src/albedo/harness/sdk/credential_store.gleam) +owns `creds.json` under the Albedo home. Its `accounts` section holds provider accounts, `providers` holds profile API keys, and `mcp` holds MCP credentials. The file can contain secrets, but account records also contain metadata. Its default write uses a temporary file with mode `0600`, syncs it, and renames it @@ -18,8 +18,9 @@ into place. Mutations use the settings lock. before retiring the old files to backups. An unreadable credential store causes migration to fail rather than overwrite it. Under the same lock it then runs the step its caller passes: -[`credentials.migrate`](../src/albedo/harness/sdk/credentials.gleam) passes -[`account_migration.run`](../src/albedo/harness/sdk/account_migration.gleam), +[`credentials.migrate`](../packages/albedo_sdk/src/albedo/harness/sdk/credentials.gleam) +passes +[`account_migration.run`](../packages/albedo_sdk/src/albedo/harness/sdk/account_migration.gleam), which turns saved profiles and keys into accounts once per home. The module merges saved profile keys into configuration on read. A nonempty key still in `config.json` takes precedence. @@ -67,9 +68,9 @@ behavior. See [cache warming](cache-warming.md) for background eligibility, ## Accounts -[`auth_accounts`](../src/albedo/harness/sdk/auth_accounts.gleam) builds the -account projection used by the auth API. It includes saved OAuth and key -accounts and environment key accounts, together with profiles that select or +[`auth_accounts`](../packages/albedo_sdk/src/albedo/harness/sdk/auth_accounts.gleam) +builds the account projection used by the auth API. It includes saved OAuth and +key accounts and environment key accounts, together with profiles that select or rotate through them. The projection exposes account metadata, not the credential value. Environment accounts cannot be renamed through `rename_account`. A hand-edited key account without an ID, or without a label and a key that is a @@ -83,9 +84,9 @@ endpoint produce `key_exists`. Conflicting identity content produces `conflict`. ## Typed key accounts -[`key_accounts.gleam`](../src/albedo/harness/sdk/key_accounts.gleam) selects -profile-bound key accounts for OpenAI, Anthropic-compatible, Perplexity, and -Mistral model requests. `Profile` supplies the home, credential store, and +[`key_accounts.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/key_accounts.gleam) +selects profile-bound key accounts for OpenAI, Anthropic-compatible, Perplexity, +and Mistral model requests. `Profile` supplies the home, credential store, and profile name. `select` returns an opaque `Account` snapshot with its identity, original endpoint, key, and label. Keep that snapshot beside the request client and pass it to `mark_limited` after a limit response. Do not rediscover the @@ -103,7 +104,7 @@ different policy. Selection and affinity updates stay in the caller's process. Environment discovery reads the variables that the profile's account IDs name. OpenCode Go and Mistral also name their own variables. Other key stores ask a -[`key_environment.KeyEnvironment`](../src/albedo/harness/sdk/key_environment.gleam) +[`key_environment.KeyEnvironment`](../packages/albedo_sdk/src/albedo/harness/sdk/key_environment.gleam) that the caller passes in. The [runtime](../src/albedo/harness/runtime.gleam) composes one from the `KeyEnvironmentPlugin` lookups of every declared extension, quarantined ones included, and `runtime.key_environment` returns it. @@ -133,11 +134,11 @@ cannot prevent an already selected request from using a subsequently deleted key. Environment and inline limits use the process registry in -[`accounts.gleam`](../src/albedo/harness/sdk/accounts.gleam) rather than -credential persistence. Environment marking rechecks the captured variable, and -inline marking rechecks the profile credential. Inline resolution reloads its -noted cooldown. Registry limits remain scoped by store and account identity, and -affinity remains scoped by store and session. +[`accounts.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/accounts.gleam) +rather than credential persistence. Environment marking rechecks the captured +variable, and inline marking rechecks the profile credential. Inline resolution +reloads its noted cooldown. Registry limits remain scoped by store and account +identity, and affinity remains scoped by store and session. Perplexity's [model account policy](../src/albedo/harness/extensions/perplexity/accounts.gleam) @@ -166,14 +167,14 @@ source. ## Stored credentials and renewal -[`credentials.gleam`](../src/albedo/harness/sdk/credentials.gleam) exposes -opaque `Stored(a)` snapshots. Providers supply a decoder and retain their own -credential types, identity rules, expiry policy, and HTTP protocol. Decoders use -`lenient_text` for string fields that older stored credentials may hold as -another type, and `/login` listings use `text` to read one string field from a -raw credential. Both read a missing or non-string field as `""`. Account reads -and binding do not establish session affinity. Ordering and affinity stay in the -calling process. A separate read followed by binding is a snapshot, not a +[`credentials.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/credentials.gleam) +exposes opaque `Stored(a)` snapshots. Providers supply a decoder and retain +their own credential types, identity rules, expiry policy, and HTTP protocol. +Decoders use `lenient_text` for string fields that older stored credentials may +hold as another type, and `/login` listings use `text` to read one string field +from a raw credential. Both read a missing or non-string field as `""`. Account +reads and binding do not establish session affinity. Ordering and affinity stay +in the calling process. A separate read followed by binding is a snapshot, not a transaction across both operations. Login identity projections in @@ -206,17 +207,18 @@ Keep the returned snapshot beside the transport that consumes it. `mark` and match. They do not mark a replacement credential. Inline and environment limits remain transient, with their source rechecked before recording a limit. Immutable labels and process-local served-account reporting survive the stream -helper boundary. [`rotation.Pool`](../src/albedo/harness/sdk/rotation.gleam) +helper boundary. +[`rotation.Pool`](../packages/albedo_sdk/src/albedo/harness/sdk/rotation.gleam) owns retry budgets. Claude's one-time 401 renewal uses that owner without adding 429 hopping. -[`google_oauth.gleam`](../src/albedo/harness/sdk/google_oauth.gleam) shares -Google's token protocol between model and service accounts. Provider modules -retain project provisioning, entitlement checks, cache policy, and request -encoding. [Quota](quota.md) uses typed provider projections and the same renewal -path, without session selection or sign-in. Failed renewal retains the account -for a failed-authentication reading when its stored access token remains usable -as an input to the feed. +[`google_oauth.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/google_oauth.gleam) +shares Google's token protocol between model and service accounts. Provider +modules retain project provisioning, entitlement checks, cache policy, and +request encoding. [Quota](quota.md) uses typed provider projections and the same +renewal path, without session selection or sign-in. Failed renewal retains the +account for a failed-authentication reading when its stored access token remains +usable as an input to the feed. Antigravity's [account policy](../src/albedo/harness/extensions/antigravity/accounts.gleam) @@ -238,14 +240,15 @@ replaces the credential and clears the mark. Quota healing must not clear it. ## Sign-in -[`oauth.gleam`](../src/albedo/harness/sdk/oauth.gleam) defines the sign-in -declarations: `Login`, `Callback`, `DeviceFlow`, `Grant`, and `Keep`. Provider -extensions own their token exchanges and account projection. +[`oauth.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/oauth.gleam) +defines the sign-in declarations: `Login`, `Callback`, `DeviceFlow`, `Grant`, +and `Keep`. Provider extensions own their token exchanges and account +projection. -[`oauth_flows.gleam`](../src/albedo/harness/sdk/oauth_flows.gleam) runs -sign-ins. Its `Service` is an opaque handle to one owner process. The daemon -starts it in [`server.main`](../src/albedo/daemon/server.gleam), linked to the -daemon, and passes it in `registry.Config.oauth`. +[`oauth_flows.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/oauth_flows.gleam) +runs sign-ins. Its `Service` is an opaque handle to one owner process. The +daemon starts it in [`server.main`](../src/albedo/daemon/server.gleam), linked +to the daemon, and passes it in `registry.Config.oauth`. [`http_auth`](../src/albedo/daemon/http_auth.gleam) is its only caller. It calls `start_identified`, `get_identified`, `input_identified`, and `cancel_identified` with that handle. Nothing finds the owner by name. Pass the @@ -283,7 +286,8 @@ pasted callback URL. `authorize` sees `None`. An RFC 8628 `DeviceFlow` runs through [`albedo_oauth/device`](../packages/albedo_oauth/src/albedo_oauth/device.gleam). `oauth.device_start` encodes the request bodies and supplies the albedo parts: -requests go through [`sdk/http`](../src/albedo/harness/sdk/http.gleam), so the +requests go through +[`sdk/http`](../packages/albedo_sdk/src/albedo/harness/sdk/http.gleam), so the flow's network route applies, and before each poll the flow reports the declared progress text and waits its interval, unscaled, or until submitted input wakes it. The provider's `credential` builds the account from the whole token @@ -340,11 +344,11 @@ schedules or other non-human callers send are never held. ## Service and catalog reads -[`credentials.gleam`](../src/albedo/harness/sdk/credentials.gleam) supplies -typed read-only profile, stored-key, and service-section projections. Provider -discovery does not establish session affinity. OAuth discovery can renew stored -credentials or mint cached session tokens. Keep credential values out of -diagnostics and public responses. +[`credentials.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/credentials.gleam) +supplies typed read-only profile, stored-key, and service-section projections. +Provider discovery does not establish session affinity. OAuth discovery can +renew stored credentials or mint cached session tokens. Keep credential values +out of diagnostics and public responses. OpenAI catalog discovery permits anonymous requests and tries matching inline, saved, then environment keys. Perplexity discovery tries the active matching @@ -354,8 +358,9 @@ endpoint-compatible selected saved keys, then its environment keys. These policies live in each provider's `accounts.gleam`, not in a universal resolver. Exa reads its `exa.apiKey` service section through `credentials.service`. -[`http.gleam`](../src/albedo/harness/sdk/http.gleam) sends ordinary GET and JSON -POST requests with explicit request and connect timeouts, through +[`http.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/http.gleam) sends +ordinary GET and JSON POST requests with explicit request and connect timeouts, +through [`albedo_http/buffered`](../packages/albedo_http/src/albedo_http/buffered.gleam) under the caller's route. Streaming, provider status interpretation, and authentication policy remain with their existing owners. MCP credentials retain diff --git a/robot-docs/cache-ttl.md b/robot-docs/cache-ttl.md index 53fc97f3b..49c9668b2 100644 --- a/robot-docs/cache-ttl.md +++ b/robot-docs/cache-ttl.md @@ -4,8 +4,8 @@ The TTL table supplies initial cache-warmth estimates. Provider request measurements can replace those estimates. The table also supplies a clock and price inputs to [cache warming](cache-warming.md). Its values are priors, not guarantees about a provider's current behavior. -[`cache_ttl`](../src/albedo/harness/sdk/cache_ttl.gleam) owns the types, merge, -and lookup. +[`cache_ttl`](../packages/albedo_sdk/src/albedo/harness/sdk/cache_ttl.gleam) +owns the types, merge, and lookup. ## Format @@ -15,8 +15,8 @@ contains seconds and an optional write multiplier. `match` can restrict extension, host, and model with case-insensitive glob patterns. An absent field matches anything. The accepted shapes and values are defined by `entry_decoder` and its helper decoders in -[`cache_ttl.gleam`](../src/albedo/harness/sdk/cache_ttl.gleam). The shipped data -is [`priv/cache-ttl.json`](../priv/cache-ttl.json). +[`cache_ttl.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/cache_ttl.gleam). +The shipped data is [`priv/cache-ttl.json`](../priv/cache-ttl.json). `Refresh` and `Fixed` entries with a tier provide a clock. `Evict` and `Unknown` do not. `lifetime` uses the shortest explicit cache mark when present, otherwise @@ -25,31 +25,32 @@ endpoint host before lookup. The first matching entry wins. ## Layers -[`cache_ttl.gleam`](../src/albedo/harness/sdk/cache_ttl.gleam) reads the shipped -table, `$ALBEDO_HOME/cache-ttl-remote.json`, and `$ALBEDO_HOME/cache-ttl.json`, -in that order. Later layers replace an entry with the same ID in place. New IDs -precede earlier layers. Entries merge before full decoding, so an invalid -override can shadow an earlier entry and then be skipped. Duplicate IDs -invalidate a layer. +[`cache_ttl.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/cache_ttl.gleam) +reads the shipped table, `$ALBEDO_HOME/cache-ttl-remote.json`, and +`$ALBEDO_HOME/cache-ttl.json`, in that order. Later layers replace an entry with +the same ID in place. New IDs precede earlier layers. Entries merge before full +decoding, so an invalid override can shadow an earlier entry and then be +skipped. Duplicate IDs invalidate a layer. ## Reload Files are limited to 1 MiB. -[`layered_table`](../src/albedo/harness/sdk/layered_table.gleam) caches parsed -layers by size and modification time. A malformed revision retains the layer's -last good entries and reports an error. Transient read errors are retried. A -missing optional layer contributes no entries. See `resolve` and `parse` in -`layered_table`, and `accept` in -[`cache_ttl.gleam`](../src/albedo/harness/sdk/cache_ttl.gleam). The -context-limits table uses the same layer reader. +[`layered_table`](../packages/albedo_sdk/src/albedo/harness/sdk/layered_table.gleam) +caches parsed layers by size and modification time. A malformed revision retains +the layer's last good entries and reports an error. Transient read errors are +retried. A missing optional layer contributes no entries. See `resolve` and +`parse` in `layered_table`, and `accept` in +[`cache_ttl.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/cache_ttl.gleam). +The context-limits table uses the same layer reader. `cacheTtl.url` in extension settings selects the remote source. `null` disables fetching. `refreshHours` defaults to 24, and zero disables background refresh. `table` triggers a stale refresh. `reload` explicitly fetches and reports failure, retaining the previous copy on failure. A successful replacement invalidates the caches even if the file revision appears unchanged. -[`cache_ttl.gleam`](../src/albedo/harness/sdk/cache_ttl.gleam) and -[`sdk/cached_fetch.gleam`](../src/albedo/harness/sdk/cached_fetch.gleam) +[`cache_ttl.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/cache_ttl.gleam) +and +[`sdk/cached_fetch.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/cached_fetch.gleam) implement this path. ## HTTP API diff --git a/robot-docs/commands.md b/robot-docs/commands.md index 01f21e98e..32869798e 100644 --- a/robot-docs/commands.md +++ b/robot-docs/commands.md @@ -1,17 +1,19 @@ # Commands A command declaration describes its slash name, arguments, caller permissions, -and result. [`command.gleam`](../src/albedo/harness/sdk/command.gleam) owns the -declaration, dispatch, catalog projection, and host routes. Clients also have -presentation-only commands that are not daemon command declarations. +and result. +[`command.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam) +owns the declaration, dispatch, catalog projection, and host routes. Clients +also have presentation-only commands that are not daemon command declarations. ## The catalog The session command catalog describes prepared commands. -[`command.catalog_json`](../src/albedo/harness/sdk/command.gleam) projects their -metadata. The [CLI catalog client](../cli/internal/daemon/command_catalog.go) -reads it. Resource commands identify their HTTP operation rather than exposing -an endpoint for arbitrary slash-command execution. +[`command.catalog_json`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam) +projects their metadata. The +[CLI catalog client](../cli/internal/daemon/command_catalog.go) reads it. +Resource commands identify their HTTP operation rather than exposing an endpoint +for arbitrary slash-command execution. ## Contributing commands @@ -25,8 +27,9 @@ handle-free `Context`. Neither carries an inbox: a command reaches its own session through `StateOp`s and turns, and posting belongs to host routes and startup workers, whose contexts carry a gated inbox ([add a slash command](../docs/extensions.md#add-a-slash-command)). See -[`Command`, `Invocation`, `Context`, and `StateOp`](../src/albedo/harness/sdk/command.gleam) -and the [extension types](../src/albedo/harness/sdk/extension.gleam). +[`Command`, `Invocation`, `Context`, and `StateOp`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam) +and the +[extension types](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam). The daemon builds every `Context`. [`command_state`](../src/albedo/daemon/command_state.gleam) keeps each session @@ -45,7 +48,8 @@ Command handlers run outside the session actor. A handler already running inside that actor must not call a command whose state operation waits on the actor, because that would deadlock. Model calls cannot invoke a command declared user-only or submit a user turn. `user_turn` controls delivery for a user -invocation. See [`command.call`](../src/albedo/harness/sdk/command.gleam). +invocation. See +[`command.call`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam). ## Python bindings diff --git a/robot-docs/compaction.md b/robot-docs/compaction.md index aa5a56c56..c02b6708e 100644 --- a/robot-docs/compaction.md +++ b/robot-docs/compaction.md @@ -3,23 +3,23 @@ Compaction changes the conversation projected into a model request. The durable transcript remains the source for text history, but tool-output image payloads can be elided. The strategy interface and request preparation live in -[`compaction.gleam`](../src/albedo/harness/sdk/compaction.gleam). The -[context inspector](context.md) reports the prepared request and its compaction -observation. +[`compaction.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/compaction.gleam). +The [context inspector](context.md) reports the prepared request and its +compaction observation. ## Request preparation A `Strategy` supplies `project` and `compact`. Projection reads saved strategy state without writing it or calling a model. -[`prepare`](../src/albedo/harness/sdk/compaction.gleam) projects the history, -applies notes layers, and compacts when the strategy says the projection is due -or the request forces compaction. It compacts at most once per request, then -projects again. Errors propagate to the caller. +[`prepare`](../packages/albedo_sdk/src/albedo/harness/sdk/compaction.gleam) +projects the history, applies notes layers, and compacts when the strategy says +the projection is due or the request forces compaction. It compacts at most once +per request, then projects again. Errors propagate to the caller. -[`triggered`](../src/albedo/harness/sdk/compaction.gleam) triggers a forced -compaction regardless of capacity. Otherwise it compares the request's size with -a percentage of known capacity. Without capacity it does not trigger -automatically. +[`triggered`](../packages/albedo_sdk/src/albedo/harness/sdk/compaction.gleam) +triggers a forced compaction regardless of capacity. Otherwise it compares the +request's size with a percentage of known capacity. Without capacity it does not +trigger automatically. Every strategy sizes through `Context.sizing` (`compaction.Sizing`); none turns lengths into tokens itself. A request's size is the provider's count when its @@ -40,12 +40,13 @@ estimate used (see [the context inspector](context.md)). Each strategy's observation names where it compacts as `trigger_tokens`, in the same measure as the observation size's `tokens`. For `rolling`, `snapcompact` and `coding-lcm` it is their share of the window rounded up to a whole token, -the boundary [`triggered`](../src/albedo/harness/sdk/compaction.gleam) compares -against; for `persistent-agent` it is `foldTokens`, or 85% of a smaller window. -The full and summary context views both carry it, and it is null until a request -has been observed. The context meter draws compaction at that point and counts -the tokens left until it, and draws neither when the strategy reports none. -Clients must not derive the point from the window themselves. +the boundary +[`triggered`](../packages/albedo_sdk/src/albedo/harness/sdk/compaction.gleam) +compares against; for `persistent-agent` it is `foldTokens`, or 85% of a smaller +window. The full and summary context views both carry it, and it is null until a +request has been observed. The context meter draws compaction at that point and +counts the tokens left until it, and draws neither when the strategy reports +none. Clients must not derive the point from the window themselves. `persistent-agent` and `coding-lcm` size their tails, chunk checks, pressure relief and merge guards the same way. `persistent-agent` starts a fold only on @@ -84,9 +85,9 @@ as a terminal emulator. Frames count scalars, including combining marks and joiners, independently. Nonpositive advance, width, or row count, or a frame with no cells, returns no pages. `render_frames` writes every missing chunk to one scratch directory and renders them in one -[`sdk/renderer`](../src/albedo/harness/sdk/renderer.gleam) run. Input names sort -in chunk order. `sdk/renderer` finds the binary, sets the 30-second timeout and -runs it through +[`sdk/renderer`](../packages/albedo_sdk/src/albedo/harness/sdk/renderer.gleam) +run. Input names sort in chunk order. `sdk/renderer` finds the binary, sets the +30-second timeout and runs it through [`albedo_ports`](../packages/albedo_ports/src/albedo_ports.gleam). The other strategies have their own state and configuration in @@ -162,17 +163,18 @@ keeps the provider's cache and reuses its reported count. See ## Summary failures and progress -[`reply_text`](../src/albedo/harness/sdk/compaction.gleam) rejects an empty -summarizer reply and detects replies that stopped before finishing. A long reply -cut at its output limit is kept as a `Summary` with `cut_off` set, and its text -ends with a closing note for the reader. Code decides on the flag, never on the -note. A summary combined from parts is `cut_off` when any part was, even when -the reply that combined them finished. `persistent-agent` discards a -consolidation merge marked `cut_off`, because the merge lost its end and would -replace complete memories. LCM graph nodes and pending memories store the flag -in a `cut_off` column, and a forced `persistent-agent` fold re-forms any cut-off -leaf from its rows. Nodes written before that column were marked once, when it -was added, by whether their text ends with the note. +[`reply_text`](../packages/albedo_sdk/src/albedo/harness/sdk/compaction.gleam) +rejects an empty summarizer reply and detects replies that stopped before +finishing. A long reply cut at its output limit is kept as a `Summary` with +`cut_off` set, and its text ends with a closing note for the reader. Code +decides on the flag, never on the note. A summary combined from parts is +`cut_off` when any part was, even when the reply that combined them finished. +`persistent-agent` discards a consolidation merge marked `cut_off`, because the +merge lost its end and would replace complete memories. LCM graph nodes and +pending memories store the flag in a `cut_off` column, and a forced +`persistent-agent` fold re-forms any cut-off leaf from its rows. Nodes written +before that column were marked once, when it was added, by whether their text +ends with the note. A `Summary` also names the provider request whose reply is its text, in `written_by`: the `provider_requests` row the loop recorded for the call, or the @@ -198,9 +200,11 @@ preparation after the strategy commits. tool-output images with a marker while retaining their text. Unreferenced payloads are then released. User uploads are excluded from that cleanup. The same module implements age-based tool-image expiry, and runs the payload reads -and inserts that [`sdk/images`](../src/albedo/harness/sdk/images.gleam) exposes -([core table operations](extensions.md#core-table-operations)). A transcript row -or a saved summary does not guarantee continued access to an image payload. +and inserts that +[`sdk/images`](../packages/albedo_sdk/src/albedo/harness/sdk/images.gleam) +exposes ([core table operations](extensions.md#core-table-operations)). A +transcript row or a saved summary does not guarantee continued access to an +image payload. ## Related pages diff --git a/robot-docs/contributing.md b/robot-docs/contributing.md index f7d04863e..6d82c38b4 100644 --- a/robot-docs/contributing.md +++ b/robot-docs/contributing.md @@ -18,15 +18,15 @@ Add capabilities through typed [plugins](plugins.md). Keep HTTP admission and wire encoding in daemon adapters, composition and kernel lifecycle in the [runtime](runtime.md), and feature state with its owning extension. The interfaces are defined in -[`extension.gleam`](../src/albedo/harness/sdk/extension.gleam). +[`extension.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam). Use the command's `Context.state` operations, typed SDK session operations, or supplied session callbacks to reach session behavior. Do not mutate a session's state from an extension. Resolve cross-extension dependencies from the applicable active selection, using -[`host.Context`](../src/albedo/harness/sdk/host.gleam) or `extension.Daemon` -rather than a captured installation registry. Declare each context capability -the extension reads in its `uses`, and only those, as +[`host.Context`](../packages/albedo_sdk/src/albedo/harness/sdk/host.gleam) or +`extension.Daemon` rather than a captured installation registry. Declare each +context capability the extension reads in its `uses`, and only those, as [extension capabilities](extensions.md#extension-capabilities) describes. See [commands](commands.md) and [extensions](extensions.md). @@ -44,7 +44,7 @@ orchestration in Gleam. When a change touches an Erlang module, move what Gleam can express in the same change. Keep typed values through internal operations and encode JSON at the wire boundary. Do not encode an observation to JSON and parse it again to add fields. See -[`command.StateOp`](../src/albedo/harness/sdk/command.gleam). +[`command.StateOp`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam). Carry a refusal as a typed value from the place that decides it. Daemon operations return a [`Refusal`](../src/albedo/daemon/refusal.gleam) variant, and @@ -131,8 +131,8 @@ Do not make core depend on extension internals. Daemon, harness, and SDK modules reach extension behavior through plugin contracts in the active composition. The kernel runtime under [`albedo/harness/kernel`](../src/albedo/harness/kernel) is core-owned, and the skills catalog under -[`albedo/harness/sdk/skills/`](../src/albedo/harness/sdk/skills) is SDK-owned. -Extensions import only the parts the +[`albedo/harness/sdk/skills/`](../packages/albedo_sdk/src/albedo/harness/sdk/skills) +is SDK-owned. Extensions import only the parts the [SDK import contract](extensions.md#sdk-imports-and-native-bindings) allows. Keep discovery read-only. A catalog read must not boot Python, allocate managed @@ -151,8 +151,8 @@ Give each allocated resource a cleanup owner. Use the owned preparation contract when a resource must survive handoff. A resource must establish its lifecycle monitors before reporting readiness, and adoption must finish before publication. Make close callbacks idempotent. -[`sdk/worker.gleam`](../src/albedo/harness/sdk/worker.gleam) and -[`composition.adopt`](../src/albedo/harness/extension/composition.gleam) +[`sdk/worker.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/worker.gleam) +and [`composition.adopt`](../src/albedo/harness/extension/composition.gleam) implement these contracts. Legacy managed callbacks do not acquire them automatically. @@ -172,10 +172,11 @@ run outside the actor whose state operations they call. A handler that waits on its own actor deadlocks. See [commands](commands.md) and [`session.gleam`](../src/albedo/daemon/session.gleam). -Use [`store.read` or `snapshot`](../src/albedo/harness/sdk/store.gleam) for pure -observations. Keep mutations and read-modify-write work on the writer through -`query`. Use `query_then` when an actor must remain responsive while a write -commits. Publish the result after commit, not after enqueueing. +Use +[`store.read` or `snapshot`](../packages/albedo_sdk/src/albedo/harness/sdk/store.gleam) +for pure observations. Keep mutations and read-modify-write work on the writer +through `query`. Use `query_then` when an actor must remain responsive while a +write commits. Publish the result after commit, not after enqueueing. Keep SDK mail insertion and stored-image writes on the connection supplied by the feature transaction. Notify clients after that transaction commits. @@ -202,7 +203,7 @@ runtime's failed-stop fencing and result acknowledgment protocol. See the Register `stop_before_close` for resources that read the store on their own schedule. The stop callback runs on the writer and must not call the store. Keep resource shutdown within the store's lifecycle. See -[`store.gleam`](../src/albedo/harness/sdk/store.gleam). +[`store.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/store.gleam). `store.close` returns once every connection of the store is closed, so the next open or the [startup check](migrations.md#refusal) finds the database's files diff --git a/robot-docs/discord.md b/robot-docs/discord.md index 1610b22f9..3e3a39b9a 100644 --- a/robot-docs/discord.md +++ b/robot-docs/discord.md @@ -54,9 +54,9 @@ bot processes and reconciles their state. process. [`port.gleam`](../src/albedo/harness/extensions/discord/port.gleam) runs one reader process per bot that owns the helper's port, its line framing, and its request IDs. It opens the helper through `open_python` in -[`sdk/host_resources`](../src/albedo/harness/sdk/host_resources.gleam), with the -bot's credentials added to the daemon's trusted environment and line framing, -and writes and closes it through +[`sdk/host_resources`](../packages/albedo_sdk/src/albedo/harness/sdk/host_resources.gleam), +with the bot's credentials added to the daemon's trusted environment and line +framing, and writes and closes it through [`albedo_ports`](../packages/albedo_ports/src/albedo_ports.gleam). Ordinary requests have a 15-second timeout. Catch-up uses 60 seconds. diff --git a/robot-docs/extensions.md b/robot-docs/extensions.md index 0d7a79ed8..34d494e12 100644 --- a/robot-docs/extensions.md +++ b/robot-docs/extensions.md @@ -3,8 +3,8 @@ An extension is a named bundle of plugins. The registry in [extensions.gleam](../src/albedo/harness/extensions.gleam) declares installed extensions and defaults. The -[extension types](../src/albedo/harness/sdk/extension.gleam) define their -contributions. See [plugins](plugins.md) for the host contracts, +[extension types](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +define their contributions. See [plugins](plugins.md) for the host contracts, [Write an extension](../docs/extensions.md) for a working Gleam example, and the [extension API reference](../docs/extension-api.md) for function-level documentation and generated signatures. @@ -61,7 +61,7 @@ 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`, `Preparation`, and `OwnedManagedPlugin` in -[extension.gleam](../src/albedo/harness/sdk/extension.gleam). +[extension.gleam](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam). During reload, application workers borrow the adopted candidate and previous session. The runtime settles their results and closes the losing resources. See @@ -71,7 +71,7 @@ death, and late-result cleanup. ## Extension settings `SettingsPlugin` registers an extension's settings declaration. -[`settings/declared.gleam`](../src/albedo/harness/sdk/settings/declared.gleam) +[`settings/declared.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/settings/declared.gleam) collects declarations and validates declared values. [`core_settings.all`](../src/albedo/daemon/core_settings.gleam) lists the daemon's own sections before each extension's `extension.settings_sections`. The @@ -88,25 +88,27 @@ and other declared dependency imports, including [workspace packages](workspace-packages.md), remain available. Extensions import nothing from `albedo/daemon/`. Storage is the scoped -[`sdk/storage`](../src/albedo/harness/sdk/storage.gleam) handle described in -[extension storage](#extension-storage), and the HTTP contract is -[`sdk/http_api`](../src/albedo/harness/sdk/http_api.gleam). No other harness -module is open to extensions. A workspace location is the SDK's -[`sdk/location`](../src/albedo/harness/sdk/location.gleam) value, and an -extension reaches the hosts workspaces live on through the `hosts` +[`sdk/storage`](../packages/albedo_sdk/src/albedo/harness/sdk/storage.gleam) +handle described in [extension storage](#extension-storage), and the HTTP +contract is +[`sdk/http_api`](../packages/albedo_sdk/src/albedo/harness/sdk/http_api.gleam). +No other harness module is open to extensions. A workspace location is the SDK's +[`sdk/location`](../packages/albedo_sdk/src/albedo/harness/sdk/location.gleam) +value, and an extension reaches the hosts workspaces live on through the `hosts` [capability](#extension-capabilities), which core's `locations` and `ssh` serve. The worktree contract is -[`sdk/worktree`](../src/albedo/harness/sdk/worktree.gleam), and an extension -reaches the host's worktree service through the `worktrees` capability, which -core's [`worktree`](../src/albedo/harness/worktree.gleam) serves. A preparation -reads its session's project files, instruction files, and capability preferences -through `extension.Preparation`'s `project_files`, `instructions`, and -`preferences`, which core's +[`sdk/worktree`](../packages/albedo_sdk/src/albedo/harness/sdk/worktree.gleam), +and an extension reaches the host's worktree service through the `worktrees` +capability, which core's [`worktree`](../src/albedo/harness/worktree.gleam) +serves. A preparation reads its session's project files, instruction files, and +capability preferences through `extension.Preparation`'s `project_files`, +`instructions`, and `preferences`, which core's [`project_files`](../src/albedo/harness/project_files.gleam), [`instruction_files`](../src/albedo/harness/instruction_files.gleam), and [`capability_preferences`](../src/albedo/harness/capability_preferences.gleam) answer. They are the session's own data, not capabilities. The skills catalog is -part of the SDK, under [`sdk/skills/`](../src/albedo/harness/sdk/skills). Every +part of the SDK, under +[`sdk/skills/`](../packages/albedo_sdk/src/albedo/harness/sdk/skills). Every kernel module is private to core, including [`albedo/harness/kernel`](../src/albedo/harness/kernel.gleam), [`kernel/journal`](../src/albedo/harness/kernel/journal.gleam), @@ -115,201 +117,205 @@ kernel module is private to core, including [`kernel/tool`](../src/albedo/harness/kernel/tool.gleam), and the [harness base](#the-harness-base) modules, along with link, launch, recovery, termination, and cell storage. Extensions take the kernel's types from -[`sdk/kernel`](../src/albedo/harness/sdk/kernel.gleam), and read its job book -and recorded processes through the `kernel_jobs` and `kernel_resources` -[capabilities](#extension-capabilities). The saved extension selection is the -`selection` capability, not an import of `extension/selection`. Reach the kernel -through Python bindings and host routes, not by driving cells. Extensions also -import the [workspace packages](#workspace-packages) listed below directly. -Transfer adapters import -[`sdk/transfer`](../src/albedo/harness/sdk/transfer.gleam) for the `Adapter`, -`Table`, `Shift`, and `Activation` types. Use supplied host or session callbacks -for daemon effects that the SDK does not expose. Follow the +[`sdk/kernel`](../packages/albedo_sdk/src/albedo/harness/sdk/kernel.gleam), and +read its job book and recorded processes through the `kernel_jobs` and +`kernel_resources` [capabilities](#extension-capabilities). The saved extension +selection is the `selection` capability, not an import of `extension/selection`. +Reach the kernel through Python bindings and host routes, not by driving cells. +Extensions also import the [workspace packages](#workspace-packages) listed +below directly. Transfer adapters import +[`sdk/transfer`](../packages/albedo_sdk/src/albedo/harness/sdk/transfer.gleam) +for the `Adapter`, `Table`, `Shift`, and `Activation` types. Use supplied host +or session callbacks for daemon effects that the SDK does not expose. Follow the [shared contribution rules](contributing.md). The existing SDK modules are: -- [`sdk/extension`](../src/albedo/harness/sdk/extension.gleam): Extension - declarations, contributions, preparation and startup contexts, and preparation - ownership. -- [`sdk/storage`](../src/albedo/harness/sdk/storage.gleam): An extension's - storage handle and the store operations it runs its own SQL through. See - [extension storage](#extension-storage). -- [`sdk/service`](../src/albedo/harness/sdk/service.gleam): Buffered JSON - extension HTTP services. -- [`sdk/http_api`](../src/albedo/harness/sdk/http_api.gleam): HTTP failures, - problem and JSON replies, request decoding through `albedo_json`'s strict - decoder with field policy, which representations a route offers, - preconditions, revision validators, and paging tokens shared with the daemon. - It reads Accept headers through `albedo_web/accept`. -- [`sdk/worker`](../src/albedo/harness/sdk/worker.gleam): Owned worker startup - and adoption. -- [`sdk/startup`](../src/albedo/harness/sdk/startup.gleam): Boot-stage timing - under `ALBEDO_BOOT_TIMING=1`. -- [`sdk/host`](../src/albedo/harness/sdk/host.gleam): Context and routes for - kernel host calls. -- [`sdk/kernel`](../src/albedo/harness/sdk/kernel.gleam): The `Kernel` handle a - tool context and `command.KernelRead` carry, the live background `Job` that - `command.KernelJobs` projects, the job book's records, pages and failures, and - the `Jobs` and `Resources` records of the `kernel_jobs` and `kernel_resources` - capabilities. The kernel runtime behind the handle stays in core, which builds - those records (`kernel/jobs.capability` and `kernel/resources.capability`). -- [`sdk/python_repair`](../src/albedo/harness/sdk/python_repair.gleam): The - python tool's replay repair: whether cell source shows token-stream +- [`sdk/extension`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam): + Extension declarations, contributions, preparation and startup contexts, and + preparation ownership. +- [`sdk/storage`](../packages/albedo_sdk/src/albedo/harness/sdk/storage.gleam): + An extension's storage handle and the store operations it runs its own SQL + through. See [extension storage](#extension-storage). +- [`sdk/service`](../packages/albedo_sdk/src/albedo/harness/sdk/service.gleam): + Buffered JSON extension HTTP services. +- [`sdk/http_api`](../packages/albedo_sdk/src/albedo/harness/sdk/http_api.gleam): + HTTP failures, problem and JSON replies, request decoding through + `albedo_json`'s strict decoder with field policy, which representations a + route offers, preconditions, revision validators, and paging tokens shared + with the daemon. It reads Accept headers through `albedo_web/accept`. +- [`sdk/worker`](../packages/albedo_sdk/src/albedo/harness/sdk/worker.gleam): + Owned worker startup and adoption. +- [`sdk/startup`](../packages/albedo_sdk/src/albedo/harness/sdk/startup.gleam): + Boot-stage timing under `ALBEDO_BOOT_TIMING=1`. +- [`sdk/host`](../packages/albedo_sdk/src/albedo/harness/sdk/host.gleam): + Context and routes for kernel host calls. +- [`sdk/kernel`](../packages/albedo_sdk/src/albedo/harness/sdk/kernel.gleam): + The `Kernel` handle a tool context and `command.KernelRead` carry, the live + background `Job` that `command.KernelJobs` projects, the job book's records, + pages and failures, and the `Jobs` and `Resources` records of the + `kernel_jobs` and `kernel_resources` capabilities. The kernel runtime behind + the handle stays in core, which builds those records (`kernel/jobs.capability` + and `kernel/resources.capability`). +- [`sdk/python_repair`](../packages/albedo_sdk/src/albedo/harness/sdk/python_repair.gleam): + The python tool's replay repair: whether cell source shows token-stream corruption, and `replay_item`, which elides that source from python calls through `replay.rewrite_tool_input` and leaves every other item unchanged. -- [`sdk/rpc`](../src/albedo/harness/sdk/rpc.gleam): Host-call dispatch and - argument decoding. -- [`sdk/selection`](../src/albedo/harness/sdk/selection.gleam): The `Selection` - record of the `selection` capability: whether an extension is enabled by - default, and the models whose context cap is raised. Core's +- [`sdk/rpc`](../packages/albedo_sdk/src/albedo/harness/sdk/rpc.gleam): + Host-call dispatch and argument decoding. +- [`sdk/selection`](../packages/albedo_sdk/src/albedo/harness/sdk/selection.gleam): + The `Selection` record of the `selection` capability: whether an extension is + enabled by default, and the models whose context cap is raised. Core's `extension/selection.capability` builds it. -- [`sdk/command`](../src/albedo/harness/sdk/command.gleam): Session command - declarations and state operations. -- [`sdk/follow`](../src/albedo/harness/sdk/follow.gleam): Core history and - worktree changes that `FollowPlugin` callbacks receive. -- [`sdk/hook`](../src/albedo/harness/sdk/hook.gleam): Turn and tool hook events - and verdicts. -- [`sdk/tool`](../src/albedo/harness/sdk/tool.gleam): Retrieval tool schemas, - paging, and rendering. -- [`sdk/compaction`](../src/albedo/harness/sdk/compaction.gleam): The compaction - `Strategy` contract, its `Context`, and request preparation. See - [compaction](compaction.md). -- [`sdk/transfer`](../src/albedo/harness/sdk/transfer.gleam): Transfer adapters, - the tables and files a session's move carries, and `occurred_in`. See - [moving a session](workspaces.md#moving-a-session). -- [`sdk/client_api`](../src/albedo/harness/sdk/client_api.gleam): Declarative - client HTTP operations. -- [`sdk/imagegen`](../src/albedo/harness/sdk/imagegen.gleam): Provider-neutral - image generation contracts. -- [`sdk/web_search`](../src/albedo/harness/sdk/web_search.gleam): Web search - provider contracts and selection. -- [`sdk/search`](../src/albedo/harness/sdk/search.gleam): Transcript search with - bounded database reads. -- [`sdk/sessions`](../src/albedo/harness/sdk/sessions.gleam): What the - `sessions` table says about sessions: their names, workspaces, and whether a - transfer is importing them or moved them. See +- [`sdk/command`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam): + Session command declarations and state operations. +- [`sdk/follow`](../packages/albedo_sdk/src/albedo/harness/sdk/follow.gleam): + Core history and worktree changes that `FollowPlugin` callbacks receive. +- [`sdk/hook`](../packages/albedo_sdk/src/albedo/harness/sdk/hook.gleam): Turn + and tool hook events and verdicts. +- [`sdk/tool`](../packages/albedo_sdk/src/albedo/harness/sdk/tool.gleam): + Retrieval tool schemas, paging, and rendering. +- [`sdk/compaction`](../packages/albedo_sdk/src/albedo/harness/sdk/compaction.gleam): + The compaction `Strategy` contract, its `Context`, and request preparation. + See [compaction](compaction.md). +- [`sdk/transfer`](../packages/albedo_sdk/src/albedo/harness/sdk/transfer.gleam): + Transfer adapters, the tables and files a session's move carries, and + `occurred_in`. See [moving a session](workspaces.md#moving-a-session). +- [`sdk/client_api`](../packages/albedo_sdk/src/albedo/harness/sdk/client_api.gleam): + Declarative client HTTP operations. +- [`sdk/imagegen`](../packages/albedo_sdk/src/albedo/harness/sdk/imagegen.gleam): + Provider-neutral image generation contracts. +- [`sdk/web_search`](../packages/albedo_sdk/src/albedo/harness/sdk/web_search.gleam): + Web search provider contracts and selection. +- [`sdk/search`](../packages/albedo_sdk/src/albedo/harness/sdk/search.gleam): + Transcript search with bounded database reads. +- [`sdk/sessions`](../packages/albedo_sdk/src/albedo/harness/sdk/sessions.gleam): + What the `sessions` table says about sessions: their names, workspaces, and + whether a transfer is importing them or moved them. See [extension storage](#extension-storage). -- [`sdk/page`](../src/albedo/harness/sdk/page.gleam): Sidebar rows and command - argument parsing. -- [`sdk/http`](../src/albedo/harness/sdk/http.gleam): Buffered HTTP requests - under albedo's network policy. Each call sends through +- [`sdk/page`](../packages/albedo_sdk/src/albedo/harness/sdk/page.gleam): + Sidebar rows and command argument parsing. +- [`sdk/http`](../packages/albedo_sdk/src/albedo/harness/sdk/http.gleam): + Buffered HTTP requests under albedo's network policy. Each call sends through [`albedo_http/buffered`](../packages/albedo_http/src/albedo_http/buffered.gleam) with the caller's route and albedo's trusted roots, and words the failure. Build `buffered.Timeouts` and `buffered.Body`, and read `buffered.Response`. `request` returns status, headers, and bytes, including non-2xx responses. `failure` formats status errors; `locations` follows redirect locations concurrently under the caller's route. -- [`sdk/settings`](../src/albedo/harness/sdk/settings.gleam): Extension settings - declarations and decoding. -- [`sdk/settings/declared`](../src/albedo/harness/sdk/settings/declared.gleam): +- [`sdk/settings`](../packages/albedo_sdk/src/albedo/harness/sdk/settings.gleam): + Extension settings declarations and decoding. +- [`sdk/settings/declared`](../packages/albedo_sdk/src/albedo/harness/sdk/settings/declared.gleam): The registry of declared extension settings and validation of their values. See [extension settings](#extension-settings). -- [`sdk/credentials`](../src/albedo/harness/sdk/credentials.gleam): Credential - recovery, persistence, and notifications. `text` and `lenient_text` treat - missing or non-string credential fields as empty strings. -- [`sdk/key_accounts`](../src/albedo/harness/sdk/key_accounts.gleam): Typed - snapshots of profile-bound key accounts. `fast_mode` selects the current +- [`sdk/credentials`](../packages/albedo_sdk/src/albedo/harness/sdk/credentials.gleam): + Credential recovery, persistence, and notifications. `text` and `lenient_text` + treat missing or non-string credential fields as empty strings. +- [`sdk/key_accounts`](../packages/albedo_sdk/src/albedo/harness/sdk/key_accounts.gleam): + Typed snapshots of profile-bound key accounts. `fast_mode` selects the current connection before invoking the provider's support callback. A selection failure returns `FastUnknown` with the provider's error prefix. The callback owns model and endpoint eligibility, mode, source, and unavailable reasons. -- [`sdk/key_environment`](../src/albedo/harness/sdk/key_environment.gleam): The - runtime's composed `KeyEnvironmentPlugin` lookups. Pass the value from the +- [`sdk/key_environment`](../packages/albedo_sdk/src/albedo/harness/sdk/key_environment.gleam): + The runtime's composed `KeyEnvironmentPlugin` lookups. Pass the value from the context you receive to key account readers. See [typed key accounts](auth.md#typed-key-accounts). -- [`sdk/accounts`](../src/albedo/harness/sdk/accounts.gleam): Pure account pool - ordering. -- [`sdk/rotation`](../src/albedo/harness/sdk/rotation.gleam): Rate-limit account - rotation. -- [`sdk/oauth`](../src/albedo/harness/sdk/oauth.gleam): OAuth sign-in and token - helpers. Build `DeviceFlow` inside `oauth.device`'s start callback so runtime - environment overrides are read after sealed declarations load. It runs a - device flow through +- [`sdk/accounts`](../packages/albedo_sdk/src/albedo/harness/sdk/accounts.gleam): + Pure account pool ordering. +- [`sdk/rotation`](../packages/albedo_sdk/src/albedo/harness/sdk/rotation.gleam): + Rate-limit account rotation. +- [`sdk/oauth`](../packages/albedo_sdk/src/albedo/harness/sdk/oauth.gleam): + OAuth sign-in and token helpers. Build `DeviceFlow` inside `oauth.device`'s + start callback so runtime environment overrides are read after sealed + declarations load. It runs a device flow through [`albedo_oauth/device`](../packages/albedo_oauth/src/albedo_oauth/device.gleam), sending through `sdk/http` and wording each failure. -- [`sdk/oauth_flows`](../src/albedo/harness/sdk/oauth_flows.gleam): The sign-in - service that runs `oauth.Login` declarations. The daemon starts it and passes - the opaque `Service` handle to its HTTP handlers. Extensions do not call it. - See [sign-in](auth.md#sign-in). -- [`sdk/google_oauth`](../src/albedo/harness/sdk/google_oauth.gleam): Shared - Google token renewal. -- [`sdk/model_lists`](../src/albedo/harness/sdk/model_lists.gleam): Provider - model-list helpers. -- [`sdk/usage_feed`](../src/albedo/harness/sdk/usage_feed.gleam): Usage driver - execution and bounded I/O. +- [`sdk/oauth_flows`](../packages/albedo_sdk/src/albedo/harness/sdk/oauth_flows.gleam): + The sign-in service that runs `oauth.Login` declarations. The daemon starts it + and passes the opaque `Service` handle to its HTTP handlers. Extensions do not + call it. See [sign-in](auth.md#sign-in). +- [`sdk/google_oauth`](../packages/albedo_sdk/src/albedo/harness/sdk/google_oauth.gleam): + Shared Google token renewal. +- [`sdk/model_lists`](../packages/albedo_sdk/src/albedo/harness/sdk/model_lists.gleam): + Provider model-list helpers. +- [`sdk/usage_feed`](../packages/albedo_sdk/src/albedo/harness/sdk/usage_feed.gleam): + Usage driver execution and bounded I/O. The SDK also provides these helpers. -- [`sdk/cached_fetch`](../src/albedo/harness/sdk/cached_fetch.gleam): The - bounded fetch of a url-backed cache file. It allows https, and plain http only - on loopback. `refresh` starts at most one background fetch per refresh key - when the file is stale. `reload` fetches now and reports the failure. A fetch - commits through `commit`, a rename that a failed fetch never reaches. +- [`sdk/cached_fetch`](../packages/albedo_sdk/src/albedo/harness/sdk/cached_fetch.gleam): + The bounded fetch of a url-backed cache file. It allows https, and plain http + only on loopback. `refresh` starts at most one background fetch per refresh + key when the file is stale. `reload` fetches now and reports the failure. A + fetch commits through `commit`, a rename that a failed fetch never reaches. `isolated` runs a large decode in a fresh process. -- [`sdk/credential_store`](../src/albedo/harness/sdk/credential_store.gleam): +- [`sdk/credential_store`](../packages/albedo_sdk/src/albedo/harness/sdk/credential_store.gleam): `creds.json` reads, private atomic writes of JSON documents through `albedo_file`, the saved account sections, and cache file age. Hold the settings lock from - [`sdk/settings_store`](../src/albedo/harness/sdk/settings_store.gleam) across - a read and the write that depends on it. -- [`sdk/settings_documents`](../src/albedo/harness/sdk/settings_documents.gleam): + [`sdk/settings_store`](../packages/albedo_sdk/src/albedo/harness/sdk/settings_store.gleam) + across a read and the write that depends on it. +- [`sdk/settings_documents`](../packages/albedo_sdk/src/albedo/harness/sdk/settings_documents.gleam): Whole settings documents such as `creds.json`, read and committed as a group through the settings store. Hold `with_lock` across a read and the commit that depends on it. `mcp_secrets` reads the `mcp` section of `creds.json`. -- [`sdk/host_resources`](../src/albedo/harness/sdk/host_resources.gleam): What - the host lends the SDK outside any session: albedo's priv directory, the two - Python launch policies, `open_python` for a long-running helper port an +- [`sdk/host_resources`](../packages/albedo_sdk/src/albedo/harness/sdk/host_resources.gleam): + What the host lends the SDK outside any session: albedo's priv directory, the + two Python launch policies, `open_python` for a long-running helper port an extension reads itself and `open_kernel_script`, and the CA roots albedo's trust policy keeps, which `network_context` passes to every connection. See [host resources](runtime.md#host-resources). -- [`sdk/priv`](../src/albedo/harness/sdk/priv.gleam): Paths and reads of files - shipped in albedo's priv directory, as the host installed it. A failed read - names the path and the file error. `shipped` names a shipped file only when - there is an installed priv directory. -- [`sdk/context_limits`](../src/albedo/harness/sdk/context_limits.gleam) and - [`sdk/cache_ttl`](../src/albedo/harness/sdk/cache_ttl.gleam): The context - window and prompt-cache lifetime tables, merged by - [`sdk/layered_table`](../src/albedo/harness/sdk/layered_table.gleam) from the - shipped default, a remote copy, and a local override. See +- [`sdk/priv`](../packages/albedo_sdk/src/albedo/harness/sdk/priv.gleam): Paths + and reads of files shipped in albedo's priv directory, as the host installed + it. A failed read names the path and the file error. `shipped` names a shipped + file only when there is an installed priv directory. +- [`sdk/context_limits`](../packages/albedo_sdk/src/albedo/harness/sdk/context_limits.gleam) + and + [`sdk/cache_ttl`](../packages/albedo_sdk/src/albedo/harness/sdk/cache_ttl.gleam): + The context window and prompt-cache lifetime tables, merged by + [`sdk/layered_table`](../packages/albedo_sdk/src/albedo/harness/sdk/layered_table.gleam) + from the shipped default, a remote copy, and a local override. See [cache TTL](cache-ttl.md). -- [`sdk/location`](../src/albedo/harness/sdk/location.gleam): Where a session - works, a local path or `[user@]host:/path`, parsed, normalized, and spelled. - It reads nothing: `label` and `to_json` take the ssh config lookup from their - caller. See [locations](workspaces.md#locations). -- [`sdk/hosts`](../src/albedo/harness/sdk/hosts.gleam): What a host's probe - observed, why a host is not ready (`Failure`), and the `Hosts` record of the - `hosts` capability. Core's `ssh` and `locations` run every operation. -- [`sdk/worktree`](../src/albedo/harness/sdk/worktree.gleam): The worktree - contract: the provider a version-control extension contributes, the `Worktree` - record, the `Worktrees` record of the `worktrees` capability, the `Origins` - reads linked groups take, and helpers for providers. See +- [`sdk/location`](../packages/albedo_sdk/src/albedo/harness/sdk/location.gleam): + Where a session works, a local path or `[user@]host:/path`, parsed, + normalized, and spelled. It reads nothing: `label` and `to_json` take the ssh + config lookup from their caller. See [locations](workspaces.md#locations). +- [`sdk/hosts`](../packages/albedo_sdk/src/albedo/harness/sdk/hosts.gleam): What + a host's probe observed, why a host is not ready (`Failure`), and the `Hosts` + record of the `hosts` capability. Core's `ssh` and `locations` run every + operation. +- [`sdk/worktree`](../packages/albedo_sdk/src/albedo/harness/sdk/worktree.gleam): + The worktree contract: the provider a version-control extension contributes, + the `Worktree` record, the `Worktrees` record of the `worktrees` capability, + the `Origins` reads linked groups take, and helpers for providers. See [worktrees](worktrees.md). -- [`sdk/capabilities`](../src/albedo/harness/sdk/capabilities.gleam): Skill, - instruction, and MCP preferences, their validation, and the precedence where a - session's choice overrides the global default. The host loads them: core's +- [`sdk/capabilities`](../packages/albedo_sdk/src/albedo/harness/sdk/capabilities.gleam): + Skill, instruction, and MCP preferences, their validation, and the precedence + where a session's choice overrides the global default. The host loads them: + core's [`capability_preferences`](../src/albedo/harness/capability_preferences.gleam) reads `capabilities.json` and the session's saved choices, and a preparing extension reads its session's through `Preparation.preferences`. -- [`sdk/links`](../src/albedo/harness/sdk/links.gleam): Linked workspace groups. - Each read takes the `worktree.Origins` the caller's context carries. See - [linked workspaces](workspaces.md#linked-workspaces). -- [`sdk/skills/catalog`](../src/albedo/harness/sdk/skills/catalog.gleam): The - Agent Skills catalog behind each session's `skills` configuration, with its - scanner, frontmatter policy, and prompt mentions. `scan_at` reads project +- [`sdk/links`](../packages/albedo_sdk/src/albedo/harness/sdk/links.gleam): + Linked workspace groups. Each read takes the `worktree.Origins` the caller's + context carries. See [linked workspaces](workspaces.md#linked-workspaces). +- [`sdk/skills/catalog`](../packages/albedo_sdk/src/albedo/harness/sdk/skills/catalog.gleam): + The Agent Skills catalog behind each session's `skills` configuration, with + its scanner, frontmatter policy, and prompt mentions. `scan_at` reads project skills from the directory its `readable` argument answers. See [skills](skills.md). -- [`sdk/file_fingerprint`](../src/albedo/harness/sdk/file_fingerprint.gleam): A - file's content fingerprint. -- [`sdk/local_command`](../src/albedo/harness/sdk/local_command.gleam): A - bounded local command, how it ended, and how its output is collected. The host - runs it: core's [`local_run`](../src/albedo/harness/local_run.gleam) finds the - program on `PATH` and starts it with the usage feed's environment allowlist. - The SDK starts no process itself. -- [`sdk/helper`](../src/albedo/harness/sdk/helper.gleam): Python helper - subprocess execution with explicit outcomes. -- [`sdk/renderer`](../src/albedo/harness/sdk/renderer.gleam): Runs of the - optional `albedo-render` binary, its report lines, and a scratch directory - deleted after each render. +- [`sdk/file_fingerprint`](../packages/albedo_sdk/src/albedo/harness/sdk/file_fingerprint.gleam): + A file's content fingerprint. +- [`sdk/local_command`](../packages/albedo_sdk/src/albedo/harness/sdk/local_command.gleam): + A bounded local command, how it ended, and how its output is collected. The + host runs it: core's [`local_run`](../src/albedo/harness/local_run.gleam) + finds the program on `PATH` and starts it with the usage feed's environment + allowlist. The SDK starts no process itself. +- [`sdk/helper`](../packages/albedo_sdk/src/albedo/harness/sdk/helper.gleam): + Python helper subprocess execution with explicit outcomes. +- [`sdk/renderer`](../packages/albedo_sdk/src/albedo/harness/sdk/renderer.gleam): + Runs of the optional `albedo-render` binary, its report lines, and a scratch + directory deleted after each render. Six lint rules enforce the layer boundaries in the commit and review profiles: @@ -352,18 +358,19 @@ helpers such as [workspace packages](workspace-packages.md). [`albedo_process/registry`](../packages/albedo_process/src/albedo_process/registry.gleam) holds keyed ETS registries whose tables outlive their callers. -[`sdk/priv`](../src/albedo/harness/sdk/priv.gleam) answers albedo's priv -directory from the [host resources](runtime.md#host-resources) the daemon -installed at boot. The daemon keeps its own handler registries in such tables, -each behind a typed handle in the module that owns it, such as the coordinator -in [`session_control`](../src/albedo/daemon/session_control.gleam) and the state -closures in [`command_state`](../src/albedo/daemon/command_state.gleam). -Extensions reach them only through capabilities in their context, such as -`control` and `session_state`, that they [declare](#extension-capabilities). Do -not let the SDK or an extension find a process, handler, or callback that -carries daemon or extension behavior through a process-wide registration, such -as a registered name, a registry key, a persistent term, or a named table. Pass -a capability or opaque handle in a context instead. The one exception is the +[`sdk/priv`](../packages/albedo_sdk/src/albedo/harness/sdk/priv.gleam) answers +albedo's priv directory from the [host resources](runtime.md#host-resources) the +daemon installed at boot. The daemon keeps its own handler registries in such +tables, each behind a typed handle in the module that owns it, such as the +coordinator in [`session_control`](../src/albedo/daemon/session_control.gleam) +and the state closures in +[`command_state`](../src/albedo/daemon/command_state.gleam). Extensions reach +them only through capabilities in their context, such as `control` and +`session_state`, that they [declare](#extension-capabilities). Do not let the +SDK or an extension find a process, handler, or callback that carries daemon or +extension behavior through a process-wide registration, such as a registered +name, a registry key, a persistent term, or a named table. Pass a capability or +opaque handle in a context instead. The one exception is the [host resources](runtime.md#host-resources) record, which the host installs once per VM for work outside any session and never changes. Caches, single-flight claims, subscriptions, and locks may stay process-wide, because they hand out no @@ -449,7 +456,7 @@ Erlang modules with `@external` from an extension. Linked concurrent calls with caller lifetime, a bound, and answers in the items' order. A map inside a worker runs serially. Workers start without the caller's route, so a caller that makes requests uses `map_carrying` with - [`network_context.carried`](../src/albedo/harness/sdk/network_context.gleam). + [`network_context.carried`](../packages/albedo_sdk/src/albedo/harness/sdk/network_context.gleam). - [`albedo_process/once`](../packages/albedo_process/src/albedo_process/once.gleam): Single-flight work shared by concurrent callers. The returned process runs the job; killing it cancels that job. It does not carry the route; a job routes @@ -481,7 +488,7 @@ Erlang modules with `@external` from an extension. - [`albedo_http`](../packages/albedo_http/src/albedo_http.gleam): The streaming HTTP/1.1 client provider wires and MCP over HTTP use. Open albedo's outbound connections with - [`network_context.connection_options()`](../src/albedo/harness/sdk/network_context.gleam), + [`network_context.connection_options()`](../packages/albedo_sdk/src/albedo/harness/sdk/network_context.gleam), which carries the [outbound route](network.md) and albedo's trusted roots, not with `albedo_http.options()`. [`albedo_http/body`](../packages/albedo_http/src/albedo_http/body.gleam) adds @@ -548,13 +555,13 @@ Erlang modules with `@external` from an extension. ## Extension storage Each extension declares the tables it creates in the `tables` field of its -[`extension.Extension`](../src/albedo/harness/sdk/extension.gleam). Write the -list as a `pub const tables: List(String)` of string literals in a Gleam module -under the extension's directory, and pass that constant to the constructor. The -lint reads the constant, not the constructor call. Extensions in the same -directory, such as `lcm` and `lcm-memory`, share the directory's declaration. -List only tables a `CREATE TABLE` in that directory makes: a core table in -`tables` is a lint finding, not a way to write it. See +[`extension.Extension`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam). +Write the list as a `pub const tables: List(String)` of string literals in a +Gleam module under the extension's directory, and pass that constant to the +constructor. The lint reads the constant, not the constructor call. Extensions +in the same directory, such as `lcm` and `lcm-memory`, share the directory's +declaration. List only tables a `CREATE TABLE` in that directory makes: a core +table in `tables` is a lint finding, not a way to write it. See [Gleam lint](gleam-lint.md#extension-storage-rules) for the two tables allowed explicitly. @@ -572,26 +579,28 @@ former name with `extension.rename_session_choices`, which owns the write to The typed core reads that extensions use are: -- [`sdk/sessions`](../src/albedo/harness/sdk/sessions.gleam): a session's - `names`, given name, family name, and title, from which each caller picks its - own precedence (`label` gives the one agents and `family.name_of` use); its - `standing`, whether a transfer is importing it or it moved; which of some - sessions are `importing`; `describe`, its names with its workspace; and the - discovery reads `find`, `all`, and `occupied`. -- [`sdk/history`](../src/albedo/harness/sdk/history.gleam): besides the history - reads, `seqs` for a page of a session's transcript rows, `spans` for when - ranges of them were written, and `context_use` for its pin and the prompt - tokens of its latest request. -- [`sdk/mail`](../src/albedo/harness/sdk/mail.gleam): `statuses_in` for the - letters an extension posted, by ID, `queued_in` for the letters still waiting - for some sessions, `undelivered_in` and `delivered_in` for a page of the - letters a producer filed under one grouping (`input.Filed`), `file_in` to file - letters posted before, and `requested` for whom a session asked for work. -- [`sdk/transfer`](../src/albedo/harness/sdk/transfer.gleam): `occurred_in`, for - an occurrence the daemon a session moved from ran after its export. -- [`follow.Forked`](../src/albedo/harness/sdk/follow.gleam) carries the branch's - copied rows as `branch_seqs`, so a follower maps source rows to their copies - without reading the transcript. +- [`sdk/sessions`](../packages/albedo_sdk/src/albedo/harness/sdk/sessions.gleam): + a session's `names`, given name, family name, and title, from which each + caller picks its own precedence (`label` gives the one agents and + `family.name_of` use); its `standing`, whether a transfer is importing it or + it moved; which of some sessions are `importing`; `describe`, its names with + its workspace; and the discovery reads `find`, `all`, and `occupied`. +- [`sdk/history`](../packages/albedo_sdk/src/albedo/harness/sdk/history.gleam): + besides the history reads, `seqs` for a page of a session's transcript rows, + `spans` for when ranges of them were written, and `context_use` for its pin + and the prompt tokens of its latest request. +- [`sdk/mail`](../packages/albedo_sdk/src/albedo/harness/sdk/mail.gleam): + `statuses_in` for the letters an extension posted, by ID, `queued_in` for the + letters still waiting for some sessions, `undelivered_in` and `delivered_in` + for a page of the letters a producer filed under one grouping (`input.Filed`), + `file_in` to file letters posted before, and `requested` for whom a session + asked for work. +- [`sdk/transfer`](../packages/albedo_sdk/src/albedo/harness/sdk/transfer.gleam): + `occurred_in`, for an occurrence the daemon a session moved from ran after its + export. +- [`follow.Forked`](../packages/albedo_sdk/src/albedo/harness/sdk/follow.gleam) + carries the branch's copied rows as `branch_seqs`, so a follower maps source + rows to their copies without reading the transcript. A read whose name ends in `_in` takes the caller's connection as well as its handle, so it runs inside the caller's transaction or read snapshot with the @@ -614,15 +623,15 @@ import goes live. `schedule` reads its first 25 due jobs and reads again without any importing session's, so those jobs never crowd out others. The host gives each extension a -[`storage.Storage`](../src/albedo/harness/sdk/storage.gleam) handle that carries -the shared store, the extension's name, its declared tables, and its declared -capabilities. `extension.storage_of` builds it. The contexts an extension -receives carry the handle in a `storage` field, and none carries the raw store: -`Setup`, `Startup`, `Daemon`, `Preparation`, `ModelContext`, the tool `Context`, -`host.Context`, `hook.Context`, `compaction.Context`, `web_search.Query`, -`transfer.BindingsContext`, `transfer.Activation`, and the `extension.Sidebar` a -`GlancePlugin` reads with. Callbacks that touch the store receive the handle -too: `SchedulePlugin`, `DataMigration`, `FoldPlugin`, and +[`storage.Storage`](../packages/albedo_sdk/src/albedo/harness/sdk/storage.gleam) +handle that carries the shared store, the extension's name, its declared tables, +and its declared capabilities. `extension.storage_of` builds it. The contexts an +extension receives carry the handle in a `storage` field, and none carries the +raw store: `Setup`, `Startup`, `Daemon`, `Preparation`, `ModelContext`, the tool +`Context`, `host.Context`, `hook.Context`, `compaction.Context`, +`web_search.Query`, `transfer.BindingsContext`, `transfer.Activation`, and the +`extension.Sidebar` a `GlancePlugin` reads with. Callbacks that touch the store +receive the handle too: `SchedulePlugin`, `DataMigration`, `FoldPlugin`, and `extension.storage_initialise`. No plugin variant hands an extension the raw store. Callbacks that receive a connection, such as `CleanPlugin`, `SchemaMigration`, `FollowPlugin`, and `Due.advance`, need no handle. The @@ -704,16 +713,16 @@ Core keeps the schema, migrations, and statements of its own tables. The SDK modules that read or change them hold no SQL on them. Each one checks the handle's capabilities and its session rule, keeps its own logic, and calls typed operations that core injects. The contract is -[`sdk/core_tables`](../src/albedo/harness/sdk/core_tables.gleam): one record of -operations per area, gathered in `core_tables.Tables`. Core implements each -area's record next to that area's schema, and +[`sdk/core_tables`](../packages/albedo_sdk/src/albedo/harness/sdk/core_tables.gleam): +one record of operations per area, gathered in `core_tables.Tables`. Core +implements each area's record next to that area's schema, and [`daemon/core_store`](../src/albedo/daemon/core_store.gleam) gathers them: - `Sessions`, the reads of `sdk/sessions` on the `sessions` table: [`daemon/session_rows`](../src/albedo/daemon/session_rows.gleam). The values they answer, such as `Names`, `Summary`, and `Standing`, are typed in - [`sdk/session_info`](../src/albedo/harness/sdk/session_info.gleam), below the - store, and `sdk/sessions` names them by alias. + [`sdk/session_info`](../packages/albedo_sdk/src/albedo/harness/sdk/session_info.gleam), + below the store, and `sdk/sessions` names them by alias. - `Family`, the reads and writes of `sdk/family` on `session_family`, `family_remote`, and the family columns of `sessions`: [`daemon/family`](../src/albedo/daemon/family.gleam), which also creates those @@ -767,8 +776,9 @@ test of these SDK functions runs where core is available. ### Migrations An extension changes its stored data with a `MigrationPlugin`. Both variants of -[`extension.Migration`](../src/albedo/harness/sdk/extension.gleam) take a `name` -and a [`migration.Compatibility`](../src/albedo/harness/sdk/migration.gleam): +[`extension.Migration`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +take a `name` and a +[`migration.Compatibility`](../packages/albedo_sdk/src/albedo/harness/sdk/migration.gleam): - `SchemaMigration(name, compatibility, apply)` runs on a connection right after the extension's initialiser, at every startup. Make `apply` idempotent. @@ -841,9 +851,9 @@ Some context fields carry authority beyond an extension's own session data: posting to any session, controlling sessions, reaching other daemons, or calling other extensions' providers. These fields are capabilities. Each extension declares the capabilities its code uses in the `uses` field of its -[`extension.Extension`](../src/albedo/harness/sdk/extension.gleam). Write the -list as a constant of -[`capability.Capability`](../src/albedo/harness/sdk/capability.gleam) +[`extension.Extension`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam). +Write the list as a constant of +[`capability.Capability`](../packages/albedo_sdk/src/albedo/harness/sdk/capability.gleam) constructors in a Gleam module under the extension's directory, and pass that constant to the constructor as `uses:`, `uses: editor_uses`, or `uses: module.uses`. An extension that uses no capability passes `uses: []`. @@ -877,8 +887,8 @@ Set `uses` only in the constructor. A record update such as | `Hosts` | `hosts` on `Daemon` and `Preparation` | `capability.fields` in -[`sdk/capability`](../src/albedo/harness/sdk/capability.gleam) holds this table. -The host gate denies exactly those fields, which +[`sdk/capability`](../packages/albedo_sdk/src/albedo/harness/sdk/capability.gleam) +holds this table. The host gate denies exactly those fields, which [`extension_capability_test`](../test/harness/extension_capability_test.gleam) checks, and the lint rule reads the constant from source, so the three agree. The lint also reads the SDK's constructors from source to learn where the host @@ -972,7 +982,8 @@ with the session it reads. The rule is: - a handle reads any other session only when its extension declares `History`. The same rule covers a session's letters under `Correspondence` instead of -`History`. The [`sdk/mail`](../src/albedo/harness/sdk/mail.gleam) reads of +`History`. The +[`sdk/mail`](../packages/albedo_sdk/src/albedo/harness/sdk/mail.gleam) reads of letters in the inbox are listed under it: `statuses_in`, `queued_in`, `undelivered_in`, `delivered_in`, `file_in`, which files letters, and `requested`. Each checks the rule for every session whose letters it reaches. @@ -994,9 +1005,9 @@ withdrawing can take out another producer's letter. `Daemon.session_state` reaches any session's actor under `SessionState`, but a service's handle is bound to no session, so the gate keeps the same rule for the operations that read a session's letters or history. -[`command.other_session_needs`](../src/albedo/harness/sdk/command.gleam) decides -every `command.StateOp` in an exhaustive `case`, so a new operation does not -compile until it is classified: +[`command.other_session_needs`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam) +decides every `command.StateOp` in an exhaustive `case`, so a new operation does +not compile until it is classified: - `QueueRead`, `QueueDrop`, and `QueueArrange` need `Correspondence`. - `ContextSummary`, `ContextPage`, `KernelJobs`, and `KernelRead` need @@ -1125,36 +1136,40 @@ for later. ## Session data and effects -[`sdk/history`](../src/albedo/harness/sdk/history.gleam) owns read-only history -observations, including generic folds, boundary snapshots, uploaded image pages, -and session metadata lists. The daemon reads history through the same functions -and keeps every transcript write and every statement on its tables -([core table operations](#core-table-operations)). Keep the captured snapshot -through related reads. -[`sdk/transcript`](../src/albedo/harness/sdk/transcript.gleam) and -[`sdk/session_info`](../src/albedo/harness/sdk/session_info.gleam) own the -shared value types, including a session stage's stored spelling. -[`sdk/transcript_codec`](../src/albedo/harness/sdk/transcript_codec.gleam) owns -the stored row format, and -[`sdk/image_fit`](../src/albedo/harness/sdk/image_fit.gleam) applies image fit -rows to earlier images. Producing a fit stays with the daemon's turn loop. +[`sdk/history`](../packages/albedo_sdk/src/albedo/harness/sdk/history.gleam) +owns read-only history observations, including generic folds, boundary +snapshots, uploaded image pages, and session metadata lists. The daemon reads +history through the same functions and keeps every transcript write and every +statement on its tables ([core table operations](#core-table-operations)). Keep +the captured snapshot through related reads. +[`sdk/transcript`](../packages/albedo_sdk/src/albedo/harness/sdk/transcript.gleam) +and +[`sdk/session_info`](../packages/albedo_sdk/src/albedo/harness/sdk/session_info.gleam) +own the shared value types, including a session stage's stored spelling. +[`sdk/transcript_codec`](../packages/albedo_sdk/src/albedo/harness/sdk/transcript_codec.gleam) +owns the stored row format, and +[`sdk/image_fit`](../packages/albedo_sdk/src/albedo/harness/sdk/image_fit.gleam) +applies image fit rows to earlier images. Producing a fit stays with the +daemon's turn loop. Some of these functions are public only because the daemon calls them across modules: the `transcript_codec` packing functions. Treat them as internal storage helpers. Read history through the typed `sdk/history` functions. Do not write the core transcript, session, or image tables from an extension. Replay projection, note encoding, and image validation use -[`sdk/projection`](../src/albedo/harness/sdk/projection.gleam), whose caller -passes the repair applied to each replay item: the host passes +[`sdk/projection`](../packages/albedo_sdk/src/albedo/harness/sdk/projection.gleam), +whose caller passes the repair applied to each replay item: the host passes `loop.replay_repair`, the python tool's -[`sdk/python_repair`](../src/albedo/harness/sdk/python_repair.gleam), and an -extension that projects history, such as the proxy, passes that repair itself, -[`sdk/message_content`](../src/albedo/harness/sdk/message_content.gleam), -[`sdk/note`](../src/albedo/harness/sdk/note.gleam), and -[`sdk/image`](../src/albedo/harness/sdk/image.gleam), which reads headers -through [`albedo_image`](../packages/albedo_image/src/albedo_image.gleam). -[`sdk/request_history`](../src/albedo/harness/sdk/request_history.gleam) owns -the request `Prefix` type. Its `last_turn` returns the latest successful +[`sdk/python_repair`](../packages/albedo_sdk/src/albedo/harness/sdk/python_repair.gleam), +and an extension that projects history, such as the proxy, passes that repair +itself, +[`sdk/message_content`](../packages/albedo_sdk/src/albedo/harness/sdk/message_content.gleam), +[`sdk/note`](../packages/albedo_sdk/src/albedo/harness/sdk/note.gleam), and +[`sdk/image`](../packages/albedo_sdk/src/albedo/harness/sdk/image.gleam), which +reads headers through +[`albedo_image`](../packages/albedo_image/src/albedo_image.gleam). +[`sdk/request_history`](../packages/albedo_sdk/src/albedo/harness/sdk/request_history.gleam) +owns the request `Prefix` type. Its `last_turn` returns the latest successful transcript turn's input identity. Background pings do not replace that observation. It reads only the turn's sequence, head hash, and inputs, so a malformed cost or cache-mark column on that row, or any malformed ping row, does @@ -1162,39 +1177,41 @@ not fail it. `requests.last_turn` in the daemon still reads and validates the whole row and its pings. Give a session something to read through -[`sdk/input`](../src/albedo/harness/sdk/input.gleam) with the shared -[`sdk/letter`](../src/albedo/harness/sdk/letter.gleam) kinds and deliveries: -describe the input and post it through the `input.Inbox` the context carries. -`extension.Setup`, `extension.Startup`, `extension.Daemon`, and `host.Context` -each have an `inbox` field. Pass it on to the code that posts, as the Discord -manager keeps it in its state. Do not store it in process-wide state. The -record's `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](inbox.md). -Agents' letters to each other go through `host.Context.send_mail`, which is -bound to the calling session. The -[`mail.Letters`](../src/albedo/harness/sdk/mail.gleam) on `host.Context` and -`extension.Preparation` reads the requests a session owes and has open. -[`sdk/images`](../src/albedo/harness/sdk/images.gleam) owns image payload reads -and inserts. `images.store_images` and `read_in` take the caller's handle and -connection, so they retain its transaction. The daemon keeps the `images` -schema, release, and elision, and runs every statement on the table +[`sdk/input`](../packages/albedo_sdk/src/albedo/harness/sdk/input.gleam) with +the shared +[`sdk/letter`](../packages/albedo_sdk/src/albedo/harness/sdk/letter.gleam) kinds +and deliveries: describe the input and post it through the `input.Inbox` the +context carries. `extension.Setup`, `extension.Startup`, `extension.Daemon`, and +`host.Context` each have an `inbox` field. Pass it on to the code that posts, as +the Discord manager keeps it in its state. Do not store it in process-wide +state. The record's `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](inbox.md). Agents' letters to each other go through +`host.Context.send_mail`, which is bound to the calling session. The +[`mail.Letters`](../packages/albedo_sdk/src/albedo/harness/sdk/mail.gleam) on +`host.Context` and `extension.Preparation` reads the requests a session owes and +has open. +[`sdk/images`](../packages/albedo_sdk/src/albedo/harness/sdk/images.gleam) owns +image payload reads and inserts. `images.store_images` and `read_in` take the +caller's handle and connection, so they retain its transaction. The daemon keeps +the `images` schema, release, and elision, and runs every statement on the table ([core table operations](#core-table-operations)). -[`sdk/image_codec`](../src/albedo/harness/sdk/image_codec.gleam) owns historical -image row packing, validated loading with lazy readers, and legacy compaction -fingerprints. It also owns image externalization, referenced-hash scans, and -legacy base64 decoding. The packed shapes are private constructors in -`image_codec` and `transcript_codec`, so rows keep the bytes earlier daemons -wrote. -[`transcript_codec_golden_test`](../test/harness/transcript_codec_golden_test.gleam) +[`sdk/image_codec`](../packages/albedo_sdk/src/albedo/harness/sdk/image_codec.gleam) +owns historical image row packing, validated loading with lazy readers, and +legacy compaction fingerprints. It also owns image externalization, +referenced-hash scans, and legacy base64 decoding. The packed shapes are private +constructors in `image_codec` and `transcript_codec`, so rows keep the bytes +earlier daemons wrote. +[`transcript_codec_golden_test`](../packages/albedo_sdk/test/albedo/harness/sdk/transcript_codec_golden_test.gleam) checks packing and the decoding of historical rows against -[golden rows](../test/fixtures/transcript-codec-golden.txt) from the earlier -Erlang codec. Change a packed shape only with a migration, and keep those rows -passing. The daemon retains migration transactions. Publish notifications after -commit. `extension.Daemon.invalidate` announces service changes. -`host.Context.progress` is bound to its session. `host.Context.session_state` is -the calling session's -[`command.Context`](../src/albedo/harness/sdk/command.gleam). +[golden rows](../packages/albedo_sdk/test/fixtures/transcript-codec-golden.txt) +from the earlier Erlang codec. Change a packed shape only with a migration, and +keep those rows passing. The daemon retains migration transactions. Publish +notifications after commit. `extension.Daemon.invalidate` announces service +changes. `host.Context.progress` is bound to its session. +`host.Context.session_state` is the calling session's +[`command.Context`](../packages/albedo_sdk/src/albedo/harness/sdk/command.gleam). `extension.Daemon.session_state` returns the context of the session a service request names. Both reach session state through `command.StateOp` values, which the session's actor answers. The daemon owns the lookup from session ID to actor @@ -1204,44 +1221,46 @@ not call `state` from inside the session's actor, because the call waits on that actor. `host.Context.read_shell_output` reads only that session's captured user-command output. A background service without a request context keeps the `extension.Startup.invalidate` callback its `StartupPlugin` received and calls -it after commit. [`sdk/notice`](../src/albedo/harness/sdk/notice.gleam) decodes -the completion notices a kernel posts under its own keys and withdraws them by -key once their result was read. Its `post`, `withdraw`, and `waiting` take the -route's `host.Context.inbox`. -[`sdk/webhook_address`](../src/albedo/harness/sdk/webhook_address.gleam) builds -delivery paths and addresses from a port. `extension.Daemon.intake_port` and -`extension.Preparation.intake_port` read the daemon intake listener's current -port, or `Error(Nil)` while it has none. Read it when you show an address. See -[webhooks](webhooks.md#setup). - -[`sdk/session_control`](../src/albedo/harness/sdk/session_control.gleam) exposes -typed session operations. It also defines the coordinator's `Op` and `Reply` -values, which only the daemon's session registry handles. Each typed function -takes the `session_control.Control` that `host.Context.control` and +it after commit. +[`sdk/notice`](../packages/albedo_sdk/src/albedo/harness/sdk/notice.gleam) +decodes the completion notices a kernel posts under its own keys and withdraws +them by key once their result was read. Its `post`, `withdraw`, and `waiting` +take the route's `host.Context.inbox`. +[`sdk/webhook_address`](../packages/albedo_sdk/src/albedo/harness/sdk/webhook_address.gleam) +builds delivery paths and addresses from a port. `extension.Daemon.intake_port` +and `extension.Preparation.intake_port` read the daemon intake listener's +current port, or `Error(Nil)` while it has none. Read it when you show an +address. See [webhooks](webhooks.md#setup). + +[`sdk/session_control`](../packages/albedo_sdk/src/albedo/harness/sdk/session_control.gleam) +exposes typed session operations. It also defines the coordinator's `Op` and +`Reply` values, which only the daemon's session registry handles. Each typed +function takes the `session_control.Control` that `host.Context.control` and `extension.Daemon.control` carry. See [agents](agent-sessions.md). -[`sdk/family`](../src/albedo/harness/sdk/family.gleam) owns the extension-facing -family operations and their capability checks. +[`sdk/family`](../packages/albedo_sdk/src/albedo/harness/sdk/family.gleam) owns +the extension-facing family operations and their capability checks. [`daemon/family`](../src/albedo/daemon/family.gleam) owns the family tables, their schema, and every statement on them, and keeps child admission, limits, closing, family revisions, remote stubs, and deletion claims. -[`sdk/session_identity`](../src/albedo/harness/sdk/session_identity.gleam) owns -the shared family member, address, stub, and local or remote destination values. -`host.Context.ask_moved`, `extension.Daemon.tell_refused`, and +[`sdk/session_identity`](../packages/albedo_sdk/src/albedo/harness/sdk/session_identity.gleam) +owns the shared family member, address, stub, and local or remote destination +values. `host.Context.ask_moved`, `extension.Daemon.tell_refused`, and `extension.Daemon.hook_gone` keep forwarding and refusal behavior for moved sessions with the daemon's [move owner](../src/albedo/daemon/moves.gleam). `extension.Preparation.editor_overlay` resolves an authorized editor overlay for MCP preparation. The daemon binds it to [`acp_overlay.resolve`](../src/albedo/daemon/acp_overlay.gleam). The returned -[`sdk/editor_mcp.Overlay`](../src/albedo/harness/sdk/editor_mcp.gleam) captures -its catalogue revision in lookup and 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`](../src/albedo/harness/sdk/profiles.gleam) 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. [`albedo_bytes`](../packages/albedo_bytes/src/albedo_bytes.gleam), +[`sdk/editor_mcp.Overlay`](../packages/albedo_sdk/src/albedo/harness/sdk/editor_mcp.gleam) +captures its catalogue revision in lookup and 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`](../packages/albedo_sdk/src/albedo/harness/sdk/profiles.gleam) +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. +[`albedo_bytes`](../packages/albedo_bytes/src/albedo_bytes.gleam), [`albedo_bytes/text`](../packages/albedo_bytes/src/albedo_bytes/text.gleam), and [`albedo_bytes/term`](../packages/albedo_bytes/src/albedo_bytes/term.gleam) provide binary framing, native text conversion, and legacy term-order @@ -1281,7 +1300,7 @@ 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](../src/albedo/harness/sdk/extension.gleam). +[extension.gleam](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam). Extensions can expose Python bindings, such as [MCP](mcp.md), [skills](skills.md), and [image generation](imagegen.md). Every session has the diff --git a/robot-docs/gleam-lint.md b/robot-docs/gleam-lint.md index 7ed2cb5e7..2c0a7f9b2 100644 --- a/robot-docs/gleam-lint.md +++ b/robot-docs/gleam-lint.md @@ -221,10 +221,11 @@ no `CREATE TABLE` in a module under the extension's directory makes. Extensions that share a directory share its created tables. Two entries are allowed explicitly, each with its reason in the rule's `adopted` list: `links` declares `workspace_links`, whose schema core -[`sdk/links`](../src/albedo/harness/sdk/links.gleam) owns because core reads -link groups for memory and work, while the links extension initialises the table -and is its only writer. `rolling` declares `rolling_compaction_observation`, a -table it created in earlier releases, so that its migration may drop it. +[`sdk/links`](../packages/albedo_sdk/src/albedo/harness/sdk/links.gleam) owns +because core reads link groups for memory and work, while the links extension +initialises the table and is its only writer. `rolling` declares +`rolling_compaction_observation`, a table it created in earlier releases, so +that its migration may drop it. A [SQL tokenizer](../tools/lint/src/albedo_lint/sql.gleam) reads the text. It skips `--` and `/* */` comments. It reads `"quoted"`, `` `backtick` ``, and @@ -316,17 +317,18 @@ the reads. [`capability_table.gleam`](../tools/lint/src/albedo_lint/capability_table.gleam) reads what the rule knows about the SDK from the SDK's source, so the rule and the host gate read one table. It parses -[`sdk/capability`](../src/albedo/harness/sdk/capability.gleam) for the -`Capability` constructors and the `fields`, `functions`, and `session_functions` -constants. It parses every module under `albedo/harness/sdk/`, each module -outside the SDK that defines a type a public SDK argument names, and each -context's module. The SDK names no core module, so the second set holds only -workspace packages' modules. It finds each by module path, wherever its source -lives, and [stops the lint](#code-in-workspace-packages) when the capabilities -are missing. The context types are the types `fields` names, such as -`host.Context`, `extension.Daemon`, and `transfer.BindingsContext`, resolved to -the module that defines each, together with `storage.Storage` and every public -record among those modules with a field that holds one, such as `hook.Context`, +[`sdk/capability`](../packages/albedo_sdk/src/albedo/harness/sdk/capability.gleam) +for the `Capability` constructors and the `fields`, `functions`, and +`session_functions` constants. It parses every module under +`albedo/harness/sdk/`, each module outside the SDK that defines a type a public +SDK argument names, and each context's module. The SDK names no core module, so +the second set holds only workspace packages' modules. It finds each by module +path, wherever its source lives, and +[stops the lint](#code-in-workspace-packages) when the capabilities are missing. +The context types are the types `fields` names, such as `host.Context`, +`extension.Daemon`, and `transfer.BindingsContext`, resolved to the module that +defines each, together with `storage.Storage` and every public record among +those modules with a field that holds one, such as `hook.Context`, `command.Invocation`, and `compaction.Context`. A context without a capability field is still a context, so a field added to it later is gated where its callbacks already are. A public constructor or function argument whose type is a diff --git a/robot-docs/hooks.md b/robot-docs/hooks.md index fba4aac03..a9edcb4a9 100644 --- a/robot-docs/hooks.md +++ b/robot-docs/hooks.md @@ -1,9 +1,9 @@ # Hooks Hooks let extensions answer turn events. -[`hook.gleam`](../src/albedo/harness/sdk/hook.gleam) defines the events and -merge rules. The [runtime](runtime.md) exposes the composed hook to turns and -kernel calls. +[`hook.gleam`](../packages/albedo_sdk/src/albedo/harness/sdk/hook.gleam) defines +the events and merge rules. The [runtime](runtime.md) exposes the composed hook +to turns and kernel calls. ## Events @@ -12,7 +12,8 @@ a tool call before execution. `Called` carries the call, output, and start and finish times. Outer model calls report refusals through `Called`. An inner Python call refused before execution raises without that follow-up report. `Stopping` carries the reply and the number of times hooks have held the turn -open. See [`hook.Event` and `hook.Call`](../src/albedo/harness/sdk/hook.gleam), +open. See +[`hook.Event` and `hook.Call`](../packages/albedo_sdk/src/albedo/harness/sdk/hook.gleam), [the model loop](../src/albedo/harness/loop.gleam), and [Python reporting](../priv/python/albedo_plugins/hook.py). @@ -22,10 +23,10 @@ A hook is a `fn(hook.Context, hook.Event) -> hook.Verdict`. An extension declares one with `HookPlugin`, or sets `hook` on a managed contribution when the hook needs something only preparation supplies, as the agents extension's needs `Preparation.letters`. The host asks both kinds the same way. Its -[`hook.Context`](../src/albedo/harness/sdk/hook.gleam) carries the session whose -turn asks, the workspace that session loaded, and the hook's own extension's -storage handle, bound to that session and limited to the extension's declared -capabilities. +[`hook.Context`](../packages/albedo_sdk/src/albedo/harness/sdk/hook.gleam) +carries the session whose turn asks, the workspace that session loaded, and the +hook's own extension's storage handle, bound to that session and limited to the +extension's declared capabilities. [`composition.hooks`](../src/albedo/harness/extension/composition.gleam) builds the context with `extension.hook_context` each time it reads the hooks, for the turn's session or for the session of a kernel's report. Read the handle, the @@ -37,16 +38,17 @@ handle is copied with it. See ## Combining verdicts A `Verdict` can block, replace call arguments, add context or notes, or halt the -turn. [`hook.ask`](../src/albedo/harness/sdk/hook.gleam) calls every hook in -order. [`composition.hooks`](../src/albedo/harness/extension/composition.gleam) -alone defines that order: extensions in composition order, the harness base -first and then the selection in registry order. Within one extension its -`HookPlugin` hooks come in plugin order, before its managed contribution's hook. -Whether a hook is static or managed never moves it past another extension's -hook. Do not reorder hooks elsewhere. The first block, argument replacement, and -halt each win in the final verdict. Each hook's replacement updates the event -passed to the next hook, even if an earlier replacement already won. Context and -notes accumulate. A crashed hook adds a note and otherwise proceeds. +turn. [`hook.ask`](../packages/albedo_sdk/src/albedo/harness/sdk/hook.gleam) +calls every hook in order. +[`composition.hooks`](../src/albedo/harness/extension/composition.gleam) alone +defines that order: extensions in composition order, the harness base first and +then the selection in registry order. Within one extension its `HookPlugin` +hooks come in plugin order, before its managed contribution's hook. Whether a +hook is static or managed never moves it past another extension's hook. Do not +reorder hooks elsewhere. The first block, argument replacement, and halt each +win in the final verdict. Each hook's replacement updates the event passed to +the next hook, even if an earlier replacement already won. Context and notes +accumulate. A crashed hook adds a note and otherwise proceeds. `hook.route` handles kernel inner-call reports and returns a halt as a refusal. Outer notes are published to the user by @@ -78,12 +80,12 @@ Commands use the session workspace when it exists as a directory, otherwise the helper's inherited working directory. The [hooks extension](../src/albedo/harness/extensions/hooks/extension.gleam) stops waiting for the entire helper after 660 seconds. The -[SDK helper owner](../src/albedo/harness/sdk/helper.gleam) sends cancellation -when that wait expires or the calling turn dies, then waits up to five seconds -for cleanup acknowledgment. The Python helper serializes command creation with -cancellation, kills registered groups, and reaps their leaders. Cleanup failure -is returned as `StartFailed`. Commands that deliberately leave their registered -process groups are outside this guarantee. +[SDK helper owner](../packages/albedo_sdk/src/albedo/harness/sdk/helper.gleam) +sends cancellation when that wait expires or the calling turn dies, then waits +up to five seconds for cleanup acknowledgment. The Python helper serializes +command creation with cancellation, kills registered groups, and reaps their +leaders. Cleanup failure is returned as `StartFailed`. Commands that +deliberately leave their registered process groups are outside this guarantee. ## Related pages diff --git a/robot-docs/inbox.md b/robot-docs/inbox.md index aeef9446b..98ef094da 100644 --- a/robot-docs/inbox.md +++ b/robot-docs/inbox.md @@ -24,15 +24,15 @@ summary, image fitting, and the salvage of a cut-off reply. ## Posting an input -[`sdk/input`](../src/albedo/harness/sdk/input.gleam) is the one way an extension -or a daemon module gives a session something to read. An `Input` says who it is -for and from, what it is, its text and the line people see for it, when it is -read, and an optional key. An extension posts it through the `input.Inbox` its -context carries, as in `daemon.inbox.post(daemon.storage, input)`. The record's -`post` stores it. Its `post_in` stores it in the caller's transaction, so it -commits with the producer's own records or not at all: a webhook delivery, a -Discord message's channel cursor, a schedule's advance. `input.note` builds a -note. +[`sdk/input`](../packages/albedo_sdk/src/albedo/harness/sdk/input.gleam) is the +one way an extension or a daemon module gives a session something to read. An +`Input` says who it is for and from, what it is, its text and the line people +see for it, when it is read, and an optional key. An extension posts it through +the `input.Inbox` its context carries, as in +`daemon.inbox.post(daemon.storage, input)`. The record's `post` stores it. Its +`post_in` stores it in the caller's transaction, so it commits with the +producer's own records or not at all: a webhook delivery, a Discord message's +channel cursor, a schedule's advance. `input.note` builds a note. | From | Who | | ---------------------- | -------------------------------------------------------------- | @@ -80,20 +80,21 @@ keep an inbox in process-wide state, and do not build another one in an extension. A producer that shows where its posts stand reads them through -[`sdk/mail`](../src/albedo/harness/sdk/mail.gleam), not through SQL on `mail`: -`statuses_in` reads letters by ID, which is a `Once` key, `queued_in` reads the -letters still waiting for some sessions, and `undelivered_in` and `delivered_in` -page the letters filed under one grouping by whether they were delivered. A -filed letter keeps its grouping as its key, the column a `Latest` key uses, so -filing adds no column a transfer would carry; partial indexes on the key hold -the delivered and the undelivered ones apart. Choose a grouping no `Latest` key -of the recipient can equal, such as a prefixed id. `file_in` files letters a -producer posted before it filed them, and leaves a letter that has a key alone. -All run on the caller's connection and need the `Inbox` capability. Their -statements run in core's [`mail`](../src/albedo/daemon/mail.gleam), next to the -inbox's schema ([core table operations](extensions.md#core-table-operations)): -`sdk/mail` checks the capabilities and the session rule, and `file_in` checks -the recipients of the letters it found before it files them, in the caller's +[`sdk/mail`](../packages/albedo_sdk/src/albedo/harness/sdk/mail.gleam), not +through SQL on `mail`: `statuses_in` reads letters by ID, which is a `Once` key, +`queued_in` reads the letters still waiting for some sessions, and +`undelivered_in` and `delivered_in` page the letters filed under one grouping by +whether they were delivered. A filed letter keeps its grouping as its key, the +column a `Latest` key uses, so filing adds no column a transfer would carry; +partial indexes on the key hold the delivered and the undelivered ones apart. +Choose a grouping no `Latest` key of the recipient can equal, such as a prefixed +id. `file_in` files letters a producer posted before it filed them, and leaves a +letter that has a key alone. All run on the caller's connection and need the +`Inbox` capability. Their statements run in core's +[`mail`](../src/albedo/daemon/mail.gleam), next to the inbox's schema +([core table operations](extensions.md#core-table-operations)): `sdk/mail` +checks the capabilities and the session rule, and `file_in` checks the +recipients of the letters it found before it files them, in the caller's transaction. They keep the session rule of the history reads: a handle reaches the letters to the session it is bound to, and another session's only when its extension declares `Correspondence` @@ -105,11 +106,13 @@ Letters between agents go through `host.Context.send_mail`, which [`kernels.gleam`](../src/albedo/harness/runtime/kernels.gleam) binds to the calling session and [`forwarding.send`](../src/albedo/daemon/forwarding.gleam). It resolves the address, forwards to another daemon when needed, and posts the -letter. The [`mail.Letters`](../src/albedo/harness/sdk/mail.gleam) in a context -reads which requests a session owes and has open, under the same session rule. -The session itself stores two inputs: a person's input, in the transaction that -records its operation receipt (`inbox.insert`, see [operations](operations.md)), -and the restart notice, at the front of the queue (`inbox.post_first`). +letter. The +[`mail.Letters`](../packages/albedo_sdk/src/albedo/harness/sdk/mail.gleam) in a +context reads which requests a session owes and has open, under the same session +rule. The session itself stores two inputs: a person's input, in the transaction +that records its operation receipt (`inbox.insert`, see +[operations](operations.md)), and the restart notice, at the front of the queue +(`inbox.post_first`). ## Rows @@ -121,8 +124,9 @@ attachments included, and the line people see in `display`; the payload is released when the row is delivered or dropped. Its id is its operation receipt's. -[`sdk/letter`](../src/albedo/harness/sdk/letter.gleam) names the kinds and the -deliveries. The kind says what a row is; the delivery says when it is read: +[`sdk/letter`](../packages/albedo_sdk/src/albedo/harness/sdk/letter.gleam) names +the kinds and the deliveries. The kind says what a row is; the delivery says +when it is read: | Delivery | Meaning | Default for | | ----------- | ---------------------------------------------------------- | ------------------------------------------ | @@ -185,11 +189,11 @@ reads a person's input and the daemon's notes. 1. A producer posts the row, in its own transaction when it has records to commit with it. 2. Once that transaction commits, the session is told - ([`store.after_commit`](../src/albedo/harness/sdk/store.gleam), `mail.put`). - A running session registered `mail.register` when it started; it rereads its - inbox, publishes the queue change, and starts a turn when it rests and a - waiting row starts one. A running turn reads the row at its next step or when - it ends. + ([`store.after_commit`](../packages/albedo_sdk/src/albedo/harness/sdk/store.gleam), + `mail.put`). A running session registered `mail.register` when it started; it + rereads its inbox, publishes the queue change, and starts a turn when it + rests and a waiting row starts one. A running turn reads the row at its next + step or when it ends. 3. A session that is not running wakes the registry's dispatcher (`mail.waiting`). The dispatcher also runs on its tick. It loads each session holding a waiting row that starts a turn (`mail.recipients`), and settles the @@ -213,12 +217,12 @@ A finished job or background cell whose result nobody read is posted as a `job` row that waits for the running turn to end. The kernel's [`albedo_notices`](../priv/python/albedo_notices.py) chooses each notice's key and sends `{key, display, text}` to `jobs.completed` or `cells.completed` -([`sdk/notice`](../src/albedo/harness/sdk/notice.gleam)), posted `Once` under -that key. It watches the notice until everything it names was read, awaited, or -stopped here, then withdraws it by key (`jobs.withdraw`, `cells.withdraw`). A -cell awaits `albedo_notices.settle` before it reports its result, so a notice -the cell made old news is withdrawn before the turn can end. The kernel never -learns row ids and never polls. +([`sdk/notice`](../packages/albedo_sdk/src/albedo/harness/sdk/notice.gleam)), +posted `Once` under that key. It watches the notice until everything it names +was read, awaited, or stopped here, then withdraws it by key (`jobs.withdraw`, +`cells.withdraw`). A cell awaits `albedo_notices.settle` before it reports its +result, so a notice the cell made old news is withdrawn before the turn can end. +The kernel never learns row ids and never polls. A kernel started before notice keys outlives a daemon upgrade and keeps the older protocol until it is replaced: it sends no key, keeps the key the route diff --git a/robot-docs/kernel.md b/robot-docs/kernel.md index 26773b7ae..29ab1de76 100644 --- a/robot-docs/kernel.md +++ b/robot-docs/kernel.md @@ -51,9 +51,9 @@ The modules in that directory divide the work as follows: `python` tool: its schema, its instructions, a call's journaled execution, and the recovery of an interrupted call. Cell source that shows token-stream corruption is elided from replay before a model sees it again: - [`sdk/python_repair`](../src/albedo/harness/sdk/python_repair.gleam) owns the - verdict and the note, the loop applies it (`loop.replay_repair`) to the - history it projects and the calls it sends back, and + [`sdk/python_repair`](../packages/albedo_sdk/src/albedo/harness/sdk/python_repair.gleam) + owns the verdict and the note, the loop applies it (`loop.replay_repair`) to + the history it projects and the calls it sends back, and [`replay.rewrite_tool_input`](../packages/albedo_model/src/albedo_model/replay.gleam) rewrites the calls of every protocol, Bedrock Converse blocks included, leaving every other item the same term. @@ -64,8 +64,8 @@ The modules in that directory divide the work as follows: - [`kernel/place`](../src/albedo/harness/kernel/place.gleam) tells the model where a remote session's kernel runs. Remote kernels reach their host through core's [`ssh`](../src/albedo/harness/ssh.gleam), which answers with the SDK's - [`sdk/hosts`](../src/albedo/harness/sdk/hosts.gleam) values; extensions reach - hosts only through the `hosts` + [`sdk/hosts`](../packages/albedo_sdk/src/albedo/harness/sdk/hosts.gleam) + values; extensions reach hosts only through the `hosts` [capability](extensions.md#extension-capabilities). - [`kernel/transfer`](../src/albedo/harness/kernel/transfer.gleam) declares the kernel tables for session transfer. `daemon/transfer.adapters` lists it after @@ -76,7 +76,8 @@ The modules in that directory divide the work as follows: observation and recorded process ownership to the run and agents extensions, through the `kernel_jobs` and `kernel_resources` [capabilities](extensions.md#extension-capabilities) they build. The types - those carry are in [`sdk/kernel`](../src/albedo/harness/sdk/kernel.gleam). + those carry are in + [`sdk/kernel`](../packages/albedo_sdk/src/albedo/harness/sdk/kernel.gleam). - [`kernel/cell_codec`](../src/albedo/harness/kernel/cell_codec.gleam) encodes the stored form of a cell's outcome and trace. It reads every shape earlier daemons wrote. diff --git a/robot-docs/mcp.md b/robot-docs/mcp.md index cc4ab779a..138038349 100644 --- a/robot-docs/mcp.md +++ b/robot-docs/mcp.md @@ -46,7 +46,7 @@ sends. A token response must name the `bearer` type, case-insensitively, or leave `token_type` out; any other value, including one that is not a string, refuses the token. Refreshes of one server are single-flight within the daemon. Record updates hold the settings lock through -[`sdk/settings_documents`](../src/albedo/harness/sdk/settings_documents.gleam). +[`sdk/settings_documents`](../packages/albedo_sdk/src/albedo/harness/sdk/settings_documents.gleam). ## Tools and lifecycle @@ -164,8 +164,8 @@ configured server name. See `editor_extension` and `prepare_editor` in [ACP](acp.md). The shared server configuration types live in -[`sdk/editor_mcp`](../src/albedo/harness/sdk/editor_mcp.gleam). `prepare_editor` -calls `Preparation.editor_overlay`, which the host binds to +[`sdk/editor_mcp`](../packages/albedo_sdk/src/albedo/harness/sdk/editor_mcp.gleam). +`prepare_editor` calls `Preparation.editor_overlay`, which the host binds to [`acp_overlay.resolve`](../src/albedo/daemon/acp_overlay.gleam). It authorizes the marker and captures catalogue lookup and save operations for that revision. The attachment owner rejects a save after the overlay changes. Keep this diff --git a/robot-docs/migrations.md b/robot-docs/migrations.md index a3d4cace4..bd3b9e59e 100644 --- a/robot-docs/migrations.md +++ b/robot-docs/migrations.md @@ -21,8 +21,8 @@ sequence. The waiting-input upgrade moves inputs from the retired sessions' saved `extra-low` effort to `minimal`, the name [`types.Effort`](../packages/albedo_model/src/albedo_model.gleam) gives Antigravity's lowest tier; -[account migration](../src/albedo/harness/sdk/account_migration.gleam) renames a -profile's at each startup. The transcript text upgrade creates the +[account migration](../packages/albedo_sdk/src/albedo/harness/sdk/account_migration.gleam) +renames a profile's at each startup. The transcript text upgrade creates the [text index](agent-sessions.md#messages-and-resources) with every row waiting for it. Startup prints `migration : rows` for each core, kernel, and extension migration that rewrote rows. @@ -63,7 +63,7 @@ A daemon refuses to start on a home that a newer build upgraded with a breaking migration this build does not know. Additive changes never block a rollback. Every migration declares a -[`migration.Compatibility`](../src/albedo/harness/sdk/migration.gleam): +[`migration.Compatibility`](../packages/albedo_sdk/src/albedo/harness/sdk/migration.gleam): - `Additive`: a build without the migration still reads the home correctly. A new table or index, a nullable or defaulted column, or a backfill of one of @@ -271,15 +271,15 @@ it decodes. `preload()` is a no-op whose call loads the module, so a rename is a compile error at the call rather than a decode failure at run time. Bind its result with `let _ =`, since Gleam treats the call as pure. -| Term and where it is stored | Decoder | Persisted layouts | Constructors from other modules, loaded first | Fixture families | -| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | -| `turn.Submission`, an inbox row's `payload` | [`turn.decode`](../src/albedo/daemon/turn.gleam) | The record with 7, 8, 9 or 10 fields: before title text, attached files, and a skill load | `albedo_model` (images), `letter` (mail kinds, stop reasons, input forms), `operations` (attached files), `sdk/skills/catalog` (skill loads and scopes) | `submission` | -| An operation's saved display | [`operations.decode_display`](../src/albedo/daemon/operations.gleam) | `{display, ...}` with 5 fields and one image as an option, or 5, 6 or 7 fields with an image list | None: `operations` names every tag it holds | `display` | -| Transcript rows and image fit rows | [`transcript_codec`](../src/albedo/harness/sdk/transcript_codec.gleam) `unpack`, `unpack_fit`, `unpack_list` | Version 1, `{1, Row}`. A user image row holds a list of images, or one before messages held several; a tool output holds 2 fields before tool images | `image_codec` (packed images, `{stored_data, Hash, Size}`) | `transcript`, `transcript-fit`, `transcript-list` | -| Kernel cell results and traces | [`cell_codec`](../src/albedo/harness/kernel/cell_codec.gleam) `unpack`, `unpack_trace` | Version 1. An outcome holds 9 fields, 8 before timing, or 6 before images; an error is `busy`, `lost`, `{invalid, _}` or `{unavailable, _}` | `image_codec` (packed images). `cell_codec` names the outcome, status and error tags itself | `cell`, `cell-trace` | -| The MCP catalogue, `mcp_catalogues` | [`catalogue.saved`](../src/albedo/harness/extensions/mcp/catalogue.gleam) | Version 2: atom-keyed maps, whose atoms the decoder creates first | None | `mcp` | -| Memory import receipts | [`files.decode_receipt`](../src/albedo/harness/extensions/memory/files.gleam) | Version 1: `{done, Sources}` or `{pending, Sources, Before, After}` | None | `memory` | -| The models.dev index beside the catalog | [`catalog_cache.catalog`](../src/albedo/harness/extensions/models/catalog_cache.gleam) | Version 4, `{4, Revision, Index, Providers}`, and version 3, which kept the index and providers in a map | None: tuples, binaries and the atoms `null`, `index` and `providers` | `models-index` | +| Term and where it is stored | Decoder | Persisted layouts | Constructors from other modules, loaded first | Fixture families | +| ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | +| `turn.Submission`, an inbox row's `payload` | [`turn.decode`](../src/albedo/daemon/turn.gleam) | The record with 7, 8, 9 or 10 fields: before title text, attached files, and a skill load | `albedo_model` (images), `letter` (mail kinds, stop reasons, input forms), `operations` (attached files), `sdk/skills/catalog` (skill loads and scopes) | `submission` | +| An operation's saved display | [`operations.decode_display`](../src/albedo/daemon/operations.gleam) | `{display, ...}` with 5 fields and one image as an option, or 5, 6 or 7 fields with an image list | None: `operations` names every tag it holds | `display` | +| Transcript rows and image fit rows | [`transcript_codec`](../packages/albedo_sdk/src/albedo/harness/sdk/transcript_codec.gleam) `unpack`, `unpack_fit`, `unpack_list` | Version 1, `{1, Row}`. A user image row holds a list of images, or one before messages held several; a tool output holds 2 fields before tool images | `image_codec` (packed images, `{stored_data, Hash, Size}`) | `transcript`, `transcript-fit`, `transcript-list` | +| Kernel cell results and traces | [`cell_codec`](../src/albedo/harness/kernel/cell_codec.gleam) `unpack`, `unpack_trace` | Version 1. An outcome holds 9 fields, 8 before timing, or 6 before images; an error is `busy`, `lost`, `{invalid, _}` or `{unavailable, _}` | `image_codec` (packed images). `cell_codec` names the outcome, status and error tags itself | `cell`, `cell-trace` | +| The MCP catalogue, `mcp_catalogues` | [`catalogue.saved`](../src/albedo/harness/extensions/mcp/catalogue.gleam) | Version 2: atom-keyed maps, whose atoms the decoder creates first | None | `mcp` | +| Memory import receipts | [`files.decode_receipt`](../src/albedo/harness/extensions/memory/files.gleam) | Version 1: `{done, Sources}` or `{pending, Sources, Before, After}` | None | `memory` | +| The models.dev index beside the catalog | [`catalog_cache.catalog`](../src/albedo/harness/extensions/models/catalog_cache.gleam) | Version 4, `{4, Revision, Index, Providers}`, and version 3, which kept the index and providers in a map | None: tuples, binaries and the atoms `null`, `index` and `providers` | `models-index` | Three other decoders read terms with no constructor that a move could rename, so they have no fixtures: diff --git a/robot-docs/models.md b/robot-docs/models.md index a57bc57c5..406f5c0c1 100644 --- a/robot-docs/models.md +++ b/robot-docs/models.md @@ -29,8 +29,8 @@ maps are shared through without copying them. The index is saved beside the catalog as `models.json.index` in version 4. A version 3 index from an earlier daemon is still read, and the next parse writes version 4. The fetch goes through -[`sdk/cached_fetch`](../src/albedo/harness/sdk/cached_fetch.gleam). The -[catalogue module](../src/albedo/harness/extensions/models/catalogue.gleam) +[`sdk/cached_fetch`](../packages/albedo_sdk/src/albedo/harness/sdk/cached_fetch.gleam). +The [catalogue module](../src/albedo/harness/extensions/models/catalogue.gleam) bounds fetched catalogs at 32 MiB and answers lookups and listings from those maps. Legacy untrimmed files are rewritten on first parse while preserving their modification time. The catalog is external data, not a guarantee of a provider's @@ -53,8 +53,8 @@ metadata. ## Display names -[`ModelInfo`](../src/albedo/harness/sdk/extension.gleam) carries an optional -`display_name` separately from the request's model ID. The +[`ModelInfo`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +carries an optional `display_name` separately from the request's model ID. The [model resource](../src/albedo/daemon/http_resources.gleam) returns it as `label`, falling back to the ID for absent or blank names. Names are presentation only; clients send the original ID when selecting or invoking a @@ -68,10 +68,10 @@ when the reported nonempty names agree. Older caches without names still work. ## Reasoning defaults -[`ModelInfo`](../src/albedo/harness/sdk/extension.gleam) stores supported -reasoning levels and the optional `default_effort` separately, both as -`types.Effort`. Each catalog reads its provider's names into that type at its -own edge and leaves out a name albedo has no level for; Antigravity's +[`ModelInfo`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +stores supported reasoning levels and the optional `default_effort` separately, +both as `types.Effort`. Each catalog reads its provider's names into that type +at its own edge and leaves out a name albedo has no level for; Antigravity's `extra-low` tier is `minimal`. An ordered list of supported levels does not establish a provider default. The [model resource](../src/albedo/daemon/http_resources.gleam) exposes both facts @@ -181,15 +181,15 @@ their origin model can replay. See the ## Model lists -[`model_lists`](../src/albedo/harness/sdk/model_lists.gleam) exposes `ids`, -`refetch`, `saved`, and `ready` for provider-specific lists. `ModelCatalog.list` -receives the runtime's key environment as its third argument. A remote listing -that discovers an environment key passes it on, and other catalogs ignore it. -Its cache stores lists separately from the general catalog, in the -`albedo_model_lists` registry table and `$ALBEDO_HOME/model-lists`, and applies -success and failure expiry periods. Consumers must handle a missing or -unavailable list. The [proxy](proxy.md) uses profile and catalog information -when it lists models. +[`model_lists`](../packages/albedo_sdk/src/albedo/harness/sdk/model_lists.gleam) +exposes `ids`, `refetch`, `saved`, and `ready` for provider-specific lists. +`ModelCatalog.list` receives the runtime's key environment as its third +argument. A remote listing that discovers an environment key passes it on, and +other catalogs ignore it. Its cache stores lists separately from the general +catalog, in the `albedo_model_lists` registry table and +`$ALBEDO_HOME/model-lists`, and applies success and failure expiry periods. +Consumers must handle a missing or unavailable list. The [proxy](proxy.md) uses +profile and catalog information when it lists models. The custom `anthropic-api` provider keeps its own model-list namespace, separate from Claude's catalog and credentials. Model metadata still comes from the @@ -203,8 +203,8 @@ request's model ID. See [custom Anthropic gateways](auth.md#custom-anthropic-gateways) for credentials. OpenAI-compatible lists share -[`model_lists.fetch`](../src/albedo/harness/sdk/model_lists.gleam), which reads -`/models` through `sdk/http` on the caller's route, and +[`model_lists.fetch`](../packages/albedo_sdk/src/albedo/harness/sdk/model_lists.gleam), +which reads `/models` through `sdk/http` on the caller's route, and [`catalog.ids`](../packages/albedo_openai/src/albedo_openai/catalog.gleam) for sorted, unique IDs. Providers retain eligibility, credential precedence, headers, timeouts, and HTTP status policy. @@ -221,9 +221,9 @@ them. A model whose list entry omits the field keeps the old behavior. The extension's picker keeps a model that reports `architecture.output_modalities` (read by `catalog.output_modalities`) when it lists `text`, and hides one that does not; only a listed model without that field is judged by its ID's name. The -[ordinary HTTP client](../src/albedo/harness/sdk/http.gleam) preserves response -headers for conditional catalog requests. Mixed-credential catalog reads do not -establish model-session affinity. +[ordinary HTTP client](../packages/albedo_sdk/src/albedo/harness/sdk/http.gleam) +preserves response headers for conditional catalog requests. Mixed-credential +catalog reads do not establish model-session affinity. The [GitHub Copilot catalog](../src/albedo/harness/extensions/github_copilot/catalog.gleam) diff --git a/robot-docs/network.md b/robot-docs/network.md index e24fd6569..bad796a0a 100644 --- a/robot-docs/network.md +++ b/robot-docs/network.md @@ -2,8 +2,8 @@ The `network` settings section sends outbound connections directly or through a named proxy, for everything or per service. -[`sdk/network`](../src/albedo/harness/sdk/network.gleam) declares the section, -parses its values, and resolves a service's route. +[`sdk/network`](../packages/albedo_sdk/src/albedo/harness/sdk/network.gleam) +declares the section, parses its values, and resolves a service's route. [`core_settings`](../src/albedo/daemon/core_settings.gleam) registers it beside the daemon's other sections, so `/config` lists it under Tools. This is separate from the inbound [OpenAI-compatible proxy](proxy.md). @@ -65,10 +65,10 @@ A route is the [`albedo_http`](workspace-packages.md) package's or a `Proxy` with its scheme, host, and port. `sdk/network` owns only the policy that picks one. The client never looks a route up; its caller passes one in. -[`network_context`](../src/albedo/harness/sdk/network_context.gleam) keeps the -route for the calling process. `routed(service, run)` resolves and runs under a -service's route; a spawned worker keeps its caller's route through `carried`, -which is also the `carry` a +[`network_context`](../packages/albedo_sdk/src/albedo/harness/sdk/network_context.gleam) +keeps the route for the calling process. `routed(service, run)` resolves and +runs under a service's route; a spawned worker keeps its caller's route through +`carried`, which is also the `carry` a [parallel map](../packages/albedo_process/src/albedo_process/parallel.gleam) takes in `map_carrying`. `connection_options()` turns the current route, with albedo's trusted roots, into the options a connection opens with. The roots are @@ -76,9 +76,9 @@ the host's: core's [trust policy](../src/albedo/harness/trust.gleam) keeps the OS store without the roots albedo blocks, and the host lends them through [host resources](runtime.md#host-resources), which `connection_options` reads each time a connection opens; -[`sdk/http`](../src/albedo/harness/sdk/http.gleam), MCP's HTTP transport, and -Codex image generation pass it. `transport()` adds the provider budget cap to -those options for the stream pump +[`sdk/http`](../packages/albedo_sdk/src/albedo/harness/sdk/http.gleam), MCP's +HTTP transport, and Codex image generation pass it. `transport()` adds the +provider budget cap to those options for the stream pump [`albedo_model_stream/http`](../packages/albedo_model_stream/src/albedo_model_stream/http.gleam), which takes them as an argument and reads no route itself. Build either in the process that sends, since a route belongs to the calling process. `sdk/http` @@ -89,10 +89,11 @@ streaming client, and verifies HTTPS against those roots either way. Do not set process-wide proxy environment variables or the global `httpc` proxy to route one service. -[`extension`](../src/albedo/harness/sdk/extension.gleam) routes model provider -requests, streams, catalogs, and search by extension id. [Quota](quota.md) and -[`oauth_flows`](../src/albedo/harness/sdk/oauth_flows.gleam) route polls and -sign-in exchanges the same way. The client's +[`extension`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +routes model provider requests, streams, catalogs, and search by extension id. +[Quota](quota.md) and +[`oauth_flows`](../packages/albedo_sdk/src/albedo/harness/sdk/oauth_flows.gleam) +route polls and sign-in exchanges the same way. The client's [connection coordinator](../packages/albedo_http/src/albedo_http/connect.gleam) negotiates the tunnel before destination TLS, and pool keys distinguish routes. The Discord helper and Colab's SSH bridge get the route as diff --git a/robot-docs/plugins.md b/robot-docs/plugins.md index 5edf22194..80bfe3f96 100644 --- a/robot-docs/plugins.md +++ b/robot-docs/plugins.md @@ -2,8 +2,8 @@ Plugins are contributions declared by an [extension](extensions.md), not independently installed packages. -[`Plugin`](../src/albedo/harness/sdk/extension.gleam) defines the host -contracts. See the +[`Plugin`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +defines the host contracts. See the [SDK helper contracts](extensions.md#sdk-imports-and-native-bindings) for HTTP, subprocesses, cache expiry, and background jobs. The [extension API reference](../docs/extension-api.md) provides function-level @@ -41,7 +41,7 @@ preparing extension gets them. `CommandPlugin` contributes session commands. `HookPlugin` contributes a static [hook](hooks.md), asked with the same `hook.Context` as a managed contribution's hook, so a hook that needs nothing prepared does not need a `ManagedPlugin`. See -[extension.gleam](../src/albedo/harness/sdk/extension.gleam). +[extension.gleam](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam). [`composition.gleam`](../src/albedo/harness/extension/composition.gleam) collects these contributions in registry order. Managed contributions can @@ -56,12 +56,12 @@ Resource monitoring remains the allocator's responsibility. ## Host route context -[`host.Context`](../src/albedo/harness/sdk/host.gleam) supplies the store, the -daemon's `inbox` and `letters`, session ID, workspace, and the loaded search, -worktree, and image generation providers to kernel host routes. Its `storage` is -the [storage handle](extensions.md#extension-storage) of the extension whose -route runs, bound to the calling session. The composition sets it for each -extension's routes, and replaces each +[`host.Context`](../packages/albedo_sdk/src/albedo/harness/sdk/host.gleam) +supplies the store, the daemon's `inbox` and `letters`, session ID, workspace, +and the loaded search, worktree, and image generation providers to kernel host +routes. Its `storage` is the [storage handle](extensions.md#extension-storage) +of the extension whose route runs, bound to the calling session. The composition +sets it for each extension's routes, and replaces each [capability](extensions.md#extension-capabilities) the extension does not declare in `uses` with a denying stand-in. Every field below except the session ID, workspace, `progress`, and `storage` is a capability. See @@ -78,7 +78,7 @@ call to the daemon a session moved to through session on another daemon that wrote to a caller, from the daemon's mail tables. Pass it to `family.locate` and `family.remote`. `control` is the daemon's session coordinator for the typed -[`sdk/session_control`](../src/albedo/harness/sdk/session_control.gleam) +[`sdk/session_control`](../packages/albedo_sdk/src/albedo/harness/sdk/session_control.gleam) functions. See [agents](agent-sessions.md). [`kernels.kernel_routes`](../src/albedo/harness/runtime/kernels.gleam) builds it from the same loaded `Cached` snapshot as the route composition. Reloads replace @@ -94,11 +94,11 @@ and the process working directory can differ from it. ## Image generation drivers `ImagegenPlugin` contributes a named -[`imagegen.Provider`](../src/albedo/harness/sdk/imagegen.gleam). Its `generate` -callback receives validated reference images and the session, profile, and call -identities. It returns encoded image data and optional request and generation -identifiers. The shared [image generation extension](imagegen.md) owns driver -selection and admission; Python owns local publication. +[`imagegen.Provider`](../packages/albedo_sdk/src/albedo/harness/sdk/imagegen.gleam). +Its `generate` callback receives validated reference images and the session, +profile, and call identities. It returns encoded image data and optional request +and generation identifiers. The shared [image generation extension](imagegen.md) +owns driver selection and admission; Python owns local publication. Run the request once. Do not retry an uncertain outcome or fall back to another service. The callback runs in a cancellable worker, so keep sockets there and @@ -106,7 +106,7 @@ ensure any resource-owning child terminates when that worker dies. ## Owned worker helper -[`worker.observer(owner, run, observed, wait_ms)`](../src/albedo/harness/sdk/worker.gleam) +[`worker.observer(owner, run, observed, wait_ms)`](../packages/albedo_sdk/src/albedo/harness/sdk/worker.gleam) starts an owned worker with `worker.start` and returns its opaque `extension.Owned` contribution. The contribution starts from `extension.empty()`. Its `observe` sends `observed(handle, event)` to the worker @@ -139,19 +139,20 @@ named after a settings section that the daemon passes as reserved, which It contributes nothing to a session. The host grants the extension's storage handle that owner, as [extension storage](extensions.md#public-features-own-their-tables) describes. -See [extension.gleam](../src/albedo/harness/sdk/extension.gleam). The kernel's -own tables, startup reconciliation, and session cleanup are not plugins. The -[runtime owns them](kernel.md#ownership). +See +[extension.gleam](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam). +The kernel's own tables, startup reconciliation, and session cleanup are not +plugins. The [runtime owns them](kernel.md#ownership). `FollowPlugin` keeps an extension's rows in step with core changes that its rows depend on. Its callback receives a -[`follow.Change`](../src/albedo/harness/sdk/follow.gleam) and the connection of -the transaction that makes the change. An error rolls that change back. Every -declared extension's follower runs in registry order, enabled for the session or -not, and quarantined or not. A quarantined extension's tables can still hold -rows that must follow the change. Skip when your tables do not exist, and ignore -the changes your extension keeps nothing for. Core reads the list with -`runtime.followers`. +[`follow.Change`](../packages/albedo_sdk/src/albedo/harness/sdk/follow.gleam) +and the connection of the transaction that makes the change. An error rolls that +change back. Every declared extension's follower runs in registry order, enabled +for the session or not, and quarantined or not. A quarantined extension's tables +can still hold rows that must follow the change. Skip when your tables do not +exist, and ignore the changes your extension keeps nothing for. Core reads the +list with `runtime.followers`. - `Forked` follows a fork or a rewind's archive copy, after the prefix is copied. See [`history.fork_in`](../src/albedo/daemon/history.gleam). @@ -167,11 +168,11 @@ worktree removal for the work ledger. `SchedulePlugin` contributes a `due` callback, given the extension's storage handle, that returns the scheduled prompts due at a given time as -[`extension.Due`](../src/albedo/harness/sdk/extension.gleam) values. The -registry's dispatcher calls every declared extension's callback on its tick, -quarantined ones included, and posts each prompt. The extension owns the timing -and repetition. Each `Due` carries an `advance` callback that runs in the -posting transaction and returns False when another tick already advanced the +[`extension.Due`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +values. The registry's dispatcher calls every declared extension's callback on +its tick, quarantined ones included, and posts each prompt. The extension owns +the timing and repetition. Each `Due` carries an `advance` callback that runs in +the posting transaction and returns False when another tick already advanced the occurrence. See [inbox rows](inbox.md#rows). Startup callbacks run after the schema transaction commits. The host does not @@ -187,18 +188,18 @@ reads declared ones. Do not find a started process through a registered name or another process-wide lookup. The callback returns -[`extension.Started`](../src/albedo/harness/sdk/extension.gleam) values. -`StartedTool`, `StartedCommand`, `StartedManaged`, `StartedOwnedManaged`, -`StartedService`, and `StartedTransfer` carry the payloads of `ToolPlugin`, -`CommandPlugin`, `ManagedPlugin`, `OwnedManagedPlugin`, `ServicePlugin`, and -`TransferPlugin`, and install converts each to that plugin. The host reads every -other kind before startup or from the declarations, so the type has no variant -for them and the compiler rejects returning one. Install checks the default -selection again after startup, so a returned tool, command, route, or Python -module that clashes quarantines its extension. Declarations that need no started -resource stay in the static plugin list. The -[Discord extension](discord.md#bot-process) returns its routes, service, and -transfer adapter this way. The +[`extension.Started`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +values. `StartedTool`, `StartedCommand`, `StartedManaged`, +`StartedOwnedManaged`, `StartedService`, and `StartedTransfer` carry the +payloads of `ToolPlugin`, `CommandPlugin`, `ManagedPlugin`, +`OwnedManagedPlugin`, `ServicePlugin`, and `TransferPlugin`, and install +converts each to that plugin. The host reads every other kind before startup or +from the declarations, so the type has no variant for them and the compiler +rejects returning one. Install checks the default selection again after startup, +so a returned tool, command, route, or Python module that clashes quarantines +its extension. Declarations that need no started resource stay in the static +plugin list. The [Discord extension](discord.md#bot-process) returns its routes, +service, and transfer adapter this way. The [image generation extension](imagegen.md#cancellation-and-recovery) returns the prepared contribution whose routes reach its call admission. @@ -210,13 +211,13 @@ polled for quota. Do not import a provider extension from core to reach the same behavior. - `QuotaPlugin` contributes a - [`usage_feed.Source`](../src/albedo/harness/sdk/usage_feed.gleam). `accounts` - lists the extension's sign-in accounts as `Target` values. `profile` maps a - saved profile that names the extension to one `Target`, or `Error(Nil)`. Both - receive the runtime's key environment for key account reads. `heal` runs after - every report the feed returns for one of the source's targets. Use - `accounts_source` for a source with only sign-in accounts, and `key_target` - for an API key. See [quota](quota.md#accounts). + [`usage_feed.Source`](../packages/albedo_sdk/src/albedo/harness/sdk/usage_feed.gleam). + `accounts` lists the extension's sign-in accounts as `Target` values. + `profile` maps a saved profile that names the extension to one `Target`, or + `Error(Nil)`. Both receive the runtime's key environment for key account + reads. `heal` runs after every report the feed returns for one of the source's + targets. Use `accounts_source` for a source with only sign-in accounts, and + `key_target` for an API key. See [quota](quota.md#accounts). - `ProfileModelPlugin` contributes a `ProfileModel` for saved profiles that name the extension. `efforts(home, profile, model)` replaces the catalog's effort list when it answers `Some`. `replay(profile, model, inputs)` refuses a model @@ -230,15 +231,17 @@ behavior. argument instead of reading shared state. See [typed key accounts](auth.md#typed-key-accounts). -Helpers in [extension.gleam](../src/albedo/harness/sdk/extension.gleam) collect -them: `quota_sources`, `profile_model`, and `key_environment`. +Helpers in +[extension.gleam](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +collect them: `quota_sources`, `profile_model`, and `key_environment`. ## Persisted extension settings -Use [`settings.Section`](../src/albedo/harness/sdk/settings.gleam) for a typed -section decoder and validation. `settings.update(section, encode, change)` -performs a locked read-modify-write of that section without extension-owned -native code. Follow the +Use +[`settings.Section`](../packages/albedo_sdk/src/albedo/harness/sdk/settings.gleam) +for a typed section decoder and validation. +`settings.update(section, encode, change)` performs a locked read-modify-write +of that section without extension-owned native code. Follow the [typed update contract](settings.md#typed-extension-updates) for encoder overlays, pure callbacks, defaults, and failure behavior. Credentials and multi-document mutations retain specialized owners. @@ -246,13 +249,14 @@ multi-document mutations retain specialized owners. ## MCP settings and editor probes `McpServersPlugin` supplies an -[`McpServers`](../src/albedo/harness/sdk/extension.gleam) record for the -daemon's `mcp` settings group and for ACP overlays. `names` lists configured -server names. `validate` checks one server's saved definition and secrets -without resolving environment references or starting anything. `check` starts an -enabled server once and closes it. `signed_out` drops the tokens from a saved -OAuth record. `EditorMcpPlugin` contributes `probe`, which starts an editor's -candidate servers once and returns their catalogues without publishing them. +[`McpServers`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +record for the daemon's `mcp` settings group and for ACP overlays. `names` lists +configured server names. `validate` checks one server's saved definition and +secrets without resolving environment references or starting anything. `check` +starts an enabled server once and closes it. `signed_out` drops the tokens from +a saved OAuth record. `EditorMcpPlugin` contributes `probe`, which starts an +editor's candidate servers once and returns their catalogues without publishing +them. The daemon looks these up with `extension.mcp_servers` and `extension.editor_mcp_probe` over the installed extensions, so a disabled MCP @@ -283,18 +287,18 @@ port. Every `Daemon` field except `home` and `storage` is a each one the serving extension does not declare in `uses` with a denying stand-in. -[`service.json(body_limit, handle)`](../src/albedo/harness/sdk/service.gleam) +[`service.json(body_limit, handle)`](../packages/albedo_sdk/src/albedo/harness/sdk/service.gleam) supplies daemon-token authentication and a fixed body limit. Its handler receives the daemon, path segments below the mount, and a buffered `Request(BitArray)`. It returns a response or `http_api.Failure`. The adapter renders failures as problem responses and rejects negotiation that selects an event stream with `406 not_acceptable`. -[`sdk/http_api`](../src/albedo/harness/sdk/http_api.gleam) owns the HTTP -contract that extension services share with the daemon. It defines `Failure`, -problem and bounded JSON replies, strict body and query decoding, `Accept` -negotiation, preconditions, revision validators, and paging tokens. It ranks -Accept headers with +[`sdk/http_api`](../packages/albedo_sdk/src/albedo/harness/sdk/http_api.gleam) +owns the HTTP contract that extension services share with the daemon. It defines +`Failure`, problem and bounded JSON replies, strict body and query decoding, +`Accept` negotiation, preconditions, revision validators, and paging tokens. It +ranks Accept headers with [`albedo_web/accept`](../packages/albedo_web/src/albedo_web/accept.gleam); a content validator is `albedo_web/etag.strong`, and a timestamp `albedo_clock.format_rfc3339`. The daemon's @@ -305,11 +309,12 @@ codes. Extensions import the SDK module, never the daemon adapter. Route dispatch, query and body decoding, and domain error mapping remain extension-owned. Services that stream, serve non-JSON content, or need different admission policies use -[`extension.Service`](../src/albedo/harness/sdk/extension.gleam) directly. See +[`extension.Service`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam) +directly. See [Expose a JSON service](../docs/extensions.md#expose-a-json-service) for registration steps. -[`http_api.resource(url, etag, value)`](../src/albedo/harness/sdk/http_api.gleam) +[`http_api.resource(url, etag, value)`](../packages/albedo_sdk/src/albedo/harness/sdk/http_api.gleam) encodes resource envelopes. `revision_etag(namespace, id, revision)` formats integer-ID validators, and `notification(status)` encodes `NotRequested`, `Queued`, or `Failed(detail)`. Callers retain URL and payload selection, @@ -318,17 +323,18 @@ precondition checks. ## Client declarations -[`client_api`](../src/albedo/harness/sdk/client_api.gleam) owns typed field -kinds, declarative request bindings, and resource pages. `ClientPlugin` commands -are validated during installation, before the extension initializer runs. A -malformed command quarantines its extension with the command and field in the -error. Installation behavior is owned by -[`extension.install`](../src/albedo/harness/sdk/extension.gleam). After -preparation, [composition](../src/albedo/harness/extension/composition.gleam) -requires each client binding to name a command contributed by the same -extension. A missing command makes that extension inactive for the session, -closes its prepared contributions, and reports the extension and command names. -Commands prepared by managed plugins are checked at this stage. +[`client_api`](../packages/albedo_sdk/src/albedo/harness/sdk/client_api.gleam) +owns typed field kinds, declarative request bindings, and resource pages. +`ClientPlugin` commands are validated during installation, before the extension +initializer runs. A malformed command quarantines its extension with the command +and field in the error. Installation behavior is owned by +[`extension.install`](../packages/albedo_sdk/src/albedo/harness/sdk/extension.gleam). +After preparation, +[composition](../src/albedo/harness/extension/composition.gleam) requires each +client binding to name a command contributed by the same extension. A missing +command makes that extension inactive for the session, closes its prepared +contributions, and reports the extension and command names. Commands prepared by +managed plugins are checked at this stage. Build page actions with `client_api.actions`, which returns validated `Actions` or an error naming the action. `Page` requires this validated value. JSON diff --git a/robot-docs/provider-requests.md b/robot-docs/provider-requests.md index 1802d0f2a..4ebe6fb6f 100644 --- a/robot-docs/provider-requests.md +++ b/robot-docs/provider-requests.md @@ -3,9 +3,9 @@ The daemon records provider attempts separately from the conversation transcript. [`requests.gleam`](../src/albedo/daemon/requests.gleam) owns the row schema, prefix hashing, recording, and queries. -[`sdk/request_history`](../src/albedo/harness/sdk/request_history.gleam) owns -the `Prefix` value type and the selection of a session's latest completed turn. -These records support usage and cache analysis. They do not store request +[`sdk/request_history`](../packages/albedo_sdk/src/albedo/harness/sdk/request_history.gleam) +owns the `Prefix` value type and the selection of a session's latest completed +turn. These records support usage and cache analysis. They do not store request bodies. ## What a row holds @@ -62,12 +62,12 @@ billing. `Upstream.count` is a provider's own count of the input tokens a request would take, asked of its count endpoint, or `None` for a route that has none. Nothing estimates a count in its place. -[`sdk/token_count`](../src/albedo/harness/sdk/token_count.gleam) posts the body -the provider extension encoded and reads the number at the path its `Endpoint` -names; a refusal comes back as the provider's own error. An endpoint says what a -refusal means: `NotFound` marks the route absent for a day on a 404 or 405, and -`AnyRefusal` does on any refusal, for a credential the endpoint is not -documented to take. The two are remembered apart. +[`sdk/token_count`](../packages/albedo_sdk/src/albedo/harness/sdk/token_count.gleam) +posts the body the provider extension encoded and reads the number at the path +its `Endpoint` names; a refusal comes back as the provider's own error. An +endpoint says what a refusal means: `NotFound` marks the route absent for a day +on a 404 or 405, and `AnyRefusal` does on any refusal, for a credential the +endpoint is not documented to take. The two are remembered apart. OpenAI profiles that speak Responses ask `/responses/input_tokens`, and Mistral asks the same path with its history bridged to Responses items. Anthropic API @@ -98,7 +98,7 @@ client header values before transport. The pump in the [`albedo_model_stream/http`](../packages/albedo_model_stream/src/albedo_model_stream/http.gleam), handles streaming exchanges over the `Transport` its caller passes: the connection options and a cap every budget is held to. -[`network_context.transport`](../src/albedo/harness/sdk/network_context.gleam) +[`network_context.transport`](../packages/albedo_sdk/src/albedo/harness/sdk/network_context.gleam) builds it in the sending process, with the cap `ALBEDO_PROVIDER_TIMEOUT_MS` sets when that is set. Every provider wire passes `network_context.transport()` where it calls `albedo_openai.exchange`, `http.exchange`, or `http.with_body`. The @@ -111,7 +111,7 @@ A caller opens a connection with `albedo_http.Options`: the route, the trusted roots, and an optional admission check. The client reads no settings, environment, or process state of its own. Provider requests and other albedo traffic take -[`network_context.connection_options`](../src/albedo/harness/sdk/network_context.gleam), +[`network_context.connection_options`](../packages/albedo_sdk/src/albedo/harness/sdk/network_context.gleam), directly or inside its `transport`, the calling process's [outbound route](network.md) with the roots albedo's [trust policy](../src/albedo/harness/trust.gleam) keeps, which the host lends diff --git a/robot-docs/runtime.md b/robot-docs/runtime.md index 69207a4f6..560a2368b 100644 --- a/robot-docs/runtime.md +++ b/robot-docs/runtime.md @@ -215,8 +215,8 @@ restores the previous scale when it is done. Clock readings are never scaled. ## Host resources -[`sdk/host_resources`](../src/albedo/harness/sdk/host_resources.gleam) holds -what the host lends the SDK outside any session: `assets`, albedo's priv +[`sdk/host_resources`](../packages/albedo_sdk/src/albedo/harness/sdk/host_resources.gleam) +holds what the host lends the SDK outside any session: `assets`, albedo's priv directory, two launch policies for Python scripts, and `trusted_roots`, the CA roots albedo's TLS clients verify against. `open_python` starts `assets/python/