@mkterswingman/5mghost-yonder 0.0.3 → 0.0.5

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.
@@ -1 +1,9 @@
1
+ export declare function canOpenBrowserForEnv(input: {
2
+ platform: NodeJS.Platform;
3
+ env: NodeJS.ProcessEnv;
4
+ stdinIsTTY: boolean;
5
+ }): boolean;
6
+ export declare function getNoBrowserSessionNotice(): string;
7
+ export declare function getNoBrowserPatHint(authUrl: string): string[];
8
+ export declare function getCookieSetupDeferredHint(): string[];
1
9
  export declare function runSetup(): Promise<void>;
package/dist/cli/setup.js CHANGED
@@ -40,27 +40,28 @@ function tryRegisterMcp(cmd, label) {
40
40
  return false;
41
41
  }
42
42
  }
43
- /**
44
- * Detect if we can open a browser (local machine with display).
45
- * Cloud environments (SSH, Docker, cloud IDE) typically can't.
46
- */
47
- function canOpenBrowser() {
48
- // Explicit override
49
- if (process.env.YT_MCP_NO_BROWSER === "1")
50
- return false;
51
- // Check for display (Linux/macOS GUI)
52
- if (process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) {
43
+ export function canOpenBrowserForEnv(input) {
44
+ if (input.env.YT_MCP_NO_BROWSER === "1") {
53
45
  return false;
54
46
  }
55
- // Check if running in common cloud/container environments
56
- if (process.env.CODESPACES || process.env.GITPOD_WORKSPACE_ID || process.env.CLOUD_SHELL) {
47
+ if (input.env.CODESPACES || input.env.GITPOD_WORKSPACE_ID || input.env.CLOUD_SHELL) {
57
48
  return false;
58
49
  }
59
- // Check if we have a TTY (interactive terminal) — headless environments often don't
60
- if (!process.stdin.isTTY) {
61
- return false;
50
+ if (input.platform === "linux") {
51
+ return Boolean(input.env.DISPLAY || input.env.WAYLAND_DISPLAY);
62
52
  }
63
- return true;
53
+ // Why: desktop Windows/macOS sessions can launch browsers even when the host app pipes stdio.
54
+ if (input.platform === "win32" || input.platform === "darwin") {
55
+ return true;
56
+ }
57
+ return input.stdinIsTTY;
58
+ }
59
+ function canOpenBrowser() {
60
+ return canOpenBrowserForEnv({
61
+ platform: process.platform,
62
+ env: process.env,
63
+ stdinIsTTY: Boolean(process.stdin.isTTY),
64
+ });
64
65
  }
65
66
  function openUrl(url) {
66
67
  try {
@@ -85,12 +86,29 @@ function prompt(question) {
85
86
  });
86
87
  });
87
88
  }
89
+ export function getNoBrowserSessionNotice() {
90
+ return " ℹ️ 当前安装会话无法自动拉起浏览器 — 使用 PAT 模式\n";
91
+ }
92
+ export function getNoBrowserPatHint(authUrl) {
93
+ return [
94
+ " 🔗 请在当前这台运行安装器的桌面环境浏览器中打开此链接获取 PAT token:",
95
+ ` ${authUrl}/pat/login`,
96
+ "",
97
+ " ⚠️ 如果你在云桌面上运行,请在云桌面的浏览器中完成登录,不要在本地电脑打开。"
98
+ ];
99
+ }
100
+ export function getCookieSetupDeferredHint() {
101
+ return [
102
+ " ⏭️ Skipped (current session can't open a browser automatically — subtitle verification deferred)",
103
+ " 💡 在当前这台机器或云桌面的交互终端里运行:npx @mkterswingman/5mghost-yonder setup-cookies"
104
+ ];
105
+ }
88
106
  export async function runSetup() {
89
107
  console.log("\n🚀 yt-mcp setup\n");
90
108
  ensureConfigDir();
91
109
  const hasBrowser = canOpenBrowser();
92
110
  if (!hasBrowser) {
93
- console.log(" ℹ️ Cloud/headless environment detected — using PAT mode\n");
111
+ console.log(getNoBrowserSessionNotice());
94
112
  }
95
113
  // ── Step 1: Runtime check ──
96
114
  console.log("Step 1/5: Checking required runtimes...");
@@ -184,10 +202,9 @@ export async function runSetup() {
184
202
  }
185
203
  else {
186
204
  // Cloud/headless — can't open browser, PAT only
187
- const patUrl = `${config.auth_url}/pat/login`;
188
- console.log(` 🔗 请在本地电脑浏览器中打开此链接获取 PAT token:`);
189
- console.log(` ${patUrl}`);
190
- console.log("");
205
+ for (const line of getNoBrowserPatHint(config.auth_url)) {
206
+ console.log(line);
207
+ }
191
208
  const patInput = await prompt(" 粘贴你的 PAT token (pat_xxx), 或直接回车跳过: ");
192
209
  if (patInput) {
193
210
  await tokenManager.savePAT(patInput);
@@ -201,8 +218,9 @@ export async function runSetup() {
201
218
  // ── Step 4: YouTube Cookies ──
202
219
  console.log("Step 4/5: YouTube cookies...");
203
220
  if (!hasBrowser) {
204
- console.log(" ⏭️ Skipped (no browser subtitle features unavailable in cloud)");
205
- console.log(" 💡 Run on your local machine: npx @mkterswingman/5mghost-yonder setup-cookies");
221
+ for (const line of getCookieSetupDeferredHint()) {
222
+ console.log(line);
223
+ }
206
224
  }
207
225
  else if (hasSIDCookies(PATHS.cookiesTxt)) {
208
226
  console.log(" ✅ Cookies already present");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mkterswingman/5mghost-yonder",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Internal MCP client with local data tools and remote API proxy",
5
5
  "type": "module",
6
6
  "bin": {