@nextclaw/openclaw-compat 0.3.34 → 0.3.35

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, AgentEngineFactory } from '@nextclaw/core';
2
+ import { Config, ExtensionChannel, ProviderRuntimeResolution, AgentEngineFactory } from '@nextclaw/core';
3
3
  import { NcpAgentRuntime } from '@nextclaw/ncp';
4
4
  import { RuntimeFactoryParams } from '@nextclaw/ncp-toolkit';
5
5
 
@@ -328,6 +328,21 @@ type PluginReplyDispatchParams = {
328
328
  };
329
329
  type PluginRuntime = {
330
330
  version: string;
331
+ agent: {
332
+ defaults: {
333
+ model: string;
334
+ workspace: string;
335
+ maxToolIterations: number;
336
+ };
337
+ resolveWorkspacePath: (workspace?: string) => string;
338
+ resolveProviderRuntime: (model?: string) => ProviderRuntimeResolution;
339
+ buildRuntimeUserPrompt: (params: {
340
+ workspace?: string;
341
+ sessionKey?: string;
342
+ metadata?: Record<string, unknown>;
343
+ userMessage: string;
344
+ }) => string;
345
+ };
331
346
  config: {
332
347
  loadConfig: () => Record<string, unknown>;
333
348
  writeConfigFile: (next: Record<string, unknown>) => Promise<void>;
package/dist/index.js CHANGED
@@ -1775,6 +1775,13 @@ function registerPluginNcpAgentRuntime(params) {
1775
1775
 
1776
1776
  // src/plugins/runtime.ts
1777
1777
  import { randomUUID as randomUUID2 } from "crypto";
1778
+ import {
1779
+ buildBootstrapAwareUserPrompt,
1780
+ getWorkspacePath,
1781
+ readRequestedSkillsFromMetadata,
1782
+ resolveProviderRuntime,
1783
+ SkillsLoader
1784
+ } from "@nextclaw/core";
1778
1785
  import { getPackageVersion } from "@nextclaw/core";
1779
1786
  import { MemoryGetTool, MemorySearchTool } from "@nextclaw/core";
1780
1787
 
@@ -2318,9 +2325,52 @@ async function dispatchReplyWithFallback(params) {
2318
2325
  }
2319
2326
  await bridge.dispatchReplyWithBufferedBlockDispatcher(params);
2320
2327
  }
2328
+ function createRuntimeUserPromptBuilder(params) {
2329
+ const skillLoaders = /* @__PURE__ */ new Map();
2330
+ return ({ workspace, sessionKey, metadata, userMessage }) => {
2331
+ const resolvedWorkspace = getWorkspacePath(workspace ?? params.defaultWorkspace);
2332
+ let skills = skillLoaders.get(resolvedWorkspace);
2333
+ if (!skills) {
2334
+ skills = new SkillsLoader(resolvedWorkspace);
2335
+ skillLoaders.set(resolvedWorkspace, skills);
2336
+ }
2337
+ return buildBootstrapAwareUserPrompt({
2338
+ workspace: resolvedWorkspace,
2339
+ contextConfig: params.config?.agents?.context,
2340
+ sessionKey,
2341
+ skills,
2342
+ skillNames: readRequestedSkillsFromMetadata(metadata),
2343
+ userMessage
2344
+ });
2345
+ };
2346
+ }
2321
2347
  function createPluginRuntime(params) {
2348
+ const defaultModel = params.config?.agents?.defaults?.model ?? "";
2349
+ const maxToolIterations = Math.max(
2350
+ 0,
2351
+ Math.trunc(params.config?.agents?.defaults?.maxToolIterations ?? 0)
2352
+ );
2353
+ const buildRuntimeUserPrompt = createRuntimeUserPromptBuilder({
2354
+ config: params.config,
2355
+ defaultWorkspace: params.workspace
2356
+ });
2322
2357
  return {
2323
2358
  version: getPackageVersion(),
2359
+ agent: {
2360
+ defaults: {
2361
+ model: defaultModel,
2362
+ workspace: params.workspace,
2363
+ maxToolIterations
2364
+ },
2365
+ resolveWorkspacePath: (workspace) => getWorkspacePath(workspace ?? params.workspace),
2366
+ resolveProviderRuntime: (model) => {
2367
+ if (!params.config) {
2368
+ throw new Error("plugin runtime agent.resolveProviderRuntime requires host config");
2369
+ }
2370
+ return resolveProviderRuntime(params.config, model);
2371
+ },
2372
+ buildRuntimeUserPrompt
2373
+ },
2324
2374
  config: {
2325
2375
  loadConfig: () => loadConfigWithFallback(params.config),
2326
2376
  writeConfigFile: async (next) => writeConfigWithFallback(next)
@@ -2749,6 +2799,14 @@ var defaultLogger2 = {
2749
2799
  error: (message) => console.error(message),
2750
2800
  debug: (message) => console.debug(message)
2751
2801
  };
2802
+ var STARTUP_TRACE_ENABLED = process.env.NEXTCLAW_STARTUP_TRACE === "1";
2803
+ function logPluginStartupTrace(step, fields) {
2804
+ if (!STARTUP_TRACE_ENABLED) {
2805
+ return;
2806
+ }
2807
+ const suffix = Object.entries(fields ?? {}).filter(([, value]) => value !== void 0).map(([key, value]) => `${key}=${String(value)}`).join(" ");
2808
+ console.log(`[startup-trace] ${step}${suffix ? ` ${suffix}` : ""}`);
2809
+ }
2752
2810
  function resolvePackageRootFromEntry(entryFile) {
2753
2811
  let cursor = path7.dirname(entryFile);
2754
2812
  for (let i = 0; i < 8; i += 1) {
@@ -2783,6 +2841,7 @@ function resolvePluginModuleExport(moduleExport) {
2783
2841
  function appendBundledChannelPlugins(params) {
2784
2842
  const require2 = createRequire2(import.meta.url);
2785
2843
  for (const packageName of BUNDLED_CHANNEL_PLUGIN_PACKAGES) {
2844
+ const packageStartedAt = Date.now();
2786
2845
  const resolvedEntry = resolveBundledPluginEntry(
2787
2846
  require2,
2788
2847
  packageName,
@@ -2869,6 +2928,11 @@ function appendBundledChannelPlugins(params) {
2869
2928
  });
2870
2929
  }
2871
2930
  params.registry.plugins.push(record);
2931
+ logPluginStartupTrace("plugin.loader.bundled_plugin", {
2932
+ package: packageName,
2933
+ plugin_id: pluginId,
2934
+ duration_ms: Date.now() - packageStartedAt
2935
+ });
2872
2936
  }
2873
2937
  }
2874
2938
  function loadExternalPluginModule(candidateSource, pluginRoot) {
@@ -2876,6 +2940,7 @@ function loadExternalPluginModule(candidateSource, pluginRoot) {
2876
2940
  return pluginJiti(candidateSource);
2877
2941
  }
2878
2942
  function loadOpenClawPlugins(options) {
2943
+ const startedAt = Date.now();
2879
2944
  const loadExternalPlugins = process.env.NEXTCLAW_ENABLE_OPENCLAW_PLUGINS !== "0";
2880
2945
  const logger = options.logger ?? defaultLogger2;
2881
2946
  const workspaceDir = options.workspaceDir?.trim() || getWorkspacePathFromConfig(options.config);
@@ -2935,6 +3000,7 @@ function loadOpenClawPlugins(options) {
2935
3000
  registry.plugins.map((entry) => [entry.id, entry.origin])
2936
3001
  );
2937
3002
  for (const candidate of filteredCandidates) {
3003
+ const candidateStartedAt = Date.now();
2938
3004
  const manifest = manifestByRoot.get(candidate.rootDir);
2939
3005
  if (!manifest) {
2940
3006
  continue;
@@ -3022,7 +3088,13 @@ function loadOpenClawPlugins(options) {
3022
3088
  }
3023
3089
  let moduleExport = null;
3024
3090
  try {
3091
+ const moduleLoadStartedAt = Date.now();
3025
3092
  moduleExport = loadExternalPluginModule(candidate.source, candidate.rootDir);
3093
+ logPluginStartupTrace("plugin.loader.external_module_loaded", {
3094
+ plugin_id: pluginId,
3095
+ duration_ms: Date.now() - moduleLoadStartedAt,
3096
+ source: candidate.source
3097
+ });
3026
3098
  } catch (err) {
3027
3099
  record.status = "error";
3028
3100
  record.error = `failed to load plugin: ${String(err)}`;
@@ -3073,6 +3145,11 @@ function loadOpenClawPlugins(options) {
3073
3145
  register,
3074
3146
  pluginConfig: validatedConfig.value
3075
3147
  });
3148
+ logPluginStartupTrace("plugin.loader.external_plugin_registered", {
3149
+ plugin_id: pluginId,
3150
+ duration_ms: Date.now() - candidateStartedAt,
3151
+ source: candidate.source
3152
+ });
3076
3153
  if (!registerResult.ok) {
3077
3154
  record.status = "error";
3078
3155
  record.error = registerResult.error;
@@ -3089,6 +3166,10 @@ function loadOpenClawPlugins(options) {
3089
3166
  registry.plugins.push(record);
3090
3167
  seenIds.set(pluginId, candidate.origin);
3091
3168
  }
3169
+ logPluginStartupTrace("plugin.loader.total", {
3170
+ duration_ms: Date.now() - startedAt,
3171
+ plugin_count: registry.plugins.length
3172
+ });
3092
3173
  return registry;
3093
3174
  }
3094
3175
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/openclaw-compat",
3
- "version": "0.3.34",
3
+ "version": "0.3.35",
4
4
  "private": false,
5
5
  "description": "OpenClaw plugin compatibility layer for NextClaw.",
6
6
  "type": "module",
@@ -19,21 +19,21 @@
19
19
  "jiti": "^1.21.7",
20
20
  "jszip": "^3.10.1",
21
21
  "tar": "^7.4.3",
22
- "@nextclaw/channel-plugin-dingtalk": "0.2.17",
23
22
  "@nextclaw/channel-plugin-discord": "0.2.17",
24
- "@nextclaw/channel-plugin-email": "0.2.17",
25
23
  "@nextclaw/channel-plugin-feishu": "0.2.21",
26
- "@nextclaw/channel-plugin-mochat": "0.2.17",
27
24
  "@nextclaw/channel-plugin-qq": "0.2.17",
25
+ "@nextclaw/channel-plugin-dingtalk": "0.2.17",
26
+ "@nextclaw/channel-plugin-email": "0.2.17",
27
+ "@nextclaw/channel-plugin-mochat": "0.2.17",
28
+ "@nextclaw/core": "0.11.2",
29
+ "@nextclaw/channel-runtime": "0.4.3",
28
30
  "@nextclaw/channel-plugin-slack": "0.2.17",
31
+ "@nextclaw/ncp-toolkit": "0.4.4",
29
32
  "@nextclaw/channel-plugin-telegram": "0.2.17",
33
+ "@nextclaw/ncp": "0.4.0",
30
34
  "@nextclaw/channel-plugin-weixin": "0.1.10",
31
- "@nextclaw/channel-plugin-wecom": "0.2.17",
32
35
  "@nextclaw/channel-plugin-whatsapp": "0.2.17",
33
- "@nextclaw/channel-runtime": "0.4.3",
34
- "@nextclaw/core": "0.11.2",
35
- "@nextclaw/ncp": "0.4.0",
36
- "@nextclaw/ncp-toolkit": "0.4.4"
36
+ "@nextclaw/channel-plugin-wecom": "0.2.17"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^20.17.6",