@nextclaw/openclaw-compat 0.3.19 → 0.3.20

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.
Files changed (2) hide show
  1. package/dist/index.js +77 -29
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -1324,6 +1324,23 @@ function loadPluginUiMetadata(params) {
1324
1324
  return toPluginUiMetadata(registry.plugins);
1325
1325
  }
1326
1326
 
1327
+ // src/plugins/plugin-loader-jiti.ts
1328
+ import createJitiImport from "jiti";
1329
+ var createJiti = createJitiImport;
1330
+ function createPluginJiti(aliases) {
1331
+ return createJiti(import.meta.url, {
1332
+ interopDefault: true,
1333
+ esmResolve: true,
1334
+ extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
1335
+ alias: aliases,
1336
+ // Plugin install/upgrade is expected to hot-apply at runtime. Disable
1337
+ // Jiti's persistent/native require cache so a reload always sees the
1338
+ // latest plugin code on disk instead of reusing a stale in-memory module.
1339
+ requireCache: false,
1340
+ cache: false
1341
+ });
1342
+ }
1343
+
1327
1344
  // src/plugins/plugin-loader-aliases.ts
1328
1345
  import fs5 from "fs";
1329
1346
  import path5 from "path";
@@ -1357,6 +1374,31 @@ function resolvePluginSdkAliasFile(params) {
1357
1374
  function resolvePluginSdkAlias() {
1358
1375
  return resolvePluginSdkAliasFile({ srcFile: "index.ts", distFile: "index.js" });
1359
1376
  }
1377
+ function resolvePluginShimFile(relativePath) {
1378
+ try {
1379
+ const modulePath = fileURLToPath(import.meta.url);
1380
+ const isProduction = process.env.NODE_ENV === "production";
1381
+ let cursor = path5.dirname(modulePath);
1382
+ for (let i = 0; i < 6; i += 1) {
1383
+ const srcCandidate = path5.join(cursor, "src", "plugins", "shims", relativePath);
1384
+ const distCandidate = path5.join(cursor, "dist", "plugins", "shims", relativePath.replace(/\.ts$/, ".js"));
1385
+ const candidates = isProduction ? [distCandidate, srcCandidate] : [srcCandidate, distCandidate];
1386
+ for (const candidate of candidates) {
1387
+ if (fs5.existsSync(candidate)) {
1388
+ return candidate;
1389
+ }
1390
+ }
1391
+ const parent = path5.dirname(cursor);
1392
+ if (parent === cursor) {
1393
+ break;
1394
+ }
1395
+ cursor = parent;
1396
+ }
1397
+ } catch {
1398
+ return null;
1399
+ }
1400
+ return null;
1401
+ }
1360
1402
  function collectExportStringValues(value, values) {
1361
1403
  if (typeof value === "string") {
1362
1404
  values.push(value);
@@ -1455,26 +1497,37 @@ function buildScopedPackageAliases(scope, pluginRoot) {
1455
1497
  function buildPluginLoaderAliases(pluginRoot) {
1456
1498
  const aliases = buildScopedPackageAliases("@nextclaw", pluginRoot);
1457
1499
  const pluginSdkAlias = resolvePluginSdkAlias();
1458
- if (pluginSdkAlias) {
1500
+ const shouldUseCompatPluginSdkAlias = shouldAliasHostPackage(pluginRoot, "openclaw");
1501
+ if (pluginSdkAlias && shouldUseCompatPluginSdkAlias) {
1459
1502
  aliases["openclaw/plugin-sdk"] = pluginSdkAlias;
1460
1503
  }
1504
+ const piCodingAgentShim = resolvePluginShimFile("pi-coding-agent.ts");
1505
+ if (piCodingAgentShim) {
1506
+ aliases["@mariozechner/pi-coding-agent"] = piCodingAgentShim;
1507
+ }
1461
1508
  return aliases;
1462
1509
  }
1463
1510
 
1464
- // src/plugins/plugin-loader-jiti.ts
1465
- import createJitiImport from "jiti";
1466
- var createJiti = createJitiImport;
1467
- function createPluginJiti(aliases) {
1468
- return createJiti(import.meta.url, {
1469
- interopDefault: true,
1470
- extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
1471
- alias: aliases,
1472
- // Plugin install/upgrade is expected to hot-apply at runtime. Disable
1473
- // Jiti's persistent/native require cache so a reload always sees the
1474
- // latest plugin code on disk instead of reusing a stale in-memory module.
1475
- requireCache: false,
1476
- cache: false
1477
- });
1511
+ // src/plugins/bundled-plugin-loader.ts
1512
+ function resolveBundledPluginEntry(require2, packageName, diagnostics, resolvePackageRootFromEntry3) {
1513
+ try {
1514
+ const entryFile = require2.resolve(packageName);
1515
+ return {
1516
+ entryFile,
1517
+ rootDir: resolvePackageRootFromEntry3(entryFile)
1518
+ };
1519
+ } catch (err) {
1520
+ diagnostics.push({
1521
+ level: "error",
1522
+ source: packageName,
1523
+ message: `bundled plugin package not resolvable: ${String(err)}`
1524
+ });
1525
+ return null;
1526
+ }
1527
+ }
1528
+ function loadBundledPluginModule(entryFile, rootDir) {
1529
+ const pluginJiti = createPluginJiti(buildPluginLoaderAliases(rootDir));
1530
+ return pluginJiti(entryFile);
1478
1531
  }
1479
1532
 
1480
1533
  // src/plugins/schema-validator.ts
@@ -2081,22 +2134,19 @@ function resolvePluginModuleExport(moduleExport) {
2081
2134
  function appendBundledChannelPlugins(params) {
2082
2135
  const require2 = createRequire2(import.meta.url);
2083
2136
  for (const packageName of BUNDLED_CHANNEL_PLUGIN_PACKAGES) {
2084
- let entryFile = "";
2085
- let rootDir = "";
2086
- try {
2087
- entryFile = require2.resolve(packageName);
2088
- rootDir = resolvePackageRootFromEntry(entryFile);
2089
- } catch (err) {
2090
- params.registry.diagnostics.push({
2091
- level: "error",
2092
- source: packageName,
2093
- message: `bundled plugin package not resolvable: ${String(err)}`
2094
- });
2137
+ const resolvedEntry = resolveBundledPluginEntry(
2138
+ require2,
2139
+ packageName,
2140
+ params.registry.diagnostics,
2141
+ resolvePackageRootFromEntry
2142
+ );
2143
+ if (!resolvedEntry) {
2095
2144
  continue;
2096
2145
  }
2146
+ const { entryFile, rootDir } = resolvedEntry;
2097
2147
  let moduleExport = null;
2098
2148
  try {
2099
- moduleExport = params.jiti(entryFile);
2149
+ moduleExport = loadBundledPluginModule(entryFile, rootDir);
2100
2150
  } catch (err) {
2101
2151
  params.registry.diagnostics.push({
2102
2152
  level: "error",
@@ -2210,11 +2260,9 @@ function loadOpenClawPlugins(options) {
2210
2260
  reservedEngineKinds,
2211
2261
  reservedNcpAgentRuntimeKinds
2212
2262
  });
2213
- const bundledPluginJiti = createPluginJiti(buildPluginLoaderAliases());
2214
2263
  appendBundledChannelPlugins({
2215
2264
  registry,
2216
2265
  runtime: registerRuntime,
2217
- jiti: bundledPluginJiti,
2218
2266
  normalizedConfig: normalized
2219
2267
  });
2220
2268
  if (!loadExternalPlugins) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/openclaw-compat",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "private": false,
5
5
  "description": "OpenClaw plugin compatibility layer for NextClaw.",
6
6
  "type": "module",
@@ -19,20 +19,20 @@
19
19
  "jiti": "^1.21.7",
20
20
  "jszip": "^3.10.1",
21
21
  "tar": "^7.4.3",
22
- "@nextclaw/channel-plugin-discord": "0.2.13",
23
- "@nextclaw/channel-plugin-qq": "0.2.13",
24
- "@nextclaw/channel-plugin-mochat": "0.2.13",
25
22
  "@nextclaw/channel-plugin-dingtalk": "0.2.13",
23
+ "@nextclaw/channel-plugin-email": "0.2.13",
24
+ "@nextclaw/channel-plugin-mochat": "0.2.13",
25
+ "@nextclaw/channel-plugin-feishu": "0.2.14",
26
+ "@nextclaw/channel-plugin-qq": "0.2.13",
26
27
  "@nextclaw/channel-plugin-telegram": "0.2.13",
28
+ "@nextclaw/channel-plugin-discord": "0.2.13",
27
29
  "@nextclaw/channel-plugin-slack": "0.2.13",
30
+ "@nextclaw/channel-plugin-whatsapp": "0.2.13",
31
+ "@nextclaw/ncp": "0.3.2",
28
32
  "@nextclaw/core": "0.10.0",
29
33
  "@nextclaw/channel-runtime": "0.3.0",
30
- "@nextclaw/ncp": "0.3.2",
31
- "@nextclaw/channel-plugin-feishu": "0.2.13",
32
- "@nextclaw/channel-plugin-email": "0.2.13",
33
34
  "@nextclaw/ncp-toolkit": "0.4.2",
34
35
  "@nextclaw/channel-plugin-weixin": "0.1.7",
35
- "@nextclaw/channel-plugin-whatsapp": "0.2.13",
36
36
  "@nextclaw/channel-plugin-wecom": "0.2.13"
37
37
  },
38
38
  "devDependencies": {