@datasynx/agentic-crm 1.2.0 → 1.4.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.
Files changed (34) hide show
  1. package/README.md +10 -0
  2. package/dist/{attachments-rLa96rOK.js → attachments-BddHbCt8.js} +51 -32
  3. package/dist/{attachments-D207gXfN.js.map → attachments-BddHbCt8.js.map} +1 -1
  4. package/dist/{attachments-D207gXfN.js → attachments-Co3kXIvu.js} +46 -31
  5. package/dist/{attachments-rLa96rOK.js.map → attachments-Co3kXIvu.js.map} +1 -1
  6. package/dist/{attachments-CX2GAtsw.cjs → attachments-Dbe7Bidz.cjs} +46 -31
  7. package/dist/{attachments-CX2GAtsw.cjs.map → attachments-Dbe7Bidz.cjs.map} +1 -1
  8. package/dist/attachments-YQKYmg6N.js +2 -0
  9. package/dist/cli.js +61 -3
  10. package/dist/cli.js.map +1 -1
  11. package/dist/daemon/worker.js +19 -1
  12. package/dist/daemon/worker.js.map +1 -1
  13. package/dist/{gmail-sync-DIbrPnTK.js → gmail-sync-BHLa8v51.js} +2 -2
  14. package/dist/{gmail-sync-DIbrPnTK.js.map → gmail-sync-BHLa8v51.js.map} +1 -1
  15. package/dist/{gmail-sync-BpSVESSe.cjs → gmail-sync-CodrUNR4.cjs} +2 -2
  16. package/dist/{gmail-sync-BpSVESSe.cjs.map → gmail-sync-CodrUNR4.cjs.map} +1 -1
  17. package/dist/{gmail-sync-B4Iu3AQb.js → gmail-sync-SvECok5p.js} +2 -2
  18. package/dist/{gmail-sync-B4Iu3AQb.js.map → gmail-sync-SvECok5p.js.map} +1 -1
  19. package/dist/imap-o6PRuBvm.js +270 -0
  20. package/dist/imap-o6PRuBvm.js.map +1 -0
  21. package/dist/{index-D8jJ1VIt.d.ts → index-BBAlKZg6.d.ts} +8 -8
  22. package/dist/{index-D8jJ1VIt.d.ts.map → index-BBAlKZg6.d.ts.map} +1 -1
  23. package/dist/{index-CLUKKfGb.d.cts → index-Dspvybo0.d.cts} +20 -20
  24. package/dist/index-Dspvybo0.d.cts.map +1 -0
  25. package/dist/index.d.cts +20 -20
  26. package/dist/index.d.cts.map +1 -1
  27. package/dist/index.d.ts +8 -8
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/mcp.cjs +2 -2
  30. package/dist/mcp.js +2 -2
  31. package/dist/{server-BhNLrnAD.js → server-uqXUhF4H.js} +3 -3
  32. package/dist/{server-BhNLrnAD.js.map → server-uqXUhF4H.js.map} +1 -1
  33. package/package.json +4 -1
  34. package/dist/index-CLUKKfGb.d.cts.map +0 -1
