perplexity-user-mcp 0.8.39 → 0.8.44
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 +5 -0
- package/dist/attachments.d.ts +10 -20
- package/dist/browser-window.d.ts +1 -0
- package/dist/cf-warmup.d.ts +32 -0
- package/dist/checks/browser.d.ts +12 -100
- package/dist/checks/config.d.ts +25 -91
- package/dist/checks/ide.d.ts +31 -89
- package/dist/checks/mcp.d.ts +12 -61
- package/dist/checks/native-deps.d.ts +46 -131
- package/dist/checks/network.d.ts +13 -71
- package/dist/checks/probe.d.ts +20 -92
- package/dist/checks/profiles.d.ts +13 -99
- package/dist/checks/profiles.mjs +35 -0
- package/dist/checks/runtime.d.ts +24 -89
- package/dist/checks/vault.d.ts +13 -142
- package/dist/checks/vault.mjs +6 -11
- package/dist/{chunk-T6ARJK2P.mjs → chunk-2B5OQUXR.mjs} +6 -6
- package/dist/{chunk-2FPGJKCA.mjs → chunk-2EE7MNP2.mjs} +2 -2
- package/dist/{chunk-NJX4RBO6.mjs → chunk-2OVLCZHU.mjs} +28 -3
- package/dist/{chunk-WDIW33DA.mjs → chunk-3LUO5ATM.mjs} +1 -1
- package/dist/{chunk-B65IJQZJ.mjs → chunk-6E6XTHTG.mjs} +1 -1
- package/dist/{chunk-S677V2JU.mjs → chunk-C5I7KXHK.mjs} +32 -2
- package/dist/{chunk-TDXETAQT.mjs → chunk-DKEJZ4FI.mjs} +1 -1
- package/dist/{chunk-U7QPUNRH.mjs → chunk-DXR6EEZH.mjs} +26 -7
- package/dist/{chunk-HJIXH6CL.mjs → chunk-E3GRJXXJ.mjs} +2 -0
- package/dist/{chunk-RK4EBZJ3.mjs → chunk-E75J42W5.mjs} +11 -8
- package/dist/{chunk-452DK6OS.mjs → chunk-FNHYUE22.mjs} +2 -2
- package/dist/{chunk-D254EFYB.mjs → chunk-GBI2U336.mjs} +1 -1
- package/dist/chunk-GPUGKWXH.mjs +17 -0
- package/dist/{chunk-HNSPNCFH.mjs → chunk-KSNV3ZVY.mjs} +1 -1
- package/dist/{chunk-XTRJSV72.mjs → chunk-LGH5BSUY.mjs} +1 -1
- package/dist/{chunk-KJFX2ZXR.mjs → chunk-NMKNEEZB.mjs} +1 -1
- package/dist/{chunk-FKQ3HP4Q.mjs → chunk-TIWHN4IW.mjs} +1 -1
- package/dist/{chunk-V4U3JM4R.mjs → chunk-TSLRTZYR.mjs} +1 -1
- package/dist/{chunk-DQQISMYN.mjs → chunk-V4LHDNWJ.mjs} +2 -2
- package/dist/{chunk-C3HPFFTD.mjs → chunk-WHVJ724K.mjs} +84 -44
- package/dist/cli.d.ts +14 -1298
- package/dist/cli.mjs +35 -27
- package/dist/client.d.ts +27 -24
- package/dist/client.mjs +6 -6
- package/dist/cloud-sync.d.ts +65 -42
- package/dist/cloud-sync.mjs +8 -8
- package/dist/config.d.ts +35 -39
- package/dist/config.mjs +3 -3
- package/dist/cookie-jar.d.ts +77 -0
- package/dist/daemon/attach.d.ts +10 -11
- package/dist/daemon/attach.mjs +19 -17
- package/dist/daemon/audit.d.ts +5 -7
- package/dist/daemon/audit.mjs +2 -2
- package/dist/daemon/client-http.d.ts +10 -16
- package/dist/daemon/client-http.mjs +17 -17
- package/dist/daemon/index.d.ts +17 -14
- package/dist/daemon/index.mjs +18 -18
- package/dist/daemon/install-tunnel.d.ts +8 -34
- package/dist/daemon/install-tunnel.mjs +2 -2
- package/dist/daemon/launcher.d.ts +24 -29
- package/dist/daemon/launcher.mjs +16 -16
- package/dist/daemon/local-tokens.d.ts +23 -0
- package/dist/daemon/lockfile.d.ts +10 -12
- package/dist/daemon/lockfile.mjs +2 -2
- package/dist/daemon/oauth-consent-cache.d.ts +86 -0
- package/dist/daemon/oauth-provider.d.ts +132 -0
- package/dist/daemon/public-pages.d.ts +9 -0
- package/dist/daemon/security.d.ts +52 -0
- package/dist/daemon/server.d.ts +12 -83
- package/dist/daemon/server.mjs +11 -11
- package/dist/daemon/token.d.ts +7 -9
- package/dist/daemon/token.mjs +2 -2
- package/dist/daemon/tunnel-providers/cloudflared-named-setup.d.ts +140 -0
- package/dist/daemon/tunnel-providers/cloudflared-named.d.ts +45 -0
- package/dist/daemon/tunnel-providers/cloudflared-quick.d.ts +8 -0
- package/dist/daemon/tunnel-providers/index.d.ts +16 -327
- package/dist/daemon/tunnel-providers/index.mjs +3 -3
- package/dist/daemon/tunnel-providers/ngrok-config.d.ts +18 -0
- package/dist/daemon/tunnel-providers/ngrok.d.ts +68 -0
- package/dist/daemon/tunnel-providers/types.d.ts +56 -0
- package/dist/daemon/tunnel.d.ts +5 -7
- package/dist/debug-tracer.d.ts +2 -0
- package/dist/doctor-report.d.ts +17 -22
- package/dist/doctor.d.ts +12 -44
- package/dist/doctor.mjs +2 -2
- package/dist/export.d.ts +11 -18
- package/dist/export.mjs +4 -4
- package/dist/format.d.ts +52 -0
- package/dist/fs-utils.d.ts +8 -0
- package/dist/health-check.d.ts +1 -108
- package/dist/health-check.mjs +3 -3
- package/dist/history-store.d.ts +29 -65
- package/dist/history-store.mjs +2 -2
- package/dist/impit-login-runner.d.ts +1 -469
- package/dist/impit-login-runner.mjs +4 -4
- package/dist/index.d.ts +25 -149
- package/dist/index.mjs +22 -20
- package/dist/is-main-module.d.ts +9 -0
- package/dist/login-runner.d.ts +1 -333
- package/dist/login-runner.mjs +13 -13
- package/dist/login.d.ts +5 -0
- package/dist/logout.d.ts +2 -28
- package/dist/logout.mjs +3 -2
- package/dist/manual-login-runner.d.ts +1 -150
- package/dist/manual-login-runner.mjs +11 -11
- package/dist/{native-deps-IE4B55EL.mjs → native-deps-FCSYDL4W.mjs} +4 -4
- package/dist/native-deps.d.ts +36 -0
- package/dist/package-version.d.ts +1 -0
- package/dist/profiles.d.ts +41 -41
- package/dist/profiles.mjs +1 -1
- package/dist/prompts.d.ts +2 -0
- package/dist/redact.d.ts +14 -142
- package/dist/refresh.d.ts +11 -16
- package/dist/refresh.mjs +4 -4
- package/dist/reinit-watcher.d.ts +15 -24
- package/dist/reinit-watcher.mjs +2 -2
- package/dist/resources.d.ts +5 -0
- package/dist/safe-write.d.ts +16 -0
- package/dist/session-metadata.d.ts +45 -0
- package/dist/tool-config.d.ts +10 -0
- package/dist/tools.d.ts +23 -0
- package/dist/tty-prompt.d.ts +18 -34
- package/dist/vault.d.ts +114 -34
- package/dist/vault.mjs +6 -4
- package/dist/viewer-detect.d.ts +2 -4
- package/dist/viewers.d.ts +13 -18
- package/dist/viewers.mjs +1 -1
- package/package.json +3 -3
- package/dist/cloud-sync.d-Cqt6y18U.d.ts +0 -42
- package/dist/doctor.d-CXmUqOXX.d.ts +0 -43
- package/dist/history-store.d-BzjBF2m3.d.ts +0 -65
- package/dist/native-deps-BNThFHxa.d.ts +0 -175
- package/dist/profiles.d-DqS1oZWr.d.ts +0 -41
- package/dist/session-metadata-B9aV_n5g.d.ts +0 -148
- package/dist/vault.d-BSJWDLhp.d.ts +0 -37
- package/dist/viewer-detect.d-HWGnyFAA.d.ts +0 -4
- package/dist/viewers.d-BGCK6sw6.d.ts +0 -10
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, rmSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { getImpitRuntimeDir } from './refresh.js';
|
|
5
|
-
import './config.js';
|
|
6
|
-
import 'patchright';
|
|
7
|
-
|
|
8
|
-
// Speed Boost (impit) install / uninstall helpers shared by the CLI and
|
|
9
|
-
// the VS Code extension. Mirrors the behavior of
|
|
10
|
-
// packages/extension/src/native-deps.ts but lives in the npm package so
|
|
11
|
-
// `npx perplexity-user-mcp install-speed-boost` doesn't require the
|
|
12
|
-
// extension to be installed.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const STATE_MARKER = "native-deps-state.json";
|
|
16
|
-
|
|
17
|
-
function stateFile() {
|
|
18
|
-
return join(getImpitRuntimeDir(), STATE_MARKER);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function writeState(state) {
|
|
22
|
-
const dir = getImpitRuntimeDir();
|
|
23
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
24
|
-
writeFileSync(stateFile(), JSON.stringify(state, null, 2));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function readState() {
|
|
28
|
-
const f = stateFile();
|
|
29
|
-
if (!existsSync(f)) return null;
|
|
30
|
-
try {
|
|
31
|
-
return JSON.parse(readFileSync(f, "utf8"));
|
|
32
|
-
} catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Ensure a minimal package.json exists in the runtime dir so `npm install`
|
|
39
|
-
* lands there cleanly (prevents npm walking up to the user's home and
|
|
40
|
-
* polluting a parent package.json). Mirrors the extension's helper.
|
|
41
|
-
*/
|
|
42
|
-
function ensureRuntimePackageJson() {
|
|
43
|
-
const dir = getImpitRuntimeDir();
|
|
44
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
45
|
-
const pkgPath = join(dir, "package.json");
|
|
46
|
-
if (!existsSync(pkgPath)) {
|
|
47
|
-
writeFileSync(
|
|
48
|
-
pkgPath,
|
|
49
|
-
JSON.stringify(
|
|
50
|
-
{
|
|
51
|
-
name: "perplexity-native-deps",
|
|
52
|
-
version: "1.0.0",
|
|
53
|
-
private: true,
|
|
54
|
-
description: "Runtime native dependencies for the Perplexity MCP CLI/extension.",
|
|
55
|
-
},
|
|
56
|
-
null,
|
|
57
|
-
2,
|
|
58
|
-
),
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
return dir;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @returns {{ installed: boolean; version: string | null; installedAt: string | null; runtimeDir: string }}
|
|
66
|
-
*/
|
|
67
|
-
function getImpitStatus() {
|
|
68
|
-
const dir = getImpitRuntimeDir();
|
|
69
|
-
const marker = join(dir, "node_modules", "impit", "package.json");
|
|
70
|
-
if (!existsSync(marker)) {
|
|
71
|
-
return { installed: false, version: null, installedAt: null, runtimeDir: dir };
|
|
72
|
-
}
|
|
73
|
-
let version = null;
|
|
74
|
-
try {
|
|
75
|
-
version = JSON.parse(readFileSync(marker, "utf8")).version ?? null;
|
|
76
|
-
} catch {
|
|
77
|
-
// marker exists but unreadable — still count as installed
|
|
78
|
-
}
|
|
79
|
-
const state = readState();
|
|
80
|
-
return {
|
|
81
|
-
installed: true,
|
|
82
|
-
version,
|
|
83
|
-
installedAt: state?.installedAt ?? null,
|
|
84
|
-
runtimeDir: dir,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Install impit into ~/.perplexity-mcp/native-deps/ via `npm install`.
|
|
90
|
-
* Does NOT depend on the user's project — uses --prefix into our own
|
|
91
|
-
* runtime dir and ensures a package.json exists there.
|
|
92
|
-
*
|
|
93
|
-
* @param {{ log?: (line: string) => void }} [opts]
|
|
94
|
-
* @returns {Promise<{ ok: boolean; version?: string; error?: string }>}
|
|
95
|
-
*/
|
|
96
|
-
async function installImpit(opts = {}) {
|
|
97
|
-
const log = opts.log ?? (() => undefined);
|
|
98
|
-
const dir = ensureRuntimePackageJson();
|
|
99
|
-
log(`Installing impit into ${dir} via npm...`);
|
|
100
|
-
|
|
101
|
-
return new Promise((resolve) => {
|
|
102
|
-
const child = spawn("npm", ["install", "impit@latest", "--no-audit", "--no-fund", "--loglevel=error"], {
|
|
103
|
-
cwd: dir,
|
|
104
|
-
shell: process.platform === "win32",
|
|
105
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
let stderrBuf = "";
|
|
109
|
-
|
|
110
|
-
child.stdout?.on("data", (chunk) => {
|
|
111
|
-
for (const line of chunk.toString().split(/\r?\n/)) if (line.trim()) log(`npm: ${line}`);
|
|
112
|
-
});
|
|
113
|
-
child.stderr?.on("data", (chunk) => {
|
|
114
|
-
const text = chunk.toString();
|
|
115
|
-
stderrBuf += text;
|
|
116
|
-
for (const line of text.split(/\r?\n/)) if (line.trim()) log(`npm: ${line}`);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
child.on("error", (err) => {
|
|
120
|
-
log(`npm spawn error: ${err.message}`);
|
|
121
|
-
resolve({
|
|
122
|
-
ok: false,
|
|
123
|
-
error:
|
|
124
|
-
err.message.includes("ENOENT")
|
|
125
|
-
? "`npm` not found on PATH. Install Node.js (which ships with npm) and try again."
|
|
126
|
-
: err.message,
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
child.on("close", (code) => {
|
|
131
|
-
if (code !== 0) {
|
|
132
|
-
resolve({
|
|
133
|
-
ok: false,
|
|
134
|
-
error: `npm exited with code ${code}. stderr: ${stderrBuf.slice(0, 400) || "(empty)"}`,
|
|
135
|
-
});
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const status = getImpitStatus();
|
|
139
|
-
if (!status.installed) {
|
|
140
|
-
resolve({
|
|
141
|
-
ok: false,
|
|
142
|
-
error: "npm reported success but impit package.json not found in node_modules. Check npm output above.",
|
|
143
|
-
});
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
writeState({
|
|
147
|
-
version: status.version ?? "unknown",
|
|
148
|
-
installedAt: new Date().toISOString(),
|
|
149
|
-
});
|
|
150
|
-
log(`impit ${status.version ?? ""} installed successfully.`);
|
|
151
|
-
resolve({ ok: true, version: status.version ?? undefined });
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Remove the entire native-deps runtime directory.
|
|
158
|
-
*
|
|
159
|
-
* @param {{ log?: (line: string) => void }} [opts]
|
|
160
|
-
* @returns {{ ok: boolean; error?: string }}
|
|
161
|
-
*/
|
|
162
|
-
function uninstallImpit(opts = {}) {
|
|
163
|
-
const log = opts.log ?? (() => undefined);
|
|
164
|
-
const dir = getImpitRuntimeDir();
|
|
165
|
-
if (!existsSync(dir)) return { ok: true };
|
|
166
|
-
try {
|
|
167
|
-
rmSync(dir, { recursive: true, force: true });
|
|
168
|
-
log(`Removed ${dir}.`);
|
|
169
|
-
return { ok: true };
|
|
170
|
-
} catch (err) {
|
|
171
|
-
return { ok: false, error: err.message };
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export { getImpitStatus, installImpit, uninstallImpit };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
interface ProfileMeta {
|
|
2
|
-
name: string;
|
|
3
|
-
displayName: string;
|
|
4
|
-
createdAt: string;
|
|
5
|
-
loginMode?: string;
|
|
6
|
-
tier?: string;
|
|
7
|
-
lastLogin?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface ProfilePaths {
|
|
11
|
-
dir: string;
|
|
12
|
-
meta: string;
|
|
13
|
-
vault: string;
|
|
14
|
-
vaultPlain: string;
|
|
15
|
-
browserData: string;
|
|
16
|
-
modelsCache: string;
|
|
17
|
-
history: string;
|
|
18
|
-
attachments: string;
|
|
19
|
-
researches: string;
|
|
20
|
-
reinit: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare function getConfigDir(): string;
|
|
24
|
-
declare function getProfilesDir(): string;
|
|
25
|
-
declare function getProfilePaths(name: string): ProfilePaths;
|
|
26
|
-
declare function validateName(name: string): string | null;
|
|
27
|
-
declare function createProfile(name: string, opts?: { displayName?: string; loginMode?: string }): ProfileMeta;
|
|
28
|
-
declare function listProfiles(): ProfileMeta[];
|
|
29
|
-
declare function getProfile(name: string): ProfileMeta | null;
|
|
30
|
-
declare function deleteProfile(name: string): void;
|
|
31
|
-
declare function getActiveName(): string | null;
|
|
32
|
-
declare function getActive(): ProfileMeta | null;
|
|
33
|
-
declare function setActive(name: string): void;
|
|
34
|
-
declare function suggestNextDefaultName(): string;
|
|
35
|
-
declare function renameProfile(oldName: string, newName: string): void;
|
|
36
|
-
declare function recordLoginSuccess(
|
|
37
|
-
name: string,
|
|
38
|
-
opts: { tier: string; loginMode: string; lastLogin: string }
|
|
39
|
-
): ProfileMeta;
|
|
40
|
-
|
|
41
|
-
export { type ProfileMeta, type ProfilePaths, createProfile, deleteProfile, getActive, getActiveName, getConfigDir, getProfile, getProfilePaths, getProfilesDir, listProfiles, recordLoginSuccess, renameProfile, setActive, suggestNextDefaultName, validateName };
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
const API_VERSION_QUERY = "version=2.18&source=default";
|
|
2
|
-
|
|
3
|
-
function buildRuntimeEndpoints(origin) {
|
|
4
|
-
const base = origin.replace(/\/+$/, "");
|
|
5
|
-
return {
|
|
6
|
-
session: `${base}/api/auth/session?${API_VERSION_QUERY}`,
|
|
7
|
-
csrf: `${base}/api/auth/csrf?${API_VERSION_QUERY}`,
|
|
8
|
-
signInEmail: `${base}/api/auth/signin/email?${API_VERSION_QUERY}`,
|
|
9
|
-
otpRedirectLink: `${base}/api/auth/otp-redirect-link`,
|
|
10
|
-
ssoDetails: `${base}/rest/enterprise/organization/login/details?${API_VERSION_QUERY}`,
|
|
11
|
-
models: `${base}/rest/models/config?config_schema=v1&${API_VERSION_QUERY}`,
|
|
12
|
-
asi: `${base}/rest/billing/asi-access-decision?${API_VERSION_QUERY}`,
|
|
13
|
-
rateLimits: `${base}/rest/rate-limit/status?${API_VERSION_QUERY}`,
|
|
14
|
-
experiments: `${base}/rest/experiments/attributes?${API_VERSION_QUERY}`,
|
|
15
|
-
userInfo: `${base}/rest/user/info?${API_VERSION_QUERY}`,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function pageRequest(page, url, init = {}) {
|
|
20
|
-
return page.evaluate(async ({ url: target, init: requestInit }) => {
|
|
21
|
-
try {
|
|
22
|
-
const response = await fetch(target, {
|
|
23
|
-
credentials: "include",
|
|
24
|
-
...requestInit,
|
|
25
|
-
});
|
|
26
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
27
|
-
let json = null;
|
|
28
|
-
let text = null;
|
|
29
|
-
try {
|
|
30
|
-
if (contentType.includes("json")) json = await response.json();
|
|
31
|
-
else text = (await response.text()).slice(0, 500);
|
|
32
|
-
} catch {}
|
|
33
|
-
return {
|
|
34
|
-
ok: response.ok,
|
|
35
|
-
status: response.status,
|
|
36
|
-
redirected: response.redirected,
|
|
37
|
-
url: response.url,
|
|
38
|
-
contentType,
|
|
39
|
-
json,
|
|
40
|
-
text,
|
|
41
|
-
};
|
|
42
|
-
} catch (error) {
|
|
43
|
-
return {
|
|
44
|
-
ok: false,
|
|
45
|
-
status: 0,
|
|
46
|
-
redirected: false,
|
|
47
|
-
url: target,
|
|
48
|
-
contentType: "",
|
|
49
|
-
json: null,
|
|
50
|
-
text: null,
|
|
51
|
-
error: error?.message ?? String(error),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}, { url, init });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function pollSession(page, sessionUrl, { timeoutMs = 10_000, intervalMs = 500 } = {}) {
|
|
58
|
-
const started = Date.now();
|
|
59
|
-
while (Date.now() - started < timeoutMs) {
|
|
60
|
-
const sessionResp = await pageRequest(page, sessionUrl);
|
|
61
|
-
if (sessionResp.ok && sessionResp.json?.user?.id) {
|
|
62
|
-
return sessionResp.json;
|
|
63
|
-
}
|
|
64
|
-
await page.waitForTimeout(intervalMs);
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function deriveAccountFlags({ experiments, userInfo, asi }) {
|
|
70
|
-
const isEnterprise = userInfo?.is_enterprise === true || experiments?.server_is_enterprise === true;
|
|
71
|
-
const isMax = experiments?.server_is_max === true;
|
|
72
|
-
const canUseComputer = asi?.can_use_computer ?? false;
|
|
73
|
-
const isPro =
|
|
74
|
-
experiments?.server_is_pro === true ||
|
|
75
|
-
(canUseComputer && !isMax && !isEnterprise);
|
|
76
|
-
|
|
77
|
-
return { isPro, isMax, isEnterprise, canUseComputer };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function deriveTier(payload) {
|
|
81
|
-
const { isPro, isMax, isEnterprise } = deriveAccountFlags(payload);
|
|
82
|
-
if (isMax) return "Max";
|
|
83
|
-
if (isEnterprise) return "Enterprise";
|
|
84
|
-
if (isPro) return "Pro";
|
|
85
|
-
return "Authenticated";
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async function collectSessionMetadata(page, origin, opts = {}) {
|
|
89
|
-
const endpoints = buildRuntimeEndpoints(origin);
|
|
90
|
-
const sessionData =
|
|
91
|
-
opts.sessionData ??
|
|
92
|
-
await pollSession(page, endpoints.session, { timeoutMs: opts.sessionTimeoutMs ?? 10_000 });
|
|
93
|
-
|
|
94
|
-
if (!sessionData?.user?.id) {
|
|
95
|
-
return {
|
|
96
|
-
sessionData: null,
|
|
97
|
-
models: null,
|
|
98
|
-
asi: null,
|
|
99
|
-
rateLimits: null,
|
|
100
|
-
experiments: null,
|
|
101
|
-
userInfo: null,
|
|
102
|
-
tier: "Authenticated",
|
|
103
|
-
cache: {
|
|
104
|
-
modelsConfig: null,
|
|
105
|
-
rateLimits: null,
|
|
106
|
-
isPro: false,
|
|
107
|
-
isMax: false,
|
|
108
|
-
isEnterprise: false,
|
|
109
|
-
canUseComputer: false,
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const [modelsResp, asiResp, rateResp, expResp, userInfoResp] = await Promise.all([
|
|
115
|
-
pageRequest(page, endpoints.models),
|
|
116
|
-
pageRequest(page, endpoints.asi),
|
|
117
|
-
pageRequest(page, endpoints.rateLimits),
|
|
118
|
-
pageRequest(page, endpoints.experiments),
|
|
119
|
-
pageRequest(page, endpoints.userInfo),
|
|
120
|
-
]);
|
|
121
|
-
|
|
122
|
-
const payload = {
|
|
123
|
-
experiments: expResp.ok ? expResp.json : null,
|
|
124
|
-
userInfo: userInfoResp.ok ? userInfoResp.json : null,
|
|
125
|
-
asi: asiResp.ok ? asiResp.json : null,
|
|
126
|
-
};
|
|
127
|
-
const flags = deriveAccountFlags(payload);
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
sessionData,
|
|
131
|
-
models: modelsResp.ok ? modelsResp.json : null,
|
|
132
|
-
asi: asiResp.ok ? asiResp.json : null,
|
|
133
|
-
rateLimits: rateResp.ok ? rateResp.json : null,
|
|
134
|
-
experiments: expResp.ok ? expResp.json : null,
|
|
135
|
-
userInfo: userInfoResp.ok ? userInfoResp.json : null,
|
|
136
|
-
tier: deriveTier(payload),
|
|
137
|
-
cache: {
|
|
138
|
-
modelsConfig: modelsResp.ok ? modelsResp.json : null,
|
|
139
|
-
rateLimits: rateResp.ok ? rateResp.json : null,
|
|
140
|
-
isPro: flags.isPro,
|
|
141
|
-
isMax: flags.isMax,
|
|
142
|
-
isEnterprise: flags.isEnterprise,
|
|
143
|
-
canUseComputer: flags.canUseComputer,
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export { buildRuntimeEndpoints as b, collectSessionMetadata as c, pageRequest as p };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
declare function encryptBlob(plaintext: Buffer, key: Buffer): Buffer;
|
|
2
|
-
declare function decryptBlob(blob: Buffer, key: Buffer): Buffer;
|
|
3
|
-
declare function __resetKeyCache(): void;
|
|
4
|
-
declare function getMasterKey(): Promise<Buffer>;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* TEST SEAM — drop scrypt cost during tests by overriding the (logN, r, p)
|
|
8
|
-
* parameters used at write time. Reads always use the params embedded in the
|
|
9
|
-
* blob, regardless of any override.
|
|
10
|
-
*
|
|
11
|
-
* Cleared by `__resetKeyCache()` so tests do not leak state across files.
|
|
12
|
-
* MUST NOT be called from production code paths. The decrypt-time floor
|
|
13
|
-
* check (logN >= SCRYPT_LOGN_FLOOR) remains enforced unconditionally.
|
|
14
|
-
*/
|
|
15
|
-
declare function __setKdfParamsForTest(params: { logN: number; r: number; p: number }): void;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Sibling of `getMasterKey()` introduced with the v2 vault format. Returns
|
|
19
|
-
* the unseal context WITHOUT prematurely deriving the HKDF key — for v2
|
|
20
|
-
* blobs, key derivation needs the salt embedded in each blob, so it can no
|
|
21
|
-
* longer happen up front. Cached just like `_keyCache`; cleared by
|
|
22
|
-
* `__resetKeyCache()`.
|
|
23
|
-
*/
|
|
24
|
-
type UnsealMaterial =
|
|
25
|
-
| { kind: "key"; key: Buffer }
|
|
26
|
-
| { kind: "passphrase"; passphrase: string };
|
|
27
|
-
|
|
28
|
-
declare function getUnsealMaterial(): Promise<UnsealMaterial>;
|
|
29
|
-
|
|
30
|
-
declare class Vault {
|
|
31
|
-
get(profile: string, key: string): Promise<string | null>;
|
|
32
|
-
set(profile: string, key: string, value: string): Promise<void>;
|
|
33
|
-
delete(profile: string, key: string): Promise<void>;
|
|
34
|
-
deleteAll(profile: string): Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { type UnsealMaterial, Vault, __resetKeyCache, __setKdfParamsForTest, decryptBlob, encryptBlob, getMasterKey, getUnsealMaterial };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ExternalViewer } from '@perplexity-user-mcp/shared';
|
|
2
|
-
|
|
3
|
-
declare function listViewers(overrides?: ExternalViewer[]): ExternalViewer[];
|
|
4
|
-
declare function buildViewerUrl(options: {
|
|
5
|
-
viewer: ExternalViewer;
|
|
6
|
-
mdPath: string;
|
|
7
|
-
profile?: string;
|
|
8
|
-
}): string;
|
|
9
|
-
|
|
10
|
-
export { buildViewerUrl, listViewers };
|