perplexity-user-mcp 0.8.36

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 (125) hide show
  1. package/README.md +192 -0
  2. package/dist/attachments.d.ts +20 -0
  3. package/dist/attachments.mjs +43 -0
  4. package/dist/checks/browser.d.ts +100 -0
  5. package/dist/checks/browser.mjs +89 -0
  6. package/dist/checks/config.d.ts +91 -0
  7. package/dist/checks/config.mjs +88 -0
  8. package/dist/checks/ide.d.ts +89 -0
  9. package/dist/checks/ide.mjs +80 -0
  10. package/dist/checks/mcp.d.ts +61 -0
  11. package/dist/checks/mcp.mjs +56 -0
  12. package/dist/checks/native-deps.d.ts +131 -0
  13. package/dist/checks/native-deps.mjs +115 -0
  14. package/dist/checks/network.d.ts +71 -0
  15. package/dist/checks/network.mjs +70 -0
  16. package/dist/checks/probe.d.ts +93 -0
  17. package/dist/checks/probe.mjs +82 -0
  18. package/dist/checks/profiles.d.ts +99 -0
  19. package/dist/checks/profiles.mjs +90 -0
  20. package/dist/checks/runtime.d.ts +89 -0
  21. package/dist/checks/runtime.mjs +90 -0
  22. package/dist/checks/vault.d.ts +101 -0
  23. package/dist/checks/vault.mjs +90 -0
  24. package/dist/chunk-3B276PGG.mjs +115 -0
  25. package/dist/chunk-4UEJOM6W.mjs +9 -0
  26. package/dist/chunk-6EP2BLTV.mjs +205 -0
  27. package/dist/chunk-6YMQVLFX.mjs +146 -0
  28. package/dist/chunk-7JL36EBH.mjs +118 -0
  29. package/dist/chunk-DPGMKSSA.mjs +57 -0
  30. package/dist/chunk-H4BUAPPO.mjs +1950 -0
  31. package/dist/chunk-HMKLWVXB.mjs +109 -0
  32. package/dist/chunk-HTUAQRKH.mjs +125 -0
  33. package/dist/chunk-HU5B4FXS.mjs +139 -0
  34. package/dist/chunk-KCXM2M4B.mjs +1006 -0
  35. package/dist/chunk-LKJMLGFP.mjs +237 -0
  36. package/dist/chunk-LZPLNZ5U.mjs +67 -0
  37. package/dist/chunk-MTDFKNXX.mjs +19 -0
  38. package/dist/chunk-OF4DMAPJ.mjs +511 -0
  39. package/dist/chunk-PE23RMXY.mjs +43 -0
  40. package/dist/chunk-Q2VY4R5F.mjs +175 -0
  41. package/dist/chunk-S5VD7WTU.mjs +2540 -0
  42. package/dist/chunk-SVPRB62V.mjs +106 -0
  43. package/dist/chunk-TQLCLE4L.mjs +345 -0
  44. package/dist/chunk-U3DGFLXZ.mjs +43 -0
  45. package/dist/chunk-X45O6YD3.mjs +688 -0
  46. package/dist/chunk-XKSWCEGI.mjs +168 -0
  47. package/dist/chunk-Z7DAACGZ.mjs +534 -0
  48. package/dist/chunk-ZQFUZPLO.mjs +257 -0
  49. package/dist/cli.d.ts +952 -0
  50. package/dist/cli.mjs +827 -0
  51. package/dist/client.d.ts +355 -0
  52. package/dist/client.mjs +27 -0
  53. package/dist/cloud-sync.d-Cqt6y18U.d.ts +42 -0
  54. package/dist/cloud-sync.d.ts +42 -0
  55. package/dist/cloud-sync.mjs +17 -0
  56. package/dist/config.d.ts +186 -0
  57. package/dist/config.mjs +54 -0
  58. package/dist/daemon/attach.d.ts +36 -0
  59. package/dist/daemon/attach.mjs +25 -0
  60. package/dist/daemon/audit.d.ts +23 -0
  61. package/dist/daemon/audit.mjs +12 -0
  62. package/dist/daemon/client-http.d.ts +42 -0
  63. package/dist/daemon/client-http.mjs +29 -0
  64. package/dist/daemon/index.d.ts +14 -0
  65. package/dist/daemon/index.mjs +110 -0
  66. package/dist/daemon/install-tunnel.d.ts +46 -0
  67. package/dist/daemon/install-tunnel.mjs +14 -0
  68. package/dist/daemon/launcher.d.ts +163 -0
  69. package/dist/daemon/launcher.mjs +50 -0
  70. package/dist/daemon/lockfile.d.ts +29 -0
  71. package/dist/daemon/lockfile.mjs +18 -0
  72. package/dist/daemon/server.d.ts +159 -0
  73. package/dist/daemon/server.mjs +20 -0
  74. package/dist/daemon/token.d.ts +17 -0
  75. package/dist/daemon/token.mjs +17 -0
  76. package/dist/daemon/tunnel-providers/index.d.ts +330 -0
  77. package/dist/daemon/tunnel-providers/index.mjs +57 -0
  78. package/dist/daemon/tunnel.d.ts +23 -0
  79. package/dist/daemon/tunnel.mjs +9 -0
  80. package/dist/doctor-report.d.ts +24 -0
  81. package/dist/doctor-report.mjs +14 -0
  82. package/dist/doctor.d-CXmUqOXX.d.ts +43 -0
  83. package/dist/doctor.d.ts +44 -0
  84. package/dist/doctor.mjs +16 -0
  85. package/dist/export.d.ts +19 -0
  86. package/dist/export.mjs +15 -0
  87. package/dist/health-check.d.ts +108 -0
  88. package/dist/health-check.mjs +92 -0
  89. package/dist/history-store.d-BzjBF2m3.d.ts +65 -0
  90. package/dist/history-store.d.ts +65 -0
  91. package/dist/history-store.mjs +48 -0
  92. package/dist/impit-login-runner.d.ts +469 -0
  93. package/dist/impit-login-runner.mjs +685 -0
  94. package/dist/index.d.ts +159 -0
  95. package/dist/index.mjs +236 -0
  96. package/dist/login-runner.d.ts +333 -0
  97. package/dist/login-runner.mjs +320 -0
  98. package/dist/logout.d.ts +28 -0
  99. package/dist/logout.mjs +45 -0
  100. package/dist/manual-login-runner.d.ts +150 -0
  101. package/dist/manual-login-runner.mjs +146 -0
  102. package/dist/native-deps-BNThFHxa.d.ts +175 -0
  103. package/dist/native-deps-YNKXITRY.mjs +139 -0
  104. package/dist/profiles.d-DqS1oZWr.d.ts +41 -0
  105. package/dist/profiles.d.ts +41 -0
  106. package/dist/profiles.mjs +33 -0
  107. package/dist/redact.d.ts +159 -0
  108. package/dist/redact.mjs +11 -0
  109. package/dist/refresh.d.ts +118 -0
  110. package/dist/refresh.mjs +21 -0
  111. package/dist/reinit-watcher.d.ts +15 -0
  112. package/dist/reinit-watcher.mjs +8 -0
  113. package/dist/session-metadata-B9aV_n5g.d.ts +148 -0
  114. package/dist/tty-prompt.d.ts +44 -0
  115. package/dist/tty-prompt.mjs +39 -0
  116. package/dist/vault.d-BtRSLZiM.d.ts +8 -0
  117. package/dist/vault.d.ts +37 -0
  118. package/dist/vault.mjs +21 -0
  119. package/dist/viewer-detect.d-HWGnyFAA.d.ts +4 -0
  120. package/dist/viewer-detect.d.ts +4 -0
  121. package/dist/viewer-detect.mjs +37 -0
  122. package/dist/viewers.d-BGCK6sw6.d.ts +10 -0
  123. package/dist/viewers.d.ts +18 -0
  124. package/dist/viewers.mjs +122 -0
  125. package/package.json +152 -0
