agentsmesh 0.14.0 → 0.15.0
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/CHANGELOG.md +6 -0
- package/README.md +26 -1
- package/dist/cli.js +112 -112
- package/dist/engine.js +23 -3
- package/dist/engine.js.map +1 -1
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { stringify, parse } from 'yaml';
|
|
3
3
|
import { access, readdir, readFile, realpath, stat, rm, mkdir, lstat, unlink, writeFile, rename } from 'fs/promises';
|
|
4
4
|
import { join, basename, dirname, relative, win32, posix, resolve, extname } from 'path';
|
|
5
|
-
import { constants, existsSync, realpathSync, statSync } from 'fs';
|
|
5
|
+
import { constants, existsSync, realpathSync, statSync, readFileSync } from 'fs';
|
|
6
6
|
import { parse as parse$1 } from 'smol-toml';
|
|
7
7
|
import { Buffer } from 'buffer';
|
|
8
8
|
import { homedir } from 'os';
|
|
@@ -17218,15 +17218,35 @@ async function loadCanonicalWithExtends(config, configDir, options = {}, canonic
|
|
|
17218
17218
|
// src/plugins/load-plugin.ts
|
|
17219
17219
|
init_target_descriptor_schema();
|
|
17220
17220
|
init_registry();
|
|
17221
|
+
function resolveNpmSpecifier(source, projectRoot) {
|
|
17222
|
+
const pkgDir = join(projectRoot, "node_modules", source);
|
|
17223
|
+
const pkgJsonPath = join(pkgDir, "package.json");
|
|
17224
|
+
if (!existsSync(pkgJsonPath)) {
|
|
17225
|
+
throw new Error(`Cannot find package '${source}' in ${join(projectRoot, "node_modules")}`);
|
|
17226
|
+
}
|
|
17227
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
|
|
17228
|
+
const entry = (typeof pkgJson.exports === "string" ? pkgJson.exports : null) ?? (typeof pkgJson.main === "string" ? pkgJson.main : null) ?? "index.js";
|
|
17229
|
+
const resolved = resolve(pkgDir, entry);
|
|
17230
|
+
if (!existsSync(resolved)) {
|
|
17231
|
+
throw new Error(`Package '${source}' entry '${entry}' does not exist at ${resolved}`);
|
|
17232
|
+
}
|
|
17233
|
+
return resolved;
|
|
17234
|
+
}
|
|
17235
|
+
function isLocalSource(source) {
|
|
17236
|
+
return source.startsWith("file:") || source.startsWith("./") || source.startsWith("../") || source.startsWith("/") || // Windows absolute paths: `D:\foo`, `C:/bar`, etc. `node:path`'s `resolve()` produces
|
|
17237
|
+
// these on win32, and they must not be misinterpreted as bare npm package names.
|
|
17238
|
+
/^[A-Za-z]:[/\\]/.test(source);
|
|
17239
|
+
}
|
|
17221
17240
|
async function importPluginModule(entry, projectRoot) {
|
|
17222
17241
|
const { source } = entry;
|
|
17223
17242
|
let importTarget;
|
|
17224
|
-
if (
|
|
17243
|
+
if (isLocalSource(source)) {
|
|
17225
17244
|
const raw = source.startsWith("file:") ? fileURLToPath(source) : source;
|
|
17226
17245
|
const resolved = resolve(projectRoot, raw);
|
|
17227
17246
|
importTarget = pathToFileURL(resolved).href;
|
|
17228
17247
|
} else {
|
|
17229
|
-
|
|
17248
|
+
const resolved = resolveNpmSpecifier(source, projectRoot);
|
|
17249
|
+
importTarget = pathToFileURL(resolved).href;
|
|
17230
17250
|
}
|
|
17231
17251
|
const mod = await import(importTarget);
|
|
17232
17252
|
return mod;
|