nextclaw 0.2.8 → 0.3.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/cli/index.js CHANGED
@@ -33,6 +33,7 @@ import {
33
33
  MessageBus,
34
34
  AgentLoop,
35
35
  LiteLLMProvider,
36
+ ProviderManager,
36
37
  ChannelManager,
37
38
  SessionManager,
38
39
  CronService,
@@ -180,9 +181,10 @@ program.command("agent").description("Interact with the agent directly").option(
180
181
  const config = loadConfig();
181
182
  const bus = new MessageBus();
182
183
  const provider = makeProvider(config);
184
+ const providerManager = new ProviderManager(provider);
183
185
  const agentLoop = new AgentLoop({
184
186
  bus,
185
- provider,
187
+ providerManager,
186
188
  workspace: getWorkspacePath(config.agents.defaults.workspace),
187
189
  braveApiKey: config.tools.web.search.apiKey || void 0,
188
190
  execConfig: config.tools.exec,
@@ -344,6 +346,7 @@ async function startGateway(options = {}) {
344
346
  const config = loadConfig();
345
347
  const bus = new MessageBus();
346
348
  const provider = options.allowMissingProvider === true ? makeProvider(config, { allowMissing: true }) : makeProvider(config);
349
+ const providerManager = provider ? new ProviderManager(provider) : null;
347
350
  const sessionManager = new SessionManager(getWorkspacePath(config.agents.defaults.workspace));
348
351
  const cronStorePath = join(getDataDir(), "cron", "jobs.json");
349
352
  const cron2 = new CronService(cronStorePath);
@@ -355,10 +358,7 @@ async function startGateway(options = {}) {
355
358
  host: uiConfig.host,
356
359
  port: uiConfig.port,
357
360
  configPath: getConfigPath(),
358
- staticDir: uiStaticDir ?? void 0,
359
- onReload: async () => {
360
- return;
361
- }
361
+ staticDir: uiStaticDir ?? void 0
362
362
  });
363
363
  const uiUrl = `http://${uiServer.host}:${uiServer.port}`;
364
364
  console.log(`\u2713 UI API: ${uiUrl}/api`);
@@ -376,7 +376,7 @@ async function startGateway(options = {}) {
376
376
  }
377
377
  const agent = new AgentLoop({
378
378
  bus,
379
- provider,
379
+ providerManager: providerManager ?? new ProviderManager(provider),
380
380
  workspace: getWorkspacePath(config.agents.defaults.workspace),
381
381
  model: config.agents.defaults.model,
382
382
  maxIterations: config.agents.defaults.maxToolIterations,
@@ -429,6 +429,29 @@ async function startGateway(options = {}) {
429
429
  reloadTask = null;
430
430
  }
431
431
  };
432
+ let providerReloadTask = null;
433
+ const reloadProvider = async (nextConfig) => {
434
+ if (!providerManager) {
435
+ return;
436
+ }
437
+ if (providerReloadTask) {
438
+ await providerReloadTask;
439
+ return;
440
+ }
441
+ providerReloadTask = (async () => {
442
+ const nextProvider = makeProvider(nextConfig, { allowMissing: true });
443
+ if (!nextProvider) {
444
+ console.warn("Provider reload skipped: missing API key.");
445
+ return;
446
+ }
447
+ providerManager.set(nextProvider);
448
+ })();
449
+ try {
450
+ await providerReloadTask;
451
+ } finally {
452
+ providerReloadTask = null;
453
+ }
454
+ };
432
455
  const applyReloadPlan = async (nextConfig) => {
433
456
  const changedPaths = diffConfigPaths(currentConfig, nextConfig);
434
457
  if (!changedPaths.length) {
@@ -439,6 +462,9 @@ async function startGateway(options = {}) {
439
462
  if (plan.restartChannels) {
440
463
  await reloadChannels(nextConfig);
441
464
  }
465
+ if (plan.reloadProviders) {
466
+ await reloadProvider(nextConfig);
467
+ }
442
468
  if (plan.restartRequired.length > 0) {
443
469
  console.warn(`Config changes require restart: ${plan.restartRequired.join(", ")}`);
444
470
  }
@@ -487,10 +513,7 @@ async function startGateway(options = {}) {
487
513
  host: uiConfig.host,
488
514
  port: uiConfig.port,
489
515
  configPath: getConfigPath(),
490
- staticDir: uiStaticDir ?? void 0,
491
- onReload: async () => {
492
- await runConfigReload("ui");
493
- }
516
+ staticDir: uiStaticDir ?? void 0
494
517
  });
495
518
  const uiUrl = `http://${uiServer.host}:${uiServer.port}`;
496
519
  console.log(`\u2713 UI API: ${uiUrl}/api`);
@@ -809,7 +832,8 @@ function makeProvider(config, options) {
809
832
  apiBase: getApiBase(config),
810
833
  defaultModel: model,
811
834
  extraHeaders: provider?.extraHeaders ?? null,
812
- providerName: getProviderName(config)
835
+ providerName: getProviderName(config),
836
+ wireApi: provider?.wireApi ?? null
813
837
  });
814
838
  }
815
839
  function createWorkspaceTemplates(workspace) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextclaw",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
4
4
  "description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -34,19 +34,11 @@
34
34
  "bridge",
35
35
  "ui-dist"
36
36
  ],
37
- "scripts": {
38
- "dev": "pnpm -C ../nextclaw-core build && pnpm -C ../nextclaw-server build && tsx src/cli/index.ts",
39
- "build": "pnpm -C ../nextclaw-core build && pnpm -C ../nextclaw-server build && tsup src/index.ts src/cli/index.ts --format esm --dts --out-dir dist && node scripts/copy-ui-dist.mjs",
40
- "start": "node dist/cli.js",
41
- "lint": "eslint .",
42
- "tsc": "tsc -p tsconfig.json",
43
- "test": "vitest"
44
- },
45
37
  "dependencies": {
46
38
  "chokidar": "^3.6.0",
47
39
  "commander": "^12.1.0",
48
- "nextclaw-core": "^0.2.8",
49
- "nextclaw-server": "^0.2.8"
40
+ "nextclaw-core": "^0.3.0",
41
+ "nextclaw-server": "^0.3.0"
50
42
  },
51
43
  "devDependencies": {
52
44
  "@types/node": "^20.17.6",
@@ -59,5 +51,13 @@
59
51
  "tsx": "^4.19.2",
60
52
  "typescript": "^5.6.3",
61
53
  "vitest": "^2.1.2"
54
+ },
55
+ "scripts": {
56
+ "dev": "pnpm -C ../nextclaw-core build && pnpm -C ../nextclaw-server build && tsx src/cli/index.ts",
57
+ "build": "pnpm -C ../nextclaw-core build && pnpm -C ../nextclaw-server build && tsup src/index.ts src/cli/index.ts --format esm --dts --out-dir dist && node scripts/copy-ui-dist.mjs",
58
+ "start": "node dist/cli.js",
59
+ "lint": "eslint .",
60
+ "tsc": "tsc -p tsconfig.json",
61
+ "test": "vitest"
62
62
  }
63
- }
63
+ }