mcp-scraper 0.3.5 → 0.3.7

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 (44) hide show
  1. package/README.md +18 -26
  2. package/dist/bin/api-server.cjs +164 -329
  3. package/dist/bin/api-server.cjs.map +1 -1
  4. package/dist/bin/api-server.js +1 -1
  5. package/dist/bin/browser-agent-stdio-server.cjs +39 -1750
  6. package/dist/bin/browser-agent-stdio-server.cjs.map +1 -1
  7. package/dist/bin/browser-agent-stdio-server.js +2 -4
  8. package/dist/bin/browser-agent-stdio-server.js.map +1 -1
  9. package/dist/bin/mcp-scraper-cli.cjs +47 -328
  10. package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
  11. package/dist/bin/mcp-scraper-cli.js +7 -91
  12. package/dist/bin/mcp-scraper-cli.js.map +1 -1
  13. package/dist/bin/mcp-scraper-combined-stdio-server.cjs +78 -1796
  14. package/dist/bin/mcp-scraper-combined-stdio-server.cjs.map +1 -1
  15. package/dist/bin/mcp-scraper-combined-stdio-server.js +4 -6
  16. package/dist/bin/mcp-scraper-combined-stdio-server.js.map +1 -1
  17. package/dist/bin/mcp-scraper-install.cjs +4 -4
  18. package/dist/bin/mcp-scraper-install.cjs.map +1 -1
  19. package/dist/bin/mcp-scraper-install.js +2 -2
  20. package/dist/bin/mcp-stdio-server.cjs +18 -25
  21. package/dist/bin/mcp-stdio-server.cjs.map +1 -1
  22. package/dist/bin/mcp-stdio-server.js +2 -2
  23. package/dist/chunk-2NEVRPK3.js +7 -0
  24. package/dist/chunk-2NEVRPK3.js.map +1 -0
  25. package/dist/{chunk-WZT3XKES.js → chunk-2O7RAK6E.js} +19 -26
  26. package/dist/chunk-2O7RAK6E.js.map +1 -0
  27. package/dist/{chunk-RVYHP7QN.js → chunk-ELI6NDEG.js} +4 -4
  28. package/dist/{chunk-RVYHP7QN.js.map → chunk-ELI6NDEG.js.map} +1 -1
  29. package/dist/{chunk-CMK5MMEE.js → chunk-IWNLHCKA.js} +13 -694
  30. package/dist/chunk-IWNLHCKA.js.map +1 -0
  31. package/dist/{server-BC4Z2L4P.js → server-HRVD52CX.js} +842 -122
  32. package/dist/server-HRVD52CX.js.map +1 -0
  33. package/docs/mcp-tool-craft-lint.generated.md +2 -5
  34. package/docs/mcp-tool-manifest.generated.json +9 -101
  35. package/package.json +1 -1
  36. package/dist/chunk-CMK5MMEE.js.map +0 -1
  37. package/dist/chunk-DUEW4EOO.js +0 -214
  38. package/dist/chunk-DUEW4EOO.js.map +0 -1
  39. package/dist/chunk-GHBU5SGQ.js +0 -7
  40. package/dist/chunk-GHBU5SGQ.js.map +0 -1
  41. package/dist/chunk-NXRWFOEZ.js +0 -816
  42. package/dist/chunk-NXRWFOEZ.js.map +0 -1
  43. package/dist/chunk-WZT3XKES.js.map +0 -1
  44. package/dist/server-BC4Z2L4P.js.map +0 -1
