@mkterswingman/5mghost-yonder 0.0.26 → 0.0.27
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/package.json +1 -1
- package/dist/auth/oauthFlow.d.ts +0 -9
- package/dist/auth/oauthFlow.js +0 -151
- package/dist/auth/sharedAuth.d.ts +0 -10
- package/dist/auth/sharedAuth.js +0 -31
- package/dist/auth/tokenManager.d.ts +0 -18
- package/dist/auth/tokenManager.js +0 -92
- package/dist/cli/check.d.ts +0 -4
- package/dist/cli/check.js +0 -90
- package/dist/cli/index.d.ts +0 -18
- package/dist/cli/index.js +0 -166
- package/dist/cli/installSkills.d.ts +0 -1
- package/dist/cli/installSkills.js +0 -39
- package/dist/cli/runtime.d.ts +0 -9
- package/dist/cli/runtime.js +0 -35
- package/dist/cli/serve.d.ts +0 -1
- package/dist/cli/serve.js +0 -26
- package/dist/cli/setup.d.ts +0 -33
- package/dist/cli/setup.js +0 -450
- package/dist/cli/setupCookies.d.ts +0 -88
- package/dist/cli/setupCookies.js +0 -431
- package/dist/cli/smoke.d.ts +0 -27
- package/dist/cli/smoke.js +0 -108
- package/dist/cli/uninstall.d.ts +0 -16
- package/dist/cli/uninstall.js +0 -99
- package/dist/download/downloader.d.ts +0 -67
- package/dist/download/downloader.js +0 -309
- package/dist/download/jobManager.d.ts +0 -22
- package/dist/download/jobManager.js +0 -211
- package/dist/download/types.d.ts +0 -44
- package/dist/download/types.js +0 -1
- package/dist/runtime/ffmpegRuntime.d.ts +0 -13
- package/dist/runtime/ffmpegRuntime.js +0 -51
- package/dist/runtime/installers.d.ts +0 -12
- package/dist/runtime/installers.js +0 -45
- package/dist/runtime/manifest.d.ts +0 -18
- package/dist/runtime/manifest.js +0 -43
- package/dist/runtime/playwrightRuntime.d.ts +0 -17
- package/dist/runtime/playwrightRuntime.js +0 -49
- package/dist/runtime/systemDeps.d.ts +0 -3
- package/dist/runtime/systemDeps.js +0 -30
- package/dist/runtime/ytdlpRuntime.d.ts +0 -14
- package/dist/runtime/ytdlpRuntime.js +0 -58
- package/dist/server.d.ts +0 -23
- package/dist/server.js +0 -81
- package/dist/tools/downloads.d.ts +0 -11
- package/dist/tools/downloads.js +0 -220
- package/dist/tools/remote.d.ts +0 -4
- package/dist/tools/remote.js +0 -239
- package/dist/tools/subtitles.d.ts +0 -29
- package/dist/tools/subtitles.js +0 -713
- package/dist/utils/browserLaunch.d.ts +0 -5
- package/dist/utils/browserLaunch.js +0 -22
- package/dist/utils/browserProfileImport.d.ts +0 -49
- package/dist/utils/browserProfileImport.js +0 -163
- package/dist/utils/codexInternal.d.ts +0 -9
- package/dist/utils/codexInternal.js +0 -60
- package/dist/utils/config.d.ts +0 -53
- package/dist/utils/config.js +0 -77
- package/dist/utils/cookieRefresh.d.ts +0 -18
- package/dist/utils/cookieRefresh.js +0 -70
- package/dist/utils/cookies.d.ts +0 -18
- package/dist/utils/cookies.js +0 -100
- package/dist/utils/ffmpeg.d.ts +0 -5
- package/dist/utils/ffmpeg.js +0 -16
- package/dist/utils/ffmpegPath.d.ts +0 -8
- package/dist/utils/ffmpegPath.js +0 -21
- package/dist/utils/formatters.d.ts +0 -4
- package/dist/utils/formatters.js +0 -42
- package/dist/utils/launcher.d.ts +0 -12
- package/dist/utils/launcher.js +0 -90
- package/dist/utils/mcpRegistration.d.ts +0 -7
- package/dist/utils/mcpRegistration.js +0 -23
- package/dist/utils/mediaPaths.d.ts +0 -7
- package/dist/utils/mediaPaths.js +0 -10
- package/dist/utils/openClaw.d.ts +0 -18
- package/dist/utils/openClaw.js +0 -82
- package/dist/utils/skills.d.ts +0 -16
- package/dist/utils/skills.js +0 -56
- package/dist/utils/videoInput.d.ts +0 -5
- package/dist/utils/videoInput.js +0 -58
- package/dist/utils/videoMetadata.d.ts +0 -11
- package/dist/utils/videoMetadata.js +0 -1
- package/dist/utils/ytdlp.d.ts +0 -28
- package/dist/utils/ytdlp.js +0 -205
- package/dist/utils/ytdlpFailures.d.ts +0 -3
- package/dist/utils/ytdlpFailures.js +0 -27
- package/dist/utils/ytdlpPath.d.ts +0 -33
- package/dist/utils/ytdlpPath.js +0 -77
- package/dist/utils/ytdlpProgress.d.ts +0 -13
- package/dist/utils/ytdlpProgress.js +0 -77
- package/dist/utils/ytdlpScheduler.d.ts +0 -25
- package/dist/utils/ytdlpScheduler.js +0 -78
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { execFileSync, execSync } from "node:child_process";
|
|
2
|
-
import { getFfmpegPath, getRuntimeFfmpegPath } from "../utils/ffmpegPath.js";
|
|
3
|
-
import { getFfmpegInstallHint } from "./systemDeps.js";
|
|
4
|
-
function getFfmpegVersion(binPath) {
|
|
5
|
-
try {
|
|
6
|
-
const version = execFileSync(binPath, ["-version"], {
|
|
7
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
8
|
-
timeout: 30_000,
|
|
9
|
-
}).toString("utf8");
|
|
10
|
-
const firstLine = version.split("\n")[0]?.trim();
|
|
11
|
-
return firstLine?.replace(/^ffmpeg version\s+/, "") ?? null;
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export function checkFfmpegRuntime() {
|
|
18
|
-
const resolved = getFfmpegPath();
|
|
19
|
-
const version = getFfmpegVersion(resolved);
|
|
20
|
-
if (!version) {
|
|
21
|
-
return {
|
|
22
|
-
name: "ffmpeg",
|
|
23
|
-
status: "missing",
|
|
24
|
-
version: null,
|
|
25
|
-
source: "system",
|
|
26
|
-
installed_at: null,
|
|
27
|
-
binary_path: null,
|
|
28
|
-
message: getFfmpegInstallHint(),
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const source = process.env.FFMPEG_PATH
|
|
32
|
-
? "env"
|
|
33
|
-
: resolved === getRuntimeFfmpegPath()
|
|
34
|
-
? "runtime"
|
|
35
|
-
: "system";
|
|
36
|
-
return {
|
|
37
|
-
name: "ffmpeg",
|
|
38
|
-
status: "installed",
|
|
39
|
-
version,
|
|
40
|
-
source,
|
|
41
|
-
installed_at: null,
|
|
42
|
-
binary_path: resolved,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export async function installFfmpegRuntime() {
|
|
46
|
-
execSync(getFfmpegInstallHint(), { stdio: "inherit" });
|
|
47
|
-
return checkFfmpegRuntime();
|
|
48
|
-
}
|
|
49
|
-
export async function updateFfmpegRuntime() {
|
|
50
|
-
return installFfmpegRuntime();
|
|
51
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type RuntimeComponentName, type RuntimeComponentState } from "./manifest.js";
|
|
2
|
-
export interface RuntimeComponentSummary extends RuntimeComponentState {
|
|
3
|
-
name: RuntimeComponentName;
|
|
4
|
-
message?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface RuntimeSummary {
|
|
7
|
-
action: "check" | "install" | "update";
|
|
8
|
-
components: RuntimeComponentSummary[];
|
|
9
|
-
}
|
|
10
|
-
export declare function checkAll(): Promise<RuntimeSummary>;
|
|
11
|
-
export declare function installAll(): Promise<RuntimeSummary>;
|
|
12
|
-
export declare function updateAll(): Promise<RuntimeSummary>;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { checkPlaywrightRuntime, installPlaywrightRuntime, updatePlaywrightRuntime, } from "./playwrightRuntime.js";
|
|
2
|
-
import { checkYtDlpRuntime, installYtDlpRuntime, updateYtDlpRuntime } from "./ytdlpRuntime.js";
|
|
3
|
-
import { checkFfmpegRuntime, installFfmpegRuntime, updateFfmpegRuntime } from "./ffmpegRuntime.js";
|
|
4
|
-
import { createEmptyRuntimeManifest, loadRuntimeManifest, saveRuntimeManifest, updateRuntimeComponent, } from "./manifest.js";
|
|
5
|
-
import { PATHS } from "../utils/config.js";
|
|
6
|
-
function persistComponents(components) {
|
|
7
|
-
let manifest = loadRuntimeManifest(PATHS.runtimeManifestJson) ?? createEmptyRuntimeManifest();
|
|
8
|
-
for (const component of components) {
|
|
9
|
-
manifest = updateRuntimeComponent(manifest, component.name, {
|
|
10
|
-
status: component.status,
|
|
11
|
-
version: component.version,
|
|
12
|
-
source: component.source,
|
|
13
|
-
installed_at: component.installed_at,
|
|
14
|
-
binary_path: component.binary_path,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
saveRuntimeManifest(PATHS.runtimeManifestJson, manifest);
|
|
18
|
-
}
|
|
19
|
-
export async function checkAll() {
|
|
20
|
-
const components = [
|
|
21
|
-
await checkPlaywrightRuntime(),
|
|
22
|
-
checkYtDlpRuntime(),
|
|
23
|
-
checkFfmpegRuntime(),
|
|
24
|
-
];
|
|
25
|
-
persistComponents(components);
|
|
26
|
-
return { action: "check", components };
|
|
27
|
-
}
|
|
28
|
-
export async function installAll() {
|
|
29
|
-
const components = [
|
|
30
|
-
await installPlaywrightRuntime(),
|
|
31
|
-
await installYtDlpRuntime(),
|
|
32
|
-
await installFfmpegRuntime(),
|
|
33
|
-
];
|
|
34
|
-
persistComponents(components);
|
|
35
|
-
return { action: "install", components };
|
|
36
|
-
}
|
|
37
|
-
export async function updateAll() {
|
|
38
|
-
const components = [
|
|
39
|
-
await updatePlaywrightRuntime(),
|
|
40
|
-
await updateYtDlpRuntime(),
|
|
41
|
-
await updateFfmpegRuntime(),
|
|
42
|
-
];
|
|
43
|
-
persistComponents(components);
|
|
44
|
-
return { action: "update", components };
|
|
45
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type RuntimeComponentName = "playwright" | "yt-dlp" | "ffmpeg";
|
|
2
|
-
export type RuntimeComponentStatus = "missing" | "installed";
|
|
3
|
-
export type RuntimeComponentSource = "runtime" | "system" | "env";
|
|
4
|
-
export interface RuntimeComponentState {
|
|
5
|
-
status: RuntimeComponentStatus;
|
|
6
|
-
version: string | null;
|
|
7
|
-
source: RuntimeComponentSource;
|
|
8
|
-
installed_at: string | null;
|
|
9
|
-
binary_path: string | null;
|
|
10
|
-
}
|
|
11
|
-
export interface RuntimeManifest {
|
|
12
|
-
schema_version: 1;
|
|
13
|
-
components: Partial<Record<RuntimeComponentName, RuntimeComponentState>>;
|
|
14
|
-
}
|
|
15
|
-
export declare function createEmptyRuntimeManifest(): RuntimeManifest;
|
|
16
|
-
export declare function loadRuntimeManifest(manifestPath?: string): RuntimeManifest;
|
|
17
|
-
export declare function saveRuntimeManifest(manifestPath: string | undefined, manifest: RuntimeManifest): void;
|
|
18
|
-
export declare function updateRuntimeComponent(manifest: RuntimeManifest, name: RuntimeComponentName, state: RuntimeComponentState): RuntimeManifest;
|
package/dist/runtime/manifest.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { dirname } from "node:path";
|
|
3
|
-
import { PATHS } from "../utils/config.js";
|
|
4
|
-
export function createEmptyRuntimeManifest() {
|
|
5
|
-
return {
|
|
6
|
-
schema_version: 1,
|
|
7
|
-
components: {},
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export function loadRuntimeManifest(manifestPath = PATHS.runtimeManifestJson) {
|
|
11
|
-
if (!existsSync(manifestPath)) {
|
|
12
|
-
return createEmptyRuntimeManifest();
|
|
13
|
-
}
|
|
14
|
-
try {
|
|
15
|
-
const raw = readFileSync(manifestPath, "utf8");
|
|
16
|
-
const parsed = JSON.parse(raw);
|
|
17
|
-
if (parsed.schema_version !== 1 || parsed.components == null || typeof parsed.components !== "object") {
|
|
18
|
-
return createEmptyRuntimeManifest();
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
schema_version: 1,
|
|
22
|
-
components: parsed.components,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
return createEmptyRuntimeManifest();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export function saveRuntimeManifest(manifestPath = PATHS.runtimeManifestJson, manifest) {
|
|
30
|
-
mkdirSync(dirname(manifestPath), { recursive: true });
|
|
31
|
-
const tempPath = `${manifestPath}.tmp`;
|
|
32
|
-
writeFileSync(tempPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
|
33
|
-
renameSync(tempPath, manifestPath);
|
|
34
|
-
}
|
|
35
|
-
export function updateRuntimeComponent(manifest, name, state) {
|
|
36
|
-
return {
|
|
37
|
-
schema_version: 1,
|
|
38
|
-
components: {
|
|
39
|
-
...manifest.components,
|
|
40
|
-
[name]: state,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { RuntimeComponentState } from "./manifest.js";
|
|
2
|
-
export declare function getPlaywrightInstallInvocation(): {
|
|
3
|
-
command: string;
|
|
4
|
-
args: string[];
|
|
5
|
-
};
|
|
6
|
-
export declare function checkPlaywrightRuntime(): Promise<RuntimeComponentState & {
|
|
7
|
-
name: "playwright";
|
|
8
|
-
message?: string;
|
|
9
|
-
}>;
|
|
10
|
-
export declare function installPlaywrightRuntime(): Promise<RuntimeComponentState & {
|
|
11
|
-
name: "playwright";
|
|
12
|
-
message?: string;
|
|
13
|
-
}>;
|
|
14
|
-
export declare function updatePlaywrightRuntime(): Promise<RuntimeComponentState & {
|
|
15
|
-
name: "playwright";
|
|
16
|
-
message?: string;
|
|
17
|
-
}>;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { execFileSync } from "node:child_process";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { createRequire } from "node:module";
|
|
5
|
-
const require = createRequire(import.meta.url);
|
|
6
|
-
export function getPlaywrightInstallInvocation() {
|
|
7
|
-
const packageJsonPath = require.resolve("playwright/package.json");
|
|
8
|
-
const cliPath = join(dirname(packageJsonPath), "cli.js");
|
|
9
|
-
return {
|
|
10
|
-
command: process.execPath,
|
|
11
|
-
args: [cliPath, "install", "chromium"],
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export async function checkPlaywrightRuntime() {
|
|
15
|
-
try {
|
|
16
|
-
const { chromium } = await import("playwright");
|
|
17
|
-
const executablePath = chromium.executablePath();
|
|
18
|
-
if (existsSync(executablePath)) {
|
|
19
|
-
return {
|
|
20
|
-
name: "playwright",
|
|
21
|
-
status: "installed",
|
|
22
|
-
version: executablePath.split("/").pop() ?? "chromium",
|
|
23
|
-
source: "runtime",
|
|
24
|
-
installed_at: null,
|
|
25
|
-
binary_path: executablePath,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
// fall through to missing state
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
name: "playwright",
|
|
34
|
-
status: "missing",
|
|
35
|
-
version: null,
|
|
36
|
-
source: "runtime",
|
|
37
|
-
installed_at: null,
|
|
38
|
-
binary_path: null,
|
|
39
|
-
message: "yt-mcp runtime install",
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export async function installPlaywrightRuntime() {
|
|
43
|
-
const invocation = getPlaywrightInstallInvocation();
|
|
44
|
-
execFileSync(invocation.command, invocation.args, { stdio: "inherit" });
|
|
45
|
-
return checkPlaywrightRuntime();
|
|
46
|
-
}
|
|
47
|
-
export async function updatePlaywrightRuntime() {
|
|
48
|
-
return installPlaywrightRuntime();
|
|
49
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
2
|
-
export function hasCommand(name) {
|
|
3
|
-
try {
|
|
4
|
-
execSync(`${name} --version`, { stdio: "ignore" });
|
|
5
|
-
return true;
|
|
6
|
-
}
|
|
7
|
-
catch {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export function getFfmpegInstallHint(platform = process.platform) {
|
|
12
|
-
switch (platform) {
|
|
13
|
-
case "darwin":
|
|
14
|
-
return "brew install ffmpeg";
|
|
15
|
-
case "win32":
|
|
16
|
-
return "winget install Gyan.FFmpeg";
|
|
17
|
-
default:
|
|
18
|
-
return "sudo apt update && sudo apt install -y ffmpeg";
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export function getNodeInstallHint(platform = process.platform) {
|
|
22
|
-
switch (platform) {
|
|
23
|
-
case "darwin":
|
|
24
|
-
return "brew install node";
|
|
25
|
-
case "win32":
|
|
26
|
-
return "winget install OpenJS.NodeJS.LTS";
|
|
27
|
-
default:
|
|
28
|
-
return "sudo apt update && sudo apt install -y nodejs npm";
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { RuntimeComponentState } from "./manifest.js";
|
|
2
|
-
export declare function buildYtDlpInstallCommand(): string;
|
|
3
|
-
export declare function checkYtDlpRuntime(): RuntimeComponentState & {
|
|
4
|
-
name: "yt-dlp";
|
|
5
|
-
message?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function installYtDlpRuntime(): Promise<RuntimeComponentState & {
|
|
8
|
-
name: "yt-dlp";
|
|
9
|
-
message?: string;
|
|
10
|
-
}>;
|
|
11
|
-
export declare function updateYtDlpRuntime(): Promise<RuntimeComponentState & {
|
|
12
|
-
name: "yt-dlp";
|
|
13
|
-
message?: string;
|
|
14
|
-
}>;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { PATHS } from "../utils/config.js";
|
|
5
|
-
import { getRuntimeYtDlpPath, getYtDlpVersion } from "../utils/ytdlpPath.js";
|
|
6
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const pkgRoot = join(__dirname, "..", "..");
|
|
8
|
-
export function buildYtDlpInstallCommand() {
|
|
9
|
-
return "node scripts/download-ytdlp.mjs";
|
|
10
|
-
}
|
|
11
|
-
export function checkYtDlpRuntime() {
|
|
12
|
-
const runtimePath = getRuntimeYtDlpPath();
|
|
13
|
-
const runtimeInfo = getYtDlpVersion(runtimePath);
|
|
14
|
-
if (runtimeInfo) {
|
|
15
|
-
return {
|
|
16
|
-
name: "yt-dlp",
|
|
17
|
-
status: "installed",
|
|
18
|
-
version: runtimeInfo.version,
|
|
19
|
-
source: runtimeInfo.source,
|
|
20
|
-
installed_at: null,
|
|
21
|
-
binary_path: runtimePath,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
const systemInfo = getYtDlpVersion("yt-dlp");
|
|
25
|
-
if (systemInfo) {
|
|
26
|
-
return {
|
|
27
|
-
name: "yt-dlp",
|
|
28
|
-
status: "installed",
|
|
29
|
-
version: systemInfo.version,
|
|
30
|
-
source: systemInfo.source,
|
|
31
|
-
installed_at: null,
|
|
32
|
-
binary_path: "yt-dlp",
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
name: "yt-dlp",
|
|
37
|
-
status: "missing",
|
|
38
|
-
version: null,
|
|
39
|
-
source: "runtime",
|
|
40
|
-
installed_at: null,
|
|
41
|
-
binary_path: null,
|
|
42
|
-
message: "yt-mcp runtime install",
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export async function installYtDlpRuntime() {
|
|
46
|
-
execSync(buildYtDlpInstallCommand(), {
|
|
47
|
-
cwd: pkgRoot,
|
|
48
|
-
stdio: "inherit",
|
|
49
|
-
env: {
|
|
50
|
-
...process.env,
|
|
51
|
-
YT_MCP_BINARY_DIR: PATHS.runtimeBinDir,
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
return checkYtDlpRuntime();
|
|
55
|
-
}
|
|
56
|
-
export async function updateYtDlpRuntime() {
|
|
57
|
-
return installYtDlpRuntime();
|
|
58
|
-
}
|
package/dist/server.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type { YtMcpConfig } from "./utils/config.js";
|
|
3
|
-
import type { TokenManager } from "./auth/tokenManager.js";
|
|
4
|
-
import { DownloadJobManager } from "./download/jobManager.js";
|
|
5
|
-
import type { DownloadToolDeps } from "./tools/downloads.js";
|
|
6
|
-
/**
|
|
7
|
-
* Creates the MCP server.
|
|
8
|
-
*
|
|
9
|
-
* Authentication flow:
|
|
10
|
-
*
|
|
11
|
-
* serve startup
|
|
12
|
-
* │
|
|
13
|
-
* ├─ YT_MCP_TOKEN env var? ──▶ PAT mode ──▶ full server (20 tools)
|
|
14
|
-
* │
|
|
15
|
-
* ├─ auth.json exists? ──▶ JWT mode ──▶ full server (20 tools)
|
|
16
|
-
* │
|
|
17
|
-
* └─ no token? ──▶ register "setup_required" tool only
|
|
18
|
-
* │
|
|
19
|
-
* └─ AI calls setup_required ──▶ returns:
|
|
20
|
-
* ├─ PAT login URL (user clicks to get token)
|
|
21
|
-
* └─ setup command (for full OAuth + cookies)
|
|
22
|
-
*/
|
|
23
|
-
export declare function createServer(config: YtMcpConfig, tokenManager: TokenManager, downloadJobManager?: DownloadJobManager, downloadToolDeps?: DownloadToolDeps): Promise<McpServer>;
|
package/dist/server.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { DownloadJobManager } from "./download/jobManager.js";
|
|
3
|
-
import { registerSubtitleTools } from "./tools/subtitles.js";
|
|
4
|
-
import { registerDownloadTools } from "./tools/downloads.js";
|
|
5
|
-
import { registerRemoteTools } from "./tools/remote.js";
|
|
6
|
-
/**
|
|
7
|
-
* Creates the MCP server.
|
|
8
|
-
*
|
|
9
|
-
* Authentication flow:
|
|
10
|
-
*
|
|
11
|
-
* serve startup
|
|
12
|
-
* │
|
|
13
|
-
* ├─ YT_MCP_TOKEN env var? ──▶ PAT mode ──▶ full server (20 tools)
|
|
14
|
-
* │
|
|
15
|
-
* ├─ auth.json exists? ──▶ JWT mode ──▶ full server (20 tools)
|
|
16
|
-
* │
|
|
17
|
-
* └─ no token? ──▶ register "setup_required" tool only
|
|
18
|
-
* │
|
|
19
|
-
* └─ AI calls setup_required ──▶ returns:
|
|
20
|
-
* ├─ PAT login URL (user clicks to get token)
|
|
21
|
-
* └─ setup command (for full OAuth + cookies)
|
|
22
|
-
*/
|
|
23
|
-
export async function createServer(config, tokenManager, downloadJobManager = new DownloadJobManager(), downloadToolDeps = {}) {
|
|
24
|
-
const server = new McpServer({
|
|
25
|
-
name: "@mkterswingman/yt-mcp",
|
|
26
|
-
version: "0.1.0",
|
|
27
|
-
});
|
|
28
|
-
const token = await tokenManager.getValidToken();
|
|
29
|
-
if (!token) {
|
|
30
|
-
// Not authenticated — register guidance tool only
|
|
31
|
-
server.registerTool("setup_required", {
|
|
32
|
-
description: "yt-mcp is not configured yet. Call this to get setup instructions for the user.",
|
|
33
|
-
}, async () => {
|
|
34
|
-
// Try to auto-open PAT login page in browser
|
|
35
|
-
const patUrl = `${config.auth_url}/pat/login`;
|
|
36
|
-
let opened = false;
|
|
37
|
-
try {
|
|
38
|
-
const { execFile } = await import("node:child_process");
|
|
39
|
-
const command = buildBrowserOpenCommand(patUrl);
|
|
40
|
-
execFile(command.file, command.args);
|
|
41
|
-
opened = true;
|
|
42
|
-
}
|
|
43
|
-
catch { /* can't open browser, fall through */ }
|
|
44
|
-
return {
|
|
45
|
-
content: [
|
|
46
|
-
{
|
|
47
|
-
type: "text",
|
|
48
|
-
text: [
|
|
49
|
-
"🔧 **yt-mcp 需要登录才能使用**",
|
|
50
|
-
"",
|
|
51
|
-
opened
|
|
52
|
-
? `✅ 已自动打开登录页面: ${patUrl}`
|
|
53
|
-
: `请在浏览器中打开: ${patUrl}`,
|
|
54
|
-
"",
|
|
55
|
-
"⚠️ **云桌面用户注意:** 如果你在云桌面(如 Win 云桌面版 OpenClaw)上运行,",
|
|
56
|
-
"请在 **云桌面的浏览器** 中完成登录,不要在本地电脑打开链接(回调地址是云桌面的 localhost)。",
|
|
57
|
-
"",
|
|
58
|
-
"**登录步骤:**",
|
|
59
|
-
"1. 用 Google 账号登录(首次需要邀请码,已有 x-mcp 账号可跳过)",
|
|
60
|
-
"2. 生成 PAT token(和 x-mcp 通用,已有可跳过)",
|
|
61
|
-
"3. 将 token 配置到 MCP:",
|
|
62
|
-
' 在 MCP 配置中添加 `"env": { "YT_MCP_TOKEN": "pat_xxx" }`',
|
|
63
|
-
"4. 重启 AI 客户端",
|
|
64
|
-
"",
|
|
65
|
-
"**完整设置(含字幕功能):**",
|
|
66
|
-
"在终端运行:`npx @mkterswingman/5mghost-yonder setup`",
|
|
67
|
-
"这会同时设置 OAuth 登录和 YouTube cookie(字幕下载需要)",
|
|
68
|
-
].join("\n"),
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
return server;
|
|
74
|
-
}
|
|
75
|
-
// Authenticated — register all tools
|
|
76
|
-
registerSubtitleTools(server, config, tokenManager);
|
|
77
|
-
registerDownloadTools(server, config, tokenManager, downloadJobManager, downloadToolDeps);
|
|
78
|
-
registerRemoteTools(server, config, tokenManager);
|
|
79
|
-
return server;
|
|
80
|
-
}
|
|
81
|
-
import { buildBrowserOpenCommand } from "./utils/browserLaunch.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type { YtMcpConfig } from "../utils/config.js";
|
|
3
|
-
import type { TokenManager } from "../auth/tokenManager.js";
|
|
4
|
-
import { downloadOneItem } from "../download/downloader.js";
|
|
5
|
-
import type { DownloadJobManager } from "../download/jobManager.js";
|
|
6
|
-
export interface DownloadToolDeps {
|
|
7
|
-
executeItem?: typeof downloadOneItem;
|
|
8
|
-
mediaRootDir?: string;
|
|
9
|
-
nowDate?: () => string;
|
|
10
|
-
}
|
|
11
|
-
export declare function registerDownloadTools(server: McpServer, config: YtMcpConfig, tokenManager: TokenManager, manager: DownloadJobManager, deps?: DownloadToolDeps): void;
|