@nextclaw/openclaw-compat 0.1.7 → 0.1.8

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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as _nextclaw_core from '@nextclaw/core';
1
2
  import { Config, ExtensionChannel } from '@nextclaw/core';
2
3
 
3
4
  type PluginConfigUiHint = {
@@ -306,6 +307,17 @@ declare function sleep(ms: number): Promise<void>;
306
307
  declare function normalizePluginHttpPath(rawPath: string): string;
307
308
  declare const DEFAULT_ACCOUNT_ID = "default";
308
309
  declare function normalizeAccountId(accountId?: string | null): string;
310
+ declare function createNextclawBuiltinChannelPlugin(channelId: string): {
311
+ id: string;
312
+ nextclaw: {
313
+ isEnabled: (cfg: _nextclaw_core.Config) => boolean;
314
+ createChannel: (ctx: {
315
+ config: _nextclaw_core.Config;
316
+ bus: _nextclaw_core.MessageBus;
317
+ sessionManager?: _nextclaw_core.SessionManager;
318
+ }) => unknown;
319
+ };
320
+ };
309
321
  declare const __nextclawPluginSdkCompat = true;
310
322
  type _CompatOnly = OpenClawPluginApi;
311
323
 
@@ -615,4 +627,4 @@ declare function uninstallPlugin(params: {
615
627
  extensionsDir?: string;
616
628
  }): Promise<UninstallPluginResult>;
617
629
 
618
- export { DEFAULT_ACCOUNT_ID, type InstallPluginResult, type NormalizedPluginsConfig, type OpenClawChannelAgentPrompt, type OpenClawChannelConfigAdapter, type OpenClawChannelConfigSchema, type OpenClawChannelGateway, type OpenClawChannelGatewayStartContext, type OpenClawChannelPlugin, type OpenClawChannelSetup, type OpenClawPluginApi, type OpenClawPluginChannelRegistration, type OpenClawPluginConfigSchema, type OpenClawPluginDefinition, type OpenClawPluginModule, type OpenClawPluginTool, type OpenClawPluginToolContext, type OpenClawPluginToolFactory, type OpenClawPluginToolOptions, type OpenClawProviderPlugin, PLUGIN_MANIFEST_FILENAME, PLUGIN_MANIFEST_FILENAMES, type PackageManifest, type PluginCandidate, type PluginChannelBinding, type PluginChannelGatewayHandle, type PluginChannelRegistration, type PluginConfigUiHint, type PluginDiagnostic, type PluginDiscoveryResult, type PluginInstallLogger, type PluginInstallSource, type PluginInstallUpdate, type PluginKind, type PluginLoadOptions, type PluginLogger, type PluginManifest, type PluginManifestLoadResult, type PluginManifestRecord, type PluginManifestRegistry, type PluginOrigin, type PluginProviderRegistration, type PluginRecord, type PluginRegisterRuntime, type PluginRegistry, type PluginReplyDispatchParams, type PluginRuntime, type PluginRuntimeBridge, type PluginStatusReport, type PluginToolRegistration, type PluginUiMetadata, type UninstallActions, type UninstallPluginResult, type _CompatOnly, __nextclawPluginSdkCompat, addPluginLoadPath, buildChannelConfigSchema, buildOauthProviderAuthResult, buildPluginStatusReport, createPluginRegisterRuntime, createPluginRuntime, disablePluginInConfig, discoverOpenClawPlugins, emptyPluginConfigSchema, enablePluginInConfig, getPackageManifestMetadata, getPluginChannelBindings, getPluginUiMetadataFromRegistry, installPluginFromArchive, installPluginFromDir, installPluginFromFile, installPluginFromNpmSpec, installPluginFromPath, loadOpenClawPlugins, loadPluginManifest, loadPluginManifestRegistry, loadPluginUiMetadata, normalizeAccountId, normalizePluginHttpPath, normalizePluginsConfig, recordPluginInstall, registerPluginWithApi, removePluginFromConfig, resolveEnableState, resolvePluginChannelMessageToolHints, resolvePluginInstallDir, resolvePluginManifestPath, resolveUninstallDirectoryTarget, setPluginRuntimeBridge, sleep, startPluginChannelGateways, stopPluginChannelGateways, toPluginUiMetadata, uninstallPlugin, validateJsonSchemaValue };
630
+ export { DEFAULT_ACCOUNT_ID, type InstallPluginResult, type NormalizedPluginsConfig, type OpenClawChannelAgentPrompt, type OpenClawChannelConfigAdapter, type OpenClawChannelConfigSchema, type OpenClawChannelGateway, type OpenClawChannelGatewayStartContext, type OpenClawChannelPlugin, type OpenClawChannelSetup, type OpenClawPluginApi, type OpenClawPluginChannelRegistration, type OpenClawPluginConfigSchema, type OpenClawPluginDefinition, type OpenClawPluginModule, type OpenClawPluginTool, type OpenClawPluginToolContext, type OpenClawPluginToolFactory, type OpenClawPluginToolOptions, type OpenClawProviderPlugin, PLUGIN_MANIFEST_FILENAME, PLUGIN_MANIFEST_FILENAMES, type PackageManifest, type PluginCandidate, type PluginChannelBinding, type PluginChannelGatewayHandle, type PluginChannelRegistration, type PluginConfigUiHint, type PluginDiagnostic, type PluginDiscoveryResult, type PluginInstallLogger, type PluginInstallSource, type PluginInstallUpdate, type PluginKind, type PluginLoadOptions, type PluginLogger, type PluginManifest, type PluginManifestLoadResult, type PluginManifestRecord, type PluginManifestRegistry, type PluginOrigin, type PluginProviderRegistration, type PluginRecord, type PluginRegisterRuntime, type PluginRegistry, type PluginReplyDispatchParams, type PluginRuntime, type PluginRuntimeBridge, type PluginStatusReport, type PluginToolRegistration, type PluginUiMetadata, type UninstallActions, type UninstallPluginResult, type _CompatOnly, __nextclawPluginSdkCompat, addPluginLoadPath, buildChannelConfigSchema, buildOauthProviderAuthResult, buildPluginStatusReport, createNextclawBuiltinChannelPlugin, createPluginRegisterRuntime, createPluginRuntime, disablePluginInConfig, discoverOpenClawPlugins, emptyPluginConfigSchema, enablePluginInConfig, getPackageManifestMetadata, getPluginChannelBindings, getPluginUiMetadataFromRegistry, installPluginFromArchive, installPluginFromDir, installPluginFromFile, installPluginFromNpmSpec, installPluginFromPath, loadOpenClawPlugins, loadPluginManifest, loadPluginManifestRegistry, loadPluginUiMetadata, normalizeAccountId, normalizePluginHttpPath, normalizePluginsConfig, recordPluginInstall, registerPluginWithApi, removePluginFromConfig, resolveEnableState, resolvePluginChannelMessageToolHints, resolvePluginInstallDir, resolvePluginManifestPath, resolveUninstallDirectoryTarget, setPluginRuntimeBridge, sleep, startPluginChannelGateways, stopPluginChannelGateways, toPluginUiMetadata, uninstallPlugin, validateJsonSchemaValue };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/plugin-sdk/index.ts
2
+ import { listBuiltinChannelPlugins } from "@nextclaw/core";
2
3
  function emptyPluginConfigSchema() {
3
4
  return {
4
5
  type: "object",
@@ -44,6 +45,19 @@ function normalizeAccountId(accountId) {
44
45
  const trimmed = accountId?.trim();
45
46
  return trimmed || DEFAULT_ACCOUNT_ID;
46
47
  }
48
+ function createNextclawBuiltinChannelPlugin(channelId) {
49
+ const builtin = listBuiltinChannelPlugins().find((entry) => entry.id === channelId);
50
+ if (!builtin) {
51
+ throw new Error(`builtin channel plugin not found: ${channelId}`);
52
+ }
53
+ return {
54
+ id: channelId,
55
+ nextclaw: {
56
+ isEnabled: builtin.isEnabled,
57
+ createChannel: builtin.create
58
+ }
59
+ };
60
+ }
47
61
  var __nextclawPluginSdkCompat = true;
48
62
 
49
63
  // src/plugins/config-state.ts
@@ -224,10 +238,10 @@ function resolvePluginChannelMessageToolHints(params) {
224
238
  }
225
239
  }
226
240
  function getPluginUiMetadataFromRegistry(registry) {
227
- return registry.plugins.map((plugin10) => ({
228
- id: plugin10.id,
229
- configSchema: plugin10.configJsonSchema,
230
- configUiHints: plugin10.configUiHints
241
+ return registry.plugins.map((plugin) => ({
242
+ id: plugin.id,
243
+ configSchema: plugin.configJsonSchema,
244
+ configUiHints: plugin.configUiHints
231
245
  }));
232
246
  }
233
247
  async function startPluginChannelGateways(params) {
@@ -1059,6 +1073,7 @@ async function installPluginFromPath(params) {
1059
1073
  import fs5 from "fs";
1060
1074
  import path5 from "path";
1061
1075
  import { fileURLToPath } from "url";
1076
+ import { createRequire } from "module";
1062
1077
  import createJitiImport from "jiti";
1063
1078
  import { getWorkspacePathFromConfig } from "@nextclaw/core";
1064
1079
 
@@ -1240,132 +1255,6 @@ function validateJsonSchemaValue(params) {
1240
1255
  return { ok: false, errors: formatAjvErrors(cached.validate.errors) };
1241
1256
  }
1242
1257
 
1243
- // src/plugins/bundled/channels/factory.ts
1244
- import { listBuiltinChannelPlugins } from "@nextclaw/core";
1245
- var EMPTY_PLUGIN_CONFIG_SCHEMA = {
1246
- type: "object",
1247
- additionalProperties: false,
1248
- properties: {}
1249
- };
1250
- function resolveBuiltinChannelPlugin(channelId) {
1251
- const plugin10 = listBuiltinChannelPlugins().find((entry) => entry.id === channelId);
1252
- if (!plugin10) {
1253
- throw new Error(`builtin channel plugin not found: ${channelId}`);
1254
- }
1255
- return plugin10;
1256
- }
1257
- function createBundledChannelPlugin(params) {
1258
- const pluginId = `builtin-channel-${params.channelId}`;
1259
- const sourceDescription = params.description ?? `Builtin NextClaw channel plugin for ${params.channelId}`;
1260
- return {
1261
- id: pluginId,
1262
- name: params.name,
1263
- description: sourceDescription,
1264
- configSchema: EMPTY_PLUGIN_CONFIG_SCHEMA,
1265
- register(api) {
1266
- const builtin = resolveBuiltinChannelPlugin(params.channelId);
1267
- api.registerChannel({
1268
- plugin: {
1269
- id: params.channelId,
1270
- nextclaw: {
1271
- isEnabled: builtin.isEnabled,
1272
- createChannel: builtin.create
1273
- }
1274
- }
1275
- });
1276
- }
1277
- };
1278
- }
1279
-
1280
- // src/plugins/bundled/channels/telegram.ts
1281
- var plugin = createBundledChannelPlugin({
1282
- channelId: "telegram",
1283
- name: "Builtin Telegram Channel",
1284
- description: "Builtin NextClaw channel plugin for telegram"
1285
- });
1286
- var telegram_default = plugin;
1287
-
1288
- // src/plugins/bundled/channels/whatsapp.ts
1289
- var plugin2 = createBundledChannelPlugin({
1290
- channelId: "whatsapp",
1291
- name: "Builtin WhatsApp Channel",
1292
- description: "Builtin NextClaw channel plugin for whatsapp"
1293
- });
1294
- var whatsapp_default = plugin2;
1295
-
1296
- // src/plugins/bundled/channels/discord.ts
1297
- var plugin3 = createBundledChannelPlugin({
1298
- channelId: "discord",
1299
- name: "Builtin Discord Channel",
1300
- description: "Builtin NextClaw channel plugin for discord"
1301
- });
1302
- var discord_default = plugin3;
1303
-
1304
- // src/plugins/bundled/channels/feishu.ts
1305
- var plugin4 = createBundledChannelPlugin({
1306
- channelId: "feishu",
1307
- name: "Builtin Feishu Channel",
1308
- description: "Builtin NextClaw channel plugin for feishu"
1309
- });
1310
- var feishu_default = plugin4;
1311
-
1312
- // src/plugins/bundled/channels/mochat.ts
1313
- var plugin5 = createBundledChannelPlugin({
1314
- channelId: "mochat",
1315
- name: "Builtin Mochat Channel",
1316
- description: "Builtin NextClaw channel plugin for mochat"
1317
- });
1318
- var mochat_default = plugin5;
1319
-
1320
- // src/plugins/bundled/channels/dingtalk.ts
1321
- var plugin6 = createBundledChannelPlugin({
1322
- channelId: "dingtalk",
1323
- name: "Builtin DingTalk Channel",
1324
- description: "Builtin NextClaw channel plugin for dingtalk"
1325
- });
1326
- var dingtalk_default = plugin6;
1327
-
1328
- // src/plugins/bundled/channels/email.ts
1329
- var plugin7 = createBundledChannelPlugin({
1330
- channelId: "email",
1331
- name: "Builtin Email Channel",
1332
- description: "Builtin NextClaw channel plugin for email"
1333
- });
1334
- var email_default = plugin7;
1335
-
1336
- // src/plugins/bundled/channels/slack.ts
1337
- var plugin8 = createBundledChannelPlugin({
1338
- channelId: "slack",
1339
- name: "Builtin Slack Channel",
1340
- description: "Builtin NextClaw channel plugin for slack"
1341
- });
1342
- var slack_default = plugin8;
1343
-
1344
- // src/plugins/bundled/channels/qq.ts
1345
- var plugin9 = createBundledChannelPlugin({
1346
- channelId: "qq",
1347
- name: "Builtin QQ Channel",
1348
- description: "Builtin NextClaw channel plugin for qq"
1349
- });
1350
- var qq_default = plugin9;
1351
-
1352
- // src/plugins/bundled/channels/index.ts
1353
- var BUNDLED_CHANNEL_PLUGINS = [
1354
- telegram_default,
1355
- whatsapp_default,
1356
- discord_default,
1357
- feishu_default,
1358
- mochat_default,
1359
- dingtalk_default,
1360
- email_default,
1361
- slack_default,
1362
- qq_default
1363
- ];
1364
- function listBundledChannelPluginDefinitions() {
1365
- return [...BUNDLED_CHANNEL_PLUGINS];
1366
- }
1367
- var BUNDLED_CHANNEL_PLUGIN_IDS = BUNDLED_CHANNEL_PLUGINS.map((plugin10) => plugin10.id).filter((id) => typeof id === "string" && id.trim().length > 0);
1368
-
1369
1258
  // src/plugins/registry.ts
1370
1259
  import path4 from "path";
1371
1260
  import { expandHome as expandHome2 } from "@nextclaw/core";
@@ -1763,6 +1652,32 @@ var defaultLogger2 = {
1763
1652
  error: (message) => console.error(message),
1764
1653
  debug: (message) => console.debug(message)
1765
1654
  };
1655
+ var BUNDLED_CHANNEL_PLUGIN_PACKAGES = [
1656
+ "@nextclaw/channel-plugin-telegram",
1657
+ "@nextclaw/channel-plugin-whatsapp",
1658
+ "@nextclaw/channel-plugin-discord",
1659
+ "@nextclaw/channel-plugin-feishu",
1660
+ "@nextclaw/channel-plugin-mochat",
1661
+ "@nextclaw/channel-plugin-dingtalk",
1662
+ "@nextclaw/channel-plugin-email",
1663
+ "@nextclaw/channel-plugin-slack",
1664
+ "@nextclaw/channel-plugin-qq"
1665
+ ];
1666
+ function resolvePackageRootFromEntry(entryFile) {
1667
+ let cursor = path5.dirname(entryFile);
1668
+ for (let i = 0; i < 8; i += 1) {
1669
+ const candidate = path5.join(cursor, "package.json");
1670
+ if (fs5.existsSync(candidate)) {
1671
+ return cursor;
1672
+ }
1673
+ const parent = path5.dirname(cursor);
1674
+ if (parent === cursor) {
1675
+ break;
1676
+ }
1677
+ cursor = parent;
1678
+ }
1679
+ return path5.dirname(entryFile);
1680
+ }
1766
1681
  function resolvePluginSdkAliasFile(params) {
1767
1682
  try {
1768
1683
  const modulePath = fileURLToPath(import.meta.url);
@@ -1856,9 +1771,37 @@ function validatePluginConfig(params) {
1856
1771
  return { ok: false, errors: result.errors };
1857
1772
  }
1858
1773
  function appendBundledChannelPlugins(params) {
1859
- for (const definition of listBundledChannelPluginDefinitions()) {
1860
- const pluginId = typeof definition.id === "string" ? definition.id.trim() : "";
1861
- const source = `builtin:nextclaw-openclaw-compat/channels/${pluginId || "unknown"}`;
1774
+ const require2 = createRequire(import.meta.url);
1775
+ for (const packageName of BUNDLED_CHANNEL_PLUGIN_PACKAGES) {
1776
+ let entryFile = "";
1777
+ let rootDir = "";
1778
+ try {
1779
+ entryFile = require2.resolve(packageName);
1780
+ rootDir = resolvePackageRootFromEntry(entryFile);
1781
+ } catch (err) {
1782
+ params.registry.diagnostics.push({
1783
+ level: "error",
1784
+ source: packageName,
1785
+ message: `bundled plugin package not resolvable: ${String(err)}`
1786
+ });
1787
+ continue;
1788
+ }
1789
+ let moduleExport = null;
1790
+ try {
1791
+ moduleExport = params.jiti(entryFile);
1792
+ } catch (err) {
1793
+ params.registry.diagnostics.push({
1794
+ level: "error",
1795
+ source: entryFile,
1796
+ message: `failed to load bundled plugin: ${String(err)}`
1797
+ });
1798
+ continue;
1799
+ }
1800
+ const resolved = resolvePluginModuleExport(moduleExport);
1801
+ const definition = resolved.definition;
1802
+ const register = resolved.register;
1803
+ const pluginId = typeof definition?.id === "string" ? definition.id.trim() : "";
1804
+ const source = entryFile;
1862
1805
  if (!pluginId) {
1863
1806
  params.registry.diagnostics.push({
1864
1807
  level: "error",
@@ -1869,18 +1812,17 @@ function appendBundledChannelPlugins(params) {
1869
1812
  }
1870
1813
  const record = createPluginRecord({
1871
1814
  id: pluginId,
1872
- name: definition.name ?? pluginId,
1873
- description: definition.description,
1874
- version: definition.version,
1875
- kind: definition.kind,
1815
+ name: definition?.name ?? pluginId,
1816
+ description: definition?.description,
1817
+ version: definition?.version,
1818
+ kind: definition?.kind,
1876
1819
  source,
1877
1820
  origin: "bundled",
1878
1821
  workspaceDir: params.runtime.workspaceDir,
1879
1822
  enabled: true,
1880
- configSchema: Boolean(definition.configSchema),
1881
- configJsonSchema: definition.configSchema
1823
+ configSchema: Boolean(definition?.configSchema),
1824
+ configJsonSchema: definition?.configSchema
1882
1825
  });
1883
- const register = definition.register ?? definition.activate;
1884
1826
  if (typeof register !== "function") {
1885
1827
  record.status = "error";
1886
1828
  record.error = "plugin export missing register/activate";
@@ -1898,7 +1840,7 @@ function appendBundledChannelPlugins(params) {
1898
1840
  record,
1899
1841
  pluginId,
1900
1842
  source,
1901
- rootDir: params.runtime.workspaceDir,
1843
+ rootDir,
1902
1844
  register,
1903
1845
  pluginConfig: void 0
1904
1846
  });
@@ -1941,9 +1883,20 @@ function loadOpenClawPlugins(options) {
1941
1883
  reservedChannelIds,
1942
1884
  reservedProviderIds
1943
1885
  });
1886
+ const pluginSdkAlias = resolvePluginSdkAlias();
1887
+ const jiti = createJiti(import.meta.url, {
1888
+ interopDefault: true,
1889
+ extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
1890
+ ...pluginSdkAlias ? {
1891
+ alias: {
1892
+ "openclaw/plugin-sdk": pluginSdkAlias
1893
+ }
1894
+ } : {}
1895
+ });
1944
1896
  appendBundledChannelPlugins({
1945
1897
  registry,
1946
- runtime: registerRuntime
1898
+ runtime: registerRuntime,
1899
+ jiti
1947
1900
  });
1948
1901
  if (!loadExternalPlugins) {
1949
1902
  return registry;
@@ -1961,17 +1914,9 @@ function loadOpenClawPlugins(options) {
1961
1914
  });
1962
1915
  registry.diagnostics.push(...manifestRegistry.diagnostics);
1963
1916
  const manifestByRoot = new Map(manifestRegistry.plugins.map((entry) => [entry.rootDir, entry]));
1964
- const seenIds = /* @__PURE__ */ new Map();
1965
- const pluginSdkAlias = resolvePluginSdkAlias();
1966
- const jiti = createJiti(import.meta.url, {
1967
- interopDefault: true,
1968
- extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
1969
- ...pluginSdkAlias ? {
1970
- alias: {
1971
- "openclaw/plugin-sdk": pluginSdkAlias
1972
- }
1973
- } : {}
1974
- });
1917
+ const seenIds = new Map(
1918
+ registry.plugins.map((entry) => [entry.id, entry.origin])
1919
+ );
1975
1920
  for (const candidate of discovery.candidates) {
1976
1921
  const manifest = manifestByRoot.get(candidate.rootDir);
1977
1922
  if (!manifest) {
@@ -2303,6 +2248,7 @@ export {
2303
2248
  buildChannelConfigSchema,
2304
2249
  buildOauthProviderAuthResult,
2305
2250
  buildPluginStatusReport,
2251
+ createNextclawBuiltinChannelPlugin,
2306
2252
  createPluginRegisterRuntime,
2307
2253
  createPluginRuntime,
2308
2254
  disablePluginInConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/openclaw-compat",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "private": false,
5
5
  "description": "OpenClaw plugin compatibility layer for NextClaw.",
6
6
  "type": "module",
@@ -18,7 +18,16 @@
18
18
  "jiti": "^1.21.7",
19
19
  "jszip": "^3.10.1",
20
20
  "tar": "^7.4.3",
21
- "@nextclaw/core": "^0.6.16"
21
+ "@nextclaw/core": "^0.6.16",
22
+ "@nextclaw/channel-plugin-telegram": "^0.1.0",
23
+ "@nextclaw/channel-plugin-whatsapp": "^0.1.0",
24
+ "@nextclaw/channel-plugin-discord": "^0.1.0",
25
+ "@nextclaw/channel-plugin-feishu": "^0.1.0",
26
+ "@nextclaw/channel-plugin-mochat": "^0.1.0",
27
+ "@nextclaw/channel-plugin-dingtalk": "^0.1.0",
28
+ "@nextclaw/channel-plugin-email": "^0.1.0",
29
+ "@nextclaw/channel-plugin-slack": "^0.1.0",
30
+ "@nextclaw/channel-plugin-qq": "^0.1.0"
22
31
  },
23
32
  "devDependencies": {
24
33
  "@types/node": "^20.17.6",