@nextclaw/openclaw-compat 0.1.34 → 0.2.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _nextclaw_core from '@nextclaw/core';
2
- import { Config, ExtensionChannel } from '@nextclaw/core';
2
+ import { Config, ExtensionChannel, AgentEngineFactory } from '@nextclaw/core';
3
3
 
4
4
  type PluginConfigUiHint = {
5
5
  label?: string;
@@ -51,6 +51,9 @@ type OpenClawPluginToolOptions = {
51
51
  names?: string[];
52
52
  optional?: boolean;
53
53
  };
54
+ type OpenClawPluginEngineOptions = {
55
+ kind: string;
56
+ };
54
57
  type OpenClawProviderPlugin = {
55
58
  id: string;
56
59
  label?: string;
@@ -171,6 +174,7 @@ type PluginRecord = {
171
174
  toolNames: string[];
172
175
  channelIds: string[];
173
176
  providerIds: string[];
177
+ engineKinds: string[];
174
178
  configSchema: boolean;
175
179
  configUiHints?: Record<string, PluginConfigUiHint>;
176
180
  configJsonSchema?: Record<string, unknown>;
@@ -192,6 +196,12 @@ type PluginProviderRegistration = {
192
196
  provider: OpenClawProviderPlugin;
193
197
  source: string;
194
198
  };
199
+ type PluginEngineRegistration = {
200
+ pluginId: string;
201
+ kind: string;
202
+ factory: AgentEngineFactory;
203
+ source: string;
204
+ };
195
205
  type PluginReplyDispatchParams = {
196
206
  ctx: {
197
207
  Body?: string;
@@ -253,6 +263,7 @@ type OpenClawPluginApi = {
253
263
  registerTool: (tool: OpenClawPluginTool | OpenClawPluginToolFactory, opts?: OpenClawPluginToolOptions) => void;
254
264
  registerChannel: (registration: OpenClawPluginChannelRegistration) => void;
255
265
  registerProvider: (provider: OpenClawProviderPlugin) => void;
266
+ registerEngine: (factory: AgentEngineFactory, opts: OpenClawPluginEngineOptions) => void;
256
267
  registerHook: (_events: string | string[], _handler: unknown, _opts?: unknown) => void;
257
268
  registerGatewayMethod: (_method: string, _handler: unknown) => void;
258
269
  registerCli: (_registrar: unknown, _opts?: unknown) => void;
@@ -270,6 +281,7 @@ type PluginRegistry = {
270
281
  tools: PluginToolRegistration[];
271
282
  channels: PluginChannelRegistration[];
272
283
  providers: PluginProviderRegistration[];
284
+ engines: PluginEngineRegistration[];
273
285
  diagnostics: PluginDiagnostic[];
274
286
  resolvedTools: OpenClawPluginTool[];
275
287
  };
@@ -464,6 +476,7 @@ type PluginLoadOptions = {
464
476
  reservedToolNames?: string[];
465
477
  reservedChannelIds?: string[];
466
478
  reservedProviderIds?: string[];
479
+ reservedEngineKinds?: string[];
467
480
  };
468
481
  declare function loadOpenClawPlugins(options: PluginLoadOptions): PluginRegistry;
469
482
 
@@ -540,10 +553,12 @@ type PluginRegisterRuntime = {
540
553
  toolNameOwners: Map<string, string>;
541
554
  channelIdOwners: Map<string, string>;
542
555
  providerIdOwners: Map<string, string>;
556
+ engineKindOwners: Map<string, string>;
543
557
  resolvedToolNames: Set<string>;
544
558
  reservedToolNames: Set<string>;
545
559
  reservedChannelIds: Set<string>;
546
560
  reservedProviderIds: Set<string>;
561
+ reservedEngineKinds: Set<string>;
547
562
  };
548
563
  declare function createPluginRegisterRuntime(params: {
549
564
  config: Config;
@@ -553,6 +568,7 @@ declare function createPluginRegisterRuntime(params: {
553
568
  reservedToolNames: Set<string>;
554
569
  reservedChannelIds: Set<string>;
555
570
  reservedProviderIds: Set<string>;
571
+ reservedEngineKinds: Set<string>;
556
572
  }): PluginRegisterRuntime;
557
573
  declare function registerPluginWithApi(params: {
558
574
  runtime: PluginRegisterRuntime;
@@ -590,6 +606,7 @@ declare function buildPluginStatusReport(params: {
590
606
  reservedToolNames?: string[];
591
607
  reservedChannelIds?: string[];
592
608
  reservedProviderIds?: string[];
609
+ reservedEngineKinds?: string[];
593
610
  }): PluginStatusReport;
594
611
 
595
612
  type UninstallActions = {
@@ -627,4 +644,4 @@ declare function uninstallPlugin(params: {
627
644
  extensionsDir?: string;
628
645
  }): Promise<UninstallPluginResult>;
629
646
 
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 };
647
+ 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 OpenClawPluginEngineOptions, 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 PluginEngineRegistration, 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
@@ -1371,10 +1371,12 @@ function createPluginRegisterRuntime(params) {
1371
1371
  toolNameOwners: /* @__PURE__ */ new Map(),
1372
1372
  channelIdOwners: /* @__PURE__ */ new Map(),
1373
1373
  providerIdOwners: /* @__PURE__ */ new Map(),
1374
+ engineKindOwners: /* @__PURE__ */ new Map(),
1374
1375
  resolvedToolNames: /* @__PURE__ */ new Set(),
1375
1376
  reservedToolNames: params.reservedToolNames,
1376
1377
  reservedChannelIds: params.reservedChannelIds,
1377
- reservedProviderIds: params.reservedProviderIds
1378
+ reservedProviderIds: params.reservedProviderIds,
1379
+ reservedEngineKinds: params.reservedEngineKinds
1378
1380
  };
1379
1381
  }
1380
1382
  function registerPluginTool(params) {
@@ -1556,6 +1558,27 @@ function registerPluginProvider(params) {
1556
1558
  });
1557
1559
  params.record.providerIds.push(accepted[0]);
1558
1560
  }
1561
+ function registerPluginEngine(params) {
1562
+ const accepted = ensureUniqueNames({
1563
+ names: [params.kind],
1564
+ pluginId: params.pluginId,
1565
+ diagnostics: params.runtime.registry.diagnostics,
1566
+ source: params.source,
1567
+ owners: params.runtime.engineKindOwners,
1568
+ reserved: params.runtime.reservedEngineKinds,
1569
+ kind: "engine"
1570
+ });
1571
+ if (accepted.length === 0) {
1572
+ return;
1573
+ }
1574
+ params.runtime.registry.engines.push({
1575
+ pluginId: params.pluginId,
1576
+ kind: accepted[0],
1577
+ factory: params.factory,
1578
+ source: params.source
1579
+ });
1580
+ params.record.engineKinds.push(accepted[0]);
1581
+ }
1559
1582
  function registerPluginWithApi(params) {
1560
1583
  const pluginRuntime = createPluginRuntime({ workspace: params.runtime.workspaceDir, config: params.runtime.config });
1561
1584
  const pluginLogger = buildPluginLogger(params.runtime.logger, params.pluginId);
@@ -1606,6 +1629,26 @@ function registerPluginWithApi(params) {
1606
1629
  provider
1607
1630
  });
1608
1631
  },
1632
+ registerEngine: (factory, opts) => {
1633
+ const kind = opts?.kind?.trim().toLowerCase();
1634
+ if (!kind) {
1635
+ params.runtime.registry.diagnostics.push({
1636
+ level: "error",
1637
+ pluginId: params.pluginId,
1638
+ source: params.source,
1639
+ message: "registerEngine requires opts.kind"
1640
+ });
1641
+ return;
1642
+ }
1643
+ registerPluginEngine({
1644
+ runtime: params.runtime,
1645
+ record: params.record,
1646
+ pluginId: params.pluginId,
1647
+ source: params.source,
1648
+ kind,
1649
+ factory
1650
+ });
1651
+ },
1609
1652
  registerHook: () => pushUnsupported("registerHook"),
1610
1653
  registerGatewayMethod: () => pushUnsupported("registerGatewayMethod"),
1611
1654
  registerCli: () => pushUnsupported("registerCli"),
@@ -1661,6 +1704,10 @@ var BUNDLED_CHANNEL_PLUGIN_PACKAGES = [
1661
1704
  "@nextclaw/channel-plugin-slack",
1662
1705
  "@nextclaw/channel-plugin-qq"
1663
1706
  ];
1707
+ var BUNDLED_RUNTIME_PLUGIN_PACKAGES = [
1708
+ "@nextclaw/nextclaw-engine-codex-sdk",
1709
+ "@nextclaw/nextclaw-engine-claude-agent-sdk"
1710
+ ];
1664
1711
  function resolvePackageRootFromEntry(entryFile) {
1665
1712
  let cursor = path5.dirname(entryFile);
1666
1713
  for (let i = 0; i < 8; i += 1) {
@@ -1735,6 +1782,7 @@ function createPluginRecord(params) {
1735
1782
  toolNames: [],
1736
1783
  channelIds: [],
1737
1784
  providerIds: [],
1785
+ engineKinds: [],
1738
1786
  configSchema: params.configSchema,
1739
1787
  configUiHints: params.configUiHints,
1740
1788
  configJsonSchema: params.configJsonSchema
@@ -1862,6 +1910,100 @@ function appendBundledChannelPlugins(params) {
1862
1910
  params.registry.plugins.push(record);
1863
1911
  }
1864
1912
  }
1913
+ function appendBundledRuntimePlugins(params) {
1914
+ const require2 = createRequire(import.meta.url);
1915
+ for (const packageName of BUNDLED_RUNTIME_PLUGIN_PACKAGES) {
1916
+ let entryFile = "";
1917
+ let rootDir = "";
1918
+ try {
1919
+ entryFile = require2.resolve(packageName);
1920
+ rootDir = resolvePackageRootFromEntry(entryFile);
1921
+ } catch (err) {
1922
+ params.registry.diagnostics.push({
1923
+ level: "error",
1924
+ source: packageName,
1925
+ message: `bundled runtime plugin package not resolvable: ${String(err)}`
1926
+ });
1927
+ continue;
1928
+ }
1929
+ let moduleExport = null;
1930
+ try {
1931
+ moduleExport = params.jiti(entryFile);
1932
+ } catch (err) {
1933
+ params.registry.diagnostics.push({
1934
+ level: "error",
1935
+ source: entryFile,
1936
+ message: `failed to load bundled runtime plugin: ${String(err)}`
1937
+ });
1938
+ continue;
1939
+ }
1940
+ const resolved = resolvePluginModuleExport(moduleExport);
1941
+ const definition = resolved.definition;
1942
+ const register = resolved.register;
1943
+ const pluginId = typeof definition?.id === "string" ? definition.id.trim() : "";
1944
+ const source = entryFile;
1945
+ if (!pluginId) {
1946
+ params.registry.diagnostics.push({
1947
+ level: "error",
1948
+ source,
1949
+ message: "bundled runtime plugin definition missing id"
1950
+ });
1951
+ continue;
1952
+ }
1953
+ const enableState = resolveEnableState(pluginId, params.normalizedConfig);
1954
+ const record = createPluginRecord({
1955
+ id: pluginId,
1956
+ name: definition?.name ?? pluginId,
1957
+ description: definition?.description,
1958
+ version: definition?.version,
1959
+ kind: definition?.kind,
1960
+ source,
1961
+ origin: "bundled",
1962
+ workspaceDir: params.runtime.workspaceDir,
1963
+ enabled: enableState.enabled,
1964
+ configSchema: Boolean(definition?.configSchema),
1965
+ configJsonSchema: definition?.configSchema
1966
+ });
1967
+ if (!enableState.enabled) {
1968
+ record.status = "disabled";
1969
+ record.error = enableState.reason;
1970
+ params.registry.plugins.push(record);
1971
+ continue;
1972
+ }
1973
+ if (typeof register !== "function") {
1974
+ record.status = "error";
1975
+ record.error = "plugin export missing register/activate";
1976
+ params.registry.plugins.push(record);
1977
+ params.registry.diagnostics.push({
1978
+ level: "error",
1979
+ pluginId,
1980
+ source,
1981
+ message: record.error
1982
+ });
1983
+ continue;
1984
+ }
1985
+ const result = registerPluginWithApi({
1986
+ runtime: params.runtime,
1987
+ record,
1988
+ pluginId,
1989
+ source,
1990
+ rootDir,
1991
+ register,
1992
+ pluginConfig: void 0
1993
+ });
1994
+ if (!result.ok) {
1995
+ record.status = "error";
1996
+ record.error = result.error;
1997
+ params.registry.diagnostics.push({
1998
+ level: "error",
1999
+ pluginId,
2000
+ source,
2001
+ message: result.error
2002
+ });
2003
+ }
2004
+ params.registry.plugins.push(record);
2005
+ }
2006
+ }
1865
2007
  function loadOpenClawPlugins(options) {
1866
2008
  const loadExternalPlugins = process.env.NEXTCLAW_ENABLE_OPENCLAW_PLUGINS !== "0";
1867
2009
  const logger = options.logger ?? defaultLogger2;
@@ -1873,12 +2015,14 @@ function loadOpenClawPlugins(options) {
1873
2015
  tools: [],
1874
2016
  channels: [],
1875
2017
  providers: [],
2018
+ engines: [],
1876
2019
  diagnostics: [],
1877
2020
  resolvedTools: []
1878
2021
  };
1879
2022
  const reservedToolNames = new Set(options.reservedToolNames ?? []);
1880
2023
  const reservedChannelIds = new Set(options.reservedChannelIds ?? []);
1881
2024
  const reservedProviderIds = new Set(options.reservedProviderIds ?? []);
2025
+ const reservedEngineKinds = new Set((options.reservedEngineKinds ?? ["native"]).map((entry) => entry.toLowerCase()));
1882
2026
  const registerRuntime = createPluginRegisterRuntime({
1883
2027
  config: options.config,
1884
2028
  workspaceDir,
@@ -1886,7 +2030,8 @@ function loadOpenClawPlugins(options) {
1886
2030
  registry,
1887
2031
  reservedToolNames,
1888
2032
  reservedChannelIds,
1889
- reservedProviderIds
2033
+ reservedProviderIds,
2034
+ reservedEngineKinds
1890
2035
  });
1891
2036
  const pluginSdkAlias = resolvePluginSdkAlias();
1892
2037
  const jiti = createJiti(import.meta.url, {
@@ -1904,6 +2049,12 @@ function loadOpenClawPlugins(options) {
1904
2049
  jiti,
1905
2050
  normalizedConfig: normalized
1906
2051
  });
2052
+ appendBundledRuntimePlugins({
2053
+ registry,
2054
+ runtime: registerRuntime,
2055
+ jiti,
2056
+ normalizedConfig: normalized
2057
+ });
1907
2058
  if (!loadExternalPlugins) {
1908
2059
  return registry;
1909
2060
  }
@@ -2091,7 +2242,8 @@ function buildPluginStatusReport(params) {
2091
2242
  logger: params.logger,
2092
2243
  reservedToolNames: params.reservedToolNames,
2093
2244
  reservedChannelIds: params.reservedChannelIds,
2094
- reservedProviderIds: params.reservedProviderIds
2245
+ reservedProviderIds: params.reservedProviderIds,
2246
+ reservedEngineKinds: params.reservedEngineKinds
2095
2247
  });
2096
2248
  return {
2097
2249
  workspaceDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/openclaw-compat",
3
- "version": "0.1.34",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "description": "OpenClaw plugin compatibility layer for NextClaw.",
6
6
  "type": "module",
@@ -14,22 +14,24 @@
14
14
  "dist"
15
15
  ],
16
16
  "dependencies": {
17
- "ajv": "^8.17.1",
18
- "jiti": "^1.21.7",
19
- "jszip": "^3.10.1",
20
- "tar": "^7.4.3",
21
- "@nextclaw/core": "^0.6.45",
22
- "@nextclaw/channel-plugin-telegram": "^0.1.6",
23
- "@nextclaw/channel-plugin-whatsapp": "^0.1.6",
17
+ "@nextclaw/channel-plugin-dingtalk": "^0.1.6",
24
18
  "@nextclaw/channel-plugin-discord": "^0.1.7",
19
+ "@nextclaw/channel-plugin-email": "^0.1.6",
25
20
  "@nextclaw/channel-plugin-feishu": "^0.1.6",
26
21
  "@nextclaw/channel-plugin-mochat": "^0.1.6",
27
- "@nextclaw/channel-plugin-dingtalk": "^0.1.6",
28
- "@nextclaw/channel-plugin-wecom": "^0.1.6",
29
- "@nextclaw/channel-plugin-email": "^0.1.6",
30
- "@nextclaw/channel-plugin-slack": "^0.1.6",
31
22
  "@nextclaw/channel-plugin-qq": "^0.1.6",
32
- "@nextclaw/channel-runtime": "^0.1.28"
23
+ "@nextclaw/channel-plugin-slack": "^0.1.6",
24
+ "@nextclaw/channel-plugin-telegram": "^0.1.6",
25
+ "@nextclaw/channel-plugin-wecom": "^0.1.6",
26
+ "@nextclaw/channel-plugin-whatsapp": "^0.1.6",
27
+ "@nextclaw/channel-runtime": "^0.1.29",
28
+ "@nextclaw/nextclaw-engine-claude-agent-sdk": "^0.2.0",
29
+ "@nextclaw/core": "^0.7.0",
30
+ "@nextclaw/nextclaw-engine-codex-sdk": "^0.2.0",
31
+ "ajv": "^8.17.1",
32
+ "jiti": "^1.21.7",
33
+ "jszip": "^3.10.1",
34
+ "tar": "^7.4.3"
33
35
  },
34
36
  "devDependencies": {
35
37
  "@types/node": "^20.17.6",