Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
feat(email): match sensitive gov domains by label, not per-country suffix (#376)
Generad2f2e703126
diff --git a/src/shared/src/constants.ts b/src/shared/src/constants.tsindex 83e6862c0..c9e8acf97 100644--- a/src/shared/src/constants.ts+++ b/src/shared/src/constants.ts@@ -136,30 +136,30 @@ export const COMMUNITY_BOT_IMAGE_URL_MAX = 2048;export const COMMUNITY_BOT_EMAIL_DOMAIN = "bots.alook.local";export const COMMUNITY_BOT_EMAIL_PREFIX = "bot-";-// Outbound recipient domains that agents must never email — government,-// law-enforcement, and intelligence services. Matched by exact domain OR-// suffix (so `.gov.br` catches `foo.gov.br`), case-insensitive. Adjusting the-// list ships via code release. See `isSensitiveRecipient` in utils/email.+// Government / law-enforcement / intelligence domain LABELS. A recipient+// domain is sensitive when any dot-separated label equals one of these — this+// catches every national variant (`gov.il`, `gov.br`, `gouv.fr`, `gob.mx`,+// `govt.nz`, `go.jp`, `gc.ca`, …) without enumerating each country. Matched+// case-insensitively per whole label, so `mycargo.com` (no label is `go`) is+// not caught, but `go.com` is (accepted trade-off — agents have no business+// emailing it). See `isSensitiveRecipient` in utils/email.+export const SENSITIVE_DOMAIN_LABELS: string[] = [+ "gov",+ "gouv",+ "gob",+ "govt",+ "mil",+ "go",+ "gc",+];++// Sensitive recipient domains that the label rule can't express — specific+// institutions or org-domains with no government label. Matched by exact+// domain OR suffix, case-insensitive.export const SENSITIVE_RECIPIENT_DOMAINS: string[] = [- ".gov",- ".gov.br",- ".gov.uk",- ".gov.au",- ".gov.in",- ".gov.cn",- ".gouv.fr",- ".go.jp",".mp.br",".jus.br",- ".gob.es",- ".gob.mx",- ".gc.ca",- ".govt.nz","pj.pt",- "nca.gov.uk",- "fbi.gov",- "cia.gov",- "nsa.gov","interpol.int","europol.europa.eu",];diff --git a/src/shared/src/index.ts b/src/shared/src/index.tsindex 9198105a2..510995808 100644--- a/src/shared/src/index.ts+++ b/src/shared/src/index.ts@@ -105,6 +105,7 @@ export {COMMUNITY_BOT_EMAIL_DOMAIN,COMMUNITY_BOT_EMAIL_PREFIX,SENSITIVE_RECIPIENT_DOMAINS,+ SENSITIVE_DOMAIN_LABELS,communityBotSyntheticEmail,SELF_BOT_FRIENDSHIP_PREFIX,isSelfBotFriendship,diff --git a/src/shared/src/utils/email.test.ts b/src/shared/src/utils/email.test.tsindex e18c591cb..8b2db91dd 100644--- a/src/shared/src/utils/email.test.ts+++ b/src/shared/src/utils/email.test.ts@@ -52,4 +52,27 @@ describe("isSensitiveRecipient", () => {it("does not let a display-name wrapper bypass the filter", () => {expect(isSensitiveRecipient("Government <[email protected]>")).toBe(true)})++ it("catches national government variants via the label rule", () => {+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ })++ it("matches on whole labels, not substrings", () => {+ expect(isSensitiveRecipient("[email protected]")).toBe(false)+ expect(isSensitiveRecipient("[email protected]")).toBe(false)+ expect(isSensitiveRecipient("[email protected]")).toBe(false)+ })++ it("still matches the non-label institution suffixes", () => {+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ expect(isSensitiveRecipient("[email protected]")).toBe(true)+ })})diff --git a/src/shared/src/utils/email.ts b/src/shared/src/utils/email.tsindex 47762c305..02a243275 100644--- a/src/shared/src/utils/email.ts+++ b/src/shared/src/utils/email.ts@@ -1,4 +1,4 @@-import { SENSITIVE_RECIPIENT_DOMAINS } from "../constants"+import { SENSITIVE_RECIPIENT_DOMAINS, SENSITIVE_DOMAIN_LABELS } from "../constants"const DOMAIN = `@${process.env.ALOOK_DOMAIN || "alook.ai"}`const HANDLE_RE = /^[a-zA-Z0-9-]{3,}$/@@ -38,6 +38,8 @@ export function extractDomain(email: string): string | null {export function isSensitiveRecipient(email: string): boolean {const domain = extractDomain(email)if (!domain) return false+ const labels = domain.split(".")+ if (labels.some((label) => SENSITIVE_DOMAIN_LABELS.includes(label))) return truereturn SENSITIVE_RECIPIENT_DOMAINS.some((entry) => {const target = entry.toLowerCase()return domain === target || domain.endsWith(target)