@nextclaw/server 0.5.1 → 0.5.3
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.js +55 -15
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { join } from "path";
|
|
|
9
9
|
|
|
10
10
|
// src/ui/router.ts
|
|
11
11
|
import { Hono } from "hono";
|
|
12
|
-
import
|
|
12
|
+
import * as NextclawCore from "@nextclaw/core";
|
|
13
13
|
import { buildPluginStatusReport } from "@nextclaw/openclaw-compat";
|
|
14
14
|
|
|
15
15
|
// src/ui/config.ts
|
|
@@ -572,12 +572,21 @@ function updateRuntime(configPath, patch) {
|
|
|
572
572
|
// src/ui/router.ts
|
|
573
573
|
var DEFAULT_MARKETPLACE_API_BASE = "https://marketplace-api.nextclaw.io";
|
|
574
574
|
var NEXTCLAW_PLUGIN_NPM_PREFIX = "@nextclaw/channel-plugin-";
|
|
575
|
+
var CLAWBAY_CHANNEL_PLUGIN_NPM_SPEC = "@clawbay/clawbay-channel";
|
|
575
576
|
var BUILTIN_CHANNEL_PLUGIN_ID_PREFIX = "builtin-channel-";
|
|
576
577
|
var MARKETPLACE_REMOTE_PAGE_SIZE = 100;
|
|
577
578
|
var MARKETPLACE_REMOTE_MAX_PAGES = 20;
|
|
578
|
-
|
|
579
|
+
var getWorkspacePathFromConfig3 = NextclawCore.getWorkspacePathFromConfig;
|
|
580
|
+
function createSkillsLoader(workspace) {
|
|
581
|
+
const ctor = NextclawCore.SkillsLoader;
|
|
582
|
+
if (!ctor) {
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
return new ctor(workspace);
|
|
586
|
+
}
|
|
587
|
+
function normalizePluginNpmSpec(rawSpec) {
|
|
579
588
|
const spec = rawSpec.trim();
|
|
580
|
-
if (!spec.startsWith(
|
|
589
|
+
if (!spec.startsWith("@")) {
|
|
581
590
|
return spec;
|
|
582
591
|
}
|
|
583
592
|
const versionDelimiterIndex = spec.lastIndexOf("@");
|
|
@@ -585,12 +594,19 @@ function normalizeChannelPluginNpmSpec(rawSpec) {
|
|
|
585
594
|
return spec;
|
|
586
595
|
}
|
|
587
596
|
const packageName = spec.slice(0, versionDelimiterIndex).trim();
|
|
588
|
-
|
|
597
|
+
if (!packageName.includes("/")) {
|
|
598
|
+
return spec;
|
|
599
|
+
}
|
|
600
|
+
return packageName;
|
|
601
|
+
}
|
|
602
|
+
function isSupportedMarketplacePluginSpec(rawSpec) {
|
|
603
|
+
const spec = normalizePluginNpmSpec(rawSpec);
|
|
604
|
+
return spec.startsWith(NEXTCLAW_PLUGIN_NPM_PREFIX) || spec === CLAWBAY_CHANNEL_PLUGIN_NPM_SPEC;
|
|
589
605
|
}
|
|
590
606
|
function resolvePluginCanonicalSpec(params) {
|
|
591
607
|
const rawInstallSpec = typeof params.installSpec === "string" ? params.installSpec.trim() : "";
|
|
592
608
|
if (rawInstallSpec.length > 0) {
|
|
593
|
-
return
|
|
609
|
+
return normalizePluginNpmSpec(rawInstallSpec);
|
|
594
610
|
}
|
|
595
611
|
if (params.pluginId.startsWith(BUILTIN_CHANNEL_PLUGIN_ID_PREFIX)) {
|
|
596
612
|
const channelSlug = params.pluginId.slice(BUILTIN_CHANNEL_PLUGIN_ID_PREFIX.length).trim();
|
|
@@ -648,7 +664,7 @@ function mergeInstalledPluginRecords(primary, secondary) {
|
|
|
648
664
|
function dedupeInstalledPluginRecordsByCanonicalSpec(records) {
|
|
649
665
|
const deduped = /* @__PURE__ */ new Map();
|
|
650
666
|
for (const record of records) {
|
|
651
|
-
const canonicalSpec =
|
|
667
|
+
const canonicalSpec = normalizePluginNpmSpec(record.spec).trim();
|
|
652
668
|
if (!canonicalSpec) {
|
|
653
669
|
continue;
|
|
654
670
|
}
|
|
@@ -762,7 +778,7 @@ function collectMarketplaceInstalledView(options) {
|
|
|
762
778
|
try {
|
|
763
779
|
const pluginReport = buildPluginStatusReport({
|
|
764
780
|
config,
|
|
765
|
-
workspaceDir:
|
|
781
|
+
workspaceDir: getWorkspacePathFromConfig3(config)
|
|
766
782
|
});
|
|
767
783
|
discoveredPlugins = pluginReport.plugins;
|
|
768
784
|
} catch {
|
|
@@ -852,10 +868,10 @@ function collectMarketplaceInstalledView(options) {
|
|
|
852
868
|
}
|
|
853
869
|
const dedupedPluginRecords = dedupeInstalledPluginRecordsByCanonicalSpec(pluginRecords);
|
|
854
870
|
const pluginSpecSet = new Set(dedupedPluginRecords.map((record) => record.spec));
|
|
855
|
-
const workspacePath =
|
|
856
|
-
const skillsLoader =
|
|
857
|
-
const availableSkillSet = new Set(skillsLoader
|
|
858
|
-
const listedSkills = skillsLoader
|
|
871
|
+
const workspacePath = getWorkspacePathFromConfig3(config);
|
|
872
|
+
const skillsLoader = createSkillsLoader(workspacePath);
|
|
873
|
+
const availableSkillSet = new Set((skillsLoader?.listSkills(true) ?? []).map((skill) => skill.name));
|
|
874
|
+
const listedSkills = skillsLoader?.listSkills(false) ?? [];
|
|
859
875
|
const skillSpecSet = /* @__PURE__ */ new Set();
|
|
860
876
|
const skillRecords = listedSkills.map((skill) => {
|
|
861
877
|
const enabled = availableSkillSet.has(skill.name);
|
|
@@ -883,6 +899,29 @@ function collectMarketplaceInstalledView(options) {
|
|
|
883
899
|
records
|
|
884
900
|
};
|
|
885
901
|
}
|
|
902
|
+
function resolvePluginManageTargetId(options, rawTargetId) {
|
|
903
|
+
const targetId = rawTargetId.trim();
|
|
904
|
+
if (!targetId) {
|
|
905
|
+
return rawTargetId;
|
|
906
|
+
}
|
|
907
|
+
const normalizedTarget = normalizePluginNpmSpec(targetId).toLowerCase();
|
|
908
|
+
const installed = collectMarketplaceInstalledView(options);
|
|
909
|
+
const pluginRecords = installed.records.filter((record) => record.type === "plugin");
|
|
910
|
+
const lowerTargetId = targetId.toLowerCase();
|
|
911
|
+
for (const record of pluginRecords) {
|
|
912
|
+
const recordId = record.id?.trim();
|
|
913
|
+
if (recordId && recordId.toLowerCase() === lowerTargetId) {
|
|
914
|
+
return recordId;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
for (const record of pluginRecords) {
|
|
918
|
+
const normalizedSpec = normalizePluginNpmSpec(record.spec).toLowerCase();
|
|
919
|
+
if (normalizedSpec === normalizedTarget && record.id && record.id.trim().length > 0) {
|
|
920
|
+
return record.id;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
return targetId;
|
|
924
|
+
}
|
|
886
925
|
function sanitizeMarketplaceItem(item) {
|
|
887
926
|
const next = { ...item };
|
|
888
927
|
delete next.metrics;
|
|
@@ -900,12 +939,12 @@ function toPositiveInt(raw, fallback) {
|
|
|
900
939
|
}
|
|
901
940
|
function collectKnownSkillNames(options) {
|
|
902
941
|
const config = loadConfigOrDefault(options.configPath);
|
|
903
|
-
const loader =
|
|
904
|
-
return new Set(loader
|
|
942
|
+
const loader = createSkillsLoader(getWorkspacePathFromConfig3(config));
|
|
943
|
+
return new Set((loader?.listSkills(false) ?? []).map((skill) => skill.name));
|
|
905
944
|
}
|
|
906
945
|
function isSupportedMarketplaceItem(item, knownSkillNames) {
|
|
907
946
|
if (item.type === "plugin") {
|
|
908
|
-
return item.install.kind === "npm" && item.install.spec
|
|
947
|
+
return item.install.kind === "npm" && isSupportedMarketplacePluginSpec(item.install.spec);
|
|
909
948
|
}
|
|
910
949
|
return item.install.kind === "builtin" && knownSkillNames.has(item.install.spec);
|
|
911
950
|
}
|
|
@@ -982,7 +1021,8 @@ async function installMarketplaceItem(params) {
|
|
|
982
1021
|
async function manageMarketplaceItem(params) {
|
|
983
1022
|
const type = params.body.type;
|
|
984
1023
|
const action = params.body.action;
|
|
985
|
-
const
|
|
1024
|
+
const requestedTargetId = typeof params.body.id === "string" && params.body.id.trim().length > 0 ? params.body.id.trim() : typeof params.body.spec === "string" && params.body.spec.trim().length > 0 ? params.body.spec.trim() : "";
|
|
1025
|
+
const targetId = type === "plugin" ? resolvePluginManageTargetId(params.options, requestedTargetId) : requestedTargetId;
|
|
986
1026
|
if (type !== "plugin" && type !== "skill" || action !== "enable" && action !== "disable" && action !== "uninstall" || !targetId) {
|
|
987
1027
|
throw new Error("INVALID_BODY:type, action and non-empty id/spec are required");
|
|
988
1028
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/server",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Nextclaw UI/API server.",
|
|
6
6
|
"type": "module",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@hono/node-server": "^1.13.3",
|
|
18
|
-
"@nextclaw/openclaw-compat": "^0.1.
|
|
18
|
+
"@nextclaw/openclaw-compat": "^0.1.21",
|
|
19
19
|
"hono": "^4.6.2",
|
|
20
20
|
"ws": "^8.18.0",
|
|
21
|
-
"@nextclaw/core": "^0.6.
|
|
21
|
+
"@nextclaw/core": "^0.6.28"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^20.17.6",
|