@@ -37,6 +37,13 @@ type BroadcastResult struct {
3737 CreatedAt string
3838 }
3939
40+// AccountInfo represents account credential information.
41+type AccountInfo struct {
42+ Username string
43+ Password string
44+ Empire string
45+}
46+
4047 // Orchestrator defines the interface for swarm orchestration.
4148 // This interface breaks the import cycle between mcp and core packages.
4249 type Orchestrator interface {
@@ -49,6 +56,10 @@ type Orchestrator interface {
4956 SearchMessages(mysisID, query string, limit int) ([]SearchResult, error)
5057 SearchReasoning(mysisID, query string, limit int) ([]ReasoningResult, error)
5158 SearchBroadcasts(query string, limit int) ([]BroadcastResult, error)
59+ ListAvailableAccounts() ([]AccountInfo, error)
60+ ClaimAccount(mysisID string) (AccountInfo, error)
61+ RegisterAccount(mysisID, username, password, empire string) error
62+ ReleaseAccount(mysisID string) error
5263 }
5364
5465 // RegisterOrchestratorTools registers the internal orchestration tools with the proxy.
@@ -431,4 +442,176 @@ func RegisterOrchestratorTools(proxy *Proxy, orchestrator Orchestrator) {
431442 }, nil
432443 },
433444 )
445+
446+ // List available accounts tool
447+ proxy.RegisterTool(
448+ Tool{
449+ Name: "zoea_accounts_available",
450+ Description: "List all available (unclaimed) swarm accounts",
451+ InputSchema: json.RawMessage(`{"type": "object", "properties": {}}`),
452+ },
453+ func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
454+ accounts, err := orchestrator.ListAvailableAccounts()
455+ if err != nil {
456+ return &ToolResult{
457+ Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("failed to list accounts: %v", err)}},
458+ IsError: true,
459+ }, nil
460+ }
461+
462+ if len(accounts) == 0 {
463+ return &ToolResult{
464+ Content: []ContentBlock{{Type: "text", Text: "No accounts available"}},
465+ }, nil
466+ }
467+
468+ var result []map[string]interface{}
469+ for _, acc := range accounts {
470+ result = append(result, map[string]interface{}{
471+ "username": acc.Username,
472+ "empire": acc.Empire,
473+ })
474+ }
475+
476+ data, _ := json.MarshalIndent(result, "", " ")
477+ return &ToolResult{
478+ Content: []ContentBlock{{Type: "text", Text: string(data)}},
479+ }, nil
480+ },
481+ )
482+
483+ // Claim account tool
484+ proxy.RegisterTool(
485+ Tool{
486+ Name: "zoea_claim_account",
487+ Description: "Claim an available account for login. Use zoea_list_myses to find your mysis_id first.",
488+ InputSchema: json.RawMessage(`{
489+ "type": "object",
490+ "properties": {
491+ "mysis_id": {"type": "string", "description": "Your mysis ID"}
492+ },
493+ "required": ["mysis_id"]
494+ }`),
495+ },
496+ func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
497+ var params struct {
498+ MysisID string `json:"mysis_id"`
499+ }
500+ if err := json.Unmarshal(args, ¶ms); err != nil {
501+ return &ToolResult{
502+ Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("invalid arguments: %v", err)}},
503+ IsError: true,
504+ }, nil
505+ }
506+
507+ account, err := orchestrator.ClaimAccount(params.MysisID)
508+ if err != nil {
509+ // Check if no accounts available
510+ if err.Error() == "no accounts available" {
511+ return &ToolResult{
512+ Content: []ContentBlock{{Type: "text", Text: "No accounts available. Register a new one."}},
513+ }, nil
514+ }
515+ return &ToolResult{
516+ Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("failed to claim account: %v", err)}},
517+ IsError: true,
518+ }, nil
519+ }
520+
521+ result := map[string]interface{}{
522+ "username": account.Username,
523+ "password": account.Password,
524+ "empire": account.Empire,
525+ }
526+
527+ data, _ := json.MarshalIndent(result, "", " ")
528+ return &ToolResult{
529+ Content: []ContentBlock{{Type: "text", Text: string(data)}},
530+ }, nil
531+ },
532+ )
533+
534+ // Register account tool
535+ proxy.RegisterTool(
536+ Tool{
537+ Name: "zoea_register_account",
538+ Description: "Store new account credentials for swarm reuse after registration",
539+ InputSchema: json.RawMessage(`{
540+ "type": "object",
541+ "properties": {
542+ "mysis_id": {"type": "string", "description": "Your mysis ID"},
543+ "username": {"type": "string", "description": "Game username you registered"},
544+ "password": {"type": "string", "description": "Game password you used"},
545+ "empire": {"type": "string", "description": "Empire (default: solarian)"}
546+ },
547+ "required": ["mysis_id", "username", "password"]
548+ }`),
549+ },
550+ func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
551+ var params struct {
552+ MysisID string `json:"mysis_id"`
553+ Username string `json:"username"`
554+ Password string `json:"password"`
555+ Empire string `json:"empire"`
556+ }
557+ if err := json.Unmarshal(args, ¶ms); err != nil {
558+ return &ToolResult{
559+ Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("invalid arguments: %v", err)}},
560+ IsError: true,
561+ }, nil
562+ }
563+
564+ if params.Empire == "" {
565+ params.Empire = "solarian"
566+ }
567+
568+ if err := orchestrator.RegisterAccount(params.MysisID, params.Username, params.Password, params.Empire); err != nil {
569+ return &ToolResult{
570+ Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("failed to register account: %v", err)}},
571+ IsError: true,
572+ }, nil
573+ }
574+
575+ return &ToolResult{
576+ Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("Account %s registered and claimed for swarm use", params.Username)}},
577+ }, nil
578+ },
579+ )
580+
581+ // Release account tool
582+ proxy.RegisterTool(
583+ Tool{
584+ Name: "zoea_release_account",
585+ Description: "Release your claimed account back to the swarm pool",
586+ InputSchema: json.RawMessage(`{
587+ "type": "object",
588+ "properties": {
589+ "mysis_id": {"type": "string", "description": "Your mysis ID"}
590+ },
591+ "required": ["mysis_id"]
592+ }`),
593+ },
594+ func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
595+ var params struct {
596+ MysisID string `json:"mysis_id"`
597+ }
598+ if err := json.Unmarshal(args, ¶ms); err != nil {
599+ return &ToolResult{
600+ Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("invalid arguments: %v", err)}},
601+ IsError: true,
602+ }, nil
603+ }
604+
605+ if err := orchestrator.ReleaseAccount(params.MysisID); err != nil {
606+ return &ToolResult{
607+ Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("failed to release account: %v", err)}},
608+ IsError: true,
609+ }, nil
610+ }
611+
612+ return &ToolResult{
613+ Content: []ContentBlock{{Type: "text", Text: "Account released"}},
614+ }, nil
615+ },
616+ )
434617 }