@vibe-lark/larkpal 0.1.84 → 0.1.86
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/account-id-BM1T6029-DYjVxojW.mjs +46 -0
- package/dist/activation-context--5yu1dPF-Bwsn3moT.mjs +172 -0
- package/dist/anthropic-TH8ERTXK.mjs +5962 -0
- package/dist/assistant-visible-text-DuFWokAt-CsbII5KS.mjs +596 -0
- package/dist/azure-openai-responses-Bt_Ag9Er.mjs +166 -0
- package/dist/boundary-file-read-BSd9MXPy--KThL5e6.mjs +594 -0
- package/dist/browser-lifecycle-cleanup-BdNsMhMD-O3tnAM4i.mjs +60 -0
- package/dist/build-DgTrEpge.mjs +3333 -0
- package/dist/bundled-compat-BpaDaAAu-D7oazKjD.mjs +5216 -0
- package/dist/bundled-dir-U738ay4K-DXK0q_TV.mjs +258 -0
- package/dist/call-DimWbpgJ-ColD4W-y.mjs +9993 -0
- package/dist/channel-bootstrap.runtime-BVclcGv1-DJv_Z-Kr.mjs +2 -0
- package/dist/channel-bootstrap.runtime-Cwcr38m2-VRfVCR-i.mjs +33 -0
- package/dist/chunk-D6SyT4dJ.mjs +36 -0
- package/dist/cli.mjs +6 -6
- package/dist/command-format-LSnUCVVF-BQ2SMKka.mjs +685 -0
- package/dist/config-Bim2pi8a-BQUdfiEi.mjs +9 -0
- package/dist/delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs +72 -0
- package/dist/diagnostic-ClMwNnUA-D6nUtLnb.mjs +140 -0
- package/dist/dist-CEGw8-2W.mjs +429 -0
- package/dist/dist-DD2aJ2UL.mjs +125135 -0
- package/dist/env-api-keys-BVvSg7T2.mjs +68 -0
- package/dist/event-stream-xaQWmyas.mjs +15226 -0
- package/dist/facade-loader-DFzIYYt_-CIr4HKtE.mjs +194 -0
- package/dist/from-DF7cl2wz.mjs +3842 -0
- package/dist/gateway-method-policy-C7rf0SeV-CJQMEYIE.mjs +28 -0
- package/dist/github-copilot-headers-DjqWtUoP.mjs +22 -0
- package/dist/google-C2pVrgBZ.mjs +336 -0
- package/dist/google-gemini-cli-BBxgS5Ho.mjs +623 -0
- package/dist/google-shared-BsWgwEk1.mjs +22791 -0
- package/dist/google-vertex-BsVLJrrC.mjs +358 -0
- package/dist/hash-DAFtW_W7.mjs +16 -0
- package/dist/headers-R3HdCbAE.mjs +8 -0
- package/dist/home-dir-C44RaPME-CBRS4HLP.mjs +93 -0
- package/dist/ids-BPsM98Uu-CwuxvUai.mjs +77 -0
- package/dist/image-2w3cApg7-CxpHvoB5.mjs +207 -0
- package/dist/io-CH2g3vsv-BOGlLlB8.mjs +26218 -0
- package/dist/jiti-loader-cache-Bat69wam-D6hCxboy.mjs +5049 -0
- package/dist/json-file-BQRNuxmK-DhJM5NsG.mjs +108 -0
- package/dist/json-parse-v_HIJjjI.mjs +381 -0
- package/dist/jws-GFcTvvVT.mjs +2291 -0
- package/dist/{lark-cli-provider-7LvtOIF_.mjs → lark-cli-provider-BARgbbmo.mjs} +1 -1
- package/dist/{live-smoke-nvTUPtrv.mjs → live-smoke-BhkBOcH9.mjs} +3 -3
- package/dist/load-context-mb7uvLSn-B10MAi3I.mjs +29 -0
- package/dist/loader-708jrx4Y-BOswuvpe.mjs +5053 -0
- package/dist/main.mjs +56780 -476
- package/dist/manifest-registry-_hxKCS2K-CZdeyN0f.mjs +3512 -0
- package/dist/mcp-server.mjs +1 -1
- package/dist/message-channel-Bk_YHfQg-AeNrPPpp.mjs +50 -0
- package/dist/message-channel-core-DTA--Gjh-CY4Tkb7N.mjs +29 -0
- package/dist/message.config.runtime-K-k4XOyq-DZTmXomP.mjs +2 -0
- package/dist/message.gateway.runtime-DqHOHRTQ-DH4ml0YF.mjs +2 -0
- package/dist/mistral-CaR4DiLu.mjs +28657 -0
- package/dist/model-auth-env-oyg2Hexc-DU_rOUU5.mjs +1306 -0
- package/dist/models-config-BmpSQJQF-Gfvh1n3A.mjs +1282 -0
- package/dist/models-config.runtime-BsU_22xk.mjs +2 -0
- package/dist/multipart-parser-DedmaB5g.mjs +294 -0
- package/dist/oauth-DOJeGfcE.mjs +6392 -0
- package/dist/openai-BDtIh3Ja.mjs +6693 -0
- package/dist/openai-codex-responses-C5EORu31.mjs +664 -0
- package/dist/openai-completions-CR_cS6gX.mjs +669 -0
- package/dist/openai-responses-oGxwZyuC.mjs +184 -0
- package/dist/openai-responses-shared-BixMSDZE.mjs +398 -0
- package/dist/paths-D6msg0S1-C2lYuisN.mjs +189 -0
- package/dist/paths-D92DjaZ--CTOESW2b.mjs +192 -0
- package/dist/pi-model-discovery-Bd0TWzo8-BFsJmeMb.mjs +227 -0
- package/dist/pi-model-discovery-runtime-CCCZxkd8.mjs +2 -0
- package/dist/pi-tools.before-tool-call.runtime-Bn7uqKie-C5ewk8kK.mjs +399 -0
- package/dist/plugin-auto-enable-DdH3n9V8-DsA1isaF.mjs +1456 -0
- package/dist/process-scoped-map-B2cWkYET-CXwUZ8CZ.mjs +61 -0
- package/dist/provider-discovery.runtime-BPzz1PFj.mjs +58 -0
- package/dist/provider-model-compat-CFqcq0it-BDDuBI3A.mjs +118 -0
- package/dist/provider-runtime-C8rljsNs-CIT93zoy.mjs +2 -0
- package/dist/provider-runtime-CT50mNIX-BwEV6GyO.mjs +573 -0
- package/dist/provider-stream-COLujAAo-CbJPDngm.mjs +35449 -0
- package/dist/providers.runtime-Ba7tOlq7-CXkhkzU9.mjs +219 -0
- package/dist/public-surface-loader-BVl0NQAE-C0piXtsT.mjs +117 -0
- package/dist/resolve-C33B7eeu-BNvYTl6k.mjs +1041 -0
- package/dist/runtime-Cym-fqI8-DaSDMH-a.mjs +120 -0
- package/dist/runtime-channel-state-CohMybAh-hXR6y5Gx.mjs +19 -0
- package/dist/runtime-snapshot-C54O1-gI-40cbyi7P.mjs +677 -0
- package/dist/runtime-state-IBOIXKOx-Bf9tcLvc.mjs +10 -0
- package/dist/runtime-web-tools-fallback.runtime-Ca-qn1mj-BCVImm7a.mjs +39 -0
- package/dist/runtime-web-tools-manifest.runtime-BgxQTjmq-Cb4nJkRT.mjs +2 -0
- package/dist/runtime-web-tools-public-artifacts.runtime-D9qcoWIX-BrQdXzOQ.mjs +2 -0
- package/dist/session-archive.runtime-B52_5vs4-BG-_IwNJ.mjs +2 -0
- package/dist/session-key-Cn2QoOyX-CuHbJMgR.mjs +82 -0
- package/dist/session-transcript-files.fs-DEeFXruQ-B1PF6nLy.mjs +147 -0
- package/dist/src-BgCX0MLG.mjs +813 -0
- package/dist/src-DYbqlAqf.mjs +1177 -0
- package/dist/subagent-announce-L5WsQatW-CQWI9GMd.mjs +344 -0
- package/dist/subagent-announce.registry.runtime-DiqZyeTs-BKuniyi3.mjs +28 -0
- package/dist/subagent-registry-steer-runtime-DFgZFC0j-BhBz0roy.mjs +211 -0
- package/dist/subagent-system-prompt-C1qnN--K-DpnTFP47.mjs +3061 -0
- package/dist/target-parsing-loaded-DKkb6jJY-BMD4CkpS.mjs +1002 -0
- package/dist/task-registry-delivery-runtime-Dd1CUkZF-C8U40a3O.mjs +2950 -0
- package/dist/task-registry-delivery-runtime-ragbeVx5-CNbFAkjD.mjs +2 -0
- package/dist/thinking-Bh-7MqXz-D3woGbO7.mjs +2 -0
- package/dist/transcript-E_-ISOkD-DWCfZP2p.mjs +2019 -0
- package/dist/transcript.runtime-BqhvZZdl-BPy42vBP.mjs +2 -0
- package/dist/transform-messages-DbhIzTxq.mjs +207 -0
- package/dist/web-provider-public-artifacts-BlpRwIUS-CGPSV4W2.mjs +295 -0
- package/dist/web-search-providers.runtime--0aUtC3b-DyuhC95V.mjs +200 -0
- package/package.json +3 -3
- package/dist/rolldown-runtime-wcPFST8Q.mjs +0 -13
- /package/dist/{interactive-init-B6j8j_Ap.mjs → interactive-init-BXQBalNr.mjs} +0 -0
|
@@ -0,0 +1,3512 @@
|
|
|
1
|
+
import { a as __toESM, t as __commonJSMin } from "./chunk-D6SyT4dJ.mjs";
|
|
2
|
+
import { c as normalizeOptionalString, o as normalizeLowercaseStringOrEmpty, s as normalizeOptionalLowercaseString } from "./home-dir-C44RaPME-CBRS4HLP.mjs";
|
|
3
|
+
import { c as resolveConfigDir, l as resolveUserPath, s as isRecord, t as resolveBundledPluginsDir } from "./bundled-dir-U738ay4K-DXK0q_TV.mjs";
|
|
4
|
+
import { i as normalizeChatChannelId } from "./ids-BPsM98Uu-CwuxvUai.mjs";
|
|
5
|
+
import { l as resolveBoundaryPathSync, n as matchBoundaryFileOpenFailure, r as openBoundaryFileSync, s as isPathInside$1 } from "./boundary-file-read-BSd9MXPy--KThL5e6.mjs";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import "node:process";
|
|
10
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/progress-line-B452nFKk.js
|
|
11
|
+
let activeStream = null;
|
|
12
|
+
function clearActiveProgressLine() {
|
|
13
|
+
if (!activeStream?.isTTY) return;
|
|
14
|
+
activeStream.write("\r\x1B[2K");
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/restore-Cq7ylBPo.js
|
|
18
|
+
const RESET_SEQUENCE = "\x1B[0m\x1B[?25h\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l\x1B[?2004l\x1B[<u\x1B[>4;0m";
|
|
19
|
+
function reportRestoreFailure(scope, err, reason) {
|
|
20
|
+
const suffix = reason ? ` (${reason})` : "";
|
|
21
|
+
const message = `[terminal] restore ${scope} failed${suffix}: ${String(err)}`;
|
|
22
|
+
try {
|
|
23
|
+
process.stderr.write(`${message}\n`);
|
|
24
|
+
} catch (writeErr) {
|
|
25
|
+
console.error(`[terminal] restore reporting failed${suffix}: ${String(writeErr)}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function restoreTerminalState(reason, options = {}) {
|
|
29
|
+
const resumeStdin = options.resumeStdinIfPaused ?? options.resumeStdin ?? false;
|
|
30
|
+
try {
|
|
31
|
+
clearActiveProgressLine();
|
|
32
|
+
} catch (err) {
|
|
33
|
+
reportRestoreFailure("progress line", err, reason);
|
|
34
|
+
}
|
|
35
|
+
const stdin = process.stdin;
|
|
36
|
+
if (stdin.isTTY && typeof stdin.setRawMode === "function") {
|
|
37
|
+
try {
|
|
38
|
+
stdin.setRawMode(false);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
reportRestoreFailure("raw mode", err, reason);
|
|
41
|
+
}
|
|
42
|
+
if (resumeStdin && typeof stdin.isPaused === "function" && stdin.isPaused()) try {
|
|
43
|
+
stdin.resume();
|
|
44
|
+
} catch (err) {
|
|
45
|
+
reportRestoreFailure("stdin resume", err, reason);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (process.stdout.isTTY) try {
|
|
49
|
+
process.stdout.write(RESET_SEQUENCE);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
reportRestoreFailure("stdout reset", err, reason);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/runtime-Dy0KdPiM.js
|
|
56
|
+
function shouldEmitRuntimeLog(env = process.env) {
|
|
57
|
+
if (env.VITEST !== "true") return true;
|
|
58
|
+
if (env.OPENCLAW_TEST_RUNTIME_LOG === "1") return true;
|
|
59
|
+
return typeof console.log.mock === "object";
|
|
60
|
+
}
|
|
61
|
+
function shouldEmitRuntimeStdout(env = process.env) {
|
|
62
|
+
if (env.VITEST !== "true") return true;
|
|
63
|
+
if (env.OPENCLAW_TEST_RUNTIME_LOG === "1") return true;
|
|
64
|
+
return typeof process.stdout.write.mock === "object";
|
|
65
|
+
}
|
|
66
|
+
function isPipeClosedError(err) {
|
|
67
|
+
const code = err?.code;
|
|
68
|
+
return code === "EPIPE" || code === "EIO";
|
|
69
|
+
}
|
|
70
|
+
function writeStdout(value) {
|
|
71
|
+
if (!shouldEmitRuntimeStdout()) return;
|
|
72
|
+
clearActiveProgressLine();
|
|
73
|
+
const line = value.endsWith("\n") ? value : `${value}\n`;
|
|
74
|
+
try {
|
|
75
|
+
process.stdout.write(line);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
if (isPipeClosedError(err)) return;
|
|
78
|
+
throw err;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function createRuntimeIo() {
|
|
82
|
+
return {
|
|
83
|
+
log: (...args) => {
|
|
84
|
+
if (!shouldEmitRuntimeLog()) return;
|
|
85
|
+
clearActiveProgressLine();
|
|
86
|
+
console.log(...args);
|
|
87
|
+
},
|
|
88
|
+
error: (...args) => {
|
|
89
|
+
clearActiveProgressLine();
|
|
90
|
+
console.error(...args);
|
|
91
|
+
},
|
|
92
|
+
writeStdout,
|
|
93
|
+
writeJson: (value, space = 2) => {
|
|
94
|
+
writeStdout(JSON.stringify(value, null, space > 0 ? space : void 0));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const defaultRuntime = {
|
|
99
|
+
...createRuntimeIo(),
|
|
100
|
+
exit: (code) => {
|
|
101
|
+
restoreTerminalState("runtime exit", { resumeStdinIfPaused: false });
|
|
102
|
+
process.exit(code);
|
|
103
|
+
throw new Error("unreachable");
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/string-normalization-5F-0OqbT.js
|
|
108
|
+
function normalizeStringEntries(list) {
|
|
109
|
+
return (list ?? []).map((entry) => normalizeOptionalString(String(entry)) ?? "").filter(Boolean);
|
|
110
|
+
}
|
|
111
|
+
function normalizeTrimmedStringList(value) {
|
|
112
|
+
if (!Array.isArray(value)) return [];
|
|
113
|
+
return value.flatMap((entry) => {
|
|
114
|
+
const normalized = normalizeOptionalString(entry);
|
|
115
|
+
return normalized ? [normalized] : [];
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function normalizeOptionalTrimmedStringList(value) {
|
|
119
|
+
const normalized = normalizeTrimmedStringList(value);
|
|
120
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
121
|
+
}
|
|
122
|
+
const MANIFEST_KEY = "openclaw";
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/unicode.js
|
|
125
|
+
var require_unicode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
126
|
+
module.exports.Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
|
127
|
+
module.exports.ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
|
|
128
|
+
module.exports.ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
|
|
129
|
+
}));
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/util.js
|
|
132
|
+
var require_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
133
|
+
const unicode = require_unicode();
|
|
134
|
+
module.exports = {
|
|
135
|
+
isSpaceSeparator(c) {
|
|
136
|
+
return typeof c === "string" && unicode.Space_Separator.test(c);
|
|
137
|
+
},
|
|
138
|
+
isIdStartChar(c) {
|
|
139
|
+
return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "$" || c === "_" || unicode.ID_Start.test(c));
|
|
140
|
+
},
|
|
141
|
+
isIdContinueChar(c) {
|
|
142
|
+
return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" || c === "$" || c === "_" || c === "" || c === "" || unicode.ID_Continue.test(c));
|
|
143
|
+
},
|
|
144
|
+
isDigit(c) {
|
|
145
|
+
return typeof c === "string" && /[0-9]/.test(c);
|
|
146
|
+
},
|
|
147
|
+
isHexDigit(c) {
|
|
148
|
+
return typeof c === "string" && /[0-9A-Fa-f]/.test(c);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}));
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/parse.js
|
|
154
|
+
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
155
|
+
const util = require_util();
|
|
156
|
+
let source;
|
|
157
|
+
let parseState;
|
|
158
|
+
let stack;
|
|
159
|
+
let pos;
|
|
160
|
+
let line;
|
|
161
|
+
let column;
|
|
162
|
+
let token;
|
|
163
|
+
let key;
|
|
164
|
+
let root;
|
|
165
|
+
module.exports = function parse(text, reviver) {
|
|
166
|
+
source = String(text);
|
|
167
|
+
parseState = "start";
|
|
168
|
+
stack = [];
|
|
169
|
+
pos = 0;
|
|
170
|
+
line = 1;
|
|
171
|
+
column = 0;
|
|
172
|
+
token = void 0;
|
|
173
|
+
key = void 0;
|
|
174
|
+
root = void 0;
|
|
175
|
+
do {
|
|
176
|
+
token = lex();
|
|
177
|
+
parseStates[parseState]();
|
|
178
|
+
} while (token.type !== "eof");
|
|
179
|
+
if (typeof reviver === "function") return internalize({ "": root }, "", reviver);
|
|
180
|
+
return root;
|
|
181
|
+
};
|
|
182
|
+
function internalize(holder, name, reviver) {
|
|
183
|
+
const value = holder[name];
|
|
184
|
+
if (value != null && typeof value === "object") if (Array.isArray(value)) for (let i = 0; i < value.length; i++) {
|
|
185
|
+
const key = String(i);
|
|
186
|
+
const replacement = internalize(value, key, reviver);
|
|
187
|
+
if (replacement === void 0) delete value[key];
|
|
188
|
+
else Object.defineProperty(value, key, {
|
|
189
|
+
value: replacement,
|
|
190
|
+
writable: true,
|
|
191
|
+
enumerable: true,
|
|
192
|
+
configurable: true
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
else for (const key in value) {
|
|
196
|
+
const replacement = internalize(value, key, reviver);
|
|
197
|
+
if (replacement === void 0) delete value[key];
|
|
198
|
+
else Object.defineProperty(value, key, {
|
|
199
|
+
value: replacement,
|
|
200
|
+
writable: true,
|
|
201
|
+
enumerable: true,
|
|
202
|
+
configurable: true
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return reviver.call(holder, name, value);
|
|
206
|
+
}
|
|
207
|
+
let lexState;
|
|
208
|
+
let buffer;
|
|
209
|
+
let doubleQuote;
|
|
210
|
+
let sign;
|
|
211
|
+
let c;
|
|
212
|
+
function lex() {
|
|
213
|
+
lexState = "default";
|
|
214
|
+
buffer = "";
|
|
215
|
+
doubleQuote = false;
|
|
216
|
+
sign = 1;
|
|
217
|
+
for (;;) {
|
|
218
|
+
c = peek();
|
|
219
|
+
const token = lexStates[lexState]();
|
|
220
|
+
if (token) return token;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function peek() {
|
|
224
|
+
if (source[pos]) return String.fromCodePoint(source.codePointAt(pos));
|
|
225
|
+
}
|
|
226
|
+
function read() {
|
|
227
|
+
const c = peek();
|
|
228
|
+
if (c === "\n") {
|
|
229
|
+
line++;
|
|
230
|
+
column = 0;
|
|
231
|
+
} else if (c) column += c.length;
|
|
232
|
+
else column++;
|
|
233
|
+
if (c) pos += c.length;
|
|
234
|
+
return c;
|
|
235
|
+
}
|
|
236
|
+
const lexStates = {
|
|
237
|
+
default() {
|
|
238
|
+
switch (c) {
|
|
239
|
+
case " ":
|
|
240
|
+
case "\v":
|
|
241
|
+
case "\f":
|
|
242
|
+
case " ":
|
|
243
|
+
case "\xA0":
|
|
244
|
+
case "":
|
|
245
|
+
case "\n":
|
|
246
|
+
case "\r":
|
|
247
|
+
case "\u2028":
|
|
248
|
+
case "\u2029":
|
|
249
|
+
read();
|
|
250
|
+
return;
|
|
251
|
+
case "/":
|
|
252
|
+
read();
|
|
253
|
+
lexState = "comment";
|
|
254
|
+
return;
|
|
255
|
+
case void 0:
|
|
256
|
+
read();
|
|
257
|
+
return newToken("eof");
|
|
258
|
+
}
|
|
259
|
+
if (util.isSpaceSeparator(c)) {
|
|
260
|
+
read();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
return lexStates[parseState]();
|
|
264
|
+
},
|
|
265
|
+
comment() {
|
|
266
|
+
switch (c) {
|
|
267
|
+
case "*":
|
|
268
|
+
read();
|
|
269
|
+
lexState = "multiLineComment";
|
|
270
|
+
return;
|
|
271
|
+
case "/":
|
|
272
|
+
read();
|
|
273
|
+
lexState = "singleLineComment";
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
throw invalidChar(read());
|
|
277
|
+
},
|
|
278
|
+
multiLineComment() {
|
|
279
|
+
switch (c) {
|
|
280
|
+
case "*":
|
|
281
|
+
read();
|
|
282
|
+
lexState = "multiLineCommentAsterisk";
|
|
283
|
+
return;
|
|
284
|
+
case void 0: throw invalidChar(read());
|
|
285
|
+
}
|
|
286
|
+
read();
|
|
287
|
+
},
|
|
288
|
+
multiLineCommentAsterisk() {
|
|
289
|
+
switch (c) {
|
|
290
|
+
case "*":
|
|
291
|
+
read();
|
|
292
|
+
return;
|
|
293
|
+
case "/":
|
|
294
|
+
read();
|
|
295
|
+
lexState = "default";
|
|
296
|
+
return;
|
|
297
|
+
case void 0: throw invalidChar(read());
|
|
298
|
+
}
|
|
299
|
+
read();
|
|
300
|
+
lexState = "multiLineComment";
|
|
301
|
+
},
|
|
302
|
+
singleLineComment() {
|
|
303
|
+
switch (c) {
|
|
304
|
+
case "\n":
|
|
305
|
+
case "\r":
|
|
306
|
+
case "\u2028":
|
|
307
|
+
case "\u2029":
|
|
308
|
+
read();
|
|
309
|
+
lexState = "default";
|
|
310
|
+
return;
|
|
311
|
+
case void 0:
|
|
312
|
+
read();
|
|
313
|
+
return newToken("eof");
|
|
314
|
+
}
|
|
315
|
+
read();
|
|
316
|
+
},
|
|
317
|
+
value() {
|
|
318
|
+
switch (c) {
|
|
319
|
+
case "{":
|
|
320
|
+
case "[": return newToken("punctuator", read());
|
|
321
|
+
case "n":
|
|
322
|
+
read();
|
|
323
|
+
literal("ull");
|
|
324
|
+
return newToken("null", null);
|
|
325
|
+
case "t":
|
|
326
|
+
read();
|
|
327
|
+
literal("rue");
|
|
328
|
+
return newToken("boolean", true);
|
|
329
|
+
case "f":
|
|
330
|
+
read();
|
|
331
|
+
literal("alse");
|
|
332
|
+
return newToken("boolean", false);
|
|
333
|
+
case "-":
|
|
334
|
+
case "+":
|
|
335
|
+
if (read() === "-") sign = -1;
|
|
336
|
+
lexState = "sign";
|
|
337
|
+
return;
|
|
338
|
+
case ".":
|
|
339
|
+
buffer = read();
|
|
340
|
+
lexState = "decimalPointLeading";
|
|
341
|
+
return;
|
|
342
|
+
case "0":
|
|
343
|
+
buffer = read();
|
|
344
|
+
lexState = "zero";
|
|
345
|
+
return;
|
|
346
|
+
case "1":
|
|
347
|
+
case "2":
|
|
348
|
+
case "3":
|
|
349
|
+
case "4":
|
|
350
|
+
case "5":
|
|
351
|
+
case "6":
|
|
352
|
+
case "7":
|
|
353
|
+
case "8":
|
|
354
|
+
case "9":
|
|
355
|
+
buffer = read();
|
|
356
|
+
lexState = "decimalInteger";
|
|
357
|
+
return;
|
|
358
|
+
case "I":
|
|
359
|
+
read();
|
|
360
|
+
literal("nfinity");
|
|
361
|
+
return newToken("numeric", Infinity);
|
|
362
|
+
case "N":
|
|
363
|
+
read();
|
|
364
|
+
literal("aN");
|
|
365
|
+
return newToken("numeric", NaN);
|
|
366
|
+
case "\"":
|
|
367
|
+
case "'":
|
|
368
|
+
doubleQuote = read() === "\"";
|
|
369
|
+
buffer = "";
|
|
370
|
+
lexState = "string";
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
throw invalidChar(read());
|
|
374
|
+
},
|
|
375
|
+
identifierNameStartEscape() {
|
|
376
|
+
if (c !== "u") throw invalidChar(read());
|
|
377
|
+
read();
|
|
378
|
+
const u = unicodeEscape();
|
|
379
|
+
switch (u) {
|
|
380
|
+
case "$":
|
|
381
|
+
case "_": break;
|
|
382
|
+
default:
|
|
383
|
+
if (!util.isIdStartChar(u)) throw invalidIdentifier();
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
buffer += u;
|
|
387
|
+
lexState = "identifierName";
|
|
388
|
+
},
|
|
389
|
+
identifierName() {
|
|
390
|
+
switch (c) {
|
|
391
|
+
case "$":
|
|
392
|
+
case "_":
|
|
393
|
+
case "":
|
|
394
|
+
case "":
|
|
395
|
+
buffer += read();
|
|
396
|
+
return;
|
|
397
|
+
case "\\":
|
|
398
|
+
read();
|
|
399
|
+
lexState = "identifierNameEscape";
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (util.isIdContinueChar(c)) {
|
|
403
|
+
buffer += read();
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
return newToken("identifier", buffer);
|
|
407
|
+
},
|
|
408
|
+
identifierNameEscape() {
|
|
409
|
+
if (c !== "u") throw invalidChar(read());
|
|
410
|
+
read();
|
|
411
|
+
const u = unicodeEscape();
|
|
412
|
+
switch (u) {
|
|
413
|
+
case "$":
|
|
414
|
+
case "_":
|
|
415
|
+
case "":
|
|
416
|
+
case "": break;
|
|
417
|
+
default:
|
|
418
|
+
if (!util.isIdContinueChar(u)) throw invalidIdentifier();
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
buffer += u;
|
|
422
|
+
lexState = "identifierName";
|
|
423
|
+
},
|
|
424
|
+
sign() {
|
|
425
|
+
switch (c) {
|
|
426
|
+
case ".":
|
|
427
|
+
buffer = read();
|
|
428
|
+
lexState = "decimalPointLeading";
|
|
429
|
+
return;
|
|
430
|
+
case "0":
|
|
431
|
+
buffer = read();
|
|
432
|
+
lexState = "zero";
|
|
433
|
+
return;
|
|
434
|
+
case "1":
|
|
435
|
+
case "2":
|
|
436
|
+
case "3":
|
|
437
|
+
case "4":
|
|
438
|
+
case "5":
|
|
439
|
+
case "6":
|
|
440
|
+
case "7":
|
|
441
|
+
case "8":
|
|
442
|
+
case "9":
|
|
443
|
+
buffer = read();
|
|
444
|
+
lexState = "decimalInteger";
|
|
445
|
+
return;
|
|
446
|
+
case "I":
|
|
447
|
+
read();
|
|
448
|
+
literal("nfinity");
|
|
449
|
+
return newToken("numeric", sign * Infinity);
|
|
450
|
+
case "N":
|
|
451
|
+
read();
|
|
452
|
+
literal("aN");
|
|
453
|
+
return newToken("numeric", NaN);
|
|
454
|
+
}
|
|
455
|
+
throw invalidChar(read());
|
|
456
|
+
},
|
|
457
|
+
zero() {
|
|
458
|
+
switch (c) {
|
|
459
|
+
case ".":
|
|
460
|
+
buffer += read();
|
|
461
|
+
lexState = "decimalPoint";
|
|
462
|
+
return;
|
|
463
|
+
case "e":
|
|
464
|
+
case "E":
|
|
465
|
+
buffer += read();
|
|
466
|
+
lexState = "decimalExponent";
|
|
467
|
+
return;
|
|
468
|
+
case "x":
|
|
469
|
+
case "X":
|
|
470
|
+
buffer += read();
|
|
471
|
+
lexState = "hexadecimal";
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
return newToken("numeric", sign * 0);
|
|
475
|
+
},
|
|
476
|
+
decimalInteger() {
|
|
477
|
+
switch (c) {
|
|
478
|
+
case ".":
|
|
479
|
+
buffer += read();
|
|
480
|
+
lexState = "decimalPoint";
|
|
481
|
+
return;
|
|
482
|
+
case "e":
|
|
483
|
+
case "E":
|
|
484
|
+
buffer += read();
|
|
485
|
+
lexState = "decimalExponent";
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (util.isDigit(c)) {
|
|
489
|
+
buffer += read();
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
return newToken("numeric", sign * Number(buffer));
|
|
493
|
+
},
|
|
494
|
+
decimalPointLeading() {
|
|
495
|
+
if (util.isDigit(c)) {
|
|
496
|
+
buffer += read();
|
|
497
|
+
lexState = "decimalFraction";
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
throw invalidChar(read());
|
|
501
|
+
},
|
|
502
|
+
decimalPoint() {
|
|
503
|
+
switch (c) {
|
|
504
|
+
case "e":
|
|
505
|
+
case "E":
|
|
506
|
+
buffer += read();
|
|
507
|
+
lexState = "decimalExponent";
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
if (util.isDigit(c)) {
|
|
511
|
+
buffer += read();
|
|
512
|
+
lexState = "decimalFraction";
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
return newToken("numeric", sign * Number(buffer));
|
|
516
|
+
},
|
|
517
|
+
decimalFraction() {
|
|
518
|
+
switch (c) {
|
|
519
|
+
case "e":
|
|
520
|
+
case "E":
|
|
521
|
+
buffer += read();
|
|
522
|
+
lexState = "decimalExponent";
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
if (util.isDigit(c)) {
|
|
526
|
+
buffer += read();
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
return newToken("numeric", sign * Number(buffer));
|
|
530
|
+
},
|
|
531
|
+
decimalExponent() {
|
|
532
|
+
switch (c) {
|
|
533
|
+
case "+":
|
|
534
|
+
case "-":
|
|
535
|
+
buffer += read();
|
|
536
|
+
lexState = "decimalExponentSign";
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
if (util.isDigit(c)) {
|
|
540
|
+
buffer += read();
|
|
541
|
+
lexState = "decimalExponentInteger";
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
throw invalidChar(read());
|
|
545
|
+
},
|
|
546
|
+
decimalExponentSign() {
|
|
547
|
+
if (util.isDigit(c)) {
|
|
548
|
+
buffer += read();
|
|
549
|
+
lexState = "decimalExponentInteger";
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
throw invalidChar(read());
|
|
553
|
+
},
|
|
554
|
+
decimalExponentInteger() {
|
|
555
|
+
if (util.isDigit(c)) {
|
|
556
|
+
buffer += read();
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
return newToken("numeric", sign * Number(buffer));
|
|
560
|
+
},
|
|
561
|
+
hexadecimal() {
|
|
562
|
+
if (util.isHexDigit(c)) {
|
|
563
|
+
buffer += read();
|
|
564
|
+
lexState = "hexadecimalInteger";
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
throw invalidChar(read());
|
|
568
|
+
},
|
|
569
|
+
hexadecimalInteger() {
|
|
570
|
+
if (util.isHexDigit(c)) {
|
|
571
|
+
buffer += read();
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
return newToken("numeric", sign * Number(buffer));
|
|
575
|
+
},
|
|
576
|
+
string() {
|
|
577
|
+
switch (c) {
|
|
578
|
+
case "\\":
|
|
579
|
+
read();
|
|
580
|
+
buffer += escape();
|
|
581
|
+
return;
|
|
582
|
+
case "\"":
|
|
583
|
+
if (doubleQuote) {
|
|
584
|
+
read();
|
|
585
|
+
return newToken("string", buffer);
|
|
586
|
+
}
|
|
587
|
+
buffer += read();
|
|
588
|
+
return;
|
|
589
|
+
case "'":
|
|
590
|
+
if (!doubleQuote) {
|
|
591
|
+
read();
|
|
592
|
+
return newToken("string", buffer);
|
|
593
|
+
}
|
|
594
|
+
buffer += read();
|
|
595
|
+
return;
|
|
596
|
+
case "\n":
|
|
597
|
+
case "\r": throw invalidChar(read());
|
|
598
|
+
case "\u2028":
|
|
599
|
+
case "\u2029":
|
|
600
|
+
separatorChar(c);
|
|
601
|
+
break;
|
|
602
|
+
case void 0: throw invalidChar(read());
|
|
603
|
+
}
|
|
604
|
+
buffer += read();
|
|
605
|
+
},
|
|
606
|
+
start() {
|
|
607
|
+
switch (c) {
|
|
608
|
+
case "{":
|
|
609
|
+
case "[": return newToken("punctuator", read());
|
|
610
|
+
}
|
|
611
|
+
lexState = "value";
|
|
612
|
+
},
|
|
613
|
+
beforePropertyName() {
|
|
614
|
+
switch (c) {
|
|
615
|
+
case "$":
|
|
616
|
+
case "_":
|
|
617
|
+
buffer = read();
|
|
618
|
+
lexState = "identifierName";
|
|
619
|
+
return;
|
|
620
|
+
case "\\":
|
|
621
|
+
read();
|
|
622
|
+
lexState = "identifierNameStartEscape";
|
|
623
|
+
return;
|
|
624
|
+
case "}": return newToken("punctuator", read());
|
|
625
|
+
case "\"":
|
|
626
|
+
case "'":
|
|
627
|
+
doubleQuote = read() === "\"";
|
|
628
|
+
lexState = "string";
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
if (util.isIdStartChar(c)) {
|
|
632
|
+
buffer += read();
|
|
633
|
+
lexState = "identifierName";
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
throw invalidChar(read());
|
|
637
|
+
},
|
|
638
|
+
afterPropertyName() {
|
|
639
|
+
if (c === ":") return newToken("punctuator", read());
|
|
640
|
+
throw invalidChar(read());
|
|
641
|
+
},
|
|
642
|
+
beforePropertyValue() {
|
|
643
|
+
lexState = "value";
|
|
644
|
+
},
|
|
645
|
+
afterPropertyValue() {
|
|
646
|
+
switch (c) {
|
|
647
|
+
case ",":
|
|
648
|
+
case "}": return newToken("punctuator", read());
|
|
649
|
+
}
|
|
650
|
+
throw invalidChar(read());
|
|
651
|
+
},
|
|
652
|
+
beforeArrayValue() {
|
|
653
|
+
if (c === "]") return newToken("punctuator", read());
|
|
654
|
+
lexState = "value";
|
|
655
|
+
},
|
|
656
|
+
afterArrayValue() {
|
|
657
|
+
switch (c) {
|
|
658
|
+
case ",":
|
|
659
|
+
case "]": return newToken("punctuator", read());
|
|
660
|
+
}
|
|
661
|
+
throw invalidChar(read());
|
|
662
|
+
},
|
|
663
|
+
end() {
|
|
664
|
+
throw invalidChar(read());
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
function newToken(type, value) {
|
|
668
|
+
return {
|
|
669
|
+
type,
|
|
670
|
+
value,
|
|
671
|
+
line,
|
|
672
|
+
column
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
function literal(s) {
|
|
676
|
+
for (const c of s) {
|
|
677
|
+
if (peek() !== c) throw invalidChar(read());
|
|
678
|
+
read();
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function escape() {
|
|
682
|
+
switch (peek()) {
|
|
683
|
+
case "b":
|
|
684
|
+
read();
|
|
685
|
+
return "\b";
|
|
686
|
+
case "f":
|
|
687
|
+
read();
|
|
688
|
+
return "\f";
|
|
689
|
+
case "n":
|
|
690
|
+
read();
|
|
691
|
+
return "\n";
|
|
692
|
+
case "r":
|
|
693
|
+
read();
|
|
694
|
+
return "\r";
|
|
695
|
+
case "t":
|
|
696
|
+
read();
|
|
697
|
+
return " ";
|
|
698
|
+
case "v":
|
|
699
|
+
read();
|
|
700
|
+
return "\v";
|
|
701
|
+
case "0":
|
|
702
|
+
read();
|
|
703
|
+
if (util.isDigit(peek())) throw invalidChar(read());
|
|
704
|
+
return "\0";
|
|
705
|
+
case "x":
|
|
706
|
+
read();
|
|
707
|
+
return hexEscape();
|
|
708
|
+
case "u":
|
|
709
|
+
read();
|
|
710
|
+
return unicodeEscape();
|
|
711
|
+
case "\n":
|
|
712
|
+
case "\u2028":
|
|
713
|
+
case "\u2029":
|
|
714
|
+
read();
|
|
715
|
+
return "";
|
|
716
|
+
case "\r":
|
|
717
|
+
read();
|
|
718
|
+
if (peek() === "\n") read();
|
|
719
|
+
return "";
|
|
720
|
+
case "1":
|
|
721
|
+
case "2":
|
|
722
|
+
case "3":
|
|
723
|
+
case "4":
|
|
724
|
+
case "5":
|
|
725
|
+
case "6":
|
|
726
|
+
case "7":
|
|
727
|
+
case "8":
|
|
728
|
+
case "9": throw invalidChar(read());
|
|
729
|
+
case void 0: throw invalidChar(read());
|
|
730
|
+
}
|
|
731
|
+
return read();
|
|
732
|
+
}
|
|
733
|
+
function hexEscape() {
|
|
734
|
+
let buffer = "";
|
|
735
|
+
let c = peek();
|
|
736
|
+
if (!util.isHexDigit(c)) throw invalidChar(read());
|
|
737
|
+
buffer += read();
|
|
738
|
+
c = peek();
|
|
739
|
+
if (!util.isHexDigit(c)) throw invalidChar(read());
|
|
740
|
+
buffer += read();
|
|
741
|
+
return String.fromCodePoint(parseInt(buffer, 16));
|
|
742
|
+
}
|
|
743
|
+
function unicodeEscape() {
|
|
744
|
+
let buffer = "";
|
|
745
|
+
let count = 4;
|
|
746
|
+
while (count-- > 0) {
|
|
747
|
+
const c = peek();
|
|
748
|
+
if (!util.isHexDigit(c)) throw invalidChar(read());
|
|
749
|
+
buffer += read();
|
|
750
|
+
}
|
|
751
|
+
return String.fromCodePoint(parseInt(buffer, 16));
|
|
752
|
+
}
|
|
753
|
+
const parseStates = {
|
|
754
|
+
start() {
|
|
755
|
+
if (token.type === "eof") throw invalidEOF();
|
|
756
|
+
push();
|
|
757
|
+
},
|
|
758
|
+
beforePropertyName() {
|
|
759
|
+
switch (token.type) {
|
|
760
|
+
case "identifier":
|
|
761
|
+
case "string":
|
|
762
|
+
key = token.value;
|
|
763
|
+
parseState = "afterPropertyName";
|
|
764
|
+
return;
|
|
765
|
+
case "punctuator":
|
|
766
|
+
pop();
|
|
767
|
+
return;
|
|
768
|
+
case "eof": throw invalidEOF();
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
afterPropertyName() {
|
|
772
|
+
if (token.type === "eof") throw invalidEOF();
|
|
773
|
+
parseState = "beforePropertyValue";
|
|
774
|
+
},
|
|
775
|
+
beforePropertyValue() {
|
|
776
|
+
if (token.type === "eof") throw invalidEOF();
|
|
777
|
+
push();
|
|
778
|
+
},
|
|
779
|
+
beforeArrayValue() {
|
|
780
|
+
if (token.type === "eof") throw invalidEOF();
|
|
781
|
+
if (token.type === "punctuator" && token.value === "]") {
|
|
782
|
+
pop();
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
push();
|
|
786
|
+
},
|
|
787
|
+
afterPropertyValue() {
|
|
788
|
+
if (token.type === "eof") throw invalidEOF();
|
|
789
|
+
switch (token.value) {
|
|
790
|
+
case ",":
|
|
791
|
+
parseState = "beforePropertyName";
|
|
792
|
+
return;
|
|
793
|
+
case "}": pop();
|
|
794
|
+
}
|
|
795
|
+
},
|
|
796
|
+
afterArrayValue() {
|
|
797
|
+
if (token.type === "eof") throw invalidEOF();
|
|
798
|
+
switch (token.value) {
|
|
799
|
+
case ",":
|
|
800
|
+
parseState = "beforeArrayValue";
|
|
801
|
+
return;
|
|
802
|
+
case "]": pop();
|
|
803
|
+
}
|
|
804
|
+
},
|
|
805
|
+
end() {}
|
|
806
|
+
};
|
|
807
|
+
function push() {
|
|
808
|
+
let value;
|
|
809
|
+
switch (token.type) {
|
|
810
|
+
case "punctuator":
|
|
811
|
+
switch (token.value) {
|
|
812
|
+
case "{":
|
|
813
|
+
value = {};
|
|
814
|
+
break;
|
|
815
|
+
case "[":
|
|
816
|
+
value = [];
|
|
817
|
+
break;
|
|
818
|
+
}
|
|
819
|
+
break;
|
|
820
|
+
case "null":
|
|
821
|
+
case "boolean":
|
|
822
|
+
case "numeric":
|
|
823
|
+
case "string":
|
|
824
|
+
value = token.value;
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
if (root === void 0) root = value;
|
|
828
|
+
else {
|
|
829
|
+
const parent = stack[stack.length - 1];
|
|
830
|
+
if (Array.isArray(parent)) parent.push(value);
|
|
831
|
+
else Object.defineProperty(parent, key, {
|
|
832
|
+
value,
|
|
833
|
+
writable: true,
|
|
834
|
+
enumerable: true,
|
|
835
|
+
configurable: true
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
if (value !== null && typeof value === "object") {
|
|
839
|
+
stack.push(value);
|
|
840
|
+
if (Array.isArray(value)) parseState = "beforeArrayValue";
|
|
841
|
+
else parseState = "beforePropertyName";
|
|
842
|
+
} else {
|
|
843
|
+
const current = stack[stack.length - 1];
|
|
844
|
+
if (current == null) parseState = "end";
|
|
845
|
+
else if (Array.isArray(current)) parseState = "afterArrayValue";
|
|
846
|
+
else parseState = "afterPropertyValue";
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
function pop() {
|
|
850
|
+
stack.pop();
|
|
851
|
+
const current = stack[stack.length - 1];
|
|
852
|
+
if (current == null) parseState = "end";
|
|
853
|
+
else if (Array.isArray(current)) parseState = "afterArrayValue";
|
|
854
|
+
else parseState = "afterPropertyValue";
|
|
855
|
+
}
|
|
856
|
+
function invalidChar(c) {
|
|
857
|
+
if (c === void 0) return syntaxError(`JSON5: invalid end of input at ${line}:${column}`);
|
|
858
|
+
return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`);
|
|
859
|
+
}
|
|
860
|
+
function invalidEOF() {
|
|
861
|
+
return syntaxError(`JSON5: invalid end of input at ${line}:${column}`);
|
|
862
|
+
}
|
|
863
|
+
function invalidIdentifier() {
|
|
864
|
+
column -= 5;
|
|
865
|
+
return syntaxError(`JSON5: invalid identifier character at ${line}:${column}`);
|
|
866
|
+
}
|
|
867
|
+
function separatorChar(c) {
|
|
868
|
+
console.warn(`JSON5: '${formatChar(c)}' in strings is not valid ECMAScript; consider escaping`);
|
|
869
|
+
}
|
|
870
|
+
function formatChar(c) {
|
|
871
|
+
const replacements = {
|
|
872
|
+
"'": "\\'",
|
|
873
|
+
"\"": "\\\"",
|
|
874
|
+
"\\": "\\\\",
|
|
875
|
+
"\b": "\\b",
|
|
876
|
+
"\f": "\\f",
|
|
877
|
+
"\n": "\\n",
|
|
878
|
+
"\r": "\\r",
|
|
879
|
+
" ": "\\t",
|
|
880
|
+
"\v": "\\v",
|
|
881
|
+
"\0": "\\0",
|
|
882
|
+
"\u2028": "\\u2028",
|
|
883
|
+
"\u2029": "\\u2029"
|
|
884
|
+
};
|
|
885
|
+
if (replacements[c]) return replacements[c];
|
|
886
|
+
if (c < " ") {
|
|
887
|
+
const hexString = c.charCodeAt(0).toString(16);
|
|
888
|
+
return "\\x" + ("00" + hexString).substring(hexString.length);
|
|
889
|
+
}
|
|
890
|
+
return c;
|
|
891
|
+
}
|
|
892
|
+
function syntaxError(message) {
|
|
893
|
+
const err = new SyntaxError(message);
|
|
894
|
+
err.lineNumber = line;
|
|
895
|
+
err.columnNumber = column;
|
|
896
|
+
return err;
|
|
897
|
+
}
|
|
898
|
+
}));
|
|
899
|
+
//#endregion
|
|
900
|
+
//#region node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/stringify.js
|
|
901
|
+
var require_stringify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
902
|
+
const util = require_util();
|
|
903
|
+
module.exports = function stringify(value, replacer, space) {
|
|
904
|
+
const stack = [];
|
|
905
|
+
let indent = "";
|
|
906
|
+
let propertyList;
|
|
907
|
+
let replacerFunc;
|
|
908
|
+
let gap = "";
|
|
909
|
+
let quote;
|
|
910
|
+
if (replacer != null && typeof replacer === "object" && !Array.isArray(replacer)) {
|
|
911
|
+
space = replacer.space;
|
|
912
|
+
quote = replacer.quote;
|
|
913
|
+
replacer = replacer.replacer;
|
|
914
|
+
}
|
|
915
|
+
if (typeof replacer === "function") replacerFunc = replacer;
|
|
916
|
+
else if (Array.isArray(replacer)) {
|
|
917
|
+
propertyList = [];
|
|
918
|
+
for (const v of replacer) {
|
|
919
|
+
let item;
|
|
920
|
+
if (typeof v === "string") item = v;
|
|
921
|
+
else if (typeof v === "number" || v instanceof String || v instanceof Number) item = String(v);
|
|
922
|
+
if (item !== void 0 && propertyList.indexOf(item) < 0) propertyList.push(item);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
if (space instanceof Number) space = Number(space);
|
|
926
|
+
else if (space instanceof String) space = String(space);
|
|
927
|
+
if (typeof space === "number") {
|
|
928
|
+
if (space > 0) {
|
|
929
|
+
space = Math.min(10, Math.floor(space));
|
|
930
|
+
gap = " ".substr(0, space);
|
|
931
|
+
}
|
|
932
|
+
} else if (typeof space === "string") gap = space.substr(0, 10);
|
|
933
|
+
return serializeProperty("", { "": value });
|
|
934
|
+
function serializeProperty(key, holder) {
|
|
935
|
+
let value = holder[key];
|
|
936
|
+
if (value != null) {
|
|
937
|
+
if (typeof value.toJSON5 === "function") value = value.toJSON5(key);
|
|
938
|
+
else if (typeof value.toJSON === "function") value = value.toJSON(key);
|
|
939
|
+
}
|
|
940
|
+
if (replacerFunc) value = replacerFunc.call(holder, key, value);
|
|
941
|
+
if (value instanceof Number) value = Number(value);
|
|
942
|
+
else if (value instanceof String) value = String(value);
|
|
943
|
+
else if (value instanceof Boolean) value = value.valueOf();
|
|
944
|
+
switch (value) {
|
|
945
|
+
case null: return "null";
|
|
946
|
+
case true: return "true";
|
|
947
|
+
case false: return "false";
|
|
948
|
+
}
|
|
949
|
+
if (typeof value === "string") return quoteString(value, false);
|
|
950
|
+
if (typeof value === "number") return String(value);
|
|
951
|
+
if (typeof value === "object") return Array.isArray(value) ? serializeArray(value) : serializeObject(value);
|
|
952
|
+
}
|
|
953
|
+
function quoteString(value) {
|
|
954
|
+
const quotes = {
|
|
955
|
+
"'": .1,
|
|
956
|
+
"\"": .2
|
|
957
|
+
};
|
|
958
|
+
const replacements = {
|
|
959
|
+
"'": "\\'",
|
|
960
|
+
"\"": "\\\"",
|
|
961
|
+
"\\": "\\\\",
|
|
962
|
+
"\b": "\\b",
|
|
963
|
+
"\f": "\\f",
|
|
964
|
+
"\n": "\\n",
|
|
965
|
+
"\r": "\\r",
|
|
966
|
+
" ": "\\t",
|
|
967
|
+
"\v": "\\v",
|
|
968
|
+
"\0": "\\0",
|
|
969
|
+
"\u2028": "\\u2028",
|
|
970
|
+
"\u2029": "\\u2029"
|
|
971
|
+
};
|
|
972
|
+
let product = "";
|
|
973
|
+
for (let i = 0; i < value.length; i++) {
|
|
974
|
+
const c = value[i];
|
|
975
|
+
switch (c) {
|
|
976
|
+
case "'":
|
|
977
|
+
case "\"":
|
|
978
|
+
quotes[c]++;
|
|
979
|
+
product += c;
|
|
980
|
+
continue;
|
|
981
|
+
case "\0": if (util.isDigit(value[i + 1])) {
|
|
982
|
+
product += "\\x00";
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
if (replacements[c]) {
|
|
987
|
+
product += replacements[c];
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
990
|
+
if (c < " ") {
|
|
991
|
+
let hexString = c.charCodeAt(0).toString(16);
|
|
992
|
+
product += "\\x" + ("00" + hexString).substring(hexString.length);
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
product += c;
|
|
996
|
+
}
|
|
997
|
+
const quoteChar = quote || Object.keys(quotes).reduce((a, b) => quotes[a] < quotes[b] ? a : b);
|
|
998
|
+
product = product.replace(new RegExp(quoteChar, "g"), replacements[quoteChar]);
|
|
999
|
+
return quoteChar + product + quoteChar;
|
|
1000
|
+
}
|
|
1001
|
+
function serializeObject(value) {
|
|
1002
|
+
if (stack.indexOf(value) >= 0) throw TypeError("Converting circular structure to JSON5");
|
|
1003
|
+
stack.push(value);
|
|
1004
|
+
let stepback = indent;
|
|
1005
|
+
indent = indent + gap;
|
|
1006
|
+
let keys = propertyList || Object.keys(value);
|
|
1007
|
+
let partial = [];
|
|
1008
|
+
for (const key of keys) {
|
|
1009
|
+
const propertyString = serializeProperty(key, value);
|
|
1010
|
+
if (propertyString !== void 0) {
|
|
1011
|
+
let member = serializeKey(key) + ":";
|
|
1012
|
+
if (gap !== "") member += " ";
|
|
1013
|
+
member += propertyString;
|
|
1014
|
+
partial.push(member);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
let final;
|
|
1018
|
+
if (partial.length === 0) final = "{}";
|
|
1019
|
+
else {
|
|
1020
|
+
let properties;
|
|
1021
|
+
if (gap === "") {
|
|
1022
|
+
properties = partial.join(",");
|
|
1023
|
+
final = "{" + properties + "}";
|
|
1024
|
+
} else {
|
|
1025
|
+
let separator = ",\n" + indent;
|
|
1026
|
+
properties = partial.join(separator);
|
|
1027
|
+
final = "{\n" + indent + properties + ",\n" + stepback + "}";
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
stack.pop();
|
|
1031
|
+
indent = stepback;
|
|
1032
|
+
return final;
|
|
1033
|
+
}
|
|
1034
|
+
function serializeKey(key) {
|
|
1035
|
+
if (key.length === 0) return quoteString(key, true);
|
|
1036
|
+
const firstChar = String.fromCodePoint(key.codePointAt(0));
|
|
1037
|
+
if (!util.isIdStartChar(firstChar)) return quoteString(key, true);
|
|
1038
|
+
for (let i = firstChar.length; i < key.length; i++) if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) return quoteString(key, true);
|
|
1039
|
+
return key;
|
|
1040
|
+
}
|
|
1041
|
+
function serializeArray(value) {
|
|
1042
|
+
if (stack.indexOf(value) >= 0) throw TypeError("Converting circular structure to JSON5");
|
|
1043
|
+
stack.push(value);
|
|
1044
|
+
let stepback = indent;
|
|
1045
|
+
indent = indent + gap;
|
|
1046
|
+
let partial = [];
|
|
1047
|
+
for (let i = 0; i < value.length; i++) {
|
|
1048
|
+
const propertyString = serializeProperty(String(i), value);
|
|
1049
|
+
partial.push(propertyString !== void 0 ? propertyString : "null");
|
|
1050
|
+
}
|
|
1051
|
+
let final;
|
|
1052
|
+
if (partial.length === 0) final = "[]";
|
|
1053
|
+
else if (gap === "") final = "[" + partial.join(",") + "]";
|
|
1054
|
+
else {
|
|
1055
|
+
let separator = ",\n" + indent;
|
|
1056
|
+
let properties = partial.join(separator);
|
|
1057
|
+
final = "[\n" + indent + properties + ",\n" + stepback + "]";
|
|
1058
|
+
}
|
|
1059
|
+
stack.pop();
|
|
1060
|
+
indent = stepback;
|
|
1061
|
+
return final;
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
}));
|
|
1065
|
+
//#endregion
|
|
1066
|
+
//#region node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/index.js
|
|
1067
|
+
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1068
|
+
module.exports = {
|
|
1069
|
+
parse: require_parse(),
|
|
1070
|
+
stringify: require_stringify()
|
|
1071
|
+
};
|
|
1072
|
+
}));
|
|
1073
|
+
//#endregion
|
|
1074
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/manifest-DgyExZJE.js
|
|
1075
|
+
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
1076
|
+
function normalizeManifestCommandAliases(value) {
|
|
1077
|
+
if (!Array.isArray(value)) return;
|
|
1078
|
+
const normalized = [];
|
|
1079
|
+
for (const entry of value) {
|
|
1080
|
+
if (typeof entry === "string") {
|
|
1081
|
+
const name = normalizeOptionalString(entry) ?? "";
|
|
1082
|
+
if (name) normalized.push({ name });
|
|
1083
|
+
continue;
|
|
1084
|
+
}
|
|
1085
|
+
if (!isRecord(entry)) continue;
|
|
1086
|
+
const name = normalizeOptionalString(entry.name) ?? "";
|
|
1087
|
+
if (!name) continue;
|
|
1088
|
+
const kind = entry.kind === "runtime-slash" ? entry.kind : void 0;
|
|
1089
|
+
const cliCommand = normalizeOptionalString(entry.cliCommand) ?? "";
|
|
1090
|
+
normalized.push({
|
|
1091
|
+
name,
|
|
1092
|
+
...kind ? { kind } : {},
|
|
1093
|
+
...cliCommand ? { cliCommand } : {}
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1097
|
+
}
|
|
1098
|
+
function resolveManifestCommandAliasOwnerInRegistry(params) {
|
|
1099
|
+
const normalizedCommand = normalizeOptionalLowercaseString(params.command);
|
|
1100
|
+
if (!normalizedCommand) return;
|
|
1101
|
+
if (params.registry.plugins.some((plugin) => normalizeOptionalLowercaseString(plugin.id) === normalizedCommand)) return;
|
|
1102
|
+
for (const plugin of params.registry.plugins) {
|
|
1103
|
+
const alias = plugin.commandAliases?.find((entry) => normalizeOptionalLowercaseString(entry.name) === normalizedCommand);
|
|
1104
|
+
if (alias) return {
|
|
1105
|
+
...alias,
|
|
1106
|
+
pluginId: plugin.id
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
const PLUGIN_MANIFEST_FILENAME = "openclaw.plugin.json";
|
|
1111
|
+
const PLUGIN_MANIFEST_FILENAMES = [PLUGIN_MANIFEST_FILENAME];
|
|
1112
|
+
const MAX_PLUGIN_MANIFEST_BYTES = 256 * 1024;
|
|
1113
|
+
function normalizeStringListRecord(value) {
|
|
1114
|
+
if (!isRecord(value)) return;
|
|
1115
|
+
const normalized = {};
|
|
1116
|
+
for (const [key, rawValues] of Object.entries(value)) {
|
|
1117
|
+
const providerId = normalizeOptionalString(key) ?? "";
|
|
1118
|
+
if (!providerId) continue;
|
|
1119
|
+
const values = normalizeTrimmedStringList(rawValues);
|
|
1120
|
+
if (values.length === 0) continue;
|
|
1121
|
+
normalized[providerId] = values;
|
|
1122
|
+
}
|
|
1123
|
+
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
1124
|
+
}
|
|
1125
|
+
function normalizeStringRecord(value) {
|
|
1126
|
+
if (!isRecord(value)) return;
|
|
1127
|
+
const normalized = {};
|
|
1128
|
+
for (const [rawKey, rawValue] of Object.entries(value)) {
|
|
1129
|
+
const key = normalizeOptionalString(rawKey) ?? "";
|
|
1130
|
+
const value = normalizeOptionalString(rawValue) ?? "";
|
|
1131
|
+
if (!key || !value) continue;
|
|
1132
|
+
normalized[key] = value;
|
|
1133
|
+
}
|
|
1134
|
+
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
1135
|
+
}
|
|
1136
|
+
const MEDIA_UNDERSTANDING_CAPABILITIES = new Set([
|
|
1137
|
+
"image",
|
|
1138
|
+
"audio",
|
|
1139
|
+
"video"
|
|
1140
|
+
]);
|
|
1141
|
+
function normalizeMediaUnderstandingCapabilityRecord(value) {
|
|
1142
|
+
if (!isRecord(value)) return;
|
|
1143
|
+
const normalized = {};
|
|
1144
|
+
for (const [rawKey, rawValue] of Object.entries(value)) {
|
|
1145
|
+
if (!MEDIA_UNDERSTANDING_CAPABILITIES.has(rawKey)) continue;
|
|
1146
|
+
const model = normalizeOptionalString(rawValue);
|
|
1147
|
+
if (model) normalized[rawKey] = model;
|
|
1148
|
+
}
|
|
1149
|
+
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
1150
|
+
}
|
|
1151
|
+
function normalizeMediaUnderstandingPriorityRecord(value) {
|
|
1152
|
+
if (!isRecord(value)) return;
|
|
1153
|
+
const normalized = {};
|
|
1154
|
+
for (const [rawKey, rawValue] of Object.entries(value)) {
|
|
1155
|
+
if (!MEDIA_UNDERSTANDING_CAPABILITIES.has(rawKey) || typeof rawValue !== "number" || !Number.isFinite(rawValue)) continue;
|
|
1156
|
+
normalized[rawKey] = rawValue;
|
|
1157
|
+
}
|
|
1158
|
+
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
1159
|
+
}
|
|
1160
|
+
function normalizeMediaUnderstandingCapabilities(value) {
|
|
1161
|
+
const values = normalizeTrimmedStringList(value).filter((entry) => MEDIA_UNDERSTANDING_CAPABILITIES.has(entry));
|
|
1162
|
+
return values.length > 0 ? values : void 0;
|
|
1163
|
+
}
|
|
1164
|
+
function normalizeMediaUnderstandingNativeDocumentInputs(value) {
|
|
1165
|
+
const values = normalizeTrimmedStringList(value).filter((entry) => entry === "pdf");
|
|
1166
|
+
return values.length > 0 ? values : void 0;
|
|
1167
|
+
}
|
|
1168
|
+
function normalizeMediaUnderstandingProviderMetadata(value) {
|
|
1169
|
+
if (!isRecord(value)) return;
|
|
1170
|
+
const normalized = {};
|
|
1171
|
+
for (const [rawProviderId, rawMetadata] of Object.entries(value)) {
|
|
1172
|
+
const providerId = normalizeOptionalString(rawProviderId) ?? "";
|
|
1173
|
+
if (!providerId || !isRecord(rawMetadata)) continue;
|
|
1174
|
+
const capabilities = normalizeMediaUnderstandingCapabilities(rawMetadata.capabilities);
|
|
1175
|
+
const defaultModels = normalizeMediaUnderstandingCapabilityRecord(rawMetadata.defaultModels);
|
|
1176
|
+
const autoPriority = normalizeMediaUnderstandingPriorityRecord(rawMetadata.autoPriority);
|
|
1177
|
+
const nativeDocumentInputs = normalizeMediaUnderstandingNativeDocumentInputs(rawMetadata.nativeDocumentInputs);
|
|
1178
|
+
const metadata = {
|
|
1179
|
+
...capabilities ? { capabilities } : {},
|
|
1180
|
+
...defaultModels ? { defaultModels } : {},
|
|
1181
|
+
...autoPriority ? { autoPriority } : {},
|
|
1182
|
+
...nativeDocumentInputs ? { nativeDocumentInputs } : {}
|
|
1183
|
+
};
|
|
1184
|
+
if (Object.keys(metadata).length > 0) normalized[providerId] = metadata;
|
|
1185
|
+
}
|
|
1186
|
+
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
1187
|
+
}
|
|
1188
|
+
function normalizeManifestContracts(value) {
|
|
1189
|
+
if (!isRecord(value)) return;
|
|
1190
|
+
const embeddedExtensionFactories = normalizeTrimmedStringList(value.embeddedExtensionFactories);
|
|
1191
|
+
const externalAuthProviders = normalizeTrimmedStringList(value.externalAuthProviders);
|
|
1192
|
+
const memoryEmbeddingProviders = normalizeTrimmedStringList(value.memoryEmbeddingProviders);
|
|
1193
|
+
const speechProviders = normalizeTrimmedStringList(value.speechProviders);
|
|
1194
|
+
const realtimeTranscriptionProviders = normalizeTrimmedStringList(value.realtimeTranscriptionProviders);
|
|
1195
|
+
const realtimeVoiceProviders = normalizeTrimmedStringList(value.realtimeVoiceProviders);
|
|
1196
|
+
const mediaUnderstandingProviders = normalizeTrimmedStringList(value.mediaUnderstandingProviders);
|
|
1197
|
+
const imageGenerationProviders = normalizeTrimmedStringList(value.imageGenerationProviders);
|
|
1198
|
+
const videoGenerationProviders = normalizeTrimmedStringList(value.videoGenerationProviders);
|
|
1199
|
+
const musicGenerationProviders = normalizeTrimmedStringList(value.musicGenerationProviders);
|
|
1200
|
+
const webFetchProviders = normalizeTrimmedStringList(value.webFetchProviders);
|
|
1201
|
+
const webSearchProviders = normalizeTrimmedStringList(value.webSearchProviders);
|
|
1202
|
+
const tools = normalizeTrimmedStringList(value.tools);
|
|
1203
|
+
const contracts = {
|
|
1204
|
+
...embeddedExtensionFactories.length > 0 ? { embeddedExtensionFactories } : {},
|
|
1205
|
+
...externalAuthProviders.length > 0 ? { externalAuthProviders } : {},
|
|
1206
|
+
...memoryEmbeddingProviders.length > 0 ? { memoryEmbeddingProviders } : {},
|
|
1207
|
+
...speechProviders.length > 0 ? { speechProviders } : {},
|
|
1208
|
+
...realtimeTranscriptionProviders.length > 0 ? { realtimeTranscriptionProviders } : {},
|
|
1209
|
+
...realtimeVoiceProviders.length > 0 ? { realtimeVoiceProviders } : {},
|
|
1210
|
+
...mediaUnderstandingProviders.length > 0 ? { mediaUnderstandingProviders } : {},
|
|
1211
|
+
...imageGenerationProviders.length > 0 ? { imageGenerationProviders } : {},
|
|
1212
|
+
...videoGenerationProviders.length > 0 ? { videoGenerationProviders } : {},
|
|
1213
|
+
...musicGenerationProviders.length > 0 ? { musicGenerationProviders } : {},
|
|
1214
|
+
...webFetchProviders.length > 0 ? { webFetchProviders } : {},
|
|
1215
|
+
...webSearchProviders.length > 0 ? { webSearchProviders } : {},
|
|
1216
|
+
...tools.length > 0 ? { tools } : {}
|
|
1217
|
+
};
|
|
1218
|
+
return Object.keys(contracts).length > 0 ? contracts : void 0;
|
|
1219
|
+
}
|
|
1220
|
+
function isManifestConfigLiteral(value) {
|
|
1221
|
+
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
1222
|
+
}
|
|
1223
|
+
function normalizeManifestDangerousConfigFlags(value) {
|
|
1224
|
+
if (!Array.isArray(value)) return;
|
|
1225
|
+
const normalized = [];
|
|
1226
|
+
for (const entry of value) {
|
|
1227
|
+
if (!isRecord(entry)) continue;
|
|
1228
|
+
const path = normalizeOptionalString(entry.path) ?? "";
|
|
1229
|
+
if (!path || !isManifestConfigLiteral(entry.equals)) continue;
|
|
1230
|
+
normalized.push({
|
|
1231
|
+
path,
|
|
1232
|
+
equals: entry.equals
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1236
|
+
}
|
|
1237
|
+
function normalizeManifestSecretInputPaths(value) {
|
|
1238
|
+
if (!Array.isArray(value)) return;
|
|
1239
|
+
const normalized = [];
|
|
1240
|
+
for (const entry of value) {
|
|
1241
|
+
if (!isRecord(entry)) continue;
|
|
1242
|
+
const path = normalizeOptionalString(entry.path) ?? "";
|
|
1243
|
+
if (!path) continue;
|
|
1244
|
+
const expected = entry.expected === "string" ? entry.expected : void 0;
|
|
1245
|
+
normalized.push({
|
|
1246
|
+
path,
|
|
1247
|
+
...expected ? { expected } : {}
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1251
|
+
}
|
|
1252
|
+
function normalizeManifestConfigContracts(value) {
|
|
1253
|
+
if (!isRecord(value)) return;
|
|
1254
|
+
const compatibilityMigrationPaths = normalizeTrimmedStringList(value.compatibilityMigrationPaths);
|
|
1255
|
+
const compatibilityRuntimePaths = normalizeTrimmedStringList(value.compatibilityRuntimePaths);
|
|
1256
|
+
const rawSecretInputs = isRecord(value.secretInputs) ? value.secretInputs : void 0;
|
|
1257
|
+
const dangerousFlags = normalizeManifestDangerousConfigFlags(value.dangerousFlags);
|
|
1258
|
+
const secretInputPaths = rawSecretInputs ? normalizeManifestSecretInputPaths(rawSecretInputs.paths) : void 0;
|
|
1259
|
+
const secretInputs = secretInputPaths && secretInputPaths.length > 0 ? {
|
|
1260
|
+
...rawSecretInputs?.bundledDefaultEnabled === true ? { bundledDefaultEnabled: true } : rawSecretInputs?.bundledDefaultEnabled === false ? { bundledDefaultEnabled: false } : {},
|
|
1261
|
+
paths: secretInputPaths
|
|
1262
|
+
} : void 0;
|
|
1263
|
+
const configContracts = {
|
|
1264
|
+
...compatibilityMigrationPaths.length > 0 ? { compatibilityMigrationPaths } : {},
|
|
1265
|
+
...compatibilityRuntimePaths.length > 0 ? { compatibilityRuntimePaths } : {},
|
|
1266
|
+
...dangerousFlags ? { dangerousFlags } : {},
|
|
1267
|
+
...secretInputs ? { secretInputs } : {}
|
|
1268
|
+
};
|
|
1269
|
+
return Object.keys(configContracts).length > 0 ? configContracts : void 0;
|
|
1270
|
+
}
|
|
1271
|
+
function normalizeManifestModelSupport(value) {
|
|
1272
|
+
if (!isRecord(value)) return;
|
|
1273
|
+
const modelPrefixes = normalizeTrimmedStringList(value.modelPrefixes);
|
|
1274
|
+
const modelPatterns = normalizeTrimmedStringList(value.modelPatterns);
|
|
1275
|
+
const modelSupport = {
|
|
1276
|
+
...modelPrefixes.length > 0 ? { modelPrefixes } : {},
|
|
1277
|
+
...modelPatterns.length > 0 ? { modelPatterns } : {}
|
|
1278
|
+
};
|
|
1279
|
+
return Object.keys(modelSupport).length > 0 ? modelSupport : void 0;
|
|
1280
|
+
}
|
|
1281
|
+
function normalizeManifestProviderEndpoints(value) {
|
|
1282
|
+
if (!Array.isArray(value)) return;
|
|
1283
|
+
const endpoints = [];
|
|
1284
|
+
for (const rawEndpoint of value) {
|
|
1285
|
+
if (!isRecord(rawEndpoint)) continue;
|
|
1286
|
+
const endpointClass = normalizeOptionalString(rawEndpoint.endpointClass);
|
|
1287
|
+
if (!endpointClass) continue;
|
|
1288
|
+
const hosts = normalizeTrimmedStringList(rawEndpoint.hosts).map((host) => host.toLowerCase());
|
|
1289
|
+
const baseUrls = normalizeTrimmedStringList(rawEndpoint.baseUrls);
|
|
1290
|
+
if (hosts.length === 0 && baseUrls.length === 0) continue;
|
|
1291
|
+
endpoints.push({
|
|
1292
|
+
endpointClass,
|
|
1293
|
+
...hosts.length > 0 ? { hosts } : {},
|
|
1294
|
+
...baseUrls.length > 0 ? { baseUrls } : {}
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
return endpoints.length > 0 ? endpoints : void 0;
|
|
1298
|
+
}
|
|
1299
|
+
function normalizeManifestActivation(value) {
|
|
1300
|
+
if (!isRecord(value)) return;
|
|
1301
|
+
const onProviders = normalizeTrimmedStringList(value.onProviders);
|
|
1302
|
+
const onAgentHarnesses = normalizeTrimmedStringList(value.onAgentHarnesses);
|
|
1303
|
+
const onCommands = normalizeTrimmedStringList(value.onCommands);
|
|
1304
|
+
const onChannels = normalizeTrimmedStringList(value.onChannels);
|
|
1305
|
+
const onRoutes = normalizeTrimmedStringList(value.onRoutes);
|
|
1306
|
+
const onCapabilities = normalizeTrimmedStringList(value.onCapabilities).filter((capability) => capability === "provider" || capability === "channel" || capability === "tool" || capability === "hook");
|
|
1307
|
+
const activation = {
|
|
1308
|
+
...onProviders.length > 0 ? { onProviders } : {},
|
|
1309
|
+
...onAgentHarnesses.length > 0 ? { onAgentHarnesses } : {},
|
|
1310
|
+
...onCommands.length > 0 ? { onCommands } : {},
|
|
1311
|
+
...onChannels.length > 0 ? { onChannels } : {},
|
|
1312
|
+
...onRoutes.length > 0 ? { onRoutes } : {},
|
|
1313
|
+
...onCapabilities.length > 0 ? { onCapabilities } : {}
|
|
1314
|
+
};
|
|
1315
|
+
return Object.keys(activation).length > 0 ? activation : void 0;
|
|
1316
|
+
}
|
|
1317
|
+
function normalizeManifestSetupProviders(value) {
|
|
1318
|
+
if (!Array.isArray(value)) return;
|
|
1319
|
+
const normalized = [];
|
|
1320
|
+
for (const entry of value) {
|
|
1321
|
+
if (!isRecord(entry)) continue;
|
|
1322
|
+
const id = normalizeOptionalString(entry.id) ?? "";
|
|
1323
|
+
if (!id) continue;
|
|
1324
|
+
const authMethods = normalizeTrimmedStringList(entry.authMethods);
|
|
1325
|
+
const envVars = normalizeTrimmedStringList(entry.envVars);
|
|
1326
|
+
normalized.push({
|
|
1327
|
+
id,
|
|
1328
|
+
...authMethods.length > 0 ? { authMethods } : {},
|
|
1329
|
+
...envVars.length > 0 ? { envVars } : {}
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1333
|
+
}
|
|
1334
|
+
function normalizeManifestSetup(value) {
|
|
1335
|
+
if (!isRecord(value)) return;
|
|
1336
|
+
const providers = normalizeManifestSetupProviders(value.providers);
|
|
1337
|
+
const cliBackends = normalizeTrimmedStringList(value.cliBackends);
|
|
1338
|
+
const configMigrations = normalizeTrimmedStringList(value.configMigrations);
|
|
1339
|
+
const requiresRuntime = typeof value.requiresRuntime === "boolean" ? value.requiresRuntime : void 0;
|
|
1340
|
+
const setup = {
|
|
1341
|
+
...providers ? { providers } : {},
|
|
1342
|
+
...cliBackends.length > 0 ? { cliBackends } : {},
|
|
1343
|
+
...configMigrations.length > 0 ? { configMigrations } : {},
|
|
1344
|
+
...requiresRuntime !== void 0 ? { requiresRuntime } : {}
|
|
1345
|
+
};
|
|
1346
|
+
return Object.keys(setup).length > 0 ? setup : void 0;
|
|
1347
|
+
}
|
|
1348
|
+
function normalizeManifestQaRunners(value) {
|
|
1349
|
+
if (!Array.isArray(value)) return;
|
|
1350
|
+
const normalized = [];
|
|
1351
|
+
for (const entry of value) {
|
|
1352
|
+
if (!isRecord(entry)) continue;
|
|
1353
|
+
const commandName = normalizeOptionalString(entry.commandName) ?? "";
|
|
1354
|
+
if (!commandName) continue;
|
|
1355
|
+
const description = normalizeOptionalString(entry.description) ?? "";
|
|
1356
|
+
normalized.push({
|
|
1357
|
+
commandName,
|
|
1358
|
+
...description ? { description } : {}
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1362
|
+
}
|
|
1363
|
+
function normalizeProviderAuthChoices(value) {
|
|
1364
|
+
if (!Array.isArray(value)) return;
|
|
1365
|
+
const normalized = [];
|
|
1366
|
+
for (const entry of value) {
|
|
1367
|
+
if (!isRecord(entry)) continue;
|
|
1368
|
+
const provider = normalizeOptionalString(entry.provider) ?? "";
|
|
1369
|
+
const method = normalizeOptionalString(entry.method) ?? "";
|
|
1370
|
+
const choiceId = normalizeOptionalString(entry.choiceId) ?? "";
|
|
1371
|
+
if (!provider || !method || !choiceId) continue;
|
|
1372
|
+
const choiceLabel = normalizeOptionalString(entry.choiceLabel) ?? "";
|
|
1373
|
+
const choiceHint = normalizeOptionalString(entry.choiceHint) ?? "";
|
|
1374
|
+
const assistantPriority = typeof entry.assistantPriority === "number" && Number.isFinite(entry.assistantPriority) ? entry.assistantPriority : void 0;
|
|
1375
|
+
const assistantVisibility = entry.assistantVisibility === "manual-only" || entry.assistantVisibility === "visible" ? entry.assistantVisibility : void 0;
|
|
1376
|
+
const deprecatedChoiceIds = normalizeTrimmedStringList(entry.deprecatedChoiceIds);
|
|
1377
|
+
const groupId = normalizeOptionalString(entry.groupId) ?? "";
|
|
1378
|
+
const groupLabel = normalizeOptionalString(entry.groupLabel) ?? "";
|
|
1379
|
+
const groupHint = normalizeOptionalString(entry.groupHint) ?? "";
|
|
1380
|
+
const optionKey = normalizeOptionalString(entry.optionKey) ?? "";
|
|
1381
|
+
const cliFlag = normalizeOptionalString(entry.cliFlag) ?? "";
|
|
1382
|
+
const cliOption = normalizeOptionalString(entry.cliOption) ?? "";
|
|
1383
|
+
const cliDescription = normalizeOptionalString(entry.cliDescription) ?? "";
|
|
1384
|
+
const onboardingScopes = normalizeTrimmedStringList(entry.onboardingScopes).filter((scope) => scope === "text-inference" || scope === "image-generation");
|
|
1385
|
+
normalized.push({
|
|
1386
|
+
provider,
|
|
1387
|
+
method,
|
|
1388
|
+
choiceId,
|
|
1389
|
+
...choiceLabel ? { choiceLabel } : {},
|
|
1390
|
+
...choiceHint ? { choiceHint } : {},
|
|
1391
|
+
...assistantPriority !== void 0 ? { assistantPriority } : {},
|
|
1392
|
+
...assistantVisibility ? { assistantVisibility } : {},
|
|
1393
|
+
...deprecatedChoiceIds.length > 0 ? { deprecatedChoiceIds } : {},
|
|
1394
|
+
...groupId ? { groupId } : {},
|
|
1395
|
+
...groupLabel ? { groupLabel } : {},
|
|
1396
|
+
...groupHint ? { groupHint } : {},
|
|
1397
|
+
...optionKey ? { optionKey } : {},
|
|
1398
|
+
...cliFlag ? { cliFlag } : {},
|
|
1399
|
+
...cliOption ? { cliOption } : {},
|
|
1400
|
+
...cliDescription ? { cliDescription } : {},
|
|
1401
|
+
...onboardingScopes.length > 0 ? { onboardingScopes } : {}
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1405
|
+
}
|
|
1406
|
+
function normalizeChannelConfigs(value) {
|
|
1407
|
+
if (!isRecord(value)) return;
|
|
1408
|
+
const normalized = {};
|
|
1409
|
+
for (const [key, rawEntry] of Object.entries(value)) {
|
|
1410
|
+
const channelId = normalizeOptionalString(key) ?? "";
|
|
1411
|
+
if (!channelId || !isRecord(rawEntry)) continue;
|
|
1412
|
+
const schema = isRecord(rawEntry.schema) ? rawEntry.schema : null;
|
|
1413
|
+
if (!schema) continue;
|
|
1414
|
+
const uiHints = isRecord(rawEntry.uiHints) ? rawEntry.uiHints : void 0;
|
|
1415
|
+
const runtime = isRecord(rawEntry.runtime) && typeof rawEntry.runtime.safeParse === "function" ? rawEntry.runtime : void 0;
|
|
1416
|
+
const label = normalizeOptionalString(rawEntry.label) ?? "";
|
|
1417
|
+
const description = normalizeOptionalString(rawEntry.description) ?? "";
|
|
1418
|
+
const preferOver = normalizeTrimmedStringList(rawEntry.preferOver);
|
|
1419
|
+
normalized[channelId] = {
|
|
1420
|
+
schema,
|
|
1421
|
+
...uiHints ? { uiHints } : {},
|
|
1422
|
+
...runtime ? { runtime } : {},
|
|
1423
|
+
...label ? { label } : {},
|
|
1424
|
+
...description ? { description } : {},
|
|
1425
|
+
...preferOver.length > 0 ? { preferOver } : {}
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
1429
|
+
}
|
|
1430
|
+
function resolvePluginManifestPath(rootDir) {
|
|
1431
|
+
for (const filename of PLUGIN_MANIFEST_FILENAMES) {
|
|
1432
|
+
const candidate = path.join(rootDir, filename);
|
|
1433
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
1434
|
+
}
|
|
1435
|
+
return path.join(rootDir, PLUGIN_MANIFEST_FILENAME);
|
|
1436
|
+
}
|
|
1437
|
+
function parsePluginKind(raw) {
|
|
1438
|
+
if (typeof raw === "string") return raw;
|
|
1439
|
+
if (Array.isArray(raw) && raw.length > 0 && raw.every((k) => typeof k === "string")) return raw.length === 1 ? raw[0] : raw;
|
|
1440
|
+
}
|
|
1441
|
+
function loadPluginManifest(rootDir, rejectHardlinks = true) {
|
|
1442
|
+
const manifestPath = resolvePluginManifestPath(rootDir);
|
|
1443
|
+
const opened = openBoundaryFileSync({
|
|
1444
|
+
absolutePath: manifestPath,
|
|
1445
|
+
rootPath: rootDir,
|
|
1446
|
+
boundaryLabel: "plugin root",
|
|
1447
|
+
maxBytes: MAX_PLUGIN_MANIFEST_BYTES,
|
|
1448
|
+
rejectHardlinks
|
|
1449
|
+
});
|
|
1450
|
+
if (!opened.ok) return matchBoundaryFileOpenFailure(opened, {
|
|
1451
|
+
path: () => ({
|
|
1452
|
+
ok: false,
|
|
1453
|
+
error: `plugin manifest not found: ${manifestPath}`,
|
|
1454
|
+
manifestPath
|
|
1455
|
+
}),
|
|
1456
|
+
fallback: (failure) => ({
|
|
1457
|
+
ok: false,
|
|
1458
|
+
error: `unsafe plugin manifest path: ${manifestPath} (${failure.reason})`,
|
|
1459
|
+
manifestPath
|
|
1460
|
+
})
|
|
1461
|
+
});
|
|
1462
|
+
let raw;
|
|
1463
|
+
try {
|
|
1464
|
+
raw = import_lib.default.parse(fs.readFileSync(opened.fd, "utf-8"));
|
|
1465
|
+
} catch (err) {
|
|
1466
|
+
return {
|
|
1467
|
+
ok: false,
|
|
1468
|
+
error: `failed to parse plugin manifest: ${String(err)}`,
|
|
1469
|
+
manifestPath
|
|
1470
|
+
};
|
|
1471
|
+
} finally {
|
|
1472
|
+
fs.closeSync(opened.fd);
|
|
1473
|
+
}
|
|
1474
|
+
if (!isRecord(raw)) return {
|
|
1475
|
+
ok: false,
|
|
1476
|
+
error: "plugin manifest must be an object",
|
|
1477
|
+
manifestPath
|
|
1478
|
+
};
|
|
1479
|
+
const id = normalizeOptionalString(raw.id) ?? "";
|
|
1480
|
+
if (!id) return {
|
|
1481
|
+
ok: false,
|
|
1482
|
+
error: "plugin manifest requires id",
|
|
1483
|
+
manifestPath
|
|
1484
|
+
};
|
|
1485
|
+
const configSchema = isRecord(raw.configSchema) ? raw.configSchema : null;
|
|
1486
|
+
if (!configSchema) return {
|
|
1487
|
+
ok: false,
|
|
1488
|
+
error: "plugin manifest requires configSchema",
|
|
1489
|
+
manifestPath
|
|
1490
|
+
};
|
|
1491
|
+
const kind = parsePluginKind(raw.kind);
|
|
1492
|
+
const enabledByDefault = raw.enabledByDefault === true;
|
|
1493
|
+
const legacyPluginIds = normalizeTrimmedStringList(raw.legacyPluginIds);
|
|
1494
|
+
const autoEnableWhenConfiguredProviders = normalizeTrimmedStringList(raw.autoEnableWhenConfiguredProviders);
|
|
1495
|
+
const name = normalizeOptionalString(raw.name);
|
|
1496
|
+
const description = normalizeOptionalString(raw.description);
|
|
1497
|
+
const version = normalizeOptionalString(raw.version);
|
|
1498
|
+
const channels = normalizeTrimmedStringList(raw.channels);
|
|
1499
|
+
const providers = normalizeTrimmedStringList(raw.providers);
|
|
1500
|
+
const providerDiscoveryEntry = normalizeOptionalString(raw.providerDiscoveryEntry);
|
|
1501
|
+
const modelSupport = normalizeManifestModelSupport(raw.modelSupport);
|
|
1502
|
+
const providerEndpoints = normalizeManifestProviderEndpoints(raw.providerEndpoints);
|
|
1503
|
+
const cliBackends = normalizeTrimmedStringList(raw.cliBackends);
|
|
1504
|
+
const syntheticAuthRefs = normalizeTrimmedStringList(raw.syntheticAuthRefs);
|
|
1505
|
+
const nonSecretAuthMarkers = normalizeTrimmedStringList(raw.nonSecretAuthMarkers);
|
|
1506
|
+
const commandAliases = normalizeManifestCommandAliases(raw.commandAliases);
|
|
1507
|
+
const providerAuthEnvVars = normalizeStringListRecord(raw.providerAuthEnvVars);
|
|
1508
|
+
const providerAuthAliases = normalizeStringRecord(raw.providerAuthAliases);
|
|
1509
|
+
const channelEnvVars = normalizeStringListRecord(raw.channelEnvVars);
|
|
1510
|
+
const providerAuthChoices = normalizeProviderAuthChoices(raw.providerAuthChoices);
|
|
1511
|
+
const activation = normalizeManifestActivation(raw.activation);
|
|
1512
|
+
const setup = normalizeManifestSetup(raw.setup);
|
|
1513
|
+
const qaRunners = normalizeManifestQaRunners(raw.qaRunners);
|
|
1514
|
+
const skills = normalizeTrimmedStringList(raw.skills);
|
|
1515
|
+
const contracts = normalizeManifestContracts(raw.contracts);
|
|
1516
|
+
const mediaUnderstandingProviderMetadata = normalizeMediaUnderstandingProviderMetadata(raw.mediaUnderstandingProviderMetadata);
|
|
1517
|
+
const configContracts = normalizeManifestConfigContracts(raw.configContracts);
|
|
1518
|
+
const channelConfigs = normalizeChannelConfigs(raw.channelConfigs);
|
|
1519
|
+
let uiHints;
|
|
1520
|
+
if (isRecord(raw.uiHints)) uiHints = raw.uiHints;
|
|
1521
|
+
return {
|
|
1522
|
+
ok: true,
|
|
1523
|
+
manifest: {
|
|
1524
|
+
id,
|
|
1525
|
+
configSchema,
|
|
1526
|
+
...enabledByDefault ? { enabledByDefault } : {},
|
|
1527
|
+
...legacyPluginIds.length > 0 ? { legacyPluginIds } : {},
|
|
1528
|
+
...autoEnableWhenConfiguredProviders.length > 0 ? { autoEnableWhenConfiguredProviders } : {},
|
|
1529
|
+
kind,
|
|
1530
|
+
channels,
|
|
1531
|
+
providers,
|
|
1532
|
+
providerDiscoveryEntry,
|
|
1533
|
+
modelSupport,
|
|
1534
|
+
providerEndpoints,
|
|
1535
|
+
cliBackends,
|
|
1536
|
+
syntheticAuthRefs,
|
|
1537
|
+
nonSecretAuthMarkers,
|
|
1538
|
+
commandAliases,
|
|
1539
|
+
providerAuthEnvVars,
|
|
1540
|
+
providerAuthAliases,
|
|
1541
|
+
channelEnvVars,
|
|
1542
|
+
providerAuthChoices,
|
|
1543
|
+
activation,
|
|
1544
|
+
setup,
|
|
1545
|
+
qaRunners,
|
|
1546
|
+
skills,
|
|
1547
|
+
name,
|
|
1548
|
+
description,
|
|
1549
|
+
version,
|
|
1550
|
+
uiHints,
|
|
1551
|
+
contracts,
|
|
1552
|
+
mediaUnderstandingProviderMetadata,
|
|
1553
|
+
configContracts,
|
|
1554
|
+
channelConfigs
|
|
1555
|
+
},
|
|
1556
|
+
manifestPath
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
const DEFAULT_PLUGIN_ENTRY_CANDIDATES = [
|
|
1560
|
+
"index.ts",
|
|
1561
|
+
"index.js",
|
|
1562
|
+
"index.mjs",
|
|
1563
|
+
"index.cjs"
|
|
1564
|
+
];
|
|
1565
|
+
function getPackageManifestMetadata(manifest) {
|
|
1566
|
+
if (!manifest) return;
|
|
1567
|
+
return manifest[MANIFEST_KEY];
|
|
1568
|
+
}
|
|
1569
|
+
function resolvePackageExtensionEntries(manifest) {
|
|
1570
|
+
const raw = getPackageManifestMetadata(manifest)?.extensions;
|
|
1571
|
+
if (!Array.isArray(raw)) return {
|
|
1572
|
+
status: "missing",
|
|
1573
|
+
entries: []
|
|
1574
|
+
};
|
|
1575
|
+
const entries = raw.map((entry) => normalizeOptionalString(entry) ?? "").filter(Boolean);
|
|
1576
|
+
if (entries.length === 0) return {
|
|
1577
|
+
status: "empty",
|
|
1578
|
+
entries: []
|
|
1579
|
+
};
|
|
1580
|
+
return {
|
|
1581
|
+
status: "ok",
|
|
1582
|
+
entries
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
//#endregion
|
|
1586
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/version-Bym9kFjy.js
|
|
1587
|
+
const CORE_PACKAGE_NAME = "openclaw";
|
|
1588
|
+
const PACKAGE_JSON_CANDIDATES = [
|
|
1589
|
+
"../package.json",
|
|
1590
|
+
"../../package.json",
|
|
1591
|
+
"../../../package.json",
|
|
1592
|
+
"./package.json"
|
|
1593
|
+
];
|
|
1594
|
+
const BUILD_INFO_CANDIDATES = [
|
|
1595
|
+
"../build-info.json",
|
|
1596
|
+
"../../build-info.json",
|
|
1597
|
+
"./build-info.json"
|
|
1598
|
+
];
|
|
1599
|
+
function readVersionFromJsonCandidates(moduleUrl, candidates, opts = {}) {
|
|
1600
|
+
try {
|
|
1601
|
+
const require = createRequire(moduleUrl);
|
|
1602
|
+
for (const candidate of candidates) try {
|
|
1603
|
+
const parsed = require(candidate);
|
|
1604
|
+
const version = normalizeOptionalString(parsed.version);
|
|
1605
|
+
if (!version) continue;
|
|
1606
|
+
if (opts.requirePackageName && parsed.name !== CORE_PACKAGE_NAME) continue;
|
|
1607
|
+
return version;
|
|
1608
|
+
} catch {}
|
|
1609
|
+
return null;
|
|
1610
|
+
} catch {
|
|
1611
|
+
return null;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
function firstNonEmpty(...values) {
|
|
1615
|
+
for (const value of values) {
|
|
1616
|
+
const trimmed = normalizeOptionalString(value);
|
|
1617
|
+
if (trimmed) return trimmed;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
function readVersionFromPackageJsonForModuleUrl(moduleUrl) {
|
|
1621
|
+
return readVersionFromJsonCandidates(moduleUrl, PACKAGE_JSON_CANDIDATES, { requirePackageName: true });
|
|
1622
|
+
}
|
|
1623
|
+
function readVersionFromBuildInfoForModuleUrl(moduleUrl) {
|
|
1624
|
+
return readVersionFromJsonCandidates(moduleUrl, BUILD_INFO_CANDIDATES);
|
|
1625
|
+
}
|
|
1626
|
+
function resolveVersionFromModuleUrl(moduleUrl) {
|
|
1627
|
+
return readVersionFromPackageJsonForModuleUrl(moduleUrl) || readVersionFromBuildInfoForModuleUrl(moduleUrl);
|
|
1628
|
+
}
|
|
1629
|
+
function resolveBinaryVersion(params) {
|
|
1630
|
+
return firstNonEmpty(params.injectedVersion) || resolveVersionFromModuleUrl(params.moduleUrl) || firstNonEmpty(params.bundledVersion) || params.fallback || "0.0.0";
|
|
1631
|
+
}
|
|
1632
|
+
const RUNTIME_SERVICE_VERSION_FALLBACK = "unknown";
|
|
1633
|
+
function resolveUsableRuntimeVersion(version) {
|
|
1634
|
+
const trimmed = normalizeOptionalString(version);
|
|
1635
|
+
if (!trimmed || trimmed === "0.0.0") return;
|
|
1636
|
+
return trimmed;
|
|
1637
|
+
}
|
|
1638
|
+
function resolveVersionFromRuntimeSources(params) {
|
|
1639
|
+
return firstNonEmpty(...params.preference === "env-first" ? [params.env["OPENCLAW_VERSION"], params.runtimeVersion] : [params.runtimeVersion, params.env["OPENCLAW_VERSION"]], params.env["OPENCLAW_SERVICE_VERSION"], params.env["npm_package_version"]) ?? params.fallback;
|
|
1640
|
+
}
|
|
1641
|
+
function resolveRuntimeServiceVersion(env = process.env, fallback = RUNTIME_SERVICE_VERSION_FALLBACK) {
|
|
1642
|
+
return resolveVersionFromRuntimeSources({
|
|
1643
|
+
env,
|
|
1644
|
+
runtimeVersion: resolveUsableRuntimeVersion(VERSION),
|
|
1645
|
+
fallback,
|
|
1646
|
+
preference: "env-first"
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
function resolveCompatibilityHostVersion(env = process.env, fallback = RUNTIME_SERVICE_VERSION_FALLBACK) {
|
|
1650
|
+
const explicitCompatibilityVersion = firstNonEmpty(env.OPENCLAW_COMPATIBILITY_HOST_VERSION);
|
|
1651
|
+
if (explicitCompatibilityVersion) return explicitCompatibilityVersion;
|
|
1652
|
+
return resolveVersionFromRuntimeSources({
|
|
1653
|
+
env,
|
|
1654
|
+
runtimeVersion: resolveUsableRuntimeVersion(VERSION),
|
|
1655
|
+
fallback,
|
|
1656
|
+
preference: env === process.env ? "runtime-first" : "env-first"
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
const VERSION = resolveBinaryVersion({
|
|
1660
|
+
moduleUrl: import.meta.url,
|
|
1661
|
+
injectedVersion: typeof __OPENCLAW_VERSION__ === "string" ? __OPENCLAW_VERSION__ : void 0,
|
|
1662
|
+
bundledVersion: process.env.OPENCLAW_BUNDLED_VERSION
|
|
1663
|
+
});
|
|
1664
|
+
//#endregion
|
|
1665
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/path-safety-Ba_J5G0M.js
|
|
1666
|
+
const CODEX_BUNDLE_MANIFEST_RELATIVE_PATH = ".codex-plugin/plugin.json";
|
|
1667
|
+
const CLAUDE_BUNDLE_MANIFEST_RELATIVE_PATH = ".claude-plugin/plugin.json";
|
|
1668
|
+
const CURSOR_BUNDLE_MANIFEST_RELATIVE_PATH = ".cursor-plugin/plugin.json";
|
|
1669
|
+
function normalizePathList(value) {
|
|
1670
|
+
if (typeof value === "string") {
|
|
1671
|
+
const trimmed = value.trim();
|
|
1672
|
+
return trimmed ? [trimmed] : [];
|
|
1673
|
+
}
|
|
1674
|
+
if (!Array.isArray(value)) return [];
|
|
1675
|
+
return value.map((entry) => normalizeOptionalString(entry)).filter((entry) => Boolean(entry));
|
|
1676
|
+
}
|
|
1677
|
+
function normalizeBundlePathList(value) {
|
|
1678
|
+
return Array.from(new Set(normalizePathList(value)));
|
|
1679
|
+
}
|
|
1680
|
+
function mergeBundlePathLists(...groups) {
|
|
1681
|
+
const merged = [];
|
|
1682
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1683
|
+
for (const group of groups) for (const entry of group) {
|
|
1684
|
+
if (seen.has(entry)) continue;
|
|
1685
|
+
seen.add(entry);
|
|
1686
|
+
merged.push(entry);
|
|
1687
|
+
}
|
|
1688
|
+
return merged;
|
|
1689
|
+
}
|
|
1690
|
+
function hasInlineCapabilityValue(value) {
|
|
1691
|
+
if (typeof value === "string") return value.trim().length > 0;
|
|
1692
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
1693
|
+
if (isRecord(value)) return Object.keys(value).length > 0;
|
|
1694
|
+
return value === true;
|
|
1695
|
+
}
|
|
1696
|
+
function slugifyPluginId(raw, rootDir) {
|
|
1697
|
+
const fallback = path.basename(rootDir);
|
|
1698
|
+
return (normalizeLowercaseStringOrEmpty(raw) || normalizeLowercaseStringOrEmpty(fallback)).replace(/[^a-z0-9]+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "") || "bundle-plugin";
|
|
1699
|
+
}
|
|
1700
|
+
function loadBundleManifestFile(params) {
|
|
1701
|
+
const manifestPath = path.join(params.rootDir, params.manifestRelativePath);
|
|
1702
|
+
const opened = openBoundaryFileSync({
|
|
1703
|
+
absolutePath: manifestPath,
|
|
1704
|
+
rootPath: params.rootDir,
|
|
1705
|
+
boundaryLabel: "plugin root",
|
|
1706
|
+
rejectHardlinks: params.rejectHardlinks
|
|
1707
|
+
});
|
|
1708
|
+
if (!opened.ok) return matchBoundaryFileOpenFailure(opened, {
|
|
1709
|
+
path: () => {
|
|
1710
|
+
if (params.allowMissing) return {
|
|
1711
|
+
ok: true,
|
|
1712
|
+
raw: {},
|
|
1713
|
+
manifestPath
|
|
1714
|
+
};
|
|
1715
|
+
return {
|
|
1716
|
+
ok: false,
|
|
1717
|
+
error: `plugin manifest not found: ${manifestPath}`,
|
|
1718
|
+
manifestPath
|
|
1719
|
+
};
|
|
1720
|
+
},
|
|
1721
|
+
fallback: (failure) => ({
|
|
1722
|
+
ok: false,
|
|
1723
|
+
error: `unsafe plugin manifest path: ${manifestPath} (${failure.reason})`,
|
|
1724
|
+
manifestPath
|
|
1725
|
+
})
|
|
1726
|
+
});
|
|
1727
|
+
try {
|
|
1728
|
+
const raw = import_lib.default.parse(fs.readFileSync(opened.fd, "utf-8"));
|
|
1729
|
+
if (!isRecord(raw)) return {
|
|
1730
|
+
ok: false,
|
|
1731
|
+
error: "plugin manifest must be an object",
|
|
1732
|
+
manifestPath
|
|
1733
|
+
};
|
|
1734
|
+
return {
|
|
1735
|
+
ok: true,
|
|
1736
|
+
raw,
|
|
1737
|
+
manifestPath
|
|
1738
|
+
};
|
|
1739
|
+
} catch (err) {
|
|
1740
|
+
return {
|
|
1741
|
+
ok: false,
|
|
1742
|
+
error: `failed to parse plugin manifest: ${String(err)}`,
|
|
1743
|
+
manifestPath
|
|
1744
|
+
};
|
|
1745
|
+
} finally {
|
|
1746
|
+
fs.closeSync(opened.fd);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
function resolveCodexSkillDirs(raw, rootDir) {
|
|
1750
|
+
const declared = normalizeBundlePathList(raw.skills);
|
|
1751
|
+
if (declared.length > 0) return declared;
|
|
1752
|
+
return fs.existsSync(path.join(rootDir, "skills")) ? ["skills"] : [];
|
|
1753
|
+
}
|
|
1754
|
+
function resolveCodexHookDirs(raw, rootDir) {
|
|
1755
|
+
const declared = normalizeBundlePathList(raw.hooks);
|
|
1756
|
+
if (declared.length > 0) return declared;
|
|
1757
|
+
return fs.existsSync(path.join(rootDir, "hooks")) ? ["hooks"] : [];
|
|
1758
|
+
}
|
|
1759
|
+
function resolveCursorSkillsRootDirs(raw, rootDir) {
|
|
1760
|
+
const declared = normalizeBundlePathList(raw.skills);
|
|
1761
|
+
return mergeBundlePathLists(fs.existsSync(path.join(rootDir, "skills")) ? ["skills"] : [], declared);
|
|
1762
|
+
}
|
|
1763
|
+
function resolveCursorCommandRootDirs(raw, rootDir) {
|
|
1764
|
+
const declared = normalizeBundlePathList(raw.commands);
|
|
1765
|
+
return mergeBundlePathLists(fs.existsSync(path.join(rootDir, ".cursor", "commands")) ? [".cursor/commands"] : [], declared);
|
|
1766
|
+
}
|
|
1767
|
+
function resolveCursorSkillDirs(raw, rootDir) {
|
|
1768
|
+
return mergeBundlePathLists(resolveCursorSkillsRootDirs(raw, rootDir), resolveCursorCommandRootDirs(raw, rootDir));
|
|
1769
|
+
}
|
|
1770
|
+
function resolveCursorAgentDirs(raw, rootDir) {
|
|
1771
|
+
const declared = normalizeBundlePathList(raw.subagents ?? raw.agents);
|
|
1772
|
+
return mergeBundlePathLists(fs.existsSync(path.join(rootDir, ".cursor", "agents")) ? [".cursor/agents"] : [], declared);
|
|
1773
|
+
}
|
|
1774
|
+
function hasCursorHookCapability(raw, rootDir) {
|
|
1775
|
+
return hasInlineCapabilityValue(raw.hooks) || fs.existsSync(path.join(rootDir, ".cursor", "hooks.json"));
|
|
1776
|
+
}
|
|
1777
|
+
function hasCursorRulesCapability(raw, rootDir) {
|
|
1778
|
+
return hasInlineCapabilityValue(raw.rules) || fs.existsSync(path.join(rootDir, ".cursor", "rules"));
|
|
1779
|
+
}
|
|
1780
|
+
function hasCursorMcpCapability(raw, rootDir) {
|
|
1781
|
+
return hasInlineCapabilityValue(raw.mcpServers) || fs.existsSync(path.join(rootDir, ".mcp.json"));
|
|
1782
|
+
}
|
|
1783
|
+
function resolveClaudeComponentPaths(raw, key, rootDir, defaults) {
|
|
1784
|
+
const declared = normalizeBundlePathList(raw[key]);
|
|
1785
|
+
return mergeBundlePathLists(defaults.filter((candidate) => fs.existsSync(path.join(rootDir, candidate))), declared);
|
|
1786
|
+
}
|
|
1787
|
+
function resolveClaudeSkillsRootDirs(raw, rootDir) {
|
|
1788
|
+
return resolveClaudeComponentPaths(raw, "skills", rootDir, ["skills"]);
|
|
1789
|
+
}
|
|
1790
|
+
function resolveClaudeCommandRootDirs(raw, rootDir) {
|
|
1791
|
+
return resolveClaudeComponentPaths(raw, "commands", rootDir, ["commands"]);
|
|
1792
|
+
}
|
|
1793
|
+
function resolveClaudeSkillDirs(raw, rootDir) {
|
|
1794
|
+
return mergeBundlePathLists(resolveClaudeSkillsRootDirs(raw, rootDir), resolveClaudeCommandRootDirs(raw, rootDir), resolveClaudeAgentDirs(raw, rootDir), resolveClaudeOutputStylePaths(raw, rootDir));
|
|
1795
|
+
}
|
|
1796
|
+
function resolveClaudeAgentDirs(raw, rootDir) {
|
|
1797
|
+
return resolveClaudeComponentPaths(raw, "agents", rootDir, ["agents"]);
|
|
1798
|
+
}
|
|
1799
|
+
function resolveClaudeHookPaths(raw, rootDir) {
|
|
1800
|
+
return resolveClaudeComponentPaths(raw, "hooks", rootDir, ["hooks/hooks.json"]);
|
|
1801
|
+
}
|
|
1802
|
+
function resolveClaudeMcpPaths(raw, rootDir) {
|
|
1803
|
+
return resolveClaudeComponentPaths(raw, "mcpServers", rootDir, [".mcp.json"]);
|
|
1804
|
+
}
|
|
1805
|
+
function resolveClaudeLspPaths(raw, rootDir) {
|
|
1806
|
+
return resolveClaudeComponentPaths(raw, "lspServers", rootDir, [".lsp.json"]);
|
|
1807
|
+
}
|
|
1808
|
+
function resolveClaudeOutputStylePaths(raw, rootDir) {
|
|
1809
|
+
return resolveClaudeComponentPaths(raw, "outputStyles", rootDir, ["output-styles"]);
|
|
1810
|
+
}
|
|
1811
|
+
function resolveClaudeSettingsFiles(_raw, rootDir) {
|
|
1812
|
+
return fs.existsSync(path.join(rootDir, "settings.json")) ? ["settings.json"] : [];
|
|
1813
|
+
}
|
|
1814
|
+
function hasClaudeHookCapability(raw, rootDir) {
|
|
1815
|
+
return hasInlineCapabilityValue(raw.hooks) || resolveClaudeHookPaths(raw, rootDir).length > 0;
|
|
1816
|
+
}
|
|
1817
|
+
function buildCodexCapabilities(raw, rootDir) {
|
|
1818
|
+
const capabilities = [];
|
|
1819
|
+
if (resolveCodexSkillDirs(raw, rootDir).length > 0) capabilities.push("skills");
|
|
1820
|
+
if (resolveCodexHookDirs(raw, rootDir).length > 0) capabilities.push("hooks");
|
|
1821
|
+
if (hasInlineCapabilityValue(raw.mcpServers) || fs.existsSync(path.join(rootDir, ".mcp.json"))) capabilities.push("mcpServers");
|
|
1822
|
+
if (hasInlineCapabilityValue(raw.apps) || fs.existsSync(path.join(rootDir, ".app.json"))) capabilities.push("apps");
|
|
1823
|
+
return capabilities;
|
|
1824
|
+
}
|
|
1825
|
+
function buildClaudeCapabilities(raw, rootDir) {
|
|
1826
|
+
const capabilities = [];
|
|
1827
|
+
if (resolveClaudeSkillDirs(raw, rootDir).length > 0) capabilities.push("skills");
|
|
1828
|
+
if (resolveClaudeCommandRootDirs(raw, rootDir).length > 0) capabilities.push("commands");
|
|
1829
|
+
if (resolveClaudeAgentDirs(raw, rootDir).length > 0) capabilities.push("agents");
|
|
1830
|
+
if (hasClaudeHookCapability(raw, rootDir)) capabilities.push("hooks");
|
|
1831
|
+
if (hasInlineCapabilityValue(raw.mcpServers) || resolveClaudeMcpPaths(raw, rootDir).length > 0) capabilities.push("mcpServers");
|
|
1832
|
+
if (hasInlineCapabilityValue(raw.lspServers) || resolveClaudeLspPaths(raw, rootDir).length > 0) capabilities.push("lspServers");
|
|
1833
|
+
if (hasInlineCapabilityValue(raw.outputStyles) || resolveClaudeOutputStylePaths(raw, rootDir).length > 0) capabilities.push("outputStyles");
|
|
1834
|
+
if (resolveClaudeSettingsFiles(raw, rootDir).length > 0) capabilities.push("settings");
|
|
1835
|
+
return capabilities;
|
|
1836
|
+
}
|
|
1837
|
+
function buildCursorCapabilities(raw, rootDir) {
|
|
1838
|
+
const capabilities = [];
|
|
1839
|
+
if (resolveCursorSkillDirs(raw, rootDir).length > 0) capabilities.push("skills");
|
|
1840
|
+
if (resolveCursorCommandRootDirs(raw, rootDir).length > 0) capabilities.push("commands");
|
|
1841
|
+
if (resolveCursorAgentDirs(raw, rootDir).length > 0) capabilities.push("agents");
|
|
1842
|
+
if (hasCursorHookCapability(raw, rootDir)) capabilities.push("hooks");
|
|
1843
|
+
if (hasCursorRulesCapability(raw, rootDir)) capabilities.push("rules");
|
|
1844
|
+
if (hasCursorMcpCapability(raw, rootDir)) capabilities.push("mcpServers");
|
|
1845
|
+
return capabilities;
|
|
1846
|
+
}
|
|
1847
|
+
function loadBundleManifest(params) {
|
|
1848
|
+
const rejectHardlinks = params.rejectHardlinks ?? true;
|
|
1849
|
+
const manifestRelativePath = params.bundleFormat === "codex" ? CODEX_BUNDLE_MANIFEST_RELATIVE_PATH : params.bundleFormat === "cursor" ? CURSOR_BUNDLE_MANIFEST_RELATIVE_PATH : CLAUDE_BUNDLE_MANIFEST_RELATIVE_PATH;
|
|
1850
|
+
const loaded = loadBundleManifestFile({
|
|
1851
|
+
rootDir: params.rootDir,
|
|
1852
|
+
manifestRelativePath,
|
|
1853
|
+
rejectHardlinks,
|
|
1854
|
+
allowMissing: params.bundleFormat === "claude"
|
|
1855
|
+
});
|
|
1856
|
+
if (!loaded.ok) return loaded;
|
|
1857
|
+
const raw = loaded.raw;
|
|
1858
|
+
const interfaceRecord = isRecord(raw.interface) ? raw.interface : void 0;
|
|
1859
|
+
const name = normalizeOptionalString(raw.name);
|
|
1860
|
+
const description = normalizeOptionalString(raw.description) ?? normalizeOptionalString(raw.shortDescription) ?? normalizeOptionalString(interfaceRecord?.shortDescription);
|
|
1861
|
+
const version = normalizeOptionalString(raw.version);
|
|
1862
|
+
if (params.bundleFormat === "codex") {
|
|
1863
|
+
const skills = resolveCodexSkillDirs(raw, params.rootDir);
|
|
1864
|
+
const hooks = resolveCodexHookDirs(raw, params.rootDir);
|
|
1865
|
+
return {
|
|
1866
|
+
ok: true,
|
|
1867
|
+
manifest: {
|
|
1868
|
+
id: slugifyPluginId(name, params.rootDir),
|
|
1869
|
+
name,
|
|
1870
|
+
description,
|
|
1871
|
+
version,
|
|
1872
|
+
skills,
|
|
1873
|
+
settingsFiles: [],
|
|
1874
|
+
hooks,
|
|
1875
|
+
bundleFormat: "codex",
|
|
1876
|
+
capabilities: buildCodexCapabilities(raw, params.rootDir)
|
|
1877
|
+
},
|
|
1878
|
+
manifestPath: loaded.manifestPath
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1881
|
+
if (params.bundleFormat === "cursor") return {
|
|
1882
|
+
ok: true,
|
|
1883
|
+
manifest: {
|
|
1884
|
+
id: slugifyPluginId(name, params.rootDir),
|
|
1885
|
+
name,
|
|
1886
|
+
description,
|
|
1887
|
+
version,
|
|
1888
|
+
skills: resolveCursorSkillDirs(raw, params.rootDir),
|
|
1889
|
+
settingsFiles: [],
|
|
1890
|
+
hooks: [],
|
|
1891
|
+
bundleFormat: "cursor",
|
|
1892
|
+
capabilities: buildCursorCapabilities(raw, params.rootDir)
|
|
1893
|
+
},
|
|
1894
|
+
manifestPath: loaded.manifestPath
|
|
1895
|
+
};
|
|
1896
|
+
return {
|
|
1897
|
+
ok: true,
|
|
1898
|
+
manifest: {
|
|
1899
|
+
id: slugifyPluginId(name, params.rootDir),
|
|
1900
|
+
name,
|
|
1901
|
+
description,
|
|
1902
|
+
version,
|
|
1903
|
+
skills: resolveClaudeSkillDirs(raw, params.rootDir),
|
|
1904
|
+
settingsFiles: resolveClaudeSettingsFiles(raw, params.rootDir),
|
|
1905
|
+
hooks: resolveClaudeHookPaths(raw, params.rootDir),
|
|
1906
|
+
bundleFormat: "claude",
|
|
1907
|
+
capabilities: buildClaudeCapabilities(raw, params.rootDir)
|
|
1908
|
+
},
|
|
1909
|
+
manifestPath: loaded.manifestPath
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
function detectBundleManifestFormat(rootDir) {
|
|
1913
|
+
if (fs.existsSync(path.join(rootDir, ".codex-plugin/plugin.json"))) return "codex";
|
|
1914
|
+
if (fs.existsSync(path.join(rootDir, ".cursor-plugin/plugin.json"))) return "cursor";
|
|
1915
|
+
if (fs.existsSync(path.join(rootDir, ".claude-plugin/plugin.json"))) return "claude";
|
|
1916
|
+
if (fs.existsSync(path.join(rootDir, "openclaw.plugin.json"))) return null;
|
|
1917
|
+
if (DEFAULT_PLUGIN_ENTRY_CANDIDATES.some((candidate) => fs.existsSync(path.join(rootDir, candidate)))) return null;
|
|
1918
|
+
if ([
|
|
1919
|
+
path.join(rootDir, "skills"),
|
|
1920
|
+
path.join(rootDir, "commands"),
|
|
1921
|
+
path.join(rootDir, "agents"),
|
|
1922
|
+
path.join(rootDir, "hooks", "hooks.json"),
|
|
1923
|
+
path.join(rootDir, ".mcp.json"),
|
|
1924
|
+
path.join(rootDir, ".lsp.json"),
|
|
1925
|
+
path.join(rootDir, "settings.json")
|
|
1926
|
+
].some((candidate) => fs.existsSync(candidate))) return "claude";
|
|
1927
|
+
return null;
|
|
1928
|
+
}
|
|
1929
|
+
function isPathInside(baseDir, targetPath) {
|
|
1930
|
+
return isPathInside$1(baseDir, targetPath);
|
|
1931
|
+
}
|
|
1932
|
+
function safeRealpathSync(targetPath, cache) {
|
|
1933
|
+
const cached = cache?.get(targetPath);
|
|
1934
|
+
if (cached) return cached;
|
|
1935
|
+
try {
|
|
1936
|
+
const resolved = fs.realpathSync(targetPath);
|
|
1937
|
+
cache?.set(targetPath, resolved);
|
|
1938
|
+
return resolved;
|
|
1939
|
+
} catch {
|
|
1940
|
+
return null;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
function safeStatSync(targetPath) {
|
|
1944
|
+
try {
|
|
1945
|
+
return fs.statSync(targetPath);
|
|
1946
|
+
} catch {
|
|
1947
|
+
return null;
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
function formatPosixMode(mode) {
|
|
1951
|
+
return (mode & 511).toString(8).padStart(3, "0");
|
|
1952
|
+
}
|
|
1953
|
+
//#endregion
|
|
1954
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/discovery-DoO9rWnu.js
|
|
1955
|
+
function resolvePluginSourceRoots(params) {
|
|
1956
|
+
const env = params.env ?? process.env;
|
|
1957
|
+
const workspaceRoot = params.workspaceDir ? resolveUserPath(params.workspaceDir, env) : void 0;
|
|
1958
|
+
return {
|
|
1959
|
+
stock: resolveBundledPluginsDir(env),
|
|
1960
|
+
global: path.join(resolveConfigDir(env), "extensions"),
|
|
1961
|
+
workspace: workspaceRoot ? path.join(workspaceRoot, ".openclaw", "extensions") : void 0
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
function resolvePluginCacheInputs(params) {
|
|
1965
|
+
const env = params.env ?? process.env;
|
|
1966
|
+
return {
|
|
1967
|
+
roots: resolvePluginSourceRoots({
|
|
1968
|
+
workspaceDir: params.workspaceDir,
|
|
1969
|
+
env
|
|
1970
|
+
}),
|
|
1971
|
+
loadPaths: (params.loadPaths ?? []).filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter(Boolean).map((entry) => resolveUserPath(entry, env))
|
|
1972
|
+
};
|
|
1973
|
+
}
|
|
1974
|
+
const EXTENSION_EXTS = new Set([
|
|
1975
|
+
".ts",
|
|
1976
|
+
".js",
|
|
1977
|
+
".mts",
|
|
1978
|
+
".cts",
|
|
1979
|
+
".mjs",
|
|
1980
|
+
".cjs"
|
|
1981
|
+
]);
|
|
1982
|
+
const SCANNED_DIRECTORY_IGNORE_NAMES = new Set([
|
|
1983
|
+
".git",
|
|
1984
|
+
".hg",
|
|
1985
|
+
".svn",
|
|
1986
|
+
".turbo",
|
|
1987
|
+
".yarn",
|
|
1988
|
+
".yarn-cache",
|
|
1989
|
+
"build",
|
|
1990
|
+
"coverage",
|
|
1991
|
+
"dist",
|
|
1992
|
+
"node_modules"
|
|
1993
|
+
]);
|
|
1994
|
+
const discoveryCache = /* @__PURE__ */ new Map();
|
|
1995
|
+
const DEFAULT_DISCOVERY_CACHE_MS = 1e3;
|
|
1996
|
+
function resolveDiscoveryCacheMs(env) {
|
|
1997
|
+
const raw = env.OPENCLAW_PLUGIN_DISCOVERY_CACHE_MS?.trim();
|
|
1998
|
+
if (raw === "" || raw === "0") return 0;
|
|
1999
|
+
if (!raw) return DEFAULT_DISCOVERY_CACHE_MS;
|
|
2000
|
+
const parsed = Number.parseInt(raw, 10);
|
|
2001
|
+
if (!Number.isFinite(parsed)) return DEFAULT_DISCOVERY_CACHE_MS;
|
|
2002
|
+
return Math.max(0, parsed);
|
|
2003
|
+
}
|
|
2004
|
+
function shouldUseDiscoveryCache(env) {
|
|
2005
|
+
if (env.OPENCLAW_DISABLE_PLUGIN_DISCOVERY_CACHE?.trim()) return false;
|
|
2006
|
+
return resolveDiscoveryCacheMs(env) > 0;
|
|
2007
|
+
}
|
|
2008
|
+
function buildScopedDiscoveryCacheKey(params) {
|
|
2009
|
+
const { roots, loadPaths } = resolvePluginCacheInputs({
|
|
2010
|
+
workspaceDir: params.workspaceDir,
|
|
2011
|
+
loadPaths: params.extraPaths,
|
|
2012
|
+
env: params.env
|
|
2013
|
+
});
|
|
2014
|
+
return `scoped::${roots.workspace ?? ""}::${roots.stock ?? ""}::${params.ownershipUid ?? currentUid() ?? "none"}::${JSON.stringify(loadPaths)}`;
|
|
2015
|
+
}
|
|
2016
|
+
function buildSharedDiscoveryCacheKey(params) {
|
|
2017
|
+
const roots = resolvePluginSourceRoots({ env: params.env });
|
|
2018
|
+
const configExtensionsRoot = roots.global ?? "";
|
|
2019
|
+
const bundledRoot = roots.stock ?? "";
|
|
2020
|
+
return `shared::${params.ownershipUid ?? currentUid() ?? "none"}::${configExtensionsRoot}::${bundledRoot}`;
|
|
2021
|
+
}
|
|
2022
|
+
function currentUid(overrideUid) {
|
|
2023
|
+
if (overrideUid !== void 0) return overrideUid;
|
|
2024
|
+
if (process.platform === "win32") return null;
|
|
2025
|
+
if (typeof process.getuid !== "function") return null;
|
|
2026
|
+
return process.getuid();
|
|
2027
|
+
}
|
|
2028
|
+
function checkSourceEscapesRoot(params) {
|
|
2029
|
+
const sourceRealPath = safeRealpathSync(params.source);
|
|
2030
|
+
const rootRealPath = safeRealpathSync(params.rootDir);
|
|
2031
|
+
if (!sourceRealPath || !rootRealPath) return null;
|
|
2032
|
+
if (isPathInside(rootRealPath, sourceRealPath)) return null;
|
|
2033
|
+
return {
|
|
2034
|
+
reason: "source_escapes_root",
|
|
2035
|
+
sourcePath: params.source,
|
|
2036
|
+
rootPath: params.rootDir,
|
|
2037
|
+
targetPath: params.source,
|
|
2038
|
+
sourceRealPath,
|
|
2039
|
+
rootRealPath
|
|
2040
|
+
};
|
|
2041
|
+
}
|
|
2042
|
+
function checkPathStatAndPermissions(params) {
|
|
2043
|
+
if (process.platform === "win32") return null;
|
|
2044
|
+
const pathsToCheck = [params.rootDir, params.source];
|
|
2045
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2046
|
+
for (const targetPath of pathsToCheck) {
|
|
2047
|
+
const normalized = path.resolve(targetPath);
|
|
2048
|
+
if (seen.has(normalized)) continue;
|
|
2049
|
+
seen.add(normalized);
|
|
2050
|
+
let stat = safeStatSync(targetPath);
|
|
2051
|
+
if (!stat) return {
|
|
2052
|
+
reason: "path_stat_failed",
|
|
2053
|
+
sourcePath: params.source,
|
|
2054
|
+
rootPath: params.rootDir,
|
|
2055
|
+
targetPath
|
|
2056
|
+
};
|
|
2057
|
+
let modeBits = stat.mode & 511;
|
|
2058
|
+
if ((modeBits & 2) !== 0 && params.origin === "bundled") try {
|
|
2059
|
+
fs.chmodSync(targetPath, modeBits & -19);
|
|
2060
|
+
const repairedStat = safeStatSync(targetPath);
|
|
2061
|
+
if (!repairedStat) return {
|
|
2062
|
+
reason: "path_stat_failed",
|
|
2063
|
+
sourcePath: params.source,
|
|
2064
|
+
rootPath: params.rootDir,
|
|
2065
|
+
targetPath
|
|
2066
|
+
};
|
|
2067
|
+
stat = repairedStat;
|
|
2068
|
+
modeBits = repairedStat.mode & 511;
|
|
2069
|
+
} catch {}
|
|
2070
|
+
if ((modeBits & 2) !== 0) return {
|
|
2071
|
+
reason: "path_world_writable",
|
|
2072
|
+
sourcePath: params.source,
|
|
2073
|
+
rootPath: params.rootDir,
|
|
2074
|
+
targetPath,
|
|
2075
|
+
modeBits
|
|
2076
|
+
};
|
|
2077
|
+
if (params.origin !== "bundled" && params.uid !== null && typeof stat.uid === "number" && stat.uid !== params.uid && stat.uid !== 0) return {
|
|
2078
|
+
reason: "path_suspicious_ownership",
|
|
2079
|
+
sourcePath: params.source,
|
|
2080
|
+
rootPath: params.rootDir,
|
|
2081
|
+
targetPath,
|
|
2082
|
+
foundUid: stat.uid,
|
|
2083
|
+
expectedUid: params.uid
|
|
2084
|
+
};
|
|
2085
|
+
}
|
|
2086
|
+
return null;
|
|
2087
|
+
}
|
|
2088
|
+
function findCandidateBlockIssue(params) {
|
|
2089
|
+
const escaped = checkSourceEscapesRoot({
|
|
2090
|
+
source: params.source,
|
|
2091
|
+
rootDir: params.rootDir
|
|
2092
|
+
});
|
|
2093
|
+
if (escaped) return escaped;
|
|
2094
|
+
return checkPathStatAndPermissions({
|
|
2095
|
+
source: params.source,
|
|
2096
|
+
rootDir: params.rootDir,
|
|
2097
|
+
origin: params.origin,
|
|
2098
|
+
uid: currentUid(params.ownershipUid)
|
|
2099
|
+
});
|
|
2100
|
+
}
|
|
2101
|
+
function formatCandidateBlockMessage(issue) {
|
|
2102
|
+
if (issue.reason === "source_escapes_root") return `blocked plugin candidate: source escapes plugin root (${issue.sourcePath} -> ${issue.sourceRealPath}; root=${issue.rootRealPath})`;
|
|
2103
|
+
if (issue.reason === "path_stat_failed") return `blocked plugin candidate: cannot stat path (${issue.targetPath})`;
|
|
2104
|
+
if (issue.reason === "path_world_writable") return `blocked plugin candidate: world-writable path (${issue.targetPath}, mode=${formatPosixMode(issue.modeBits ?? 0)})`;
|
|
2105
|
+
return `blocked plugin candidate: suspicious ownership (${issue.targetPath}, uid=${issue.foundUid}, expected uid=${issue.expectedUid} or root)`;
|
|
2106
|
+
}
|
|
2107
|
+
function isUnsafePluginCandidate(params) {
|
|
2108
|
+
const issue = findCandidateBlockIssue({
|
|
2109
|
+
source: params.source,
|
|
2110
|
+
rootDir: params.rootDir,
|
|
2111
|
+
origin: params.origin,
|
|
2112
|
+
ownershipUid: params.ownershipUid
|
|
2113
|
+
});
|
|
2114
|
+
if (!issue) return false;
|
|
2115
|
+
params.diagnostics.push({
|
|
2116
|
+
level: "warn",
|
|
2117
|
+
source: issue.targetPath,
|
|
2118
|
+
message: formatCandidateBlockMessage(issue)
|
|
2119
|
+
});
|
|
2120
|
+
return true;
|
|
2121
|
+
}
|
|
2122
|
+
function isExtensionFile(filePath) {
|
|
2123
|
+
const ext = path.extname(filePath);
|
|
2124
|
+
if (!EXTENSION_EXTS.has(ext)) return false;
|
|
2125
|
+
if (filePath.endsWith(".d.ts")) return false;
|
|
2126
|
+
const baseName = normalizeLowercaseStringOrEmpty(path.basename(filePath));
|
|
2127
|
+
return !baseName.includes(".test.") && !baseName.includes(".live.test.") && !baseName.includes(".e2e.test.");
|
|
2128
|
+
}
|
|
2129
|
+
function shouldIgnoreScannedDirectory(dirName) {
|
|
2130
|
+
const normalized = normalizeLowercaseStringOrEmpty(dirName);
|
|
2131
|
+
if (!normalized) return true;
|
|
2132
|
+
if (SCANNED_DIRECTORY_IGNORE_NAMES.has(normalized)) return true;
|
|
2133
|
+
if (normalized.endsWith(".bak")) return true;
|
|
2134
|
+
if (normalized.includes(".backup-")) return true;
|
|
2135
|
+
if (normalized.includes(".disabled")) return true;
|
|
2136
|
+
return false;
|
|
2137
|
+
}
|
|
2138
|
+
function resolvesToSameDirectory(left, right) {
|
|
2139
|
+
if (!left || !right) return false;
|
|
2140
|
+
const leftRealPath = safeRealpathSync(left);
|
|
2141
|
+
const rightRealPath = safeRealpathSync(right);
|
|
2142
|
+
if (leftRealPath && rightRealPath) return leftRealPath === rightRealPath;
|
|
2143
|
+
return path.resolve(left) === path.resolve(right);
|
|
2144
|
+
}
|
|
2145
|
+
function createDiscoveryResult() {
|
|
2146
|
+
return {
|
|
2147
|
+
candidates: [],
|
|
2148
|
+
diagnostics: []
|
|
2149
|
+
};
|
|
2150
|
+
}
|
|
2151
|
+
function mergeDiscoveryResult(target, source, seenSources) {
|
|
2152
|
+
for (const candidate of source.candidates) {
|
|
2153
|
+
const key = candidate.source;
|
|
2154
|
+
if (seenSources.has(key)) continue;
|
|
2155
|
+
seenSources.add(key);
|
|
2156
|
+
target.candidates.push(candidate);
|
|
2157
|
+
}
|
|
2158
|
+
target.diagnostics.push(...source.diagnostics);
|
|
2159
|
+
}
|
|
2160
|
+
function getCachedDiscoveryResult(params) {
|
|
2161
|
+
const ttl = resolveDiscoveryCacheMs(params.env);
|
|
2162
|
+
if (params.cacheEnabled) {
|
|
2163
|
+
const cached = discoveryCache.get(params.cacheKey);
|
|
2164
|
+
if (cached && cached.expiresAt > Date.now()) return cached.result;
|
|
2165
|
+
}
|
|
2166
|
+
const result = params.load();
|
|
2167
|
+
if (params.cacheEnabled && ttl > 0) discoveryCache.set(params.cacheKey, {
|
|
2168
|
+
expiresAt: Date.now() + ttl,
|
|
2169
|
+
result
|
|
2170
|
+
});
|
|
2171
|
+
return result;
|
|
2172
|
+
}
|
|
2173
|
+
function readPackageManifest(dir, rejectHardlinks = true) {
|
|
2174
|
+
const opened = openBoundaryFileSync({
|
|
2175
|
+
absolutePath: path.join(dir, "package.json"),
|
|
2176
|
+
rootPath: dir,
|
|
2177
|
+
boundaryLabel: "plugin package directory",
|
|
2178
|
+
rejectHardlinks
|
|
2179
|
+
});
|
|
2180
|
+
if (!opened.ok) return null;
|
|
2181
|
+
try {
|
|
2182
|
+
const raw = fs.readFileSync(opened.fd, "utf-8");
|
|
2183
|
+
return JSON.parse(raw);
|
|
2184
|
+
} catch {
|
|
2185
|
+
return null;
|
|
2186
|
+
} finally {
|
|
2187
|
+
fs.closeSync(opened.fd);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
function deriveIdHint(params) {
|
|
2191
|
+
const base = path.basename(params.filePath, path.extname(params.filePath));
|
|
2192
|
+
const rawManifestId = params.manifestId?.trim();
|
|
2193
|
+
if (rawManifestId) return params.hasMultipleExtensions ? `${rawManifestId}/${base}` : rawManifestId;
|
|
2194
|
+
const rawPackageName = params.packageName?.trim();
|
|
2195
|
+
if (!rawPackageName) return base;
|
|
2196
|
+
const unscoped = rawPackageName.includes("/") ? rawPackageName.split("/").pop() ?? rawPackageName : rawPackageName;
|
|
2197
|
+
const normalizedPackageId = unscoped.endsWith("-provider") && unscoped.length > 9 ? unscoped.slice(0, -9) : unscoped;
|
|
2198
|
+
if (!params.hasMultipleExtensions) return normalizedPackageId;
|
|
2199
|
+
return `${normalizedPackageId}/${base}`;
|
|
2200
|
+
}
|
|
2201
|
+
function resolveIdHintManifestId(rootDir, rejectHardlinks) {
|
|
2202
|
+
const manifest = loadPluginManifest(rootDir, rejectHardlinks);
|
|
2203
|
+
return manifest.ok ? manifest.manifest.id : void 0;
|
|
2204
|
+
}
|
|
2205
|
+
function addCandidate(params) {
|
|
2206
|
+
const resolved = path.resolve(params.source);
|
|
2207
|
+
if (params.seen.has(resolved)) return;
|
|
2208
|
+
const resolvedRoot = safeRealpathSync(params.rootDir) ?? path.resolve(params.rootDir);
|
|
2209
|
+
if (isUnsafePluginCandidate({
|
|
2210
|
+
source: resolved,
|
|
2211
|
+
rootDir: resolvedRoot,
|
|
2212
|
+
origin: params.origin,
|
|
2213
|
+
diagnostics: params.diagnostics,
|
|
2214
|
+
ownershipUid: params.ownershipUid
|
|
2215
|
+
})) return;
|
|
2216
|
+
params.seen.add(resolved);
|
|
2217
|
+
const manifest = params.manifest ?? null;
|
|
2218
|
+
params.candidates.push({
|
|
2219
|
+
idHint: params.idHint,
|
|
2220
|
+
source: resolved,
|
|
2221
|
+
setupSource: params.setupSource,
|
|
2222
|
+
rootDir: resolvedRoot,
|
|
2223
|
+
origin: params.origin,
|
|
2224
|
+
format: params.format ?? "openclaw",
|
|
2225
|
+
bundleFormat: params.bundleFormat,
|
|
2226
|
+
workspaceDir: params.workspaceDir,
|
|
2227
|
+
packageName: normalizeOptionalString(manifest?.name),
|
|
2228
|
+
packageVersion: normalizeOptionalString(manifest?.version),
|
|
2229
|
+
packageDescription: normalizeOptionalString(manifest?.description),
|
|
2230
|
+
packageDir: params.packageDir,
|
|
2231
|
+
packageManifest: getPackageManifestMetadata(manifest ?? void 0),
|
|
2232
|
+
bundledManifest: params.bundledManifest,
|
|
2233
|
+
bundledManifestPath: params.bundledManifestPath
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
function discoverBundleInRoot(params) {
|
|
2237
|
+
const bundleFormat = detectBundleManifestFormat(params.rootDir);
|
|
2238
|
+
if (!bundleFormat) return "none";
|
|
2239
|
+
const bundleManifest = loadBundleManifest({
|
|
2240
|
+
rootDir: params.rootDir,
|
|
2241
|
+
bundleFormat,
|
|
2242
|
+
rejectHardlinks: params.origin !== "bundled"
|
|
2243
|
+
});
|
|
2244
|
+
if (!bundleManifest.ok) {
|
|
2245
|
+
params.diagnostics.push({
|
|
2246
|
+
level: "error",
|
|
2247
|
+
message: bundleManifest.error,
|
|
2248
|
+
source: bundleManifest.manifestPath
|
|
2249
|
+
});
|
|
2250
|
+
return "invalid";
|
|
2251
|
+
}
|
|
2252
|
+
addCandidate({
|
|
2253
|
+
candidates: params.candidates,
|
|
2254
|
+
diagnostics: params.diagnostics,
|
|
2255
|
+
seen: params.seen,
|
|
2256
|
+
idHint: bundleManifest.manifest.id,
|
|
2257
|
+
source: params.rootDir,
|
|
2258
|
+
rootDir: params.rootDir,
|
|
2259
|
+
origin: params.origin,
|
|
2260
|
+
format: "bundle",
|
|
2261
|
+
bundleFormat,
|
|
2262
|
+
ownershipUid: params.ownershipUid,
|
|
2263
|
+
workspaceDir: params.workspaceDir
|
|
2264
|
+
});
|
|
2265
|
+
return "added";
|
|
2266
|
+
}
|
|
2267
|
+
function resolvePackageEntrySource(params) {
|
|
2268
|
+
const source = path.resolve(params.packageDir, params.entryPath);
|
|
2269
|
+
const rejectHardlinks = params.rejectHardlinks ?? true;
|
|
2270
|
+
const candidates = [source];
|
|
2271
|
+
const openCandidate = (absolutePath) => {
|
|
2272
|
+
const opened = openBoundaryFileSync({
|
|
2273
|
+
absolutePath,
|
|
2274
|
+
rootPath: params.packageDir,
|
|
2275
|
+
boundaryLabel: "plugin package directory",
|
|
2276
|
+
rejectHardlinks
|
|
2277
|
+
});
|
|
2278
|
+
if (!opened.ok) return matchBoundaryFileOpenFailure(opened, {
|
|
2279
|
+
path: () => null,
|
|
2280
|
+
io: () => {
|
|
2281
|
+
params.diagnostics.push({
|
|
2282
|
+
level: "warn",
|
|
2283
|
+
message: `extension entry unreadable (I/O error): ${params.entryPath}`,
|
|
2284
|
+
source: params.sourceLabel
|
|
2285
|
+
});
|
|
2286
|
+
return null;
|
|
2287
|
+
},
|
|
2288
|
+
fallback: () => {
|
|
2289
|
+
params.diagnostics.push({
|
|
2290
|
+
level: "error",
|
|
2291
|
+
message: `extension entry escapes package directory: ${params.entryPath}`,
|
|
2292
|
+
source: params.sourceLabel
|
|
2293
|
+
});
|
|
2294
|
+
return null;
|
|
2295
|
+
}
|
|
2296
|
+
});
|
|
2297
|
+
const safeSource = opened.path;
|
|
2298
|
+
fs.closeSync(opened.fd);
|
|
2299
|
+
return safeSource;
|
|
2300
|
+
};
|
|
2301
|
+
if (!rejectHardlinks) {
|
|
2302
|
+
const builtCandidate = source.replace(/\.[^.]+$/u, ".js");
|
|
2303
|
+
if (builtCandidate !== source) candidates.push(builtCandidate);
|
|
2304
|
+
}
|
|
2305
|
+
for (const candidate of new Set(candidates)) {
|
|
2306
|
+
if (!fs.existsSync(candidate)) continue;
|
|
2307
|
+
return openCandidate(candidate);
|
|
2308
|
+
}
|
|
2309
|
+
return openCandidate(source);
|
|
2310
|
+
}
|
|
2311
|
+
function isTypeScriptPackageEntry(entryPath) {
|
|
2312
|
+
return [
|
|
2313
|
+
".ts",
|
|
2314
|
+
".mts",
|
|
2315
|
+
".cts"
|
|
2316
|
+
].includes(normalizeLowercaseStringOrEmpty(path.extname(entryPath)));
|
|
2317
|
+
}
|
|
2318
|
+
function shouldInferBuiltRuntimeEntry(origin) {
|
|
2319
|
+
return origin === "config" || origin === "global";
|
|
2320
|
+
}
|
|
2321
|
+
function resolveSafePackageEntry(params) {
|
|
2322
|
+
const absolutePath = path.resolve(params.packageDir, params.entryPath);
|
|
2323
|
+
if (fs.existsSync(absolutePath)) {
|
|
2324
|
+
const existingSource = resolvePackageEntrySource({
|
|
2325
|
+
packageDir: params.packageDir,
|
|
2326
|
+
entryPath: params.entryPath,
|
|
2327
|
+
sourceLabel: params.sourceLabel,
|
|
2328
|
+
diagnostics: params.diagnostics,
|
|
2329
|
+
rejectHardlinks: params.rejectHardlinks
|
|
2330
|
+
});
|
|
2331
|
+
if (!existingSource) return null;
|
|
2332
|
+
return {
|
|
2333
|
+
relativePath: path.relative(params.packageDir, absolutePath).replace(/\\/g, "/"),
|
|
2334
|
+
existingSource
|
|
2335
|
+
};
|
|
2336
|
+
}
|
|
2337
|
+
try {
|
|
2338
|
+
resolveBoundaryPathSync({
|
|
2339
|
+
absolutePath,
|
|
2340
|
+
rootPath: params.packageDir,
|
|
2341
|
+
boundaryLabel: "plugin package directory"
|
|
2342
|
+
});
|
|
2343
|
+
} catch {
|
|
2344
|
+
params.diagnostics.push({
|
|
2345
|
+
level: "error",
|
|
2346
|
+
message: `extension entry escapes package directory: ${params.entryPath}`,
|
|
2347
|
+
source: params.sourceLabel
|
|
2348
|
+
});
|
|
2349
|
+
return null;
|
|
2350
|
+
}
|
|
2351
|
+
return { relativePath: path.relative(params.packageDir, absolutePath).replace(/\\/g, "/") };
|
|
2352
|
+
}
|
|
2353
|
+
function listBuiltRuntimeEntryCandidates(entryPath) {
|
|
2354
|
+
if (!isTypeScriptPackageEntry(entryPath)) return [];
|
|
2355
|
+
const normalized = entryPath.replace(/\\/g, "/");
|
|
2356
|
+
const withoutExtension = normalized.replace(/\.[^.]+$/u, "");
|
|
2357
|
+
const normalizedRelative = normalized.replace(/^\.\//u, "");
|
|
2358
|
+
const distWithoutExtension = normalizedRelative.startsWith("src/") ? `./dist/${normalizedRelative.slice(4).replace(/\.[^.]+$/u, "")}` : `./dist/${withoutExtension.replace(/^\.\//u, "")}`;
|
|
2359
|
+
const withJavaScriptExtensions = (basePath) => [
|
|
2360
|
+
`${basePath}.js`,
|
|
2361
|
+
`${basePath}.mjs`,
|
|
2362
|
+
`${basePath}.cjs`
|
|
2363
|
+
];
|
|
2364
|
+
const candidates = [...withJavaScriptExtensions(distWithoutExtension), ...withJavaScriptExtensions(withoutExtension)];
|
|
2365
|
+
return [...new Set(candidates)].filter((candidate) => candidate !== normalized);
|
|
2366
|
+
}
|
|
2367
|
+
function resolveExistingPackageEntrySource(params) {
|
|
2368
|
+
const source = path.resolve(params.packageDir, params.entryPath);
|
|
2369
|
+
if (!fs.existsSync(source)) return null;
|
|
2370
|
+
return resolvePackageEntrySource(params);
|
|
2371
|
+
}
|
|
2372
|
+
function normalizePackageManifestStringList(value) {
|
|
2373
|
+
if (!Array.isArray(value)) return [];
|
|
2374
|
+
return value.map((entry) => normalizeOptionalString(entry) ?? "").filter(Boolean);
|
|
2375
|
+
}
|
|
2376
|
+
function resolvePackageRuntimeEntrySource(params) {
|
|
2377
|
+
const safeEntry = resolveSafePackageEntry({
|
|
2378
|
+
packageDir: params.packageDir,
|
|
2379
|
+
entryPath: params.entryPath,
|
|
2380
|
+
sourceLabel: params.sourceLabel,
|
|
2381
|
+
diagnostics: params.diagnostics,
|
|
2382
|
+
rejectHardlinks: params.rejectHardlinks
|
|
2383
|
+
});
|
|
2384
|
+
if (!safeEntry) return null;
|
|
2385
|
+
if (params.runtimeEntryPath) {
|
|
2386
|
+
const runtimeSource = resolvePackageEntrySource({
|
|
2387
|
+
packageDir: params.packageDir,
|
|
2388
|
+
entryPath: params.runtimeEntryPath,
|
|
2389
|
+
sourceLabel: params.sourceLabel,
|
|
2390
|
+
diagnostics: params.diagnostics,
|
|
2391
|
+
rejectHardlinks: params.rejectHardlinks
|
|
2392
|
+
});
|
|
2393
|
+
if (runtimeSource) return runtimeSource;
|
|
2394
|
+
}
|
|
2395
|
+
if (shouldInferBuiltRuntimeEntry(params.origin)) for (const candidate of listBuiltRuntimeEntryCandidates(safeEntry.relativePath)) {
|
|
2396
|
+
const runtimeSource = resolveExistingPackageEntrySource({
|
|
2397
|
+
packageDir: params.packageDir,
|
|
2398
|
+
entryPath: candidate,
|
|
2399
|
+
sourceLabel: params.sourceLabel,
|
|
2400
|
+
diagnostics: params.diagnostics,
|
|
2401
|
+
rejectHardlinks: params.rejectHardlinks
|
|
2402
|
+
});
|
|
2403
|
+
if (runtimeSource) return runtimeSource;
|
|
2404
|
+
}
|
|
2405
|
+
if (safeEntry.existingSource) return safeEntry.existingSource;
|
|
2406
|
+
return resolvePackageEntrySource({
|
|
2407
|
+
packageDir: params.packageDir,
|
|
2408
|
+
entryPath: params.entryPath,
|
|
2409
|
+
sourceLabel: params.sourceLabel,
|
|
2410
|
+
diagnostics: params.diagnostics,
|
|
2411
|
+
rejectHardlinks: params.rejectHardlinks
|
|
2412
|
+
});
|
|
2413
|
+
}
|
|
2414
|
+
function resolvePackageSetupSource(params) {
|
|
2415
|
+
const packageManifest = getPackageManifestMetadata(params.manifest ?? void 0);
|
|
2416
|
+
const setupEntryPath = normalizeOptionalString(packageManifest?.setupEntry);
|
|
2417
|
+
if (!setupEntryPath) return null;
|
|
2418
|
+
return resolvePackageRuntimeEntrySource({
|
|
2419
|
+
packageDir: params.packageDir,
|
|
2420
|
+
entryPath: setupEntryPath,
|
|
2421
|
+
runtimeEntryPath: normalizeOptionalString(packageManifest?.runtimeSetupEntry),
|
|
2422
|
+
origin: params.origin,
|
|
2423
|
+
sourceLabel: params.sourceLabel,
|
|
2424
|
+
diagnostics: params.diagnostics,
|
|
2425
|
+
rejectHardlinks: params.rejectHardlinks
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
function resolvePackageRuntimeExtensionEntries(params) {
|
|
2429
|
+
const runtimeExtensions = normalizePackageManifestStringList(getPackageManifestMetadata(params.manifest ?? void 0)?.runtimeExtensions);
|
|
2430
|
+
return params.extensions.flatMap((entryPath, index) => {
|
|
2431
|
+
const source = resolvePackageRuntimeEntrySource({
|
|
2432
|
+
packageDir: params.packageDir,
|
|
2433
|
+
entryPath,
|
|
2434
|
+
runtimeEntryPath: runtimeExtensions.length === params.extensions.length ? runtimeExtensions[index] : void 0,
|
|
2435
|
+
origin: params.origin,
|
|
2436
|
+
sourceLabel: params.sourceLabel,
|
|
2437
|
+
diagnostics: params.diagnostics,
|
|
2438
|
+
rejectHardlinks: params.rejectHardlinks
|
|
2439
|
+
});
|
|
2440
|
+
return source ? [source] : [];
|
|
2441
|
+
});
|
|
2442
|
+
}
|
|
2443
|
+
function discoverInDirectory(params) {
|
|
2444
|
+
if (!fs.existsSync(params.dir)) return;
|
|
2445
|
+
const resolvedDir = safeRealpathSync(params.dir) ?? path.resolve(params.dir);
|
|
2446
|
+
if (params.recurseDirectories) {
|
|
2447
|
+
if (params.visitedDirectories?.has(resolvedDir)) return;
|
|
2448
|
+
params.visitedDirectories?.add(resolvedDir);
|
|
2449
|
+
}
|
|
2450
|
+
let entries = [];
|
|
2451
|
+
try {
|
|
2452
|
+
entries = fs.readdirSync(params.dir, { withFileTypes: true });
|
|
2453
|
+
} catch (err) {
|
|
2454
|
+
params.diagnostics.push({
|
|
2455
|
+
level: "warn",
|
|
2456
|
+
message: `failed to read extensions dir: ${params.dir} (${String(err)})`,
|
|
2457
|
+
source: params.dir
|
|
2458
|
+
});
|
|
2459
|
+
return;
|
|
2460
|
+
}
|
|
2461
|
+
for (const entry of entries) {
|
|
2462
|
+
const fullPath = path.join(params.dir, entry.name);
|
|
2463
|
+
if (entry.isFile()) {
|
|
2464
|
+
if (!isExtensionFile(fullPath)) continue;
|
|
2465
|
+
addCandidate({
|
|
2466
|
+
candidates: params.candidates,
|
|
2467
|
+
diagnostics: params.diagnostics,
|
|
2468
|
+
seen: params.seen,
|
|
2469
|
+
idHint: path.basename(entry.name, path.extname(entry.name)),
|
|
2470
|
+
source: fullPath,
|
|
2471
|
+
rootDir: path.dirname(fullPath),
|
|
2472
|
+
origin: params.origin,
|
|
2473
|
+
ownershipUid: params.ownershipUid,
|
|
2474
|
+
workspaceDir: params.workspaceDir
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
if (!entry.isDirectory()) continue;
|
|
2478
|
+
if (params.skipDirectories?.has(entry.name)) continue;
|
|
2479
|
+
if (shouldIgnoreScannedDirectory(entry.name)) continue;
|
|
2480
|
+
const rejectHardlinks = params.origin !== "bundled";
|
|
2481
|
+
const manifest = readPackageManifest(fullPath, rejectHardlinks);
|
|
2482
|
+
const extensionResolution = resolvePackageExtensionEntries(manifest ?? void 0);
|
|
2483
|
+
const extensions = extensionResolution.status === "ok" ? extensionResolution.entries : [];
|
|
2484
|
+
const manifestId = resolveIdHintManifestId(fullPath, rejectHardlinks);
|
|
2485
|
+
const setupSource = resolvePackageSetupSource({
|
|
2486
|
+
packageDir: fullPath,
|
|
2487
|
+
manifest,
|
|
2488
|
+
origin: params.origin,
|
|
2489
|
+
sourceLabel: fullPath,
|
|
2490
|
+
diagnostics: params.diagnostics,
|
|
2491
|
+
rejectHardlinks
|
|
2492
|
+
});
|
|
2493
|
+
if (extensions.length > 0) {
|
|
2494
|
+
const resolvedRuntimeSources = resolvePackageRuntimeExtensionEntries({
|
|
2495
|
+
packageDir: fullPath,
|
|
2496
|
+
manifest,
|
|
2497
|
+
extensions,
|
|
2498
|
+
origin: params.origin,
|
|
2499
|
+
sourceLabel: fullPath,
|
|
2500
|
+
diagnostics: params.diagnostics,
|
|
2501
|
+
rejectHardlinks
|
|
2502
|
+
});
|
|
2503
|
+
for (const resolved of resolvedRuntimeSources) addCandidate({
|
|
2504
|
+
candidates: params.candidates,
|
|
2505
|
+
diagnostics: params.diagnostics,
|
|
2506
|
+
seen: params.seen,
|
|
2507
|
+
idHint: deriveIdHint({
|
|
2508
|
+
filePath: resolved,
|
|
2509
|
+
manifestId,
|
|
2510
|
+
packageName: manifest?.name,
|
|
2511
|
+
hasMultipleExtensions: extensions.length > 1
|
|
2512
|
+
}),
|
|
2513
|
+
source: resolved,
|
|
2514
|
+
...setupSource ? { setupSource } : {},
|
|
2515
|
+
rootDir: fullPath,
|
|
2516
|
+
origin: params.origin,
|
|
2517
|
+
ownershipUid: params.ownershipUid,
|
|
2518
|
+
workspaceDir: params.workspaceDir,
|
|
2519
|
+
manifest,
|
|
2520
|
+
packageDir: fullPath
|
|
2521
|
+
});
|
|
2522
|
+
continue;
|
|
2523
|
+
}
|
|
2524
|
+
if (discoverBundleInRoot({
|
|
2525
|
+
rootDir: fullPath,
|
|
2526
|
+
origin: params.origin,
|
|
2527
|
+
ownershipUid: params.ownershipUid,
|
|
2528
|
+
workspaceDir: params.workspaceDir,
|
|
2529
|
+
candidates: params.candidates,
|
|
2530
|
+
diagnostics: params.diagnostics,
|
|
2531
|
+
seen: params.seen
|
|
2532
|
+
}) === "added") continue;
|
|
2533
|
+
const indexFile = [...DEFAULT_PLUGIN_ENTRY_CANDIDATES].map((candidate) => path.join(fullPath, candidate)).find((candidate) => fs.existsSync(candidate));
|
|
2534
|
+
if (indexFile && isExtensionFile(indexFile)) {
|
|
2535
|
+
addCandidate({
|
|
2536
|
+
candidates: params.candidates,
|
|
2537
|
+
diagnostics: params.diagnostics,
|
|
2538
|
+
seen: params.seen,
|
|
2539
|
+
idHint: entry.name,
|
|
2540
|
+
source: indexFile,
|
|
2541
|
+
...setupSource ? { setupSource } : {},
|
|
2542
|
+
rootDir: fullPath,
|
|
2543
|
+
origin: params.origin,
|
|
2544
|
+
ownershipUid: params.ownershipUid,
|
|
2545
|
+
workspaceDir: params.workspaceDir,
|
|
2546
|
+
manifest,
|
|
2547
|
+
packageDir: fullPath
|
|
2548
|
+
});
|
|
2549
|
+
continue;
|
|
2550
|
+
}
|
|
2551
|
+
if (params.recurseDirectories) discoverInDirectory({
|
|
2552
|
+
...params,
|
|
2553
|
+
dir: fullPath
|
|
2554
|
+
});
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
function discoverFromPath(params) {
|
|
2558
|
+
const resolved = resolveUserPath(params.rawPath, params.env);
|
|
2559
|
+
if (!fs.existsSync(resolved)) {
|
|
2560
|
+
params.diagnostics.push({
|
|
2561
|
+
level: "error",
|
|
2562
|
+
message: `plugin path not found: ${resolved}`,
|
|
2563
|
+
source: resolved
|
|
2564
|
+
});
|
|
2565
|
+
return;
|
|
2566
|
+
}
|
|
2567
|
+
const stat = fs.statSync(resolved);
|
|
2568
|
+
if (stat.isFile()) {
|
|
2569
|
+
if (!isExtensionFile(resolved)) {
|
|
2570
|
+
params.diagnostics.push({
|
|
2571
|
+
level: "error",
|
|
2572
|
+
message: `plugin path is not a supported file: ${resolved}`,
|
|
2573
|
+
source: resolved
|
|
2574
|
+
});
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2577
|
+
addCandidate({
|
|
2578
|
+
candidates: params.candidates,
|
|
2579
|
+
diagnostics: params.diagnostics,
|
|
2580
|
+
seen: params.seen,
|
|
2581
|
+
idHint: path.basename(resolved, path.extname(resolved)),
|
|
2582
|
+
source: resolved,
|
|
2583
|
+
rootDir: path.dirname(resolved),
|
|
2584
|
+
origin: params.origin,
|
|
2585
|
+
ownershipUid: params.ownershipUid,
|
|
2586
|
+
workspaceDir: params.workspaceDir
|
|
2587
|
+
});
|
|
2588
|
+
return;
|
|
2589
|
+
}
|
|
2590
|
+
if (stat.isDirectory()) {
|
|
2591
|
+
const rejectHardlinks = params.origin !== "bundled";
|
|
2592
|
+
const manifest = readPackageManifest(resolved, rejectHardlinks);
|
|
2593
|
+
const extensionResolution = resolvePackageExtensionEntries(manifest ?? void 0);
|
|
2594
|
+
const extensions = extensionResolution.status === "ok" ? extensionResolution.entries : [];
|
|
2595
|
+
const manifestId = resolveIdHintManifestId(resolved, rejectHardlinks);
|
|
2596
|
+
const setupSource = resolvePackageSetupSource({
|
|
2597
|
+
packageDir: resolved,
|
|
2598
|
+
manifest,
|
|
2599
|
+
origin: params.origin,
|
|
2600
|
+
sourceLabel: resolved,
|
|
2601
|
+
diagnostics: params.diagnostics,
|
|
2602
|
+
rejectHardlinks
|
|
2603
|
+
});
|
|
2604
|
+
if (extensions.length > 0) {
|
|
2605
|
+
const resolvedRuntimeSources = resolvePackageRuntimeExtensionEntries({
|
|
2606
|
+
packageDir: resolved,
|
|
2607
|
+
manifest,
|
|
2608
|
+
extensions,
|
|
2609
|
+
origin: params.origin,
|
|
2610
|
+
sourceLabel: resolved,
|
|
2611
|
+
diagnostics: params.diagnostics,
|
|
2612
|
+
rejectHardlinks
|
|
2613
|
+
});
|
|
2614
|
+
for (const source of resolvedRuntimeSources) addCandidate({
|
|
2615
|
+
candidates: params.candidates,
|
|
2616
|
+
diagnostics: params.diagnostics,
|
|
2617
|
+
seen: params.seen,
|
|
2618
|
+
idHint: deriveIdHint({
|
|
2619
|
+
filePath: source,
|
|
2620
|
+
manifestId,
|
|
2621
|
+
packageName: manifest?.name,
|
|
2622
|
+
hasMultipleExtensions: extensions.length > 1
|
|
2623
|
+
}),
|
|
2624
|
+
source,
|
|
2625
|
+
...setupSource ? { setupSource } : {},
|
|
2626
|
+
rootDir: resolved,
|
|
2627
|
+
origin: params.origin,
|
|
2628
|
+
ownershipUid: params.ownershipUid,
|
|
2629
|
+
workspaceDir: params.workspaceDir,
|
|
2630
|
+
manifest,
|
|
2631
|
+
packageDir: resolved
|
|
2632
|
+
});
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
if (discoverBundleInRoot({
|
|
2636
|
+
rootDir: resolved,
|
|
2637
|
+
origin: params.origin,
|
|
2638
|
+
ownershipUid: params.ownershipUid,
|
|
2639
|
+
workspaceDir: params.workspaceDir,
|
|
2640
|
+
candidates: params.candidates,
|
|
2641
|
+
diagnostics: params.diagnostics,
|
|
2642
|
+
seen: params.seen
|
|
2643
|
+
}) === "added") return;
|
|
2644
|
+
const indexFile = [...DEFAULT_PLUGIN_ENTRY_CANDIDATES].map((candidate) => path.join(resolved, candidate)).find((candidate) => fs.existsSync(candidate));
|
|
2645
|
+
if (indexFile && isExtensionFile(indexFile)) {
|
|
2646
|
+
addCandidate({
|
|
2647
|
+
candidates: params.candidates,
|
|
2648
|
+
diagnostics: params.diagnostics,
|
|
2649
|
+
seen: params.seen,
|
|
2650
|
+
idHint: path.basename(resolved),
|
|
2651
|
+
source: indexFile,
|
|
2652
|
+
...setupSource ? { setupSource } : {},
|
|
2653
|
+
rootDir: resolved,
|
|
2654
|
+
origin: params.origin,
|
|
2655
|
+
ownershipUid: params.ownershipUid,
|
|
2656
|
+
workspaceDir: params.workspaceDir,
|
|
2657
|
+
manifest,
|
|
2658
|
+
packageDir: resolved
|
|
2659
|
+
});
|
|
2660
|
+
return;
|
|
2661
|
+
}
|
|
2662
|
+
discoverInDirectory({
|
|
2663
|
+
dir: resolved,
|
|
2664
|
+
origin: params.origin,
|
|
2665
|
+
ownershipUid: params.ownershipUid,
|
|
2666
|
+
workspaceDir: params.workspaceDir,
|
|
2667
|
+
candidates: params.candidates,
|
|
2668
|
+
diagnostics: params.diagnostics,
|
|
2669
|
+
seen: params.seen
|
|
2670
|
+
});
|
|
2671
|
+
return;
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
function discoverOpenClawPlugins(params) {
|
|
2675
|
+
const env = params.env ?? process.env;
|
|
2676
|
+
const cacheEnabled = params.cache !== false && shouldUseDiscoveryCache(env);
|
|
2677
|
+
const workspaceDir = normalizeOptionalString(params.workspaceDir);
|
|
2678
|
+
const workspaceRoot = workspaceDir ? resolveUserPath(workspaceDir, env) : void 0;
|
|
2679
|
+
const roots = resolvePluginSourceRoots({
|
|
2680
|
+
workspaceDir: workspaceRoot,
|
|
2681
|
+
env
|
|
2682
|
+
});
|
|
2683
|
+
const scopedResult = getCachedDiscoveryResult({
|
|
2684
|
+
cacheEnabled,
|
|
2685
|
+
cacheKey: buildScopedDiscoveryCacheKey({
|
|
2686
|
+
workspaceDir: params.workspaceDir,
|
|
2687
|
+
extraPaths: params.extraPaths,
|
|
2688
|
+
ownershipUid: params.ownershipUid,
|
|
2689
|
+
env
|
|
2690
|
+
}),
|
|
2691
|
+
env,
|
|
2692
|
+
load: () => {
|
|
2693
|
+
const result = createDiscoveryResult();
|
|
2694
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2695
|
+
const extra = params.extraPaths ?? [];
|
|
2696
|
+
for (const extraPath of extra) {
|
|
2697
|
+
if (typeof extraPath !== "string") continue;
|
|
2698
|
+
const trimmed = extraPath.trim();
|
|
2699
|
+
if (!trimmed) continue;
|
|
2700
|
+
discoverFromPath({
|
|
2701
|
+
rawPath: trimmed,
|
|
2702
|
+
origin: "config",
|
|
2703
|
+
ownershipUid: params.ownershipUid,
|
|
2704
|
+
workspaceDir,
|
|
2705
|
+
env,
|
|
2706
|
+
candidates: result.candidates,
|
|
2707
|
+
diagnostics: result.diagnostics,
|
|
2708
|
+
seen
|
|
2709
|
+
});
|
|
2710
|
+
}
|
|
2711
|
+
const workspaceMatchesBundledRoot = resolvesToSameDirectory(workspaceRoot, roots.stock);
|
|
2712
|
+
if (roots.workspace && workspaceRoot && !workspaceMatchesBundledRoot) discoverInDirectory({
|
|
2713
|
+
dir: roots.workspace,
|
|
2714
|
+
origin: "workspace",
|
|
2715
|
+
ownershipUid: params.ownershipUid,
|
|
2716
|
+
workspaceDir: workspaceRoot,
|
|
2717
|
+
candidates: result.candidates,
|
|
2718
|
+
diagnostics: result.diagnostics,
|
|
2719
|
+
seen
|
|
2720
|
+
});
|
|
2721
|
+
return result;
|
|
2722
|
+
}
|
|
2723
|
+
});
|
|
2724
|
+
const sharedResult = getCachedDiscoveryResult({
|
|
2725
|
+
cacheEnabled,
|
|
2726
|
+
cacheKey: buildSharedDiscoveryCacheKey({
|
|
2727
|
+
ownershipUid: params.ownershipUid,
|
|
2728
|
+
env
|
|
2729
|
+
}),
|
|
2730
|
+
env,
|
|
2731
|
+
load: () => {
|
|
2732
|
+
const result = createDiscoveryResult();
|
|
2733
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2734
|
+
if (roots.stock) discoverInDirectory({
|
|
2735
|
+
dir: roots.stock,
|
|
2736
|
+
origin: "bundled",
|
|
2737
|
+
ownershipUid: params.ownershipUid,
|
|
2738
|
+
candidates: result.candidates,
|
|
2739
|
+
diagnostics: result.diagnostics,
|
|
2740
|
+
seen
|
|
2741
|
+
});
|
|
2742
|
+
discoverInDirectory({
|
|
2743
|
+
dir: roots.global,
|
|
2744
|
+
origin: "global",
|
|
2745
|
+
ownershipUid: params.ownershipUid,
|
|
2746
|
+
candidates: result.candidates,
|
|
2747
|
+
diagnostics: result.diagnostics,
|
|
2748
|
+
seen
|
|
2749
|
+
});
|
|
2750
|
+
return result;
|
|
2751
|
+
}
|
|
2752
|
+
});
|
|
2753
|
+
const result = createDiscoveryResult();
|
|
2754
|
+
const seenSources = /* @__PURE__ */ new Set();
|
|
2755
|
+
mergeDiscoveryResult(result, scopedResult, seenSources);
|
|
2756
|
+
mergeDiscoveryResult(result, sharedResult, seenSources);
|
|
2757
|
+
return result;
|
|
2758
|
+
}
|
|
2759
|
+
//#endregion
|
|
2760
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/slots-DkFhJWYQ.js
|
|
2761
|
+
const DEFAULT_SLOT_BY_KEY = {
|
|
2762
|
+
memory: "memory-core",
|
|
2763
|
+
contextEngine: "legacy"
|
|
2764
|
+
};
|
|
2765
|
+
/** Normalize a kind field to an array for uniform iteration. */
|
|
2766
|
+
function normalizeKinds(kind) {
|
|
2767
|
+
if (!kind) return [];
|
|
2768
|
+
return Array.isArray(kind) ? kind : [kind];
|
|
2769
|
+
}
|
|
2770
|
+
/** Check whether a plugin's kind field includes a specific kind. */
|
|
2771
|
+
function hasKind$1(kind, target) {
|
|
2772
|
+
if (!kind) return false;
|
|
2773
|
+
return Array.isArray(kind) ? kind.includes(target) : kind === target;
|
|
2774
|
+
}
|
|
2775
|
+
/** Order-insensitive equality check for two kind values (string or array). */
|
|
2776
|
+
function kindsEqual(a, b) {
|
|
2777
|
+
const aN = normalizeKinds(a).toSorted();
|
|
2778
|
+
const bN = normalizeKinds(b).toSorted();
|
|
2779
|
+
return aN.length === bN.length && aN.every((k, i) => k === bN[i]);
|
|
2780
|
+
}
|
|
2781
|
+
function defaultSlotIdForKey(slotKey) {
|
|
2782
|
+
return DEFAULT_SLOT_BY_KEY[slotKey];
|
|
2783
|
+
}
|
|
2784
|
+
//#endregion
|
|
2785
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/runtime-guard-DYXyo2C1.js
|
|
2786
|
+
const SEMVER_RE = /(\d+)\.(\d+)\.(\d+)/;
|
|
2787
|
+
function parseSemver(version) {
|
|
2788
|
+
if (!version) return null;
|
|
2789
|
+
const match = version.match(SEMVER_RE);
|
|
2790
|
+
if (!match) return null;
|
|
2791
|
+
const [, major, minor, patch] = match;
|
|
2792
|
+
return {
|
|
2793
|
+
major: Number.parseInt(major, 10),
|
|
2794
|
+
minor: Number.parseInt(minor, 10),
|
|
2795
|
+
patch: Number.parseInt(patch, 10)
|
|
2796
|
+
};
|
|
2797
|
+
}
|
|
2798
|
+
function isAtLeast(version, minimum) {
|
|
2799
|
+
if (!version) return false;
|
|
2800
|
+
if (version.major !== minimum.major) return version.major > minimum.major;
|
|
2801
|
+
if (version.minor !== minimum.minor) return version.minor > minimum.minor;
|
|
2802
|
+
return version.patch >= minimum.patch;
|
|
2803
|
+
}
|
|
2804
|
+
//#endregion
|
|
2805
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/min-host-version-lEP3RI0K.js
|
|
2806
|
+
const MIN_HOST_VERSION_FORMAT = "openclaw.install.minHostVersion must use a semver floor in the form \">=x.y.z\"";
|
|
2807
|
+
const MIN_HOST_VERSION_RE = /^>=(\d+)\.(\d+)\.(\d+)$/;
|
|
2808
|
+
function parseMinHostVersionRequirement(raw) {
|
|
2809
|
+
if (typeof raw !== "string") return null;
|
|
2810
|
+
const trimmed = raw.trim();
|
|
2811
|
+
if (!trimmed) return null;
|
|
2812
|
+
const match = trimmed.match(MIN_HOST_VERSION_RE);
|
|
2813
|
+
if (!match) return null;
|
|
2814
|
+
const minimumLabel = `${match[1]}.${match[2]}.${match[3]}`;
|
|
2815
|
+
if (!parseSemver(minimumLabel)) return null;
|
|
2816
|
+
return {
|
|
2817
|
+
raw: trimmed,
|
|
2818
|
+
minimumLabel
|
|
2819
|
+
};
|
|
2820
|
+
}
|
|
2821
|
+
function checkMinHostVersion(params) {
|
|
2822
|
+
if (params.minHostVersion === void 0) return {
|
|
2823
|
+
ok: true,
|
|
2824
|
+
requirement: null
|
|
2825
|
+
};
|
|
2826
|
+
const requirement = parseMinHostVersionRequirement(params.minHostVersion);
|
|
2827
|
+
if (!requirement) return {
|
|
2828
|
+
ok: false,
|
|
2829
|
+
kind: "invalid",
|
|
2830
|
+
error: MIN_HOST_VERSION_FORMAT
|
|
2831
|
+
};
|
|
2832
|
+
const currentVersion = normalizeOptionalString(params.currentVersion) || "unknown";
|
|
2833
|
+
const currentSemver = parseSemver(currentVersion);
|
|
2834
|
+
if (!currentSemver) return {
|
|
2835
|
+
ok: false,
|
|
2836
|
+
kind: "unknown_host_version",
|
|
2837
|
+
requirement
|
|
2838
|
+
};
|
|
2839
|
+
if (!isAtLeast(currentSemver, parseSemver(requirement.minimumLabel))) return {
|
|
2840
|
+
ok: false,
|
|
2841
|
+
kind: "incompatible",
|
|
2842
|
+
requirement,
|
|
2843
|
+
currentVersion
|
|
2844
|
+
};
|
|
2845
|
+
return {
|
|
2846
|
+
ok: true,
|
|
2847
|
+
requirement
|
|
2848
|
+
};
|
|
2849
|
+
}
|
|
2850
|
+
//#endregion
|
|
2851
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/manifest-registry-_hxKCS2K.js
|
|
2852
|
+
const PLUGIN_ACTIVATION_REASON_BY_CAUSE = {
|
|
2853
|
+
"enabled-in-config": "enabled in config",
|
|
2854
|
+
"bundled-channel-enabled-in-config": "channel enabled in config",
|
|
2855
|
+
"selected-memory-slot": "selected memory slot",
|
|
2856
|
+
"selected-context-engine-slot": "selected context engine slot",
|
|
2857
|
+
"selected-in-allowlist": "selected in allowlist",
|
|
2858
|
+
"plugins-disabled": "plugins disabled",
|
|
2859
|
+
"blocked-by-denylist": "blocked by denylist",
|
|
2860
|
+
"disabled-in-config": "disabled in config",
|
|
2861
|
+
"workspace-disabled-by-default": "workspace plugin (disabled by default)",
|
|
2862
|
+
"not-in-allowlist": "not in allowlist",
|
|
2863
|
+
"enabled-by-effective-config": "enabled by effective config",
|
|
2864
|
+
"bundled-channel-configured": "channel configured",
|
|
2865
|
+
"bundled-default-enablement": "bundled default enablement",
|
|
2866
|
+
"bundled-disabled-by-default": "bundled (disabled by default)"
|
|
2867
|
+
};
|
|
2868
|
+
function resolvePluginActivationReason(cause, reason) {
|
|
2869
|
+
if (reason) return reason;
|
|
2870
|
+
return cause ? PLUGIN_ACTIVATION_REASON_BY_CAUSE[cause] : void 0;
|
|
2871
|
+
}
|
|
2872
|
+
function toPluginActivationState(decision) {
|
|
2873
|
+
return {
|
|
2874
|
+
enabled: decision.enabled,
|
|
2875
|
+
activated: decision.activated,
|
|
2876
|
+
explicitlyEnabled: decision.explicitlyEnabled,
|
|
2877
|
+
source: decision.source,
|
|
2878
|
+
reason: resolvePluginActivationReason(decision.cause, decision.reason)
|
|
2879
|
+
};
|
|
2880
|
+
}
|
|
2881
|
+
function resolveExplicitPluginSelectionShared(params) {
|
|
2882
|
+
if (params.config.entries[params.id]?.enabled === true) return {
|
|
2883
|
+
explicitlyEnabled: true,
|
|
2884
|
+
cause: "enabled-in-config"
|
|
2885
|
+
};
|
|
2886
|
+
if (params.origin === "bundled" && params.isBundledChannelEnabledByChannelConfig(params.rootConfig, params.id)) return {
|
|
2887
|
+
explicitlyEnabled: true,
|
|
2888
|
+
cause: "bundled-channel-enabled-in-config"
|
|
2889
|
+
};
|
|
2890
|
+
if (params.config.slots.memory === params.id) return {
|
|
2891
|
+
explicitlyEnabled: true,
|
|
2892
|
+
cause: "selected-memory-slot"
|
|
2893
|
+
};
|
|
2894
|
+
if (params.config.slots.contextEngine === params.id) return {
|
|
2895
|
+
explicitlyEnabled: true,
|
|
2896
|
+
cause: "selected-context-engine-slot"
|
|
2897
|
+
};
|
|
2898
|
+
if (params.origin !== "bundled" && params.config.allow.includes(params.id)) return {
|
|
2899
|
+
explicitlyEnabled: true,
|
|
2900
|
+
cause: "selected-in-allowlist"
|
|
2901
|
+
};
|
|
2902
|
+
return { explicitlyEnabled: false };
|
|
2903
|
+
}
|
|
2904
|
+
function resolvePluginActivationDecisionShared(params) {
|
|
2905
|
+
const activationSource = params.activationSource ?? {
|
|
2906
|
+
plugins: params.config,
|
|
2907
|
+
rootConfig: params.rootConfig
|
|
2908
|
+
};
|
|
2909
|
+
const explicitSelection = resolveExplicitPluginSelectionShared({
|
|
2910
|
+
id: params.id,
|
|
2911
|
+
origin: params.origin,
|
|
2912
|
+
config: activationSource.plugins,
|
|
2913
|
+
rootConfig: activationSource.rootConfig,
|
|
2914
|
+
isBundledChannelEnabledByChannelConfig: params.isBundledChannelEnabledByChannelConfig
|
|
2915
|
+
});
|
|
2916
|
+
if (!params.config.enabled) return {
|
|
2917
|
+
enabled: false,
|
|
2918
|
+
activated: false,
|
|
2919
|
+
explicitlyEnabled: explicitSelection.explicitlyEnabled,
|
|
2920
|
+
source: "disabled",
|
|
2921
|
+
cause: "plugins-disabled"
|
|
2922
|
+
};
|
|
2923
|
+
if (params.config.deny.includes(params.id)) return {
|
|
2924
|
+
enabled: false,
|
|
2925
|
+
activated: false,
|
|
2926
|
+
explicitlyEnabled: explicitSelection.explicitlyEnabled,
|
|
2927
|
+
source: "disabled",
|
|
2928
|
+
cause: "blocked-by-denylist"
|
|
2929
|
+
};
|
|
2930
|
+
const entry = params.config.entries[params.id];
|
|
2931
|
+
if (entry?.enabled === false) return {
|
|
2932
|
+
enabled: false,
|
|
2933
|
+
activated: false,
|
|
2934
|
+
explicitlyEnabled: explicitSelection.explicitlyEnabled,
|
|
2935
|
+
source: "disabled",
|
|
2936
|
+
cause: "disabled-in-config"
|
|
2937
|
+
};
|
|
2938
|
+
const explicitlyAllowed = params.config.allow.includes(params.id);
|
|
2939
|
+
if (params.origin === "workspace" && !explicitlyAllowed && entry?.enabled !== true && explicitSelection.cause !== "selected-context-engine-slot") return {
|
|
2940
|
+
enabled: false,
|
|
2941
|
+
activated: false,
|
|
2942
|
+
explicitlyEnabled: explicitSelection.explicitlyEnabled,
|
|
2943
|
+
source: "disabled",
|
|
2944
|
+
cause: "workspace-disabled-by-default"
|
|
2945
|
+
};
|
|
2946
|
+
if (params.config.slots.memory === params.id) return {
|
|
2947
|
+
enabled: true,
|
|
2948
|
+
activated: true,
|
|
2949
|
+
explicitlyEnabled: true,
|
|
2950
|
+
source: "explicit",
|
|
2951
|
+
cause: "selected-memory-slot"
|
|
2952
|
+
};
|
|
2953
|
+
if (params.config.slots.contextEngine === params.id) return {
|
|
2954
|
+
enabled: true,
|
|
2955
|
+
activated: true,
|
|
2956
|
+
explicitlyEnabled: true,
|
|
2957
|
+
source: "explicit",
|
|
2958
|
+
cause: "selected-context-engine-slot"
|
|
2959
|
+
};
|
|
2960
|
+
if (params.allowBundledChannelExplicitBypassesAllowlist === true && explicitSelection.cause === "bundled-channel-enabled-in-config") return {
|
|
2961
|
+
enabled: true,
|
|
2962
|
+
activated: true,
|
|
2963
|
+
explicitlyEnabled: true,
|
|
2964
|
+
source: "explicit",
|
|
2965
|
+
cause: explicitSelection.cause
|
|
2966
|
+
};
|
|
2967
|
+
if (params.config.allow.length > 0 && !explicitlyAllowed) return {
|
|
2968
|
+
enabled: false,
|
|
2969
|
+
activated: false,
|
|
2970
|
+
explicitlyEnabled: explicitSelection.explicitlyEnabled,
|
|
2971
|
+
source: "disabled",
|
|
2972
|
+
cause: "not-in-allowlist"
|
|
2973
|
+
};
|
|
2974
|
+
if (explicitSelection.explicitlyEnabled) return {
|
|
2975
|
+
enabled: true,
|
|
2976
|
+
activated: true,
|
|
2977
|
+
explicitlyEnabled: true,
|
|
2978
|
+
source: "explicit",
|
|
2979
|
+
cause: explicitSelection.cause
|
|
2980
|
+
};
|
|
2981
|
+
if (params.autoEnabledReason) return {
|
|
2982
|
+
enabled: true,
|
|
2983
|
+
activated: true,
|
|
2984
|
+
explicitlyEnabled: false,
|
|
2985
|
+
source: "auto",
|
|
2986
|
+
reason: params.autoEnabledReason
|
|
2987
|
+
};
|
|
2988
|
+
if (entry?.enabled === true) return {
|
|
2989
|
+
enabled: true,
|
|
2990
|
+
activated: true,
|
|
2991
|
+
explicitlyEnabled: false,
|
|
2992
|
+
source: "auto",
|
|
2993
|
+
cause: "enabled-by-effective-config"
|
|
2994
|
+
};
|
|
2995
|
+
if (params.origin === "bundled" && params.isBundledChannelEnabledByChannelConfig(params.rootConfig, params.id)) return {
|
|
2996
|
+
enabled: true,
|
|
2997
|
+
activated: true,
|
|
2998
|
+
explicitlyEnabled: false,
|
|
2999
|
+
source: "auto",
|
|
3000
|
+
cause: "bundled-channel-configured"
|
|
3001
|
+
};
|
|
3002
|
+
if (params.origin === "bundled" && params.enabledByDefault === true) return {
|
|
3003
|
+
enabled: true,
|
|
3004
|
+
activated: true,
|
|
3005
|
+
explicitlyEnabled: false,
|
|
3006
|
+
source: "default",
|
|
3007
|
+
cause: "bundled-default-enablement"
|
|
3008
|
+
};
|
|
3009
|
+
if (params.origin === "bundled") return {
|
|
3010
|
+
enabled: false,
|
|
3011
|
+
activated: false,
|
|
3012
|
+
explicitlyEnabled: false,
|
|
3013
|
+
source: "disabled",
|
|
3014
|
+
cause: "bundled-disabled-by-default"
|
|
3015
|
+
};
|
|
3016
|
+
return {
|
|
3017
|
+
enabled: true,
|
|
3018
|
+
activated: true,
|
|
3019
|
+
explicitlyEnabled: explicitSelection.explicitlyEnabled,
|
|
3020
|
+
source: "default"
|
|
3021
|
+
};
|
|
3022
|
+
}
|
|
3023
|
+
function toEnableStateResult(state) {
|
|
3024
|
+
return state.enabled ? { enabled: true } : {
|
|
3025
|
+
enabled: false,
|
|
3026
|
+
reason: state.reason
|
|
3027
|
+
};
|
|
3028
|
+
}
|
|
3029
|
+
function resolveEnableStateResult(params, resolveState) {
|
|
3030
|
+
return toEnableStateResult(resolveState(params));
|
|
3031
|
+
}
|
|
3032
|
+
function createPluginEnableStateResolver(resolveState) {
|
|
3033
|
+
return (id, origin, config, enabledByDefault) => resolveEnableStateResult({
|
|
3034
|
+
id,
|
|
3035
|
+
origin,
|
|
3036
|
+
config,
|
|
3037
|
+
enabledByDefault
|
|
3038
|
+
}, resolveState);
|
|
3039
|
+
}
|
|
3040
|
+
function createEffectiveEnableStateResolver(resolveState) {
|
|
3041
|
+
return (params) => resolveEnableStateResult(params, resolveState);
|
|
3042
|
+
}
|
|
3043
|
+
function hasKind(kind, target) {
|
|
3044
|
+
if (!kind) return false;
|
|
3045
|
+
return Array.isArray(kind) ? kind.includes(target) : kind === target;
|
|
3046
|
+
}
|
|
3047
|
+
function resolveMemorySlotDecisionShared(params) {
|
|
3048
|
+
if (!hasKind(params.kind, "memory")) return { enabled: true };
|
|
3049
|
+
const isMultiKind = Array.isArray(params.kind) && params.kind.length > 1;
|
|
3050
|
+
if (params.slot === null) return isMultiKind ? { enabled: true } : {
|
|
3051
|
+
enabled: false,
|
|
3052
|
+
reason: "memory slot disabled"
|
|
3053
|
+
};
|
|
3054
|
+
if (typeof params.slot === "string") {
|
|
3055
|
+
if (params.slot === params.id) return {
|
|
3056
|
+
enabled: true,
|
|
3057
|
+
selected: true
|
|
3058
|
+
};
|
|
3059
|
+
return isMultiKind ? { enabled: true } : {
|
|
3060
|
+
enabled: false,
|
|
3061
|
+
reason: `memory slot set to "${params.slot}"`
|
|
3062
|
+
};
|
|
3063
|
+
}
|
|
3064
|
+
if (params.selectedId && params.selectedId !== params.id) return isMultiKind ? { enabled: true } : {
|
|
3065
|
+
enabled: false,
|
|
3066
|
+
reason: `memory slot already filled by "${params.selectedId}"`
|
|
3067
|
+
};
|
|
3068
|
+
return {
|
|
3069
|
+
enabled: true,
|
|
3070
|
+
selected: true
|
|
3071
|
+
};
|
|
3072
|
+
}
|
|
3073
|
+
const identityNormalizePluginId = (id) => id.trim();
|
|
3074
|
+
function normalizeList(value, normalizePluginId) {
|
|
3075
|
+
if (!Array.isArray(value)) return [];
|
|
3076
|
+
return value.map((entry) => typeof entry === "string" ? normalizePluginId(entry) : "").filter(Boolean);
|
|
3077
|
+
}
|
|
3078
|
+
function normalizeSlotValue(value) {
|
|
3079
|
+
const trimmed = normalizeOptionalString(value);
|
|
3080
|
+
if (!trimmed) return;
|
|
3081
|
+
if (normalizeOptionalLowercaseString(trimmed) === "none") return null;
|
|
3082
|
+
return trimmed;
|
|
3083
|
+
}
|
|
3084
|
+
function normalizePluginEntries(entries, normalizePluginId) {
|
|
3085
|
+
if (!entries || typeof entries !== "object" || Array.isArray(entries)) return {};
|
|
3086
|
+
const normalized = {};
|
|
3087
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
3088
|
+
const normalizedKey = normalizePluginId(key);
|
|
3089
|
+
if (!normalizedKey) continue;
|
|
3090
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
3091
|
+
normalized[normalizedKey] = {};
|
|
3092
|
+
continue;
|
|
3093
|
+
}
|
|
3094
|
+
const entry = value;
|
|
3095
|
+
const hooksRaw = entry.hooks;
|
|
3096
|
+
const hooks = hooksRaw && typeof hooksRaw === "object" && !Array.isArray(hooksRaw) ? { allowPromptInjection: hooksRaw.allowPromptInjection } : void 0;
|
|
3097
|
+
const normalizedHooks = hooks && typeof hooks.allowPromptInjection === "boolean" ? { allowPromptInjection: hooks.allowPromptInjection } : void 0;
|
|
3098
|
+
const subagentRaw = entry.subagent;
|
|
3099
|
+
const subagent = subagentRaw && typeof subagentRaw === "object" && !Array.isArray(subagentRaw) ? {
|
|
3100
|
+
allowModelOverride: subagentRaw.allowModelOverride,
|
|
3101
|
+
hasAllowedModelsConfig: Array.isArray(subagentRaw.allowedModels),
|
|
3102
|
+
allowedModels: Array.isArray(subagentRaw.allowedModels) ? subagentRaw.allowedModels.map((model) => normalizeOptionalString(model)).filter((model) => Boolean(model)) : void 0
|
|
3103
|
+
} : void 0;
|
|
3104
|
+
const normalizedSubagent = subagent && (typeof subagent.allowModelOverride === "boolean" || subagent.hasAllowedModelsConfig || Array.isArray(subagent.allowedModels) && subagent.allowedModels.length > 0) ? {
|
|
3105
|
+
...typeof subagent.allowModelOverride === "boolean" ? { allowModelOverride: subagent.allowModelOverride } : {},
|
|
3106
|
+
...subagent.hasAllowedModelsConfig ? { hasAllowedModelsConfig: true } : {},
|
|
3107
|
+
...Array.isArray(subagent.allowedModels) && subagent.allowedModels.length > 0 ? { allowedModels: subagent.allowedModels } : {}
|
|
3108
|
+
} : void 0;
|
|
3109
|
+
normalized[normalizedKey] = {
|
|
3110
|
+
...normalized[normalizedKey],
|
|
3111
|
+
enabled: typeof entry.enabled === "boolean" ? entry.enabled : normalized[normalizedKey]?.enabled,
|
|
3112
|
+
hooks: normalizedHooks ?? normalized[normalizedKey]?.hooks,
|
|
3113
|
+
subagent: normalizedSubagent ?? normalized[normalizedKey]?.subagent,
|
|
3114
|
+
config: "config" in entry ? entry.config : normalized[normalizedKey]?.config
|
|
3115
|
+
};
|
|
3116
|
+
}
|
|
3117
|
+
return normalized;
|
|
3118
|
+
}
|
|
3119
|
+
function normalizePluginsConfigWithResolver$1(config, normalizePluginId = identityNormalizePluginId) {
|
|
3120
|
+
const memorySlot = normalizeSlotValue(config?.slots?.memory);
|
|
3121
|
+
return {
|
|
3122
|
+
enabled: config?.enabled !== false,
|
|
3123
|
+
allow: normalizeList(config?.allow, normalizePluginId),
|
|
3124
|
+
deny: normalizeList(config?.deny, normalizePluginId),
|
|
3125
|
+
loadPaths: normalizeList(config?.load?.paths, identityNormalizePluginId),
|
|
3126
|
+
slots: {
|
|
3127
|
+
memory: memorySlot === void 0 ? defaultSlotIdForKey("memory") : memorySlot,
|
|
3128
|
+
contextEngine: normalizeSlotValue(config?.slots?.contextEngine)
|
|
3129
|
+
},
|
|
3130
|
+
entries: normalizePluginEntries(config?.entries, normalizePluginId)
|
|
3131
|
+
};
|
|
3132
|
+
}
|
|
3133
|
+
function hasExplicitPluginConfig$1(plugins) {
|
|
3134
|
+
if (!plugins) return false;
|
|
3135
|
+
if (typeof plugins.enabled === "boolean") return true;
|
|
3136
|
+
if (Array.isArray(plugins.allow) && plugins.allow.length > 0) return true;
|
|
3137
|
+
if (Array.isArray(plugins.deny) && plugins.deny.length > 0) return true;
|
|
3138
|
+
if (plugins.load?.paths && Array.isArray(plugins.load.paths) && plugins.load.paths.length > 0) return true;
|
|
3139
|
+
if (plugins.slots && Object.keys(plugins.slots).length > 0) return true;
|
|
3140
|
+
if (plugins.entries && Object.keys(plugins.entries).length > 0) return true;
|
|
3141
|
+
return false;
|
|
3142
|
+
}
|
|
3143
|
+
function isBundledChannelEnabledByChannelConfig$1(cfg, pluginId) {
|
|
3144
|
+
if (!cfg) return false;
|
|
3145
|
+
const channelId = normalizeChatChannelId(pluginId);
|
|
3146
|
+
if (!channelId) return false;
|
|
3147
|
+
const entry = cfg.channels?.[channelId];
|
|
3148
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return false;
|
|
3149
|
+
return entry.enabled === true;
|
|
3150
|
+
}
|
|
3151
|
+
function normalizePluginsConfigWithResolver(config, normalizePluginId = identityNormalizePluginId) {
|
|
3152
|
+
return normalizePluginsConfigWithResolver$1(config, normalizePluginId);
|
|
3153
|
+
}
|
|
3154
|
+
function resolvePluginActivationState(params) {
|
|
3155
|
+
return toPluginActivationState(resolvePluginActivationDecisionShared({
|
|
3156
|
+
...params,
|
|
3157
|
+
activationSource: {
|
|
3158
|
+
plugins: params.sourceConfig ?? params.config,
|
|
3159
|
+
rootConfig: params.sourceRootConfig ?? params.rootConfig
|
|
3160
|
+
},
|
|
3161
|
+
isBundledChannelEnabledByChannelConfig
|
|
3162
|
+
}));
|
|
3163
|
+
}
|
|
3164
|
+
const hasExplicitPluginConfig = hasExplicitPluginConfig$1;
|
|
3165
|
+
createPluginEnableStateResolver(resolvePluginActivationState);
|
|
3166
|
+
const isBundledChannelEnabledByChannelConfig = isBundledChannelEnabledByChannelConfig$1;
|
|
3167
|
+
createEffectiveEnableStateResolver(resolveEffectivePluginActivationState);
|
|
3168
|
+
function resolveEffectivePluginActivationState(params) {
|
|
3169
|
+
return resolvePluginActivationState(params);
|
|
3170
|
+
}
|
|
3171
|
+
const pluginManifestRegistryCache = /* @__PURE__ */ new Map();
|
|
3172
|
+
const PLUGIN_ORIGIN_RANK = {
|
|
3173
|
+
config: 0,
|
|
3174
|
+
workspace: 1,
|
|
3175
|
+
global: 2,
|
|
3176
|
+
bundled: 3
|
|
3177
|
+
};
|
|
3178
|
+
const registryCache = pluginManifestRegistryCache;
|
|
3179
|
+
const DEFAULT_MANIFEST_CACHE_MS = 1e3;
|
|
3180
|
+
function listContractValues(plugin, contract) {
|
|
3181
|
+
return plugin.contracts?.[contract] ?? [];
|
|
3182
|
+
}
|
|
3183
|
+
function resolveManifestContractPluginIds(params) {
|
|
3184
|
+
const onlyPluginIdSet = params.onlyPluginIds && params.onlyPluginIds.length > 0 ? new Set(params.onlyPluginIds) : null;
|
|
3185
|
+
return loadPluginManifestRegistry({
|
|
3186
|
+
config: params.config,
|
|
3187
|
+
workspaceDir: params.workspaceDir,
|
|
3188
|
+
env: params.env
|
|
3189
|
+
}).plugins.filter((plugin) => (!params.origin || plugin.origin === params.origin) && (!onlyPluginIdSet || onlyPluginIdSet.has(plugin.id)) && listContractValues(plugin, params.contract).length > 0).map((plugin) => plugin.id).toSorted((left, right) => left.localeCompare(right));
|
|
3190
|
+
}
|
|
3191
|
+
function resolveManifestContractPluginIdsByCompatibilityRuntimePath(params) {
|
|
3192
|
+
const normalizedPath = params.path?.trim();
|
|
3193
|
+
if (!normalizedPath) return [];
|
|
3194
|
+
return loadPluginManifestRegistry({
|
|
3195
|
+
config: params.config,
|
|
3196
|
+
workspaceDir: params.workspaceDir,
|
|
3197
|
+
env: params.env
|
|
3198
|
+
}).plugins.filter((plugin) => (!params.origin || plugin.origin === params.origin) && listContractValues(plugin, params.contract).length > 0 && (plugin.configContracts?.compatibilityRuntimePaths ?? []).includes(normalizedPath)).map((plugin) => plugin.id).toSorted((left, right) => left.localeCompare(right));
|
|
3199
|
+
}
|
|
3200
|
+
function resolveManifestContractOwnerPluginId(params) {
|
|
3201
|
+
const normalizedValue = normalizeOptionalLowercaseString(params.value);
|
|
3202
|
+
if (!normalizedValue) return;
|
|
3203
|
+
return loadPluginManifestRegistry({
|
|
3204
|
+
config: params.config,
|
|
3205
|
+
workspaceDir: params.workspaceDir,
|
|
3206
|
+
env: params.env
|
|
3207
|
+
}).plugins.find((plugin) => (!params.origin || plugin.origin === params.origin) && listContractValues(plugin, params.contract).some((candidate) => normalizeOptionalLowercaseString(candidate) === normalizedValue))?.id;
|
|
3208
|
+
}
|
|
3209
|
+
function resolveManifestCacheMs(env) {
|
|
3210
|
+
const raw = env.OPENCLAW_PLUGIN_MANIFEST_CACHE_MS?.trim();
|
|
3211
|
+
if (raw === "" || raw === "0") return 0;
|
|
3212
|
+
if (!raw) return DEFAULT_MANIFEST_CACHE_MS;
|
|
3213
|
+
const parsed = Number.parseInt(raw, 10);
|
|
3214
|
+
if (!Number.isFinite(parsed)) return DEFAULT_MANIFEST_CACHE_MS;
|
|
3215
|
+
return Math.max(0, parsed);
|
|
3216
|
+
}
|
|
3217
|
+
function shouldUseManifestCache(env) {
|
|
3218
|
+
if (env.OPENCLAW_DISABLE_PLUGIN_MANIFEST_CACHE?.trim()) return false;
|
|
3219
|
+
return resolveManifestCacheMs(env) > 0;
|
|
3220
|
+
}
|
|
3221
|
+
function buildCacheKey(params) {
|
|
3222
|
+
const { roots, loadPaths } = resolvePluginCacheInputs({
|
|
3223
|
+
workspaceDir: params.workspaceDir,
|
|
3224
|
+
loadPaths: params.plugins.loadPaths,
|
|
3225
|
+
env: params.env
|
|
3226
|
+
});
|
|
3227
|
+
return `${roots.workspace ?? ""}::${roots.global}::${roots.stock ?? ""}::${resolveCompatibilityHostVersion(params.env)}::${JSON.stringify(loadPaths)}`;
|
|
3228
|
+
}
|
|
3229
|
+
function safeStatMtimeMs(filePath) {
|
|
3230
|
+
try {
|
|
3231
|
+
return fs.statSync(filePath).mtimeMs;
|
|
3232
|
+
} catch {
|
|
3233
|
+
return null;
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
function normalizePreferredPluginIds(raw) {
|
|
3237
|
+
return normalizeOptionalTrimmedStringList(raw);
|
|
3238
|
+
}
|
|
3239
|
+
function mergePackageChannelMetaIntoChannelConfigs(params) {
|
|
3240
|
+
const channelId = params.packageChannel?.id?.trim();
|
|
3241
|
+
if (!channelId || !params.channelConfigs?.[channelId]) return params.channelConfigs;
|
|
3242
|
+
const existing = params.channelConfigs[channelId];
|
|
3243
|
+
const label = existing.label ?? normalizeOptionalString(params.packageChannel?.label) ?? "";
|
|
3244
|
+
const description = existing.description ?? normalizeOptionalString(params.packageChannel?.blurb) ?? "";
|
|
3245
|
+
const preferOver = existing.preferOver ?? normalizePreferredPluginIds(params.packageChannel?.preferOver);
|
|
3246
|
+
return {
|
|
3247
|
+
...params.channelConfigs,
|
|
3248
|
+
[channelId]: {
|
|
3249
|
+
...existing,
|
|
3250
|
+
...label ? { label } : {},
|
|
3251
|
+
...description ? { description } : {},
|
|
3252
|
+
...preferOver?.length ? { preferOver } : {}
|
|
3253
|
+
}
|
|
3254
|
+
};
|
|
3255
|
+
}
|
|
3256
|
+
function buildRecord(params) {
|
|
3257
|
+
const channelConfigs = mergePackageChannelMetaIntoChannelConfigs({
|
|
3258
|
+
channelConfigs: params.manifest.channelConfigs,
|
|
3259
|
+
packageChannel: params.candidate.packageManifest?.channel
|
|
3260
|
+
});
|
|
3261
|
+
return {
|
|
3262
|
+
id: params.manifest.id,
|
|
3263
|
+
name: normalizeOptionalString(params.manifest.name) ?? params.candidate.packageName,
|
|
3264
|
+
description: normalizeOptionalString(params.manifest.description) ?? params.candidate.packageDescription,
|
|
3265
|
+
version: normalizeOptionalString(params.manifest.version) ?? params.candidate.packageVersion,
|
|
3266
|
+
enabledByDefault: params.manifest.enabledByDefault === true ? true : void 0,
|
|
3267
|
+
autoEnableWhenConfiguredProviders: params.manifest.autoEnableWhenConfiguredProviders,
|
|
3268
|
+
legacyPluginIds: params.manifest.legacyPluginIds,
|
|
3269
|
+
format: params.candidate.format ?? "openclaw",
|
|
3270
|
+
bundleFormat: params.candidate.bundleFormat,
|
|
3271
|
+
kind: params.manifest.kind,
|
|
3272
|
+
channels: params.manifest.channels ?? [],
|
|
3273
|
+
providers: params.manifest.providers ?? [],
|
|
3274
|
+
providerDiscoverySource: params.manifest.providerDiscoveryEntry ? path.resolve(params.candidate.rootDir, params.manifest.providerDiscoveryEntry) : void 0,
|
|
3275
|
+
modelSupport: params.manifest.modelSupport,
|
|
3276
|
+
providerEndpoints: params.manifest.providerEndpoints,
|
|
3277
|
+
cliBackends: params.manifest.cliBackends ?? [],
|
|
3278
|
+
syntheticAuthRefs: params.manifest.syntheticAuthRefs ?? [],
|
|
3279
|
+
nonSecretAuthMarkers: params.manifest.nonSecretAuthMarkers ?? [],
|
|
3280
|
+
commandAliases: params.manifest.commandAliases,
|
|
3281
|
+
providerAuthEnvVars: params.manifest.providerAuthEnvVars,
|
|
3282
|
+
providerAuthAliases: params.manifest.providerAuthAliases,
|
|
3283
|
+
channelEnvVars: params.manifest.channelEnvVars,
|
|
3284
|
+
providerAuthChoices: params.manifest.providerAuthChoices,
|
|
3285
|
+
activation: params.manifest.activation,
|
|
3286
|
+
setup: params.manifest.setup,
|
|
3287
|
+
qaRunners: params.manifest.qaRunners,
|
|
3288
|
+
skills: params.manifest.skills ?? [],
|
|
3289
|
+
settingsFiles: [],
|
|
3290
|
+
hooks: [],
|
|
3291
|
+
origin: params.candidate.origin,
|
|
3292
|
+
workspaceDir: params.candidate.workspaceDir,
|
|
3293
|
+
rootDir: params.candidate.rootDir,
|
|
3294
|
+
source: params.candidate.source,
|
|
3295
|
+
setupSource: params.candidate.setupSource,
|
|
3296
|
+
startupDeferConfiguredChannelFullLoadUntilAfterListen: params.candidate.packageManifest?.startup?.deferConfiguredChannelFullLoadUntilAfterListen === true,
|
|
3297
|
+
manifestPath: params.manifestPath,
|
|
3298
|
+
schemaCacheKey: params.schemaCacheKey,
|
|
3299
|
+
configSchema: params.configSchema,
|
|
3300
|
+
configUiHints: params.manifest.uiHints,
|
|
3301
|
+
contracts: params.manifest.contracts,
|
|
3302
|
+
mediaUnderstandingProviderMetadata: params.manifest.mediaUnderstandingProviderMetadata,
|
|
3303
|
+
configContracts: params.manifest.configContracts,
|
|
3304
|
+
channelConfigs,
|
|
3305
|
+
...params.candidate.packageManifest?.channel?.id ? { channelCatalogMeta: {
|
|
3306
|
+
id: params.candidate.packageManifest.channel.id,
|
|
3307
|
+
...typeof params.candidate.packageManifest.channel.label === "string" ? { label: params.candidate.packageManifest.channel.label } : {},
|
|
3308
|
+
...typeof params.candidate.packageManifest.channel.blurb === "string" ? { blurb: params.candidate.packageManifest.channel.blurb } : {},
|
|
3309
|
+
...params.candidate.packageManifest.channel.preferOver ? { preferOver: params.candidate.packageManifest.channel.preferOver } : {}
|
|
3310
|
+
} } : {}
|
|
3311
|
+
};
|
|
3312
|
+
}
|
|
3313
|
+
function buildBundleRecord(params) {
|
|
3314
|
+
return {
|
|
3315
|
+
id: params.manifest.id,
|
|
3316
|
+
name: normalizeOptionalString(params.manifest.name) ?? params.candidate.idHint,
|
|
3317
|
+
description: normalizeOptionalString(params.manifest.description),
|
|
3318
|
+
version: normalizeOptionalString(params.manifest.version),
|
|
3319
|
+
format: "bundle",
|
|
3320
|
+
bundleFormat: params.candidate.bundleFormat,
|
|
3321
|
+
bundleCapabilities: params.manifest.capabilities,
|
|
3322
|
+
channels: [],
|
|
3323
|
+
providers: [],
|
|
3324
|
+
cliBackends: [],
|
|
3325
|
+
syntheticAuthRefs: [],
|
|
3326
|
+
nonSecretAuthMarkers: [],
|
|
3327
|
+
skills: params.manifest.skills ?? [],
|
|
3328
|
+
settingsFiles: params.manifest.settingsFiles ?? [],
|
|
3329
|
+
hooks: params.manifest.hooks ?? [],
|
|
3330
|
+
origin: params.candidate.origin,
|
|
3331
|
+
workspaceDir: params.candidate.workspaceDir,
|
|
3332
|
+
rootDir: params.candidate.rootDir,
|
|
3333
|
+
source: params.candidate.source,
|
|
3334
|
+
manifestPath: params.manifestPath,
|
|
3335
|
+
schemaCacheKey: void 0,
|
|
3336
|
+
configSchema: void 0,
|
|
3337
|
+
configUiHints: void 0,
|
|
3338
|
+
configContracts: void 0,
|
|
3339
|
+
channelConfigs: void 0
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3342
|
+
function matchesInstalledPluginRecord(params) {
|
|
3343
|
+
if (params.candidate.origin !== "global") return false;
|
|
3344
|
+
const record = params.config?.plugins?.installs?.[params.pluginId];
|
|
3345
|
+
if (!record) return false;
|
|
3346
|
+
const candidateSource = resolveUserPath(params.candidate.source, params.env);
|
|
3347
|
+
const trackedPaths = [record.installPath, record.sourcePath].filter((entry) => typeof entry === "string" && entry.trim().length > 0).map((entry) => resolveUserPath(entry, params.env));
|
|
3348
|
+
if (trackedPaths.length === 0) return false;
|
|
3349
|
+
return trackedPaths.some((trackedPath) => {
|
|
3350
|
+
return candidateSource === trackedPath || isPathInside(trackedPath, candidateSource);
|
|
3351
|
+
});
|
|
3352
|
+
}
|
|
3353
|
+
function resolveDuplicatePrecedenceRank(params) {
|
|
3354
|
+
if (params.candidate.origin === "config") return 0;
|
|
3355
|
+
if (params.candidate.origin === "global" && matchesInstalledPluginRecord({
|
|
3356
|
+
pluginId: params.pluginId,
|
|
3357
|
+
candidate: params.candidate,
|
|
3358
|
+
config: params.config,
|
|
3359
|
+
env: params.env
|
|
3360
|
+
})) return 1;
|
|
3361
|
+
if (params.candidate.origin === "bundled") return 2;
|
|
3362
|
+
if (params.candidate.origin === "workspace") return 3;
|
|
3363
|
+
return 4;
|
|
3364
|
+
}
|
|
3365
|
+
function loadPluginManifestRegistry(params = {}) {
|
|
3366
|
+
const config = params.config ?? {};
|
|
3367
|
+
const normalized = normalizePluginsConfigWithResolver(config.plugins);
|
|
3368
|
+
const env = params.env ?? process.env;
|
|
3369
|
+
const cacheKey = buildCacheKey({
|
|
3370
|
+
workspaceDir: params.workspaceDir,
|
|
3371
|
+
plugins: normalized,
|
|
3372
|
+
env
|
|
3373
|
+
});
|
|
3374
|
+
const cacheEnabled = params.cache !== false && shouldUseManifestCache(env);
|
|
3375
|
+
if (cacheEnabled) {
|
|
3376
|
+
const cached = registryCache.get(cacheKey);
|
|
3377
|
+
if (cached && cached.expiresAt > Date.now()) return cached.registry;
|
|
3378
|
+
}
|
|
3379
|
+
const discovery = params.candidates ? {
|
|
3380
|
+
candidates: params.candidates,
|
|
3381
|
+
diagnostics: params.diagnostics ?? []
|
|
3382
|
+
} : discoverOpenClawPlugins({
|
|
3383
|
+
workspaceDir: params.workspaceDir,
|
|
3384
|
+
extraPaths: normalized.loadPaths,
|
|
3385
|
+
cache: params.cache,
|
|
3386
|
+
env
|
|
3387
|
+
});
|
|
3388
|
+
const diagnostics = [...discovery.diagnostics];
|
|
3389
|
+
const candidates = discovery.candidates;
|
|
3390
|
+
const records = [];
|
|
3391
|
+
const seenIds = /* @__PURE__ */ new Map();
|
|
3392
|
+
const realpathCache = /* @__PURE__ */ new Map();
|
|
3393
|
+
const currentHostVersion = resolveCompatibilityHostVersion(env);
|
|
3394
|
+
for (const candidate of candidates) {
|
|
3395
|
+
const rejectHardlinks = candidate.origin !== "bundled";
|
|
3396
|
+
const isBundleRecord = (candidate.format ?? "openclaw") === "bundle";
|
|
3397
|
+
const manifestRes = candidate.origin === "bundled" && candidate.bundledManifest && candidate.bundledManifestPath ? {
|
|
3398
|
+
ok: true,
|
|
3399
|
+
manifest: candidate.bundledManifest,
|
|
3400
|
+
manifestPath: candidate.bundledManifestPath
|
|
3401
|
+
} : isBundleRecord && candidate.bundleFormat ? loadBundleManifest({
|
|
3402
|
+
rootDir: candidate.rootDir,
|
|
3403
|
+
bundleFormat: candidate.bundleFormat,
|
|
3404
|
+
rejectHardlinks
|
|
3405
|
+
}) : loadPluginManifest(candidate.rootDir, rejectHardlinks);
|
|
3406
|
+
if (!manifestRes.ok) {
|
|
3407
|
+
diagnostics.push({
|
|
3408
|
+
level: "error",
|
|
3409
|
+
message: manifestRes.error,
|
|
3410
|
+
source: manifestRes.manifestPath
|
|
3411
|
+
});
|
|
3412
|
+
continue;
|
|
3413
|
+
}
|
|
3414
|
+
const manifest = manifestRes.manifest;
|
|
3415
|
+
const minHostVersionCheck = checkMinHostVersion({
|
|
3416
|
+
currentVersion: currentHostVersion,
|
|
3417
|
+
minHostVersion: candidate.packageManifest?.install?.minHostVersion
|
|
3418
|
+
});
|
|
3419
|
+
if (!minHostVersionCheck.ok) {
|
|
3420
|
+
const packageManifestSource = path.join(candidate.packageDir ?? candidate.rootDir, "package.json");
|
|
3421
|
+
diagnostics.push({
|
|
3422
|
+
level: minHostVersionCheck.kind === "unknown_host_version" ? "warn" : "error",
|
|
3423
|
+
pluginId: manifest.id,
|
|
3424
|
+
source: packageManifestSource,
|
|
3425
|
+
message: minHostVersionCheck.kind === "invalid" ? `plugin manifest invalid | ${minHostVersionCheck.error}` : minHostVersionCheck.kind === "unknown_host_version" ? `plugin requires OpenClaw >=${minHostVersionCheck.requirement.minimumLabel}, but this host version could not be determined; skipping load` : `plugin requires OpenClaw >=${minHostVersionCheck.requirement.minimumLabel}, but this host is ${minHostVersionCheck.currentVersion}; skipping load`
|
|
3426
|
+
});
|
|
3427
|
+
continue;
|
|
3428
|
+
}
|
|
3429
|
+
const configSchema = "configSchema" in manifest ? manifest.configSchema : void 0;
|
|
3430
|
+
const schemaCacheKey = (() => {
|
|
3431
|
+
if (!configSchema) return;
|
|
3432
|
+
const manifestMtime = safeStatMtimeMs(manifestRes.manifestPath);
|
|
3433
|
+
return manifestMtime ? `${manifestRes.manifestPath}:${manifestMtime}` : manifestRes.manifestPath;
|
|
3434
|
+
})();
|
|
3435
|
+
const record = isBundleRecord ? buildBundleRecord({
|
|
3436
|
+
manifest,
|
|
3437
|
+
candidate,
|
|
3438
|
+
manifestPath: manifestRes.manifestPath
|
|
3439
|
+
}) : buildRecord({
|
|
3440
|
+
manifest,
|
|
3441
|
+
candidate,
|
|
3442
|
+
manifestPath: manifestRes.manifestPath,
|
|
3443
|
+
schemaCacheKey,
|
|
3444
|
+
configSchema
|
|
3445
|
+
});
|
|
3446
|
+
const existing = seenIds.get(manifest.id);
|
|
3447
|
+
if (existing) {
|
|
3448
|
+
const samePath = existing.candidate.rootDir === candidate.rootDir;
|
|
3449
|
+
if ((() => {
|
|
3450
|
+
if (samePath) return true;
|
|
3451
|
+
const existingReal = safeRealpathSync(existing.candidate.rootDir, realpathCache);
|
|
3452
|
+
const candidateReal = safeRealpathSync(candidate.rootDir, realpathCache);
|
|
3453
|
+
return Boolean(existingReal && candidateReal && existingReal === candidateReal);
|
|
3454
|
+
})()) {
|
|
3455
|
+
if (PLUGIN_ORIGIN_RANK[candidate.origin] < PLUGIN_ORIGIN_RANK[existing.candidate.origin]) {
|
|
3456
|
+
records[existing.recordIndex] = record;
|
|
3457
|
+
seenIds.set(manifest.id, {
|
|
3458
|
+
candidate,
|
|
3459
|
+
recordIndex: existing.recordIndex
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3462
|
+
continue;
|
|
3463
|
+
}
|
|
3464
|
+
const candidateWins = resolveDuplicatePrecedenceRank({
|
|
3465
|
+
pluginId: manifest.id,
|
|
3466
|
+
candidate,
|
|
3467
|
+
config,
|
|
3468
|
+
env
|
|
3469
|
+
}) < resolveDuplicatePrecedenceRank({
|
|
3470
|
+
pluginId: manifest.id,
|
|
3471
|
+
candidate: existing.candidate,
|
|
3472
|
+
config,
|
|
3473
|
+
env
|
|
3474
|
+
});
|
|
3475
|
+
const winnerCandidate = candidateWins ? candidate : existing.candidate;
|
|
3476
|
+
const overriddenCandidate = candidateWins ? existing.candidate : candidate;
|
|
3477
|
+
if (candidateWins) {
|
|
3478
|
+
records[existing.recordIndex] = record;
|
|
3479
|
+
seenIds.set(manifest.id, {
|
|
3480
|
+
candidate,
|
|
3481
|
+
recordIndex: existing.recordIndex
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
diagnostics.push({
|
|
3485
|
+
level: "warn",
|
|
3486
|
+
pluginId: manifest.id,
|
|
3487
|
+
source: overriddenCandidate.source,
|
|
3488
|
+
message: `duplicate plugin id detected; ${overriddenCandidate.origin} plugin will be overridden by ${winnerCandidate.origin} plugin (${winnerCandidate.source})`
|
|
3489
|
+
});
|
|
3490
|
+
continue;
|
|
3491
|
+
}
|
|
3492
|
+
seenIds.set(manifest.id, {
|
|
3493
|
+
candidate,
|
|
3494
|
+
recordIndex: records.length
|
|
3495
|
+
});
|
|
3496
|
+
records.push(record);
|
|
3497
|
+
}
|
|
3498
|
+
const registry = {
|
|
3499
|
+
plugins: records,
|
|
3500
|
+
diagnostics
|
|
3501
|
+
};
|
|
3502
|
+
if (cacheEnabled) {
|
|
3503
|
+
const ttl = resolveManifestCacheMs(env);
|
|
3504
|
+
if (ttl > 0) registryCache.set(cacheKey, {
|
|
3505
|
+
expiresAt: Date.now() + ttl,
|
|
3506
|
+
registry
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3509
|
+
return registry;
|
|
3510
|
+
}
|
|
3511
|
+
//#endregion
|
|
3512
|
+
export { resolveManifestCommandAliasOwnerInRegistry as A, mergeBundlePathLists as C, resolveRuntimeServiceVersion as D, VERSION as E, clearActiveProgressLine as F, normalizeStringEntries as M, normalizeTrimmedStringList as N, getPackageManifestMetadata as O, defaultRuntime as P, isPathInside as S, safeStatSync as T, discoverOpenClawPlugins as _, isBundledChannelEnabledByChannelConfig$1 as a, CODEX_BUNDLE_MANIFEST_RELATIVE_PATH as b, resolveManifestContractOwnerPluginId as c, resolveMemorySlotDecisionShared as d, resolvePluginActivationDecisionShared as f, kindsEqual as g, hasKind$1 as h, hasExplicitPluginConfig$1 as i, require_lib as j, loadPluginManifest as k, resolveManifestContractPluginIds as l, defaultSlotIdForKey as m, createPluginEnableStateResolver as n, loadPluginManifestRegistry as o, toPluginActivationState as p, hasExplicitPluginConfig as r, normalizePluginsConfigWithResolver$1 as s, createEffectiveEnableStateResolver as t, resolveManifestContractPluginIdsByCompatibilityRuntimePath as u, resolvePluginCacheInputs as v, normalizeBundlePathList as w, CURSOR_BUNDLE_MANIFEST_RELATIVE_PATH as x, CLAUDE_BUNDLE_MANIFEST_RELATIVE_PATH as y };
|