@nebutra/outreach-engine 0.1.1 → 0.1.2
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/.nebutra/debug/content-store.jsonl +3 -3
- package/.nebutra/debug/event-log.jsonl +1 -1
- package/.nebutra/debug/outreach-engine.jsonl +1 -1
- package/.turbo/turbo-build.log +5 -5
- package/.turbo/turbo-test.log +5 -6
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +14 -0
- package/dist/{chunk-ZH5KSGRI.js → chunk-IY3N4YTP.js} +10 -12
- package/dist/chunk-IY3N4YTP.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +7 -7
- package/src/index.ts +10 -12
- package/dist/chunk-ZH5KSGRI.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{"at":"2026-05-
|
|
2
|
-
{"at":"2026-05-
|
|
3
|
-
{"at":"2026-05-
|
|
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 +1 @@
|
|
|
1
|
-
{"traceId":"
|
|
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 +1 @@
|
|
|
1
|
-
{"at":"2026-05-
|
|
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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @nebutra/outreach-engine@0.1.
|
|
2
|
+
> @nebutra/outreach-engine@0.1.2 build /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/outreach-engine
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/cli.ts, src/index.ts
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[32mESM[39m [1mdist/cli.js [22m[32m1.61 KB[39m
|
|
13
13
|
[32mESM[39m [1mdist/index.js [22m[32m290.00 B[39m
|
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
|
14
|
+
[32mESM[39m [1mdist/chunk-IY3N4YTP.js [22m[32m6.72 KB[39m
|
|
15
15
|
[32mESM[39m [1mdist/cli.js.map [22m[32m2.75 KB[39m
|
|
16
16
|
[32mESM[39m [1mdist/index.js.map [22m[32m71.00 B[39m
|
|
17
|
-
[32mESM[39m [1mdist/chunk-
|
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
|
17
|
+
[32mESM[39m [1mdist/chunk-IY3N4YTP.js.map [22m[32m14.97 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 76ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 10096ms
|
|
21
21
|
[32mDTS[39m [1mdist/cli.d.ts [22m[32m13.00 B[39m
|
|
22
22
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.69 KB[39m
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
> @nebutra/outreach-engine@0.1.
|
|
2
|
+
> @nebutra/outreach-engine@0.1.2 test /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/outreach-engine
|
|
3
3
|
> vitest run
|
|
4
4
|
|
|
5
5
|
|
|
6
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
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
[32m✓[39m src/index.test.ts [2m([22m[2m5 tests[22m[2m)[22m[33m 421[2mms[22m[39m
|
|
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
|
|
11
10
|
|
|
12
11
|
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
13
12
|
[2m Tests [22m [1m[32m5 passed[39m[22m[90m (5)[39m
|
|
14
|
-
[2m Start at [22m
|
|
15
|
-
[2m Duration [22m
|
|
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
|
|
16
15
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @nebutra/outreach-engine
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Publish registry package metadata under the MIT license.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @nebutra/capability-kit@0.2.1
|
|
11
|
+
- @nebutra/content-store@0.1.1
|
|
12
|
+
- @nebutra/errors@0.1.1
|
|
13
|
+
- @nebutra/event-log@0.1.1
|
|
14
|
+
- @nebutra/generation-context@0.1.1
|
|
15
|
+
- @nebutra/play-loader@0.1.1
|
|
16
|
+
|
|
3
17
|
## 0.1.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { mkdir } from "fs/promises";
|
|
3
3
|
import { dirname, join } from "path";
|
|
4
|
+
import { requireCapabilityTenant } from "@nebutra/capability-kit";
|
|
4
5
|
import { appendCapabilityDebug, readCapabilityDebug } from "@nebutra/capability-kit/debug";
|
|
5
6
|
import { ContentStore } from "@nebutra/content-store";
|
|
6
7
|
import { CapabilityError } from "@nebutra/errors";
|
|
7
8
|
import { EventLog } from "@nebutra/event-log";
|
|
8
9
|
import { assetId } from "@nebutra/generation-context";
|
|
9
|
-
function requireTenant(explicit, fallback) {
|
|
10
|
-
const tenantId = explicit ?? fallback;
|
|
11
|
-
if (!tenantId?.trim()) {
|
|
12
|
-
throw new CapabilityError("outreach-engine", "Outreach Engine requires tenant context", {
|
|
13
|
-
suggestion: "Pass tenantId before creating or persisting a campaign.",
|
|
14
|
-
statusCode: 400
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return tenantId;
|
|
18
|
-
}
|
|
19
10
|
function slug(value) {
|
|
20
11
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 48);
|
|
21
12
|
}
|
|
@@ -95,7 +86,14 @@ var OutreachEngine = class _OutreachEngine {
|
|
|
95
86
|
return new _OutreachEngine({ ...options, tenantId, root, contentStore, eventLog });
|
|
96
87
|
}
|
|
97
88
|
async createCampaign(input) {
|
|
98
|
-
const tenantId =
|
|
89
|
+
const tenantId = requireCapabilityTenant({
|
|
90
|
+
explicit: input.tenantId,
|
|
91
|
+
fallback: this.#tenantId,
|
|
92
|
+
onMissing: () => new CapabilityError("outreach-engine", "Outreach Engine requires tenant context", {
|
|
93
|
+
suggestion: "Pass tenantId before creating or persisting a campaign.",
|
|
94
|
+
statusCode: 400
|
|
95
|
+
})
|
|
96
|
+
});
|
|
99
97
|
const icp = defineIcp(input.icpDescription);
|
|
100
98
|
const sequence = buildEmailSequence({
|
|
101
99
|
product: input.product,
|
|
@@ -186,4 +184,4 @@ export {
|
|
|
186
184
|
OutreachEngine,
|
|
187
185
|
readOutreachEngineDebug
|
|
188
186
|
};
|
|
189
|
-
//# sourceMappingURL=chunk-
|
|
187
|
+
//# sourceMappingURL=chunk-IY3N4YTP.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 .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,SA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
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebutra/outreach-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Compliance-first outreach campaign Play package for founder-led sales workflows",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
".": "./src/index.ts"
|
|
30
30
|
},
|
|
31
31
|
"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.
|
|
32
|
+
"@nebutra/capability-kit": "0.2.1",
|
|
33
|
+
"@nebutra/content-store": "0.1.1",
|
|
34
|
+
"@nebutra/errors": "0.1.1",
|
|
35
|
+
"@nebutra/event-log": "0.1.1",
|
|
36
|
+
"@nebutra/generation-context": "0.1.1",
|
|
37
|
+
"@nebutra/play-loader": "0.1.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^22.19.15",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mkdir } from "node:fs/promises";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
|
+
import { requireCapabilityTenant } from "@nebutra/capability-kit";
|
|
3
4
|
import { appendCapabilityDebug, readCapabilityDebug } from "@nebutra/capability-kit/debug";
|
|
4
5
|
import { ContentStore } from "@nebutra/content-store";
|
|
5
6
|
import { CapabilityError } from "@nebutra/errors";
|
|
@@ -98,17 +99,6 @@ export interface OutreachEngineOptions {
|
|
|
98
99
|
readonly eventLog?: EventLog;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
function requireTenant(explicit: string | undefined, fallback: string | undefined): string {
|
|
102
|
-
const tenantId = explicit ?? fallback;
|
|
103
|
-
if (!tenantId?.trim()) {
|
|
104
|
-
throw new CapabilityError("outreach-engine", "Outreach Engine requires tenant context", {
|
|
105
|
-
suggestion: "Pass tenantId before creating or persisting a campaign.",
|
|
106
|
-
statusCode: 400,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
return tenantId;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
102
|
function slug(value: string): string {
|
|
113
103
|
return value
|
|
114
104
|
.toLowerCase()
|
|
@@ -223,7 +213,15 @@ export class OutreachEngine {
|
|
|
223
213
|
}
|
|
224
214
|
|
|
225
215
|
async createCampaign(input: CampaignInput): Promise<CampaignPackage> {
|
|
226
|
-
const tenantId =
|
|
216
|
+
const tenantId = requireCapabilityTenant({
|
|
217
|
+
explicit: input.tenantId,
|
|
218
|
+
fallback: this.#tenantId,
|
|
219
|
+
onMissing: () =>
|
|
220
|
+
new CapabilityError("outreach-engine", "Outreach Engine requires tenant context", {
|
|
221
|
+
suggestion: "Pass tenantId before creating or persisting a campaign.",
|
|
222
|
+
statusCode: 400,
|
|
223
|
+
}),
|
|
224
|
+
});
|
|
227
225
|
const icp = defineIcp(input.icpDescription);
|
|
228
226
|
const sequence = buildEmailSequence({
|
|
229
227
|
product: input.product,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { mkdir } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\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 requireTenant(explicit: string | undefined, fallback: string | undefined): string {\n const tenantId = explicit ?? fallback;\n if (!tenantId?.trim()) {\n throw 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 return tenantId;\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 = requireTenant(input.tenantId, this.#tenantId);\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,uBAAuB,2BAA2B;AAC3D,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,eAAe;AA8FxB,SAAS,cAAc,UAA8B,UAAsC;AACzF,QAAM,WAAW,YAAY;AAC7B,MAAI,CAAC,UAAU,KAAK,GAAG;AACrB,UAAM,IAAI,gBAAgB,mBAAmB,2CAA2C;AAAA,MACtF,YAAY;AAAA,MACZ,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,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,IAC9B,CAAC,OAAO,kBAAkB,qBAAqB,IAC/C,CAAC,gBAAgB,kBAAkB,KAAK;AAC5C,QAAM,cACJ,KAAK,SAAS,UAAU,KAAK,KAAK,SAAS,QAAQ,IAC/C,EAAE,KAAK,IAAI,KAAK,IAAI,IACpB,EAAE,KAAK,GAAG,KAAK,GAAG;AACxB,QAAM,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK,SAAS,IAAI,IAA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