@feynmanzhang/open-party 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3994,9 +3994,15 @@ agentRoutes.post("/heartbeat", async (c) => {
3994
3994
  agentRoutes.get("/list", async (c) => {
3995
3995
  const { registry: registry2, discovery: discovery2 } = await Promise.resolve().then(() => (init_state(), state_exports));
3996
3996
  const localAgents = registry2.listAll();
3997
- const remoteAgents = discovery2.getReachableRemoteAgents();
3998
- const allAgents = localAgents.concat(remoteAgents);
3999
- return c.json({ agents: sanitizeAgentList(allAgents), count: allAgents.length });
3997
+ const remoteEntries = discovery2.getRemoteAgentEntries();
3998
+ const remoteAgents = remoteEntries.filter((e) => e.reachable).map((e) => ({ ...sanitizeAgentInfo(e.agentInfo), source_peer_ip: e.sourcePeerIp }));
3999
+ const allAgents = sanitizeAgentList(localAgents).concat(remoteAgents);
4000
+ return c.json({
4001
+ agents: allAgents,
4002
+ count: allAgents.length,
4003
+ local_count: localAgents.length,
4004
+ remote_count: remoteAgents.length
4005
+ });
4000
4006
  });
4001
4007
  agentRoutes.post("/send", async (c) => {
4002
4008
  const { registry: registry2, messageQueue: messageQueue2, discovery: discovery2 } = await Promise.resolve().then(() => (init_state(), state_exports));
@@ -4082,6 +4088,11 @@ proxyRoutes.get("/list_agents", async (c) => {
4082
4088
  const agents = registry.listAll();
4083
4089
  return c.json({ agents, count: agents.length });
4084
4090
  });
4091
+ proxyRoutes.get("/peers", async (c) => {
4092
+ const { discovery: discovery2 } = await Promise.resolve().then(() => (init_state(), state_exports));
4093
+ const peerStates = discovery2.getPeerStates();
4094
+ return c.json({ peers: peerStates, total: peerStates.length });
4095
+ });
4085
4096
  proxyRoutes.post("/receive", async (c) => {
4086
4097
  const envelope = await c.req.json();
4087
4098
  const stamped = { ...envelope, timestamp: envelope.timestamp ?? Date.now() / 1e3 };