@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,8 +0,0 @@
|
|
|
1
|
-
export interface ResolveFfmpegPathOptions {
|
|
2
|
-
envPath?: string | null;
|
|
3
|
-
runtimePath?: string;
|
|
4
|
-
runtimeExists?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare function getRuntimeFfmpegPath(runtimeBinDir?: string): string;
|
|
7
|
-
export declare function resolveFfmpegPath(options?: ResolveFfmpegPathOptions): string;
|
|
8
|
-
export declare function getFfmpegPath(): string;
|
package/dist/utils/ffmpegPath.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { PATHS, buildRuntimeBinaryPath } from "./config.js";
|
|
3
|
-
export function getRuntimeFfmpegPath(runtimeBinDir = PATHS.runtimeBinDir) {
|
|
4
|
-
const name = process.platform === "win32" ? "ffmpeg.exe" : "ffmpeg";
|
|
5
|
-
return buildRuntimeBinaryPath(runtimeBinDir, name);
|
|
6
|
-
}
|
|
7
|
-
export function resolveFfmpegPath(options = {}) {
|
|
8
|
-
const envPath = options.envPath ?? process.env.FFMPEG_PATH ?? null;
|
|
9
|
-
if (envPath) {
|
|
10
|
-
return envPath;
|
|
11
|
-
}
|
|
12
|
-
const runtimePath = options.runtimePath ?? getRuntimeFfmpegPath();
|
|
13
|
-
const runtimeExists = options.runtimeExists ?? existsSync(runtimePath);
|
|
14
|
-
if (runtimeExists) {
|
|
15
|
-
return runtimePath;
|
|
16
|
-
}
|
|
17
|
-
return "ffmpeg";
|
|
18
|
-
}
|
|
19
|
-
export function getFfmpegPath() {
|
|
20
|
-
return resolveFfmpegPath();
|
|
21
|
-
}
|
package/dist/utils/formatters.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const UNITS = ["B", "KB", "MB", "GB", "TB"];
|
|
2
|
-
function formatScaled(value) {
|
|
3
|
-
if (!Number.isFinite(value) || value < 0) {
|
|
4
|
-
return "0 B";
|
|
5
|
-
}
|
|
6
|
-
let scaled = value;
|
|
7
|
-
let unitIndex = 0;
|
|
8
|
-
while (scaled >= 1024 && unitIndex < UNITS.length - 1) {
|
|
9
|
-
scaled /= 1024;
|
|
10
|
-
unitIndex++;
|
|
11
|
-
}
|
|
12
|
-
const floored = Math.floor(scaled * 10) / 10;
|
|
13
|
-
return `${Number.isInteger(floored) ? floored.toFixed(0) : floored} ${UNITS[unitIndex]}`;
|
|
14
|
-
}
|
|
15
|
-
export function formatPercent(value) {
|
|
16
|
-
return `${Math.max(0, Math.min(100, Math.round(value)))}%`;
|
|
17
|
-
}
|
|
18
|
-
export function formatBytes(bytes) {
|
|
19
|
-
return formatScaled(bytes);
|
|
20
|
-
}
|
|
21
|
-
export function formatSpeed(bytesPerSecond) {
|
|
22
|
-
return `${formatBytes(bytesPerSecond)}/s`;
|
|
23
|
-
}
|
|
24
|
-
export function formatEta(seconds) {
|
|
25
|
-
if (!Number.isFinite(seconds) || seconds <= 0) {
|
|
26
|
-
return "0s";
|
|
27
|
-
}
|
|
28
|
-
let remaining = Math.floor(seconds);
|
|
29
|
-
const hours = Math.floor(remaining / 3600);
|
|
30
|
-
remaining -= hours * 3600;
|
|
31
|
-
const minutes = Math.floor(remaining / 60);
|
|
32
|
-
remaining -= minutes * 60;
|
|
33
|
-
const parts = [];
|
|
34
|
-
if (hours > 0) {
|
|
35
|
-
parts.push(`${hours}h`);
|
|
36
|
-
}
|
|
37
|
-
if (minutes > 0 || hours > 0) {
|
|
38
|
-
parts.push(`${minutes}m`);
|
|
39
|
-
}
|
|
40
|
-
parts.push(`${remaining}s`);
|
|
41
|
-
return parts.join(" ");
|
|
42
|
-
}
|
package/dist/utils/launcher.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface LauncherSourceOptions {
|
|
2
|
-
packageSpec?: string;
|
|
3
|
-
npmCacheDir?: string;
|
|
4
|
-
}
|
|
5
|
-
export interface LauncherCommand {
|
|
6
|
-
command: string;
|
|
7
|
-
args: string[];
|
|
8
|
-
}
|
|
9
|
-
export declare function buildLauncherCommand(launcherPath?: string): LauncherCommand;
|
|
10
|
-
export declare function isRepairableNpxFailure(stderr: string): boolean;
|
|
11
|
-
export declare function buildLauncherSource(options?: LauncherSourceOptions): string;
|
|
12
|
-
export declare function writeLauncherFile(options?: LauncherSourceOptions): string;
|
package/dist/utils/launcher.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { dirname } from "node:path";
|
|
3
|
-
import { PATHS } from "./config.js";
|
|
4
|
-
const DEFAULT_PACKAGE_SPEC = "@mkterswingman/5mghost-yonder@latest";
|
|
5
|
-
export function buildLauncherCommand(launcherPath = PATHS.launcherJs) {
|
|
6
|
-
return {
|
|
7
|
-
command: "node",
|
|
8
|
-
args: [launcherPath, "serve"],
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function isRepairableNpxFailure(stderr) {
|
|
12
|
-
const lower = stderr.toLowerCase();
|
|
13
|
-
const referencesNpxDir = lower.includes("_npx/") || lower.includes("_npx\\");
|
|
14
|
-
return referencesNpxDir && (lower.includes("enotempty") || lower.includes("rename"));
|
|
15
|
-
}
|
|
16
|
-
export function buildLauncherSource(options = {}) {
|
|
17
|
-
const packageSpec = options.packageSpec ?? DEFAULT_PACKAGE_SPEC;
|
|
18
|
-
const npmCacheDir = options.npmCacheDir ?? PATHS.npmCacheDir;
|
|
19
|
-
return `#!/usr/bin/env node
|
|
20
|
-
import { existsSync, mkdirSync, renameSync } from "node:fs";
|
|
21
|
-
import { join } from "node:path";
|
|
22
|
-
import { spawnSync } from "node:child_process";
|
|
23
|
-
|
|
24
|
-
const packageSpec = ${JSON.stringify(packageSpec)};
|
|
25
|
-
const npmCacheDir = ${JSON.stringify(npmCacheDir)};
|
|
26
|
-
const args = process.argv.slice(2);
|
|
27
|
-
const targetArgs = args.length > 0 ? args : ["serve"];
|
|
28
|
-
|
|
29
|
-
function isSkillInstallerMode(subArgs) {
|
|
30
|
-
return subArgs[0] === "install-skills";
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function isRepairableNpxFailure(stderr) {
|
|
34
|
-
const lower = stderr.toLowerCase();
|
|
35
|
-
return (lower.includes("_npx/") || lower.includes("_npx\\\\"))
|
|
36
|
-
&& (lower.includes("enotempty") || lower.includes("rename"));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function runNpx(subArgs, captureStdErrOnly = false) {
|
|
40
|
-
mkdirSync(npmCacheDir, { recursive: true });
|
|
41
|
-
const npxBin = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
42
|
-
return spawnSync(npxBin, ["--yes", packageSpec, ...subArgs], {
|
|
43
|
-
env: { ...process.env, npm_config_cache: npmCacheDir },
|
|
44
|
-
// Why: probe runs before MCP starts; stdout must stay silent or it will corrupt stdio transport.
|
|
45
|
-
// The skill installer is an explicit one-shot CLI path, so it can inherit stdio safely.
|
|
46
|
-
stdio: captureStdErrOnly ? ["ignore", "ignore", "pipe"] : "inherit",
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function rotateNpxDir() {
|
|
51
|
-
const npxDir = join(npmCacheDir, "_npx");
|
|
52
|
-
if (!existsSync(npxDir)) return false;
|
|
53
|
-
const backup = \`\${npxDir}.bad.\${new Date().toISOString().replace(/[^0-9]/g, "").slice(0, 14)}\`;
|
|
54
|
-
renameSync(npxDir, backup);
|
|
55
|
-
process.stderr.write(\`[yt-mcp launcher] repaired corrupted npx cache: \${backup}\\n\`);
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function ensurePackageReady() {
|
|
60
|
-
const first = runNpx(["version"], true);
|
|
61
|
-
if ((first.status ?? 1) === 0) return;
|
|
62
|
-
|
|
63
|
-
const stderr = first.stderr ? String(first.stderr) : "";
|
|
64
|
-
if (!isRepairableNpxFailure(stderr) || !rotateNpxDir()) {
|
|
65
|
-
if (stderr) process.stderr.write(stderr);
|
|
66
|
-
process.exit(first.status ?? 1);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const second = runNpx(["version"], true);
|
|
70
|
-
const secondStderr = second.stderr ? String(second.stderr) : "";
|
|
71
|
-
if ((second.status ?? 1) !== 0) {
|
|
72
|
-
if (secondStderr) process.stderr.write(secondStderr);
|
|
73
|
-
process.exit(second.status ?? 1);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
ensurePackageReady();
|
|
78
|
-
if (isSkillInstallerMode(targetArgs)) {
|
|
79
|
-
process.env.YT_MCP_INSTALL_SKILLS = "1";
|
|
80
|
-
}
|
|
81
|
-
const finalRun = runNpx(targetArgs, false);
|
|
82
|
-
process.exit(finalRun.status ?? 0);
|
|
83
|
-
`;
|
|
84
|
-
}
|
|
85
|
-
export function writeLauncherFile(options = {}) {
|
|
86
|
-
mkdirSync(dirname(PATHS.launcherJs), { recursive: true });
|
|
87
|
-
const source = buildLauncherSource(options);
|
|
88
|
-
writeFileSync(PATHS.launcherJs, source, { encoding: "utf8", mode: 0o755 });
|
|
89
|
-
return PATHS.launcherJs;
|
|
90
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const MCP_REGISTER_TIMEOUT_MS = 5000;
|
|
2
|
-
export type RegistrationFailureKind = "already_exists" | "authentication" | "timeout" | "other";
|
|
3
|
-
export interface RegistrationFailure {
|
|
4
|
-
kind: RegistrationFailureKind;
|
|
5
|
-
output: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function classifyRegistrationFailure(err: unknown): RegistrationFailure;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export const MCP_REGISTER_TIMEOUT_MS = 5000;
|
|
2
|
-
function readOutput(err) {
|
|
3
|
-
if (!(err instanceof Error))
|
|
4
|
-
return "";
|
|
5
|
-
const stderr = "stderr" in err ? String(err.stderr ?? "") : "";
|
|
6
|
-
const stdout = "stdout" in err ? String(err.stdout ?? "") : "";
|
|
7
|
-
return `${stderr}${stdout}`;
|
|
8
|
-
}
|
|
9
|
-
export function classifyRegistrationFailure(err) {
|
|
10
|
-
const output = readOutput(err);
|
|
11
|
-
const lower = output.toLowerCase();
|
|
12
|
-
if (lower.includes("already exists")) {
|
|
13
|
-
return { kind: "already_exists", output };
|
|
14
|
-
}
|
|
15
|
-
if (lower.includes("waiting for authentication")) {
|
|
16
|
-
return { kind: "authentication", output };
|
|
17
|
-
}
|
|
18
|
-
if (err instanceof Error &&
|
|
19
|
-
("code" in err && err.code === "ETIMEDOUT")) {
|
|
20
|
-
return { kind: "timeout", output };
|
|
21
|
-
}
|
|
22
|
-
return { kind: "other", output };
|
|
23
|
-
}
|
package/dist/utils/mediaPaths.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
export function buildMediaOutputPaths(rootDir, dateStr, videoId) {
|
|
3
|
-
const outputDir = join(rootDir, `${dateStr}_${videoId}`);
|
|
4
|
-
return {
|
|
5
|
-
outputDir,
|
|
6
|
-
videoFile: join(outputDir, "video.mp4"),
|
|
7
|
-
metadataFile: join(outputDir, "metadata.json"),
|
|
8
|
-
subtitlesDir: join(outputDir, "subtitles"),
|
|
9
|
-
};
|
|
10
|
-
}
|
package/dist/utils/openClaw.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { LauncherCommand } from "./launcher.js";
|
|
2
|
-
export interface OpenClawServerConfig {
|
|
3
|
-
transport: "stdio";
|
|
4
|
-
command: string;
|
|
5
|
-
args: string[];
|
|
6
|
-
env?: Record<string, string>;
|
|
7
|
-
}
|
|
8
|
-
export declare function getOpenClawConfigPath(homeDir?: string): string;
|
|
9
|
-
export declare function getOpenClawSkillsDir(homeDir?: string): string;
|
|
10
|
-
export declare function buildOpenClawServerConfig(launcherCommand: LauncherCommand): OpenClawServerConfig;
|
|
11
|
-
export declare function upsertOpenClawConfigText(currentText: string | null, serverName: string, launcherCommand: LauncherCommand): string;
|
|
12
|
-
export declare function removeOpenClawConfigEntryText(currentText: string | null, serverName: string): {
|
|
13
|
-
changed: boolean;
|
|
14
|
-
nextText: string | null;
|
|
15
|
-
};
|
|
16
|
-
export declare function isOpenClawInstallLikelyInstalled(detectBinary: (name: string) => boolean, configPath?: string): boolean;
|
|
17
|
-
export declare function writeOpenClawConfig(serverName: string, launcherCommand: LauncherCommand, configPath?: string): "created" | "updated";
|
|
18
|
-
export declare function removeOpenClawConfig(serverName: string, configPath?: string): "removed" | "missing";
|
package/dist/utils/openClaw.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
export function getOpenClawConfigPath(homeDir = homedir()) {
|
|
5
|
-
return join(homeDir, ".openclaw", "workspace", "config", "mcporter.json");
|
|
6
|
-
}
|
|
7
|
-
export function getOpenClawSkillsDir(homeDir = homedir()) {
|
|
8
|
-
return join(homeDir, ".openclaw", "skills");
|
|
9
|
-
}
|
|
10
|
-
export function buildOpenClawServerConfig(launcherCommand) {
|
|
11
|
-
return {
|
|
12
|
-
transport: "stdio",
|
|
13
|
-
command: launcherCommand.command,
|
|
14
|
-
args: [...launcherCommand.args],
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function parseOpenClawConfig(raw) {
|
|
18
|
-
const parsed = JSON.parse(raw);
|
|
19
|
-
if (parsed && typeof parsed === "object") {
|
|
20
|
-
return parsed;
|
|
21
|
-
}
|
|
22
|
-
throw new Error("OpenClaw mcporter.json must be a JSON object");
|
|
23
|
-
}
|
|
24
|
-
export function upsertOpenClawConfigText(currentText, serverName, launcherCommand) {
|
|
25
|
-
const config = currentText ? parseOpenClawConfig(currentText) : {};
|
|
26
|
-
const servers = config.servers && typeof config.servers === "object" ? { ...config.servers } : {};
|
|
27
|
-
servers[serverName] = buildOpenClawServerConfig(launcherCommand);
|
|
28
|
-
const nextConfig = {
|
|
29
|
-
...config,
|
|
30
|
-
servers,
|
|
31
|
-
};
|
|
32
|
-
return JSON.stringify(nextConfig, null, 2);
|
|
33
|
-
}
|
|
34
|
-
export function removeOpenClawConfigEntryText(currentText, serverName) {
|
|
35
|
-
if (!currentText) {
|
|
36
|
-
return { changed: false, nextText: null };
|
|
37
|
-
}
|
|
38
|
-
const config = parseOpenClawConfig(currentText);
|
|
39
|
-
if (!config.servers || typeof config.servers !== "object" || !(serverName in config.servers)) {
|
|
40
|
-
return { changed: false, nextText: currentText };
|
|
41
|
-
}
|
|
42
|
-
const servers = { ...config.servers };
|
|
43
|
-
delete servers[serverName];
|
|
44
|
-
const nextConfig = { ...config };
|
|
45
|
-
if (Object.keys(servers).length === 0) {
|
|
46
|
-
delete nextConfig.servers;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
nextConfig.servers = servers;
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
changed: true,
|
|
53
|
-
nextText: JSON.stringify(nextConfig, null, 2),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export function isOpenClawInstallLikelyInstalled(detectBinary, configPath = getOpenClawConfigPath()) {
|
|
57
|
-
if (detectBinary("mcporter") || detectBinary("openclaw")) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
return existsSync(configPath) || existsSync(dirname(configPath));
|
|
61
|
-
}
|
|
62
|
-
export function writeOpenClawConfig(serverName, launcherCommand, configPath = getOpenClawConfigPath()) {
|
|
63
|
-
const existingText = existsSync(configPath) ? readFileSync(configPath, "utf8") : null;
|
|
64
|
-
const created = existingText === null;
|
|
65
|
-
const nextText = upsertOpenClawConfigText(existingText, serverName, launcherCommand);
|
|
66
|
-
mkdirSync(dirname(configPath), { recursive: true });
|
|
67
|
-
writeFileSync(configPath, `${nextText}\n`, "utf8");
|
|
68
|
-
return created ? "created" : "updated";
|
|
69
|
-
}
|
|
70
|
-
export function removeOpenClawConfig(serverName, configPath = getOpenClawConfigPath()) {
|
|
71
|
-
const existingText = existsSync(configPath) ? readFileSync(configPath, "utf8") : null;
|
|
72
|
-
const result = removeOpenClawConfigEntryText(existingText, serverName);
|
|
73
|
-
if (!result.changed) {
|
|
74
|
-
return "missing";
|
|
75
|
-
}
|
|
76
|
-
if (!result.nextText) {
|
|
77
|
-
rmSync(configPath, { force: true });
|
|
78
|
-
return "removed";
|
|
79
|
-
}
|
|
80
|
-
writeFileSync(configPath, `${result.nextText}\n`, "utf8");
|
|
81
|
-
return "removed";
|
|
82
|
-
}
|
package/dist/utils/skills.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { LauncherCommand } from "./launcher.js";
|
|
2
|
-
export interface SkillInstallTarget {
|
|
3
|
-
client: string;
|
|
4
|
-
label: string;
|
|
5
|
-
sourceDir: string;
|
|
6
|
-
targetDir: string;
|
|
7
|
-
}
|
|
8
|
-
export interface SkillInstallPlanOptions {
|
|
9
|
-
homeDir?: string;
|
|
10
|
-
availableCliNames?: string[];
|
|
11
|
-
includeOpenClaw?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function getSkillPackageSourcePath(packageRoot: string): string;
|
|
14
|
-
export declare function buildSkillLauncherCommand(launcherPath: string): LauncherCommand;
|
|
15
|
-
export declare function buildSkillInstallPlan(packageRoot: string, options?: SkillInstallPlanOptions): SkillInstallTarget[];
|
|
16
|
-
export declare function installSkillTarget(target: SkillInstallTarget): void;
|
package/dist/utils/skills.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { cpSync, existsSync, mkdirSync, rmSync } from "node:fs";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { getOpenClawSkillsDir } from "./openClaw.js";
|
|
5
|
-
const SKILL_NAME = "use-yt-mcp";
|
|
6
|
-
export function getSkillPackageSourcePath(packageRoot) {
|
|
7
|
-
return join(packageRoot, "skills", SKILL_NAME);
|
|
8
|
-
}
|
|
9
|
-
export function buildSkillLauncherCommand(launcherPath) {
|
|
10
|
-
return {
|
|
11
|
-
command: "node",
|
|
12
|
-
args: [launcherPath, "install-skills"],
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export function buildSkillInstallPlan(packageRoot, options = {}) {
|
|
16
|
-
const homeDir = options.homeDir ?? homedir();
|
|
17
|
-
const availableCliNames = new Set(options.availableCliNames ?? []);
|
|
18
|
-
const sourceDir = getSkillPackageSourcePath(packageRoot);
|
|
19
|
-
const plan = [];
|
|
20
|
-
const cliTargets = [
|
|
21
|
-
{ client: "claude-internal", label: "Claude Code (internal)", dir: join(homeDir, ".claude-internal", "skills") },
|
|
22
|
-
{ client: "claude", label: "Claude Code", dir: join(homeDir, ".claude", "skills") },
|
|
23
|
-
{ client: "codex-internal", label: "Codex CLI (internal)", dir: join(homeDir, ".codex-internal", "skills") },
|
|
24
|
-
{ client: "codex", label: "Codex CLI / Codex App", dir: join(homeDir, ".codex", "skills") },
|
|
25
|
-
{ client: "gemini-internal", label: "Gemini CLI (internal)", dir: join(homeDir, ".gemini-internal", "skills") },
|
|
26
|
-
{ client: "gemini", label: "Gemini CLI", dir: join(homeDir, ".gemini", "skills") },
|
|
27
|
-
];
|
|
28
|
-
for (const target of cliTargets) {
|
|
29
|
-
if (!availableCliNames.has(target.client)) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
plan.push({
|
|
33
|
-
client: target.client,
|
|
34
|
-
label: target.label,
|
|
35
|
-
sourceDir,
|
|
36
|
-
targetDir: join(target.dir, SKILL_NAME),
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
if (options.includeOpenClaw) {
|
|
40
|
-
plan.push({
|
|
41
|
-
client: "openclaw",
|
|
42
|
-
label: "OpenClaw",
|
|
43
|
-
sourceDir,
|
|
44
|
-
targetDir: join(getOpenClawSkillsDir(homeDir), SKILL_NAME),
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return plan;
|
|
48
|
-
}
|
|
49
|
-
export function installSkillTarget(target) {
|
|
50
|
-
if (!existsSync(target.sourceDir)) {
|
|
51
|
-
throw new Error(`Bundled skill not found: ${target.sourceDir}`);
|
|
52
|
-
}
|
|
53
|
-
mkdirSync(dirname(target.targetDir), { recursive: true });
|
|
54
|
-
rmSync(target.targetDir, { recursive: true, force: true });
|
|
55
|
-
cpSync(target.sourceDir, target.targetDir, { recursive: true });
|
|
56
|
-
}
|
package/dist/utils/videoInput.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const VIDEO_ID_RE = /^[A-Za-z0-9_-]{11}$/;
|
|
2
|
-
function toValidVideoId(value) {
|
|
3
|
-
const v = value.trim();
|
|
4
|
-
return VIDEO_ID_RE.test(v) ? v : null;
|
|
5
|
-
}
|
|
6
|
-
function extractFromUrl(raw) {
|
|
7
|
-
let url;
|
|
8
|
-
try {
|
|
9
|
-
url = new URL(raw.trim());
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
const host = url.hostname.toLowerCase();
|
|
15
|
-
const normalizedHost = host.startsWith("www.") ? host.slice(4) : host;
|
|
16
|
-
if (url.searchParams.has("list")) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
if (normalizedHost === "youtu.be") {
|
|
20
|
-
const id = url.pathname.split("/").filter(Boolean)[0] ?? "";
|
|
21
|
-
return toValidVideoId(id);
|
|
22
|
-
}
|
|
23
|
-
if (normalizedHost === "youtube.com" || normalizedHost === "m.youtube.com") {
|
|
24
|
-
if (url.pathname === "/watch") {
|
|
25
|
-
return toValidVideoId(url.searchParams.get("v") ?? "");
|
|
26
|
-
}
|
|
27
|
-
const parts = url.pathname.split("/").filter(Boolean);
|
|
28
|
-
if (parts.length >= 2 && ["shorts", "live", "embed"].includes(parts[0])) {
|
|
29
|
-
return toValidVideoId(parts[1]);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
export function resolveVideoInput(input) {
|
|
35
|
-
const candidate = input.trim();
|
|
36
|
-
if (!candidate) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const directId = toValidVideoId(candidate);
|
|
40
|
-
return directId ?? extractFromUrl(candidate);
|
|
41
|
-
}
|
|
42
|
-
export function normalizeVideoInputs(inputs) {
|
|
43
|
-
const resolvedIds = [];
|
|
44
|
-
const invalidInputs = [];
|
|
45
|
-
const seen = new Set();
|
|
46
|
-
for (const raw of inputs) {
|
|
47
|
-
const parsedId = resolveVideoInput(raw);
|
|
48
|
-
if (!parsedId) {
|
|
49
|
-
invalidInputs.push(raw);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (!seen.has(parsedId)) {
|
|
53
|
-
seen.add(parsedId);
|
|
54
|
-
resolvedIds.push(parsedId);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return { resolvedIds, invalidInputs };
|
|
58
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils/ytdlp.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
|
-
export interface YtDlpResult {
|
|
3
|
-
exitCode: number;
|
|
4
|
-
stdout: string;
|
|
5
|
-
stderr: string;
|
|
6
|
-
durationMs: number;
|
|
7
|
-
failureLogPath?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface YtDlpStderrLineSplitter {
|
|
10
|
-
push(chunk: Buffer | string): void;
|
|
11
|
-
flush(): void;
|
|
12
|
-
}
|
|
13
|
-
type SpawnSyncFn = typeof spawnSync;
|
|
14
|
-
export declare function createYtDlpStderrLineSplitter(onLine: (line: string) => void): YtDlpStderrLineSplitter;
|
|
15
|
-
export declare function hasYtDlp(runSpawnSync?: SpawnSyncFn): boolean;
|
|
16
|
-
export declare function buildYtDlpArgs(args: string[], options?: {
|
|
17
|
-
cookiesPath?: string;
|
|
18
|
-
cookiesExist?: boolean;
|
|
19
|
-
}): string[];
|
|
20
|
-
export declare function runYtDlp(args: string[], timeoutMs?: number, onStderrLine?: (line: string) => void): Promise<YtDlpResult>;
|
|
21
|
-
export declare function runYtDlpJson<T>(args: string[], timeoutMs?: number): Promise<{
|
|
22
|
-
ok: true;
|
|
23
|
-
value: T;
|
|
24
|
-
} | {
|
|
25
|
-
ok: false;
|
|
26
|
-
error: string;
|
|
27
|
-
}>;
|
|
28
|
-
export {};
|