mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-25 23:47:20 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { LEGACY_MANIFEST_KEY } from "../compat/legacy-names.js";
|
||||
import { MANIFEST_KEY } from "../compat/legacy-names.js";
|
||||
import { runCommandWithTimeout } from "../process/exec.js";
|
||||
import { CONFIG_DIR, resolveUserPath } from "../utils.js";
|
||||
import {
|
||||
@@ -21,9 +21,7 @@ type PackageManifest = {
|
||||
name?: string;
|
||||
version?: string;
|
||||
dependencies?: Record<string, string>;
|
||||
moltbot?: { extensions?: string[] };
|
||||
[LEGACY_MANIFEST_KEY]?: { extensions?: string[] };
|
||||
};
|
||||
} & Partial<Record<typeof MANIFEST_KEY, { extensions?: string[] }>>;
|
||||
|
||||
export type InstallPluginResult =
|
||||
| {
|
||||
@@ -54,14 +52,14 @@ function safeFileName(input: string): string {
|
||||
return safeDirName(input);
|
||||
}
|
||||
|
||||
async function ensureMoltbotExtensions(manifest: PackageManifest) {
|
||||
const extensions = manifest.moltbot?.extensions ?? manifest[LEGACY_MANIFEST_KEY]?.extensions;
|
||||
async function ensureOpenClawExtensions(manifest: PackageManifest) {
|
||||
const extensions = manifest[MANIFEST_KEY]?.extensions;
|
||||
if (!Array.isArray(extensions)) {
|
||||
throw new Error("package.json missing moltbot.extensions");
|
||||
throw new Error("package.json missing openclaw.extensions");
|
||||
}
|
||||
const list = extensions.map((e) => (typeof e === "string" ? e.trim() : "")).filter(Boolean);
|
||||
if (list.length === 0) {
|
||||
throw new Error("package.json moltbot.extensions is empty");
|
||||
throw new Error("package.json openclaw.extensions is empty");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -101,7 +99,7 @@ async function installPluginFromPackageDir(params: {
|
||||
|
||||
let extensions: string[];
|
||||
try {
|
||||
extensions = await ensureMoltbotExtensions(manifest);
|
||||
extensions = await ensureOpenClawExtensions(manifest);
|
||||
} catch (err) {
|
||||
return { ok: false, error: String(err) };
|
||||
}
|
||||
@@ -219,7 +217,7 @@ export async function installPluginFromArchive(params: {
|
||||
return { ok: false, error: `unsupported archive: ${archivePath}` };
|
||||
}
|
||||
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-plugin-"));
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-plugin-"));
|
||||
const extractDir = path.join(tmpDir, "extract");
|
||||
await fs.mkdir(extractDir, { recursive: true });
|
||||
|
||||
@@ -352,7 +350,7 @@ export async function installPluginFromNpmSpec(params: {
|
||||
const spec = params.spec.trim();
|
||||
if (!spec) return { ok: false, error: "missing npm spec" };
|
||||
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-npm-pack-"));
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-npm-pack-"));
|
||||
logger.info?.(`Downloading ${spec}…`);
|
||||
const res = await runCommandWithTimeout(["npm", "pack", spec], {
|
||||
timeoutMs: Math.max(timeoutMs, 300_000),
|
||||
|
||||
Reference in New Issue
Block a user