MeshAgentProviderAdapter in @monad/sdk-atom. Register it
through AtomPackContext.registerAgentAdapter.
Event-source contract
events.projectLive is the only required event-source member. Incremental projection
and provider history are optional:
events into wire-level convenience frames.
Provider history
The daemon supplies this context when the provider has an established session identity:workingPath and providerSessionRef.
Provider-specific APIs, files, commands, cursors, and protocol vocabulary remain inside
the adapter; the daemon never lends its live session handle to history readers.
MeshAgentEventPageRequest.limit is the page capacity in complete provider records, not
a byte budget. File-backed adapters must not cut a JSONL record at a byte boundary, and
their before cursor must remain stable if the provider appends new records.
unavailable when the capability exists but cannot provide the requested page.
Do not manufacture an empty authoritative page for a temporary provider failure.
Raw provider pages use adapter-native records and cursors. coverage: 'exact' means the
source is authoritative for those records; settled means it omits transient live
deltas. The daemon wraps adapter cursors in the wire-level provider: namespace, so the
adapter receives and returns only its own opaque token.
Projection rules
- Capture accepted live data before parsing, projection, merging, or deduplication.
- Preserve raw provider records byte-for-byte or value-for-value.
- Project deterministic
MeshAgentObservationEventvalues with non-empty raw provenance. - Give stable provider entities stable event identities across live and historical reads.
- Preserve meaningful unknown records as shared diagnostic envelopes.
- Keep raw acquisition available if convenience projection fails.
- Never emit UI components, labels, cards, or view state from an adapter.
createLiveProjector is useful when reparsing the full prefix on every delta would be
expensive. Its incremental output must be equivalent to projectLive over the same
complete input.
Session runtime and controls
Mesh session execution has one entry point:createSessionRuntime. It returns a
session-scoped driver and either a resident or per-turn plan. Both produce the same
normalized session-event stream; process lifetime, framing, and provider protocol names
remain internal implementation details.
Resident drivers implement attachChannel and sendTurn. Per-turn drivers implement
attachTurnChannel and completeTurn, and must resume through a stable
providerSessionRef. Controls are declared as effective driver capabilities:
approvalResolution, steer, and interrupt. Unsupported controls are false, not
optional methods that the daemon guesses from a provider or launch mode.
PTY is not a Mesh session runtime. Use it only for provider-owned authentication, setup,
or explicit diagnostics. A one-shot CLI qualifies only when it streams structured events
during the invocation and can resume the same provider session on the next turn.
The daemon resolves the executable, validates cwd and environment additions, owns the
channel resource, captures raw packets before decoding, bounds event ingestion, and
performs teardown. The daemon owns the allowAutopilot decision; the adapter owns
provider-specific unsafe arguments and must report capabilities truthfully.
When the provider protocol has request IDs, record the request kind when sending and
dispatch responses through that ledger. Do not infer response types from payload shape.
Authentication and usage
Provider authentication remains provider-owned. Implement the applicable adapter surfaces:- an interactive auth launch;
- an auth-status probe and parser;
- an optional usage probe and parser.
unknown rather than guessing
an authenticated state.
Authoring sequence
- Declare the provider ID, label, product icon, discovery probe, settings, and models.
- Implement a session-scoped structured event driver.
- Return a resident or resumable per-turn runtime from
createSessionRuntime. - Implement
events.projectLive. - Add
createLiveProjectoronly when incremental state is useful. - Add
events.readPagefor each supported raw or convenience view. - Verify live and earlier records converge on stable event identities.
- Add provider-owned authentication and usage probes where supported.
Contract tests
Use sanitized fixtures captured from real providers. Cover:- exact raw preservation;
- provider cursor progress, including an empty first-page token;
availableandunavailablepage results;exactandsettledcoverage;- exact projection shapes with raw provenance;
- full-prefix and incremental-projector equivalence;
- stable identity across live and historical reads;
- unknown-record behavior;
- raw delivery when projection fails;
- provider request-ID correlation inside the session driver;
- identical externally observable behavior over daemon TCP and Unix transports.
@monad/atoms. Wire schemas remain in
@monad/protocol; do not redeclare them in the adapter package.