@nextclaw/server 0.5.2 → 0.5.4
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 +37 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -899,6 +899,40 @@ function collectMarketplaceInstalledView(options) {
|
|
|
899
899
|
records
|
|
900
900
|
};
|
|
901
901
|
}
|
|
902
|
+
function resolvePluginManageTargetId(options, rawTargetId, rawSpec) {
|
|
903
|
+
const targetId = rawTargetId.trim();
|
|
904
|
+
if (!targetId && !rawSpec) {
|
|
905
|
+
return rawTargetId;
|
|
906
|
+
}
|
|
907
|
+
const normalizedTarget = targetId ? normalizePluginNpmSpec(targetId).toLowerCase() : "";
|
|
908
|
+
const normalizedSpec = rawSpec ? normalizePluginNpmSpec(rawSpec).toLowerCase() : "";
|
|
909
|
+
const installed = collectMarketplaceInstalledView(options);
|
|
910
|
+
const pluginRecords = installed.records.filter((record) => record.type === "plugin");
|
|
911
|
+
const lowerTargetId = targetId.toLowerCase();
|
|
912
|
+
for (const record of pluginRecords) {
|
|
913
|
+
const recordId = record.id?.trim();
|
|
914
|
+
if (recordId && recordId.toLowerCase() === lowerTargetId) {
|
|
915
|
+
return recordId;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
if (normalizedTarget) {
|
|
919
|
+
for (const record of pluginRecords) {
|
|
920
|
+
const normalizedRecordSpec = normalizePluginNpmSpec(record.spec).toLowerCase();
|
|
921
|
+
if (normalizedRecordSpec === normalizedTarget && record.id && record.id.trim().length > 0) {
|
|
922
|
+
return record.id;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
if (normalizedSpec && normalizedSpec !== normalizedTarget) {
|
|
927
|
+
for (const record of pluginRecords) {
|
|
928
|
+
const normalizedRecordSpec = normalizePluginNpmSpec(record.spec).toLowerCase();
|
|
929
|
+
if (normalizedRecordSpec === normalizedSpec && record.id && record.id.trim().length > 0) {
|
|
930
|
+
return record.id;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return targetId || rawSpec || rawTargetId;
|
|
935
|
+
}
|
|
902
936
|
function sanitizeMarketplaceItem(item) {
|
|
903
937
|
const next = { ...item };
|
|
904
938
|
delete next.metrics;
|
|
@@ -998,7 +1032,9 @@ async function installMarketplaceItem(params) {
|
|
|
998
1032
|
async function manageMarketplaceItem(params) {
|
|
999
1033
|
const type = params.body.type;
|
|
1000
1034
|
const action = params.body.action;
|
|
1001
|
-
const
|
|
1035
|
+
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() : "";
|
|
1036
|
+
const rawSpec = typeof params.body.spec === "string" ? params.body.spec.trim() : "";
|
|
1037
|
+
const targetId = type === "plugin" ? resolvePluginManageTargetId(params.options, requestedTargetId, rawSpec) : requestedTargetId;
|
|
1002
1038
|
if (type !== "plugin" && type !== "skill" || action !== "enable" && action !== "disable" && action !== "uninstall" || !targetId) {
|
|
1003
1039
|
throw new Error("INVALID_BODY:type, action and non-empty id/spec are required");
|
|
1004
1040
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/server",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Nextclaw UI/API server.",
|
|
6
6
|
"type": "module",
|
|
@@ -15,7 +15,7 @@
|
|
|
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
21
|
"@nextclaw/core": "^0.6.28"
|