@@ -0,0 +1,175 @@
1
+ import {
2
+ PerplexityClient,
3
+ getCloudThreadViaImpit,
4
+ listCloudThreadsViaImpit
5
+ } from "./chunk-H4BUAPPO.mjs";
6
+ import {
7
+ hydrateCloudEntry,
8
+ upsertFromCloud
9
+ } from "./chunk-OF4DMAPJ.mjs";
10
+
11
+ // src/cloud-sync.js
12
+ var DEFAULT_PAGE_SIZE = 1e3;
13
+ var MAX_PAGES = 10;
14
+ function firstAnswerPreview(firstAnswerJson) {
15
+ if (typeof firstAnswerJson !== "string") return "";
16
+ try {
17
+ const parsed = JSON.parse(firstAnswerJson);
18
+ if (typeof parsed?.answer === "string") return parsed.answer.slice(0, 220);
19
+ } catch {
20
+ }
21
+ return "";
22
+ }
23
+ function buildHydratedBody(entries) {
24
+ const parts = [];
25
+ for (const entry of entries) {
26
+ if (entry.queryStr) parts.push(`### ${entry.queryStr}
27
+ `);
28
+ if (entry.answer) parts.push(entry.answer.trim(), "");
29
+ if (entry.sources?.length) {
30
+ parts.push("**Sources:**");
31
+ for (const s of entry.sources) parts.push(`${s.n}. [${s.title || s.url}](${s.url})`);
32
+ parts.push("");
33
+ }
34
+ if (entry.mediaItems?.length) {
35
+ parts.push("**Media:**");
36
+ for (const m of entry.mediaItems) parts.push(`- ${m.name ? `[${m.name}](${m.url})` : m.url}`);
37
+ parts.push("");
38
+ }
39
+ parts.push("---", "");
40
+ }
41
+ return parts.join("\n").replace(/\n?---\n$/, "").trim();
42
+ }
43
+ async function syncCloudHistory(opts = {}) {
44
+ const pageSize = opts.pageSize ?? DEFAULT_PAGE_SIZE;
45
+ const onProgress = opts.onProgress ?? (() => {
46
+ });
47
+ const signal = opts.signal;
48
+ let client = opts.client ?? null;
49
+ let ownsClient = false;
50
+ const acquireClient = async () => {
51
+ if (client) return client;
52
+ if (opts.getClient) {
53
+ client = await opts.getClient();
54
+ return client;
55
+ }
56
+ client = new PerplexityClient();
57
+ ownsClient = true;
58
+ await client.init();
59
+ return client;
60
+ };
61
+ const stats = { fetched: 0, total: 0, inserted: 0, updated: 0, skipped: 0 };
62
+ onProgress({ phase: "starting", ...stats });
63
+ try {
64
+ let offset = 0;
65
+ let impitDisabled = !!client;
66
+ for (let page = 0; page < MAX_PAGES; page++) {
67
+ if (signal?.aborted) {
68
+ onProgress({ phase: "cancelled", ...stats });
69
+ return { ...stats, cancelled: true };
70
+ }
71
+ let items, total;
72
+ if (!impitDisabled) {
73
+ const fast = await listCloudThreadsViaImpit({ limit: pageSize, offset });
74
+ if (fast) {
75
+ ({ items, total } = fast);
76
+ } else {
77
+ impitDisabled = true;
78
+ }
79
+ }
80
+ if (impitDisabled && items === void 0) {
81
+ const c = await acquireClient();
82
+ ({ items, total } = await c.listCloudThreads({ limit: pageSize, offset }));
83
+ }
84
+ stats.total = Math.max(stats.total, total);
85
+ if (items.length === 0) break;
86
+ for (const row of items) {
87
+ if (!row.backendUuid) continue;
88
+ const preview = row.answerPreview || firstAnswerPreview(row.firstAnswer);
89
+ const threadUrl = row.slug ? `https://www.perplexity.ai/search/${row.slug}` : void 0;
90
+ const result = upsertFromCloud({
91
+ backendUuid: row.backendUuid,
92
+ query: row.queryStr || row.title,
93
+ answerPreview: preview,
94
+ createdAt: row.createdAt,
95
+ threadUrl,
96
+ threadSlug: row.slug,
97
+ readWriteToken: row.readWriteToken,
98
+ mode: row.mode,
99
+ model: row.displayModel,
100
+ sourceCount: row.sources?.length ?? 0,
101
+ status: row.threadStatus === "completed" ? "completed" : "pending",
102
+ tool: "perplexity_search"
103
+ });
104
+ if (result.action === "inserted") stats.inserted += 1;
105
+ else if (result.action === "updated") stats.updated += 1;
106
+ else stats.skipped += 1;
107
+ stats.fetched += 1;
108
+ }
109
+ onProgress({ phase: "syncing", ...stats });
110
+ if (items.length < pageSize) break;
111
+ offset += pageSize;
112
+ }
113
+ onProgress({ phase: "done", ...stats });
114
+ return { ...stats, cancelled: false };
115
+ } catch (err) {
116
+ const message = err instanceof Error ? err.message : String(err);
117
+ onProgress({ phase: "error", ...stats, error: message });
118
+ throw err;
119
+ } finally {
120
+ if (ownsClient && client) await client.shutdown().catch(() => {
121
+ });
122
+ }
123
+ }
124
+ async function hydrateCloudHistoryEntry(historyId, opts = {}) {
125
+ const { get } = await import("./history-store.mjs");
126
+ const entry = get(historyId);
127
+ if (!entry) throw new Error(`History entry '${historyId}' not found.`);
128
+ if (entry.source !== "cloud") return { action: "skipped-local", id: entry.id };
129
+ if (entry.cloudHydratedAt) return { action: "skipped-hydrated", id: entry.id };
130
+ if (!entry.threadSlug) throw new Error(`Entry '${historyId}' has no threadSlug.`);
131
+ let client = opts.client ?? null;
132
+ let ownsClient = false;
133
+ let thread = null;
134
+ if (!client) {
135
+ thread = await getCloudThreadViaImpit(entry.threadSlug);
136
+ }
137
+ if (!thread) {
138
+ if (!client) {
139
+ if (opts.getClient) {
140
+ client = await opts.getClient();
141
+ } else {
142
+ client = new PerplexityClient();
143
+ ownsClient = true;
144
+ await client.init();
145
+ }
146
+ }
147
+ try {
148
+ thread = await client.getCloudThread(entry.threadSlug);
149
+ } finally {
150
+ if (ownsClient && !thread) await client.shutdown().catch(() => {
151
+ });
152
+ }
153
+ }
154
+ try {
155
+ const body = buildHydratedBody(thread.entries);
156
+ const firstEntry = thread.entries[0];
157
+ const preview = firstEntry?.answer ? firstEntry.answer.replace(/\s+/g, " ").slice(0, 220) : entry.answerPreview;
158
+ const allSources = thread.entries.flatMap((e) => e.sources ?? []);
159
+ hydrateCloudEntry(entry.id, {
160
+ body,
161
+ sources: allSources.length ? allSources.map((s, i) => ({ ...s, n: i + 1 })) : entry.sources,
162
+ answerPreview: preview,
163
+ sourceCount: allSources.length || entry.sourceCount
164
+ });
165
+ return { action: "hydrated", id: entry.id };
166
+ } finally {
167
+ if (ownsClient && client) await client.shutdown().catch(() => {
168
+ });
169
+ }
170
+ }
171
+
172
+ export {
173
+ syncCloudHistory,
174
+ hydrateCloudHistoryEntry
175
+ };