@nebutra/outreach-engine 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/LICENSE +21 -676
- package/dist/{chunk-IY3N4YTP.js → chunk-XD3Y5BKC.js} +2 -2
- package/dist/chunk-XD3Y5BKC.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +21 -11
- package/.nebutra/debug/content-store.jsonl +0 -3
- package/.nebutra/debug/event-log.jsonl +0 -1
- package/.nebutra/debug/outreach-engine.jsonl +0 -1
- package/.turbo/turbo-build.log +0 -22
- package/.turbo/turbo-test.log +0 -15
- package/.turbo/turbo-typecheck.log +0 -4
- package/dist/chunk-IY3N4YTP.js.map +0 -1
- package/examples/compliance.ts +0 -18
- package/examples/icp.ts +0 -9
- package/examples/quickstart.ts +0 -30
- package/plays/outreach_campaign/SKILL.md +0 -44
- package/src/cli.ts +0 -49
- package/src/index.test.ts +0 -120
- package/src/index.ts +0 -314
- package/tsconfig.json +0 -9
- package/tsup.config.ts +0 -11
|
@@ -8,7 +8,7 @@ import { CapabilityError } from "@nebutra/errors";
|
|
|
8
8
|
import { EventLog } from "@nebutra/event-log";
|
|
9
9
|
import { assetId } from "@nebutra/generation-context";
|
|
10
10
|
function slug(value) {
|
|
11
|
-
return value.toLowerCase().replace(/[^a-z0-9]
|
|
11
|
+
return value.slice(0, 200).toLowerCase().replace(/[^a-z0-9]{1,200}/g, "_").replace(/^_{1,200}|_{1,200}$/g, "").slice(0, 48);
|
|
12
12
|
}
|
|
13
13
|
function defineIcp(description) {
|
|
14
14
|
const text = description.toLowerCase();
|
|
@@ -184,4 +184,4 @@ export {
|
|
|
184
184
|
OutreachEngine,
|
|
185
185
|
readOutreachEngineDebug
|
|
186
186
|
};
|
|
187
|
-
//# sourceMappingURL=chunk-
|
|
187
|
+
//# sourceMappingURL=chunk-XD3Y5BKC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { mkdir } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { requireCapabilityTenant } from \"@nebutra/capability-kit\";\nimport { appendCapabilityDebug, readCapabilityDebug } from \"@nebutra/capability-kit/debug\";\nimport { ContentStore } from \"@nebutra/content-store\";\nimport { CapabilityError } from \"@nebutra/errors\";\nimport { EventLog } from \"@nebutra/event-log\";\nimport { assetId } from \"@nebutra/generation-context\";\n\nexport interface IcpDefinition {\n readonly industries: readonly string[];\n readonly companySize: { readonly min: number; readonly max: number };\n readonly titles: readonly string[];\n readonly geo: readonly string[];\n readonly techStack: readonly string[];\n}\n\nexport interface ComplianceProfile {\n readonly physicalAddress: string;\n readonly unsubscribeUrl: string;\n readonly gdprBasis?: \"legitimate_interest\" | \"consent\" | \"existing_customer\";\n}\n\nexport interface EmailVariant {\n readonly step: number;\n readonly subject: string;\n readonly body: string;\n readonly daysAfterPrevious: number;\n}\n\nexport interface ComplianceReport {\n readonly ok: boolean;\n readonly checks: {\n readonly hasUnsubscribeLink: boolean;\n readonly hasPhysicalAddress: boolean;\n readonly hasClearSubject: boolean;\n readonly gdprBasisDocumented: boolean;\n };\n readonly suggestion?: string;\n}\n\nexport interface CampaignInput {\n readonly tenantId?: string;\n readonly icpDescription: string;\n readonly targetCount: number;\n readonly product: string;\n readonly sequenceLength: number;\n readonly sendPerDay: number;\n readonly senderEmails: readonly string[];\n readonly complianceProfile: ComplianceProfile;\n}\n\nexport interface Lead {\n readonly id: string;\n readonly company: string;\n readonly title: string;\n readonly source: \"local-plan\";\n readonly confidence: number;\n}\n\nexport interface CampaignPackage {\n readonly tenantId: string;\n readonly play: \"outreach_campaign\";\n readonly id: string;\n readonly status: \"draft\";\n readonly icp: IcpDefinition;\n readonly leads: readonly Lead[];\n readonly sequence: readonly EmailVariant[];\n readonly compliance: ComplianceReport;\n readonly schedule: {\n readonly dailyLimit: number;\n readonly senderEmails: readonly string[];\n readonly requiresApprovalBeforeSend: true;\n };\n readonly artifactPath: string;\n readonly eventId: string;\n}\n\nexport interface SequenceInput {\n readonly product: string;\n readonly sequenceLength: number;\n readonly brandVoice?: readonly string[];\n}\n\nexport interface OutreachDoctorReport {\n readonly capability: \"outreach-engine\";\n readonly ok: boolean;\n readonly checkedAt: string;\n readonly plays: readonly string[];\n readonly sendMode: \"draft-only\";\n readonly adapters: readonly { readonly provider: string; readonly ok: boolean }[];\n}\n\nexport interface OutreachEngineOptions {\n readonly tenantId?: string;\n readonly root?: string;\n readonly debugRoot?: string;\n readonly contentStore?: ContentStore;\n readonly eventLog?: EventLog;\n}\n\nfunction slug(value: string): string {\n return value\n .slice(0, 200)\n .toLowerCase()\n .replace(/[^a-z0-9]{1,200}/g, \"_\")\n .replace(/^_{1,200}|_{1,200}$/g, \"\")\n .slice(0, 48);\n}\n\nexport function defineIcp(description: string): IcpDefinition {\n const text = description.toLowerCase();\n const industries =\n text.includes(\"e-commerce\") || text.includes(\"d2c\")\n ? [\"e-commerce\", \"D2C\"]\n : text.includes(\"saas\")\n ? [\"SaaS\"]\n : [\"startup\"];\n const titles = text.includes(\"cto\")\n ? [\"CTO\", \"VP Engineering\", \"Head of Engineering\"]\n : [\"VP Marketing\", \"Head of Growth\", \"CMO\"];\n const companySize =\n text.includes(\"mid-size\") || text.includes(\"medium\")\n ? { min: 50, max: 500 }\n : { min: 1, max: 50 };\n const geo = text.includes(\"eu\") ? [\"EU\"] : text.includes(\"us\") ? [\"US\"] : [\"US\", \"EU\"];\n const techStack = text.includes(\"shopify\") ? [\"Shopify\"] : [];\n return { industries, companySize, titles, geo, techStack };\n}\n\nexport function buildEmailSequence(input: SequenceInput): readonly EmailVariant[] {\n const length = Math.max(1, Math.min(5, input.sequenceLength));\n const voice = input.brandVoice?.join(\", \") ?? \"clear, useful\";\n return Array.from({ length }, (_, index) => {\n const step = index + 1;\n return {\n step,\n subject: step === 1 ? \"Quick question\" : `Following up ${step}`,\n body: [\n `Hi {{first_name}},`,\n \"\",\n step === 1\n ? `I noticed {{company}} may care about ${input.product}.`\n : `Sharing one more angle on ${input.product}.`,\n `Tone: ${voice}.`,\n \"\",\n \"If this is not useful, unsubscribe here: {{unsubscribe_url}}.\",\n \"{{physical_address}}\",\n ].join(\"\\n\"),\n daysAfterPrevious: step === 1 ? 0 : step + 1,\n };\n });\n}\n\nexport function checkEmailCompliance(\n email: EmailVariant | undefined,\n profile: ComplianceProfile,\n): ComplianceReport {\n const body = email?.body ?? \"\";\n const checks = {\n hasUnsubscribeLink: body.includes(\"unsubscribe\") && profile.unsubscribeUrl.startsWith(\"http\"),\n hasPhysicalAddress: profile.physicalAddress.trim().length > 4,\n hasClearSubject: Boolean(email?.subject.trim()),\n gdprBasisDocumented: Boolean(profile.gdprBasis),\n };\n const ok = Object.values(checks).every(Boolean);\n return {\n ok,\n checks,\n ...(!ok\n ? {\n suggestion:\n \"Add unsubscribe URL, physical address, clear subject, and GDPR basis before any send adapter can run.\",\n }\n : {}),\n };\n}\n\nfunction plannedLeads(icp: IcpDefinition, count: number): readonly Lead[] {\n const size = Math.max(1, Math.min(250, count));\n return Array.from({ length: size }, (_, index) => ({\n id: `lead_${String(index + 1).padStart(3, \"0\")}`,\n company: `${icp.industries[0] ?? \"startup\"} account ${index + 1}`,\n title: icp.titles[index % icp.titles.length] ?? \"Founder\",\n source: \"local-plan\",\n confidence: 0.72,\n }));\n}\n\nexport class OutreachEngine {\n readonly #tenantId: string | undefined;\n readonly #debugRoot: string;\n readonly #contentStore: ContentStore;\n readonly #eventLog: EventLog;\n\n private constructor(\n options: OutreachEngineOptions & { contentStore: ContentStore; eventLog: EventLog },\n ) {\n this.#tenantId = options.tenantId;\n this.#debugRoot = options.debugRoot ?? process.cwd();\n this.#contentStore = options.contentStore;\n this.#eventLog = options.eventLog;\n }\n\n static async open(\n root = \".nebutra/outreach-engine\",\n options: Omit<OutreachEngineOptions, \"root\" | \"contentStore\" | \"eventLog\"> = {},\n ): Promise<OutreachEngine> {\n const tenantId = options.tenantId ?? \"local\";\n await mkdir(root, { recursive: true });\n const contentStore = await ContentStore.open(join(root, \"content\"), { tenantId });\n const eventLog = await EventLog.open(join(root, \"event-log\"), { tenantId });\n return new OutreachEngine({ ...options, tenantId, root, contentStore, eventLog });\n }\n\n async createCampaign(input: CampaignInput): Promise<CampaignPackage> {\n const tenantId = requireCapabilityTenant({\n explicit: input.tenantId,\n fallback: this.#tenantId,\n onMissing: () =>\n new CapabilityError(\"outreach-engine\", \"Outreach Engine requires tenant context\", {\n suggestion: \"Pass tenantId before creating or persisting a campaign.\",\n statusCode: 400,\n }),\n });\n const icp = defineIcp(input.icpDescription);\n const sequence = buildEmailSequence({\n product: input.product,\n sequenceLength: input.sequenceLength,\n brandVoice: [\"specific\", \"useful\", \"respectful\"],\n });\n const compliance = checkEmailCompliance(sequence[0], input.complianceProfile);\n if (!compliance.ok) {\n throw new CapabilityError(\"outreach-engine\", \"Campaign failed compliance checks\", {\n suggestion:\n compliance.suggestion ??\n \"Add unsubscribe URL, physical address, clear subject, and GDPR basis.\",\n statusCode: 400,\n metadata: compliance.checks,\n });\n }\n const id = assetId(\"outreach_campaign\", slug(input.icpDescription));\n const leads = plannedLeads(icp, input.targetCount);\n const artifactPath = `outreach/${id}.json`;\n const draft = {\n id,\n status: \"draft\",\n icp,\n leads,\n sequence,\n schedule: {\n dailyLimit: Math.max(1, Math.min(30, input.sendPerDay)),\n senderEmails: input.senderEmails,\n requiresApprovalBeforeSend: true,\n } as const,\n };\n const content = `${JSON.stringify(draft, null, 2)}\\n`;\n await this.#contentStore.write(artifactPath, content);\n const eventId = await this.#eventLog.commit({\n traceId: id,\n kind: \"content_write\",\n affected: [artifactPath],\n parent: null,\n snapshot: { [artifactPath]: content },\n });\n const campaign: CampaignPackage = {\n tenantId,\n play: \"outreach_campaign\",\n id,\n status: \"draft\",\n icp,\n leads,\n sequence,\n compliance,\n schedule: draft.schedule,\n artifactPath,\n eventId,\n };\n await this.#debug({ type: \"campaign_draft\", tenantId, campaignId: id, eventId });\n return campaign;\n }\n\n async doctor(): Promise<OutreachDoctorReport> {\n return {\n capability: \"outreach-engine\",\n ok: true,\n checkedAt: new Date().toISOString(),\n plays: [\"outreach_campaign\"],\n sendMode: \"draft-only\",\n adapters: [\n { provider: \"local-plan\", ok: true },\n { provider: \"integration-vault-email\", ok: false },\n { provider: \"crm-sync\", ok: false },\n ],\n };\n }\n\n async close(): Promise<void> {\n await this.#contentStore.close();\n }\n\n async #debug(entry: Record<string, unknown>): Promise<void> {\n await mkdir(dirname(join(this.#debugRoot, \".nebutra\", \"debug\", \"outreach-engine.jsonl\")), {\n recursive: true,\n });\n await appendCapabilityDebug(\"outreach-engine\", entry, { root: this.#debugRoot });\n }\n}\n\nexport async function readOutreachEngineDebug(\n root = process.cwd(),\n limit = 20,\n): Promise<unknown[]> {\n return readCapabilityDebug(\"outreach-engine\", { root, limit });\n}\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,SAAS,YAAY;AAC9B,SAAS,+BAA+B;AACxC,SAAS,uBAAuB,2BAA2B;AAC3D,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,eAAe;AA8FxB,SAAS,KAAK,OAAuB;AACnC,SAAO,MACJ,MAAM,GAAG,GAAG,EACZ,YAAY,EACZ,QAAQ,qBAAqB,GAAG,EAChC,QAAQ,wBAAwB,EAAE,EAClC,MAAM,GAAG,EAAE;AAChB;AAEO,SAAS,UAAU,aAAoC;AAC5D,QAAM,OAAO,YAAY,YAAY;AACrC,QAAM,aACJ,KAAK,SAAS,YAAY,KAAK,KAAK,SAAS,KAAK,IAC9C,CAAC,cAAc,KAAK,IACpB,KAAK,SAAS,MAAM,IAClB,CAAC,MAAM,IACP,CAAC,SAAS;AAClB,QAAM,SAAS,KAAK,SAAS,KAAK,IAC9B,CAAC,OAAO,kBAAkB,qBAAqB,IAC/C,CAAC,gBAAgB,kBAAkB,KAAK;AAC5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2
2
|
"name": "@nebutra/outreach-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Compliance-first outreach campaign Play package for founder-led sales workflows",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,21 +23,25 @@
|
|
|
23
23
|
"category": "ai",
|
|
24
24
|
"summary": "Compliance-first outreach Play product that produces auditable campaign drafts"
|
|
25
25
|
},
|
|
26
|
-
"main": "./
|
|
27
|
-
"types": "./
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
28
|
"exports": {
|
|
29
|
-
".":
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
}
|
|
30
34
|
},
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"@nebutra/capability-kit": "0.2.
|
|
33
|
-
"@nebutra/content-store": "0.1.
|
|
34
|
-
"@nebutra/errors": "0.1.
|
|
35
|
-
"@nebutra/event-log": "0.1.
|
|
36
|
-
"@nebutra/generation-context": "0.1.
|
|
37
|
-
"@nebutra/play-loader": "0.1.
|
|
36
|
+
"@nebutra/capability-kit": "0.2.4",
|
|
37
|
+
"@nebutra/content-store": "0.1.4",
|
|
38
|
+
"@nebutra/errors": "0.1.2",
|
|
39
|
+
"@nebutra/event-log": "0.1.4",
|
|
40
|
+
"@nebutra/generation-context": "0.1.3",
|
|
41
|
+
"@nebutra/play-loader": "0.1.3"
|
|
38
42
|
},
|
|
39
43
|
"devDependencies": {
|
|
40
|
-
"@types/node": "^
|
|
44
|
+
"@types/node": "^25.9.1",
|
|
41
45
|
"tsup": "^8.5.1",
|
|
42
46
|
"tsx": "^4.21.0",
|
|
43
47
|
"typescript": "^5.9.3",
|
|
@@ -55,6 +59,12 @@
|
|
|
55
59
|
"publishConfig": {
|
|
56
60
|
"access": "public"
|
|
57
61
|
},
|
|
62
|
+
"files": [
|
|
63
|
+
"dist",
|
|
64
|
+
"README.md",
|
|
65
|
+
"LICENSE",
|
|
66
|
+
"CHANGELOG.md"
|
|
67
|
+
],
|
|
58
68
|
"scripts": {
|
|
59
69
|
"build": "tsup",
|
|
60
70
|
"test": "vitest run",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
{"at":"2026-05-19T08:15:29.836Z","type":"reindex","tenantId":"tenant_a","files":0}
|
|
2
|
-
{"at":"2026-05-19T08:15:29.865Z","type":"write","tenantId":"tenant_a","path":"outreach/outreach_campaign_decision_makers_at_mid_size_d2c_e_commer_mpccyjow.json"}
|
|
3
|
-
{"at":"2026-05-19T08:15:30.046Z","type":"reindex","tenantId":"tenant_a","files":0}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"at":"2026-05-19T08:15:29.894Z","traceId":"outreach_campaign_decision_makers_at_mid_size_d2c_e_commer_mpccyjow","kind":"content_write","affected":["outreach/outreach_campaign_decision_makers_at_mid_size_d2c_e_commer_mpccyjow.json"],"parent":null,"snapshot":{"outreach/outreach_campaign_decision_makers_at_mid_size_d2c_e_commer_mpccyjow.json":"{\n \"id\": \"outreach_campaign_decision_makers_at_mid_size_d2c_e_commer_mpccyjow\",\n \"status\": \"draft\",\n \"icp\": {\n \"industries\": [\n \"e-commerce\",\n \"D2C\"\n ],\n \"companySize\": {\n \"min\": 50,\n \"max\": 500\n },\n \"titles\": [\n \"VP Marketing\",\n \"Head of Growth\",\n \"CMO\"\n ],\n \"geo\": [\n \"US\",\n \"EU\"\n ],\n \"techStack\": []\n },\n \"leads\": [\n {\n \"id\": \"lead_001\",\n \"company\": \"e-commerce account 1\",\n \"title\": \"VP Marketing\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_002\",\n \"company\": \"e-commerce account 2\",\n \"title\": \"Head of Growth\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_003\",\n \"company\": \"e-commerce account 3\",\n \"title\": \"CMO\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_004\",\n \"company\": \"e-commerce account 4\",\n \"title\": \"VP Marketing\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_005\",\n \"company\": \"e-commerce account 5\",\n \"title\": \"Head of Growth\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_006\",\n \"company\": \"e-commerce account 6\",\n \"title\": \"CMO\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_007\",\n \"company\": \"e-commerce account 7\",\n \"title\": \"VP Marketing\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_008\",\n \"company\": \"e-commerce account 8\",\n \"title\": \"Head of Growth\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_009\",\n \"company\": \"e-commerce account 9\",\n \"title\": \"CMO\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_010\",\n \"company\": \"e-commerce account 10\",\n \"title\": \"VP Marketing\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_011\",\n \"company\": \"e-commerce account 11\",\n \"title\": \"Head of Growth\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n },\n {\n \"id\": \"lead_012\",\n \"company\": \"e-commerce account 12\",\n \"title\": \"CMO\",\n \"source\": \"local-plan\",\n \"confidence\": 0.72\n }\n ],\n \"sequence\": [\n {\n \"step\": 1,\n \"subject\": \"Quick question\",\n \"body\": \"Hi {{first_name}},\\n\\nI noticed {{company}} may care about Loop helps teams debug production issues.\\nTone: specific, useful, respectful.\\n\\nIf this is not useful, unsubscribe here: {{unsubscribe_url}}.\\n{{physical_address}}\",\n \"daysAfterPrevious\": 0\n },\n {\n \"step\": 2,\n \"subject\": \"Following up 2\",\n \"body\": \"Hi {{first_name}},\\n\\nSharing one more angle on Loop helps teams debug production issues.\\nTone: specific, useful, respectful.\\n\\nIf this is not useful, unsubscribe here: {{unsubscribe_url}}.\\n{{physical_address}}\",\n \"daysAfterPrevious\": 3\n },\n {\n \"step\": 3,\n \"subject\": \"Following up 3\",\n \"body\": \"Hi {{first_name}},\\n\\nSharing one more angle on Loop helps teams debug production issues.\\nTone: specific, useful, respectful.\\n\\nIf this is not useful, unsubscribe here: {{unsubscribe_url}}.\\n{{physical_address}}\",\n \"daysAfterPrevious\": 4\n }\n ],\n \"schedule\": {\n \"dailyLimit\": 4,\n \"senderEmails\": [\n \"founder@loop.test\"\n ],\n \"requiresApprovalBeforeSend\": true\n }\n}\n"},"id":"e1f0777672396d3d7112e2dd69a4c18749cd773ae637bf10a16aed25ef72010a","tenantId":"tenant_a","summary":"content_write touched 1 path(s)","objectHashes":["a67b080547435c86547169b5ba680605d93af81556f3f188d9c6ec3aef4a66e9"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"at":"2026-05-19T08:15:29.905Z","type":"campaign_draft","tenantId":"tenant_a","campaignId":"outreach_campaign_decision_makers_at_mid_size_d2c_e_commer_mpccyjow","eventId":"e1f0777672396d3d7112e2dd69a4c18749cd773ae637bf10a16aed25ef72010a"}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @nebutra/outreach-engine@0.1.2 build /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/outreach-engine
|
|
3
|
-
> tsup
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/cli.ts, src/index.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.5.1
|
|
8
|
-
[34mCLI[39m Using tsup config: /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/outreach-engine/tsup.config.ts
|
|
9
|
-
[34mCLI[39m Target: es2022
|
|
10
|
-
[34mCLI[39m Cleaning output folder
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/cli.js [22m[32m1.61 KB[39m
|
|
13
|
-
[32mESM[39m [1mdist/index.js [22m[32m290.00 B[39m
|
|
14
|
-
[32mESM[39m [1mdist/chunk-IY3N4YTP.js [22m[32m6.72 KB[39m
|
|
15
|
-
[32mESM[39m [1mdist/cli.js.map [22m[32m2.75 KB[39m
|
|
16
|
-
[32mESM[39m [1mdist/index.js.map [22m[32m71.00 B[39m
|
|
17
|
-
[32mESM[39m [1mdist/chunk-IY3N4YTP.js.map [22m[32m14.97 KB[39m
|
|
18
|
-
[32mESM[39m ⚡️ Build success in 76ms
|
|
19
|
-
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in 10096ms
|
|
21
|
-
[32mDTS[39m [1mdist/cli.d.ts [22m[32m13.00 B[39m
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.69 KB[39m
|
package/.turbo/turbo-test.log
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @nebutra/outreach-engine@0.1.2 test /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/outreach-engine
|
|
3
|
-
> vitest run
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.4 [39m[90m/home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/outreach-engine[39m
|
|
7
|
-
|
|
8
|
-
[32m✓[39m src/index.test.ts [2m([22m[2m5 tests[22m[2m)[22m[33m 647[2mms[22m[39m
|
|
9
|
-
[33m[2m✓[22m[39m runs outreach_campaign as a draft with leads, sequence, schedule, and event [33m 353[2mms[22m[39m
|
|
10
|
-
|
|
11
|
-
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
12
|
-
[2m Tests [22m [1m[32m5 passed[39m[22m[90m (5)[39m
|
|
13
|
-
[2m Start at [22m 08:15:26
|
|
14
|
-
[2m Duration [22m 3.52s[2m (transform 1.37s, setup 0ms, import 1.91s, tests 647ms, environment 0ms)[22m
|
|
15
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { mkdir } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { requireCapabilityTenant } from \"@nebutra/capability-kit\";\nimport { appendCapabilityDebug, readCapabilityDebug } from \"@nebutra/capability-kit/debug\";\nimport { ContentStore } from \"@nebutra/content-store\";\nimport { CapabilityError } from \"@nebutra/errors\";\nimport { EventLog } from \"@nebutra/event-log\";\nimport { assetId } from \"@nebutra/generation-context\";\n\nexport interface IcpDefinition {\n readonly industries: readonly string[];\n readonly companySize: { readonly min: number; readonly max: number };\n readonly titles: readonly string[];\n readonly geo: readonly string[];\n readonly techStack: readonly string[];\n}\n\nexport interface ComplianceProfile {\n readonly physicalAddress: string;\n readonly unsubscribeUrl: string;\n readonly gdprBasis?: \"legitimate_interest\" | \"consent\" | \"existing_customer\";\n}\n\nexport interface EmailVariant {\n readonly step: number;\n readonly subject: string;\n readonly body: string;\n readonly daysAfterPrevious: number;\n}\n\nexport interface ComplianceReport {\n readonly ok: boolean;\n readonly checks: {\n readonly hasUnsubscribeLink: boolean;\n readonly hasPhysicalAddress: boolean;\n readonly hasClearSubject: boolean;\n readonly gdprBasisDocumented: boolean;\n };\n readonly suggestion?: string;\n}\n\nexport interface CampaignInput {\n readonly tenantId?: string;\n readonly icpDescription: string;\n readonly targetCount: number;\n readonly product: string;\n readonly sequenceLength: number;\n readonly sendPerDay: number;\n readonly senderEmails: readonly string[];\n readonly complianceProfile: ComplianceProfile;\n}\n\nexport interface Lead {\n readonly id: string;\n readonly company: string;\n readonly title: string;\n readonly source: \"local-plan\";\n readonly confidence: number;\n}\n\nexport interface CampaignPackage {\n readonly tenantId: string;\n readonly play: \"outreach_campaign\";\n readonly id: string;\n readonly status: \"draft\";\n readonly icp: IcpDefinition;\n readonly leads: readonly Lead[];\n readonly sequence: readonly EmailVariant[];\n readonly compliance: ComplianceReport;\n readonly schedule: {\n readonly dailyLimit: number;\n readonly senderEmails: readonly string[];\n readonly requiresApprovalBeforeSend: true;\n };\n readonly artifactPath: string;\n readonly eventId: string;\n}\n\nexport interface SequenceInput {\n readonly product: string;\n readonly sequenceLength: number;\n readonly brandVoice?: readonly string[];\n}\n\nexport interface OutreachDoctorReport {\n readonly capability: \"outreach-engine\";\n readonly ok: boolean;\n readonly checkedAt: string;\n readonly plays: readonly string[];\n readonly sendMode: \"draft-only\";\n readonly adapters: readonly { readonly provider: string; readonly ok: boolean }[];\n}\n\nexport interface OutreachEngineOptions {\n readonly tenantId?: string;\n readonly root?: string;\n readonly debugRoot?: string;\n readonly contentStore?: ContentStore;\n readonly eventLog?: EventLog;\n}\n\nfunction slug(value: string): string {\n return value\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\")\n .slice(0, 48);\n}\n\nexport function defineIcp(description: string): IcpDefinition {\n const text = description.toLowerCase();\n const industries =\n text.includes(\"e-commerce\") || text.includes(\"d2c\")\n ? [\"e-commerce\", \"D2C\"]\n : text.includes(\"saas\")\n ? [\"SaaS\"]\n : [\"startup\"];\n const titles = text.includes(\"cto\")\n ? [\"CTO\", \"VP Engineering\", \"Head of Engineering\"]\n : [\"VP Marketing\", \"Head of Growth\", \"CMO\"];\n const companySize =\n text.includes(\"mid-size\") || text.includes(\"medium\")\n ? { min: 50, max: 500 }\n : { min: 1, max: 50 };\n const geo = text.includes(\"eu\") ? [\"EU\"] : text.includes(\"us\") ? [\"US\"] : [\"US\", \"EU\"];\n const techStack = text.includes(\"shopify\") ? [\"Shopify\"] : [];\n return { industries, companySize, titles, geo, techStack };\n}\n\nexport function buildEmailSequence(input: SequenceInput): readonly EmailVariant[] {\n const length = Math.max(1, Math.min(5, input.sequenceLength));\n const voice = input.brandVoice?.join(\", \") ?? \"clear, useful\";\n return Array.from({ length }, (_, index) => {\n const step = index + 1;\n return {\n step,\n subject: step === 1 ? \"Quick question\" : `Following up ${step}`,\n body: [\n `Hi {{first_name}},`,\n \"\",\n step === 1\n ? `I noticed {{company}} may care about ${input.product}.`\n : `Sharing one more angle on ${input.product}.`,\n `Tone: ${voice}.`,\n \"\",\n \"If this is not useful, unsubscribe here: {{unsubscribe_url}}.\",\n \"{{physical_address}}\",\n ].join(\"\\n\"),\n daysAfterPrevious: step === 1 ? 0 : step + 1,\n };\n });\n}\n\nexport function checkEmailCompliance(\n email: EmailVariant | undefined,\n profile: ComplianceProfile,\n): ComplianceReport {\n const body = email?.body ?? \"\";\n const checks = {\n hasUnsubscribeLink: body.includes(\"unsubscribe\") && profile.unsubscribeUrl.startsWith(\"http\"),\n hasPhysicalAddress: profile.physicalAddress.trim().length > 4,\n hasClearSubject: Boolean(email?.subject.trim()),\n gdprBasisDocumented: Boolean(profile.gdprBasis),\n };\n const ok = Object.values(checks).every(Boolean);\n return {\n ok,\n checks,\n ...(!ok\n ? {\n suggestion:\n \"Add unsubscribe URL, physical address, clear subject, and GDPR basis before any send adapter can run.\",\n }\n : {}),\n };\n}\n\nfunction plannedLeads(icp: IcpDefinition, count: number): readonly Lead[] {\n const size = Math.max(1, Math.min(250, count));\n return Array.from({ length: size }, (_, index) => ({\n id: `lead_${String(index + 1).padStart(3, \"0\")}`,\n company: `${icp.industries[0] ?? \"startup\"} account ${index + 1}`,\n title: icp.titles[index % icp.titles.length] ?? \"Founder\",\n source: \"local-plan\",\n confidence: 0.72,\n }));\n}\n\nexport class OutreachEngine {\n readonly #tenantId: string | undefined;\n readonly #debugRoot: string;\n readonly #contentStore: ContentStore;\n readonly #eventLog: EventLog;\n\n private constructor(\n options: OutreachEngineOptions & { contentStore: ContentStore; eventLog: EventLog },\n ) {\n this.#tenantId = options.tenantId;\n this.#debugRoot = options.debugRoot ?? process.cwd();\n this.#contentStore = options.contentStore;\n this.#eventLog = options.eventLog;\n }\n\n static async open(\n root = \".nebutra/outreach-engine\",\n options: Omit<OutreachEngineOptions, \"root\" | \"contentStore\" | \"eventLog\"> = {},\n ): Promise<OutreachEngine> {\n const tenantId = options.tenantId ?? \"local\";\n await mkdir(root, { recursive: true });\n const contentStore = await ContentStore.open(join(root, \"content\"), { tenantId });\n const eventLog = await EventLog.open(join(root, \"event-log\"), { tenantId });\n return new OutreachEngine({ ...options, tenantId, root, contentStore, eventLog });\n }\n\n async createCampaign(input: CampaignInput): Promise<CampaignPackage> {\n const tenantId = requireCapabilityTenant({\n explicit: input.tenantId,\n fallback: this.#tenantId,\n onMissing: () =>\n new CapabilityError(\"outreach-engine\", \"Outreach Engine requires tenant context\", {\n suggestion: \"Pass tenantId before creating or persisting a campaign.\",\n statusCode: 400,\n }),\n });\n const icp = defineIcp(input.icpDescription);\n const sequence = buildEmailSequence({\n product: input.product,\n sequenceLength: input.sequenceLength,\n brandVoice: [\"specific\", \"useful\", \"respectful\"],\n });\n const compliance = checkEmailCompliance(sequence[0], input.complianceProfile);\n if (!compliance.ok) {\n throw new CapabilityError(\"outreach-engine\", \"Campaign failed compliance checks\", {\n suggestion:\n compliance.suggestion ??\n \"Add unsubscribe URL, physical address, clear subject, and GDPR basis.\",\n statusCode: 400,\n metadata: compliance.checks,\n });\n }\n const id = assetId(\"outreach_campaign\", slug(input.icpDescription));\n const leads = plannedLeads(icp, input.targetCount);\n const artifactPath = `outreach/${id}.json`;\n const draft = {\n id,\n status: \"draft\",\n icp,\n leads,\n sequence,\n schedule: {\n dailyLimit: Math.max(1, Math.min(30, input.sendPerDay)),\n senderEmails: input.senderEmails,\n requiresApprovalBeforeSend: true,\n } as const,\n };\n const content = `${JSON.stringify(draft, null, 2)}\\n`;\n await this.#contentStore.write(artifactPath, content);\n const eventId = await this.#eventLog.commit({\n traceId: id,\n kind: \"content_write\",\n affected: [artifactPath],\n parent: null,\n snapshot: { [artifactPath]: content },\n });\n const campaign: CampaignPackage = {\n tenantId,\n play: \"outreach_campaign\",\n id,\n status: \"draft\",\n icp,\n leads,\n sequence,\n compliance,\n schedule: draft.schedule,\n artifactPath,\n eventId,\n };\n await this.#debug({ type: \"campaign_draft\", tenantId, campaignId: id, eventId });\n return campaign;\n }\n\n async doctor(): Promise<OutreachDoctorReport> {\n return {\n capability: \"outreach-engine\",\n ok: true,\n checkedAt: new Date().toISOString(),\n plays: [\"outreach_campaign\"],\n sendMode: \"draft-only\",\n adapters: [\n { provider: \"local-plan\", ok: true },\n { provider: \"integration-vault-email\", ok: false },\n { provider: \"crm-sync\", ok: false },\n ],\n };\n }\n\n async close(): Promise<void> {\n await this.#contentStore.close();\n }\n\n async #debug(entry: Record<string, unknown>): Promise<void> {\n await mkdir(dirname(join(this.#debugRoot, \".nebutra\", \"debug\", \"outreach-engine.jsonl\")), {\n recursive: true,\n });\n await appendCapabilityDebug(\"outreach-engine\", entry, { root: this.#debugRoot });\n }\n}\n\nexport async function readOutreachEngineDebug(\n root = process.cwd(),\n limit = 20,\n): Promise<unknown[]> {\n return readCapabilityDebug(\"outreach-engine\", { root, limit });\n}\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,SAAS,YAAY;AAC9B,SAAS,+BAA+B;AACxC,SAAS,uBAAuB,2BAA2B;AAC3D,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,eAAe;AA8FxB,SAAS,KAAK,OAAuB;AACnC,SAAO,MACJ,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE,EACtB,MAAM,GAAG,EAAE;AAChB;AAEO,SAAS,UAAU,aAAoC;AAC5D,QAAM,OAAO,YAAY,YAAY;AACrC,QAAM,aACJ,KAAK,SAAS,YAAY,KAAK,KAAK,SAAS,KAAK,IAC9C,CAAC,cAAc,KAAK,IACpB,KAAK,SAAS,MAAM,IAClB,CAAC,MAAM,IACP,CAAC,SAAS;AAClB,QAAM,SAAS,KAAK,SAAS,KAAK,IAC9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@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { buildEmailSequence, checkEmailCompliance } from "../src/index";
|
|
2
|
-
|
|
3
|
-
const sequence = buildEmailSequence({
|
|
4
|
-
product: "Loop helps teams debug production issues",
|
|
5
|
-
sequenceLength: 2,
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
process.stdout.write(
|
|
9
|
-
`${JSON.stringify(
|
|
10
|
-
checkEmailCompliance(sequence[0], {
|
|
11
|
-
physicalAddress: "123 Market St",
|
|
12
|
-
unsubscribeUrl: "https://loop.test/unsubscribe",
|
|
13
|
-
gdprBasis: "legitimate_interest",
|
|
14
|
-
}),
|
|
15
|
-
null,
|
|
16
|
-
2,
|
|
17
|
-
)}\n`,
|
|
18
|
-
);
|
package/examples/icp.ts
DELETED
package/examples/quickstart.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { OutreachEngine } from "../src/index";
|
|
2
|
-
|
|
3
|
-
const engine = await OutreachEngine.open(".nebutra/outreach-engine-example", {
|
|
4
|
-
tenantId: "local",
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
process.stdout.write(
|
|
9
|
-
`${JSON.stringify(
|
|
10
|
-
await engine.createCampaign({
|
|
11
|
-
tenantId: "local",
|
|
12
|
-
icpDescription: "decision makers at mid-size D2C e-commerce companies",
|
|
13
|
-
targetCount: 10,
|
|
14
|
-
product: "Loop helps teams debug production issues",
|
|
15
|
-
sequenceLength: 3,
|
|
16
|
-
sendPerDay: 5,
|
|
17
|
-
senderEmails: ["founder@loop.test"],
|
|
18
|
-
complianceProfile: {
|
|
19
|
-
physicalAddress: "123 Market St",
|
|
20
|
-
unsubscribeUrl: "https://loop.test/unsubscribe",
|
|
21
|
-
gdprBasis: "legitimate_interest",
|
|
22
|
-
},
|
|
23
|
-
}),
|
|
24
|
-
null,
|
|
25
|
-
2,
|
|
26
|
-
)}\n`,
|
|
27
|
-
);
|
|
28
|
-
} finally {
|
|
29
|
-
await engine.close();
|
|
30
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: outreach_campaign
|
|
3
|
-
kind: play
|
|
4
|
-
version: 1.0.0
|
|
5
|
-
description: Create a compliance-gated founder-led outbound campaign draft
|
|
6
|
-
inputs:
|
|
7
|
-
icp_description: { type: string, max_length: 500 }
|
|
8
|
-
target_count: { type: number }
|
|
9
|
-
product: { type: string, max_length: 500 }
|
|
10
|
-
sequence_length: { type: number }
|
|
11
|
-
send_per_day: { type: number }
|
|
12
|
-
outputs:
|
|
13
|
-
campaign: { type: file, path: outreach/campaign.json, mime: application/json }
|
|
14
|
-
budget:
|
|
15
|
-
duration_s: 600
|
|
16
|
-
cost_usd: 2.0
|
|
17
|
-
required_skills:
|
|
18
|
-
- content_store.write
|
|
19
|
-
- research_agent.run
|
|
20
|
-
- integration_vault.invoke
|
|
21
|
-
sub_agents:
|
|
22
|
-
- role: icp_strategist
|
|
23
|
-
allowed_skills: [content_store.write]
|
|
24
|
-
- role: lead_researcher
|
|
25
|
-
allowed_skills: [research_agent.run]
|
|
26
|
-
- role: compliance_reviewer
|
|
27
|
-
allowed_skills: [content_store.write]
|
|
28
|
-
depends_on_plays: []
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## What this play does
|
|
32
|
-
|
|
33
|
-
Creates a draft outbound campaign from an ICP description.
|
|
34
|
-
|
|
35
|
-
The Play is draft-first. It may produce leads, enrichment notes, email variants,
|
|
36
|
-
and a schedule, but actual sending requires explicit approval and a configured
|
|
37
|
-
sender adapter.
|
|
38
|
-
|
|
39
|
-
## Rules
|
|
40
|
-
|
|
41
|
-
- Never bypass unsubscribe, physical address, or consent basis checks.
|
|
42
|
-
- Never send directly from the Play run.
|
|
43
|
-
- Keep lead data tenant-scoped.
|
|
44
|
-
- Write campaign artifacts through content-store.
|
package/src/cli.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { OutreachEngine, readOutreachEngineDebug } from "./index";
|
|
2
|
-
|
|
3
|
-
const command = process.argv[2] ?? "doctor";
|
|
4
|
-
const root = process.env.OUTREACH_ENGINE_ROOT ?? ".nebutra/outreach-engine";
|
|
5
|
-
const tenantId = process.env.NEBUTRA_TENANT_ID ?? "local";
|
|
6
|
-
|
|
7
|
-
if (command === "doctor") {
|
|
8
|
-
const engine = await OutreachEngine.open(root, { tenantId });
|
|
9
|
-
try {
|
|
10
|
-
process.stdout.write(`${JSON.stringify(await engine.doctor(), null, 2)}\n`);
|
|
11
|
-
} finally {
|
|
12
|
-
await engine.close();
|
|
13
|
-
}
|
|
14
|
-
} else if (command === "quickstart") {
|
|
15
|
-
const engine = await OutreachEngine.open(root, { tenantId });
|
|
16
|
-
try {
|
|
17
|
-
process.stdout.write(
|
|
18
|
-
`${JSON.stringify(
|
|
19
|
-
await engine.createCampaign({
|
|
20
|
-
tenantId,
|
|
21
|
-
icpDescription:
|
|
22
|
-
process.argv.slice(3).join(" ") ||
|
|
23
|
-
"decision makers at mid-size D2C e-commerce companies",
|
|
24
|
-
targetCount: 10,
|
|
25
|
-
product: "Loop helps teams debug production issues",
|
|
26
|
-
sequenceLength: 3,
|
|
27
|
-
sendPerDay: 5,
|
|
28
|
-
senderEmails: ["founder@loop.test"],
|
|
29
|
-
complianceProfile: {
|
|
30
|
-
physicalAddress: "123 Market St, San Francisco, CA",
|
|
31
|
-
unsubscribeUrl: "https://loop.test/unsubscribe",
|
|
32
|
-
gdprBasis: "legitimate_interest",
|
|
33
|
-
},
|
|
34
|
-
}),
|
|
35
|
-
null,
|
|
36
|
-
2,
|
|
37
|
-
)}\n`,
|
|
38
|
-
);
|
|
39
|
-
} finally {
|
|
40
|
-
await engine.close();
|
|
41
|
-
}
|
|
42
|
-
} else if (command === "debug") {
|
|
43
|
-
process.stdout.write(
|
|
44
|
-
`${JSON.stringify({ capability: "outreach-engine", entries: await readOutreachEngineDebug() }, null, 2)}\n`,
|
|
45
|
-
);
|
|
46
|
-
} else {
|
|
47
|
-
process.stderr.write(`Unknown outreach-engine command: ${command}\n`);
|
|
48
|
-
process.exitCode = 1;
|
|
49
|
-
}
|
package/src/index.test.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { parsePlayMarkdown } from "@nebutra/play-loader";
|
|
5
|
-
import { afterEach, describe, expect, it } from "vitest";
|
|
6
|
-
import {
|
|
7
|
-
buildEmailSequence,
|
|
8
|
-
checkEmailCompliance,
|
|
9
|
-
defineIcp,
|
|
10
|
-
OutreachEngine,
|
|
11
|
-
readOutreachEngineDebug,
|
|
12
|
-
} from "./index";
|
|
13
|
-
|
|
14
|
-
let root: string | undefined;
|
|
15
|
-
let engine: OutreachEngine | undefined;
|
|
16
|
-
|
|
17
|
-
afterEach(async () => {
|
|
18
|
-
if (engine) await engine.close();
|
|
19
|
-
if (root) await rm(root, { recursive: true, force: true });
|
|
20
|
-
root = undefined;
|
|
21
|
-
engine = undefined;
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
async function open(): Promise<OutreachEngine> {
|
|
25
|
-
root = await mkdtemp(join(tmpdir(), "outreach-engine-"));
|
|
26
|
-
engine = await OutreachEngine.open(root, { tenantId: "tenant_a" });
|
|
27
|
-
return engine;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
describe("outreach-engine", () => {
|
|
31
|
-
it("turns fuzzy ICP language into a structured targeting plan", () => {
|
|
32
|
-
const icp = defineIcp("decision makers at mid-size D2C e-commerce companies in the US");
|
|
33
|
-
|
|
34
|
-
expect(icp.industries).toContain("e-commerce");
|
|
35
|
-
expect(icp.companySize).toEqual({ min: 50, max: 500 });
|
|
36
|
-
expect(icp.titles).toContain("Head of Growth");
|
|
37
|
-
expect(icp.geo).toContain("US");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("builds compliance-gated email variants with unsubscribe requirements", () => {
|
|
41
|
-
const sequence = buildEmailSequence({
|
|
42
|
-
product: "Loop helps indie devs debug production issues",
|
|
43
|
-
sequenceLength: 3,
|
|
44
|
-
brandVoice: ["technical", "warm"],
|
|
45
|
-
});
|
|
46
|
-
const compliance = checkEmailCompliance(sequence[0], {
|
|
47
|
-
physicalAddress: "123 Market St, San Francisco, CA",
|
|
48
|
-
unsubscribeUrl: "https://loop.test/unsubscribe",
|
|
49
|
-
gdprBasis: "legitimate_interest",
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
expect(sequence).toHaveLength(3);
|
|
53
|
-
expect(sequence[0]?.body).toContain("unsubscribe");
|
|
54
|
-
expect(compliance.ok).toBe(true);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("runs outreach_campaign as a draft with leads, sequence, schedule, and event", async () => {
|
|
58
|
-
const runtime = await open();
|
|
59
|
-
|
|
60
|
-
const campaign = await runtime.createCampaign({
|
|
61
|
-
tenantId: "tenant_a",
|
|
62
|
-
icpDescription: "decision makers at mid-size D2C e-commerce companies",
|
|
63
|
-
targetCount: 12,
|
|
64
|
-
product: "Loop helps teams debug production issues",
|
|
65
|
-
sequenceLength: 3,
|
|
66
|
-
sendPerDay: 4,
|
|
67
|
-
senderEmails: ["founder@loop.test"],
|
|
68
|
-
complianceProfile: {
|
|
69
|
-
physicalAddress: "123 Market St, San Francisco, CA",
|
|
70
|
-
unsubscribeUrl: "https://loop.test/unsubscribe",
|
|
71
|
-
gdprBasis: "legitimate_interest",
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
expect(campaign.play).toBe("outreach_campaign");
|
|
76
|
-
expect(campaign.status).toBe("draft");
|
|
77
|
-
expect(campaign.leads).toHaveLength(12);
|
|
78
|
-
expect(campaign.sequence).toHaveLength(3);
|
|
79
|
-
expect(campaign.schedule.dailyLimit).toBe(4);
|
|
80
|
-
expect(campaign.compliance.ok).toBe(true);
|
|
81
|
-
expect(campaign.eventId).toEqual(expect.any(String));
|
|
82
|
-
await expect(readOutreachEngineDebug(root)).resolves.toEqual(expect.any(Array));
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("rejects persistent campaign creation without tenant context", async () => {
|
|
86
|
-
const runtime = await open();
|
|
87
|
-
|
|
88
|
-
await expect(
|
|
89
|
-
runtime.createCampaign({
|
|
90
|
-
tenantId: "",
|
|
91
|
-
icpDescription: "SaaS CTOs",
|
|
92
|
-
targetCount: 5,
|
|
93
|
-
product: "Loop",
|
|
94
|
-
sequenceLength: 2,
|
|
95
|
-
sendPerDay: 2,
|
|
96
|
-
senderEmails: ["founder@loop.test"],
|
|
97
|
-
complianceProfile: {
|
|
98
|
-
physicalAddress: "123 Market St",
|
|
99
|
-
unsubscribeUrl: "https://loop.test/unsubscribe",
|
|
100
|
-
gdprBasis: "legitimate_interest",
|
|
101
|
-
},
|
|
102
|
-
}),
|
|
103
|
-
).rejects.toMatchObject({
|
|
104
|
-
capability: "outreach-engine",
|
|
105
|
-
suggestion: expect.stringContaining("tenantId"),
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("keeps the outreach campaign as SKILL.md instead of a new workflow format", async () => {
|
|
110
|
-
const skill = await readFile(
|
|
111
|
-
join(process.cwd(), "plays", "outreach_campaign", "SKILL.md"),
|
|
112
|
-
"utf8",
|
|
113
|
-
);
|
|
114
|
-
const play = parsePlayMarkdown(skill);
|
|
115
|
-
|
|
116
|
-
expect(play.meta).toMatchObject({ name: "outreach_campaign", kind: "play" });
|
|
117
|
-
expect(play.requiredSkills).toContain("content_store.write");
|
|
118
|
-
expect(play.subAgents.map((agent) => agent.role)).toContain("lead_researcher");
|
|
119
|
-
});
|
|
120
|
-
});
|