@@ -0,0 +1,270 @@
1
+ import { i as listCustomerSlugs } from "./customer-dir-CkMMXhb0.js";
2
+ import { i as readInteractions, n as appendInteraction } from "./interactions-writer-B8XAzdqR.js";
3
+ import { n as logger } from "./logger-Dyl4VcLO.js";
4
+ import { t as chunkText } from "./chunk-BhUZmQg5.js";
5
+ import { r as persistAttachment } from "./attachments-BddHbCt8.js";
6
+ import { n as htmlToMarkdown } from "./html-BaeOCZKE.js";
7
+ import path from "path";
8
+ import fs from "fs";
9
+ import matter from "gray-matter";
10
+ //#region src/sync/email-ingest.ts
11
+ /**
12
+ * Ingest one normalized email into a customer: convert + index its
13
+ * attachments, summarize it, append the interaction (with attachment links),
14
+ * and index the full body (chunked) for semantic search. Caller is responsible
15
+ * for deduplication (skip messages whose sourceRef is already logged).
16
+ */
17
+ async function ingestEmail(dataDir, slug, msg, options = {}) {
18
+ const includeAttachments = options.includeAttachments ?? true;
19
+ const maxBytes = options.maxAttachmentBytes ?? 26214400;
20
+ const attachmentLinks = [];
21
+ if (includeAttachments) for (const att of msg.attachments) {
22
+ if (att.content.length > maxBytes) {
23
+ logger.warn("email-ingest", "skipping oversized attachment", {
24
+ filename: att.filename,
25
+ bytes: att.content.length
26
+ });
27
+ continue;
28
+ }
29
+ try {
30
+ const saved = await persistAttachment({
31
+ dataDir,
32
+ slug,
33
+ messageId: msg.messageId,
34
+ source: msg.sourceRef,
35
+ date: msg.date,
36
+ filename: att.filename,
37
+ mimeType: att.mimeType,
38
+ buffer: att.content
39
+ });
40
+ attachmentLinks.push(saved.markdownName);
41
+ } catch (err) {
42
+ logger.warn("email-ingest", "attachment failed", {
43
+ filename: att.filename,
44
+ error: err.message
45
+ });
46
+ }
47
+ }
48
+ const { summarizeEmail } = await import("./llm-DSX1-wFu.js");
49
+ const summary = await summarizeEmail(msg.subject, msg.bodyMarkdown, msg.from);
50
+ await appendInteraction(dataDir, slug, {
51
+ date: msg.date,
52
+ type: "Email",
53
+ direction: options.direction ?? "inbound",
54
+ with: msg.from,
55
+ subject: msg.subject,
56
+ summary: summary.summary,
57
+ nextSteps: summary.nextSteps,
58
+ ...attachmentLinks.length > 0 ? { attachments: attachmentLinks } : {},
59
+ sourceRef: msg.sourceRef,
60
+ synced: (/* @__PURE__ */ new Date()).toISOString()
61
+ });
62
+ const { indexInLanceDB } = await import("./lancedb-CswQEE5K.js");
63
+ const bodyChunks = chunkText(`${msg.subject}\n${msg.bodyMarkdown}`);
64
+ for (let i = 0; i < bodyChunks.length; i++) {
65
+ const ref = i === 0 ? msg.sourceRef : `${msg.sourceRef}#${i}`;
66
+ await indexInLanceDB(dataDir, slug, bodyChunks[i], ref, {
67
+ date: msg.date,
68
+ type: "Email"
69
+ }).catch((err) => {
70
+ logger.error("email-ingest", "LanceDB index failed", { error: err.message });
71
+ });
72
+ }
73
+ return {
74
+ attachments: attachmentLinks.length,
75
+ chunks: bodyChunks.length
76
+ };
77
+ }
78
+ //#endregion
79
+ //#region src/sync/email-router.ts
80
+ /** The domain part of an email address, lowercased (empty string if malformed). */
81
+ function domainOf(email) {
82
+ const at = email.lastIndexOf("@");
83
+ return at >= 0 ? email.slice(at + 1).trim().toLowerCase() : "";
84
+ }
85
+ /** Read just the routing-relevant fields from a customer's main_facts (tolerant). */
86
+ function readRoutingFields(dataDir, slug) {
87
+ const file = path.join(dataDir, "customers", slug, "main_facts.md");
88
+ if (!fs.existsSync(file)) return {};
89
+ try {
90
+ const data = matter(fs.readFileSync(file, "utf-8")).data;
91
+ return {
92
+ domain: typeof data["domain"] === "string" ? data["domain"] : void 0,
93
+ email: typeof data["email"] === "string" ? data["email"] : void 0,
94
+ primary_contact: typeof data["primary_contact"] === "string" ? data["primary_contact"] : void 0
95
+ };
96
+ } catch {
97
+ return {};
98
+ }
99
+ }
100
+ /**
101
+ * Build the routing table from every customer's main_facts. A customer is
102
+ * identified by its `domain`, `email`, and `primary_contact` (when it looks
103
+ * like an email). Customers without any identifier are still listed (empty
104
+ * arrays) so callers can see them, but they never match.
105
+ */
106
+ function buildRoutingTable(dataDir) {
107
+ return listCustomerSlugs(dataDir).map((slug) => {
108
+ const facts = readRoutingFields(dataDir, slug);
109
+ const domains = /* @__PURE__ */ new Set();
110
+ const emails = /* @__PURE__ */ new Set();
111
+ if (facts.domain) domains.add(facts.domain.trim().toLowerCase());
112
+ for (const candidate of [facts.email, facts.primary_contact]) if (candidate && candidate.includes("@")) {
113
+ const addr = candidate.trim().toLowerCase();
114
+ emails.add(addr);
115
+ const d = domainOf(addr);
116
+ if (d) domains.add(d);
117
+ }
118
+ return {
119
+ slug,
120
+ domains: [...domains],
121
+ emails: [...emails]
122
+ };
123
+ });
124
+ }
125
+ /**
126
+ * Route a message to a customer slug by matching any of its addresses
127
+ * (from/to/cc) against the routing table. Exact email matches win over domain
128
+ * matches. Returns the matched slug, or null when nothing matches (the message
129
+ * is "unrouted").
130
+ */
131
+ function routeMessage(addresses, table) {
132
+ const addrs = addresses.map((a) => a.trim().toLowerCase()).filter((a) => a.includes("@"));
133
+ if (addrs.length === 0) return null;
134
+ const domains = new Set(addrs.map(domainOf).filter(Boolean));
135
+ for (const c of table) if (c.emails.some((e) => addrs.includes(e))) return c.slug;
136
+ for (const c of table) if (c.domains.some((d) => domains.has(d))) return c.slug;
137
+ return null;
138
+ }
139
+ //#endregion
140
+ //#region src/sync/connectors/imap.ts
141
+ /** Build a real ImapFlow client. Loaded lazily so the dep stays off hot paths. */
142
+ async function defaultClientFactory(config) {
143
+ const { ImapFlow } = await import("imapflow");
144
+ const auth = config.auth.accessToken ? {
145
+ user: config.auth.user,
146
+ accessToken: config.auth.accessToken
147
+ } : {
148
+ user: config.auth.user,
149
+ pass: config.auth.pass ?? ""
150
+ };
151
+ return new ImapFlow({
152
+ host: config.host,
153
+ port: config.port ?? 993,
154
+ secure: config.secure ?? true,
155
+ auth,
156
+ logger: false
157
+ });
158
+ }
159
+ /** Normalize extracted email fields into the provider-independent email shape. */
160
+ async function normalizeParsedEmail(parsed, ctx) {
161
+ const toAddresses = (parsed.toAddresses ?? []).map((a) => a.toLowerCase()).filter((a) => a.includes("@"));
162
+ const plain = (parsed.text ?? "").trim();
163
+ const bodyMarkdown = plain ? plain : parsed.html ? (await htmlToMarkdown(parsed.html)).trim() : "";
164
+ return {
165
+ messageId: (parsed.messageId ?? "").replace(/[<>]/g, "").trim() || `uid-${ctx.uid}`,
166
+ from: parsed.fromText ?? "",
167
+ toAddresses,
168
+ subject: parsed.subject ?? "(no subject)",
169
+ date: (parsed.date ?? /* @__PURE__ */ new Date()).toISOString().slice(0, 10),
170
+ bodyMarkdown,
171
+ attachments: (parsed.attachments ?? []).filter((a) => a.filename).map((a) => ({
172
+ filename: a.filename,
173
+ mimeType: a.contentType ?? "application/octet-stream",
174
+ content: a.content
175
+ })),
176
+ sourceRef: `imap://${ctx.user}@${ctx.host}/${ctx.mailbox}/${ctx.uid}`
177
+ };
178
+ }
179
+ /** Flatten mailparser's AddressObject | AddressObject[] | undefined to addresses. */
180
+ function flattenAddresses(field) {
181
+ if (!field) return [];
182
+ return (Array.isArray(field) ? field : [field]).flatMap((o) => o.value ?? []).map((a) => (a.address ?? "").toLowerCase()).filter((a) => a.includes("@"));
183
+ }
184
+ /**
185
+ * Sync a whole IMAP mailbox (any provider). Each message is parsed, routed to a
186
+ * customer — by a fixed `slug` or auto-routed by sender/recipient domain — and
187
+ * ingested through the shared pipeline (attachments→Markdown, summary, index).
188
+ * Messages that match no customer are counted as `unrouted` and skipped.
189
+ */
190
+ async function syncImapMailbox(opts) {
191
+ const result = {
192
+ synced: 0,
193
+ skipped: 0,
194
+ unrouted: 0
195
+ };
196
+ const mailbox = opts.config.mailbox ?? "INBOX";
197
+ const { simpleParser } = await import("mailparser");
198
+ const client = opts.clientFactory ? opts.clientFactory(opts.config) : await defaultClientFactory(opts.config);
199
+ const table = opts.slug ? null : buildRoutingTable(opts.dataDir);
200
+ const dedupCache = /* @__PURE__ */ new Map();
201
+ const seen = async (slug, sourceRef) => {
202
+ let content = dedupCache.get(slug);
203
+ if (content === void 0) {
204
+ content = await readInteractions(opts.dataDir, slug).catch(() => "");
205
+ dedupCache.set(slug, content);
206
+ }
207
+ return content.includes(sourceRef);
208
+ };
209
+ await client.connect();
210
+ const lock = await client.getMailboxLock(mailbox);
211
+ try {
212
+ const range = opts.since ? { since: opts.since } : { all: true };
213
+ for await (const message of client.fetch(range, {
214
+ uid: true,
215
+ source: true
216
+ })) try {
217
+ const parsed = await simpleParser(message.source);
218
+ const msg = await normalizeParsedEmail({
219
+ messageId: parsed.messageId,
220
+ fromText: parsed.from?.text,
221
+ toAddresses: [...flattenAddresses(parsed.to), ...flattenAddresses(parsed.cc)],
222
+ subject: parsed.subject,
223
+ date: parsed.date,
224
+ text: parsed.text,
225
+ html: parsed.html,
226
+ attachments: parsed.attachments
227
+ }, {
228
+ user: opts.config.auth.user,
229
+ host: opts.config.host,
230
+ mailbox,
231
+ uid: message.uid
232
+ });
233
+ let slug = opts.slug ?? null;
234
+ if (!slug && table) slug = routeMessage([(msg.from.match(/<([^>]+)>/)?.[1] ?? msg.from).toLowerCase(), ...msg.toAddresses].filter((a) => domainOf(a)), table);
235
+ if (!slug) {
236
+ result.unrouted++;
237
+ continue;
238
+ }
239
+ if (await seen(slug, msg.sourceRef)) {
240
+ result.skipped++;
241
+ continue;
242
+ }
243
+ await ingestEmail(opts.dataDir, slug, msg, {
244
+ ...opts.includeAttachments !== void 0 ? { includeAttachments: opts.includeAttachments } : {},
245
+ ...opts.maxAttachmentBytes !== void 0 ? { maxAttachmentBytes: opts.maxAttachmentBytes } : {},
246
+ direction: directionFor(msg, opts.config.auth.user)
247
+ });
248
+ dedupCache.set(slug, (dedupCache.get(slug) ?? "") + msg.sourceRef);
249
+ result.synced++;
250
+ } catch (err) {
251
+ logger.warn("imap-sync", "message failed", {
252
+ uid: message.uid,
253
+ error: err.message
254
+ });
255
+ result.skipped++;
256
+ }
257
+ } finally {
258
+ lock.release();
259
+ await client.logout().catch(() => void 0);
260
+ }
261
+ return result;
262
+ }
263
+ /** Inbound unless the mailbox owner is the sender. */
264
+ function directionFor(msg, user) {
265
+ return (msg.from.match(/<([^>]+)>/)?.[1] ?? msg.from).toLowerCase() === user.toLowerCase() ? "outbound" : "inbound";
266
+ }
267
+ //#endregion
268
+ export { syncImapMailbox };
269
+
270
+ //# sourceMappingURL=imap-o6PRuBvm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imap-o6PRuBvm.js","names":[],"sources":["../src/sync/email-ingest.ts","../src/sync/email-router.ts","../src/sync/connectors/imap.ts"],"sourcesContent":["// src/sync/email-ingest.ts\nimport { appendInteraction } from \"../fs/interactions-writer.js\";\nimport { persistAttachment, DEFAULT_MAX_ATTACHMENT_BYTES } from \"./attachments.js\";\nimport { chunkText } from \"../core/chunk.js\";\nimport { logger } from \"../core/logger.js\";\n\n/** An attachment with its bytes already in hand (no provider fetch needed). */\nexport interface NormalizedAttachment {\n filename: string;\n mimeType: string;\n content: Buffer;\n}\n\n/**\n * A provider-independent email, normalized from Gmail / IMAP / Graph into a\n * single shape so the downstream pipeline (summary, attachments→Markdown,\n * indexing, interaction log) is written once and reused everywhere.\n */\nexport interface NormalizedEmail {\n /** Stable id for dedup and as the attachment filename prefix. */\n messageId: string;\n /** Raw `From` header value (display name + address). */\n from: string;\n /** Recipient addresses (to + cc), lowercased. */\n toAddresses: string[];\n subject: string;\n /** Message date as YYYY-MM-DD. */\n date: string;\n /** Body already rendered to Markdown (plain verbatim or HTML→MD). */\n bodyMarkdown: string;\n attachments: NormalizedAttachment[];\n /** Canonical source ref, e.g. `imap://user@host/INBOX/42`. */\n sourceRef: string;\n}\n\nexport interface IngestOptions {\n includeAttachments?: boolean;\n maxAttachmentBytes?: number;\n direction?: \"inbound\" | \"outbound\";\n}\n\n/**\n * Ingest one normalized email into a customer: convert + index its\n * attachments, summarize it, append the interaction (with attachment links),\n * and index the full body (chunked) for semantic search. Caller is responsible\n * for deduplication (skip messages whose sourceRef is already logged).\n */\nexport async function ingestEmail(\n dataDir: string,\n slug: string,\n msg: NormalizedEmail,\n options: IngestOptions = {}\n): Promise<{ attachments: number; chunks: number }> {\n const includeAttachments = options.includeAttachments ?? true;\n const maxBytes = options.maxAttachmentBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES;\n\n // Attachments first, so the interaction entry can link to the Markdown.\n const attachmentLinks: string[] = [];\n if (includeAttachments) {\n for (const att of msg.attachments) {\n if (att.content.length > maxBytes) {\n logger.warn(\"email-ingest\", \"skipping oversized attachment\", {\n filename: att.filename,\n bytes: att.content.length,\n });\n continue;\n }\n try {\n const saved = await persistAttachment({\n dataDir,\n slug,\n messageId: msg.messageId,\n source: msg.sourceRef,\n date: msg.date,\n filename: att.filename,\n mimeType: att.mimeType,\n buffer: att.content,\n });\n attachmentLinks.push(saved.markdownName);\n } catch (err) {\n logger.warn(\"email-ingest\", \"attachment failed\", {\n filename: att.filename,\n error: (err as Error).message,\n });\n }\n }\n }\n\n // LLM summary — non-blocking fallback to the raw body when no API key.\n const { summarizeEmail } = await import(\"../core/llm.js\");\n const summary = await summarizeEmail(msg.subject, msg.bodyMarkdown, msg.from);\n\n await appendInteraction(dataDir, slug, {\n date: msg.date,\n type: \"Email\",\n direction: options.direction ?? \"inbound\",\n with: msg.from,\n subject: msg.subject,\n summary: summary.summary,\n nextSteps: summary.nextSteps,\n ...(attachmentLinks.length > 0 ? { attachments: attachmentLinks } : {}),\n sourceRef: msg.sourceRef,\n synced: new Date().toISOString(),\n });\n\n // Index the full email (subject + body), chunked for long threads.\n const { indexInLanceDB } = await import(\"../core/lancedb.js\");\n const bodyChunks = chunkText(`${msg.subject}\\n${msg.bodyMarkdown}`);\n for (let i = 0; i < bodyChunks.length; i++) {\n const ref = i === 0 ? msg.sourceRef : `${msg.sourceRef}#${i}`;\n await indexInLanceDB(dataDir, slug, bodyChunks[i]!, ref, {\n date: msg.date,\n type: \"Email\",\n }).catch((err: unknown) => {\n logger.error(\"email-ingest\", \"LanceDB index failed\", { error: (err as Error).message });\n });\n }\n\n return { attachments: attachmentLinks.length, chunks: bodyChunks.length };\n}\n","// src/sync/email-router.ts\nimport fs from \"fs\";\nimport path from \"path\";\nimport matter from \"gray-matter\";\nimport { listCustomerSlugs } from \"../fs/customer-dir.js\";\n\nexport interface CustomerRoutingInfo {\n slug: string;\n /** Lowercased domains that identify this customer (e.g. \"acme.com\"). */\n domains: string[];\n /** Lowercased full email addresses that identify this customer. */\n emails: string[];\n}\n\n/** Extract the bare email address from a header value like `\"Name <a@b.com>\"`. */\nexport function extractEmailAddress(headerValue: string): string {\n const angle = headerValue.match(/<([^>]+)>/);\n const raw = (angle ? angle[1] : headerValue) ?? \"\";\n return raw.trim().toLowerCase();\n}\n\n/** The domain part of an email address, lowercased (empty string if malformed). */\nexport function domainOf(email: string): string {\n const at = email.lastIndexOf(\"@\");\n return at >= 0 ? email.slice(at + 1).trim().toLowerCase() : \"\";\n}\n\n/**\n * Split a header that may contain several comma-separated addresses\n * (To/Cc) into individual lowercased email addresses.\n */\nexport function parseAddressList(headerValue: string | undefined): string[] {\n if (!headerValue) return [];\n return headerValue\n .split(\",\")\n .map((part) => extractEmailAddress(part))\n .filter((a) => a.includes(\"@\"));\n}\n\n/** Read just the routing-relevant fields from a customer's main_facts (tolerant). */\nfunction readRoutingFields(\n dataDir: string,\n slug: string\n): { domain?: string | undefined; email?: string | undefined; primary_contact?: string | undefined } {\n const file = path.join(dataDir, \"customers\", slug, \"main_facts.md\");\n if (!fs.existsSync(file)) return {};\n try {\n const data = matter(fs.readFileSync(file, \"utf-8\")).data as Record<string, unknown>;\n return {\n domain: typeof data[\"domain\"] === \"string\" ? data[\"domain\"] : undefined,\n email: typeof data[\"email\"] === \"string\" ? data[\"email\"] : undefined,\n primary_contact:\n typeof data[\"primary_contact\"] === \"string\" ? data[\"primary_contact\"] : undefined,\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Build the routing table from every customer's main_facts. A customer is\n * identified by its `domain`, `email`, and `primary_contact` (when it looks\n * like an email). Customers without any identifier are still listed (empty\n * arrays) so callers can see them, but they never match.\n */\nexport function buildRoutingTable(dataDir: string): CustomerRoutingInfo[] {\n return listCustomerSlugs(dataDir).map((slug) => {\n const facts = readRoutingFields(dataDir, slug);\n const domains = new Set<string>();\n const emails = new Set<string>();\n if (facts.domain) domains.add(facts.domain.trim().toLowerCase());\n for (const candidate of [facts.email, facts.primary_contact]) {\n if (candidate && candidate.includes(\"@\")) {\n const addr = candidate.trim().toLowerCase();\n emails.add(addr);\n const d = domainOf(addr);\n if (d) domains.add(d);\n }\n }\n return { slug, domains: [...domains], emails: [...emails] };\n });\n}\n\n/**\n * Route a message to a customer slug by matching any of its addresses\n * (from/to/cc) against the routing table. Exact email matches win over domain\n * matches. Returns the matched slug, or null when nothing matches (the message\n * is \"unrouted\").\n */\nexport function routeMessage(addresses: string[], table: CustomerRoutingInfo[]): string | null {\n const addrs = addresses.map((a) => a.trim().toLowerCase()).filter((a) => a.includes(\"@\"));\n if (addrs.length === 0) return null;\n const domains = new Set(addrs.map(domainOf).filter(Boolean));\n\n // Pass 1: exact email match (most specific).\n for (const c of table) {\n if (c.emails.some((e) => addrs.includes(e))) return c.slug;\n }\n // Pass 2: domain match.\n for (const c of table) {\n if (c.domains.some((d) => domains.has(d))) return c.slug;\n }\n return null;\n}\n","// src/sync/connectors/imap.ts\nimport { readInteractions } from \"../../fs/interactions-writer.js\";\nimport { ingestEmail, type NormalizedEmail } from \"../email-ingest.js\";\nimport { buildRoutingTable, routeMessage, domainOf } from \"../email-router.js\";\nimport { htmlToMarkdown } from \"../converters/html.js\";\nimport { logger } from \"../../core/logger.js\";\n\nexport interface ImapMailboxConfig {\n host: string;\n port?: number;\n secure?: boolean;\n /** Either a password (legacy IMAP) or an OAuth2 access token (XOAUTH2). */\n auth: { user: string; pass?: string; accessToken?: string };\n mailbox?: string;\n}\n\n/** Minimal slice of the ImapFlow client surface we depend on (for testability). */\nexport interface ImapMessage {\n uid: number;\n source: Buffer;\n}\nexport interface ImapClient {\n connect(): Promise<void>;\n getMailboxLock(mailbox: string): Promise<{ release: () => void }>;\n fetch(\n range: unknown,\n query: { uid?: boolean; source?: boolean }\n ): AsyncIterable<ImapMessage>;\n logout(): Promise<void>;\n}\n\nexport interface SyncImapOptions {\n dataDir: string;\n config: ImapMailboxConfig;\n since?: Date;\n /** Fixed customer slug. When omitted, messages are auto-routed by domain. */\n slug?: string;\n includeAttachments?: boolean;\n maxAttachmentBytes?: number;\n /** Inject a client (tests); defaults to a real ImapFlow connection. */\n clientFactory?: (config: ImapMailboxConfig) => ImapClient;\n}\n\nexport interface SyncImapResult {\n synced: number;\n skipped: number;\n unrouted: number;\n}\n\n/** Build a real ImapFlow client. Loaded lazily so the dep stays off hot paths. */\nasync function defaultClientFactory(config: ImapMailboxConfig): Promise<ImapClient> {\n const { ImapFlow } = await import(\"imapflow\");\n const auth = config.auth.accessToken\n ? { user: config.auth.user, accessToken: config.auth.accessToken }\n : { user: config.auth.user, pass: config.auth.pass ?? \"\" };\n return new ImapFlow({\n host: config.host,\n port: config.port ?? 993,\n secure: config.secure ?? true,\n auth,\n logger: false,\n }) as unknown as ImapClient;\n}\n\n/** Fields extracted from a parsed message, decoupled from mailparser's types. */\nexport interface ParsedEmailInput {\n messageId?: string | undefined;\n fromText?: string | undefined;\n toAddresses?: string[] | undefined;\n subject?: string | undefined;\n date?: Date | undefined;\n text?: string | undefined;\n html?: string | false | undefined;\n attachments?:\n | Array<{ filename?: string | undefined; contentType?: string | undefined; content: Buffer }>\n | undefined;\n}\n\n/** Normalize extracted email fields into the provider-independent email shape. */\nexport async function normalizeParsedEmail(\n parsed: ParsedEmailInput,\n ctx: { user: string; host: string; mailbox: string; uid: number }\n): Promise<NormalizedEmail> {\n const toAddresses = (parsed.toAddresses ?? [])\n .map((a) => a.toLowerCase())\n .filter((a) => a.includes(\"@\"));\n\n const plain = (parsed.text ?? \"\").trim();\n const bodyMarkdown = plain\n ? plain\n : parsed.html\n ? (await htmlToMarkdown(parsed.html)).trim()\n : \"\";\n\n const rawId = (parsed.messageId ?? \"\").replace(/[<>]/g, \"\").trim();\n const messageId = rawId || `uid-${ctx.uid}`;\n\n return {\n messageId,\n from: parsed.fromText ?? \"\",\n toAddresses,\n subject: parsed.subject ?? \"(no subject)\",\n date: (parsed.date ?? new Date()).toISOString().slice(0, 10),\n bodyMarkdown,\n attachments: (parsed.attachments ?? [])\n .filter((a) => a.filename)\n .map((a) => ({\n filename: a.filename!,\n mimeType: a.contentType ?? \"application/octet-stream\",\n content: a.content,\n })),\n sourceRef: `imap://${ctx.user}@${ctx.host}/${ctx.mailbox}/${ctx.uid}`,\n };\n}\n\n/** Flatten mailparser's AddressObject | AddressObject[] | undefined to addresses. */\nfunction flattenAddresses(\n field:\n | { value?: Array<{ address?: string | undefined }> }\n | Array<{ value?: Array<{ address?: string | undefined }> }>\n | undefined\n): string[] {\n if (!field) return [];\n const objects = Array.isArray(field) ? field : [field];\n return objects\n .flatMap((o) => o.value ?? [])\n .map((a) => (a.address ?? \"\").toLowerCase())\n .filter((a) => a.includes(\"@\"));\n}\n\n/**\n * Sync a whole IMAP mailbox (any provider). Each message is parsed, routed to a\n * customer — by a fixed `slug` or auto-routed by sender/recipient domain — and\n * ingested through the shared pipeline (attachments→Markdown, summary, index).\n * Messages that match no customer are counted as `unrouted` and skipped.\n */\nexport async function syncImapMailbox(opts: SyncImapOptions): Promise<SyncImapResult> {\n const result: SyncImapResult = { synced: 0, skipped: 0, unrouted: 0 };\n const mailbox = opts.config.mailbox ?? \"INBOX\";\n const { simpleParser } = await import(\"mailparser\");\n\n const client = opts.clientFactory\n ? opts.clientFactory(opts.config)\n : await defaultClientFactory(opts.config);\n\n // Routing table (auto-route mode) + per-slug dedup cache.\n const table = opts.slug ? null : buildRoutingTable(opts.dataDir);\n const dedupCache = new Map<string, string>();\n const seen = async (slug: string, sourceRef: string): Promise<boolean> => {\n let content = dedupCache.get(slug);\n if (content === undefined) {\n content = await readInteractions(opts.dataDir, slug).catch(() => \"\");\n dedupCache.set(slug, content);\n }\n return content.includes(sourceRef);\n };\n\n await client.connect();\n const lock = await client.getMailboxLock(mailbox);\n try {\n const range = opts.since ? { since: opts.since } : { all: true };\n for await (const message of client.fetch(range, { uid: true, source: true })) {\n try {\n const parsed = await simpleParser(message.source);\n const msg = await normalizeParsedEmail(\n {\n messageId: parsed.messageId,\n fromText: parsed.from?.text,\n toAddresses: [...flattenAddresses(parsed.to), ...flattenAddresses(parsed.cc)],\n subject: parsed.subject,\n date: parsed.date,\n text: parsed.text,\n html: parsed.html,\n attachments: parsed.attachments,\n },\n {\n user: opts.config.auth.user,\n host: opts.config.host,\n mailbox,\n uid: message.uid,\n }\n );\n\n // Route: fixed slug, or auto-route by any from/to/cc domain.\n let slug = opts.slug ?? null;\n if (!slug && table) {\n const fromAddr = (msg.from.match(/<([^>]+)>/)?.[1] ?? msg.from).toLowerCase();\n const addresses = [fromAddr, ...msg.toAddresses].filter((a) => domainOf(a));\n slug = routeMessage(addresses, table);\n }\n if (!slug) {\n result.unrouted++;\n continue;\n }\n\n if (await seen(slug, msg.sourceRef)) {\n result.skipped++;\n continue;\n }\n\n await ingestEmail(opts.dataDir, slug, msg, {\n ...(opts.includeAttachments !== undefined\n ? { includeAttachments: opts.includeAttachments }\n : {}),\n ...(opts.maxAttachmentBytes !== undefined\n ? { maxAttachmentBytes: opts.maxAttachmentBytes }\n : {}),\n direction: directionFor(msg, opts.config.auth.user),\n });\n dedupCache.set(slug, (dedupCache.get(slug) ?? \"\") + msg.sourceRef);\n result.synced++;\n } catch (err) {\n logger.warn(\"imap-sync\", \"message failed\", {\n uid: message.uid,\n error: (err as Error).message,\n });\n result.skipped++;\n }\n }\n } finally {\n lock.release();\n await client.logout().catch(() => undefined);\n }\n\n return result;\n}\n\n/** Inbound unless the mailbox owner is the sender. */\nfunction directionFor(msg: NormalizedEmail, user: string): \"inbound\" | \"outbound\" {\n const fromAddr = (msg.from.match(/<([^>]+)>/)?.[1] ?? msg.from).toLowerCase();\n return fromAddr === user.toLowerCase() ? \"outbound\" : \"inbound\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+CA,eAAsB,YACpB,SACA,MACA,KACA,UAAyB,CAAC,GACwB;CAClD,MAAM,qBAAqB,QAAQ,sBAAsB;CACzD,MAAM,WAAW,QAAQ,sBAAA;CAGzB,MAAM,kBAA4B,CAAC;CACnC,IAAI,oBACF,KAAK,MAAM,OAAO,IAAI,aAAa;EACjC,IAAI,IAAI,QAAQ,SAAS,UAAU;GACjC,OAAO,KAAK,gBAAgB,iCAAiC;IAC3D,UAAU,IAAI;IACd,OAAO,IAAI,QAAQ;GACrB,CAAC;GACD;EACF;EACA,IAAI;GACF,MAAM,QAAQ,MAAM,kBAAkB;IACpC;IACA;IACA,WAAW,IAAI;IACf,QAAQ,IAAI;IACZ,MAAM,IAAI;IACV,UAAU,IAAI;IACd,UAAU,IAAI;IACd,QAAQ,IAAI;GACd,CAAC;GACD,gBAAgB,KAAK,MAAM,YAAY;EACzC,SAAS,KAAK;GACZ,OAAO,KAAK,gBAAgB,qBAAqB;IAC/C,UAAU,IAAI;IACd,OAAQ,IAAc;GACxB,CAAC;EACH;CACF;CAIF,MAAM,EAAE,mBAAmB,MAAM,OAAO;CACxC,MAAM,UAAU,MAAM,eAAe,IAAI,SAAS,IAAI,cAAc,IAAI,IAAI;CAE5E,MAAM,kBAAkB,SAAS,MAAM;EACrC,MAAM,IAAI;EACV,MAAM;EACN,WAAW,Q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AK,OAAO;IAClB;IACA,KAAK,QAAQ;GACf,CACF;GAGA,IAAI,OAAO,KAAK,QAAQ;GACxB,IAAI,CAAC,QAAQ,OAGX,OAAO,aADW,EADA,IAAI,KAAK,MAAM,WAAW,IAAI,MAAM,IAAI,MAAM,YACtC,GAAG,GAAG,IAAI,WAAW,EAAE,QAAQ,MAAM,SAAS,CAAC,CAC7C,GAAG,KAAK;GAEtC,IAAI,CAAC,MAAM;IACT,OAAO;IACP;GACF;GAEA,IAAI,MAAM,KAAK,MAAM,IAAI,SAAS,GAAG;IACnC,OAAO;IACP;GACF;GAEA,MAAM,YAAY,KAAK,SAAS,MAAM,KAAK;IACzC,GAAI,KAAK,uBAAuB,KAAA,IAC5B,EAAE,oBAAoB,KAAK,mBAAmB,IAC9C,CAAC;IACL,GAAI,KAAK,uBAAuB,KAAA,IAC5B,EAAE,oBAAoB,KAAK,mBAAmB,IAC9C,CAAC;IACL,WAAW,aAAa,KAAK,KAAK,OAAO,KAAK,IAAI;GACpD,CAAC;GACD,WAAW,IAAI,OAAO,WAAW,IAAI,IAAI,KAAK,MAAM,IAAI,SAAS;GACjE,OAAO;EACT,SAAS,KAAK;GACZ,OAAO,KAAK,aAAa,kBAAkB;IACzC,KAAK,QAAQ;IACb,OAAQ,IAAc;GACxB,CAAC;GACD,OAAO;EACT;CAEJ,UAAU;EACR,KAAK,QAAQ;EACb,MAAM,OAAO,OAAO,EAAE,YAAY,KAAA,CAAS;CAC7C;CAEA,OAAO;AACT;;AAGA,SAAS,aAAa,KAAsB,MAAsC;CAEhF,QADkB,IAAI,KAAK,MAAM,WAAW,IAAI,MAAM,IAAI,MAAM,YAClD,MAAM,KAAK,YAAY,IAAI,aAAa;AACxD"}
@@ -43,8 +43,8 @@ declare const GlobalSourcesSchema: z.ZodObject<{
43
43
  version: z.ZodDefault<z.ZodNumber>;
44
44
  created: z.ZodString;
45
45
  }, "strip", z.ZodTypeAny, {
46
- created: string;
47
46
  version: number;
47
+ created: string;
48
48
  gmail?: {
49
49
  type: "gmail";
50
50
  query: string;
@@ -212,20 +212,20 @@ declare const TicketSchema: z.ZodObject<{
212
212
  resolved: z.ZodOptional<z.ZodString>;
213
213
  description: z.ZodOptional<z.ZodString>;
214
214
  }, "strip", z.ZodTypeAny, {
215
+ status: "open" | "in-progress" | "waiting" | "resolved" | "closed";
216
+ created: string;
215
217
  id: string;
216
218
  title: string;
217
- status: "open" | "in-progress" | "waiting" | "resolved" | "closed";
218
219
  priority: "urgent" | "high" | "normal" | "low";
219
- created: string;
220
220
  resolved?: string | undefined;
221
221
  assignee?: string | undefined;
222
222
  slaDue?: string | undefined;
223
223
  description?: string | undefined;
224
224
  }, {
225
- id: string;
226
- title: string;
227
225
  status: "open" | "in-progress" | "waiting" | "resolved" | "closed";
228
226
  created: string;
227
+ id: string;
228
+ title: string;
229
229
  resolved?: string | undefined;
230
230
  priority?: "urgent" | "high" | "normal" | "low" | undefined;
231
231
  assignee?: string | undefined;
@@ -346,9 +346,9 @@ declare const KbArticleSchema: z.ZodObject<{
346
346
  updatedAt: z.ZodString;
347
347
  sourceTicketId: z.ZodOptional<z.ZodString>;
348
348
  }, "strip", z.ZodTypeAny, {
349
+ tags: string[];
349
350
  id: string;
350
351
  title: string;
351
- tags: string[];
352
352
  createdAt: string;
353
353
  category: string;
354
354
  public: boolean;
@@ -389,8 +389,8 @@ declare const SurveyDefinitionSchema: z.ZodObject<{
389
389
  commentPrompt: z.ZodOptional<z.ZodString>;
390
390
  createdAt: z.ZodString;
391
391
  }, "strip", z.ZodTypeAny, {
392
- id: string;
393
392
  type: "nps" | "csat" | "ces";
393
+ id: string;
394
394
  createdAt: string;
395
395
  question: string;
396
396
  scale: {
@@ -544,4 +544,4 @@ declare const VERSION = "0.1.0";
544
544
 
545
545
  //#endregion
546
546
  export { type GlobalSources, type InteractionEntry, type KbArticle, type MainFacts, type PipelineDeal, type QuoteLineItem, type Quote as QuoteRecord, type SurveyDefinition, type SurveyResponse, type TicketPriority, type Ticket as TicketRecord, type TicketStatus, VERSION, canSeeCustomer, clearSession, createCustomer, customerExists, filterAuditLog, getRbacConfig, getRole, getSession, readAuditLog, readMainFacts, runAudit, runBackup, runValidate, setSession };
547
- //# sourceMappingURL=index-D8jJ1VIt.d.ts.map
547
+ //# sourceMappingURL=index-BBAlKZg6.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-D8jJ1VIt.d.ts","names":[],"sources":["../src/schemas/sources.ts","../src/schemas/main-facts.ts","../src/schemas/interaction.ts","../src/schemas/pipeline.ts","../src/schemas/ticket.ts","../src/schemas/quote.ts","../src/schemas/kb-article.ts","../src/schemas/survey.ts","../src/commands/create.ts","../src/commands/backup.ts","../src/commands/audit.ts","../src/commands/validate.ts","../src/fs/customer-dir.ts","../src/fs/audit-log.ts","../src/core/rbac.ts","../src/core/session-store.ts","../src/version.ts"],"mappings":";;;;;cAea,qBAAmB,CAAA,CAAA;;;IAAA,KAAA,aAAA;IAAA,OAAA,cAAA,aAAA,CAAA;EAUpB,CAAA,EAAA,OAAA,cAAa,EAAA;IAAA,IAAA,EAAA,OAAA;IAAkB,KAAA,EAAA,MAAA;IAAf,OAAE,EAAA,OAAA;EAAK,CAAA,EAAA;;;;ECvBtB,CAAA,CAAA,CAAA;EAoBX,QAAA,eAAA,YAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;SApB0B,EAAA,MAAA;EAAA,KAAA,CAAA,EAAA;IAsBhB,IAAA,EAAA,OAAS;IAAA,KAAA,EAAA,MAAA;IAAkB,OAAA,EAAA,OAAA;MAAf,SAAE;EAAK,QAAA,CAAA,EAAA;;;;ICtBlB,IAAA,EAAA,YAAA;IAYX,OAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;IAZiC,UAAA,CAAA,EAAA,MAAA,EAAA,GAAA,SAAA;EAAA,CAAA,GAAA,SAAA;EAcvB,OAAA,CAAA,EAAA,MAAA,GAAgB,SAAA;CAAA,CAAA;AAAU,KFS1B,aAAA,GAAgB,CAAA,CAAE,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mBAAgC;iBAUhC,OAAA,kCAAyC;iBAuBzC,cAAA;;;;;;;;UClEC,OAAA;;;;EfeJ,KAAA,CAAA,EAAA,MAAA;;iBeNG,UAAA,IAAc;iBAId,UAAA,CAAA,GAAc;iBAId,YAAA,CAAA;;;;cCjBH,OAAA"}
1
+ {"version":3,"file":"index-BBAlKZg6.d.ts","names":[],"sources":["../src/schemas/sources.ts","../src/schemas/main-facts.ts","../src/schemas/interaction.ts","../src/schemas/pipeline.ts","../src/schemas/ticket.ts","../src/schemas/quote.ts","../src/schemas/kb-article.ts","../src/schemas/survey.ts","../src/commands/create.ts","../src/commands/backup.ts","../src/commands/audit.ts","../src/commands/validate.ts","../src/fs/customer-dir.ts","../src/fs/audit-log.ts","../src/core/rbac.ts","../src/core/session-store.ts","../src/version.ts"],"mappings":";;;;;cAea,qBAAmB,CAAA,CAAA;;;IAAA,KAAA,aAAA;IAAA,OAAA,cAAA,aAAA,CAAA;EAUpB,CAAA,EAAA,OAAA,cAAa,EAAA;IAAA,IAAA,EAAA,OAAA;IAAkB,KAAA,EAAA,MAAA;IAAf,OAAE,EAAA,OAAA;EAAK,CAAA,EAAA;;;;ECvBtB,CAAA,CAAA,CAAA;EAoBX,QAAA,eAAA,YAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;SApB0B,EAAA,MAAA;EAAA,KAAA,CAAA,EAAA;IAsBhB,IAAA,EAAA,OAAS;IAAA,KAAA,EAAA,MAAA;IAAkB,OAAA,EAAA,OAAA;MAAf,SAAE;EAAK,QAAA,CAAA,EAAA;;;;ICtBlB,IAAA,EAAA,YAAA;IAYX,OAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;IAZiC,UAAA,CAAA,EAAA,MAAA,EAAA,GAAA,SAAA;EAAA,CAAA,GAAA,SAAA;EAcvB,OAAA,CAAA,EAAA,MAAA,GAAgB,SAAA;CAAA,CAAA;AAAU,KFS1B,aAAA,GAAgB,CAAA,CAAE,KETQ,CAAA,OFSK,mBETL,CAA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yC;iBAuBzC,cAAA;;;;;;;;UClEC,OAAA;;;;EfeJ,KAAA,CAAA,EAAA,MAAA;;iBeNG,UAAA,IAAc;iBAId,UAAA,CAAA,GAAc;iBAId,YAAA,CAAA;;;;cCjBH,OAAA"}
@@ -42,8 +42,8 @@ declare const GlobalSourcesSchema: z.ZodObject<{
42
42
  version: z.ZodDefault<z.ZodNumber>;
43
43
  created: z.ZodString;
44
44
  }, "strip", z.ZodTypeAny, {
45
- version: number;
46
45
  created: string;
46
+ version: number;
47
47
  gmail?: {
48
48
  type: "gmail";
49
49
  query: string;
@@ -96,11 +96,11 @@ declare const MainFactsSchema: z.ZodObject<{
96
96
  updated: z.ZodEffects<z.ZodString, string, unknown>;
97
97
  }, "strip", z.ZodTypeAny, {
98
98
  name: string;
99
- currency: string;
100
- updated: string;
101
- created: string;
102
99
  relationship_stage: "prospect" | "active" | "churned" | "paused";
100
+ currency: string;
103
101
  tags: string[];
102
+ created: string;
103
+ updated: string;
104
104
  domain?: string | undefined;
105
105
  email?: string | undefined;
106
106
  phone?: string | undefined;
@@ -111,17 +111,17 @@ declare const MainFactsSchema: z.ZodObject<{
111
111
  }, {
112
112
  name: string;
113
113
  relationship_stage: "prospect" | "active" | "churned" | "paused";
114
- currency?: string | undefined;
115
- updated?: unknown;
116
- created?: unknown;
117
114
  domain?: string | undefined;
118
115
  email?: string | undefined;
119
116
  phone?: string | undefined;
120
117
  industry?: string | undefined;
121
118
  deal_value?: number | undefined;
119
+ currency?: string | undefined;
122
120
  primary_contact?: string | undefined;
123
121
  timezone?: string | undefined;
124
122
  tags?: string[] | undefined;
123
+ created?: unknown;
124
+ updated?: unknown;
125
125
  }>;
126
126
  type MainFacts = z.infer<typeof MainFactsSchema>;
127
127
  //# sourceMappingURL=main-facts.d.ts.map
@@ -177,17 +177,17 @@ declare const PipelineDealSchema: z.ZodObject<{
177
177
  updated: z.ZodString;
178
178
  }, "strip", z.ZodTypeAny, {
179
179
  name: string;
180
- stage: "lead" | "qualified" | "proposal" | "negotiation" | "won" | "lost";
181
180
  currency: string;
182
181
  updated: string;
182
+ stage: "lead" | "qualified" | "proposal" | "negotiation" | "won" | "lost";
183
183
  value?: number | undefined;
184
184
  probability?: number | undefined;
185
185
  close_date?: string | undefined;
186
186
  notes?: string | undefined;
187
187
  }, {
188
188
  name: string;
189
- stage: "lead" | "qualified" | "proposal" | "negotiation" | "won" | "lost";
190
189
  updated: string;
190
+ stage: "lead" | "qualified" | "proposal" | "negotiation" | "won" | "lost";
191
191
  value?: number | undefined;
192
192
  currency?: string | undefined;
193
193
  probability?: number | undefined;
@@ -288,9 +288,10 @@ declare const QuoteSchema: z.ZodObject<{
288
288
  }, "strip", z.ZodTypeAny, {
289
289
  status: "draft" | "sent" | "viewed" | "accepted" | "declined";
290
290
  currency: string;
291
+ createdAt: string;
292
+ slug: string;
291
293
  total: number;
292
294
  quoteNumber: string;
293
- slug: string;
294
295
  dealName: string;
295
296
  lineItems: {
296
297
  description: string;
@@ -301,16 +302,16 @@ declare const QuoteSchema: z.ZodObject<{
301
302
  subtotal: number;
302
303
  vatPercent: number;
303
304
  vat: number;
304
- createdAt: string;
305
305
  validUntilDays: number;
306
306
  validUntil: string;
307
307
  viewedAt?: string | undefined;
308
308
  acceptedAt?: string | undefined;
309
309
  htmlPath?: string | undefined;
310
310
  }, {
311
+ createdAt: string;
312
+ slug: string;
311
313
  total: number;
312
314
  quoteNumber: string;
313
- slug: string;
314
315
  dealName: string;
315
316
  lineItems: {
316
317
  description: string;
@@ -321,7 +322,6 @@ declare const QuoteSchema: z.ZodObject<{
321
322
  subtotal: number;
322
323
  vatPercent: number;
323
324
  vat: number;
324
- createdAt: string;
325
325
  validUntil: string;
326
326
  status?: "draft" | "sent" | "viewed" | "accepted" | "declined" | undefined;
327
327
  currency?: string | undefined;
@@ -347,16 +347,16 @@ declare const KbArticleSchema: z.ZodObject<{
347
347
  }, "strip", z.ZodTypeAny, {
348
348
  tags: string[];
349
349
  id: string;
350
- title: string;
351
350
  createdAt: string;
351
+ title: string;
352
352
  category: string;
353
353
  public: boolean;
354
354
  updatedAt: string;
355
355
  sourceTicketId?: string | undefined;
356
356
  }, {
357
357
  id: string;
358
- title: string;
359
358
  createdAt: string;
359
+ title: string;
360
360
  updatedAt: string;
361
361
  tags?: string[] | undefined;
362
362
  category?: string | undefined;
@@ -390,18 +390,18 @@ declare const SurveyDefinitionSchema: z.ZodObject<{
390
390
  }, "strip", z.ZodTypeAny, {
391
391
  type: "nps" | "csat" | "ces";
392
392
  id: string;
393
- createdAt: string;
394
393
  question: string;
395
394
  scale: {
396
395
  min: number;
397
396
  max: number;
398
397
  };
399
398
  includeComment: boolean;
399
+ createdAt: string;
400
400
  commentPrompt?: string | undefined;
401
401
  }, {
402
402
  id: string;
403
- createdAt: string;
404
403
  question: string;
404
+ createdAt: string;
405
405
  type?: "nps" | "csat" | "ces" | undefined;
406
406
  scale?: {
407
407
  min?: number | undefined;
@@ -420,8 +420,8 @@ declare const SurveyResponseSchema: z.ZodObject<{
420
420
  token: z.ZodString;
421
421
  sentAt: z.ZodString;
422
422
  }, "strip", z.ZodTypeAny, {
423
- slug: string;
424
423
  surveyId: string;
424
+ slug: string;
425
425
  contactEmail: string;
426
426
  score: number;
427
427
  respondedAt: string;
@@ -429,8 +429,8 @@ declare const SurveyResponseSchema: z.ZodObject<{
429
429
  sentAt: string;
430
430
  comment?: string | undefined;
431
431
  }, {
432
- slug: string;
433
432
  surveyId: string;
433
+ slug: string;
434
434
  contactEmail: string;
435
435
  score: number;
436
436
  respondedAt: string;
@@ -543,4 +543,4 @@ declare const VERSION = "0.1.0";
543
543
 
544
544
  //#endregion
545
545
  export { type GlobalSources, type InteractionEntry, type KbArticle, type MainFacts, type PipelineDeal, type QuoteLineItem, type Quote as QuoteRecord, type SurveyDefinition, type SurveyResponse, type TicketPriority, type Ticket as TicketRecord, type TicketStatus, VERSION, canSeeCustomer, clearSession, createCustomer, customerExists, filterAuditLog, getRbacConfig, getRole, getSession, readAuditLog, readMainFacts, runAudit, runBackup, runValidate, setSession };
546
- //# sourceMappingURL=index-CLUKKfGb.d.cts.map
546
+ //# sourceMappingURL=index-Dspvybo0.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Dspvybo0.d.cts","names":[],"sources":["../src/schemas/sources.ts","../src/schemas/main-facts.ts","../src/schemas/interaction.ts","../src/schemas/pipeline.ts","../src/schemas/ticket.ts","../src/schemas/quote.ts","../src/schemas/kb-article.ts","../src/schemas/survey.ts","../src/commands/create.ts","../src/commands/backup.ts","../src/commands/audit.ts","../src/commands/validate.ts","../src/fs/customer-dir.ts","../src/fs/audit-log.ts","../src/core/rbac.ts","../src/core/session-store.ts","../src/version.ts"],"mappings":";;;;cAea,qBAAmB,CAAA,CAAA;;IAAA,IAAA,cAAA,CAAA,OAAA,CAAA;IAAA,KAAA,aAAA;IAUpB,OAAA,cAAa,aAAA,CAAA;EAAA,CAAA,EAAA,OAAA,cAAA,EAAA;IAAkB,IAAA,EAAA,OAAA;IAAf,KAAE,EAAA,MAAA;IAAK,OAAA,EAAA,OAAA;;;;ICvBtB,OAAA,CAAA,EAAA,OAoBX,GAAA,SAAA;EAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;SApB0B,EAAA,MAAA;EAAA,OAAA,EAAA,MAAA;EAsBhB,KAAA,CAAA,EAAA;IAAS,IAAA,EAAA,OAAA;IAAkB,KAAA,EAAA,MAAA;IAAf,OAAE,EAAA,OAAA;EAAK,CAAA,GAAA,SAAA;;;;ECtBlB,WAAA,CAAA,EAAA;IAYX,IAAA,EAAA,YAAA;;;;;;;;;;;;;;;;;;IAZiC,OAAA,CAAA,EAAA,OAAA,GAAA,SAAA;IAAA,UAAA,CAAA,EAAA,MAAA,EAAA,GAAA,SAAA;EAcvB,CAAA,GAAA,SAAA;EAAgB,OAAA,CAAA,EAAA,MAAA,GAAA,SAAA;;KFShB,aAAA,GAAgB,CAAA,CAAE,aAAa;;;;cCvB9B,iBAAe,C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