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.
- package/README.md +192 -0
- package/dist/attachments.d.ts +20 -0
- package/dist/attachments.mjs +43 -0
- package/dist/checks/browser.d.ts +100 -0
- package/dist/checks/browser.mjs +89 -0
- package/dist/checks/config.d.ts +91 -0
- package/dist/checks/config.mjs +88 -0
- package/dist/checks/ide.d.ts +89 -0
- package/dist/checks/ide.mjs +80 -0
- package/dist/checks/mcp.d.ts +61 -0
- package/dist/checks/mcp.mjs +56 -0
- package/dist/checks/native-deps.d.ts +131 -0
- package/dist/checks/native-deps.mjs +115 -0
- package/dist/checks/network.d.ts +71 -0
- package/dist/checks/network.mjs +70 -0
- package/dist/checks/probe.d.ts +93 -0
- package/dist/checks/probe.mjs +82 -0
- package/dist/checks/profiles.d.ts +99 -0
- package/dist/checks/profiles.mjs +90 -0
- package/dist/checks/runtime.d.ts +89 -0
- package/dist/checks/runtime.mjs +90 -0
- package/dist/checks/vault.d.ts +101 -0
- package/dist/checks/vault.mjs +90 -0
- package/dist/chunk-3B276PGG.mjs +115 -0
- package/dist/chunk-4UEJOM6W.mjs +9 -0
- package/dist/chunk-6EP2BLTV.mjs +205 -0
- package/dist/chunk-6YMQVLFX.mjs +146 -0
- package/dist/chunk-7JL36EBH.mjs +118 -0
- package/dist/chunk-DPGMKSSA.mjs +57 -0
- package/dist/chunk-H4BUAPPO.mjs +1950 -0
- package/dist/chunk-HMKLWVXB.mjs +109 -0
- package/dist/chunk-HTUAQRKH.mjs +125 -0
- package/dist/chunk-HU5B4FXS.mjs +139 -0
- package/dist/chunk-KCXM2M4B.mjs +1006 -0
- package/dist/chunk-LKJMLGFP.mjs +237 -0
- package/dist/chunk-LZPLNZ5U.mjs +67 -0
- package/dist/chunk-MTDFKNXX.mjs +19 -0
- package/dist/chunk-OF4DMAPJ.mjs +511 -0
- package/dist/chunk-PE23RMXY.mjs +43 -0
- package/dist/chunk-Q2VY4R5F.mjs +175 -0
- package/dist/chunk-S5VD7WTU.mjs +2540 -0
- package/dist/chunk-SVPRB62V.mjs +106 -0
- package/dist/chunk-TQLCLE4L.mjs +345 -0
- package/dist/chunk-U3DGFLXZ.mjs +43 -0
- package/dist/chunk-X45O6YD3.mjs +688 -0
- package/dist/chunk-XKSWCEGI.mjs +168 -0
- package/dist/chunk-Z7DAACGZ.mjs +534 -0
- package/dist/chunk-ZQFUZPLO.mjs +257 -0
- package/dist/cli.d.ts +952 -0
- package/dist/cli.mjs +827 -0
- package/dist/client.d.ts +355 -0
- package/dist/client.mjs +27 -0
- package/dist/cloud-sync.d-Cqt6y18U.d.ts +42 -0
- package/dist/cloud-sync.d.ts +42 -0
- package/dist/cloud-sync.mjs +17 -0
- package/dist/config.d.ts +186 -0
- package/dist/config.mjs +54 -0
- package/dist/daemon/attach.d.ts +36 -0
- package/dist/daemon/attach.mjs +25 -0
- package/dist/daemon/audit.d.ts +23 -0
- package/dist/daemon/audit.mjs +12 -0
- package/dist/daemon/client-http.d.ts +42 -0
- package/dist/daemon/client-http.mjs +29 -0
- package/dist/daemon/index.d.ts +14 -0
- package/dist/daemon/index.mjs +110 -0
- package/dist/daemon/install-tunnel.d.ts +46 -0
- package/dist/daemon/install-tunnel.mjs +14 -0
- package/dist/daemon/launcher.d.ts +163 -0
- package/dist/daemon/launcher.mjs +50 -0
- package/dist/daemon/lockfile.d.ts +29 -0
- package/dist/daemon/lockfile.mjs +18 -0
- package/dist/daemon/server.d.ts +159 -0
- package/dist/daemon/server.mjs +20 -0
- package/dist/daemon/token.d.ts +17 -0
- package/dist/daemon/token.mjs +17 -0
- package/dist/daemon/tunnel-providers/index.d.ts +330 -0
- package/dist/daemon/tunnel-providers/index.mjs +57 -0
- package/dist/daemon/tunnel.d.ts +23 -0
- package/dist/daemon/tunnel.mjs +9 -0
- package/dist/doctor-report.d.ts +24 -0
- package/dist/doctor-report.mjs +14 -0
- package/dist/doctor.d-CXmUqOXX.d.ts +43 -0
- package/dist/doctor.d.ts +44 -0
- package/dist/doctor.mjs +16 -0
- package/dist/export.d.ts +19 -0
- package/dist/export.mjs +15 -0
- package/dist/health-check.d.ts +108 -0
- package/dist/health-check.mjs +92 -0
- package/dist/history-store.d-BzjBF2m3.d.ts +65 -0
- package/dist/history-store.d.ts +65 -0
- package/dist/history-store.mjs +48 -0
- package/dist/impit-login-runner.d.ts +469 -0
- package/dist/impit-login-runner.mjs +685 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.mjs +236 -0
- package/dist/login-runner.d.ts +333 -0
- package/dist/login-runner.mjs +320 -0
- package/dist/logout.d.ts +28 -0
- package/dist/logout.mjs +45 -0
- package/dist/manual-login-runner.d.ts +150 -0
- package/dist/manual-login-runner.mjs +146 -0
- package/dist/native-deps-BNThFHxa.d.ts +175 -0
- package/dist/native-deps-YNKXITRY.mjs +139 -0
- package/dist/profiles.d-DqS1oZWr.d.ts +41 -0
- package/dist/profiles.d.ts +41 -0
- package/dist/profiles.mjs +33 -0
- package/dist/redact.d.ts +159 -0
- package/dist/redact.mjs +11 -0
- package/dist/refresh.d.ts +118 -0
- package/dist/refresh.mjs +21 -0
- package/dist/reinit-watcher.d.ts +15 -0
- package/dist/reinit-watcher.mjs +8 -0
- package/dist/session-metadata-B9aV_n5g.d.ts +148 -0
- package/dist/tty-prompt.d.ts +44 -0
- package/dist/tty-prompt.mjs +39 -0
- package/dist/vault.d-BtRSLZiM.d.ts +8 -0
- package/dist/vault.d.ts +37 -0
- package/dist/vault.mjs +21 -0
- package/dist/viewer-detect.d-HWGnyFAA.d.ts +4 -0
- package/dist/viewer-detect.d.ts +4 -0
- package/dist/viewer-detect.mjs +37 -0
- package/dist/viewers.d-BGCK6sw6.d.ts +10 -0
- package/dist/viewers.d.ts +18 -0
- package/dist/viewers.mjs +122 -0
- package/package.json +152 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { PerplexityClient } from './client.js';
|
|
3
|
+
export { ensureDaemon, startDaemon } from './daemon/launcher.js';
|
|
4
|
+
export { attachToDaemon } from './daemon/attach.js';
|
|
5
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
import { SearchResult } from './config.js';
|
|
7
|
+
export { BrowserInfo, findBrowser } from './config.js';
|
|
8
|
+
export { append as appendHistory, countAll as countAllHistory, deleteEntry, findByBackendUuid, findPendingByThread, get, getAttachmentsDir, getAttachmentsRoot, getHistoryDir, getIndexPath as getHistoryPath, getMdPath, hydrateCloudEntry, pin, list as readHistory, rebuildIndex, tag, update, upsertFromCloud } from './history-store.d-BzjBF2m3.js';
|
|
9
|
+
export { hydrateCloudHistoryEntry, syncCloudHistory } from './cloud-sync.d-Cqt6y18U.js';
|
|
10
|
+
export { HistoryItem } from '@perplexity-user-mcp/shared';
|
|
11
|
+
export { RefreshOptions, RefreshResult, RefreshTier, getImpitRuntimeDir, getModelsCacheInfo, isImpitAvailable, refreshAccountInfo } from './refresh.js';
|
|
12
|
+
import { DoctorReport, DoctorCategory } from './doctor.d-CXmUqOXX.js';
|
|
13
|
+
export { CATEGORIES as DOCTOR_CATEGORIES, formatReportMarkdown, runAll as runDoctor } from './doctor.d-CXmUqOXX.js';
|
|
14
|
+
import 'patchright';
|
|
15
|
+
import './daemon/lockfile.js';
|
|
16
|
+
import 'node:stream';
|
|
17
|
+
|
|
18
|
+
type GetClient = () => Promise<PerplexityClient>;
|
|
19
|
+
interface ToolAuditEvent {
|
|
20
|
+
tool: string;
|
|
21
|
+
clientId: string;
|
|
22
|
+
source: "loopback" | "tunnel";
|
|
23
|
+
durationMs: number;
|
|
24
|
+
ok: boolean;
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
interface ToolProgressEvent {
|
|
28
|
+
tool: string;
|
|
29
|
+
clientId: string;
|
|
30
|
+
source: "loopback" | "tunnel";
|
|
31
|
+
progress: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
interface ToolHooks {
|
|
34
|
+
onToolSettled?: (event: ToolAuditEvent) => void;
|
|
35
|
+
onToolProgress?: (event: ToolProgressEvent) => void;
|
|
36
|
+
}
|
|
37
|
+
declare function registerTools(server: McpServer, getClient: GetClient, enabledTools?: Set<string>, hooks?: ToolHooks): void;
|
|
38
|
+
|
|
39
|
+
declare function registerPrompts(server: McpServer): void;
|
|
40
|
+
|
|
41
|
+
interface AccountSnapshotProvider {
|
|
42
|
+
(): Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
declare function registerResources(server: McpServer, getAccountSnapshot?: AccountSnapshotProvider): void;
|
|
45
|
+
|
|
46
|
+
interface HistoryEntry {
|
|
47
|
+
tool: string;
|
|
48
|
+
query: string;
|
|
49
|
+
model: string | null;
|
|
50
|
+
mode: string | null;
|
|
51
|
+
language: string | null;
|
|
52
|
+
answerPreview: string;
|
|
53
|
+
sourceCount: number;
|
|
54
|
+
threadUrl?: string;
|
|
55
|
+
error?: string;
|
|
56
|
+
}
|
|
57
|
+
declare function formatResponse(result: SearchResult): string;
|
|
58
|
+
declare function buildAnswerPreview(result: SearchResult | null, error?: string): string;
|
|
59
|
+
declare function buildHistoryEntry(options: {
|
|
60
|
+
tool: string;
|
|
61
|
+
query: string;
|
|
62
|
+
model: string | null;
|
|
63
|
+
mode: string | null;
|
|
64
|
+
language: string | null;
|
|
65
|
+
result?: SearchResult;
|
|
66
|
+
error?: string;
|
|
67
|
+
}): HistoryEntry;
|
|
68
|
+
declare function buildHistoryBody(result: SearchResult | undefined, error?: string): string;
|
|
69
|
+
declare function buildStoredHistoryEntry(options: {
|
|
70
|
+
tool: string;
|
|
71
|
+
query: string;
|
|
72
|
+
model: string | null;
|
|
73
|
+
mode: string | null;
|
|
74
|
+
language: string | null;
|
|
75
|
+
tier?: "Max" | "Pro" | "Enterprise" | "Authenticated" | "Anonymous";
|
|
76
|
+
status?: "completed" | "pending" | "failed";
|
|
77
|
+
createdAt?: string;
|
|
78
|
+
completedAt?: string;
|
|
79
|
+
result?: SearchResult;
|
|
80
|
+
error?: string;
|
|
81
|
+
}): HistoryEntry & {
|
|
82
|
+
createdAt: string;
|
|
83
|
+
body: string;
|
|
84
|
+
status?: "completed" | "pending" | "failed";
|
|
85
|
+
completedAt?: string;
|
|
86
|
+
tier?: "Max" | "Pro" | "Enterprise" | "Authenticated" | "Anonymous";
|
|
87
|
+
threadSlug?: string | null;
|
|
88
|
+
backendUuid?: string | null;
|
|
89
|
+
readWriteToken?: string | null;
|
|
90
|
+
sources?: Array<{
|
|
91
|
+
n: number;
|
|
92
|
+
title: string;
|
|
93
|
+
url: string;
|
|
94
|
+
snippet?: string;
|
|
95
|
+
}>;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type ExportFormat = "pdf" | "markdown" | "docx";
|
|
99
|
+
|
|
100
|
+
interface ExportResult {
|
|
101
|
+
buffer: Buffer;
|
|
102
|
+
filename: string;
|
|
103
|
+
contentType: string;
|
|
104
|
+
}
|
|
105
|
+
declare function exportThread(options: {
|
|
106
|
+
entryUuid: string;
|
|
107
|
+
format: ExportFormat;
|
|
108
|
+
fetchImpl?: (input: string, init?: RequestInit) => Promise<Response>;
|
|
109
|
+
baseUrl?: string;
|
|
110
|
+
headers?: HeadersInit;
|
|
111
|
+
}): Promise<ExportResult>;
|
|
112
|
+
|
|
113
|
+
type ToolProfile = "read-only" | "full" | "custom";
|
|
114
|
+
interface ToolConfig {
|
|
115
|
+
profile: ToolProfile;
|
|
116
|
+
customEnabled?: string[];
|
|
117
|
+
}
|
|
118
|
+
declare function loadToolConfig(): ToolConfig;
|
|
119
|
+
declare function getEnabledTools(config: ToolConfig): Set<string>;
|
|
120
|
+
declare function saveToolConfig(config: ToolConfig): void;
|
|
121
|
+
declare function watchToolConfig(onChange: (config: ToolConfig) => void): void;
|
|
122
|
+
|
|
123
|
+
declare function buildIssueBody(input: {
|
|
124
|
+
report: DoctorReport;
|
|
125
|
+
stderrTail: string;
|
|
126
|
+
extVersion: string;
|
|
127
|
+
nodeVersion: string;
|
|
128
|
+
os: string;
|
|
129
|
+
activeTier?: string | null;
|
|
130
|
+
}): string;
|
|
131
|
+
|
|
132
|
+
declare function redactIssueBody(md: string): string;
|
|
133
|
+
|
|
134
|
+
declare function decideTransport(input: { bodyBytes: number }): "inline" | "file";
|
|
135
|
+
|
|
136
|
+
declare function buildIssueUrl(input: {
|
|
137
|
+
owner: string;
|
|
138
|
+
repo: string;
|
|
139
|
+
category: DoctorCategory | string;
|
|
140
|
+
check: string;
|
|
141
|
+
body: string;
|
|
142
|
+
}): string;
|
|
143
|
+
|
|
144
|
+
declare function __resetVaultPreflightForTests(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Probe the vault unseal chain at startup. If unsealing succeeds, the result
|
|
147
|
+
* is cached inside `vault.js` for free — subsequent tool calls skip the
|
|
148
|
+
* keychain hit. If it fails (e.g. headless Codex CLI: no keychain, no env var,
|
|
149
|
+
* no TTY), emit a structured stderr warning so the user sees the actionable
|
|
150
|
+
* setup hint in their IDE's MCP server-launch logs instead of waiting for the
|
|
151
|
+
* first cookie-needing tool to fail with a deep-stack "Vault locked" trace.
|
|
152
|
+
*
|
|
153
|
+
* Never throws. The MCP server must continue to load and serve tools that
|
|
154
|
+
* don't need cookies (perplexity_doctor, anonymous perplexity_search).
|
|
155
|
+
*/
|
|
156
|
+
declare function runVaultPreflight(stderr?: NodeJS.WritableStream): Promise<void>;
|
|
157
|
+
declare function main(): Promise<void>;
|
|
158
|
+
|
|
159
|
+
export { type HistoryEntry, PerplexityClient, type ToolProfile, __resetVaultPreflightForTests, buildAnswerPreview, buildHistoryBody, buildHistoryEntry, buildIssueBody, buildIssueUrl, buildStoredHistoryEntry, decideTransport, exportThread, formatResponse, getEnabledTools, loadToolConfig, main, redactIssueBody, registerPrompts, registerResources, registerTools, runVaultPreflight, saveToolConfig, watchToolConfig };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CATEGORIES,
|
|
4
|
+
formatReportMarkdown,
|
|
5
|
+
runAll
|
|
6
|
+
} from "./chunk-7JL36EBH.mjs";
|
|
7
|
+
import {
|
|
8
|
+
buildIssueBody,
|
|
9
|
+
buildIssueUrl,
|
|
10
|
+
decideTransport,
|
|
11
|
+
redactIssueBody
|
|
12
|
+
} from "./chunk-DPGMKSSA.mjs";
|
|
13
|
+
import {
|
|
14
|
+
attachToDaemon
|
|
15
|
+
} from "./chunk-SVPRB62V.mjs";
|
|
16
|
+
import {
|
|
17
|
+
ensureDaemon,
|
|
18
|
+
startDaemon
|
|
19
|
+
} from "./chunk-X45O6YD3.mjs";
|
|
20
|
+
import "./chunk-KCXM2M4B.mjs";
|
|
21
|
+
import "./chunk-6YMQVLFX.mjs";
|
|
22
|
+
import "./chunk-3B276PGG.mjs";
|
|
23
|
+
import "./chunk-6EP2BLTV.mjs";
|
|
24
|
+
import {
|
|
25
|
+
buildAnswerPreview,
|
|
26
|
+
buildHistoryBody,
|
|
27
|
+
buildHistoryEntry,
|
|
28
|
+
buildStoredHistoryEntry,
|
|
29
|
+
formatResponse,
|
|
30
|
+
getEnabledTools,
|
|
31
|
+
getPackageVersion,
|
|
32
|
+
loadToolConfig,
|
|
33
|
+
registerPrompts,
|
|
34
|
+
registerResources,
|
|
35
|
+
registerTools,
|
|
36
|
+
saveToolConfig,
|
|
37
|
+
watchToolConfig
|
|
38
|
+
} from "./chunk-S5VD7WTU.mjs";
|
|
39
|
+
import "./chunk-PE23RMXY.mjs";
|
|
40
|
+
import "./chunk-HTUAQRKH.mjs";
|
|
41
|
+
import {
|
|
42
|
+
watchReinit
|
|
43
|
+
} from "./chunk-U3DGFLXZ.mjs";
|
|
44
|
+
import "./chunk-HMKLWVXB.mjs";
|
|
45
|
+
import {
|
|
46
|
+
hydrateCloudHistoryEntry,
|
|
47
|
+
syncCloudHistory
|
|
48
|
+
} from "./chunk-Q2VY4R5F.mjs";
|
|
49
|
+
import {
|
|
50
|
+
PerplexityClient
|
|
51
|
+
} from "./chunk-H4BUAPPO.mjs";
|
|
52
|
+
import {
|
|
53
|
+
getImpitRuntimeDir,
|
|
54
|
+
getModelsCacheInfo,
|
|
55
|
+
isImpitAvailable,
|
|
56
|
+
refreshAccountInfo
|
|
57
|
+
} from "./chunk-Z7DAACGZ.mjs";
|
|
58
|
+
import {
|
|
59
|
+
append,
|
|
60
|
+
countAll,
|
|
61
|
+
deleteEntry,
|
|
62
|
+
findByBackendUuid,
|
|
63
|
+
findPendingByThread,
|
|
64
|
+
get,
|
|
65
|
+
getAttachmentsDir,
|
|
66
|
+
getAttachmentsRoot,
|
|
67
|
+
getHistoryDir,
|
|
68
|
+
getIndexPath,
|
|
69
|
+
getMdPath,
|
|
70
|
+
hydrateCloudEntry,
|
|
71
|
+
list,
|
|
72
|
+
pin,
|
|
73
|
+
rebuildIndex,
|
|
74
|
+
tag,
|
|
75
|
+
update,
|
|
76
|
+
upsertFromCloud
|
|
77
|
+
} from "./chunk-OF4DMAPJ.mjs";
|
|
78
|
+
import {
|
|
79
|
+
exportThread
|
|
80
|
+
} from "./chunk-LZPLNZ5U.mjs";
|
|
81
|
+
import {
|
|
82
|
+
findBrowser
|
|
83
|
+
} from "./chunk-LKJMLGFP.mjs";
|
|
84
|
+
import {
|
|
85
|
+
getUnsealMaterial
|
|
86
|
+
} from "./chunk-TQLCLE4L.mjs";
|
|
87
|
+
import "./chunk-MTDFKNXX.mjs";
|
|
88
|
+
import {
|
|
89
|
+
getActiveName
|
|
90
|
+
} from "./chunk-XKSWCEGI.mjs";
|
|
91
|
+
import "./chunk-4UEJOM6W.mjs";
|
|
92
|
+
|
|
93
|
+
// src/index.ts
|
|
94
|
+
import { pathToFileURL } from "url";
|
|
95
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
96
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
97
|
+
var client;
|
|
98
|
+
var clientInitPromise = null;
|
|
99
|
+
async function getClient() {
|
|
100
|
+
if (!clientInitPromise) clientInitPromise = client.init();
|
|
101
|
+
await clientInitPromise;
|
|
102
|
+
return client;
|
|
103
|
+
}
|
|
104
|
+
var _vaultPreflightDone = false;
|
|
105
|
+
function __resetVaultPreflightForTests() {
|
|
106
|
+
_vaultPreflightDone = false;
|
|
107
|
+
}
|
|
108
|
+
async function runVaultPreflight(stderr = process.stderr) {
|
|
109
|
+
if (_vaultPreflightDone) return;
|
|
110
|
+
_vaultPreflightDone = true;
|
|
111
|
+
try {
|
|
112
|
+
await getUnsealMaterial();
|
|
113
|
+
} catch (err) {
|
|
114
|
+
const summary = err instanceof Error ? err.message.split("\n")[0] : String(err);
|
|
115
|
+
stderr.write(`[perplexity-mcp] WARN vault-locked: ${summary}
|
|
116
|
+
`);
|
|
117
|
+
stderr.write(`[perplexity-mcp] Setup docs: docs/codex-cli-setup.md
|
|
118
|
+
`);
|
|
119
|
+
stderr.write(`[perplexity-mcp] Tools that don't need cookies (perplexity_doctor, perplexity_search anonymous mode) will still work.
|
|
120
|
+
`);
|
|
121
|
+
stderr.write(`[perplexity-mcp] Tools that need cookies (perplexity_research, perplexity_compute, perplexity_reason) will fail until the vault is unsealed.
|
|
122
|
+
`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function main() {
|
|
126
|
+
client = new PerplexityClient();
|
|
127
|
+
const server = new McpServer({
|
|
128
|
+
name: "perplexity",
|
|
129
|
+
version: getPackageVersion()
|
|
130
|
+
});
|
|
131
|
+
const toolConfig = loadToolConfig();
|
|
132
|
+
const enabledTools = getEnabledTools(toolConfig);
|
|
133
|
+
registerResources(server);
|
|
134
|
+
registerPrompts(server);
|
|
135
|
+
registerTools(server, getClient, enabledTools);
|
|
136
|
+
const profile = process.env.PERPLEXITY_PROFILE || getActiveName() || "default";
|
|
137
|
+
console.error(`[perplexity-mcp] Starting with profile: ${profile}`);
|
|
138
|
+
await runVaultPreflight();
|
|
139
|
+
const watcher = watchReinit(profile, async () => {
|
|
140
|
+
console.error("[perplexity-mcp] .reinit sentinel fired \u2014 reloading client.");
|
|
141
|
+
try {
|
|
142
|
+
clientInitPromise = client.reinit();
|
|
143
|
+
await clientInitPromise;
|
|
144
|
+
} catch (err) {
|
|
145
|
+
console.error("[perplexity-mcp] reinit failed:", err);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
process.on("SIGINT", async () => {
|
|
149
|
+
watcher.dispose();
|
|
150
|
+
await client.shutdown();
|
|
151
|
+
process.exit(0);
|
|
152
|
+
});
|
|
153
|
+
process.on("SIGTERM", async () => {
|
|
154
|
+
watcher.dispose();
|
|
155
|
+
await client.shutdown();
|
|
156
|
+
process.exit(0);
|
|
157
|
+
});
|
|
158
|
+
const transport = new StdioServerTransport();
|
|
159
|
+
await server.connect(transport);
|
|
160
|
+
}
|
|
161
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
162
|
+
runEntrypoint().catch(async (error) => {
|
|
163
|
+
console.error("[perplexity-mcp] Fatal error:", error);
|
|
164
|
+
await client?.shutdown?.().catch(() => void 0);
|
|
165
|
+
process.exit(1);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async function runEntrypoint() {
|
|
169
|
+
if (process.argv.length > 2) {
|
|
170
|
+
const { parseArgs, routeCommand } = await import("./cli.mjs");
|
|
171
|
+
const result = await routeCommand(parseArgs(process.argv.slice(2)));
|
|
172
|
+
if (result.stdout) {
|
|
173
|
+
process.stdout.write(result.stdout);
|
|
174
|
+
}
|
|
175
|
+
if (result.stderr) {
|
|
176
|
+
process.stderr.write(result.stderr);
|
|
177
|
+
}
|
|
178
|
+
process.exitCode = result.code;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
await main();
|
|
182
|
+
}
|
|
183
|
+
export {
|
|
184
|
+
CATEGORIES as DOCTOR_CATEGORIES,
|
|
185
|
+
PerplexityClient,
|
|
186
|
+
__resetVaultPreflightForTests,
|
|
187
|
+
append as appendHistory,
|
|
188
|
+
attachToDaemon,
|
|
189
|
+
buildAnswerPreview,
|
|
190
|
+
buildHistoryBody,
|
|
191
|
+
buildHistoryEntry,
|
|
192
|
+
buildIssueBody,
|
|
193
|
+
buildIssueUrl,
|
|
194
|
+
buildStoredHistoryEntry,
|
|
195
|
+
countAll as countAllHistory,
|
|
196
|
+
decideTransport,
|
|
197
|
+
deleteEntry,
|
|
198
|
+
ensureDaemon,
|
|
199
|
+
exportThread,
|
|
200
|
+
findBrowser,
|
|
201
|
+
findByBackendUuid,
|
|
202
|
+
findPendingByThread,
|
|
203
|
+
formatReportMarkdown,
|
|
204
|
+
formatResponse,
|
|
205
|
+
get,
|
|
206
|
+
getAttachmentsDir,
|
|
207
|
+
getAttachmentsRoot,
|
|
208
|
+
getEnabledTools,
|
|
209
|
+
getHistoryDir,
|
|
210
|
+
getIndexPath as getHistoryPath,
|
|
211
|
+
getImpitRuntimeDir,
|
|
212
|
+
getMdPath,
|
|
213
|
+
getModelsCacheInfo,
|
|
214
|
+
hydrateCloudEntry,
|
|
215
|
+
hydrateCloudHistoryEntry,
|
|
216
|
+
isImpitAvailable,
|
|
217
|
+
loadToolConfig,
|
|
218
|
+
main,
|
|
219
|
+
pin,
|
|
220
|
+
list as readHistory,
|
|
221
|
+
rebuildIndex,
|
|
222
|
+
redactIssueBody,
|
|
223
|
+
refreshAccountInfo,
|
|
224
|
+
registerPrompts,
|
|
225
|
+
registerResources,
|
|
226
|
+
registerTools,
|
|
227
|
+
runAll as runDoctor,
|
|
228
|
+
runVaultPreflight,
|
|
229
|
+
saveToolConfig,
|
|
230
|
+
startDaemon,
|
|
231
|
+
syncCloudHistory,
|
|
232
|
+
tag,
|
|
233
|
+
update,
|
|
234
|
+
upsertFromCloud,
|
|
235
|
+
watchToolConfig
|
|
236
|
+
};
|