HubMessagingRepository class final

The DAP/1 hub as a MessagingRepository.

Implemented types

Constructors

HubMessagingRepository({required Uri url, required HubTransport transport, HubIdentity? identity, String? name, String? token, Duration backoff(int attempt) = defaultHubBackoff, void onLog(String message)?})
Builds a repository for the hub at url. identity defaults to a fresh one — hosts that need a stable address persist the seeds and pass them back (see lib/io.dart). token is the pairing token for a protected hub (rides the upgrade as ?dap_token=, the browser-safe form). onLog receives soft diagnostics (decrypt failures, protocol errors) — never required.

Properties

agentId → String?
Our hub address (the identity-derived id), set after the first welcome. Null until then.
no setter
backoff → Duration Function(int attempt)
Reconnect backoff schedule (injectable: tests shrink it).
final
busy ↔ bool
True while the owner reported a run in progress (touch) — local presence knowledge; mail is accepted either way (steering semantics).
getter/setter pair
capabilities ↔ List<AgentCapability>
The capabilities announced by register (surfaced on our own directory entry until the hub wire carries them for peers).
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
isConnected → bool
Whether the live transport is currently usable. A false answer routes everything to the fallback.
no setteroverride
name ↔ String?
The roster display name published by the signed hello — the session name (register refreshes it).
getter/setter pair
onLog ↔ void Function(String message)?
Soft diagnostics sink (null = drop).
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
state → HubLinkState
The current link state (UI surface).
no setter
stateChanges → Stream<HubLinkState>
Fires on every link-state transition.
no setter
token → String?
The pairing token for a protected hub (write-only: never echoed).
final

Methods

directory() → Future<List<MailboxEntry>>
The known mailboxes in the fabric, with optional cwd metadata. The FULL set (live and stale alike) — live/dead filtering is a display policy above this layer, not a repository concern.
override
dispose() → Future<void>
Permanent shutdown (the host is going away).
drain(String agent) → Future<List<AgentMessage>>
The unread messages for agentId, oldest first, consumed (marked read). A drained message never appears again.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
peek(String agent) → Future<List<AgentMessage>>
The unread messages for agentId, oldest first, without consuming them.
override
register(String agentId, {String? sessionName, List<AgentCapability> capabilities = const []}) → Future<void>
Announces agentId's mailbox in the directory (presence): an agent with no mail yet is still discoverable. sessionName, when non-empty, publishes the session's display name so peers can address this mailbox by name (goal_builder instead of sess1/main). capabilities publishes the host's discovery metadata (fabric.enable(name, capabilities) — see AgentCapability); an empty list clears any previously announced set. Called by hosts on session start/switch.
override
resolveTarget(String toId) → Future<String?>
The canonical target id for toId on this transport, or null when toId is not deliverable here (unknown recipient, transport down).
override
send(AgentMessage message) → Future<void>
Delivers message to the recipient's inbox. Implementations must assign/keep a unique AgentMessage.id and never lose a message silently (a failed delivery throws).
override
start() → Future<void>
Starts the connect loop: dials, handshakes, reconnects with backoff. Idempotent.
stop() → Future<void>
Stops the loop and closes the socket cleanly (the iOS background path: suspend → stop, foreground → start — reconnect + flush).
toString() → String
A string representation of this object.
inherited
touch(String agentId, {bool busy = false}) → Future<void>
Refreshes agentId's liveness marker (a heartbeat): hosts call this periodically while the agent runs so directory consumers can tell live mailboxes from abandoned ones WITHOUT any pending mail. busy reports an agent run in progress (mail still accepted — steering semantics); a fresh busy beats the liveness heuristics in directory views. Best-effort by contract — a failing backend never breaks the caller's loop.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited