@nextclaw/server 0.10.35 → 0.10.37

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/index.js +151 -93
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -4019,13 +4019,6 @@ async function fetchAllMarketplaceItems(params) {
4019
4019
  }
4020
4020
  };
4021
4021
  }
4022
- async function fetchAllPluginMarketplaceItems(params) {
4023
- return fetchAllMarketplaceItems({
4024
- baseUrl: params.baseUrl,
4025
- path: "/api/v1/plugins/items",
4026
- query: params.query
4027
- });
4028
- }
4029
4022
  async function fetchAllSkillMarketplaceItems(params) {
4030
4023
  return fetchAllMarketplaceItems({
4031
4024
  baseUrl: params.baseUrl,
@@ -4259,7 +4252,7 @@ var McpMarketplaceController = class {
4259
4252
 
4260
4253
  // src/ui/router/marketplace/installed.ts
4261
4254
  import * as NextclawCore3 from "@nextclaw/core";
4262
- import { buildPluginStatusReport } from "@nextclaw/openclaw-compat";
4255
+ import { discoverPluginStatusReport } from "@nextclaw/openclaw-compat";
4263
4256
 
4264
4257
  // src/ui/router/marketplace/spec.ts
4265
4258
  function normalizePluginNpmSpec(rawSpec) {
@@ -4373,54 +4366,67 @@ function createSkillsLoader(workspace) {
4373
4366
  }
4374
4367
  return new ctor(workspace);
4375
4368
  }
4376
- function collectInstalledPluginRecords(options) {
4377
- const config = loadConfigOrDefault(options.configPath);
4378
- const pluginRecordsMap = config.plugins.installs ?? {};
4379
- const pluginEntries = config.plugins.entries ?? {};
4380
- const pluginRecords = [];
4381
- const seenPluginIds = /* @__PURE__ */ new Set();
4382
- let discoveredPlugins = [];
4383
- try {
4384
- const pluginReport = buildPluginStatusReport({
4385
- config,
4386
- workspaceDir: getWorkspacePathFromConfig3(config)
4387
- });
4388
- discoveredPlugins = pluginReport.plugins;
4389
- } catch {
4390
- discoveredPlugins = [];
4369
+ function readPluginStatusScore(plugin) {
4370
+ if (plugin.status === "loaded") {
4371
+ return 300;
4391
4372
  }
4392
- const readPluginPriority = (plugin) => {
4393
- const hasInstallRecord = Boolean(pluginRecordsMap[plugin.id]);
4394
- const statusScore = plugin.status === "loaded" ? 300 : plugin.status === "disabled" ? 200 : 100;
4395
- let originScore = 0;
4396
- if (hasInstallRecord) {
4397
- originScore = plugin.origin === "workspace" ? 40 : plugin.origin === "global" ? 30 : plugin.origin === "config" ? 20 : 10;
4398
- } else {
4399
- originScore = plugin.origin === "bundled" ? 40 : plugin.origin === "workspace" ? 30 : plugin.origin === "global" ? 20 : 10;
4373
+ if (plugin.status === "disabled") {
4374
+ return 200;
4375
+ }
4376
+ return 100;
4377
+ }
4378
+ function readPluginOriginScore(plugin, hasInstallRecord) {
4379
+ if (hasInstallRecord) {
4380
+ if (plugin.origin === "workspace") {
4381
+ return 40;
4400
4382
  }
4401
- return statusScore + originScore;
4402
- };
4383
+ if (plugin.origin === "global") {
4384
+ return 30;
4385
+ }
4386
+ if (plugin.origin === "config") {
4387
+ return 20;
4388
+ }
4389
+ return 10;
4390
+ }
4391
+ if (plugin.origin === "bundled") {
4392
+ return 40;
4393
+ }
4394
+ if (plugin.origin === "workspace") {
4395
+ return 30;
4396
+ }
4397
+ if (plugin.origin === "global") {
4398
+ return 20;
4399
+ }
4400
+ return 10;
4401
+ }
4402
+ function readPluginPriority(plugin, installedPluginIds) {
4403
+ return readPluginStatusScore(plugin) + readPluginOriginScore(plugin, installedPluginIds.has(plugin.id));
4404
+ }
4405
+ function buildDiscoveredPluginMap(params) {
4403
4406
  const discoveredById = /* @__PURE__ */ new Map();
4404
- for (const plugin of discoveredPlugins) {
4407
+ for (const plugin of params.discoveredPlugins) {
4405
4408
  const existing = discoveredById.get(plugin.id);
4406
4409
  if (!existing) {
4407
4410
  discoveredById.set(plugin.id, plugin);
4408
4411
  continue;
4409
4412
  }
4410
- if (readPluginPriority(plugin) > readPluginPriority(existing)) {
4413
+ if (readPluginPriority(plugin, params.installedPluginIds) > readPluginPriority(existing, params.installedPluginIds)) {
4411
4414
  discoveredById.set(plugin.id, plugin);
4412
4415
  }
4413
4416
  }
4414
- for (const plugin of discoveredById.values()) {
4415
- const installRecord = pluginRecordsMap[plugin.id];
4416
- const entry = pluginEntries[plugin.id];
4417
+ return discoveredById;
4418
+ }
4419
+ function appendDiscoveredPluginRecords(params) {
4420
+ for (const plugin of params.discoveredById.values()) {
4421
+ const installRecord = params.pluginRecordsMap[plugin.id];
4422
+ const entry = params.pluginEntries[plugin.id];
4417
4423
  const normalizedSpec = resolvePluginCanonicalSpec({
4418
4424
  pluginId: plugin.id,
4419
4425
  installSpec: installRecord?.spec
4420
4426
  });
4421
4427
  const enabled = entry?.enabled === false ? false : plugin.enabled;
4422
4428
  const runtimeStatus = entry?.enabled === false ? "disabled" : plugin.status;
4423
- pluginRecords.push({
4429
+ params.pluginRecords.push({
4424
4430
  type: "plugin",
4425
4431
  id: plugin.id,
4426
4432
  spec: normalizedSpec,
@@ -4432,21 +4438,22 @@ function collectInstalledPluginRecords(options) {
4432
4438
  origin: plugin.origin,
4433
4439
  installPath: installRecord?.installPath
4434
4440
  });
4435
- seenPluginIds.add(plugin.id);
4441
+ params.seenPluginIds.add(plugin.id);
4436
4442
  }
4437
- for (const [pluginId, installRecord] of Object.entries(pluginRecordsMap)) {
4438
- if (seenPluginIds.has(pluginId)) {
4443
+ }
4444
+ function appendInstalledOnlyPluginRecords(params) {
4445
+ for (const [pluginId, installRecord] of Object.entries(params.pluginRecordsMap)) {
4446
+ if (params.seenPluginIds.has(pluginId)) {
4439
4447
  continue;
4440
4448
  }
4441
- const normalizedSpec = resolvePluginCanonicalSpec({
4442
- pluginId,
4443
- installSpec: installRecord.spec
4444
- });
4445
- const entry = pluginEntries[pluginId];
4446
- pluginRecords.push({
4449
+ const entry = params.pluginEntries[pluginId];
4450
+ params.pluginRecords.push({
4447
4451
  type: "plugin",
4448
4452
  id: pluginId,
4449
- spec: normalizedSpec,
4453
+ spec: resolvePluginCanonicalSpec({
4454
+ pluginId,
4455
+ installSpec: installRecord.spec
4456
+ }),
4450
4457
  label: pluginId,
4451
4458
  source: installRecord.source,
4452
4459
  installedAt: installRecord.installedAt,
@@ -4454,23 +4461,87 @@ function collectInstalledPluginRecords(options) {
4454
4461
  runtimeStatus: entry?.enabled === false ? "disabled" : "unresolved",
4455
4462
  installPath: installRecord.installPath
4456
4463
  });
4457
- seenPluginIds.add(pluginId);
4464
+ params.seenPluginIds.add(pluginId);
4458
4465
  }
4459
- for (const [pluginId, entry] of Object.entries(pluginEntries)) {
4460
- if (!seenPluginIds.has(pluginId)) {
4461
- const normalizedSpec = resolvePluginCanonicalSpec({ pluginId });
4462
- pluginRecords.push({
4463
- type: "plugin",
4464
- id: pluginId,
4465
- spec: normalizedSpec,
4466
- label: pluginId,
4467
- source: "config",
4468
- enabled: entry?.enabled !== false,
4469
- runtimeStatus: entry?.enabled === false ? "disabled" : "unresolved"
4470
- });
4471
- seenPluginIds.add(pluginId);
4466
+ }
4467
+ function appendConfigOnlyPluginRecords(params) {
4468
+ for (const [pluginId, entry] of Object.entries(params.pluginEntries)) {
4469
+ if (params.seenPluginIds.has(pluginId)) {
4470
+ continue;
4471
+ }
4472
+ params.pluginRecords.push({
4473
+ type: "plugin",
4474
+ id: pluginId,
4475
+ spec: resolvePluginCanonicalSpec({ pluginId }),
4476
+ label: pluginId,
4477
+ source: "config",
4478
+ enabled: entry?.enabled !== false,
4479
+ runtimeStatus: entry?.enabled === false ? "disabled" : "unresolved"
4480
+ });
4481
+ params.seenPluginIds.add(pluginId);
4482
+ }
4483
+ }
4484
+ function findPluginIdByExactId(pluginRecords, lowerTargetId) {
4485
+ for (const record of pluginRecords) {
4486
+ const recordId = record.id?.trim();
4487
+ if (recordId && recordId.toLowerCase() === lowerTargetId) {
4488
+ return recordId;
4489
+ }
4490
+ }
4491
+ return void 0;
4492
+ }
4493
+ function findPluginIdByNormalizedSpec(pluginRecords, normalizedSpec) {
4494
+ if (!normalizedSpec) {
4495
+ return void 0;
4496
+ }
4497
+ for (const record of pluginRecords) {
4498
+ const recordId = record.id?.trim();
4499
+ if (!recordId) {
4500
+ continue;
4472
4501
  }
4502
+ const normalizedRecordSpec = normalizePluginNpmSpec(record.spec).toLowerCase();
4503
+ if (normalizedRecordSpec === normalizedSpec) {
4504
+ return recordId;
4505
+ }
4506
+ }
4507
+ return void 0;
4508
+ }
4509
+ function collectInstalledPluginRecords(options) {
4510
+ const config = loadConfigOrDefault(options.configPath);
4511
+ const pluginRecordsMap = config.plugins.installs ?? {};
4512
+ const pluginEntries = config.plugins.entries ?? {};
4513
+ const pluginRecords = [];
4514
+ const seenPluginIds = /* @__PURE__ */ new Set();
4515
+ const installedPluginIds = new Set(Object.keys(pluginRecordsMap));
4516
+ let discoveredPlugins = [];
4517
+ try {
4518
+ const pluginReport = discoverPluginStatusReport({
4519
+ config,
4520
+ workspaceDir: getWorkspacePathFromConfig3(config)
4521
+ });
4522
+ discoveredPlugins = pluginReport.plugins;
4523
+ } catch {
4524
+ discoveredPlugins = [];
4473
4525
  }
4526
+ const discoveredById = buildDiscoveredPluginMap({ discoveredPlugins, installedPluginIds });
4527
+ appendDiscoveredPluginRecords({
4528
+ discoveredById,
4529
+ pluginRecordsMap,
4530
+ pluginEntries,
4531
+ pluginRecords,
4532
+ seenPluginIds
4533
+ });
4534
+ appendInstalledOnlyPluginRecords({
4535
+ pluginRecordsMap,
4536
+ pluginEntries,
4537
+ pluginRecords,
4538
+ seenPluginIds
4539
+ });
4540
+ appendConfigOnlyPluginRecords({
4541
+ pluginEntries,
4542
+ pluginRecords,
4543
+ seenPluginIds
4544
+ });
4474
4545
  const dedupedPluginRecords = dedupeInstalledPluginRecordsByCanonicalSpec(pluginRecords);
4475
4546
  dedupedPluginRecords.sort((left, right) => {
4476
4547
  return left.spec.localeCompare(right.spec);
@@ -4535,27 +4606,17 @@ function resolvePluginManageTargetId(options, rawTargetId, rawSpec) {
4535
4606
  const normalizedSpec = rawSpec ? normalizePluginNpmSpec(rawSpec).toLowerCase() : "";
4536
4607
  const pluginRecords = collectInstalledPluginRecords(options).records;
4537
4608
  const lowerTargetId = targetId.toLowerCase();
4538
- for (const record of pluginRecords) {
4539
- const recordId = record.id?.trim();
4540
- if (recordId && recordId.toLowerCase() === lowerTargetId) {
4541
- return recordId;
4542
- }
4609
+ const matchedRecordId = findPluginIdByExactId(pluginRecords, lowerTargetId);
4610
+ if (matchedRecordId) {
4611
+ return matchedRecordId;
4543
4612
  }
4544
- if (normalizedTarget) {
4545
- for (const record of pluginRecords) {
4546
- const normalizedRecordSpec = normalizePluginNpmSpec(record.spec).toLowerCase();
4547
- if (normalizedRecordSpec === normalizedTarget && record.id && record.id.trim().length > 0) {
4548
- return record.id;
4549
- }
4550
- }
4613
+ const matchedByTargetSpec = findPluginIdByNormalizedSpec(pluginRecords, normalizedTarget);
4614
+ if (matchedByTargetSpec) {
4615
+ return matchedByTargetSpec;
4551
4616
  }
4552
- if (normalizedSpec && normalizedSpec !== normalizedTarget) {
4553
- for (const record of pluginRecords) {
4554
- const normalizedRecordSpec = normalizePluginNpmSpec(record.spec).toLowerCase();
4555
- if (normalizedRecordSpec === normalizedSpec && record.id && record.id.trim().length > 0) {
4556
- return record.id;
4557
- }
4558
- }
4617
+ const matchedByRawSpec = normalizedSpec && normalizedSpec !== normalizedTarget ? findPluginIdByNormalizedSpec(pluginRecords, normalizedSpec) : void 0;
4618
+ if (matchedByRawSpec) {
4619
+ return matchedByRawSpec;
4559
4620
  }
4560
4621
  return targetId || rawSpec || rawTargetId;
4561
4622
  }
@@ -4724,8 +4785,9 @@ var PluginMarketplaceController = class {
4724
4785
  };
4725
4786
  listItems = async (c) => {
4726
4787
  const query = c.req.query();
4727
- const result = await fetchAllPluginMarketplaceItems({
4788
+ const result = await fetchMarketplaceData({
4728
4789
  baseUrl: this.marketplaceBaseUrl,
4790
+ path: "/api/v1/plugins/items",
4729
4791
  query: {
4730
4792
  q: query.q,
4731
4793
  tag: query.tag,
@@ -4737,19 +4799,15 @@ var PluginMarketplaceController = class {
4737
4799
  if (!result.ok) {
4738
4800
  return c.json(err("MARKETPLACE_UNAVAILABLE", result.message), result.status);
4739
4801
  }
4740
- const filteredItems = sanitizeMarketplaceListItems(result.data.items).map((item) => normalizeMarketplaceItemForUi(item)).filter((item) => isSupportedMarketplacePluginItem(item));
4741
- const pageSize = Math.min(100, toPositiveInt(query.pageSize, 20));
4742
- const requestedPage = toPositiveInt(query.page, 1);
4743
- const totalPages = filteredItems.length === 0 ? 0 : Math.ceil(filteredItems.length / pageSize);
4744
- const currentPage = totalPages === 0 ? 1 : Math.min(requestedPage, totalPages);
4802
+ const items = sanitizeMarketplaceListItems(result.data.items).map((item) => normalizeMarketplaceItemForUi(item)).filter((item) => isSupportedMarketplacePluginItem(item));
4745
4803
  return c.json(ok({
4746
- total: filteredItems.length,
4747
- page: currentPage,
4748
- pageSize,
4749
- totalPages,
4804
+ total: result.data.total,
4805
+ page: result.data.page,
4806
+ pageSize: result.data.pageSize,
4807
+ totalPages: result.data.totalPages,
4750
4808
  sort: result.data.sort,
4751
4809
  query: result.data.query,
4752
- items: filteredItems.slice((currentPage - 1) * pageSize, currentPage * pageSize)
4810
+ items
4753
4811
  }));
4754
4812
  };
4755
4813
  getItem = async (c) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/server",
3
- "version": "0.10.35",
3
+ "version": "0.10.37",
4
4
  "private": false,
5
5
  "description": "Nextclaw UI/API server.",
6
6
  "type": "module",
@@ -18,12 +18,12 @@
18
18
  "@hono/node-server": "^1.13.3",
19
19
  "hono": "^4.6.2",
20
20
  "ws": "^8.18.0",
21
- "@nextclaw/mcp": "0.1.31",
22
- "@nextclaw/ncp": "0.3.2",
21
+ "@nextclaw/mcp": "0.1.33",
23
22
  "@nextclaw/ncp-http-agent-server": "0.3.2",
24
- "@nextclaw/runtime": "0.2.12",
25
- "@nextclaw/openclaw-compat": "0.3.18",
26
- "@nextclaw/core": "0.9.12"
23
+ "@nextclaw/ncp": "0.3.2",
24
+ "@nextclaw/core": "0.10.0",
25
+ "@nextclaw/openclaw-compat": "0.3.19",
26
+ "@nextclaw/runtime": "0.2.13"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^20.17.6",