Unified Agent + reusable Go agent core.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: remove maep support from contacts

Lyric 01628c11 47973337

+25 -78
+7 -52
contacts/file_store.go
··· 424 424 SlackUserID string `yaml:"slack_user_id"` 425 425 SlackDMChannelID string `yaml:"slack_dm_channel_id"` 426 426 SlackChannelIDs []string `yaml:"slack_channel_ids"` 427 - MAEPNodeID string `yaml:"maep_node_id"` 428 - MAEPDialAddress string `yaml:"maep_dial_address"` 429 427 PersonaBrief string `yaml:"persona_brief"` 430 428 TopicPreferences []string `yaml:"topic_preferences"` 431 429 CooldownUntil string `yaml:"cooldown_until"` ··· 588 586 SlackUserID: normalizeSlackID(profile.SlackUserID), 589 587 SlackDMChannelID: normalizeSlackID(profile.SlackDMChannelID), 590 588 SlackChannelIDs: normalizeStringSlice(profile.SlackChannelIDs), 591 - MAEPDialAddress: strings.TrimSpace(profile.MAEPDialAddress), 592 589 PersonaBrief: strings.TrimSpace(profile.PersonaBrief), 593 590 TopicPreferences: normalizeStringSlice(profile.TopicPreferences), 594 591 } ··· 615 612 } 616 613 contact.TGGroupChatIDs = groupChatIDs 617 614 618 - nodeID, _ := splitMAEPNodeID(profile.MAEPNodeID) 619 - contact.MAEPNodeID = nodeID 620 - 621 615 kindRaw := strings.ToLower(strings.TrimSpace(profile.Kind)) 622 616 switch kindRaw { 623 617 case string(KindAgent): ··· 626 620 contact.Kind = KindHuman 627 621 case "": 628 622 channel := strings.ToLower(strings.TrimSpace(profile.Channel)) 629 - if channel == ChannelMAEP { 623 + switch channel { 624 + case "", ChannelTelegram, ChannelSlack, "discord": 625 + contact.Kind = KindHuman 626 + default: 630 627 contact.Kind = KindAgent 631 - } else { 632 - contact.Kind = KindHuman 633 628 } 634 629 default: 635 630 return Contact{}, fmt.Errorf("invalid contact kind: %s", profile.Kind) ··· 673 668 SlackUserID: normalizeSlackID(contact.SlackUserID), 674 669 SlackDMChannelID: normalizeSlackID(contact.SlackDMChannelID), 675 670 SlackChannelIDs: normalizeStringSlice(contact.SlackChannelIDs), 676 - MAEPNodeID: strings.TrimSpace(contact.MAEPNodeID), 677 - MAEPDialAddress: strings.TrimSpace(contact.MAEPDialAddress), 678 671 PersonaBrief: strings.TrimSpace(contact.PersonaBrief), 679 672 TopicPreferences: normalizeStringSlice(contact.TopicPreferences), 680 673 } ··· 685 678 profile.Channel = ChannelTelegram 686 679 case profile.SlackTeamID != "" || profile.SlackUserID != "" || profile.SlackDMChannelID != "" || len(profile.SlackChannelIDs) > 0 || strings.HasPrefix(strings.ToLower(profile.ContactID), "slack:"): 687 680 profile.Channel = ChannelSlack 688 - case profile.MAEPNodeID != "": 689 - profile.Channel = ChannelMAEP 690 681 default: 691 682 profile.Channel = strings.TrimSpace(string(normalizeKind(contact.Kind))) 692 683 } ··· 738 729 profile.SlackChannelIDs = []string{id} 739 730 } 740 731 } 741 - } 742 - if profile.MAEPNodeID == "" { 743 - nodeID, _ := splitMAEPNodeID(contact.ContactID) 744 - profile.MAEPNodeID = nodeID 745 732 } 746 733 if contact.CooldownUntil != nil && !contact.CooldownUntil.IsZero() { 747 734 profile.CooldownUntil = contact.CooldownUntil.UTC().Format(time.RFC3339) ··· 819 806 return teamID, userOrChannelID, true 820 807 } 821 808 822 - func splitMAEPNodeID(raw string) (string, string) { 823 - value := strings.TrimSpace(raw) 824 - if value == "" { 825 - return "", "" 826 - } 827 - lower := strings.ToLower(value) 828 - if strings.Contains(value, ":") && !strings.HasPrefix(lower, "maep:") { 829 - return "", "" 830 - } 831 - if strings.HasPrefix(lower, "maep:") { 832 - peerID := strings.TrimSpace(value[len("maep:"):]) 833 - if peerID == "" { 834 - return "", "" 835 - } 836 - return "maep:" + peerID, peerID 837 - } 838 - return "maep:" + value, value 839 - } 840 - 841 809 func slugToken(raw string) string { 842 810 value := strings.ToLower(strings.TrimSpace(raw)) 843 811 if value == "" { ··· 1047 1015 if c.TGPrivateChatID <= 0 { 1048 1016 c.TGPrivateChatID = 0 1049 1017 } 1050 - nodeID, _ := splitMAEPNodeID(c.MAEPNodeID) 1051 - c.MAEPNodeID = nodeID 1052 - c.MAEPDialAddress = strings.TrimSpace(c.MAEPDialAddress) 1053 1018 c.TopicPreferences = normalizeStringSlice(c.TopicPreferences) 1054 1019 if len(c.TopicPreferences) == 0 { 1055 1020 c.TopicPreferences = nil ··· 1085 1050 c.Channel = ChannelTelegram 1086 1051 case strings.HasPrefix(strings.ToLower(c.ContactID), "slack:"), c.SlackTeamID != "", c.SlackUserID != "", c.SlackDMChannelID != "", len(c.SlackChannelIDs) > 0: 1087 1052 c.Channel = ChannelSlack 1088 - case strings.HasPrefix(strings.ToLower(c.ContactID), "maep:"), c.MAEPNodeID != "", c.MAEPDialAddress != "": 1089 - c.Channel = ChannelMAEP 1090 1053 } 1091 1054 } 1092 - if c.Channel == "" { 1093 - if c.Kind == KindHuman { 1094 - c.Channel = ChannelTelegram 1095 - } else { 1096 - c.Channel = ChannelMAEP 1097 - } 1055 + if c.Channel == "" && c.Kind == KindHuman { 1056 + c.Channel = ChannelTelegram 1098 1057 } 1099 1058 1100 1059 if strings.HasPrefix(strings.ToLower(c.ContactID), "tg:@") && c.TGUsername == "" { ··· 1105 1064 if err == nil && id > 0 { 1106 1065 c.TGPrivateChatID = id 1107 1066 } 1108 - } 1109 - if strings.HasPrefix(strings.ToLower(c.ContactID), "maep:") && c.MAEPNodeID == "" { 1110 - node, _ := splitMAEPNodeID(c.ContactID) 1111 - c.MAEPNodeID = node 1112 1067 } 1113 1068 if strings.HasPrefix(strings.ToLower(c.ContactID), "slack:") { 1114 1069 teamID, userOrChannelID, ok := parseSlackContactID(c.ContactID) ··· 1143 1098 func normalizeContactChannel(raw string) string { 1144 1099 value := strings.ToLower(strings.TrimSpace(raw)) 1145 1100 switch value { 1146 - case ChannelTelegram, ChannelSlack, ChannelMAEP, "discord": 1101 + case ChannelTelegram, ChannelSlack, "discord": 1147 1102 return value 1148 1103 default: 1149 1104 return ""
+18 -17
contacts/file_store_test.go
··· 18 18 } 19 19 20 20 active := Contact{ 21 - ContactID: "maep:12D3KooWactive", 22 - Kind: KindAgent, 23 - Channel: ChannelMAEP, 24 - ContactNickname: "Active Agent", 25 - MAEPNodeID: "maep:12D3KooWactive", 26 - MAEPDialAddress: "/ip4/127.0.0.1/tcp/4021/p2p/12D3KooWactive", 21 + ContactID: "slack:T111:U222", 22 + Kind: KindHuman, 23 + Channel: ChannelSlack, 24 + ContactNickname: "Active Slack", 25 + SlackTeamID: "T111", 26 + SlackUserID: "U222", 27 + SlackDMChannelID: "D333", 27 28 TopicPreferences: []string{"ops", "alerts"}, 28 29 } 29 30 inactive := Contact{ ··· 53 54 if len(activeList) != 1 || activeList[0].ContactID != active.ContactID { 54 55 t.Fatalf("active contacts mismatch: got=%v", activeList) 55 56 } 56 - if activeList[0].MAEPDialAddress == "" { 57 - t.Fatalf("active contact maep_dial_address should be set") 57 + if activeList[0].SlackDMChannelID == "" { 58 + t.Fatalf("active contact slack_dm_channel_id should be set") 58 59 } 59 60 60 61 inactiveList, err := store.ListContacts(ctx, StatusInactive) ··· 178 179 179 180 # Inactive Contacts 180 181 181 - ## Morph Node 182 + ## Bob Slack 182 183 183 - ` + "```yaml\n" + `contact_id: "maep:12D3KooWPeerX" 184 - kind: "agent" 185 - channel: "maep" 186 - maep_node_id: "maep:12D3KooWPeerX" 187 - maep_dial_address: "/ip4/127.0.0.1/tcp/4021/p2p/12D3KooWPeerX" 184 + ` + "```yaml\n" + `contact_id: "slack:T111:D222" 185 + kind: "human" 186 + channel: "slack" 187 + slack_team_id: "T111" 188 + slack_dm_channel_id: "D222" 188 189 ` + "```\n" 189 190 if err := os.WriteFile(filepath.Join(root, "ACTIVE.md"), []byte(activeBody), 0o600); err != nil { 190 191 t.Fatalf("WriteFile(ACTIVE.md) error = %v", err) ··· 214 215 if len(inactive) != 1 { 215 216 t.Fatalf("inactive contacts mismatch: got=%d want=1", len(inactive)) 216 217 } 217 - if inactive[0].MAEPNodeID != "maep:12D3KooWPeerX" || inactive[0].Kind != KindAgent { 218 + if inactive[0].ContactID != "slack:T111:D222" || inactive[0].Kind != KindHuman { 218 219 t.Fatalf("inactive contact mismatch: %#v", inactive[0]) 219 220 } 220 - if inactive[0].MAEPDialAddress == "" { 221 - t.Fatalf("inactive contact maep_dial_address should be set") 221 + if inactive[0].SlackDMChannelID != "D222" { 222 + t.Fatalf("inactive contact slack_dm_channel_id mismatch: got=%q want=D222", inactive[0].SlackDMChannelID) 222 223 } 223 224 } 224 225
-6
contacts/service.go
··· 134 134 if len(contact.TGGroupChatIDs) == 0 && len(existing.TGGroupChatIDs) > 0 { 135 135 contact.TGGroupChatIDs = append([]int64(nil), existing.TGGroupChatIDs...) 136 136 } 137 - if strings.TrimSpace(contact.MAEPNodeID) == "" && strings.TrimSpace(existing.MAEPNodeID) != "" { 138 - contact.MAEPNodeID = strings.TrimSpace(existing.MAEPNodeID) 139 - } 140 - if strings.TrimSpace(contact.MAEPDialAddress) == "" && strings.TrimSpace(existing.MAEPDialAddress) != "" { 141 - contact.MAEPDialAddress = strings.TrimSpace(existing.MAEPDialAddress) 142 - } 143 137 if len(contact.TopicPreferences) == 0 && len(existing.TopicPreferences) > 0 { 144 138 contact.TopicPreferences = append([]string(nil), existing.TopicPreferences...) 145 139 }
-3
contacts/types.go
··· 23 23 const ( 24 24 ChannelTelegram = channels.Telegram 25 25 ChannelSlack = channels.Slack 26 - ChannelMAEP = channels.MAEP 27 26 ShareTopic = "chat.message" 28 27 ) 29 28 ··· 39 38 SlackUserID string `json:"slack_user_id,omitempty"` 40 39 SlackDMChannelID string `json:"slack_dm_channel_id,omitempty"` 41 40 SlackChannelIDs []string `json:"slack_channel_ids,omitempty"` 42 - MAEPNodeID string `json:"maep_node_id,omitempty"` 43 - MAEPDialAddress string `json:"maep_dial_address,omitempty"` 44 41 PersonaBrief string `json:"persona_brief,omitempty"` 45 42 TopicPreferences []string `json:"topic_preferences,omitempty"` 46 43 CooldownUntil *time.Time `json:"cooldown_until,omitempty"`