@elizaos/cli 1.2.11-beta.6 → 1.2.11-beta.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.
- package/dist/{chunk-MHXS2LE3.js → chunk-BVMPDDVC.js} +306 -153
- package/dist/{chunk-ZCHV5DKU.js → chunk-LBWSLIF4.js} +2 -2
- package/dist/{chunk-XHL7ASRH.js → chunk-P2EDLOL3.js} +1 -1
- package/dist/commands/agent/actions/index.js +1 -1
- package/dist/commands/agent/index.js +1 -1
- package/dist/commands/create/actions/index.js +2 -2
- package/dist/commands/create/index.js +3 -3
- package/dist/index.js +24 -5
- package/dist/{registry-FOWACLT2.js → registry-RLIFZR6O.js} +1 -1
- package/dist/templates/plugin-quick-starter/package.json +1 -1
- package/dist/templates/plugin-starter/package.json +1 -1
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-tee-starter/package.json +3 -3
- package/dist/{utils-GALDWFSJ.js → utils-4MMOCB4V.js} +7 -1
- package/package.json +5 -5
- package/templates/plugin-quick-starter/package.json +2 -2
- package/templates/plugin-starter/package.json +2 -2
- package/templates/project-starter/package.json +5 -5
- package/templates/project-tee-starter/package.json +4 -4
|
@@ -2616,10 +2616,10 @@ async function createBranch(token, owner, repo, branch, baseBranch = "main") {
|
|
|
2616
2616
|
return false;
|
|
2617
2617
|
}
|
|
2618
2618
|
}
|
|
2619
|
-
async function getFileContent(token, owner, repo,
|
|
2619
|
+
async function getFileContent(token, owner, repo, path22, branch = "main") {
|
|
2620
2620
|
try {
|
|
2621
2621
|
const response = await fetch(
|
|
2622
|
-
`${GITHUB_API_URL}/repos/${owner}/${repo}/contents/${
|
|
2622
|
+
`${GITHUB_API_URL}/repos/${owner}/${repo}/contents/${path22}?ref=${branch}`,
|
|
2623
2623
|
{
|
|
2624
2624
|
headers: {
|
|
2625
2625
|
Authorization: `token ${token}`,
|
|
@@ -2636,14 +2636,14 @@ async function getFileContent(token, owner, repo, path21, branch = "main") {
|
|
|
2636
2636
|
return null;
|
|
2637
2637
|
}
|
|
2638
2638
|
}
|
|
2639
|
-
async function updateFile(token, owner, repo,
|
|
2639
|
+
async function updateFile(token, owner, repo, path22, content, message, branch = "main") {
|
|
2640
2640
|
try {
|
|
2641
|
-
const existingContent = await getFileContent(token, owner, repo,
|
|
2641
|
+
const existingContent = await getFileContent(token, owner, repo, path22, branch);
|
|
2642
2642
|
const method = "PUT";
|
|
2643
2643
|
let sha;
|
|
2644
2644
|
if (existingContent !== null) {
|
|
2645
2645
|
const response2 = await fetch(
|
|
2646
|
-
`${GITHUB_API_URL}/repos/${owner}/${repo}/contents/${
|
|
2646
|
+
`${GITHUB_API_URL}/repos/${owner}/${repo}/contents/${path22}?ref=${branch}`,
|
|
2647
2647
|
{
|
|
2648
2648
|
headers: {
|
|
2649
2649
|
Authorization: `token ${token}`,
|
|
@@ -2656,7 +2656,7 @@ async function updateFile(token, owner, repo, path21, content, message, branch =
|
|
|
2656
2656
|
sha = data.sha;
|
|
2657
2657
|
}
|
|
2658
2658
|
}
|
|
2659
|
-
const fileUrl = `${GITHUB_API_URL}/repos/${owner}/${repo}/contents/${
|
|
2659
|
+
const fileUrl = `${GITHUB_API_URL}/repos/${owner}/${repo}/contents/${path22}`;
|
|
2660
2660
|
logger10.info(`Updating file at: ${fileUrl}`);
|
|
2661
2661
|
const requestBody = {
|
|
2662
2662
|
message,
|
|
@@ -2682,7 +2682,7 @@ async function updateFile(token, owner, repo, path21, content, message, branch =
|
|
|
2682
2682
|
logger10.error(`Failed to update file: ${response.status} ${response.statusText}`);
|
|
2683
2683
|
logger10.error(`Response body: ${errorBody}`);
|
|
2684
2684
|
if (response.status === 404) {
|
|
2685
|
-
logger10.error(`Repository or path not found: ${owner}/${repo}/${
|
|
2685
|
+
logger10.error(`Repository or path not found: ${owner}/${repo}/${path22}`);
|
|
2686
2686
|
const repoCheck = await fetch(`${GITHUB_API_URL}/repos/${owner}/${repo}`, {
|
|
2687
2687
|
headers: {
|
|
2688
2688
|
Authorization: `token ${token}`,
|
|
@@ -2761,7 +2761,7 @@ async function getGitHubCredentials() {
|
|
|
2761
2761
|
}
|
|
2762
2762
|
logger10.warn("Invalid GitHub token found in environment variables");
|
|
2763
2763
|
}
|
|
2764
|
-
const { getGitHubToken: getGitHubToken2 } = await import("./registry-
|
|
2764
|
+
const { getGitHubToken: getGitHubToken2 } = await import("./registry-RLIFZR6O.js");
|
|
2765
2765
|
const token = await getGitHubToken2() || void 0;
|
|
2766
2766
|
if (token) {
|
|
2767
2767
|
const isValid2 = await validateGitHubToken(token);
|
|
@@ -2848,11 +2848,11 @@ async function saveGitHubCredentials(username, token) {
|
|
|
2848
2848
|
process.env.GITHUB_TOKEN = token;
|
|
2849
2849
|
logger10.success("GitHub credentials saved");
|
|
2850
2850
|
}
|
|
2851
|
-
async function ensureDirectory(token, repo,
|
|
2851
|
+
async function ensureDirectory(token, repo, path22, branch) {
|
|
2852
2852
|
try {
|
|
2853
2853
|
try {
|
|
2854
2854
|
const response = await fetch(
|
|
2855
|
-
`${GITHUB_API_URL}/repos/${repo}/contents/${
|
|
2855
|
+
`${GITHUB_API_URL}/repos/${repo}/contents/${path22}?ref=${branch}`,
|
|
2856
2856
|
{
|
|
2857
2857
|
headers: {
|
|
2858
2858
|
Authorization: `token ${token}`,
|
|
@@ -2861,27 +2861,27 @@ async function ensureDirectory(token, repo, path21, branch) {
|
|
|
2861
2861
|
}
|
|
2862
2862
|
);
|
|
2863
2863
|
if (response.status === 200) {
|
|
2864
|
-
logger10.info(`Directory ${
|
|
2864
|
+
logger10.info(`Directory ${path22} already exists`);
|
|
2865
2865
|
return true;
|
|
2866
2866
|
}
|
|
2867
2867
|
} catch (error) {
|
|
2868
|
-
logger10.info(`Directory ${
|
|
2868
|
+
logger10.info(`Directory ${path22} doesn't exist, creating it`);
|
|
2869
2869
|
}
|
|
2870
|
-
const placeholderPath = `${
|
|
2870
|
+
const placeholderPath = `${path22}/.gitkeep`;
|
|
2871
2871
|
const result = await updateFile(
|
|
2872
2872
|
token,
|
|
2873
2873
|
repo,
|
|
2874
2874
|
placeholderPath,
|
|
2875
2875
|
"",
|
|
2876
2876
|
// Empty content for placeholder
|
|
2877
|
-
`Create directory: ${
|
|
2877
|
+
`Create directory: ${path22}`,
|
|
2878
2878
|
branch
|
|
2879
2879
|
);
|
|
2880
2880
|
if (result) {
|
|
2881
|
-
logger10.success(`Created directory: ${
|
|
2881
|
+
logger10.success(`Created directory: ${path22}`);
|
|
2882
2882
|
return true;
|
|
2883
2883
|
}
|
|
2884
|
-
logger10.error(`Failed to create directory: ${
|
|
2884
|
+
logger10.error(`Failed to create directory: ${path22}`);
|
|
2885
2885
|
return false;
|
|
2886
2886
|
} catch (error) {
|
|
2887
2887
|
logger10.error(
|
|
@@ -4177,21 +4177,171 @@ async function installPlugin(packageName, cwd, versionSpecifier, skipVerificatio
|
|
|
4177
4177
|
return false;
|
|
4178
4178
|
}
|
|
4179
4179
|
|
|
4180
|
+
// src/utils/local-cli-delegation.ts
|
|
4181
|
+
import { spawn } from "child_process";
|
|
4182
|
+
import { existsSync as existsSync15 } from "fs";
|
|
4183
|
+
import path18 from "path";
|
|
4184
|
+
import { logger as logger19 } from "@elizaos/core";
|
|
4185
|
+
function isRunningFromLocalCli() {
|
|
4186
|
+
try {
|
|
4187
|
+
const currentScriptPath = process.argv[1];
|
|
4188
|
+
if (!currentScriptPath) return false;
|
|
4189
|
+
const absoluteScriptPath = path18.resolve(currentScriptPath);
|
|
4190
|
+
const isInLocalCli = absoluteScriptPath.includes(path18.join("node_modules", "@elizaos", "cli"));
|
|
4191
|
+
return isInLocalCli;
|
|
4192
|
+
} catch (error) {
|
|
4193
|
+
logger19.debug("Error checking if running from local CLI:", error);
|
|
4194
|
+
return false;
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
function getLocalCliPath() {
|
|
4198
|
+
const localCliPath = path18.join(
|
|
4199
|
+
process.cwd(),
|
|
4200
|
+
"node_modules",
|
|
4201
|
+
"@elizaos",
|
|
4202
|
+
"cli",
|
|
4203
|
+
"dist",
|
|
4204
|
+
"index.js"
|
|
4205
|
+
);
|
|
4206
|
+
return existsSync15(localCliPath) ? localCliPath : null;
|
|
4207
|
+
}
|
|
4208
|
+
function setupLocalEnvironment() {
|
|
4209
|
+
const env = { ...process.env };
|
|
4210
|
+
const localModulesPath = path18.join(process.cwd(), "node_modules");
|
|
4211
|
+
if (existsSync15(localModulesPath)) {
|
|
4212
|
+
if (env.NODE_PATH) {
|
|
4213
|
+
env.NODE_PATH = `${localModulesPath}${path18.delimiter}${env.NODE_PATH}`;
|
|
4214
|
+
} else {
|
|
4215
|
+
env.NODE_PATH = localModulesPath;
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
4218
|
+
const localBinPath = path18.join(process.cwd(), "node_modules", ".bin");
|
|
4219
|
+
if (existsSync15(localBinPath)) {
|
|
4220
|
+
if (env.PATH) {
|
|
4221
|
+
env.PATH = `${localBinPath}${path18.delimiter}${env.PATH}`;
|
|
4222
|
+
} else {
|
|
4223
|
+
env.PATH = localBinPath;
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
env.FORCE_COLOR = "1";
|
|
4227
|
+
return env;
|
|
4228
|
+
}
|
|
4229
|
+
async function delegateToLocalCli(localCliPath) {
|
|
4230
|
+
return new Promise((resolve2, reject) => {
|
|
4231
|
+
logger19.info("Using local @elizaos/cli installation");
|
|
4232
|
+
const nodeExecutable = process.execPath;
|
|
4233
|
+
const args = process.argv.slice(2);
|
|
4234
|
+
const env = setupLocalEnvironment();
|
|
4235
|
+
const childProcess = spawn(nodeExecutable, [localCliPath, ...args], {
|
|
4236
|
+
stdio: "inherit",
|
|
4237
|
+
// Inherit stdio to maintain interactive behavior
|
|
4238
|
+
env,
|
|
4239
|
+
cwd: process.cwd()
|
|
4240
|
+
});
|
|
4241
|
+
childProcess.on("exit", (code, signal) => {
|
|
4242
|
+
if (code !== null) {
|
|
4243
|
+
process.exit(code);
|
|
4244
|
+
} else if (signal) {
|
|
4245
|
+
const exitCode = signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 1;
|
|
4246
|
+
process.exit(exitCode);
|
|
4247
|
+
}
|
|
4248
|
+
resolve2();
|
|
4249
|
+
});
|
|
4250
|
+
childProcess.on("error", (error) => {
|
|
4251
|
+
logger19.error(`Failed to start local CLI: ${error.message}`);
|
|
4252
|
+
reject(error);
|
|
4253
|
+
});
|
|
4254
|
+
const forwardSignal = (signal) => {
|
|
4255
|
+
process.on(signal, () => {
|
|
4256
|
+
if (childProcess.killed === false) {
|
|
4257
|
+
childProcess.kill(signal);
|
|
4258
|
+
}
|
|
4259
|
+
});
|
|
4260
|
+
};
|
|
4261
|
+
forwardSignal("SIGINT");
|
|
4262
|
+
forwardSignal("SIGTERM");
|
|
4263
|
+
});
|
|
4264
|
+
}
|
|
4265
|
+
function isTestEnvironment() {
|
|
4266
|
+
const testIndicators = [
|
|
4267
|
+
process.env.NODE_ENV === "test",
|
|
4268
|
+
process.env.ELIZA_TEST_MODE === "true",
|
|
4269
|
+
process.env.ELIZA_TEST_MODE === "1",
|
|
4270
|
+
process.env.ELIZA_CLI_TEST_MODE === "true",
|
|
4271
|
+
process.env.BUN_TEST === "true",
|
|
4272
|
+
process.env.VITEST === "true",
|
|
4273
|
+
process.env.JEST_WORKER_ID !== void 0,
|
|
4274
|
+
process.argv.includes("--test"),
|
|
4275
|
+
process.argv.includes("test"),
|
|
4276
|
+
// Check if we're running under a test runner
|
|
4277
|
+
process.argv[1]?.includes("test") === true,
|
|
4278
|
+
// Check if parent process is a test runner
|
|
4279
|
+
process.env.npm_lifecycle_event === "test"
|
|
4280
|
+
];
|
|
4281
|
+
return testIndicators.some((indicator) => indicator === true);
|
|
4282
|
+
}
|
|
4283
|
+
async function tryDelegateToLocalCli() {
|
|
4284
|
+
try {
|
|
4285
|
+
if (isTestEnvironment()) {
|
|
4286
|
+
logger19.debug("Running in test environment, skipping local CLI delegation");
|
|
4287
|
+
return false;
|
|
4288
|
+
}
|
|
4289
|
+
if (isRunningFromLocalCli()) {
|
|
4290
|
+
logger19.debug("Already running from local CLI, continuing execution");
|
|
4291
|
+
return false;
|
|
4292
|
+
}
|
|
4293
|
+
const localCliPath = getLocalCliPath();
|
|
4294
|
+
if (!localCliPath) {
|
|
4295
|
+
logger19.debug("No local CLI found, using global installation");
|
|
4296
|
+
return false;
|
|
4297
|
+
}
|
|
4298
|
+
await delegateToLocalCli(localCliPath);
|
|
4299
|
+
return true;
|
|
4300
|
+
} catch (error) {
|
|
4301
|
+
logger19.error("Error during local CLI delegation:", error);
|
|
4302
|
+
logger19.info("Falling back to global CLI installation");
|
|
4303
|
+
return false;
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
4306
|
+
function hasLocalCli() {
|
|
4307
|
+
return getLocalCliPath() !== null;
|
|
4308
|
+
}
|
|
4309
|
+
function getCliContext() {
|
|
4310
|
+
return {
|
|
4311
|
+
isLocal: isRunningFromLocalCli(),
|
|
4312
|
+
hasLocal: hasLocalCli(),
|
|
4313
|
+
localPath: getLocalCliPath(),
|
|
4314
|
+
currentPath: process.argv[1] || "unknown"
|
|
4315
|
+
};
|
|
4316
|
+
}
|
|
4317
|
+
|
|
4180
4318
|
// src/utils/module-loader.ts
|
|
4181
4319
|
import { createRequire } from "module";
|
|
4182
4320
|
import { pathToFileURL } from "url";
|
|
4183
|
-
import { logger as
|
|
4184
|
-
import
|
|
4185
|
-
import { existsSync as
|
|
4321
|
+
import { logger as logger20 } from "@elizaos/core";
|
|
4322
|
+
import path19 from "path";
|
|
4323
|
+
import { existsSync as existsSync16 } from "fs";
|
|
4186
4324
|
var ModuleLoader = class {
|
|
4187
4325
|
require;
|
|
4188
4326
|
cache = /* @__PURE__ */ new Map();
|
|
4189
4327
|
projectPath;
|
|
4190
|
-
constructor(projectPath
|
|
4191
|
-
this.projectPath = projectPath;
|
|
4192
|
-
this.require = createRequire(pathToFileURL(projectPath + "/package.json").href);
|
|
4328
|
+
constructor(projectPath) {
|
|
4329
|
+
this.projectPath = projectPath || this.detectProjectPath();
|
|
4330
|
+
this.require = createRequire(pathToFileURL(this.projectPath + "/package.json").href);
|
|
4193
4331
|
this.setupEnvironment();
|
|
4194
4332
|
}
|
|
4333
|
+
/**
|
|
4334
|
+
* Detect the appropriate project path, preferring monorepo root over current working directory
|
|
4335
|
+
*/
|
|
4336
|
+
detectProjectPath() {
|
|
4337
|
+
const monorepoRoot = UserEnvironment.getInstance().findMonorepoRoot(process.cwd());
|
|
4338
|
+
if (monorepoRoot) {
|
|
4339
|
+
logger20.debug(`Using monorepo root: ${monorepoRoot}`);
|
|
4340
|
+
return monorepoRoot;
|
|
4341
|
+
}
|
|
4342
|
+
logger20.debug(`Using current working directory: ${process.cwd()}`);
|
|
4343
|
+
return process.cwd();
|
|
4344
|
+
}
|
|
4195
4345
|
/**
|
|
4196
4346
|
* Load a module from the project's node_modules directory.
|
|
4197
4347
|
* Uses caching to ensure the same instance is returned for repeated calls.
|
|
@@ -4202,31 +4352,31 @@ var ModuleLoader = class {
|
|
|
4202
4352
|
*/
|
|
4203
4353
|
async load(moduleName) {
|
|
4204
4354
|
if (this.cache.has(moduleName)) {
|
|
4205
|
-
|
|
4355
|
+
logger20.debug(`Using cached module: ${moduleName}`);
|
|
4206
4356
|
return this.cache.get(moduleName);
|
|
4207
4357
|
}
|
|
4208
4358
|
try {
|
|
4209
|
-
const localModulePath =
|
|
4210
|
-
const isLocalModule =
|
|
4359
|
+
const localModulePath = path19.join(this.projectPath, "node_modules", moduleName);
|
|
4360
|
+
const isLocalModule = existsSync16(localModulePath);
|
|
4211
4361
|
if (isLocalModule) {
|
|
4212
|
-
|
|
4362
|
+
logger20.info(`Using local ${moduleName} installation`);
|
|
4213
4363
|
} else {
|
|
4214
|
-
|
|
4364
|
+
logger20.info(`Using global ${moduleName} installation`);
|
|
4215
4365
|
}
|
|
4216
4366
|
const modulePath = this.require.resolve(moduleName);
|
|
4217
|
-
|
|
4367
|
+
logger20.debug(`Loading ${moduleName} from: ${modulePath}`);
|
|
4218
4368
|
if (isLocalModule && !modulePath.includes(this.projectPath)) {
|
|
4219
|
-
|
|
4369
|
+
logger20.warn(`Expected local module but resolved to global: ${modulePath}`);
|
|
4220
4370
|
}
|
|
4221
4371
|
const module = await import(pathToFileURL(modulePath).href);
|
|
4222
4372
|
this.cache.set(moduleName, module);
|
|
4223
|
-
|
|
4373
|
+
logger20.success(
|
|
4224
4374
|
`Loaded ${moduleName} from ${isLocalModule ? "local" : "global"} installation`
|
|
4225
4375
|
);
|
|
4226
4376
|
return module;
|
|
4227
4377
|
} catch (error) {
|
|
4228
4378
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4229
|
-
|
|
4379
|
+
logger20.error(`Failed to load module ${moduleName}: ${errorMessage}`);
|
|
4230
4380
|
throw new Error(
|
|
4231
4381
|
`Cannot find module '${moduleName}' in project at ${this.projectPath}.
|
|
4232
4382
|
Please ensure it's installed by running:
|
|
@@ -4241,18 +4391,18 @@ Original error: ${errorMessage}`
|
|
|
4241
4391
|
* This ensures the same local-first guarantees as server-manager.ts.
|
|
4242
4392
|
*/
|
|
4243
4393
|
setupEnvironment() {
|
|
4244
|
-
const localModulesPath =
|
|
4245
|
-
if (
|
|
4394
|
+
const localModulesPath = path19.join(this.projectPath, "node_modules");
|
|
4395
|
+
if (existsSync16(localModulesPath)) {
|
|
4246
4396
|
if (process.env.NODE_PATH) {
|
|
4247
|
-
process.env.NODE_PATH = `${localModulesPath}${
|
|
4397
|
+
process.env.NODE_PATH = `${localModulesPath}${path19.delimiter}${process.env.NODE_PATH}`;
|
|
4248
4398
|
} else {
|
|
4249
4399
|
process.env.NODE_PATH = localModulesPath;
|
|
4250
4400
|
}
|
|
4251
4401
|
}
|
|
4252
|
-
const localBinPath =
|
|
4253
|
-
if (
|
|
4402
|
+
const localBinPath = path19.join(this.projectPath, "node_modules", ".bin");
|
|
4403
|
+
if (existsSync16(localBinPath)) {
|
|
4254
4404
|
if (process.env.PATH) {
|
|
4255
|
-
process.env.PATH = `${localBinPath}${
|
|
4405
|
+
process.env.PATH = `${localBinPath}${path19.delimiter}${process.env.PATH}`;
|
|
4256
4406
|
} else {
|
|
4257
4407
|
process.env.PATH = localBinPath;
|
|
4258
4408
|
}
|
|
@@ -4308,22 +4458,22 @@ async function findNextAvailablePort(startPort) {
|
|
|
4308
4458
|
}
|
|
4309
4459
|
|
|
4310
4460
|
// src/utils/publisher.ts
|
|
4311
|
-
import { logger as
|
|
4461
|
+
import { logger as logger21 } from "@elizaos/core";
|
|
4312
4462
|
async function testPublishToNpm(cwd) {
|
|
4313
4463
|
try {
|
|
4314
4464
|
await bunExec("npm", ["whoami"]);
|
|
4315
|
-
|
|
4316
|
-
|
|
4465
|
+
logger21.info("[\u2713] Logged in to npm");
|
|
4466
|
+
logger21.info("Testing build...");
|
|
4317
4467
|
await bunExec("npm", ["run", "build", "--dry-run"], { cwd });
|
|
4318
|
-
|
|
4468
|
+
logger21.info("[\u2713] Build test successful");
|
|
4319
4469
|
await bunExec("npm", ["access", "ls-packages"], { cwd });
|
|
4320
|
-
|
|
4470
|
+
logger21.info("[\u2713] Have publish permissions");
|
|
4321
4471
|
return true;
|
|
4322
4472
|
} catch (error) {
|
|
4323
|
-
|
|
4473
|
+
logger21.error("Test failed:", error);
|
|
4324
4474
|
if (error instanceof Error) {
|
|
4325
|
-
|
|
4326
|
-
|
|
4475
|
+
logger21.error(`Error message: ${error.message}`);
|
|
4476
|
+
logger21.error(`Error stack: ${error.stack}`);
|
|
4327
4477
|
}
|
|
4328
4478
|
return false;
|
|
4329
4479
|
}
|
|
@@ -4332,53 +4482,53 @@ async function testPublishToGitHub(packageJson, username) {
|
|
|
4332
4482
|
try {
|
|
4333
4483
|
const credentials = await getGitHubCredentials();
|
|
4334
4484
|
if (!credentials) {
|
|
4335
|
-
|
|
4485
|
+
logger21.error("Failed to get GitHub credentials");
|
|
4336
4486
|
return false;
|
|
4337
4487
|
}
|
|
4338
4488
|
const token = credentials.token;
|
|
4339
|
-
|
|
4489
|
+
logger21.info("[\u2713] GitHub credentials found");
|
|
4340
4490
|
const response = await fetch("https://api.github.com/user", {
|
|
4341
4491
|
headers: { Authorization: `token ${token}` }
|
|
4342
4492
|
});
|
|
4343
4493
|
if (!response.ok) {
|
|
4344
|
-
|
|
4494
|
+
logger21.error("Invalid GitHub token or insufficient permissions");
|
|
4345
4495
|
return false;
|
|
4346
4496
|
}
|
|
4347
|
-
|
|
4497
|
+
logger21.info("[\u2713] GitHub token is valid");
|
|
4348
4498
|
if (packageJson.packageType === "project") {
|
|
4349
|
-
|
|
4499
|
+
logger21.info("[\u2713] Project validation complete - GitHub token is valid");
|
|
4350
4500
|
return true;
|
|
4351
4501
|
}
|
|
4352
4502
|
const settings = await getRegistrySettings();
|
|
4353
4503
|
const [registryOwner, registryRepo] = settings.defaultRegistry.split("/");
|
|
4354
|
-
|
|
4504
|
+
logger21.info(`Testing with registry: ${registryOwner}/${registryRepo}`);
|
|
4355
4505
|
const hasFork = await forkExists(token, registryRepo, username);
|
|
4356
|
-
|
|
4506
|
+
logger21.info(hasFork ? "[\u2713] Fork exists" : "[\u2713] Can create fork");
|
|
4357
4507
|
if (!hasFork) {
|
|
4358
|
-
|
|
4508
|
+
logger21.info("Creating fork...");
|
|
4359
4509
|
const forkCreated = await forkRepository(token, registryOwner, registryRepo);
|
|
4360
4510
|
if (!forkCreated) {
|
|
4361
|
-
|
|
4511
|
+
logger21.error("Failed to create fork");
|
|
4362
4512
|
return false;
|
|
4363
4513
|
}
|
|
4364
|
-
|
|
4514
|
+
logger21.info("[\u2713] Fork created");
|
|
4365
4515
|
await new Promise((resolve2) => setTimeout(resolve2, 3e3));
|
|
4366
4516
|
}
|
|
4367
4517
|
const branchName = `test-${packageJson.name.replace(/^@[^/]+\//, "")}-${packageJson.version}`;
|
|
4368
4518
|
const hasBranch = await branchExists(token, username, registryRepo, branchName);
|
|
4369
|
-
|
|
4519
|
+
logger21.info(hasBranch ? "[\u2713] Test branch exists" : "[\u2713] Can create branch");
|
|
4370
4520
|
if (!hasBranch) {
|
|
4371
|
-
|
|
4521
|
+
logger21.info("Creating branch...");
|
|
4372
4522
|
const branchCreated = await createBranch(token, username, registryRepo, branchName, "main");
|
|
4373
4523
|
if (!branchCreated) {
|
|
4374
|
-
|
|
4524
|
+
logger21.error("Failed to create branch");
|
|
4375
4525
|
return false;
|
|
4376
4526
|
}
|
|
4377
|
-
|
|
4527
|
+
logger21.info("[\u2713] Branch created");
|
|
4378
4528
|
}
|
|
4379
4529
|
const simpleName = packageJson.name.replace(/^@[^/]+\//, "").replace(/[^a-zA-Z0-9-]/g, "-");
|
|
4380
4530
|
const testPath = `test-files/${simpleName}-test.json`;
|
|
4381
|
-
|
|
4531
|
+
logger21.info(`Attempting to create test file: ${testPath} in branch: ${branchName}`);
|
|
4382
4532
|
const dirCreated = await ensureDirectory(
|
|
4383
4533
|
token,
|
|
4384
4534
|
`${username}/${registryRepo}`,
|
|
@@ -4386,7 +4536,7 @@ async function testPublishToGitHub(packageJson, username) {
|
|
|
4386
4536
|
branchName
|
|
4387
4537
|
);
|
|
4388
4538
|
if (!dirCreated) {
|
|
4389
|
-
|
|
4539
|
+
logger21.warn("Failed to create test directory, but continuing with file creation");
|
|
4390
4540
|
}
|
|
4391
4541
|
const canUpdate = await updateFile(
|
|
4392
4542
|
token,
|
|
@@ -4399,53 +4549,53 @@ async function testPublishToGitHub(packageJson, username) {
|
|
|
4399
4549
|
// Use the test branch instead of main
|
|
4400
4550
|
);
|
|
4401
4551
|
if (!canUpdate) {
|
|
4402
|
-
|
|
4552
|
+
logger21.error("Cannot update files in repository");
|
|
4403
4553
|
return false;
|
|
4404
4554
|
}
|
|
4405
|
-
|
|
4555
|
+
logger21.info("[\u2713] Can create and update files");
|
|
4406
4556
|
return true;
|
|
4407
4557
|
} catch (error) {
|
|
4408
|
-
|
|
4558
|
+
logger21.error("Test failed:", error);
|
|
4409
4559
|
return false;
|
|
4410
4560
|
}
|
|
4411
4561
|
}
|
|
4412
4562
|
async function publishToNpm(cwd) {
|
|
4413
4563
|
try {
|
|
4414
4564
|
await bunExec("npm", ["whoami"]);
|
|
4415
|
-
|
|
4565
|
+
logger21.info("Building package...");
|
|
4416
4566
|
await bunExecInherit("npm", ["run", "build"], { cwd });
|
|
4417
|
-
|
|
4567
|
+
logger21.info("Publishing to npm...");
|
|
4418
4568
|
await bunExecInherit("npm", ["publish"], { cwd });
|
|
4419
4569
|
return true;
|
|
4420
4570
|
} catch (error) {
|
|
4421
|
-
|
|
4571
|
+
logger21.error("Failed to publish to npm:", error);
|
|
4422
4572
|
return false;
|
|
4423
4573
|
}
|
|
4424
4574
|
}
|
|
4425
4575
|
async function publishToGitHub(cwd, packageJson, username, skipRegistry = false, isTest = false) {
|
|
4426
4576
|
const credentials = await getGitHubCredentials();
|
|
4427
4577
|
if (!credentials) {
|
|
4428
|
-
|
|
4578
|
+
logger21.error("Failed to get GitHub credentials");
|
|
4429
4579
|
return false;
|
|
4430
4580
|
}
|
|
4431
4581
|
const token = credentials.token;
|
|
4432
4582
|
if (!packageJson.packageType) {
|
|
4433
|
-
|
|
4583
|
+
logger21.error(
|
|
4434
4584
|
'Package type is required. Set "packageType" to either "plugin" or "project" in package.json'
|
|
4435
4585
|
);
|
|
4436
4586
|
return false;
|
|
4437
4587
|
}
|
|
4438
4588
|
if (packageJson.packageType !== "plugin" && packageJson.packageType !== "project") {
|
|
4439
|
-
|
|
4589
|
+
logger21.error(
|
|
4440
4590
|
`Invalid package type: ${packageJson.packageType}. Must be either "plugin" or "project"`
|
|
4441
4591
|
);
|
|
4442
4592
|
return false;
|
|
4443
4593
|
}
|
|
4444
4594
|
if (isTest) {
|
|
4445
|
-
|
|
4595
|
+
logger21.info("Running in test mode - no actual changes will be made");
|
|
4446
4596
|
}
|
|
4447
4597
|
if (skipRegistry) {
|
|
4448
|
-
|
|
4598
|
+
logger21.info("Registry updates will be skipped as requested with --skip-registry flag");
|
|
4449
4599
|
}
|
|
4450
4600
|
if (!isTest) {
|
|
4451
4601
|
const repoName = packageJson.name.replace(/^@[^/]+\//, "");
|
|
@@ -4458,24 +4608,24 @@ async function publishToGitHub(cwd, packageJson, username, skipRegistry = false,
|
|
|
4458
4608
|
} else {
|
|
4459
4609
|
topic = "elizaos-plugins";
|
|
4460
4610
|
}
|
|
4461
|
-
|
|
4611
|
+
logger21.info(`Checking/creating GitHub repository: ${username}/${repoName}`);
|
|
4462
4612
|
const repoResult = await createGitHubRepository(token, repoName, description, false, [topic]);
|
|
4463
4613
|
if (!repoResult.success) {
|
|
4464
|
-
|
|
4614
|
+
logger21.error(`Failed to create GitHub repository: ${repoResult.message}`);
|
|
4465
4615
|
return false;
|
|
4466
4616
|
}
|
|
4467
|
-
|
|
4617
|
+
logger21.info(`Using repository: ${repoResult.repoUrl}`);
|
|
4468
4618
|
const repoUrl = `https://${token}@github.com/${username}/${repoName}.git`;
|
|
4469
|
-
|
|
4619
|
+
logger21.info("Pushing code to GitHub...");
|
|
4470
4620
|
const pushSuccess = await pushToGitHub(cwd, repoUrl);
|
|
4471
4621
|
if (!pushSuccess) {
|
|
4472
|
-
|
|
4622
|
+
logger21.error("Failed to push code to GitHub repository.");
|
|
4473
4623
|
return false;
|
|
4474
4624
|
}
|
|
4475
|
-
|
|
4625
|
+
logger21.success("Successfully pushed code to GitHub repository");
|
|
4476
4626
|
if (packageJson.packageType === "project" || skipRegistry) {
|
|
4477
4627
|
const reason = packageJson.packageType === "project" ? "Projects do not need registry updates" : "Registry updates skipped as requested with --skip-registry flag";
|
|
4478
|
-
|
|
4628
|
+
logger21.info(`${packageJson.name} published to GitHub successfully. ${reason}`);
|
|
4479
4629
|
return {
|
|
4480
4630
|
success: true,
|
|
4481
4631
|
prUrl: repoResult.repoUrl
|
|
@@ -4484,7 +4634,7 @@ async function publishToGitHub(cwd, packageJson, username, skipRegistry = false,
|
|
|
4484
4634
|
}
|
|
4485
4635
|
if (packageJson.packageType === "project" || skipRegistry) {
|
|
4486
4636
|
if (isTest) {
|
|
4487
|
-
|
|
4637
|
+
logger21.info("Test successful - project would be published to GitHub only");
|
|
4488
4638
|
}
|
|
4489
4639
|
return true;
|
|
4490
4640
|
}
|
|
@@ -4493,33 +4643,33 @@ async function publishToGitHub(cwd, packageJson, username, skipRegistry = false,
|
|
|
4493
4643
|
const hasFork = await forkExists(token, registryRepo, username);
|
|
4494
4644
|
let forkFullName;
|
|
4495
4645
|
if (!hasFork && !isTest) {
|
|
4496
|
-
|
|
4646
|
+
logger21.info(`Creating fork of ${settings.defaultRegistry}...`);
|
|
4497
4647
|
const fork = await forkRepository(token, registryOwner, registryRepo);
|
|
4498
4648
|
if (!fork) {
|
|
4499
|
-
|
|
4649
|
+
logger21.error("Failed to fork registry repository.");
|
|
4500
4650
|
return false;
|
|
4501
4651
|
}
|
|
4502
4652
|
forkFullName = fork;
|
|
4503
4653
|
await new Promise((resolve2) => setTimeout(resolve2, 2e3));
|
|
4504
4654
|
} else {
|
|
4505
4655
|
forkFullName = `${username}/${registryRepo}`;
|
|
4506
|
-
|
|
4656
|
+
logger21.info(`Using existing fork: ${forkFullName}`);
|
|
4507
4657
|
}
|
|
4508
4658
|
const entityType = packageJson.packageType;
|
|
4509
4659
|
const packageNameWithoutScope = packageJson.name.replace(/^@[^/]+\//, "");
|
|
4510
4660
|
let branchName;
|
|
4511
4661
|
if (entityType === "plugin" && packageNameWithoutScope.startsWith("plugin-")) {
|
|
4512
4662
|
branchName = `${packageNameWithoutScope}-${packageJson.version}`;
|
|
4513
|
-
|
|
4663
|
+
logger21.info(`Using package name directly to avoid duplicate plugin prefix: ${branchName}`);
|
|
4514
4664
|
} else {
|
|
4515
4665
|
branchName = `${entityType}-${packageNameWithoutScope}-${packageJson.version}`;
|
|
4516
4666
|
}
|
|
4517
4667
|
const hasBranch = await branchExists(token, username, registryRepo, branchName);
|
|
4518
4668
|
if (!hasBranch && !isTest) {
|
|
4519
|
-
|
|
4669
|
+
logger21.info(`Creating branch ${branchName}...`);
|
|
4520
4670
|
const created = await createBranch(token, username, registryRepo, branchName);
|
|
4521
4671
|
if (!created) {
|
|
4522
|
-
|
|
4672
|
+
logger21.error("Failed to create branch.");
|
|
4523
4673
|
return false;
|
|
4524
4674
|
}
|
|
4525
4675
|
}
|
|
@@ -4532,10 +4682,10 @@ async function publishToGitHub(cwd, packageJson, username, skipRegistry = false,
|
|
|
4532
4682
|
const githubRepo = `github:${username}/${packageName}`;
|
|
4533
4683
|
const index = JSON.parse(indexContent);
|
|
4534
4684
|
if (index[registryPackageName]) {
|
|
4535
|
-
|
|
4685
|
+
logger21.warn(`Package ${registryPackageName} already exists in registry`);
|
|
4536
4686
|
return false;
|
|
4537
4687
|
}
|
|
4538
|
-
|
|
4688
|
+
logger21.info(`Adding registry entry: ${registryPackageName} -> ${githubRepo}`);
|
|
4539
4689
|
const lines = indexContent.split("\n");
|
|
4540
4690
|
const newEntry = ` "${registryPackageName}": "${githubRepo}",`;
|
|
4541
4691
|
let insertIndex = -1;
|
|
@@ -4564,7 +4714,7 @@ async function publishToGitHub(cwd, packageJson, username, skipRegistry = false,
|
|
|
4564
4714
|
}
|
|
4565
4715
|
}
|
|
4566
4716
|
if (insertIndex === -1) {
|
|
4567
|
-
|
|
4717
|
+
logger21.error("Could not find insertion point in index.json");
|
|
4568
4718
|
return false;
|
|
4569
4719
|
}
|
|
4570
4720
|
lines.splice(insertIndex, 0, newEntry);
|
|
@@ -4579,15 +4729,15 @@ async function publishToGitHub(cwd, packageJson, username, skipRegistry = false,
|
|
|
4579
4729
|
branchName
|
|
4580
4730
|
);
|
|
4581
4731
|
if (!indexUpdated) {
|
|
4582
|
-
|
|
4732
|
+
logger21.error("Failed to update registry index.");
|
|
4583
4733
|
return false;
|
|
4584
4734
|
}
|
|
4585
4735
|
} else {
|
|
4586
|
-
|
|
4736
|
+
logger21.error("Could not fetch index.json from registry");
|
|
4587
4737
|
return false;
|
|
4588
4738
|
}
|
|
4589
4739
|
} catch (error) {
|
|
4590
|
-
|
|
4740
|
+
logger21.error(
|
|
4591
4741
|
`Failed to update index.json: ${error instanceof Error ? error.message : String(error)}`
|
|
4592
4742
|
);
|
|
4593
4743
|
return false;
|
|
@@ -4609,20 +4759,20 @@ Submitted by: @${username}`,
|
|
|
4609
4759
|
"main"
|
|
4610
4760
|
);
|
|
4611
4761
|
if (!prUrl) {
|
|
4612
|
-
|
|
4762
|
+
logger21.error("Failed to create pull request.");
|
|
4613
4763
|
return false;
|
|
4614
4764
|
}
|
|
4615
|
-
|
|
4765
|
+
logger21.success(`Pull request created: ${prUrl}`);
|
|
4616
4766
|
return {
|
|
4617
4767
|
success: true,
|
|
4618
4768
|
prUrl
|
|
4619
4769
|
};
|
|
4620
4770
|
} else {
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4771
|
+
logger21.info("Test successful - all checks passed");
|
|
4772
|
+
logger21.info("Would create:");
|
|
4773
|
+
logger21.info(`- Branch: ${branchName}`);
|
|
4774
|
+
logger21.info(`- Registry entry: ${registryPackageName} -> github:${username}/${packageName}`);
|
|
4775
|
+
logger21.info(`- Pull request: Add ${registryPackageName} to registry`);
|
|
4626
4776
|
}
|
|
4627
4777
|
return true;
|
|
4628
4778
|
}
|
|
@@ -4637,17 +4787,17 @@ async function resolveImport(importPath, config) {
|
|
|
4637
4787
|
|
|
4638
4788
|
// src/utils/test-runner.ts
|
|
4639
4789
|
import {
|
|
4640
|
-
logger as
|
|
4790
|
+
logger as logger22
|
|
4641
4791
|
} from "@elizaos/core";
|
|
4642
4792
|
import * as fs9 from "fs";
|
|
4643
|
-
import * as
|
|
4793
|
+
import * as path20 from "path";
|
|
4644
4794
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
4645
4795
|
var safeLogger = {
|
|
4646
|
-
debug:
|
|
4647
|
-
info:
|
|
4648
|
-
warn:
|
|
4649
|
-
error:
|
|
4650
|
-
success:
|
|
4796
|
+
debug: logger22?.debug || console.log,
|
|
4797
|
+
info: logger22?.info || console.log,
|
|
4798
|
+
warn: logger22?.warn || console.warn,
|
|
4799
|
+
error: logger22?.error || console.error,
|
|
4800
|
+
success: logger22?.success || console.log
|
|
4651
4801
|
};
|
|
4652
4802
|
var TestRunner = class {
|
|
4653
4803
|
runtime;
|
|
@@ -4824,14 +4974,14 @@ export const myPlugin = {
|
|
|
4824
4974
|
return;
|
|
4825
4975
|
}
|
|
4826
4976
|
try {
|
|
4827
|
-
const e2eDir =
|
|
4977
|
+
const e2eDir = path20.join(process.cwd(), "e2e");
|
|
4828
4978
|
if (!fs9.existsSync(e2eDir)) {
|
|
4829
4979
|
safeLogger.debug("No e2e directory found, skipping e2e tests");
|
|
4830
4980
|
return;
|
|
4831
4981
|
}
|
|
4832
4982
|
safeLogger.info("\nRunning e2e tests...");
|
|
4833
4983
|
const walk = (dir) => fs9.readdirSync(dir, { withFileTypes: true }).flatMap(
|
|
4834
|
-
(entry) => entry.isDirectory() ? walk(
|
|
4984
|
+
(entry) => entry.isDirectory() ? walk(path20.join(dir, entry.name)) : entry.name.match(/\.test\.(t|j)sx?$/) ? [path20.join(dir, entry.name)] : []
|
|
4835
4985
|
);
|
|
4836
4986
|
const testFiles = walk(e2eDir);
|
|
4837
4987
|
if (testFiles.length === 0) {
|
|
@@ -4839,16 +4989,16 @@ export const myPlugin = {
|
|
|
4839
4989
|
return;
|
|
4840
4990
|
}
|
|
4841
4991
|
safeLogger.info(`Found ${testFiles.length} e2e test files`);
|
|
4842
|
-
const distE2eDir =
|
|
4992
|
+
const distE2eDir = path20.join(process.cwd(), "dist", "e2e");
|
|
4843
4993
|
const hasDistE2e = fs9.existsSync(distE2eDir);
|
|
4844
4994
|
for (const testFile of testFiles) {
|
|
4845
4995
|
try {
|
|
4846
|
-
const fileName =
|
|
4847
|
-
const fileNameWithoutExt =
|
|
4996
|
+
const fileName = path20.basename(testFile);
|
|
4997
|
+
const fileNameWithoutExt = path20.basename(testFile, ".test.ts");
|
|
4848
4998
|
safeLogger.info(`Loading test file: ${fileName}`);
|
|
4849
4999
|
let moduleImportPath = testFile;
|
|
4850
5000
|
if (hasDistE2e) {
|
|
4851
|
-
const distFile =
|
|
5001
|
+
const distFile = path20.join(distE2eDir, `${fileNameWithoutExt}.test.js`);
|
|
4852
5002
|
if (fs9.existsSync(distFile)) {
|
|
4853
5003
|
moduleImportPath = distFile;
|
|
4854
5004
|
safeLogger.debug(`Using compiled version from ${distFile}`);
|
|
@@ -4921,11 +5071,11 @@ Test Summary: ${this.stats.passed} passed, ${this.stats.failed} failed, ${this.s
|
|
|
4921
5071
|
};
|
|
4922
5072
|
|
|
4923
5073
|
// src/utils/registry/index.ts
|
|
4924
|
-
import { logger as
|
|
5074
|
+
import { logger as logger23 } from "@elizaos/core";
|
|
4925
5075
|
import dotenv3 from "dotenv";
|
|
4926
5076
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
4927
|
-
import { existsSync as
|
|
4928
|
-
import
|
|
5077
|
+
import { existsSync as existsSync18, promises as fs10 } from "fs";
|
|
5078
|
+
import path21 from "path";
|
|
4929
5079
|
|
|
4930
5080
|
// src/utils/registry/constants.ts
|
|
4931
5081
|
var REGISTRY_ORG = "elizaos-plugins";
|
|
@@ -4936,10 +5086,10 @@ var REGISTRY_GITHUB_URL = `https://github.com/${REGISTRY_REPO}`;
|
|
|
4936
5086
|
var RAW_REGISTRY_URL = REGISTRY_URL;
|
|
4937
5087
|
|
|
4938
5088
|
// src/utils/registry/index.ts
|
|
4939
|
-
var ELIZA_DIR =
|
|
4940
|
-
var REGISTRY_SETTINGS_FILE =
|
|
4941
|
-
var ENV_FILE = resolveEnvFile() ||
|
|
4942
|
-
var REGISTRY_CACHE_FILE =
|
|
5089
|
+
var ELIZA_DIR = path21.join(process.cwd(), ".eliza");
|
|
5090
|
+
var REGISTRY_SETTINGS_FILE = path21.join(ELIZA_DIR, "registrysettings.json");
|
|
5091
|
+
var ENV_FILE = resolveEnvFile() || path21.join(ELIZA_DIR, ".env");
|
|
5092
|
+
var REGISTRY_CACHE_FILE = path21.join(ELIZA_DIR, "registry-cache.json");
|
|
4943
5093
|
var REQUIRED_ENV_VARS = ["GITHUB_TOKEN"];
|
|
4944
5094
|
var REQUIRED_SETTINGS = ["defaultRegistry"];
|
|
4945
5095
|
async function ensureElizaDir2() {
|
|
@@ -4987,19 +5137,19 @@ async function setEnvVar(key, value) {
|
|
|
4987
5137
|
async function getGitHubToken() {
|
|
4988
5138
|
try {
|
|
4989
5139
|
const envPath = resolveEnvFile();
|
|
4990
|
-
if (envPath &&
|
|
5140
|
+
if (envPath && existsSync18(envPath)) {
|
|
4991
5141
|
const envContent = await fs10.readFile(envPath, "utf-8");
|
|
4992
5142
|
const env = dotenv3.parse(envContent);
|
|
4993
5143
|
return env.GITHUB_TOKEN;
|
|
4994
5144
|
}
|
|
4995
|
-
const globalEnvPath =
|
|
4996
|
-
if (
|
|
5145
|
+
const globalEnvPath = path21.join(ELIZA_DIR, ".env");
|
|
5146
|
+
if (existsSync18(globalEnvPath) && globalEnvPath !== envPath) {
|
|
4997
5147
|
const envContent = await fs10.readFile(globalEnvPath, "utf-8");
|
|
4998
5148
|
const env = dotenv3.parse(envContent);
|
|
4999
5149
|
return env.GITHUB_TOKEN;
|
|
5000
5150
|
}
|
|
5001
5151
|
} catch (error) {
|
|
5002
|
-
|
|
5152
|
+
logger23.debug(
|
|
5003
5153
|
`Error reading GitHub token: ${error instanceof Error ? error.message : String(error)}`
|
|
5004
5154
|
);
|
|
5005
5155
|
}
|
|
@@ -5010,7 +5160,7 @@ async function setGitHubToken(token) {
|
|
|
5010
5160
|
try {
|
|
5011
5161
|
let envContent = "";
|
|
5012
5162
|
try {
|
|
5013
|
-
if (
|
|
5163
|
+
if (existsSync18(ENV_FILE)) {
|
|
5014
5164
|
envContent = await fs10.readFile(ENV_FILE, "utf-8");
|
|
5015
5165
|
}
|
|
5016
5166
|
} catch (error) {
|
|
@@ -5025,9 +5175,9 @@ async function setGitHubToken(token) {
|
|
|
5025
5175
|
}
|
|
5026
5176
|
await fs10.writeFile(ENV_FILE, newContent);
|
|
5027
5177
|
process.env.GITHUB_TOKEN = token;
|
|
5028
|
-
|
|
5178
|
+
logger23.debug("GitHub token saved successfully");
|
|
5029
5179
|
} catch (error) {
|
|
5030
|
-
|
|
5180
|
+
logger23.error(
|
|
5031
5181
|
`Failed to save GitHub token: ${error instanceof Error ? error.message : String(error)}`
|
|
5032
5182
|
);
|
|
5033
5183
|
}
|
|
@@ -5070,16 +5220,16 @@ async function saveRegistryCache(registry) {
|
|
|
5070
5220
|
try {
|
|
5071
5221
|
await ensureElizaDir2();
|
|
5072
5222
|
await fs10.writeFile(REGISTRY_CACHE_FILE, JSON.stringify(registry, null, 2));
|
|
5073
|
-
|
|
5223
|
+
logger23.debug("Registry cache saved successfully");
|
|
5074
5224
|
} catch (error) {
|
|
5075
|
-
|
|
5225
|
+
logger23.debug(
|
|
5076
5226
|
`Failed to save registry cache: ${error instanceof Error ? error.message : String(error)}`
|
|
5077
5227
|
);
|
|
5078
5228
|
}
|
|
5079
5229
|
}
|
|
5080
5230
|
async function getLocalRegistryIndex() {
|
|
5081
5231
|
try {
|
|
5082
|
-
|
|
5232
|
+
logger23.debug("Fetching registry from public GitHub URL");
|
|
5083
5233
|
const response = await fetch(RAW_REGISTRY_URL);
|
|
5084
5234
|
if (response.ok) {
|
|
5085
5235
|
const rawData = await response.json();
|
|
@@ -5091,24 +5241,24 @@ async function getLocalRegistryIndex() {
|
|
|
5091
5241
|
}
|
|
5092
5242
|
}
|
|
5093
5243
|
await saveRegistryCache(result);
|
|
5094
|
-
|
|
5244
|
+
logger23.debug("Successfully fetched registry from public GitHub URL");
|
|
5095
5245
|
return result;
|
|
5096
5246
|
}
|
|
5097
5247
|
}
|
|
5098
5248
|
} catch (error) {
|
|
5099
|
-
|
|
5249
|
+
logger23.debug(
|
|
5100
5250
|
`Failed to fetch registry from public URL: ${error instanceof Error ? error.message : String(error)}`
|
|
5101
5251
|
);
|
|
5102
5252
|
}
|
|
5103
5253
|
try {
|
|
5104
|
-
if (
|
|
5254
|
+
if (existsSync18(REGISTRY_CACHE_FILE)) {
|
|
5105
5255
|
const cacheContent = await fs10.readFile(REGISTRY_CACHE_FILE, "utf-8");
|
|
5106
5256
|
const cachedRegistry = JSON.parse(cacheContent);
|
|
5107
|
-
|
|
5257
|
+
logger23.debug("Using cached registry index");
|
|
5108
5258
|
return cachedRegistry;
|
|
5109
5259
|
}
|
|
5110
5260
|
} catch (error) {
|
|
5111
|
-
|
|
5261
|
+
logger23.debug(
|
|
5112
5262
|
`Failed to read registry cache: ${error instanceof Error ? error.message : String(error)}`
|
|
5113
5263
|
);
|
|
5114
5264
|
}
|
|
@@ -5125,7 +5275,7 @@ async function getLocalRegistryIndex() {
|
|
|
5125
5275
|
}
|
|
5126
5276
|
return { ...DEFAULT_REGISTRY, ...localRegistry };
|
|
5127
5277
|
} catch (error) {
|
|
5128
|
-
|
|
5278
|
+
logger23.debug(
|
|
5129
5279
|
`Failed to discover local plugins: ${error instanceof Error ? error.message : String(error)}`
|
|
5130
5280
|
);
|
|
5131
5281
|
}
|
|
@@ -5136,7 +5286,7 @@ async function getRegistryIndex() {
|
|
|
5136
5286
|
const settings = await getRegistrySettings();
|
|
5137
5287
|
const credentials = await getGitHubCredentials();
|
|
5138
5288
|
if (!credentials) {
|
|
5139
|
-
|
|
5289
|
+
logger23.error("GitHub credentials not found. Please run login first.");
|
|
5140
5290
|
process.exit(1);
|
|
5141
5291
|
}
|
|
5142
5292
|
const [owner, repo] = settings.defaultRegistry.split("/");
|
|
@@ -5193,7 +5343,7 @@ async function getPluginRepository(pluginName) {
|
|
|
5193
5343
|
const registry = await getLocalRegistryIndex();
|
|
5194
5344
|
for (const name of possibleNames) {
|
|
5195
5345
|
if (registry[name]) {
|
|
5196
|
-
|
|
5346
|
+
logger23.debug(`Found plugin in registry as: ${name}`);
|
|
5197
5347
|
return registry[name];
|
|
5198
5348
|
}
|
|
5199
5349
|
}
|
|
@@ -5206,7 +5356,7 @@ async function getPluginRepository(pluginName) {
|
|
|
5206
5356
|
}
|
|
5207
5357
|
return null;
|
|
5208
5358
|
} catch (error) {
|
|
5209
|
-
|
|
5359
|
+
logger23.debug(
|
|
5210
5360
|
`Error getting plugin repository: ${error instanceof Error ? error.message : String(error)}`
|
|
5211
5361
|
);
|
|
5212
5362
|
return null;
|
|
@@ -5217,7 +5367,7 @@ async function repoHasBranch(repoUrl, branchName) {
|
|
|
5217
5367
|
const { stdout } = await bunExecSimple("git", ["ls-remote", "--heads", repoUrl, branchName]);
|
|
5218
5368
|
return stdout.includes(branchName);
|
|
5219
5369
|
} catch (error) {
|
|
5220
|
-
|
|
5370
|
+
logger23.warn(
|
|
5221
5371
|
`Failed to check for branch ${branchName} in ${repoUrl}: ${error instanceof Error ? error.message : String(error)}`
|
|
5222
5372
|
);
|
|
5223
5373
|
return false;
|
|
@@ -5240,7 +5390,7 @@ async function getPluginMetadata(pluginName) {
|
|
|
5240
5390
|
const settings = await getRegistrySettings();
|
|
5241
5391
|
const credentials = await getGitHubCredentials();
|
|
5242
5392
|
if (!credentials) {
|
|
5243
|
-
|
|
5393
|
+
logger23.error("GitHub credentials not found. Please run login first.");
|
|
5244
5394
|
process.exit(1);
|
|
5245
5395
|
}
|
|
5246
5396
|
const [owner, repo] = settings.defaultRegistry.split("/");
|
|
@@ -5269,7 +5419,7 @@ async function getPluginMetadata(pluginName) {
|
|
|
5269
5419
|
}
|
|
5270
5420
|
return metadata;
|
|
5271
5421
|
} catch (error) {
|
|
5272
|
-
|
|
5422
|
+
logger23.error("Failed to fetch plugin metadata:", error);
|
|
5273
5423
|
return null;
|
|
5274
5424
|
}
|
|
5275
5425
|
}
|
|
@@ -5283,7 +5433,7 @@ async function getPluginVersion(pluginName, version) {
|
|
|
5283
5433
|
return packageDetails.latestVersion;
|
|
5284
5434
|
}
|
|
5285
5435
|
} catch (error) {
|
|
5286
|
-
|
|
5436
|
+
logger23.debug(
|
|
5287
5437
|
`Error getting package details: ${error instanceof Error ? error.message : String(error)}`
|
|
5288
5438
|
);
|
|
5289
5439
|
}
|
|
@@ -5317,11 +5467,11 @@ async function getPackageDetails(packageName) {
|
|
|
5317
5467
|
try {
|
|
5318
5468
|
return JSON.parse(text4);
|
|
5319
5469
|
} catch {
|
|
5320
|
-
|
|
5470
|
+
logger23.warn(`Invalid JSON response received from registry for package ${packageName}:`, text4);
|
|
5321
5471
|
return null;
|
|
5322
5472
|
}
|
|
5323
5473
|
} catch (error) {
|
|
5324
|
-
|
|
5474
|
+
logger23.warn(
|
|
5325
5475
|
`Failed to fetch package details from registry: ${error instanceof Error ? error.message : String(error)}`
|
|
5326
5476
|
);
|
|
5327
5477
|
return null;
|
|
@@ -5338,14 +5488,14 @@ async function getBestPluginVersion(packageName, runtimeVersion) {
|
|
|
5338
5488
|
const [runtimeMajor, runtimeMinor] = runtimeVersion.split(".").map(Number);
|
|
5339
5489
|
const [packageMajor, packageMinor] = packageDetails.runtimeVersion.split(".").map(Number);
|
|
5340
5490
|
if (runtimeMajor !== packageMajor) {
|
|
5341
|
-
|
|
5491
|
+
logger23.warn(
|
|
5342
5492
|
`Plugin ${packageName} was built for runtime v${packageDetails.runtimeVersion}, but you're using v${runtimeVersion}`
|
|
5343
5493
|
);
|
|
5344
|
-
|
|
5494
|
+
logger23.warn("This may cause compatibility issues.");
|
|
5345
5495
|
return packageDetails.latestVersion;
|
|
5346
5496
|
}
|
|
5347
5497
|
if (runtimeMinor !== packageMinor) {
|
|
5348
|
-
|
|
5498
|
+
logger23.warn(
|
|
5349
5499
|
`Plugin ${packageName} was built for runtime v${packageDetails.runtimeVersion}, you're using v${runtimeVersion}`
|
|
5350
5500
|
);
|
|
5351
5501
|
}
|
|
@@ -5407,7 +5557,7 @@ async function initializeDataDir() {
|
|
|
5407
5557
|
async function validateDataDir() {
|
|
5408
5558
|
const status = await checkDataDir();
|
|
5409
5559
|
if (!status.exists) {
|
|
5410
|
-
|
|
5560
|
+
logger23.warn("ElizaOS data directory not found. Initializing...");
|
|
5411
5561
|
await initializeDataDir();
|
|
5412
5562
|
return false;
|
|
5413
5563
|
}
|
|
@@ -5417,22 +5567,22 @@ async function validateDataDir() {
|
|
|
5417
5567
|
const envContent = await fs10.readFile(envPath, "utf-8");
|
|
5418
5568
|
const parsedEnv = dotenv3.parse(envContent);
|
|
5419
5569
|
if (!parsedEnv.GITHUB_TOKEN) {
|
|
5420
|
-
|
|
5570
|
+
logger23.warn("GitHub token not found in environment");
|
|
5421
5571
|
isValid = false;
|
|
5422
5572
|
}
|
|
5423
5573
|
} else {
|
|
5424
|
-
|
|
5574
|
+
logger23.warn(".env file not found");
|
|
5425
5575
|
isValid = false;
|
|
5426
5576
|
}
|
|
5427
5577
|
if (!status.env.hasAllKeys) {
|
|
5428
|
-
|
|
5578
|
+
logger23.warn(`Missing environment variables: ${status.env.missingKeys.join(", ")}`);
|
|
5429
5579
|
isValid = false;
|
|
5430
5580
|
}
|
|
5431
5581
|
if (!status.settings.exists) {
|
|
5432
|
-
|
|
5582
|
+
logger23.warn("Registry settings file not found");
|
|
5433
5583
|
isValid = false;
|
|
5434
5584
|
} else if (!status.settings.hasAllKeys) {
|
|
5435
|
-
|
|
5585
|
+
logger23.warn(`Missing settings: ${status.settings.missingKeys.join(", ")}`);
|
|
5436
5586
|
isValid = false;
|
|
5437
5587
|
}
|
|
5438
5588
|
return isValid;
|
|
@@ -5570,6 +5720,9 @@ export {
|
|
|
5570
5720
|
executeInstallationWithFallback,
|
|
5571
5721
|
fetchPluginRegistry,
|
|
5572
5722
|
installPlugin,
|
|
5723
|
+
tryDelegateToLocalCli,
|
|
5724
|
+
hasLocalCli,
|
|
5725
|
+
getCliContext,
|
|
5573
5726
|
ModuleLoader,
|
|
5574
5727
|
getModuleLoader,
|
|
5575
5728
|
loadModule,
|