nextclaw 0.6.34 → 0.6.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.
Files changed (2) hide show
  1. package/dist/cli/index.js +124 -73
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -20,7 +20,11 @@ import {
20
20
  DEFAULT_WORKSPACE_DIR,
21
21
  DEFAULT_WORKSPACE_PATH
22
22
  } from "@nextclaw/core";
23
- import { resolvePluginChannelMessageToolHints as resolvePluginChannelMessageToolHints2 } from "@nextclaw/openclaw-compat";
23
+ import {
24
+ getPluginChannelBindings as getPluginChannelBindings3,
25
+ resolvePluginChannelMessageToolHints as resolvePluginChannelMessageToolHints2,
26
+ setPluginRuntimeBridge as setPluginRuntimeBridge2
27
+ } from "@nextclaw/openclaw-compat";
24
28
  import { existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
25
29
  import { join as join6, resolve as resolve9 } from "path";
26
30
  import { createInterface as createInterface2 } from "readline";
@@ -3295,7 +3299,9 @@ var CliRuntime = class {
3295
3299
  }
3296
3300
  const uiHost = FORCED_PUBLIC_UI_HOST;
3297
3301
  const uiPort = typeof state.uiPort === "number" && Number.isFinite(state.uiPort) ? state.uiPort : 18791;
3298
- console.log(`Applying changes (${reason}): restarting ${APP_NAME4} background service...`);
3302
+ console.log(
3303
+ `Applying changes (${reason}): restarting ${APP_NAME4} background service...`
3304
+ );
3299
3305
  await this.serviceCommands.stopService();
3300
3306
  await this.serviceCommands.startService({
3301
3307
  uiOverrides: {
@@ -3442,11 +3448,15 @@ var CliRuntime = class {
3442
3448
  }
3443
3449
  });
3444
3450
  } catch (error) {
3445
- console.warn(`Warning: failed to write restart sentinel from exec context: ${String(error)}`);
3451
+ console.warn(
3452
+ `Warning: failed to write restart sentinel from exec context: ${String(error)}`
3453
+ );
3446
3454
  }
3447
3455
  }
3448
3456
  async onboard() {
3449
- console.warn(`Warning: ${APP_NAME4} onboard is deprecated. Use "${APP_NAME4} init" instead.`);
3457
+ console.warn(
3458
+ `Warning: ${APP_NAME4} onboard is deprecated. Use "${APP_NAME4} init" instead.`
3459
+ );
3450
3460
  await this.init({ source: "onboard" });
3451
3461
  }
3452
3462
  async init(options = {}) {
@@ -3465,7 +3475,10 @@ var CliRuntime = class {
3465
3475
  const workspacePath = !workspaceSetting || workspaceSetting === DEFAULT_WORKSPACE_PATH ? join6(getDataDir7(), DEFAULT_WORKSPACE_DIR) : expandHome2(workspaceSetting);
3466
3476
  const workspaceExisted = existsSync8(workspacePath);
3467
3477
  mkdirSync5(workspacePath, { recursive: true });
3468
- const templateResult = this.workspaceManager.createWorkspaceTemplates(workspacePath, { force });
3478
+ const templateResult = this.workspaceManager.createWorkspaceTemplates(
3479
+ workspacePath,
3480
+ { force }
3481
+ );
3469
3482
  if (createdConfig) {
3470
3483
  console.log(`\u2713 ${prefix}: created config at ${configPath}`);
3471
3484
  }
@@ -3485,7 +3498,9 @@ ${this.logo} ${APP_NAME4} is ready! (${source})`);
3485
3498
  console.log(` 1. Add your API key to ${configPath}`);
3486
3499
  console.log(` 2. Chat: ${APP_NAME4} agent -m "Hello!"`);
3487
3500
  } else {
3488
- console.log(`Tip: Run "${APP_NAME4} init${force ? " --force" : ""}" to re-run initialization if needed.`);
3501
+ console.log(
3502
+ `Tip: Run "${APP_NAME4} init${force ? " --force" : ""}" to re-run initialization if needed.`
3503
+ );
3489
3504
  }
3490
3505
  }
3491
3506
  async gateway(opts) {
@@ -3512,7 +3527,10 @@ ${this.logo} ${APP_NAME4} is ready! (${source})`);
3512
3527
  if (opts.port) {
3513
3528
  uiOverrides.port = Number(opts.port);
3514
3529
  }
3515
- await this.serviceCommands.startGateway({ uiOverrides, allowMissingProvider: true });
3530
+ await this.serviceCommands.startGateway({
3531
+ uiOverrides,
3532
+ allowMissingProvider: true
3533
+ });
3516
3534
  }