@@ -1,214 +0,0 @@
1
- // src/lib/chrome-profiles.ts
2
- import { readFile } from "fs/promises";
3
- import { homedir } from "os";
4
- import { join } from "path";
5
- function defaultChromeUserDataDir() {
6
- if (process.platform === "darwin") return join(homedir(), "Library", "Application Support", "Google", "Chrome");
7
- if (process.platform === "win32") {
8
- return join(process.env.LOCALAPPDATA ?? join(homedir(), "AppData", "Local"), "Google", "Chrome", "User Data");
9
- }
10
- return join(process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "google-chrome");
11
- }
12
- function recommendedKernelProfileName(value) {
13
- return value.trim().toLowerCase().replace(/@/g, "-").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80) || "browser-profile";
14
- }
15
- async function listLocalChromeProfiles(userDataDir = defaultChromeUserDataDir(), emailFilter) {
16
- const raw = await readFile(join(userDataDir, "Local State"), "utf8");
17
- const localState = JSON.parse(raw);
18
- const wanted = emailFilter?.trim().toLowerCase();
19
- return Object.entries(localState.profile?.info_cache ?? {}).map(([directory, info]) => {
20
- const email = (info.user_name ?? "").trim();
21
- const displayName = (info.name ?? info.shortcut_name ?? "").trim();
22
- const labelSource = email || displayName || directory;
23
- return {
24
- email,
25
- displayName,
26
- chromeProfileDirectory: directory,
27
- chromeProfilePath: join(userDataDir, directory),
28
- recommendedKernelProfileName: recommendedKernelProfileName(labelSource)
29
- };
30
- }).filter((row) => !wanted || row.email.toLowerCase() === wanted || row.displayName.toLowerCase().includes(wanted));
31
- }
32
-
33
- // src/lib/local-browser-profiles.ts
34
- import { existsSync } from "fs";
35
- import { cp, mkdir, readFile as readFile2, rm, stat, writeFile } from "fs/promises";
36
- import { homedir as homedir2 } from "os";
37
- import { join as join2, relative, sep } from "path";
38
- var EXCLUDED_PROFILE_NAMES = [
39
- "Cache",
40
- "Code Cache",
41
- "Crashpad",
42
- "DawnCache",
43
- "DawnGraphiteCache",
44
- "DawnWebGPUCache",
45
- "GPUCache",
46
- "GrShaderCache",
47
- "ShaderCache",
48
- "Shared Dictionary"
49
- ];
50
- function defaultImportedBrowserProfilesDir() {
51
- return process.env.MCP_SCRAPER_BROWSER_PROFILE_BASE_DIR?.trim() || join2(homedir2(), ".mcp-scraper", "browser-profiles");
52
- }
53
- function defaultChromeExecutablePath() {
54
- const envPath = process.env.MCP_SCRAPER_BROWSER_EXECUTABLE?.trim() || process.env.CHROME_PATH?.trim();
55
- if (envPath) return envPath;
56
- const candidates = process.platform === "darwin" ? ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"] : process.platform === "win32" ? [
57
- join2(process.env.PROGRAMFILES ?? "C:\\Program Files", "Google", "Chrome", "Application", "chrome.exe"),
58
- join2(process.env["PROGRAMFILES(X86)"] ?? "C:\\Program Files (x86)", "Google", "Chrome", "Application", "chrome.exe")
59
- ] : ["/usr/bin/google-chrome", "/usr/bin/google-chrome-stable", "/usr/bin/chromium-browser", "/usr/bin/chromium"];
60
- return candidates.find((candidate) => existsSync(candidate));
61
- }
62
- function localBrowserModeEnabled() {
63
- return process.env.MCP_SCRAPER_BROWSER_MODE?.trim().toLowerCase() === "local";
64
- }
65
- function importedProfileName(value) {
66
- return recommendedKernelProfileName(value);
67
- }
68
- function importedProfileRoot(name, outputDir = defaultImportedBrowserProfilesDir()) {
69
- return join2(outputDir, importedProfileName(name));
70
- }
71
- function importedProfileManifestPath(name, outputDir = defaultImportedBrowserProfilesDir()) {
72
- return join2(importedProfileRoot(name, outputDir), "manifest.json");
73
- }
74
- function importedProfileUserDataDir(name, outputDir = defaultImportedBrowserProfilesDir()) {
75
- return join2(importedProfileRoot(name, outputDir), "user-data");
76
- }
77
- async function readExistingManifest(path) {
78
- try {
79
- return JSON.parse(await readFile2(path, "utf8"));
80
- } catch {
81
- return null;
82
- }
83
- }
84
- function isExcludedProfilePath(sourceRoot, sourcePath) {
85
- const rel = relative(sourceRoot, sourcePath);
86
- if (!rel) return false;
87
- const parts = rel.split(sep).filter(Boolean);
88
- const last = parts[parts.length - 1] ?? "";
89
- if (last.startsWith("Singleton")) return true;
90
- if (last === "LOCK" || last.endsWith(".lock")) return true;
91
- if (parts.some((part) => EXCLUDED_PROFILE_NAMES.includes(part))) return true;
92
- if (parts.includes("Service Worker") && parts.includes("CacheStorage")) return true;
93
- return false;
94
- }
95
- async function copyProfileTree(sourceProfilePath, destinationProfilePath) {
96
- await cp(sourceProfilePath, destinationProfilePath, {
97
- recursive: true,
98
- force: true,
99
- errorOnExist: false,
100
- dereference: false,
101
- filter: (source) => !isExcludedProfilePath(sourceProfilePath, source)
102
- });
103
- }
104
- function selectProfile(profiles, options) {
105
- const requestedDirectory = options.chromeProfileDirectory?.trim();
106
- const requestedEmail = options.email?.trim().toLowerCase();
107
- const exactDirectory = requestedDirectory ? profiles.find((profile) => profile.chromeProfileDirectory === requestedDirectory) : void 0;
108
- if (exactDirectory) return exactDirectory;
109
- const exactEmail = requestedEmail ? profiles.find((profile) => profile.email.toLowerCase() === requestedEmail) : void 0;
110
- if (exactEmail) return exactEmail;
111
- const first = profiles[0];
112
- if (first) return first;
113
- const hint = requestedDirectory ? `Chrome profile directory "${requestedDirectory}"` : requestedEmail ? `Chrome account "${requestedEmail}"` : "Chrome profile";
114
- throw new Error(`${hint} was not found in ${options.sourceUserDataDir ?? defaultChromeUserDataDir()}`);
115
- }
116
- async function ensureProfilePathExists(profile) {
117
- const details = await stat(profile.chromeProfilePath).catch(() => null);
118
- if (!details?.isDirectory()) {
119
- throw new Error(`Chrome profile path does not exist or is not a directory: ${profile.chromeProfilePath}`);
120
- }
121
- }
122
- async function writeNormalizedLocalState(sourceLocalStatePath, destinationLocalStatePath, sourceProfileDirectory) {
123
- const raw = await readFile2(sourceLocalStatePath, "utf8");
124
- const localState = JSON.parse(raw);
125
- const selectedInfo = localState.profile?.info_cache?.[sourceProfileDirectory] ?? localState.profile?.info_cache?.Default ?? {};
126
- localState.profile = {
127
- ...localState.profile ?? {},
128
- info_cache: { Default: selectedInfo },
129
- last_used: "Default",
130
- last_active_profiles: ["Default"]
131
- };
132
- await writeFile(destinationLocalStatePath, `${JSON.stringify(localState, null, 2)}
133
- `);
134
- }
135
- async function importChromeProfile(options = {}) {
136
- const sourceUserDataDir = options.sourceUserDataDir?.trim() || defaultChromeUserDataDir();
137
- const profiles = await listLocalChromeProfiles(sourceUserDataDir, options.email);
138
- const sourceProfile = selectProfile(profiles, { ...options, sourceUserDataDir });
139
- await ensureProfilePathExists(sourceProfile);
140
- const name = importedProfileName(options.name?.trim() || sourceProfile.recommendedKernelProfileName);
141
- const outputDir = options.outputDir?.trim() || defaultImportedBrowserProfilesDir();
142
- const profileRoot = importedProfileRoot(name, outputDir);
143
- const manifestPath = importedProfileManifestPath(name, outputDir);
144
- const userDataDir = importedProfileUserDataDir(name, outputDir);
145
- const existingManifest = await readExistingManifest(manifestPath);
146
- const existing = existsSync(profileRoot);
147
- if (existing && !options.overwrite) {
148
- throw new Error(`Imported browser profile "${name}" already exists at ${profileRoot}. Re-run with --overwrite to refresh it.`);
149
- }
150
- if (existing) await rm(profileRoot, { recursive: true, force: true });
151
- await mkdir(join2(userDataDir, "Default"), { recursive: true });
152
- await writeNormalizedLocalState(
153
- join2(sourceUserDataDir, "Local State"),
154
- join2(userDataDir, "Local State"),
155
- sourceProfile.chromeProfileDirectory
156
- );
157
- await copyProfileTree(sourceProfile.chromeProfilePath, join2(userDataDir, "Default"));
158
- const now = (/* @__PURE__ */ new Date()).toISOString();
159
- const manifest = {
160
- layoutVersion: 1,
161
- name,
162
- profileRoot,
163
- userDataDir,
164
- browserExecutablePath: options.browserExecutablePath?.trim() || defaultChromeExecutablePath() || null,
165
- sourceUserDataDir,
166
- sourceProfileDirectory: sourceProfile.chromeProfileDirectory,
167
- sourceProfilePath: sourceProfile.chromeProfilePath,
168
- email: sourceProfile.email,
169
- displayName: sourceProfile.displayName,
170
- createdAt: existingManifest?.createdAt ?? now,
171
- updatedAt: now,
172
- copyMode: "chrome-profile-clone"
173
- };
174
- await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
175
- `);
176
- return {
177
- profile: manifest,
178
- sourceProfile,
179
- excludedNames: EXCLUDED_PROFILE_NAMES
180
- };
181
- }
182
- async function loadImportedBrowserProfile(name = process.env.MCP_SCRAPER_BROWSER_PROFILE?.trim() || "default", outputDir = defaultImportedBrowserProfilesDir()) {
183
- const profileName = importedProfileName(name);
184
- const manifestPath = importedProfileManifestPath(profileName, outputDir);
185
- const manifest = await readExistingManifest(manifestPath);
186
- if (!manifest) {
187
- throw new Error(
188
- `Imported browser profile "${profileName}" was not found. Run: mcp-scraper-cli browser import-chrome --name ${profileName}`
189
- );
190
- }
191
- return manifest;
192
- }
193
- async function syncImportedChromeProfile(name, options = {}) {
194
- const outputDir = options.outputDir?.trim() || defaultImportedBrowserProfilesDir();
195
- const manifest = await loadImportedBrowserProfile(name, outputDir);
196
- return importChromeProfile({
197
- name: manifest.name,
198
- sourceUserDataDir: manifest.sourceUserDataDir,
199
- chromeProfileDirectory: manifest.sourceProfileDirectory,
200
- outputDir,
201
- overwrite: true,
202
- browserExecutablePath: options.browserExecutablePath ?? manifest.browserExecutablePath ?? void 0
203
- });
204
- }
205
-
206
- export {
207
- listLocalChromeProfiles,
208
- defaultChromeExecutablePath,
209
- localBrowserModeEnabled,
210
- importChromeProfile,
211
- loadImportedBrowserProfile,
212
- syncImportedChromeProfile
213
- };
214
- //# sourceMappingURL=chunk-DUEW4EOO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/chrome-profiles.ts","../src/lib/local-browser-profiles.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\n\nexport interface LocalChromeProfile {\n email: string\n displayName: string\n chromeProfileDirectory: string\n chromeProfilePath: string\n recommendedKernelProfileName: string\n}\n\nexport function defaultChromeUserDataDir(): string {\n if (process.platform === 'darwin') return join(homedir(), 'Library', 'Application Support', 'Google', 'Chrome')\n if (process.platform === 'win32') {\n return join(process.env.LOCALAPPDATA ?? join(homedir(), 'AppData', 'Local'), 'Google', 'Chrome', 'User Data')\n }\n return join(process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config'), 'google-chrome')\n}\n\nexport function recommendedKernelProfileName(value: string): string {\n return value\n .trim()\n .toLowerCase()\n .replace(/@/g, '-')\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 80) || 'browser-profile'\n}\n\nexport async function listLocalChromeProfiles(\n userDataDir = defaultChromeUserDataDir(),\n emailFilter?: string,\n): Promise<LocalChromeProfile[]> {\n const raw = await readFile(join(userDataDir, 'Local State'), 'utf8')\n const localState = JSON.parse(raw) as {\n profile?: {\n info_cache?: Record<string, {\n name?: string\n shortcut_name?: string\n user_name?: string\n gaia_name?: string\n }>\n }\n }\n const wanted = emailFilter?.trim().toLowerCase()\n return Object.entries(localState.profile?.info_cache ?? {})\n .map(([directory, info]) => {\n const email = (info.user_name ?? '').trim()\n const displayName = (info.name ?? info.shortcut_name ?? '').trim()\n const labelSource = email || displayName || directory\n return {\n email,\n displayName,\n chromeProfileDirectory: directory,\n chromeProfilePath: join(userDataDir, directory),\n recommendedKernelProfileName: recommendedKernelProfileName(labelSource),\n }\n })\n .filter(row => !wanted || row.email.toLowerCase() === wanted || row.displayName.toLowerCase().includes(wanted))\n}\n","import { existsSync } from 'node:fs'\nimport { cp, mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { join, relative, sep } from 'node:path'\nimport {\n defaultChromeUserDataDir,\n listLocalChromeProfiles,\n recommendedKernelProfileName,\n type LocalChromeProfile,\n} from './chrome-profiles.js'\n\nexport interface ImportedBrowserProfileManifest {\n layoutVersion: 1\n name: string\n profileRoot: string\n userDataDir: string\n browserExecutablePath: string | null\n sourceUserDataDir: string\n sourceProfileDirectory: string\n sourceProfilePath: string\n email: string\n displayName: string\n createdAt: string\n updatedAt: string\n copyMode: 'chrome-profile-clone'\n}\n\nexport interface ImportChromeProfileOptions {\n email?: string\n name?: string\n chromeProfileDirectory?: string\n sourceUserDataDir?: string\n outputDir?: string\n overwrite?: boolean\n browserExecutablePath?: string\n}\n\nexport interface ImportChromeProfileResult {\n profile: ImportedBrowserProfileManifest\n sourceProfile: LocalChromeProfile\n excludedNames: string[]\n}\n\nconst EXCLUDED_PROFILE_NAMES = [\n 'Cache',\n 'Code Cache',\n 'Crashpad',\n 'DawnCache',\n 'DawnGraphiteCache',\n 'DawnWebGPUCache',\n 'GPUCache',\n 'GrShaderCache',\n 'ShaderCache',\n 'Shared Dictionary',\n]\n\nexport function defaultImportedBrowserProfilesDir(): string {\n return process.env.MCP_SCRAPER_BROWSER_PROFILE_BASE_DIR?.trim()\n || join(homedir(), '.mcp-scraper', 'browser-profiles')\n}\n\nexport function defaultChromeExecutablePath(): string | undefined {\n const envPath = process.env.MCP_SCRAPER_BROWSER_EXECUTABLE?.trim() || process.env.CHROME_PATH?.trim()\n if (envPath) return envPath\n\n const candidates = process.platform === 'darwin'\n ? ['/Applications/Google Chrome.app/Contents/MacOS/Google Chrome']\n : process.platform === 'win32'\n ? [\n join(process.env.PROGRAMFILES ?? 'C:\\\\Program Files', 'Google', 'Chrome', 'Application', 'chrome.exe'),\n join(process.env['PROGRAMFILES(X86)'] ?? 'C:\\\\Program Files (x86)', 'Google', 'Chrome', 'Application', 'chrome.exe'),\n ]\n : ['/usr/bin/google-chrome', '/usr/bin/google-chrome-stable', '/usr/bin/chromium-browser', '/usr/bin/chromium']\n\n return candidates.find(candidate => existsSync(candidate))\n}\n\nexport function localBrowserModeEnabled(): boolean {\n return process.env.MCP_SCRAPER_BROWSER_MODE?.trim().toLowerCase() === 'local'\n}\n\nexport function importedProfileName(value: string): string {\n return recommendedKernelProfileName(value)\n}\n\nexport function importedProfileRoot(name: string, outputDir = defaultImportedBrowserProfilesDir()): string {\n return join(outputDir, importedProfileName(name))\n}\n\nexport function importedProfileManifestPath(name: string, outputDir = defaultImportedBrowserProfilesDir()): string {\n return join(importedProfileRoot(name, outputDir), 'manifest.json')\n}\n\nexport function importedProfileUserDataDir(name: string, outputDir = defaultImportedBrowserProfilesDir()): string {\n return join(importedProfileRoot(name, outputDir), 'user-data')\n}\n\nasync function readExistingManifest(path: string): Promise<ImportedBrowserProfileManifest | null> {\n try {\n return JSON.parse(await readFile(path, 'utf8')) as ImportedBrowserProfileManifest\n } catch {\n return null\n }\n}\n\nfunction isExcludedProfilePath(sourceRoot: string, sourcePath: string): boolean {\n const rel = relative(sourceRoot, sourcePath)\n if (!rel) return false\n const parts = rel.split(sep).filter(Boolean)\n const last = parts[parts.length - 1] ?? ''\n if (last.startsWith('Singleton')) return true\n if (last === 'LOCK' || last.endsWith('.lock')) return true\n if (parts.some(part => EXCLUDED_PROFILE_NAMES.includes(part))) return true\n if (parts.includes('Service Worker') && parts.includes('CacheStorage')) return true\n return false\n}\n\nasync function copyProfileTree(sourceProfilePath: string, destinationProfilePath: string): Promise<void> {\n await cp(sourceProfilePath, destinationProfilePath, {\n recursive: true,\n force: true,\n errorOnExist: false,\n dereference: false,\n filter: source => !isExcludedProfilePath(sourceProfilePath, source),\n })\n}\n\nfunction selectProfile(profiles: LocalChromeProfile[], options: ImportChromeProfileOptions): LocalChromeProfile {\n const requestedDirectory = options.chromeProfileDirectory?.trim()\n const requestedEmail = options.email?.trim().toLowerCase()\n const exactDirectory = requestedDirectory\n ? profiles.find(profile => profile.chromeProfileDirectory === requestedDirectory)\n : undefined\n if (exactDirectory) return exactDirectory\n\n const exactEmail = requestedEmail\n ? profiles.find(profile => profile.email.toLowerCase() === requestedEmail)\n : undefined\n if (exactEmail) return exactEmail\n\n const first = profiles[0]\n if (first) return first\n\n const hint = requestedDirectory\n ? `Chrome profile directory \"${requestedDirectory}\"`\n : requestedEmail\n ? `Chrome account \"${requestedEmail}\"`\n : 'Chrome profile'\n throw new Error(`${hint} was not found in ${options.sourceUserDataDir ?? defaultChromeUserDataDir()}`)\n}\n\nasync function ensureProfilePathExists(profile: LocalChromeProfile): Promise<void> {\n const details = await stat(profile.chromeProfilePath).catch(() => null)\n if (!details?.isDirectory()) {\n throw new Error(`Chrome profile path does not exist or is not a directory: ${profile.chromeProfilePath}`)\n }\n}\n\nasync function writeNormalizedLocalState(\n sourceLocalStatePath: string,\n destinationLocalStatePath: string,\n sourceProfileDirectory: string,\n): Promise<void> {\n const raw = await readFile(sourceLocalStatePath, 'utf8')\n const localState = JSON.parse(raw) as {\n profile?: {\n info_cache?: Record<string, unknown>\n last_used?: string\n last_active_profiles?: string[]\n }\n }\n const selectedInfo = localState.profile?.info_cache?.[sourceProfileDirectory]\n ?? localState.profile?.info_cache?.Default\n ?? {}\n localState.profile = {\n ...(localState.profile ?? {}),\n info_cache: { Default: selectedInfo },\n last_used: 'Default',\n last_active_profiles: ['Default'],\n }\n await writeFile(destinationLocalStatePath, `${JSON.stringify(localState, null, 2)}\\n`)\n}\n\nexport async function importChromeProfile(options: ImportChromeProfileOptions = {}): Promise<ImportChromeProfileResult> {\n const sourceUserDataDir = options.sourceUserDataDir?.trim() || defaultChromeUserDataDir()\n const profiles = await listLocalChromeProfiles(sourceUserDataDir, options.email)\n const sourceProfile = selectProfile(profiles, { ...options, sourceUserDataDir })\n await ensureProfilePathExists(sourceProfile)\n\n const name = importedProfileName(options.name?.trim() || sourceProfile.recommendedKernelProfileName)\n const outputDir = options.outputDir?.trim() || defaultImportedBrowserProfilesDir()\n const profileRoot = importedProfileRoot(name, outputDir)\n const manifestPath = importedProfileManifestPath(name, outputDir)\n const userDataDir = importedProfileUserDataDir(name, outputDir)\n const existingManifest = await readExistingManifest(manifestPath)\n const existing = existsSync(profileRoot)\n\n if (existing && !options.overwrite) {\n throw new Error(`Imported browser profile \"${name}\" already exists at ${profileRoot}. Re-run with --overwrite to refresh it.`)\n }\n\n if (existing) await rm(profileRoot, { recursive: true, force: true })\n await mkdir(join(userDataDir, 'Default'), { recursive: true })\n await writeNormalizedLocalState(\n join(sourceUserDataDir, 'Local State'),\n join(userDataDir, 'Local State'),\n sourceProfile.chromeProfileDirectory,\n )\n await copyProfileTree(sourceProfile.chromeProfilePath, join(userDataDir, 'Default'))\n\n const now = new Date().toISOString()\n const manifest: ImportedBrowserProfileManifest = {\n layoutVersion: 1,\n name,\n profileRoot,\n userDataDir,\n browserExecutablePath: options.browserExecutablePath?.trim() || defaultChromeExecutablePath() || null,\n sourceUserDataDir,\n sourceProfileDirectory: sourceProfile.chromeProfileDirectory,\n sourceProfilePath: sourceProfile.chromeProfilePath,\n email: sourceProfile.email,\n displayName: sourceProfile.displayName,\n createdAt: existingManifest?.createdAt ?? now,\n updatedAt: now,\n copyMode: 'chrome-profile-clone',\n }\n await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`)\n\n return {\n profile: manifest,\n sourceProfile,\n excludedNames: EXCLUDED_PROFILE_NAMES,\n }\n}\n\nexport async function loadImportedBrowserProfile(\n name = process.env.MCP_SCRAPER_BROWSER_PROFILE?.trim() || 'default',\n outputDir = defaultImportedBrowserProfilesDir(),\n): Promise<ImportedBrowserProfileManifest> {\n const profileName = importedProfileName(name)\n const manifestPath = importedProfileManifestPath(profileName, outputDir)\n const manifest = await readExistingManifest(manifestPath)\n if (!manifest) {\n throw new Error(\n `Imported browser profile \"${profileName}\" was not found. Run: mcp-scraper-cli browser import-chrome --name ${profileName}`,\n )\n }\n return manifest\n}\n\nexport async function syncImportedChromeProfile(\n name: string,\n options: Pick<ImportChromeProfileOptions, 'outputDir' | 'browserExecutablePath'> = {},\n): Promise<ImportChromeProfileResult> {\n const outputDir = options.outputDir?.trim() || defaultImportedBrowserProfilesDir()\n const manifest = await loadImportedBrowserProfile(name, outputDir)\n return importChromeProfile({\n name: manifest.name,\n sourceUserDataDir: manifest.sourceUserDataDir,\n chromeProfileDirectory: manifest.sourceProfileDirectory,\n outputDir,\n overwrite: true,\n browserExecutablePath: options.browserExecutablePath ?? manifest.browserExecutablePath ?? undefined,\n })\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,YAAY;AAUd,SAAS,2BAAmC;AACjD,MAAI,QAAQ,aAAa,SAAU,QAAO,KAAK,QAAQ,GAAG,WAAW,uBAAuB,UAAU,QAAQ;AAC9G,MAAI,QAAQ,aAAa,SAAS;AAChC,WAAO,KAAK,QAAQ,IAAI,gBAAgB,KAAK,QAAQ,GAAG,WAAW,OAAO,GAAG,UAAU,UAAU,WAAW;AAAA,EAC9G;AACA,SAAO,KAAK,QAAQ,IAAI,mBAAmB,KAAK,QAAQ,GAAG,SAAS,GAAG,eAAe;AACxF;AAEO,SAAS,6BAA6B,OAAuB;AAClE,SAAO,MACJ,KAAK,EACL,YAAY,EACZ,QAAQ,MAAM,GAAG,EACjB,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE,EACtB,MAAM,GAAG,EAAE,KAAK;AACrB;AAEA,eAAsB,wBACpB,cAAc,yBAAyB,GACvC,aAC+B;AAC/B,QAAM,MAAM,MAAM,SAAS,KAAK,aAAa,aAAa,GAAG,MAAM;AACnE,QAAM,aAAa,KAAK,MAAM,GAAG;AAUjC,QAAM,SAAS,aAAa,KAAK,E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A,uBAAuB,QAAQ,uBAAuB,KAAK,KAAK,4BAA4B,KAAK;AAAA,IACjG;AAAA,IACA,wBAAwB,cAAc;AAAA,IACtC,mBAAmB,cAAc;AAAA,IACjC,OAAO,cAAc;AAAA,IACrB,aAAa,cAAc;AAAA,IAC3B,WAAW,kBAAkB,aAAa;AAAA,IAC1C,WAAW;AAAA,IACX,UAAU;AAAA,EACZ;AACA,QAAM,UAAU,cAAc,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAAA,CAAI;AAEtE,SAAO;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA,eAAe;AAAA,EACjB;AACF;AAEA,eAAsB,2BACpB,OAAO,QAAQ,IAAI,6BAA6B,KAAK,KAAK,WAC1D,YAAY,kCAAkC,GACL;AACzC,QAAM,cAAc,oBAAoB,IAAI;AAC5C,QAAM,eAAe,4BAA4B,aAAa,SAAS;AACvE,QAAM,WAAW,MAAM,qBAAqB,YAAY;AACxD,MAAI,CAAC,UAAU;AACb,UAAM,IAAI;AAAA,MACR,6BAA6B,WAAW,sEAAsE,WAAW;AAAA,IAC3H;AAAA,EACF;AACA,SAAO;AACT;AAEA,eAAsB,0BACpB,MACA,UAAmF,CAAC,GAChD;AACpC,QAAM,YAAY,QAAQ,WAAW,KAAK,KAAK,kCAAkC;AACjF,QAAM,WAAW,MAAM,2BAA2B,MAAM,SAAS;AACjE,SAAO,oBAAoB;AAAA,IACzB,MAAM,SAAS;AAAA,IACf,mBAAmB,SAAS;AAAA,IAC5B,wBAAwB,SAAS;AAAA,IACjC;AAAA,IACA,WAAW;AAAA,IACX,uBAAuB,QAAQ,yBAAyB,SAAS,yBAAyB;AAAA,EAC5F,CAAC;AACH;","names":["readFile","homedir","join","join","homedir","readFile"]}
@@ -1,7 +0,0 @@
1
- // src/version.ts
2
- var PACKAGE_VERSION = "0.3.5";
3
-
4
- export {
5
- PACKAGE_VERSION
6
- };
7
- //# sourceMappingURL=chunk-GHBU5SGQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/version.ts"],"sourcesContent":["export const PACKAGE_VERSION = '0.3.5'\n"],"mappings":";AAAO,IAAM,kBAAkB;","names":[]}