@datasynx/agentic-crm 0.1.0
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/LICENSE +21 -0
- package/README.md +767 -0
- package/dist/agent-config-zPvcqu07.js +14 -0
- package/dist/agent-config-zPvcqu07.js.map +1 -0
- package/dist/approvals-DpjxGHFp.js +67 -0
- package/dist/approvals-DpjxGHFp.js.map +1 -0
- package/dist/ask-CID3jnuL.js +52 -0
- package/dist/ask-CID3jnuL.js.map +1 -0
- package/dist/audit-log-DNMY9mUZ.js +49 -0
- package/dist/audit-log-DNMY9mUZ.js.map +1 -0
- package/dist/auth-CyFuu9X_.js +2 -0
- package/dist/auth-DFWwWcYD.js +93 -0
- package/dist/auth-DFWwWcYD.js.map +1 -0
- package/dist/autofill-Di_-SP7t.js +51 -0
- package/dist/autofill-Di_-SP7t.js.map +1 -0
- package/dist/backup-CeMk9z86.js +417 -0
- package/dist/backup-CeMk9z86.js.map +1 -0
- package/dist/backup-f_hC7rBV.js +2 -0
- package/dist/calendly-Bft_wwji.js +52 -0
- package/dist/calendly-Bft_wwji.js.map +1 -0
- package/dist/calendly-D3coO92o.cjs +53 -0
- package/dist/calendly-D3coO92o.cjs.map +1 -0
- package/dist/chunk-DakpK96I.cjs +43 -0
- package/dist/churn-C28IgnAj.js +54 -0
- package/dist/churn-C28IgnAj.js.map +1 -0
- package/dist/cli.js +4396 -0
- package/dist/cli.js.map +1 -0
- package/dist/colors-BG07TZQz.js +11 -0
- package/dist/colors-BG07TZQz.js.map +1 -0
- package/dist/compliance-B1kk5-YS.js +115 -0
- package/dist/compliance-B1kk5-YS.js.map +1 -0
- package/dist/compliance-B91zNvCR.cjs +156 -0
- package/dist/compliance-B91zNvCR.cjs.map +1 -0
- package/dist/compliance-CKSBoQUe.js +118 -0
- package/dist/compliance-CKSBoQUe.js.map +1 -0
- package/dist/compliance-CujOqAKk.js +2 -0
- package/dist/context-builder-BzWAp3Zs.js +96 -0
- package/dist/context-builder-BzWAp3Zs.js.map +1 -0
- package/dist/context-builder-DlrRcqmJ.js +2 -0
- package/dist/conversation-intel-mm7Lhemh.js +72 -0
- package/dist/conversation-intel-mm7Lhemh.js.map +1 -0
- package/dist/custom-fields-CzNeD3_v.js +2 -0
- package/dist/custom-fields-Pl2t9xzp.js +73 -0
- package/dist/custom-fields-Pl2t9xzp.js.map +1 -0
- package/dist/custom-objects-BHgn1GEX.js +78 -0
- package/dist/custom-objects-BHgn1GEX.js.map +1 -0
- package/dist/custom-objects-CIFrmQ2V.js +2 -0
- package/dist/customer-dir-DIylZ8Q6.js +75 -0
- package/dist/customer-dir-DIylZ8Q6.js.map +1 -0
- package/dist/daemon/worker.js +207 -0
- package/dist/daemon/worker.js.map +1 -0
- package/dist/enrichment-3XvgGDfB.js +103 -0
- package/dist/enrichment-3XvgGDfB.js.map +1 -0
- package/dist/file-lock-B_zi7NQl.js +22 -0
- package/dist/file-lock-B_zi7NQl.js.map +1 -0
- package/dist/gmail-auth-BP6cJwfw.js +40 -0
- package/dist/gmail-auth-BP6cJwfw.js.map +1 -0
- package/dist/gmail-auth-DxakCtGm.cjs +44 -0
- package/dist/gmail-auth-DxakCtGm.cjs.map +1 -0
- package/dist/gmail-auth-OComS92L.js +40 -0
- package/dist/gmail-auth-OComS92L.js.map +1 -0
- package/dist/gmail-push-watch-DELQFMPk.js +20 -0
- package/dist/gmail-push-watch-DELQFMPk.js.map +1 -0
- package/dist/gmail-sender-StTpJ9Ub.js +32 -0
- package/dist/gmail-sender-StTpJ9Ub.js.map +1 -0
- package/dist/gmail-sync-DIaxInDT.js +204 -0
- package/dist/gmail-sync-DIaxInDT.js.map +1 -0
- package/dist/gmail-sync-hHm9gaWd.cjs +218 -0
- package/dist/gmail-sync-hHm9gaWd.cjs.map +1 -0
- package/dist/gmail-sync-rQaVqKWd.js +214 -0
- package/dist/gmail-sync-rQaVqKWd.js.map +1 -0
- package/dist/gmail-webhook-handler-DS7OlRPX.js +3 -0
- package/dist/gmail-webhook-handler-e5Od25FX.js +97 -0
- package/dist/gmail-webhook-handler-e5Od25FX.js.map +1 -0
- package/dist/goal-engine-CUZSpERI.js +2 -0
- package/dist/goal-engine-KpBftn4V.js +295 -0
- package/dist/goal-engine-KpBftn4V.js.map +1 -0
- package/dist/google-drive-sync-DEPcqFca.js +105 -0
- package/dist/google-drive-sync-DEPcqFca.js.map +1 -0
- package/dist/hybrid-search-BmHttLrR.js +40 -0
- package/dist/hybrid-search-BmHttLrR.js.map +1 -0
- package/dist/hygiene-DZqfYpFf.js +38 -0
- package/dist/hygiene-DZqfYpFf.js.map +1 -0
- package/dist/identity-CI6olMNm.js +41 -0
- package/dist/identity-CI6olMNm.js.map +1 -0
- package/dist/identity-gyfWdrcX.js +2 -0
- package/dist/import-hubspot-BaK71U_K.js +588 -0
- package/dist/import-hubspot-BaK71U_K.js.map +1 -0
- package/dist/index-V8BFaH-b.d.ts +539 -0
- package/dist/index-V8BFaH-b.d.ts.map +1 -0
- package/dist/index-YqwMd6aQ.d.cts +538 -0
- package/dist/index-YqwMd6aQ.d.cts.map +1 -0
- package/dist/index.cjs +185 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +538 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +539 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +165 -0
- package/dist/index.js.map +1 -0
- package/dist/interactions-writer-CrPStUll.cjs +77 -0
- package/dist/interactions-writer-CrPStUll.cjs.map +1 -0
- package/dist/interactions-writer-DO3KcSR3.js +52 -0
- package/dist/interactions-writer-DO3KcSR3.js.map +1 -0
- package/dist/interactions-writer-SLHnoEeE.js +46 -0
- package/dist/interactions-writer-SLHnoEeE.js.map +1 -0
- package/dist/interactions-writer-dSPy1XfO.js +2 -0
- package/dist/knowledge-base-D0Fh40kc.js +1013 -0
- package/dist/knowledge-base-D0Fh40kc.js.map +1 -0
- package/dist/lancedb-CCBbpulq.js +2 -0
- package/dist/lancedb-rlvWoPwl.js +98 -0
- package/dist/lancedb-rlvWoPwl.js.map +1 -0
- package/dist/lead-model-BCFzyktm.js +109 -0
- package/dist/lead-model-BCFzyktm.js.map +1 -0
- package/dist/llm-DEjWcqmW.js +2 -0
- package/dist/llm-DvzZqva0.js +372 -0
- package/dist/llm-DvzZqva0.js.map +1 -0
- package/dist/llm-Z8RIYkpF.js +174 -0
- package/dist/llm-Z8RIYkpF.js.map +1 -0
- package/dist/llm-iijeXmgq.cjs +198 -0
- package/dist/llm-iijeXmgq.cjs.map +1 -0
- package/dist/mcp-CdTJWTJf.d.cts +12 -0
- package/dist/mcp-CdTJWTJf.d.cts.map +1 -0
- package/dist/mcp-CdTJWTJf.d.ts +12 -0
- package/dist/mcp-CdTJWTJf.d.ts.map +1 -0
- package/dist/mcp.cjs +7464 -0
- package/dist/mcp.cjs.map +1 -0
- package/dist/mcp.d.cts +12 -0
- package/dist/mcp.d.cts.map +1 -0
- package/dist/mcp.d.ts +12 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +7448 -0
- package/dist/mcp.js.map +1 -0
- package/dist/memory-Bb6ky3kb.js +58 -0
- package/dist/memory-Bb6ky3kb.js.map +1 -0
- package/dist/memory-Cy6-Tbyl.js +2 -0
- package/dist/metrics-DH8wHvya.js +26 -0
- package/dist/metrics-DH8wHvya.js.map +1 -0
- package/dist/microsoft-auth-B8_S45gh.js +17 -0
- package/dist/microsoft-auth-B8_S45gh.js.map +1 -0
- package/dist/microsoft-calendar-B6MMtUQK.js +67 -0
- package/dist/microsoft-calendar-B6MMtUQK.js.map +1 -0
- package/dist/microsoft-sync-CpZVoSuq.js +68 -0
- package/dist/microsoft-sync-CpZVoSuq.js.map +1 -0
- package/dist/nba-3wanmJ0U.js +48 -0
- package/dist/nba-3wanmJ0U.js.map +1 -0
- package/dist/notification-dispatcher-0vYNngWe.js +97 -0
- package/dist/notification-dispatcher-0vYNngWe.js.map +1 -0
- package/dist/opportunity-score-BTMOQSTV.js +47 -0
- package/dist/opportunity-score-BTMOQSTV.js.map +1 -0
- package/dist/pipedrive-client-CdGKpH9b.js +17 -0
- package/dist/pipedrive-client-CdGKpH9b.js.map +1 -0
- package/dist/pipeline-writer-BqBrYrQc.js +2 -0
- package/dist/pipeline-writer-BvVquKIe.js +96 -0
- package/dist/pipeline-writer-BvVquKIe.js.map +1 -0
- package/dist/pipeline-writer-N2omexxp.cjs +121 -0
- package/dist/pipeline-writer-N2omexxp.cjs.map +1 -0
- package/dist/pipeline-writer-eufx_0o1.js +102 -0
- package/dist/pipeline-writer-eufx_0o1.js.map +1 -0
- package/dist/proactive-agent-BgQXw3ac.js +96 -0
- package/dist/proactive-agent-BgQXw3ac.js.map +1 -0
- package/dist/proactive-worker-BrLHNhjH.js +229 -0
- package/dist/proactive-worker-BrLHNhjH.js.map +1 -0
- package/dist/push-manager-CdqIIkuh.js +108 -0
- package/dist/push-manager-CdqIIkuh.js.map +1 -0
- package/dist/push-manager-CowY-0IK.js +2 -0
- package/dist/quote-generator-BfwENXzg.js +133 -0
- package/dist/quote-generator-BfwENXzg.js.map +1 -0
- package/dist/quote-generator-OhSFsi3x.js +2 -0
- package/dist/rbac-C7c8tcES.js +2 -0
- package/dist/rbac-CTIktZaC.js +91 -0
- package/dist/rbac-CTIktZaC.js.map +1 -0
- package/dist/relationship-health-odxEoQdJ.js +454 -0
- package/dist/relationship-health-odxEoQdJ.js.map +1 -0
- package/dist/revenue-simulation-BJdRTEHc.js +2 -0
- package/dist/revenue-simulation-Bqf2DLVB.js +251 -0
- package/dist/revenue-simulation-Bqf2DLVB.js.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/salesforce-client-rhZFa_p5.js +51 -0
- package/dist/salesforce-client-rhZFa_p5.js.map +1 -0
- package/dist/segments-BqcD5HIl.js +61 -0
- package/dist/segments-BqcD5HIl.js.map +1 -0
- package/dist/sequence-engine-CCTHEBgi.js +2 -0
- package/dist/sequence-engine-J1lTW_in.js +91 -0
- package/dist/sequence-engine-J1lTW_in.js.map +1 -0
- package/dist/sequence-store-DaaWr0Os.js +221 -0
- package/dist/sequence-store-DaaWr0Os.js.map +1 -0
- package/dist/server-Dyva03K8.js +4287 -0
- package/dist/server-Dyva03K8.js.map +1 -0
- package/dist/session-B9AilxOE.js +81 -0
- package/dist/session-B9AilxOE.js.map +1 -0
- package/dist/session-D0qFkBla.cjs +82 -0
- package/dist/session-D0qFkBla.cjs.map +1 -0
- package/dist/session-D9ub6Wl1.js +79 -0
- package/dist/session-D9ub6Wl1.js.map +1 -0
- package/dist/session-mWHA71Lw.js +2 -0
- package/dist/session-store-B0QZE8Bx.cjs +697 -0
- package/dist/session-store-B0QZE8Bx.cjs.map +1 -0
- package/dist/session-store-C8tEvMPw.js +543 -0
- package/dist/session-store-C8tEvMPw.js.map +1 -0
- package/dist/session-store-CEa39Dxs.js +15 -0
- package/dist/session-store-CEa39Dxs.js.map +1 -0
- package/dist/sla-engine-5IhTsBUR.js +2 -0
- package/dist/sla-engine-BqX-7u-7.js +53 -0
- package/dist/sla-engine-BqX-7u-7.js.map +1 -0
- package/dist/sop-DkhVChGy.js +2 -0
- package/dist/sop-Vp0UPWFW.js +70 -0
- package/dist/sop-Vp0UPWFW.js.map +1 -0
- package/dist/survey-engine-C06hcQt3.js +2 -0
- package/dist/survey-engine-DBjCYqCv.js +147 -0
- package/dist/survey-engine-DBjCYqCv.js.map +1 -0
- package/dist/sync-state-ChaLbamC.js +33 -0
- package/dist/sync-state-ChaLbamC.js.map +1 -0
- package/dist/sync-state-CwLSt_1m.js +2 -0
- package/dist/ticket-writer-CjqKeIRD.js +2 -0
- package/dist/ticket-writer-j2oX_Wal.js +134 -0
- package/dist/ticket-writer-j2oX_Wal.js.map +1 -0
- package/dist/tone-Bdm5uaht.js +48 -0
- package/dist/tone-Bdm5uaht.js.map +1 -0
- package/dist/tone-DRKlZgPr.cjs +43 -0
- package/dist/tone-DRKlZgPr.cjs.map +1 -0
- package/dist/tone-vNb2DAAD.js +39 -0
- package/dist/tone-vNb2DAAD.js.map +1 -0
- package/dist/transcript-watcher-CL2QUygI.js +132 -0
- package/dist/transcript-watcher-CL2QUygI.js.map +1 -0
- package/dist/unmatched-transcripts-BsH5bhkU.js +26 -0
- package/dist/unmatched-transcripts-BsH5bhkU.js.map +1 -0
- package/dist/unmatched-transcripts-D0PrJ9iz.js +2 -0
- package/dist/update-deal-BNwPGaTV.js +2 -0
- package/dist/update-deal-DKC79skb.js +91 -0
- package/dist/update-deal-DKC79skb.js.map +1 -0
- package/dist/usage-CClTf5e6.cjs +57 -0
- package/dist/usage-CClTf5e6.cjs.map +1 -0
- package/dist/usage-D0-TYJkw.js +93 -0
- package/dist/usage-D0-TYJkw.js.map +1 -0
- package/dist/usage-D0u9a-lV.js +54 -0
- package/dist/usage-D0u9a-lV.js.map +1 -0
- package/dist/vault-C1D3zScD.js +2 -0
- package/dist/vault-DXCg29W-.js +86 -0
- package/dist/vault-DXCg29W-.js.map +1 -0
- package/dist/webhooks-7EpA05Qr.js +138 -0
- package/dist/webhooks-7EpA05Qr.js.map +1 -0
- package/dist/webhooks-BO2UAnmn.js +94 -0
- package/dist/webhooks-BO2UAnmn.js.map +1 -0
- package/dist/webhooks-Xn6zO6kd.cjs +97 -0
- package/dist/webhooks-Xn6zO6kd.cjs.map +1 -0
- package/dist/write-queue-BDolUxfs.cjs +26 -0
- package/dist/write-queue-BDolUxfs.cjs.map +1 -0
- package/dist/write-queue-IbsAjUnh.js +21 -0
- package/dist/write-queue-IbsAjUnh.js.map +1 -0
- package/package.json +142 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-DakpK96I.cjs");
|
|
2
|
+
let path = require("path");
|
|
3
|
+
path = require_chunk.__toESM(path, 1);
|
|
4
|
+
let fs = require("fs");
|
|
5
|
+
fs = require_chunk.__toESM(fs, 1);
|
|
6
|
+
let crypto = require("crypto");
|
|
7
|
+
//#region src/core/webhooks.ts
|
|
8
|
+
function subsPath(dataDir) {
|
|
9
|
+
return path.default.join(dataDir, ".agentic", "webhooks.json");
|
|
10
|
+
}
|
|
11
|
+
function failuresPath(dataDir) {
|
|
12
|
+
return path.default.join(dataDir, ".agentic", "webhook-failures.json");
|
|
13
|
+
}
|
|
14
|
+
function readJson(p, key) {
|
|
15
|
+
if (!fs.default.existsSync(p)) return [];
|
|
16
|
+
try {
|
|
17
|
+
const data = JSON.parse(fs.default.readFileSync(p, "utf-8"));
|
|
18
|
+
return Array.isArray(data[key]) ? data[key] : [];
|
|
19
|
+
} catch {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function writeJson(p, key, items) {
|
|
24
|
+
fs.default.mkdirSync(path.default.dirname(p), { recursive: true });
|
|
25
|
+
fs.default.writeFileSync(p, JSON.stringify({ [key]: items }, null, 2), "utf-8");
|
|
26
|
+
}
|
|
27
|
+
function loadWebhooks(dataDir) {
|
|
28
|
+
return readJson(subsPath(dataDir), "subscriptions");
|
|
29
|
+
}
|
|
30
|
+
/** A subscription matches an event by exact name, "*", or a "prefix.*" pattern. */
|
|
31
|
+
function matchSubscriptions(subs, event) {
|
|
32
|
+
return subs.filter((s) => s.events.some((pat) => {
|
|
33
|
+
if (pat === "*" || pat === event) return true;
|
|
34
|
+
if (pat.endsWith(".*")) return event.startsWith(pat.slice(0, -1));
|
|
35
|
+
return false;
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
function signPayload(secret, body) {
|
|
39
|
+
return (0, crypto.createHmac)("sha256", secret).update(body).digest("hex");
|
|
40
|
+
}
|
|
41
|
+
function loadFailures(dataDir) {
|
|
42
|
+
return readJson(failuresPath(dataDir), "failures");
|
|
43
|
+
}
|
|
44
|
+
async function deliver(sub, event, payload) {
|
|
45
|
+
const body = JSON.stringify({
|
|
46
|
+
event,
|
|
47
|
+
payload,
|
|
48
|
+
deliveredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
49
|
+
});
|
|
50
|
+
const headers = {
|
|
51
|
+
"Content-Type": "application/json",
|
|
52
|
+
"X-DXCRM-Event": event
|
|
53
|
+
};
|
|
54
|
+
if (sub.secret) headers["X-DXCRM-Signature"] = `sha256=${signPayload(sub.secret, body)}`;
|
|
55
|
+
try {
|
|
56
|
+
const res = await fetch(sub.url, {
|
|
57
|
+
method: "POST",
|
|
58
|
+
headers,
|
|
59
|
+
body
|
|
60
|
+
});
|
|
61
|
+
if (!res.ok) return {
|
|
62
|
+
ok: false,
|
|
63
|
+
error: `HTTP ${res.status}`
|
|
64
|
+
};
|
|
65
|
+
return { ok: true };
|
|
66
|
+
} catch (err) {
|
|
67
|
+
return {
|
|
68
|
+
ok: false,
|
|
69
|
+
error: err.message
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Emit an event to all matching subscriptions; queue failures for replay. */
|
|
74
|
+
async function emitEvent(dataDir, event, payload) {
|
|
75
|
+
const matched = matchSubscriptions(loadWebhooks(dataDir), event);
|
|
76
|
+
if (matched.length === 0) return;
|
|
77
|
+
const failures = loadFailures(dataDir);
|
|
78
|
+
for (const sub of matched) {
|
|
79
|
+
const r = await deliver(sub, event, payload);
|
|
80
|
+
if (!r.ok) failures.push({
|
|
81
|
+
id: `whf_${(0, crypto.createHash)("sha256").update(`${sub.id}:${event}:${Date.now()}`).digest("hex").slice(0, 10)}`,
|
|
82
|
+
subscriptionId: sub.id,
|
|
83
|
+
url: sub.url,
|
|
84
|
+
...sub.secret ? { secret: sub.secret } : {},
|
|
85
|
+
event,
|
|
86
|
+
payload,
|
|
87
|
+
attempts: 1,
|
|
88
|
+
lastError: r.error ?? "unknown",
|
|
89
|
+
queuedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (failures.length > 0) writeJson(failuresPath(dataDir), "failures", failures);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
exports.emitEvent = emitEvent;
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=webhooks-Xn6zO6kd.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks-Xn6zO6kd.cjs","names":[],"sources":["../src/core/webhooks.ts"],"sourcesContent":["import { createHash, createHmac, randomBytes } from \"crypto\";\nimport fs from \"fs\";\nimport path from \"path\";\n\n/**\n * Outbound webhooks (event-driven architecture, N5-2). Subscriptions live in\n * .agentic/webhooks.json; failed deliveries are queued in\n * .agentic/webhook-failures.json (replay store) and re-attempted by\n * retryFailures (e.g. from the daemon) — backoff via periodic replay.\n */\nexport interface WebhookSubscription {\n id: string;\n url: string;\n events: string[];\n secret?: string;\n createdAt: string;\n}\n\nexport interface WebhookFailure {\n id: string;\n subscriptionId: string;\n url: string;\n secret?: string;\n event: string;\n payload: unknown;\n attempts: number;\n lastError: string;\n queuedAt: string;\n}\n\nfunction subsPath(dataDir: string): string {\n return path.join(dataDir, \".agentic\", \"webhooks.json\");\n}\nfunction failuresPath(dataDir: string): string {\n return path.join(dataDir, \".agentic\", \"webhook-failures.json\");\n}\n\nfunction readJson<T>(p: string, key: string): T[] {\n if (!fs.existsSync(p)) return [];\n try {\n const data = JSON.parse(fs.readFileSync(p, \"utf-8\") as string) as Record<string, T[]>;\n return Array.isArray(data[key]) ? data[key]! : [];\n } catch {\n return [];\n }\n}\nfunction writeJson<T>(p: string, key: string, items: T[]): void {\n fs.mkdirSync(path.dirname(p), { recursive: true });\n fs.writeFileSync(p, JSON.stringify({ [key]: items }, null, 2), \"utf-8\");\n}\n\nexport function loadWebhooks(dataDir: string): WebhookSubscription[] {\n return readJson<WebhookSubscription>(subsPath(dataDir), \"subscriptions\");\n}\n\nexport function addWebhook(\n dataDir: string,\n url: string,\n events: string[],\n secret?: string\n): WebhookSubscription {\n const sub: WebhookSubscription = {\n id: `wh_${randomBytes(5).toString(\"hex\")}`,\n url,\n events,\n ...(secret ? { secret } : {}),\n createdAt: new Date().toISOString(),\n };\n writeJson(subsPath(dataDir), \"subscriptions\", [...loadWebhooks(dataDir), sub]);\n return sub;\n}\n\nexport function removeWebhook(dataDir: string, id: string): boolean {\n const subs = loadWebhooks(dataDir);\n const next = subs.filter((s) => s.id !== id);\n if (next.length === subs.length) return false;\n writeJson(subsPath(dataDir), \"subscriptions\", next);\n return true;\n}\n\n/** A subscription matches an event by exact name, \"*\", or a \"prefix.*\" pattern. */\nexport function matchSubscriptions(\n subs: WebhookSubscription[],\n event: string\n): WebhookSubscription[] {\n return subs.filter((s) =>\n s.events.some((pat) => {\n if (pat === \"*\" || pat === event) return true;\n if (pat.endsWith(\".*\")) return event.startsWith(pat.slice(0, -1));\n return false;\n })\n );\n}\n\nexport function signPayload(secret: string, body: string): string {\n return createHmac(\"sha256\", secret).update(body).digest(\"hex\");\n}\n\nexport function loadFailures(dataDir: string): WebhookFailure[] {\n return readJson<WebhookFailure>(failuresPath(dataDir), \"failures\");\n}\n\nasync function deliver(\n sub: WebhookSubscription,\n event: string,\n payload: unknown\n): Promise<{ ok: boolean; error?: string }> {\n const body = JSON.stringify({ event, payload, deliveredAt: new Date().toISOString() });\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"X-DXCRM-Event\": event,\n };\n if (sub.secret) headers[\"X-DXCRM-Signature\"] = `sha256=${signPayload(sub.secret, body)}`;\n try {\n const res = (await fetch(sub.url, { method: \"POST\", headers, body })) as {\n ok: boolean;\n status: number;\n };\n if (!res.ok) return { ok: false, error: `HTTP ${res.status}` };\n return { ok: true };\n } catch (err) {\n return { ok: false, error: (err as Error).message };\n }\n}\n\n/** Emit an event to all matching subscriptions; queue failures for replay. */\nexport async function emitEvent(dataDir: string, event: string, payload: unknown): Promise<void> {\n const matched = matchSubscriptions(loadWebhooks(dataDir), event);\n if (matched.length === 0) return;\n const failures = loadFailures(dataDir);\n for (const sub of matched) {\n const r = await deliver(sub, event, payload);\n if (!r.ok) {\n failures.push({\n id: `whf_${createHash(\"sha256\").update(`${sub.id}:${event}:${Date.now()}`).digest(\"hex\").slice(0, 10)}`,\n subscriptionId: sub.id,\n url: sub.url,\n ...(sub.secret ? { secret: sub.secret } : {}),\n event,\n payload,\n attempts: 1,\n lastError: r.error ?? \"unknown\",\n queuedAt: new Date().toISOString(),\n });\n }\n }\n if (failures.length > 0) writeJson(failuresPath(dataDir), \"failures\", failures);\n}\n\n/** Re-attempt queued failures; remove on success, increment attempts on failure. */\nexport async function retryFailures(\n dataDir: string\n): Promise<{ retried: number; stillFailing: number }> {\n const failures = loadFailures(dataDir);\n const remaining: WebhookFailure[] = [];\n let retried = 0;\n for (const f of failures) {\n const sub: WebhookSubscription = {\n id: f.subscriptionId,\n url: f.url,\n events: [f.event],\n ...(f.secret ? { secret: f.secret } : {}),\n createdAt: f.queuedAt,\n };\n const r = await deliver(sub, f.event, f.payload);\n if (r.ok) retried++;\n else remaining.push({ ...f, attempts: f.attempts + 1, lastError: r.error ?? \"unknown\" });\n }\n writeJson(failuresPath(dataDir), \"failures\", remaining);\n return { retried, stillFailing: remaining.length };\n}\n"],"mappings":";;;;;;;AA8BA,SAAS,SAAS,SAAyB;CACzC,OAAO,KAAA,QAAK,KAAK,SAAS,YAAY,eAAe;AACvD;AACA,SAAS,aAAa,SAAyB;CAC7C,OAAO,KAAA,QAAK,KAAK,SAAS,YAAY,uBAAuB;AAC/D;AAEA,SAAS,SAAY,GAAW,KAAkB;CAChD,IAAI,CAAC,GAAA,QAAG,WAAW,CAAC,GAAG,OAAO,CAAC;CAC/B,IAAI;EACF,MAAM,OAAO,KAAK,MAAM,GAAA,QAAG,aAAa,GAAG,OAAO,CAAW;EAC7D,OAAO,MAAM,QAAQ,KAAK,IAAI,IAAI,KAAK,OAAQ,CAAC;CAClD,QAAQ;EACN,OAAO,CAAC;CACV;AACF;AACA,SAAS,UAAa,GAAW,KAAa,OAAkB;CAC9D,GAAA,QAAG,UAAU,KAAA,QAAK,QAAQ,CAAC,GAAG,EAAE,WAAW,KAAK,CAAC;CACjD,GAAA,QAAG,cAAc,GAAG,KAAK,UAAU,GAAG,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,OAAO;AACxE;AAEA,SAAgB,aAAa,SAAwC;CACnE,OAAO,SAA8B,SAAS,OAAO,GAAG,eAAe;AACzE;;AA4BA,SAAgB,mBACd,MACA,OACuB;CACvB,OAAO,KAAK,QAAQ,MAClB,EAAE,OAAO,MAAM,QAAQ;EACrB,IAAI,QAAQ,OAAO,QAAQ,OAAO,OAAO;EACzC,IAAI,IAAI,SAAS,IAAI,GAAG,OAAO,MAAM,WAAW,IAAI,MAAM,GAAG,EAAE,CAAC;EAChE,OAAO;CACT,CAAC,CACH;AACF;AAEA,SAAgB,YAAY,QAAgB,MAAsB;CAChE,QAAA,GAAA,OAAA,YAAkB,UAAU,MAAM,EAAE,OAAO,IAAI,EAAE,OAAO,KAAK;AAC/D;AAEA,SAAgB,aAAa,SAAmC;CAC9D,OAAO,SAAyB,aAAa,OAAO,GAAG,UAAU;AACnE;AAEA,eAAe,QACb,KACA,OACA,SAC0C;CAC1C,MAAM,OAAO,KAAK,UAAU;EAAE;EAAO;EAAS,8BAAa,IAAI,KAAK,GAAE,YAAY;CAAE,CAAC;CACrF,MAAM,UAAkC;EACtC,gBAAgB;EAChB,iBAAiB;CACnB;CACA,IAAI,IAAI,QAAQ,QAAQ,uBAAuB,UAAU,YAAY,IAAI,QAAQ,IAAI;CACrF,IAAI;EACF,MAAM,MAAO,MAAM,MAAM,IAAI,KAAK;GAAE,QAAQ;GAAQ;GAAS;EAAK,CAAC;EAInE,IAAI,CAAC,IAAI,IAAI,OAAO;GAAE,IAAI;GAAO,OAAO,QAAQ,IAAI;EAAS;EAC7D,OAAO,EAAE,IAAI,KAAK;CACpB,SAAS,KAAK;EACZ,OAAO;GAAE,IAAI;GAAO,OAAQ,IAAc;EAAQ;CACpD;AACF;;AAGA,eAAsB,UAAU,SAAiB,OAAe,SAAiC;CAC/F,MAAM,UAAU,mBAAmB,aAAa,OAAO,GAAG,KAAK;CAC/D,IAAI,QAAQ,WAAW,GAAG;CAC1B,MAAM,WAAW,aAAa,OAAO;CACrC,KAAK,MAAM,OAAO,SAAS;EACzB,MAAM,IAAI,MAAM,QAAQ,KAAK,OAAO,OAAO;EAC3C,IAAI,CAAC,EAAE,IACL,SAAS,KAAK;GACZ,IAAI,QAAA,GAAA,OAAA,YAAkB,QAAQ,EAAE,OAAO,GAAG,IAAI,GAAG,GAAG,MAAM,GAAG,KAAK,IAAI,GAAG,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;GACpG,gBAAgB,IAAI;GACpB,KAAK,IAAI;GACT,GAAI,IAAI,SAAS,EAAE,QAAQ,IAAI,OAAO,IAAI,CAAC;GAC3C;GACA;GACA,UAAU;GACV,WAAW,EAAE,SAAS;GACtB,2BAAU,IAAI,KAAK,GAAE,YAAY;EACnC,CAAC;CAEL;CACA,IAAI,SAAS,SAAS,GAAG,UAAU,aAAa,OAAO,GAAG,YAAY,QAAQ;AAChF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/fs/write-queue.ts
|
|
2
|
+
const queues = /* @__PURE__ */ new Map();
|
|
3
|
+
function withFileQueue(filePath, fn) {
|
|
4
|
+
const current = queues.get(filePath) ?? Promise.resolve();
|
|
5
|
+
let resolve;
|
|
6
|
+
const barrier = new Promise((r) => {
|
|
7
|
+
resolve = r;
|
|
8
|
+
});
|
|
9
|
+
queues.set(filePath, current.then(() => barrier));
|
|
10
|
+
return current.then(async () => {
|
|
11
|
+
try {
|
|
12
|
+
return await fn();
|
|
13
|
+
} finally {
|
|
14
|
+
resolve();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
Object.defineProperty(exports, "withFileQueue", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function() {
|
|
22
|
+
return withFileQueue;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=write-queue-BDolUxfs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-queue-BDolUxfs.cjs","names":[],"sources":["../src/fs/write-queue.ts"],"sourcesContent":["const queues = new Map<string, Promise<void>>();\n\nexport function withFileQueue<T>(filePath: string, fn: () => Promise<T>): Promise<T> {\n const current = queues.get(filePath) ?? Promise.resolve();\n let resolve!: () => void;\n const barrier = new Promise<void>((r) => {\n resolve = r;\n });\n queues.set(\n filePath,\n current.then(() => barrier)\n );\n return current.then(async () => {\n try {\n return await fn();\n } finally {\n resolve();\n }\n });\n}\n"],"mappings":";AAAA,MAAM,yBAAS,IAAI,IAA2B;AAE9C,SAAgB,cAAiB,UAAkB,IAAkC;CACnF,MAAM,UAAU,OAAO,IAAI,QAAQ,KAAK,QAAQ,QAAQ;CACxD,IAAI;CACJ,MAAM,UAAU,IAAI,SAAe,MAAM;EACvC,UAAU;CACZ,CAAC;CACD,OAAO,IACL,UACA,QAAQ,WAAW,OAAO,CAC5B;CACA,OAAO,QAAQ,KAAK,YAAY;EAC9B,IAAI;GACF,OAAO,MAAM,GAAG;EAClB,UAAU;GACR,QAAQ;EACV;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fs/write-queue.ts
|
|
2
|
+
const queues = /* @__PURE__ */ new Map();
|
|
3
|
+
function withFileQueue(filePath, fn) {
|
|
4
|
+
const current = queues.get(filePath) ?? Promise.resolve();
|
|
5
|
+
let resolve;
|
|
6
|
+
const barrier = new Promise((r) => {
|
|
7
|
+
resolve = r;
|
|
8
|
+
});
|
|
9
|
+
queues.set(filePath, current.then(() => barrier));
|
|
10
|
+
return current.then(async () => {
|
|
11
|
+
try {
|
|
12
|
+
return await fn();
|
|
13
|
+
} finally {
|
|
14
|
+
resolve();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { withFileQueue as t };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=write-queue-IbsAjUnh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-queue-IbsAjUnh.js","names":[],"sources":["../src/fs/write-queue.ts"],"sourcesContent":["const queues = new Map<string, Promise<void>>();\n\nexport function withFileQueue<T>(filePath: string, fn: () => Promise<T>): Promise<T> {\n const current = queues.get(filePath) ?? Promise.resolve();\n let resolve!: () => void;\n const barrier = new Promise<void>((r) => {\n resolve = r;\n });\n queues.set(\n filePath,\n current.then(() => barrier)\n );\n return current.then(async () => {\n try {\n return await fn();\n } finally {\n resolve();\n }\n });\n}\n"],"mappings":";AAAA,MAAM,yBAAS,IAAI,IAA2B;AAE9C,SAAgB,cAAiB,UAAkB,IAAkC;CACnF,MAAM,UAAU,OAAO,IAAI,QAAQ,KAAK,QAAQ,QAAQ;CACxD,IAAI;CACJ,MAAM,UAAU,IAAI,SAAe,MAAM;EACvC,UAAU;CACZ,CAAC;CACD,OAAO,IACL,UACA,QAAQ,WAAW,OAAO,CAC5B;CACA,OAAO,QAAQ,KAAK,YAAY;EAC9B,IAAI;GACF,OAAO,MAAM,GAAG;EAClB,UAAU;GACR,QAAQ;EACV;CACF,CAAC;AACH"}
|
package/package.json
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@datasynx/agentic-crm",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Local-first, MCP-native CRM. One agent per customer. npm install.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Datasynx Engineering <eng@datasynx.io>",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"crm",
|
|
10
|
+
"mcp",
|
|
11
|
+
"model-context-protocol",
|
|
12
|
+
"local-first",
|
|
13
|
+
"ai-agent",
|
|
14
|
+
"claude",
|
|
15
|
+
"cli",
|
|
16
|
+
"sales",
|
|
17
|
+
"lancedb"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/datasynx-ai/datasynx-crm.git"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/datasynx-ai/datasynx-crm#readme",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/datasynx-ai/datasynx-crm/issues"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20"
|
|
29
|
+
},
|
|
30
|
+
"main": "./dist/index.cjs",
|
|
31
|
+
"module": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"import": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"default": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"require": {
|
|
41
|
+
"types": "./dist/index.d.cts",
|
|
42
|
+
"default": "./dist/index.cjs"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"./mcp": {
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./dist/mcp.d.ts",
|
|
48
|
+
"default": "./dist/mcp.js"
|
|
49
|
+
},
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./dist/mcp.d.cts",
|
|
52
|
+
"default": "./dist/mcp.cjs"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"bin": {
|
|
57
|
+
"dxcrm": "./dist/cli.js",
|
|
58
|
+
"datasynx-opencrm": "./dist/cli.js"
|
|
59
|
+
},
|
|
60
|
+
"files": [
|
|
61
|
+
"dist/",
|
|
62
|
+
"README.md",
|
|
63
|
+
"LICENSE"
|
|
64
|
+
],
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsdown && node scripts/postbuild.js",
|
|
67
|
+
"dev": "tsx watch src/cli.ts",
|
|
68
|
+
"typecheck": "tsc --noEmit && tsc --project tsconfig.types.json",
|
|
69
|
+
"lint": "eslint src --max-warnings 0",
|
|
70
|
+
"lint:fix": "eslint src --fix",
|
|
71
|
+
"format": "prettier --write src __tests__",
|
|
72
|
+
"format:check": "prettier --check src __tests__",
|
|
73
|
+
"test": "vitest run",
|
|
74
|
+
"test:watch": "vitest",
|
|
75
|
+
"test:coverage": "vitest run --coverage",
|
|
76
|
+
"release": "semantic-release",
|
|
77
|
+
"prepublishOnly": "npm run typecheck && npm test && npm run build && npx publint && npx attw --pack . --ignore-rules no-resolution",
|
|
78
|
+
"prepare": "husky"
|
|
79
|
+
},
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"@anthropic-ai/sdk": "^0.98.0",
|
|
82
|
+
"@googleapis/calendar": "15.0.0",
|
|
83
|
+
"@googleapis/gmail": "17.0.0",
|
|
84
|
+
"@huggingface/transformers": "^3.8.1",
|
|
85
|
+
"@lancedb/lancedb": "^0.29.0",
|
|
86
|
+
"@modelcontextprotocol/sdk": "^1.10.0",
|
|
87
|
+
"adm-zip": "^0.5.17",
|
|
88
|
+
"ansis": "^3.0.0",
|
|
89
|
+
"apache-arrow": "^17.0.0",
|
|
90
|
+
"chokidar": "^4.0.0",
|
|
91
|
+
"cli-table3": "^0.6.3",
|
|
92
|
+
"commander": "^14.0.0",
|
|
93
|
+
"cron": "^4.4.0",
|
|
94
|
+
"google-auth-library": "10.6.2",
|
|
95
|
+
"gray-matter": "^4.0.3",
|
|
96
|
+
"js-yaml": "^4.1.1",
|
|
97
|
+
"slug": "^9.0.0",
|
|
98
|
+
"zod": "^3.25.0",
|
|
99
|
+
"zod-validation-error": "^3.0.0"
|
|
100
|
+
},
|
|
101
|
+
"peerDependencies": {
|
|
102
|
+
"express": "^4.0.0 || ^5.0.0"
|
|
103
|
+
},
|
|
104
|
+
"peerDependenciesMeta": {
|
|
105
|
+
"express": {
|
|
106
|
+
"optional": true
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"devDependencies": {
|
|
110
|
+
"@arethetypeswrong/cli": "^0.18.3",
|
|
111
|
+
"@commitlint/cli": "^21.0.2",
|
|
112
|
+
"@commitlint/config-conventional": "^21.0.2",
|
|
113
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
114
|
+
"@semantic-release/git": "^10.0.1",
|
|
115
|
+
"@semantic-release/github": "^12.0.8",
|
|
116
|
+
"@semantic-release/npm": "^13.1.5",
|
|
117
|
+
"@types/adm-zip": "^0.5.8",
|
|
118
|
+
"@types/express": "^5.0.6",
|
|
119
|
+
"@types/iarna__toml": "^2.0.0",
|
|
120
|
+
"@types/js-yaml": "^4.0.9",
|
|
121
|
+
"@types/slug": "^5.0.0",
|
|
122
|
+
"@types/which": "^3.0.0",
|
|
123
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
124
|
+
"expect-type": "^1.3.0",
|
|
125
|
+
"husky": "^9.1.7",
|
|
126
|
+
"license-checker": "^25.0.1",
|
|
127
|
+
"lint-staged": "^17.0.5",
|
|
128
|
+
"memfs": "^4.0.0",
|
|
129
|
+
"prettier": "^3.8.3",
|
|
130
|
+
"publint": "^0.3.21",
|
|
131
|
+
"semantic-release": "^25.0.3",
|
|
132
|
+
"tsdown": "^0.12.0",
|
|
133
|
+
"tsx": "^4.0.0",
|
|
134
|
+
"typescript": "^5.8.0",
|
|
135
|
+
"typescript-eslint": "^8.60.0",
|
|
136
|
+
"vitest": "^3.0.0"
|
|
137
|
+
},
|
|
138
|
+
"publishConfig": {
|
|
139
|
+
"access": "public",
|
|
140
|
+
"provenance": true
|
|
141
|
+
}
|
|
142
|
+
}
|