3517
3535
  async start(opts) {
3518
3536
  await this.init({ source: "start", auto: true });
@@ -3566,74 +3584,103 @@ ${this.logo} ${APP_NAME4} is ready! (${source})`);
3566
3584
  const pluginRegistry = loadPluginRegistry(config2, workspace);
3567
3585
  const extensionRegistry = toExtensionRegistry(pluginRegistry);
3568
3586
  logPluginDiagnostics(pluginRegistry);
3569
- const bus = new MessageBus2();
3570
- const provider = this.serviceCommands.createProvider(config2) ?? this.serviceCommands.createMissingProvider(config2);
3571
- const providerManager = new ProviderManager2({
3572
- defaultProvider: provider,
3573
- config: config2
3574
- });
3575
- const agentLoop = new AgentLoop2({
3576
- bus,
3577
- providerManager,
3578
- workspace,
3579
- model: config2.agents.defaults.model,
3580
- maxIterations: config2.agents.defaults.maxToolIterations,
3581
- maxTokens: config2.agents.defaults.maxTokens,
3582
- contextTokens: config2.agents.defaults.contextTokens,
3583
- braveApiKey: config2.tools.web.search.apiKey || void 0,
3584
- execConfig: config2.tools.exec,
3585
- restrictToWorkspace: config2.tools.restrictToWorkspace,
3586
- contextConfig: config2.agents.context,
3587
- config: config2,
3588
- extensionRegistry,
3589
- resolveMessageToolHints: ({ channel, accountId }) => resolvePluginChannelMessageToolHints2({
3590
- registry: pluginRegistry,
3591
- channel,
3592
- cfg: loadConfig6(),
3593
- accountId
3594
- })
3587
+ const pluginChannelBindings = getPluginChannelBindings3(pluginRegistry);
3588
+ setPluginRuntimeBridge2({
3589
+ loadConfig: () => toPluginConfigView(loadConfig6(), pluginChannelBindings),
3590
+ writeConfigFile: async (nextConfigView) => {
3591
+ if (!nextConfigView || typeof nextConfigView !== "object" || Array.isArray(nextConfigView)) {
3592
+ throw new Error(
3593
+ "plugin runtime writeConfigFile expects an object config"
3594
+ );
3595
+ }
3596
+ const current = loadConfig6();
3597
+ const next = mergePluginConfigView(
3598
+ current,
3599
+ nextConfigView,
3600
+ pluginChannelBindings
3601
+ );
3602
+ saveConfig5(next);
3603
+ }
3595
3604
  });
3596
- if (opts.message) {
3597
- const response = await agentLoop.processDirect({
3598
- content: opts.message,
3599
- sessionKey: opts.session ?? "cli:default",
3600
- channel: "cli",
3601
- chatId: "direct",
3602
- metadata: typeof opts.model === "string" && opts.model.trim() ? { model: opts.model.trim() } : {}
3605
+ try {
3606
+ const bus = new MessageBus2();
3607
+ const provider = this.serviceCommands.createProvider(config2) ?? this.serviceCommands.createMissingProvider(config2);
3608
+ const providerManager = new ProviderManager2({
3609
+ defaultProvider: provider,
3610
+ config: config2
3603
3611
  });
3604
- printAgentResponse(response);
3605
- return;
3606
- }
3607
- console.log(`${this.logo} Interactive mode (type exit or Ctrl+C to quit)
3608
- `);
3609
- const historyFile = join6(getDataDir7(), "history", "cli_history");
3610
- const historyDir = resolve9(historyFile, "..");
3611
- mkdirSync5(historyDir, { recursive: true });
3612
- const history = existsSync8(historyFile) ? readFileSync6(historyFile, "utf-8").split("\n").filter(Boolean) : [];
3613
- const rl = createInterface2({ input: process.stdin, output: process.stdout });
3614
- rl.on("close", () => {
3615
- const merged = history.concat(rl.history ?? []);
3616
- writeFileSync4(historyFile, merged.join("\n"));
3617
- process.exit(0);
3618
- });
3619
- let running = true;
3620
- while (running) {
3621
- const line = await prompt(rl, "You: ");
3622
- const trimmed = line.trim();
3623
- if (!trimmed) {
3624
- continue;
3625
- }
3626
- if (EXIT_COMMANDS.has(trimmed.toLowerCase())) {
3627
- rl.close();
3628
- running = false;
3629
- break;
3612
+ const agentLoop = new AgentLoop2({
3613
+ bus,
3614
+ providerManager,
3615
+ workspace,
3616
+ model: config2.agents.defaults.model,
3617
+ maxIterations: config2.agents.defaults.maxToolIterations,
3618
+ maxTokens: config2.agents.defaults.maxTokens,
3619
+ contextTokens: config2.agents.defaults.contextTokens,
3620
+ braveApiKey: config2.tools.web.search.apiKey || void 0,
3621
+ execConfig: config2.tools.exec,
3622
+ restrictToWorkspace: config2.tools.restrictToWorkspace,
3623
+ contextConfig: config2.agents.context,
3624
+ config: config2,
3625
+ extensionRegistry,
3626
+ resolveMessageToolHints: ({ channel, accountId }) => resolvePluginChannelMessageToolHints2({
3627
+ registry: pluginRegistry,
3628
+ channel,
3629
+ cfg: loadConfig6(),
3630
+ accountId
3631
+ })
3632
+ });
3633
+ if (opts.message) {
3634
+ const response = await agentLoop.processDirect({
3635
+ content: opts.message,
3636
+ sessionKey: opts.session ?? "cli:default",
3637
+ channel: "cli",
3638
+ chatId: "direct",
3639
+ metadata: typeof opts.model === "string" && opts.model.trim() ? { model: opts.model.trim() } : {}
3640
+ });
3641
+ printAgentResponse(response);
3642
+ return;
3630
3643
  }
3631
- const response = await agentLoop.processDirect({
3632
- content: trimmed,
3633
- sessionKey: opts.session ?? "cli:default",
3634
- metadata: typeof opts.model === "string" && opts.model.trim() ? { model: opts.model.trim() } : {}
3644
+ console.log(
3645
+ `${this.logo} Interactive mode (type exit or Ctrl+C to quit)
3646
+ `
3647
+ );
3648
+ const historyFile = join6(getDataDir7(), "history", "cli_history");
3649
+ const historyDir = resolve9(historyFile, "..");
3650
+ mkdirSync5(historyDir, { recursive: true });
3651
+ const history = existsSync8(historyFile) ? readFileSync6(historyFile, "utf-8").split("\n").filter(Boolean) : [];
3652
+ const rl = createInterface2({
3653
+ input: process.stdin,
3654
+ output: process.stdout
3655
+ });
3656
+ rl.on("close", () => {
3657
+ const merged = history.concat(
3658
+ rl.history ?? []
3659
+ );
3660
+ writeFileSync4(historyFile, merged.join("\n"));
3661
+ process.exit(0);
3635
3662
  });
3636
- printAgentResponse(response);
3663
+ let running = true;
3664
+ while (running) {
3665
+ const line = await prompt(rl, "You: ");
3666
+ const trimmed = line.trim();
3667
+ if (!trimmed) {
3668
+ continue;
3669
+ }
3670
+ if (EXIT_COMMANDS.has(trimmed.toLowerCase())) {
3671
+ rl.close();
3672
+ running = false;
3673
+ break;
3674
+ }
3675
+ const response = await agentLoop.processDirect({
3676
+ content: trimmed,
3677
+ sessionKey: opts.session ?? "cli:default",
3678
+ metadata: typeof opts.model === "string" && opts.model.trim() ? { model: opts.model.trim() } : {}
3679
+ });
3680
+ printAgentResponse(response);
3681
+ }
3682
+ } finally {
3683
+ setPluginRuntimeBridge2(null);
3637
3684
  }
3638
3685
  }
3639
3686
  async update(opts) {
@@ -3641,7 +3688,9 @@ ${this.logo} ${APP_NAME4} is ready! (${source})`);
3641
3688
  if (opts.timeout !== void 0) {
3642
3689
  const parsed = Number(opts.timeout);
3643
3690
  if (!Number.isFinite(parsed) || parsed <= 0) {
3644
- console.error("Invalid --timeout value. Provide milliseconds (e.g. 1200000).");
3691
+ console.error(
3692
+ "Invalid --timeout value. Provide milliseconds (e.g. 1200000)."
3693
+ );
3645
3694
  process.exit(1);
3646
3695
  }
3647
3696
  timeoutMs = parsed;
@@ -3651,7 +3700,9 @@ ${this.logo} ${APP_NAME4} is ready! (${source})`);
3651
3700
  const result = runSelfUpdate({ timeoutMs, cwd: process.cwd() });
3652
3701
  const printSteps = () => {
3653
3702
  for (const step of result.steps) {
3654
- console.log(`- ${step.cmd} ${step.args.join(" ")} (code ${step.code ?? "?"})`);
3703
+ console.log(
3704
+ `- ${step.cmd} ${step.args.join(" ")} (code ${step.code ?? "?"})`
3705
+ );
3655
3706
  if (step.stderr) {
3656
3707
  console.log(` stderr: ${step.stderr}`);
3657
3708
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextclaw",
3
- "version": "0.6.34",
3
+ "version": "0.6.35",
4
4
  "description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
5
5
  "private": false,
6
6
  "type": "module",