Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/core/agent-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

import { CommsError } from "./store.js";
import type { DeliveryEngine } from "./delivery-engine.js";
import type { FederationManager } from "./federation.js";
import type { MeshTransport } from "./transport.js";
import type { AgentSelfAdvert } from "./wire-mesh-transport.js";
import { AgentStatus } from "./types.js";
import type { AgentIdentity, Visibility } from "./types.js";

/** The state and collaborators AgentRegistry needs from MeshStore. agents/identityCache are direct references into MeshStore's own fields; startedAt is a readonly value copied once; deliveryEngine and federation are the already-constructed instances, narrowed to what agent-lifecycle bookkeeping ever needs. */
/** The state and collaborators AgentRegistry needs from MeshStore. agents/identityCache are direct references into MeshStore's own fields; startedAt is a readonly value copied once; deliveryEngine is the already-constructed instance, narrowed to what agent-lifecycle bookkeeping ever needs. */
export interface AgentRegistryDeps {
agents: Map<string, AgentIdentity>;
identityCache: Map<string, { id: string }>;
Expand All @@ -24,10 +23,6 @@ export interface AgentRegistryDeps {
| "notifyRoomsOfStatus"
| "notifyRoomsOfNameChange"
>;
federation: Pick<
FederationManager,
"broadcastAgentVisible" | "broadcastAgentGone"
>;
}

/** Narrows an untrusted gossiped value (WireMeshTransport.listKnownDevices' own advert["agent/self"], self-asserted by whichever peer advertised it) into an AgentSelfAdvert -- a malformed or non-conforming entry is silently skipped rather than treated as an error, the same convention room-lifecycle.ts's own isHostedRoomAdvert already established for the identical class of gossip consumption. */
Expand Down Expand Up @@ -109,10 +104,6 @@ export class AgentRegistry {
type: "agent_upsert",
agent,
});
// Broadcast presence to federated links
if (agent.visibility === "visible") {
await this.deps.federation.broadcastAgentVisible(agent);
}
return agent;
}

Expand Down Expand Up @@ -227,7 +218,6 @@ export class AgentRegistry {
type: "agent_offline",
agentId: id,
});
await this.deps.federation.broadcastAgentGone(id);
}
}
}
22 changes: 0 additions & 22 deletions src/core/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ export const MCP_TOOL_PARAMS = z.object({
"mesh_listeners",
"mesh_set_visibility",
"mesh_get_visibility",
"mesh_fed_connect",
"mesh_fed_disconnect",
"mesh_fed_links",
]),
name: z.string().optional(),
visibility: VisibilityEnum.optional(),
Expand Down Expand Up @@ -346,25 +343,6 @@ export function buildAction(params: Record<string, unknown>): CommsAction {
};
return result;
}
case "mesh_fed_connect": {
if (p.host === undefined)
throw new BuildActionError("mesh_fed_connect", "host");
if (p.port === undefined)
throw new BuildActionError("mesh_fed_connect", "port");
const result: CommsAction & { action: "mesh_fed_connect" } = {
action: "mesh_fed_connect",
host: p.host,
port: p.port,
};
if (p.name !== undefined) result.name = p.name;
return result;
}
case "mesh_fed_disconnect":
if (p.id === undefined)
throw new BuildActionError("mesh_fed_disconnect", "id");
return { action: "mesh_fed_disconnect", linkId: p.id };
case "mesh_fed_links":
return { action: "mesh_fed_links" };
default:
return p.action satisfies never;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/comms-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Bridges depend on this interface, not on a specific implementation.
*
* Deliberately excludes listener management, federation, and connection approval: those are transport concerns MeshStore alone can support -- FileStore has no network transport to manage listeners on, federate through, or approve inbound connections for. Widening this interface to cover them (as it once did, via always-throwing FileStore stubs) is what forced server.ts and the bridge controller to reach past CommsStore into the concrete MeshStore anyway; CommsTool, the one consumer that genuinely needs to expose these when a MeshStore backs it, takes them as an optional extension (see MeshOnlyFeatures in tool.ts) rather than the shared interface pretending every implementation supports them.
* Deliberately excludes listener management and connection approval: those are transport concerns MeshStore alone can support -- FileStore has no network transport to manage listeners on or approve inbound connections for. Widening this interface to cover them (as it once did, via always-throwing FileStore stubs) is what forced server.ts and the bridge controller to reach past CommsStore into the concrete MeshStore anyway; CommsTool, the one consumer that genuinely needs to expose these when a MeshStore backs it, takes them as an optional extension (see MeshOnlyFeatures in tool.ts) rather than the shared interface pretending every implementation supports them.
*/

import type {
Expand Down
19 changes: 1 addition & 18 deletions src/core/delivery-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface DeliveryEngineDeps {
((patch: MeshStatePatch) => void | Promise<void>) | undefined;
isShutDown: () => boolean;
/**
* Sends one directed room-domain request to a single member, queuing it for retry when unreachable -- RoomProtocol's own method. Deferred: RoomProtocol doesn't exist yet when DeliveryEngine is constructed (construction order: discovery -\> deliveryEngine -\> ... -\> roomProtocol), so MeshStore wires this as `(...) => this.roomProtocol.sendRoomRequestToMember(...)`, a closure over `this` that only resolves `this.roomProtocol` when markRead actually calls it at runtime, well after the constructor has finished -- the same lazy-`this`-capture pattern the constructor already uses to wire FederationManager's own callbacks before `this.federation` exists.
* Sends one directed room-domain request to a single member, queuing it for retry when unreachable -- RoomProtocol's own method. Deferred: RoomProtocol doesn't exist yet when DeliveryEngine is constructed (construction order: discovery -\> deliveryEngine -\> ... -\> roomProtocol), so MeshStore wires this as `(...) => this.roomProtocol.sendRoomRequestToMember(...)`, a closure over `this` that only resolves `this.roomProtocol` when markRead actually calls it at runtime, well after the constructor has finished.
*/
sendRoomRequestToMember: (
memberId: string,
Expand Down Expand Up @@ -110,8 +110,6 @@ export class DeliveryEngine {
existing.owner = incoming.owner;
existing.createdAt = incoming.createdAt;
existing.description = incoming.description;
if (incoming.federated !== undefined)
existing.federated = incoming.federated;
existing.memberJoins = DeliveryEngine.mergeMemberOps(
existing.memberJoins,
incoming.memberJoins,
Expand Down Expand Up @@ -467,21 +465,6 @@ export class DeliveryEngine {
}
}

/**
* Delivers a room message to one specific member -- the local-fanout half of a federated room message (federation-bridge.ts's own onRoomMessage), which has no handleRoomSend manage-response of its own to carry delivery, since the message arrives over a federation link rather than a live room.send. Emits the "delivered" receipt back to the message's own sender the same way deliverLocallyAndBroadcast used to, then delivers to the member via deliverToMember (locally for this store's own agent, or a directed room.notify otherwise).
*/
async deliverRoomMessageToMember(
roomId: string,
memberId: string,
message: RoomMessage,
): Promise<void> {
await this.emitDeliveryStatus(message.id, memberId, "delivered", roomId);
await this.deliverToMember(memberId, roomId, {
type: "room_message",
message,
});
}

async notifyRoomsOfStatus(
agentId: string,
status: AgentStatus,
Expand Down
151 changes: 0 additions & 151 deletions src/core/federation-bridge.ts

This file was deleted.

Loading