@mukulaggarwal/pacman 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.
Files changed (53) hide show
  1. package/README.md +39 -0
  2. package/dist/chunk-3QNXXON5.js +330 -0
  3. package/dist/chunk-3QNXXON5.js.map +1 -0
  4. package/dist/chunk-43PUZDIZ.js +148 -0
  5. package/dist/chunk-43PUZDIZ.js.map +1 -0
  6. package/dist/chunk-7D4SUZUM.js +38 -0
  7. package/dist/chunk-7D4SUZUM.js.map +1 -0
  8. package/dist/chunk-AYFIQNZ5.js +807 -0
  9. package/dist/chunk-AYFIQNZ5.js.map +1 -0
  10. package/dist/chunk-FH6ZHWGR.js +37 -0
  11. package/dist/chunk-FH6ZHWGR.js.map +1 -0
  12. package/dist/chunk-O6T35A4O.js +137 -0
  13. package/dist/chunk-O6T35A4O.js.map +1 -0
  14. package/dist/chunk-TRQIZP6Z.js +451 -0
  15. package/dist/chunk-TRQIZP6Z.js.map +1 -0
  16. package/dist/chunk-UWT6AFJB.js +471 -0
  17. package/dist/chunk-UWT6AFJB.js.map +1 -0
  18. package/dist/chunk-ZKKMIDRK.js +3923 -0
  19. package/dist/chunk-ZKKMIDRK.js.map +1 -0
  20. package/dist/daemon.d.ts +3 -0
  21. package/dist/daemon.js +141 -0
  22. package/dist/daemon.js.map +1 -0
  23. package/dist/dist-3PIJOFZ4.js +91 -0
  24. package/dist/dist-3PIJOFZ4.js.map +1 -0
  25. package/dist/dist-L76NGFFH.js +102 -0
  26. package/dist/dist-L76NGFFH.js.map +1 -0
  27. package/dist/dist-NV2YVVHI.js +178 -0
  28. package/dist/dist-NV2YVVHI.js.map +1 -0
  29. package/dist/dist-RMYCRZIU.js +41 -0
  30. package/dist/dist-RMYCRZIU.js.map +1 -0
  31. package/dist/dist-THLCZNOZ.js +14 -0
  32. package/dist/dist-THLCZNOZ.js.map +1 -0
  33. package/dist/dist-TWNHTXYH.js +95 -0
  34. package/dist/dist-TWNHTXYH.js.map +1 -0
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.js +452 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/mcp-compat.d.ts +1 -0
  39. package/dist/mcp-compat.js +78 -0
  40. package/dist/mcp-compat.js.map +1 -0
  41. package/dist/onboarding-server.d.ts +3 -0
  42. package/dist/onboarding-server.js +1172 -0
  43. package/dist/onboarding-server.js.map +1 -0
  44. package/dist/provider-runtime.d.ts +11 -0
  45. package/dist/provider-runtime.js +10 -0
  46. package/dist/provider-runtime.js.map +1 -0
  47. package/dist/slack-listener.d.ts +49 -0
  48. package/dist/slack-listener.js +888 -0
  49. package/dist/slack-listener.js.map +1 -0
  50. package/dist/storage.d.ts +8 -0
  51. package/dist/storage.js +9 -0
  52. package/dist/storage.js.map +1 -0
  53. package/package.json +75 -0
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # pacman
2
+
3
+ Privacy-first personal assistant context manager with onboarding, MCP, and Slack runtime.
4
+
5
+ Install:
6
+
7
+ ```bash
8
+ npm install -g @mukulaggarwal/pacman
9
+ ```
10
+
11
+ Primary commands:
12
+
13
+ ```bash
14
+ pacman init
15
+ pacman claude install
16
+ pacman codex install
17
+ pacman mcp claude install
18
+ pacman mcp codex install
19
+ pacman daemon
20
+ pacman slack listen
21
+ ```
22
+
23
+ Compatibility aliases shipped in the same package:
24
+
25
+ ```bash
26
+ personal-assistant
27
+ personal-assistant-mcp
28
+ ```
29
+
30
+ Manual MCP fallback:
31
+
32
+ ```bash
33
+ claude mcp add -s user --env=PA_WORKSPACE=$HOME/.personal-assistant personal_assistant -- npx -y pacman mcp serve
34
+ codex mcp add personal_assistant --env PA_WORKSPACE=$HOME/.personal-assistant -- npx -y pacman mcp serve
35
+ ```
36
+
37
+ Full docs, release notes, and contribution guide:
38
+
39
+ - https://github.com/mukulaggarwal/personal-assistant-with-context
@@ -0,0 +1,330 @@
1
+ import {
2
+ WORKSPACE_PATHS
3
+ } from "./chunk-TRQIZP6Z.js";
4
+
5
+ // ../indexer/dist/index.js
6
+ import * as crypto from "crypto";
7
+ var FileIndexer = class {
8
+ constructor(storage) {
9
+ this.storage = storage;
10
+ }
11
+ async buildIndexes() {
12
+ const manifest = await this.buildManifest();
13
+ const chunks = await this.buildChunks(manifest);
14
+ const entities = await this.buildEntities(chunks);
15
+ const recent = await this.buildRecent(manifest);
16
+ await this.storage.mkdir("context/derived/indexes");
17
+ await Promise.all([
18
+ this.storage.write(WORKSPACE_PATHS.context.derived.indexes.manifest, JSON.stringify(manifest, null, 2)),
19
+ this.storage.write(
20
+ WORKSPACE_PATHS.context.derived.indexes.chunks,
21
+ chunks.map((c) => JSON.stringify(c)).join("\n")
22
+ ),
23
+ this.storage.write(
24
+ WORKSPACE_PATHS.context.derived.indexes.entities,
25
+ JSON.stringify(entities, null, 2)
26
+ ),
27
+ this.storage.write(WORKSPACE_PATHS.context.derived.indexes.recent, JSON.stringify(recent, null, 2))
28
+ ]);
29
+ }
30
+ async search(query) {
31
+ const results = [];
32
+ const queryLower = query.toLowerCase();
33
+ const queryTerms = queryLower.split(/\s+/).filter(Boolean);
34
+ const canonicalResults = await this.searchCanonical(queryTerms);
35
+ results.push(...canonicalResults);
36
+ const projectResults = await this.searchProjects(queryLower);
37
+ results.push(...projectResults);
38
+ const entityResults = await this.searchEntities(queryTerms);
39
+ results.push(...entityResults);
40
+ const chunkResults = await this.searchChunks(queryTerms);
41
+ results.push(...chunkResults);
42
+ const dailyResults = await this.searchDailySummaries(queryTerms);
43
+ results.push(...dailyResults);
44
+ const seen = /* @__PURE__ */ new Set();
45
+ return results.filter((r) => {
46
+ const key = `${r.filePath}:${r.section ?? ""}`;
47
+ if (seen.has(key)) return false;
48
+ seen.add(key);
49
+ return true;
50
+ }).sort((a, b) => b.score - a.score).slice(0, 20);
51
+ }
52
+ async buildManifest() {
53
+ const entries = [];
54
+ const scanDir = async (dir, type) => {
55
+ try {
56
+ const files = await this.storage.list(dir);
57
+ for (const file of files) {
58
+ const filePath = `${dir}/${file}`;
59
+ try {
60
+ const content = await this.storage.read(filePath);
61
+ entries.push({
62
+ path: filePath,
63
+ type,
64
+ size: content.length,
65
+ lastModified: (/* @__PURE__ */ new Date()).toISOString(),
66
+ hash: crypto.createHash("sha256").update(content).digest("hex").slice(0, 16)
67
+ });
68
+ } catch {
69
+ }
70
+ }
71
+ } catch {
72
+ }
73
+ };
74
+ await Promise.all([
75
+ scanDir("context/canonical", "canonical"),
76
+ scanDir("context/canonical/projects", "canonical"),
77
+ scanDir("context/derived/daily", "derived"),
78
+ scanDir("context/raw/slack", "raw"),
79
+ scanDir("context/raw/gmail", "raw"),
80
+ scanDir("context/raw/github", "raw"),
81
+ scanDir("context/raw/gitlab", "raw"),
82
+ scanDir("context/raw/gdrive", "raw"),
83
+ scanDir("context/raw/gchat", "raw")
84
+ ]);
85
+ return {
86
+ files: entries,
87
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString()
88
+ };
89
+ }
90
+ async buildChunks(manifest) {
91
+ const chunks = [];
92
+ for (const entry of manifest.files) {
93
+ try {
94
+ const content = await this.storage.read(entry.path);
95
+ const sections = this.splitIntoSections(content);
96
+ for (const section of sections) {
97
+ chunks.push({
98
+ id: crypto.randomUUID(),
99
+ filePath: entry.path,
100
+ section: section.heading,
101
+ content: section.content,
102
+ entities: this.extractEntities(section.content),
103
+ keywords: this.extractKeywords(section.content)
104
+ });
105
+ }
106
+ } catch {
107
+ }
108
+ }
109
+ return chunks;
110
+ }
111
+ async buildEntities(chunks) {
112
+ const entityMap = /* @__PURE__ */ new Map();
113
+ for (const chunk of chunks) {
114
+ for (const entityName of chunk.entities) {
115
+ let entry = entityMap.get(entityName.toLowerCase());
116
+ if (!entry) {
117
+ entry = {
118
+ name: entityName,
119
+ type: "other",
120
+ mentions: []
121
+ };
122
+ entityMap.set(entityName.toLowerCase(), entry);
123
+ }
124
+ entry.mentions.push({
125
+ filePath: chunk.filePath,
126
+ section: chunk.section,
127
+ context: chunk.content.slice(0, 200)
128
+ });
129
+ }
130
+ }
131
+ return {
132
+ entities: Array.from(entityMap.values()),
133
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString()
134
+ };
135
+ }
136
+ async buildRecent(manifest) {
137
+ const sorted = [...manifest.files].sort(
138
+ (a, b) => new Date(b.lastModified).getTime() - new Date(a.lastModified).getTime()
139
+ );
140
+ return { files: sorted.slice(0, 20) };
141
+ }
142
+ splitIntoSections(content) {
143
+ const lines = content.split("\n");
144
+ const sections = [];
145
+ let currentHeading = "top";
146
+ let currentContent = [];
147
+ for (const line of lines) {
148
+ const headingMatch = line.match(/^#+\s+(.+)/);
149
+ if (headingMatch) {
150
+ if (currentContent.length > 0) {
151
+ sections.push({ heading: currentHeading, content: currentContent.join("\n").trim() });
152
+ }
153
+ currentHeading = headingMatch[1];
154
+ currentContent = [];
155
+ } else {
156
+ currentContent.push(line);
157
+ }
158
+ }
159
+ if (currentContent.length > 0) {
160
+ sections.push({ heading: currentHeading, content: currentContent.join("\n").trim() });
161
+ }
162
+ return sections;
163
+ }
164
+ extractEntities(content) {
165
+ const entities = [];
166
+ const mentions = content.match(/@[\w.-]+/g);
167
+ if (mentions) entities.push(...mentions);
168
+ const names = content.match(/\b[A-Z][a-z]+(?:\s[A-Z][a-z]+)+\b/g);
169
+ if (names) entities.push(...names);
170
+ return [...new Set(entities)];
171
+ }
172
+ extractKeywords(content) {
173
+ const words = content.toLowerCase().replace(/[^a-z0-9\s-]/g, "").split(/\s+/).filter((w) => w.length > 3);
174
+ const stopWords = /* @__PURE__ */ new Set([
175
+ "this",
176
+ "that",
177
+ "with",
178
+ "from",
179
+ "have",
180
+ "been",
181
+ "will",
182
+ "your",
183
+ "they",
184
+ "their",
185
+ "about",
186
+ "would",
187
+ "there",
188
+ "which",
189
+ "when",
190
+ "what",
191
+ "were",
192
+ "them",
193
+ "some",
194
+ "into",
195
+ "other",
196
+ "than",
197
+ "then",
198
+ "these",
199
+ "more",
200
+ "also",
201
+ "each",
202
+ "only"
203
+ ]);
204
+ const filtered = words.filter((w) => !stopWords.has(w));
205
+ const freq = /* @__PURE__ */ new Map();
206
+ for (const w of filtered) {
207
+ freq.set(w, (freq.get(w) ?? 0) + 1);
208
+ }
209
+ return Array.from(freq.entries()).sort((a, b) => b[1] - a[1]).slice(0, 20).map(([w]) => w);
210
+ }
211
+ async searchCanonical(terms) {
212
+ const results = [];
213
+ const canonicalDir = "context/canonical";
214
+ try {
215
+ const files = await this.storage.list(canonicalDir);
216
+ for (const file of files) {
217
+ if (!file.endsWith(".md")) continue;
218
+ const filePath = `${canonicalDir}/${file}`;
219
+ const content = await this.storage.read(filePath);
220
+ const score = this.computeScore(content.toLowerCase(), terms);
221
+ if (score > 0) {
222
+ results.push({ filePath, content: content.slice(0, 500), score: score + 10, matchType: "exact" });
223
+ }
224
+ }
225
+ } catch {
226
+ }
227
+ return results;
228
+ }
229
+ async searchProjects(query) {
230
+ const results = [];
231
+ const projectsDir = "context/canonical/projects";
232
+ try {
233
+ const files = await this.storage.list(projectsDir);
234
+ for (const file of files) {
235
+ const projectName = file.replace(".md", "");
236
+ if (projectName.toLowerCase().includes(query) || query.includes(projectName.toLowerCase())) {
237
+ const filePath = `${projectsDir}/${file}`;
238
+ const content = await this.storage.read(filePath);
239
+ results.push({ filePath, content: content.slice(0, 500), score: 20, matchType: "project" });
240
+ }
241
+ }
242
+ } catch {
243
+ }
244
+ return results;
245
+ }
246
+ async searchEntities(terms) {
247
+ const results = [];
248
+ try {
249
+ const entitiesJson = await this.storage.read(WORKSPACE_PATHS.context.derived.indexes.entities);
250
+ const entities = JSON.parse(entitiesJson);
251
+ for (const entity of entities.entities) {
252
+ const nameMatch = terms.some((t) => entity.name.toLowerCase().includes(t));
253
+ if (nameMatch) {
254
+ for (const mention of entity.mentions.slice(0, 3)) {
255
+ results.push({
256
+ filePath: mention.filePath,
257
+ section: mention.section,
258
+ content: mention.context,
259
+ score: 15,
260
+ matchType: "entity"
261
+ });
262
+ }
263
+ }
264
+ }
265
+ } catch {
266
+ }
267
+ return results;
268
+ }
269
+ async searchChunks(terms) {
270
+ const results = [];
271
+ try {
272
+ const chunksData = await this.storage.read(WORKSPACE_PATHS.context.derived.indexes.chunks);
273
+ const chunks = chunksData.split("\n").filter(Boolean).map((line) => JSON.parse(line));
274
+ for (const chunk of chunks) {
275
+ const score = this.computeScore(chunk.content.toLowerCase(), terms);
276
+ if (score > 0) {
277
+ results.push({
278
+ filePath: chunk.filePath,
279
+ section: chunk.section,
280
+ content: chunk.content.slice(0, 500),
281
+ score,
282
+ matchType: "keyword"
283
+ });
284
+ }
285
+ }
286
+ } catch {
287
+ }
288
+ return results;
289
+ }
290
+ async searchDailySummaries(terms) {
291
+ const results = [];
292
+ const dailyDir = "context/derived/daily";
293
+ try {
294
+ const files = await this.storage.list(dailyDir);
295
+ const recent = files.sort().reverse().slice(0, 7);
296
+ for (const file of recent) {
297
+ const filePath = `${dailyDir}/${file}`;
298
+ const content = await this.storage.read(filePath);
299
+ const score = this.computeScore(content.toLowerCase(), terms);
300
+ if (score > 0) {
301
+ results.push({
302
+ filePath,
303
+ content: content.slice(0, 500),
304
+ score: score + 5,
305
+ // freshness bonus
306
+ matchType: "fuzzy"
307
+ });
308
+ }
309
+ }
310
+ } catch {
311
+ }
312
+ return results;
313
+ }
314
+ computeScore(content, terms) {
315
+ let score = 0;
316
+ for (const term of terms) {
317
+ const matches = content.split(term).length - 1;
318
+ score += matches;
319
+ }
320
+ return score;
321
+ }
322
+ };
323
+ function createIndexer(storage) {
324
+ return new FileIndexer(storage);
325
+ }
326
+
327
+ export {
328
+ createIndexer
329
+ };
330
+ //# sourceMappingURL=chunk-3QNXXON5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../indexer/dist/index.js"],"sourcesContent":["// src/index.ts\nimport * as crypto from \"crypto\";\nimport { WORKSPACE_PATHS as PATHS } from \"@personal-assistant/core-types\";\nvar FileIndexer = class {\n constructor(storage) {\n this.storage = storage;\n }\n async buildIndexes() {\n const manifest = await this.buildManifest();\n const chunks = await this.buildChunks(manifest);\n const entities = await this.buildEntities(chunks);\n const recent = await this.buildRecent(manifest);\n await this.storage.mkdir(\"context/derived/indexes\");\n await Promise.all([\n this.storage.write(PATHS.context.derived.indexes.manifest, JSON.stringify(manifest, null, 2)),\n this.storage.write(\n PATHS.context.derived.indexes.chunks,\n chunks.map((c) => JSON.stringify(c)).join(\"\\n\")\n ),\n this.storage.write(\n PATHS.context.derived.indexes.entities,\n JSON.stringify(entities, null, 2)\n ),\n this.storage.write(PATHS.context.derived.indexes.recent, JSON.stringify(recent, null, 2))\n ]);\n }\n async search(query) {\n const results = [];\n const queryLower = query.toLowerCase();\n const queryTerms = queryLower.split(/\\s+/).filter(Boolean);\n const canonicalResults = await this.searchCanonical(queryTerms);\n results.push(...canonicalResults);\n const projectResults = await this.searchProjects(queryLower);\n results.push(...projectResults);\n const entityResults = await this.searchEntities(queryTerms);\n results.push(...entityResults);\n const chunkResults = await this.searchChunks(queryTerms);\n results.push(...chunkResults);\n const dailyResults = await this.searchDailySummaries(queryTerms);\n results.push(...dailyResults);\n const seen = /* @__PURE__ */ new Set();\n return results.filter((r) => {\n const key = `${r.filePath}:${r.section ?? \"\"}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n }).sort((a, b) => b.score - a.score).slice(0, 20);\n }\n async buildManifest() {\n const entries = [];\n const scanDir = async (dir, type) => {\n try {\n const files = await this.storage.list(dir);\n for (const file of files) {\n const filePath = `${dir}/${file}`;\n try {\n const content = await this.storage.read(filePath);\n entries.push({\n path: filePath,\n type,\n size: content.length,\n lastModified: (/* @__PURE__ */ new Date()).toISOString(),\n hash: crypto.createHash(\"sha256\").update(content).digest(\"hex\").slice(0, 16)\n });\n } catch {\n }\n }\n } catch {\n }\n };\n await Promise.all([\n scanDir(\"context/canonical\", \"canonical\"),\n scanDir(\"context/canonical/projects\", \"canonical\"),\n scanDir(\"context/derived/daily\", \"derived\"),\n scanDir(\"context/raw/slack\", \"raw\"),\n scanDir(\"context/raw/gmail\", \"raw\"),\n scanDir(\"context/raw/github\", \"raw\"),\n scanDir(\"context/raw/gitlab\", \"raw\"),\n scanDir(\"context/raw/gdrive\", \"raw\"),\n scanDir(\"context/raw/gchat\", \"raw\")\n ]);\n return {\n files: entries,\n generatedAt: (/* @__PURE__ */ new Date()).toISOString()\n };\n }\n async buildChunks(manifest) {\n const chunks = [];\n for (const entry of manifest.files) {\n try {\n const content = await this.storage.read(entry.path);\n const sections = this.splitIntoSections(content);\n for (const section of sections) {\n chunks.push({\n id: crypto.randomUUID(),\n filePath: entry.path,\n section: section.heading,\n content: section.content,\n entities: this.extractEntities(section.content),\n keywords: this.extractKeywords(section.content)\n });\n }\n } catch {\n }\n }\n return chunks;\n }\n async buildEntities(chunks) {\n const entityMap = /* @__PURE__ */ new Map();\n for (const chunk of chunks) {\n for (const entityName of chunk.entities) {\n let entry = entityMap.get(entityName.toLowerCase());\n if (!entry) {\n entry = {\n name: entityName,\n type: \"other\",\n mentions: []\n };\n entityMap.set(entityName.toLowerCase(), entry);\n }\n entry.mentions.push({\n filePath: chunk.filePath,\n section: chunk.section,\n context: chunk.content.slice(0, 200)\n });\n }\n }\n return {\n entities: Array.from(entityMap.values()),\n generatedAt: (/* @__PURE__ */ new Date()).toISOString()\n };\n }\n async buildRecent(manifest) {\n const sorted = [...manifest.files].sort(\n (a, b) => new Date(b.lastModified).getTime() - new Date(a.lastModified).getTime()\n );\n return { files: sorted.slice(0, 20) };\n }\n splitIntoSections(content) {\n const lines = content.split(\"\\n\");\n const sections = [];\n let currentHeading = \"top\";\n let currentContent = [];\n for (const line of lines) {\n const headingMatch = line.match(/^#+\\s+(.+)/);\n if (headingMatch) {\n if (currentContent.length > 0) {\n sections.push({ heading: currentHeading, content: currentContent.join(\"\\n\").trim() });\n }\n currentHeading = headingMatch[1];\n currentContent = [];\n } else {\n currentContent.push(line);\n }\n }\n if (currentContent.length > 0) {\n sections.push({ heading: currentHeading, content: currentContent.join(\"\\n\").trim() });\n }\n return sections;\n }\n extractEntities(content) {\n const entities = [];\n const mentions = content.match(/@[\\w.-]+/g);\n if (mentions) entities.push(...mentions);\n const names = content.match(/\\b[A-Z][a-z]+(?:\\s[A-Z][a-z]+)+\\b/g);\n if (names) entities.push(...names);\n return [...new Set(entities)];\n }\n extractKeywords(content) {\n const words = content.toLowerCase().replace(/[^a-z0-9\\s-]/g, \"\").split(/\\s+/).filter((w) => w.length > 3);\n const stopWords = /* @__PURE__ */ new Set([\n \"this\",\n \"that\",\n \"with\",\n \"from\",\n \"have\",\n \"been\",\n \"will\",\n \"your\",\n \"they\",\n \"their\",\n \"about\",\n \"would\",\n \"there\",\n \"which\",\n \"when\",\n \"what\",\n \"were\",\n \"them\",\n \"some\",\n \"into\",\n \"other\",\n \"than\",\n \"then\",\n \"these\",\n \"more\",\n \"also\",\n \"each\",\n \"only\"\n ]);\n const filtered = words.filter((w) => !stopWords.has(w));\n const freq = /* @__PURE__ */ new Map();\n for (const w of filtered) {\n freq.set(w, (freq.get(w) ?? 0) + 1);\n }\n return Array.from(freq.entries()).sort((a, b) => b[1] - a[1]).slice(0, 20).map(([w]) => w);\n }\n async searchCanonical(terms) {\n const results = [];\n const canonicalDir = \"context/canonical\";\n try {\n const files = await this.storage.list(canonicalDir);\n for (const file of files) {\n if (!file.endsWith(\".md\")) continue;\n const filePath = `${canonicalDir}/${file}`;\n const content = await this.storage.read(filePath);\n const score = this.computeScore(content.toLowerCase(), terms);\n if (score > 0) {\n results.push({ filePath, content: content.slice(0, 500), score: score + 10, matchType: \"exact\" });\n }\n }\n } catch {\n }\n return results;\n }\n async searchProjects(query) {\n const results = [];\n const projectsDir = \"context/canonical/projects\";\n try {\n const files = await this.storage.list(projectsDir);\n for (const file of files) {\n const projectName = file.replace(\".md\", \"\");\n if (projectName.toLowerCase().includes(query) || query.includes(projectName.toLowerCase())) {\n const filePath = `${projectsDir}/${file}`;\n const content = await this.storage.read(filePath);\n results.push({ filePath, content: content.slice(0, 500), score: 20, matchType: \"project\" });\n }\n }\n } catch {\n }\n return results;\n }\n async searchEntities(terms) {\n const results = [];\n try {\n const entitiesJson = await this.storage.read(PATHS.context.derived.indexes.entities);\n const entities = JSON.parse(entitiesJson);\n for (const entity of entities.entities) {\n const nameMatch = terms.some((t) => entity.name.toLowerCase().includes(t));\n if (nameMatch) {\n for (const mention of entity.mentions.slice(0, 3)) {\n results.push({\n filePath: mention.filePath,\n section: mention.section,\n content: mention.context,\n score: 15,\n matchType: \"entity\"\n });\n }\n }\n }\n } catch {\n }\n return results;\n }\n async searchChunks(terms) {\n const results = [];\n try {\n const chunksData = await this.storage.read(PATHS.context.derived.indexes.chunks);\n const chunks = chunksData.split(\"\\n\").filter(Boolean).map((line) => JSON.parse(line));\n for (const chunk of chunks) {\n const score = this.computeScore(chunk.content.toLowerCase(), terms);\n if (score > 0) {\n results.push({\n filePath: chunk.filePath,\n section: chunk.section,\n content: chunk.content.slice(0, 500),\n score,\n matchType: \"keyword\"\n });\n }\n }\n } catch {\n }\n return results;\n }\n async searchDailySummaries(terms) {\n const results = [];\n const dailyDir = \"context/derived/daily\";\n try {\n const files = await this.storage.list(dailyDir);\n const recent = files.sort().reverse().slice(0, 7);\n for (const file of recent) {\n const filePath = `${dailyDir}/${file}`;\n const content = await this.storage.read(filePath);\n const score = this.computeScore(content.toLowerCase(), terms);\n if (score > 0) {\n results.push({\n filePath,\n content: content.slice(0, 500),\n score: score + 5,\n // freshness bonus\n matchType: \"fuzzy\"\n });\n }\n }\n } catch {\n }\n return results;\n }\n computeScore(content, terms) {\n let score = 0;\n for (const term of terms) {\n const matches = content.split(term).length - 1;\n score += matches;\n }\n return score;\n }\n};\nfunction createIndexer(storage) {\n return new FileIndexer(storage);\n}\nexport {\n FileIndexer,\n createIndexer\n};\n"],"mappings":";;;;;AACA,YAAY,YAAY;AAExB,IAAI,cAAc,MAAM;AAAA,EACtB,YAAY,SAAS;AACnB,SAAK,UAAU;AAAA,EACjB;AAAA,EACA,MAAM,eAAe;AACnB,UAAM,WAAW,MA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,UACb,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF,QAAQ;AAAA,IACR;AACA,WAAO;AAAA,EACT;AAAA,EACA,aAAa,SAAS,OAAO;AAC3B,QAAI,QAAQ;AACZ,eAAW,QAAQ,OAAO;AACxB,YAAM,UAAU,QAAQ,MAAM,IAAI,EAAE,SAAS;AAC7C,eAAS;AAAA,IACX;AACA,WAAO;AAAA,EACT;AACF;AACA,SAAS,cAAc,SAAS;AAC9B,SAAO,IAAI,YAAY,OAAO;AAChC;","names":[]}
@@ -0,0 +1,148 @@
1
+ // ../event-client/dist/index.js
2
+ var EventClient = class {
3
+ config;
4
+ constructor(config) {
5
+ this.config = config;
6
+ }
7
+ async emit(eventName, metadata) {
8
+ if (!this.config.enabled || !this.config.endpoint) {
9
+ return;
10
+ }
11
+ const payload = {
12
+ eventName,
13
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
14
+ localUserId: this.config.localUserId,
15
+ storageMode: this.config.storageMode,
16
+ appVersion: this.config.appVersion,
17
+ metadata
18
+ };
19
+ try {
20
+ await fetch(this.config.endpoint, {
21
+ method: "POST",
22
+ headers: { "Content-Type": "application/json" },
23
+ body: JSON.stringify(payload),
24
+ signal: AbortSignal.timeout(5e3)
25
+ });
26
+ } catch {
27
+ }
28
+ }
29
+ async emitWithIntegrations(eventName, integrations, metadata) {
30
+ await this.emit(eventName, {
31
+ ...metadata,
32
+ integrations_enabled: integrations.join(",")
33
+ });
34
+ }
35
+ async emitWithProject(eventName, projectName, metadata) {
36
+ const hash = await this.hashString(projectName);
37
+ await this.emit(eventName, {
38
+ ...metadata,
39
+ project_name_hash: hash
40
+ });
41
+ }
42
+ async hashString(input) {
43
+ const encoder = new TextEncoder();
44
+ const data = encoder.encode(input);
45
+ const hashBuffer = await crypto.subtle.digest("SHA-256", data);
46
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
47
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
48
+ }
49
+ };
50
+ function createNoopEventClient() {
51
+ return new EventClient({
52
+ enabled: false,
53
+ appVersion: "0.1.0",
54
+ localUserId: "anonymous",
55
+ storageMode: "local"
56
+ });
57
+ }
58
+
59
+ // ../integration-runtime/dist/index.js
60
+ async function loadConnector(configOrType) {
61
+ const type = typeof configOrType === "string" ? configOrType : configOrType.type;
62
+ switch (type) {
63
+ case "slack": {
64
+ const { createSlackConnector } = await import("./dist-THLCZNOZ.js");
65
+ return createSlackConnector();
66
+ }
67
+ case "gmail": {
68
+ const { createGmailConnector } = await import("./dist-TWNHTXYH.js");
69
+ return createGmailConnector();
70
+ }
71
+ case "github": {
72
+ const { createGitHubConnector } = await import("./dist-NV2YVVHI.js");
73
+ return createGitHubConnector();
74
+ }
75
+ case "gitlab": {
76
+ const { createGitLabConnector } = await import("./dist-L76NGFFH.js");
77
+ return createGitLabConnector();
78
+ }
79
+ case "gdrive": {
80
+ const { createGDriveDocsConnector } = await import("./dist-3PIJOFZ4.js");
81
+ return createGDriveDocsConnector();
82
+ }
83
+ case "gchat": {
84
+ const { createGChatConnector } = await import("./dist-RMYCRZIU.js");
85
+ return createGChatConnector();
86
+ }
87
+ }
88
+ const unknownType = type;
89
+ throw new Error(`Unknown integration type: ${unknownType}`);
90
+ }
91
+ async function validateIntegrationConfig(config) {
92
+ try {
93
+ const connector = await loadConnector(config);
94
+ await connector.authenticate(config);
95
+ const result = await connector.healthCheck();
96
+ return {
97
+ ok: true,
98
+ summary: result.summary ?? `Connected to ${config.type}`
99
+ };
100
+ } catch (err) {
101
+ return {
102
+ ok: false,
103
+ reason: err instanceof Error ? err.message : String(err),
104
+ fix: getIntegrationFixSteps(config.type)
105
+ };
106
+ }
107
+ }
108
+ function getIntegrationFixSteps(type) {
109
+ switch (type) {
110
+ case "slack":
111
+ return [
112
+ "Update the Slack bot token in your integrations config.",
113
+ "Ensure the app is installed to the workspace and the token starts with xoxb-."
114
+ ];
115
+ case "gmail":
116
+ return [
117
+ "Update the Gmail client ID, client secret, and refresh token in your integrations config.",
118
+ "Regenerate the refresh token if it has been revoked or expired."
119
+ ];
120
+ case "github":
121
+ return [
122
+ "Update the GitHub personal access token in your integrations config.",
123
+ "Ensure the token still has repo, notifications, and read:user scopes."
124
+ ];
125
+ case "gitlab":
126
+ return [
127
+ "Update the GitLab personal access token or base URL in your integrations config.",
128
+ "If you use self-hosted GitLab, ensure the base URL ends with /api/v4."
129
+ ];
130
+ case "gdrive":
131
+ return [
132
+ "Update the Google Drive client ID, client secret, and refresh token in your integrations config.",
133
+ "Confirm the Google Drive API is enabled for the OAuth client you are using."
134
+ ];
135
+ case "gchat":
136
+ return [
137
+ "Disable the gchat integration in your config for now.",
138
+ "The Google Chat connector is not implemented yet in this version."
139
+ ];
140
+ }
141
+ }
142
+
143
+ export {
144
+ createNoopEventClient,
145
+ loadConnector,
146
+ validateIntegrationConfig
147
+ };
148
+ //# sourceMappingURL=chunk-43PUZDIZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../event-client/dist/index.js","../../integration-runtime/dist/index.js"],"sourcesContent":["// src/index.ts\nvar EventClient = class {\n config;\n constructor(config) {\n this.config = config;\n }\n async emit(eventName, metadata) {\n if (!this.config.enabled || !this.config.endpoint) {\n return;\n }\n const payload = {\n eventName,\n timestamp: (/* @__PURE__ */ new Date()).toISOString(),\n localUserId: this.config.localUserId,\n storageMode: this.config.storageMode,\n appVersion: this.config.appVersion,\n metadata\n };\n try {\n await fetch(this.config.endpoint, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(payload),\n signal: AbortSignal.timeout(5e3)\n });\n } catch {\n }\n }\n async emitWithIntegrations(eventName, integrations, metadata) {\n await this.emit(eventName, {\n ...metadata,\n integrations_enabled: integrations.join(\",\")\n });\n }\n async emitWithProject(eventName, projectName, metadata) {\n const hash = await this.hashString(projectName);\n await this.emit(eventName, {\n ...metadata,\n project_name_hash: hash\n });\n }\n async hashString(input) {\n const encoder = new TextEncoder();\n const data = encoder.encode(input);\n const hashBuffer = await crypto.subtle.digest(\"SHA-256\", data);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map((b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n }\n};\nfunction createEventClient(config) {\n return new EventClient(config);\n}\nfunction createNoopEventClient() {\n return new EventClient({\n enabled: false,\n appVersion: \"0.1.0\",\n localUserId: \"anonymous\",\n storageMode: \"local\"\n });\n}\nexport {\n EventClient,\n createEventClient,\n createNoopEventClient\n};\n","// src/index.ts\nasync function loadConnector(configOrType) {\n const type = typeof configOrType === \"string\" ? configOrType : configOrType.type;\n switch (type) {\n case \"slack\": {\n const { createSlackConnector } = await import(\"@personal-assistant/integrations-slack\");\n return createSlackConnector();\n }\n case \"gmail\": {\n const { createGmailConnector } = await import(\"@personal-assistant/integrations-gmail\");\n return createGmailConnector();\n }\n case \"github\": {\n const { createGitHubConnector } = await import(\"@personal-assistant/integrations-github\");\n return createGitHubConnector();\n }\n case \"gitlab\": {\n const { createGitLabConnector } = await import(\"@personal-assistant/integrations-gitlab\");\n return createGitLabConnector();\n }\n case \"gdrive\": {\n const { createGDriveDocsConnector } = await import(\"@personal-assistant/integrations-gdrive\");\n return createGDriveDocsConnector();\n }\n case \"gchat\": {\n const { createGChatConnector } = await import(\"@personal-assistant/integrations-gchat\");\n return createGChatConnector();\n }\n }\n const unknownType = type;\n throw new Error(`Unknown integration type: ${unknownType}`);\n}\nasync function validateIntegrationConfig(config) {\n try {\n const connector = await loadConnector(config);\n await connector.authenticate(config);\n const result = await connector.healthCheck();\n return {\n ok: true,\n summary: result.summary ?? `Connected to ${config.type}`\n };\n } catch (err) {\n return {\n ok: false,\n reason: err instanceof Error ? err.message : String(err),\n fix: getIntegrationFixSteps(config.type)\n };\n }\n}\nfunction getIntegrationFixSteps(type) {\n switch (type) {\n case \"slack\":\n return [\n \"Update the Slack bot token in your integrations config.\",\n \"Ensure the app is installed to the workspace and the token starts with xoxb-.\"\n ];\n case \"gmail\":\n return [\n \"Update the Gmail client ID, client secret, and refresh token in your integrations config.\",\n \"Regenerate the refresh token if it has been revoked or expired.\"\n ];\n case \"github\":\n return [\n \"Update the GitHub personal access token in your integrations config.\",\n \"Ensure the token still has repo, notifications, and read:user scopes.\"\n ];\n case \"gitlab\":\n return [\n \"Update the GitLab personal access token or base URL in your integrations config.\",\n \"If you use self-hosted GitLab, ensure the base URL ends with /api/v4.\"\n ];\n case \"gdrive\":\n return [\n \"Update the Google Drive client ID, client secret, and refresh token in your integrations config.\",\n \"Confirm the Google Drive API is enabled for the OAuth client you are using.\"\n ];\n case \"gchat\":\n return [\n \"Disable the gchat integration in your config for now.\",\n \"The Google Chat connector is not implemented yet in this version.\"\n ];\n }\n}\nexport {\n getIntegrationFixSteps,\n loadConnector,\n validateIntegrationConfig\n};\n"],"mappings":";AACA,IAAI,cAAc,MAAM;AAAA,EACtB;AAAA,EACA,YAAY,QAAQ;AAClB,SAAK,SAAS;AAAA,EAChB;AAAA,EACA,MAAM,KAAK,WAAW,UAAU;AAC9B,QAAI,CAAC,KAAK,OAAO,WAAW,CAAC,KAAK,OAAO,UAAU;AACjD;AAAA,IACF;AACA,UAAM,UAAU;AAAA,MACd;AAAA,MACA,YAA4B,oBAAI,KAAK,GAAG,YAAY;AAAA,MACpD,aAAa,KAAK,OAAO;AAAA,MACzB,aAAa,KAAK,OAAO;AAAA,MACzB,YAAY,KAAK,OAAO;AAAA,MACxB;AAAA,IACF;AACA,QAAI;AACF,YAAM,MAAM,KAAK,OAAO,UAAU;AAAA,QAChC,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,QAC9C,MAAM,KAAK,UAAU,OAAO;AAAA,QAC5B,QAAQ,YAAY,QAAQ,GAAG;AAAA,MACjC,CAAC;AAAA,IACH,QAAQ;AAAA,IACR;AAAA,EACF;AAAA,EACA,MAAM,qBAAqB,WAAW,cAAc,UAAU;AAC5D,UAAM,KAAK,KAAK,WAAW;AAAA,MACzB,GAAG;AAAA,MACH,sBAAsB,aAAa,KA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AAK,UAAU;AACb,YAAM,EAAE,0BAA0B,IAAI,MAAM,OAAO,oBAAyC;AAC5F,aAAO,0BAA0B;AAAA,IACnC;AAAA,IACA,KAAK,SAAS;AACZ,YAAM,EAAE,qBAAqB,IAAI,MAAM,OAAO,oBAAwC;AACtF,aAAO,qBAAqB;AAAA,IAC9B;AAAA,EACF;AACA,QAAM,cAAc;AACpB,QAAM,IAAI,MAAM,6BAA6B,WAAW,EAAE;AAC5D;AACA,eAAe,0BAA0B,QAAQ;AAC/C,MAAI;AACF,UAAM,YAAY,MAAM,cAAc,MAAM;AAC5C,UAAM,UAAU,aAAa,MAAM;AACnC,UAAM,SAAS,MAAM,UAAU,YAAY;AAC3C,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,OAAO,WAAW,gBAAgB,OAAO,IAAI;AAAA,IACxD;AAAA,EACF,SAAS,KAAK;AACZ,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,QAAQ,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,MACvD,KAAK,uBAAuB,OAAO,IAAI;AAAA,IACzC;AAAA,EACF;AACF;AACA,SAAS,uBAAuB,MAAM;AACpC,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,EACJ;AACF;","names":[]}
@@ -0,0 +1,38 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ export {
34
+ __require,
35
+ __commonJS,
36
+ __toESM
37
+ };
38
+ //# sourceMappingURL=chunk-7D4SUZUM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}