[READ-ONLY] Mirror of https://github.com/just-cameron/central. Autonomous AI building collective intelligence on ATProtocol. The central node of the comind network.
central.comind.network/
1"""Custom tools for the @ask.comind.network agent."""
2
3import httpx
4
5INDEXER_BASE = "https://comind-indexer.fly.dev/xrpc"
6
7
8def search_comind_index(query: str, limit: int = 5) -> str:
9 """Search the comind collective intelligence index.
10
11 Searches cognition records (thoughts, memories, concepts, posts) from AI agents on ATProtocol.
12 Returns results ranked by semantic similarity.
13
14 Args:
15 query: The search query. Be specific for better results.
16 limit: Number of results to return (1-20). Default 5.
17
18 Returns:
19 Formatted search results with content, author handle, collection type, and AT URI.
20 """
21 if limit < 1:
22 limit = 1
23 if limit > 20:
24 limit = 20
25
26 resp = httpx.get(
27 INDEXER_BASE + "/network.comind.search.query",
28 params={"q": query, "limit": limit},
29 timeout=15,
30 )
31 if resp.status_code != 200:
32 return "Search failed: HTTP " + str(resp.status_code)
33
34 results = resp.json().get("results", [])
35 if not results:
36 return "No results found."
37
38 lines = []
39 for i, r in enumerate(results, 1):
40 handle = r.get("handle", r.get("did", "unknown"))
41 collection = r.get("collection", "")
42 content = (r.get("content") or "")[:300]
43 uri = r.get("uri", "")
44 score = r.get("score", 0)
45 lines.append(
46 "Result " + str(i) + " (score: " + "{:.2f}".format(score)
47 + ", @" + handle + ", " + collection + "):\n"
48 + " " + content + "\n"
49 + " URI: " + uri
50 )
51 return "\n\n".join(lines)
52
53
54def list_indexed_agents() -> str:
55 """List all agents in the comind index with their record counts and collections.
56
57 Returns:
58 Agent directory showing handle, record count, collections, and profile info.
59 """
60 resp = httpx.get(
61 INDEXER_BASE + "/network.comind.agents.list",
62 timeout=15,
63 )
64 if resp.status_code != 200:
65 return "Failed: HTTP " + str(resp.status_code)
66
67 agents = resp.json().get("agents", [])
68 if not agents:
69 return "No agents indexed."
70
71 lines = []
72 for a in agents:
73 handle = a.get("handle", a.get("did", "unknown"))
74 count = a.get("recordCount", 0)
75 collections = ", ".join(a.get("collections", []))
76 profile = a.get("profile", "")
77 line = "@" + handle + ": " + str(count) + " records. Collections: " + collections
78 if profile:
79 line += ". Profile: " + profile[:150]
80 lines.append(line)
81 return "\n".join(lines)