@@ -6,13 +6,6 @@ import (
66 "fmt"
77 )
88
9-// MysisInfo represents mysis information returned by the orchestrator.
10-type MysisInfo struct {
11- ID string
12- Name string
13- LastError error
14-}
15-
169 // SearchResult represents a search result from memory.
1710 type SearchResult struct {
1811 Role string
@@ -29,22 +22,9 @@ type ReasoningResult struct {
2922 CreatedAt string
3023 }
3124
32-// BroadcastResult represents a broadcast search result.
33-type BroadcastResult struct {
34- Content string
35- CreatedAt string
36-}
37-
38-// AccountInfo represents account credential information.
39-type AccountInfo struct {
40- Username string
41- Password string
42-}
43-
4425 // Orchestrator defines the interface for swarm orchestration.
4526 // This interface breaks the import cycle between mcp and core packages.
4627 type Orchestrator interface {
47- ListMyses() []MysisInfo
4828 MysisCount() int
4929 MaxMyses() int
5030 GetStateCounts() map[string]int
@@ -53,112 +33,10 @@ type Orchestrator interface {
5333 BroadcastFrom(senderID, message string) error
5434 SearchMessages(mysisID, query string, limit int) ([]SearchResult, error)
5535 SearchReasoning(mysisID, query string, limit int) ([]ReasoningResult, error)
56- SearchBroadcasts(query string, limit int) ([]BroadcastResult, error)
57- ClaimAccount() (AccountInfo, error)
5836 }
5937
6038 // RegisterOrchestratorTools registers the internal orchestration tools with the proxy.
6139 func RegisterOrchestratorTools(proxy *Proxy, orchestrator Orchestrator) {
62- // List myses tool
63- proxy.RegisterTool(
64- Tool{
65- Name: "zoea_list_myses",
66- Description: "List all myses in the swarm with their current status",
67- InputSchema: json.RawMessage(`{"type": "object", "properties": {}}`),
68- },
69- func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
70- myses := orchestrator.ListMyses()
71- var result []map[string]interface{}
72- for _, m := range myses {
73- result = append(result, map[string]interface{}{
74- "id": m.ID,
75- "name": m.Name,
76- })
77- }
78-
79- data, _ := json.MarshalIndent(result, "", " ")
80- return &ToolResult{
81- Content: []ContentBlock{{Type: "text", Text: string(data)}},
82- }, nil
83- },
84- )
85-
86- // Send message to mysis tool
87- proxy.RegisterTool(
88- Tool{
89- Name: "zoea_send_message",
90- Description: "Send a message to a specific mysis",
91- InputSchema: json.RawMessage(`{
92- "type": "object",
93- "properties": {
94- "mysis_id": {"type": "string", "description": "The ID of the mysis"},
95- "message": {"type": "string", "description": "The message to send"}
96- },
97- "required": ["mysis_id", "message"]
98- }`),
99- },
100- func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
101- var params struct {
102- MysisID string `json:"mysis_id"`
103- Message string `json:"message"`
104- }
105- if err := json.Unmarshal(args, ¶ms); err != nil {
106- return &ToolResult{
107- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("invalid arguments: %v", err)}},
108- IsError: true,
109- }, nil
110- }
111-
112- if err := orchestrator.SendMessageAsync(params.MysisID, params.Message); err != nil {
113- return &ToolResult{
114- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("failed to send message: %v", err)}},
115- IsError: true,
116- }, nil
117- }
118-
119- return &ToolResult{
120- Content: []ContentBlock{{Type: "text", Text: "message queued for delivery"}},
121- }, nil
122- },
123- )
124-
125- // Broadcast message tool
126- proxy.RegisterToolWithContext(
127- Tool{
128- Name: "zoea_broadcast",
129- Description: "Send a message to all running myses (you will not receive your own broadcast)",
130- InputSchema: json.RawMessage(`{
131- "type": "object",
132- "properties": {
133- "message": {"type": "string", "description": "The message to broadcast"}
134- },
135- "required": ["message"]
136- }`),
137- },
138- func(ctx context.Context, caller CallerContext, args json.RawMessage) (*ToolResult, error) {
139- var params struct {
140- Message string `json:"message"`
141- }
142- if err := json.Unmarshal(args, ¶ms); err != nil {
143- return &ToolResult{
144- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("invalid arguments: %v", err)}},
145- IsError: true,
146- }, nil
147- }
148-
149- if err := orchestrator.BroadcastFrom(caller.MysisID, params.Message); err != nil {
150- return &ToolResult{
151- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("broadcast failed: %v", err)}},
152- IsError: true,
153- }, nil
154- }
155-
156- return &ToolResult{
157- Content: []ContentBlock{{Type: "text", Text: "broadcast sent to all running myses (excluding you)"}},
158- }, nil
159- },
160- )
161-
16240 // Search messages tool
16341 proxy.RegisterTool(
16442 Tool{
@@ -283,101 +161,4 @@ func RegisterOrchestratorTools(proxy *Proxy, orchestrator Orchestrator) {
283161 }, nil
284162 },
285163 )
286-
287- // Search broadcasts tool
288- proxy.RegisterTool(
289- Tool{
290- Name: "zoea_search_broadcasts",
291- Description: "Search past swarm broadcasts by text content",
292- InputSchema: json.RawMessage(`{
293- "type": "object",
294- "properties": {
295- "query": {"type": "string", "description": "Text to search for in broadcast content"},
296- "limit": {"type": "integer", "description": "Maximum results to return (default 20, max 100)"}
297- },
298- "required": ["query"]
299- }`),
300- },
301- func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
302- var params struct {
303- Query string `json:"query"`
304- Limit int `json:"limit"`
305- }
306- if err := json.Unmarshal(args, ¶ms); err != nil {
307- return &ToolResult{
308- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("invalid arguments: %v", err)}},
309- IsError: true,
310- }, nil
311- }
312-
313- if params.Query == "" {
314- return &ToolResult{
315- Content: []ContentBlock{{Type: "text", Text: "query cannot be empty"}},
316- IsError: true,
317- }, nil
318- }
319-
320- limit := params.Limit
321- if limit <= 0 {
322- limit = 20
323- } else if limit > 100 {
324- limit = 100
325- }
326-
327- results, err := orchestrator.SearchBroadcasts(params.Query, limit)
328- if err != nil {
329- return &ToolResult{
330- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("search failed: %v", err)}},
331- IsError: true,
332- }, nil
333- }
334-
335- if len(results) == 0 {
336- return &ToolResult{
337- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("no broadcasts found matching '%s'", params.Query)}},
338- }, nil
339- }
340-
341- data, _ := json.MarshalIndent(results, "", " ")
342- return &ToolResult{
343- Content: []ContentBlock{{Type: "text", Text: string(data)}},
344- }, nil
345- },
346- )
347-
348- // Claim account tool
349- proxy.RegisterTool(
350- Tool{
351- Name: "zoea_claim_account",
352- Description: "Get existing credentials from swarm pool. Returns username and password to use with the game's login tool. No arguments needed.",
353- InputSchema: json.RawMessage(`{"type": "object", "properties": {}}`),
354- },
355- func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
356- account, err := orchestrator.ClaimAccount()
357- if err != nil {
358- // Check if no accounts available
359- if err.Error() == "no accounts available" {
360- data, _ := json.Marshal(map[string]string{
361- "status": "no_accounts",
362- "action_required": "register",
363- })
364- return &ToolResult{
365- Content: []ContentBlock{{Type: "text", Text: string(data)}},
366- }, nil
367- }
368- return &ToolResult{
369- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("failed to claim account: %v", err)}},
370- IsError: true,
371- }, nil
372- }
373-
374- data, _ := json.Marshal(map[string]string{
375- "username": account.Username,
376- "password": account.Password,
377- })
378- return &ToolResult{
379- Content: []ContentBlock{{Type: "text", Text: string(data)}},
380- }, nil
381- },
382- )
383164 }