@namzu/sdk 69.2.0 → 69.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +30 -2
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/constants/plugin/index.d.ts +8 -0
- package/dist/constants/plugin/index.d.ts.map +1 -1
- package/dist/constants/plugin/index.js +8 -0
- package/dist/constants/plugin/index.js.map +1 -1
- package/dist/plugin/common-layout/index.d.ts +5 -0
- package/dist/plugin/common-layout/index.d.ts.map +1 -0
- package/dist/plugin/common-layout/index.js +3 -0
- package/dist/plugin/common-layout/index.js.map +1 -0
- package/dist/plugin/common-layout/mcp.d.ts +21 -0
- package/dist/plugin/common-layout/mcp.d.ts.map +1 -0
- package/dist/plugin/common-layout/mcp.js +305 -0
- package/dist/plugin/common-layout/mcp.js.map +1 -0
- package/dist/plugin/common-layout/paths.d.ts +27 -0
- package/dist/plugin/common-layout/paths.d.ts.map +1 -0
- package/dist/plugin/common-layout/paths.js +48 -0
- package/dist/plugin/common-layout/paths.js.map +1 -0
- package/dist/plugin/common-layout/read.d.ts +25 -0
- package/dist/plugin/common-layout/read.d.ts.map +1 -0
- package/dist/plugin/common-layout/read.js +1155 -0
- package/dist/plugin/common-layout/read.js.map +1 -0
- package/dist/plugin/common-layout/types.d.ts +66 -0
- package/dist/plugin/common-layout/types.d.ts.map +1 -0
- package/dist/plugin/common-layout/types.js +2 -0
- package/dist/plugin/common-layout/types.js.map +1 -0
- package/dist/plugin/common-layout-names.d.ts +65 -0
- package/dist/plugin/common-layout-names.d.ts.map +1 -0
- package/dist/plugin/common-layout-names.js +94 -0
- package/dist/plugin/common-layout-names.js.map +1 -0
- package/dist/plugin/hook-module/capabilities.d.ts +41 -0
- package/dist/plugin/hook-module/capabilities.d.ts.map +1 -0
- package/dist/plugin/hook-module/capabilities.js +438 -0
- package/dist/plugin/hook-module/capabilities.js.map +1 -0
- package/dist/plugin/hook-module/consent.d.ts +39 -0
- package/dist/plugin/hook-module/consent.d.ts.map +1 -0
- package/dist/plugin/hook-module/consent.js +59 -0
- package/dist/plugin/hook-module/consent.js.map +1 -0
- package/dist/plugin/hook-module/events.d.ts +33 -0
- package/dist/plugin/hook-module/events.d.ts.map +1 -0
- package/dist/plugin/hook-module/events.js +149 -0
- package/dist/plugin/hook-module/events.js.map +1 -0
- package/dist/plugin/hook-module/host.d.ts +79 -0
- package/dist/plugin/hook-module/host.d.ts.map +1 -0
- package/dist/plugin/hook-module/host.js +546 -0
- package/dist/plugin/hook-module/host.js.map +1 -0
- package/dist/plugin/hook-module/index.d.ts +11 -0
- package/dist/plugin/hook-module/index.d.ts.map +1 -0
- package/dist/plugin/hook-module/index.js +6 -0
- package/dist/plugin/hook-module/index.js.map +1 -0
- package/dist/plugin/hook-module/scan.d.ts +99 -0
- package/dist/plugin/hook-module/scan.d.ts.map +1 -0
- package/dist/plugin/hook-module/scan.js +789 -0
- package/dist/plugin/hook-module/scan.js.map +1 -0
- package/dist/plugin/hook-module/worker-source.d.ts +31 -0
- package/dist/plugin/hook-module/worker-source.d.ts.map +1 -0
- package/dist/plugin/hook-module/worker-source.js +498 -0
- package/dist/plugin/hook-module/worker-source.js.map +1 -0
- package/dist/plugin/index.d.ts +5 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +4 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +57 -0
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +92 -11
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/loader.d.ts +30 -0
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +76 -19
- package/dist/plugin/loader.js.map +1 -1
- package/dist/plugin/shell-hook-env.d.ts +7 -0
- package/dist/plugin/shell-hook-env.d.ts.map +1 -1
- package/dist/plugin/shell-hook-env.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +10 -1
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +81 -70
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +1 -1
- package/dist/provider/side-request-reasoning.d.ts.map +1 -1
- package/dist/provider/side-request-reasoning.js +5 -1
- package/dist/provider/side-request-reasoning.js.map +1 -1
- package/dist/public-runtime.d.ts +3 -2
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +2 -2
- package/dist/public-runtime.js.map +1 -1
- package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/classifier.js +13 -2
- package/dist/runtime/query/auto-review/classifier.js.map +1 -1
- package/dist/runtime/query/auto-review/failure.d.ts +12 -5
- package/dist/runtime/query/auto-review/failure.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/failure.js +42 -7
- package/dist/runtime/query/auto-review/failure.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +22 -6
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/turn/check-scope.d.ts +18 -0
- package/dist/runtime/query/turn/check-scope.d.ts.map +1 -0
- package/dist/runtime/query/turn/check-scope.js +90 -0
- package/dist/runtime/query/turn/check-scope.js.map +1 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +13 -0
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/skills/loader.d.ts +8 -2
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +22 -11
- package/dist/skills/loader.js.map +1 -1
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +9 -1
- package/dist/skills/registry.js.map +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +4 -1
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +2 -1
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/types/plugin/index.d.ts +73 -0
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +28 -6
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/skills/index.d.ts +6 -0
- package/dist/types/skills/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/authorization/readonly-commands.ts +30 -2
- package/src/constants/plugin/index.ts +9 -0
- package/src/plugin/common-layout/index.ts +19 -0
- package/src/plugin/common-layout/mcp.ts +362 -0
- package/src/plugin/common-layout/paths.ts +70 -0
- package/src/plugin/common-layout/read.ts +1282 -0
- package/src/plugin/common-layout/types.ts +77 -0
- package/src/plugin/common-layout-names.ts +108 -0
- package/src/plugin/hook-module/capabilities.ts +500 -0
- package/src/plugin/hook-module/consent.ts +96 -0
- package/src/plugin/hook-module/events.ts +177 -0
- package/src/plugin/hook-module/host.ts +649 -0
- package/src/plugin/hook-module/index.ts +52 -0
- package/src/plugin/hook-module/scan.ts +1004 -0
- package/src/plugin/hook-module/worker-source.ts +500 -0
- package/src/plugin/index.ts +13 -1
- package/src/plugin/lifecycle.ts +179 -17
- package/src/plugin/loader.ts +97 -18
- package/src/plugin/shell-hook-env.ts +7 -0
- package/src/plugin/shell-hook.ts +91 -70
- package/src/prompt/coding-agent-doctrine.ts +1 -1
- package/src/provider/side-request-reasoning.ts +5 -1
- package/src/public-runtime.ts +35 -0
- package/src/runtime/query/auto-review/classifier.ts +14 -2
- package/src/runtime/query/auto-review/failure.ts +52 -7
- package/src/runtime/query/review-policy.ts +30 -6
- package/src/runtime/query/turn/check-scope.ts +90 -0
- package/src/runtime/query/turn/outcome-ledger.ts +11 -0
- package/src/skills/loader.ts +26 -9
- package/src/skills/registry.ts +9 -1
- package/src/tools/builtins/job.ts +4 -1
- package/src/tools/builtins/wait-for-job.ts +3 -1
- package/src/types/plugin/index.ts +81 -24
- package/src/types/skills/index.ts +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/skills/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAA;AAE3D,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAA;IAEZ,WAAW,EAAE,MAAM,CAAA;IAEnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,eAAe,CAAA;IAE5B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;IAE9B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IAE3B,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;;OAIG;IACH,MAAM,CAAC,EAAE,eAAe,CAAA;IAExB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE;IAC/C,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,MAAM,CAIT;AAED,4CAA4C;AAC5C,eAAO,MAAM,wBAAwB,EAAE,eAAwB,CAAA;AAE/D,iDAAiD;AACjD,wBAAgB,eAAe,CAAC,KAAK,EAAE;IAAE,QAAQ,EAAE,aAAa,CAAA;CAAE,GAAG,eAAe,CAEnF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC5B,KAAK,EAAE;IAAE,QAAQ,EAAE,aAAa,CAAA;CAAE,EAClC,QAAQ,EAAE,OAAO,GAAG,UAAU,GAC5B,OAAO,CAGT;AAED,MAAM,WAAW,KAAK;IACrB,QAAQ,EAAE,aAAa,CAAA;IAEvB,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,OAAO,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/skills/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAA;AAE3D,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAA;IAEZ,WAAW,EAAE,MAAM,CAAA;IAEnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,eAAe,CAAA;IAE5B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;IAE9B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IAE3B,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;;OAIG;IACH,MAAM,CAAC,EAAE,eAAe,CAAA;IAExB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE;IAC/C,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,MAAM,CAIT;AAED,4CAA4C;AAC5C,eAAO,MAAM,wBAAwB,EAAE,eAAwB,CAAA;AAE/D,iDAAiD;AACjD,wBAAgB,eAAe,CAAC,KAAK,EAAE;IAAE,QAAQ,EAAE,aAAa,CAAA;CAAE,GAAG,eAAe,CAEnF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC5B,KAAK,EAAE;IAAE,QAAQ,EAAE,aAAa,CAAA;CAAE,EAClC,QAAQ,EAAE,OAAO,GAAG,UAAU,GAC5B,OAAO,CAGT;AAED,MAAM,WAAW,KAAK;IACrB,QAAQ,EAAE,aAAa,CAAA;IAEvB,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,OAAO,EAAE,MAAM,CAAA;IAEf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEjE,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,KAAK,CAAA;IACZ,eAAe,EAAE,oBAAoB,CAAA;IAErC,aAAa,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,UAAU;IAC1B,SAAS,EAAE,KAAK,EAAE,CAAA;IAElB,GAAG,EAAE,KAAK,EAAE,CAAA;IAEZ,QAAQ,EAAE,KAAK,EAAE,CAAA;CACjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@namzu/sdk",
|
|
3
|
-
"version": "69.
|
|
3
|
+
"version": "69.4.0",
|
|
4
4
|
"description": "Open-source AI kernel for TypeScript: runs an agent the way an operating system runs a process, with an identity and a budget, scheduled tool calls and checkpointed turns.",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"engines": {
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@jitl/quickjs-wasmfile-release-sync": "0.32.0",
|
|
89
|
+
"acorn": "8.14.0",
|
|
89
90
|
"brace-expansion": "^2.1.7",
|
|
90
91
|
"diff": "9.0.0",
|
|
91
92
|
"fast-png": "^8.0.0",
|
|
@@ -299,7 +299,9 @@ function looksLikeNetworkPath(value: string): boolean {
|
|
|
299
299
|
function isDynamic(word: ShellWord): boolean {
|
|
300
300
|
// `expands` is false for a single-quoted `$`, which is only text.
|
|
301
301
|
if (word.substitutes || (word.expands && /[$`]/.test(word.value))) return true
|
|
302
|
-
|
|
302
|
+
// A brace list inside quotes is text: `echo '{a,b}'`.
|
|
303
|
+
if (/\{[^{}]*(?:,|\.\.)[^{}]*\}/.test(word.text.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g, '')))
|
|
304
|
+
return true
|
|
303
305
|
// `~user` expands to another account's home; `~` and `~/x` are this one's.
|
|
304
306
|
return /^~(?!\/|$)/.test(word.text)
|
|
305
307
|
}
|
|
@@ -319,6 +321,18 @@ function valueFits(value: string, kind: 'none' | 'string' | 'number'): boolean {
|
|
|
319
321
|
return kind === 'string'
|
|
320
322
|
}
|
|
321
323
|
|
|
324
|
+
/**
|
|
325
|
+
* A path that reads a process's environment (`/proc/<pid>/environ`, or a
|
|
326
|
+
* glob under `/proc` that can reach it). `env` and `printenv` are not
|
|
327
|
+
* read-only here, so neither is reading the same bytes through a file.
|
|
328
|
+
*/
|
|
329
|
+
function namesProcessEnvironment(word: ShellWord | string): boolean {
|
|
330
|
+
const value = typeof word === 'string' ? word : word.value
|
|
331
|
+
if (/(?:^|\/)environ$/.test(value)) return true
|
|
332
|
+
const text = typeof word === 'string' ? word : word.text
|
|
333
|
+
return /(?:^|\/)proc\//.test(value) && hasUnquotedGlob(text)
|
|
334
|
+
}
|
|
335
|
+
|
|
322
336
|
/** A flag's value that is dynamic or names a network path. */
|
|
323
337
|
function dangerousValue(value: string): boolean {
|
|
324
338
|
return /[$`]/.test(value) || looksLikeNetworkPath(value)
|
|
@@ -651,7 +665,19 @@ function dockerIsReadOnly(args: readonly string[]): boolean {
|
|
|
651
665
|
}
|
|
652
666
|
|
|
653
667
|
/** Whether one simple command, as its argument vector, is on the list. */
|
|
654
|
-
|
|
668
|
+
/** Options that go before a git subcommand and change nothing about what it reads. */
|
|
669
|
+
const GIT_NEUTRAL_GLOBALS: ReadonlySet<string> = new Set(['--no-optional-locks', '--no-pager'])
|
|
670
|
+
|
|
671
|
+
function commandIsReadOnly(vector: readonly string[], text: string): boolean {
|
|
672
|
+
// `git --no-optional-locks status`: the option keeps git from taking the
|
|
673
|
+
// index lock for an opportunistic refresh, so it only makes a read gentler.
|
|
674
|
+
let argv = vector
|
|
675
|
+
if (argv[0] === 'git' && argv[1] !== undefined && GIT_NEUTRAL_GLOBALS.has(argv[1])) {
|
|
676
|
+
argv = ['git', ...argv.slice(2)]
|
|
677
|
+
while (argv[1] !== undefined && GIT_NEUTRAL_GLOBALS.has(argv[1])) {
|
|
678
|
+
argv = ['git', ...argv.slice(2)]
|
|
679
|
+
}
|
|
680
|
+
}
|
|
655
681
|
const [head, ...rest] = argv
|
|
656
682
|
if (head === undefined) return false
|
|
657
683
|
if (ANY_ARGUMENTS.has(head)) return true
|
|
@@ -741,6 +767,7 @@ function redirectionsAreHarmless(
|
|
|
741
767
|
}
|
|
742
768
|
if (operator === '<') {
|
|
743
769
|
if (looksLikeNetworkPath(value)) return false
|
|
770
|
+
if (namesProcessEnvironment(target)) return false
|
|
744
771
|
if (/^~(?!\/|$)/.test(target.text)) return false
|
|
745
772
|
continue
|
|
746
773
|
}
|
|
@@ -794,6 +821,7 @@ export function isReadOnlyCommandLine(line: string, dialect: ShellDialect = 'bas
|
|
|
794
821
|
const glob = words.some((word) => word.expands && hasUnquotedGlob(word.text))
|
|
795
822
|
if (glob && !GLOB_OK.has(head.value)) return false
|
|
796
823
|
if (words.some((word) => looksLikeNetworkPath(word.value))) return false
|
|
824
|
+
if (words.some(namesProcessEnvironment)) return false
|
|
797
825
|
|
|
798
826
|
const argv = words.map((word) => word.value)
|
|
799
827
|
if (!commandIsReadOnly(argv, command.text)) return false
|
|
@@ -35,6 +35,15 @@ export const MAX_PERSONAS_PER_PLUGIN = 5
|
|
|
35
35
|
export const MAX_COMMAND_DIRS_PER_PLUGIN = 10
|
|
36
36
|
export const MAX_AGENT_DIRS_PER_PLUGIN = 10
|
|
37
37
|
|
|
38
|
+
/** Limits for a plugin read in the common plugin layout, which ships larger plugins. */
|
|
39
|
+
export const COMMON_LAYOUT_MAX_MCP_SERVERS = 16
|
|
40
|
+
export const COMMON_LAYOUT_MAX_SKILLS = 64
|
|
41
|
+
export const COMMON_LAYOUT_MAX_COMMANDS = 64
|
|
42
|
+
export const COMMON_LAYOUT_MAX_AGENTS = 64
|
|
43
|
+
/** A plugin folder over either of these is refused. */
|
|
44
|
+
export const COMMON_LAYOUT_MAX_FILES = 20_000
|
|
45
|
+
export const COMMON_LAYOUT_MAX_BYTES = 256 * 1024 * 1024
|
|
46
|
+
|
|
38
47
|
/** Hook execution */
|
|
39
48
|
export const HOOK_TIMEOUT_MS = 600_000
|
|
40
49
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export {
|
|
2
|
+
findCommonLayoutRoot,
|
|
3
|
+
MAX_LAYOUT_MANIFEST_BYTES,
|
|
4
|
+
readCommonLayout,
|
|
5
|
+
} from './read.js'
|
|
6
|
+
export {
|
|
7
|
+
expandPluginPaths,
|
|
8
|
+
expandPluginRootText,
|
|
9
|
+
PLUGIN_PATH_VARIABLES,
|
|
10
|
+
} from './paths.js'
|
|
11
|
+
export type { ExpandedPaths, PluginPathValues } from './paths.js'
|
|
12
|
+
export type {
|
|
13
|
+
CommonLayoutOptions,
|
|
14
|
+
CommonLayoutRead,
|
|
15
|
+
CommonLayoutSource,
|
|
16
|
+
LayoutFinding,
|
|
17
|
+
LayoutFindingLevel,
|
|
18
|
+
LayoutSetupServer,
|
|
19
|
+
} from './types.js'
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { isAbsolute } from 'node:path'
|
|
2
|
+
import type {
|
|
3
|
+
PluginMCPServerConfig,
|
|
4
|
+
PluginRemoteMCPServerConfig,
|
|
5
|
+
} from '../../types/plugin/index.js'
|
|
6
|
+
import { COMMON_USER_CONFIG_PREFIX } from '../common-layout-names.js'
|
|
7
|
+
import { type PluginPathValues, expandPluginPaths } from './paths.js'
|
|
8
|
+
import type { LayoutFinding, LayoutSetupServer } from './types.js'
|
|
9
|
+
|
|
10
|
+
/** One servers map and the file (or manifest) it was read from. */
|
|
11
|
+
export interface McpSource {
|
|
12
|
+
readonly origin: string
|
|
13
|
+
readonly map: Readonly<Record<string, unknown>>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface McpReadResult {
|
|
17
|
+
readonly local: readonly PluginMCPServerConfig[]
|
|
18
|
+
readonly remote: readonly PluginRemoteMCPServerConfig[]
|
|
19
|
+
readonly findings: readonly LayoutFinding[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const SERVER_NAME = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/
|
|
23
|
+
const KNOWN_KEYS = new Set(['command', 'args', 'env', 'type', 'url', 'headers', 'connectTimeoutMs'])
|
|
24
|
+
const REMOTE_TYPES = new Set(['http', 'sse', 'streamable-http'])
|
|
25
|
+
|
|
26
|
+
function isMapping(value: unknown): value is Record<string, unknown> {
|
|
27
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The servers of one parsed file or inline value: `{ "mcpServers": { name: spec } }`
|
|
32
|
+
* or the flat `{ name: spec }`.
|
|
33
|
+
*/
|
|
34
|
+
export function serversOf(value: unknown): Record<string, unknown> | undefined {
|
|
35
|
+
if (!isMapping(value)) return undefined
|
|
36
|
+
if (isMapping(value.mcpServers)) return value.mcpServers
|
|
37
|
+
return value
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface Expanded {
|
|
41
|
+
readonly text: string
|
|
42
|
+
readonly needs: readonly string[]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
class Reader {
|
|
46
|
+
readonly findings: LayoutFinding[] = []
|
|
47
|
+
readonly local: PluginMCPServerConfig[] = []
|
|
48
|
+
readonly remote: PluginRemoteMCPServerConfig[] = []
|
|
49
|
+
private readonly seen = new Set<string>()
|
|
50
|
+
|
|
51
|
+
constructor(
|
|
52
|
+
private readonly values: PluginPathValues,
|
|
53
|
+
private readonly environment: Readonly<Record<string, string | undefined>>,
|
|
54
|
+
) {}
|
|
55
|
+
|
|
56
|
+
add(finding: LayoutFinding): void {
|
|
57
|
+
this.findings.push(finding)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Path names, then (only in an `env` value) bare environment references; the rest is said. */
|
|
61
|
+
private expand(
|
|
62
|
+
text: string,
|
|
63
|
+
field: string,
|
|
64
|
+
name: string,
|
|
65
|
+
mode: 'env' | 'keep' | 'none',
|
|
66
|
+
): Expanded {
|
|
67
|
+
const needs: string[] = []
|
|
68
|
+
let expanded: string
|
|
69
|
+
try {
|
|
70
|
+
const result = expandPluginPaths(text, this.values)
|
|
71
|
+
expanded = result.text
|
|
72
|
+
for (const unresolved of result.unresolved) {
|
|
73
|
+
needs.push(`\${${unresolved}} has no folder here (${field})`)
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
needs.push(error instanceof Error ? error.message : String(error))
|
|
77
|
+
expanded = text
|
|
78
|
+
}
|
|
79
|
+
expanded = expanded.replace(/\$\{([^}]*)\}/g, (whole: string, inner: string) => {
|
|
80
|
+
if (inner.startsWith(COMMON_USER_CONFIG_PREFIX)) {
|
|
81
|
+
needs.push(`${whole} is a saved option, which is not supported yet (${field})`)
|
|
82
|
+
return whole
|
|
83
|
+
}
|
|
84
|
+
if ((mode === 'env' || mode === 'keep') && /^[A-Za-z_][A-Za-z0-9_]*$/.test(inner)) {
|
|
85
|
+
const value = this.environment[inner]
|
|
86
|
+
if (value === undefined || value === '') {
|
|
87
|
+
needs.push(`${inner} is not set`)
|
|
88
|
+
return whole
|
|
89
|
+
}
|
|
90
|
+
// A header keeps its reference as written: the value is read when it connects.
|
|
91
|
+
return mode === 'keep' ? whole : value
|
|
92
|
+
}
|
|
93
|
+
needs.push(`${whole} is not expanded in ${field}`)
|
|
94
|
+
return whole
|
|
95
|
+
})
|
|
96
|
+
const bare = expanded.replace(/\$\{[^}]*\}/g, '')
|
|
97
|
+
if (/\$[A-Za-z_]|`|%[A-Za-z_][A-Za-z0-9_]*%/.test(bare)) {
|
|
98
|
+
this.add({
|
|
99
|
+
level: 'ignored',
|
|
100
|
+
code: 'mcp-text-left-as-is',
|
|
101
|
+
field: `mcpServers.${name}.${field}`,
|
|
102
|
+
message: `${name}: ${field} holds a $-name, backtick or %NAME% that is left as written; no shell reads it.`,
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
return { text: expanded, needs }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private refuse(name: string, code: string, message: string): void {
|
|
109
|
+
this.add({ level: 'refused', code, field: `mcpServers.${name}`, message })
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private needsSetup(
|
|
113
|
+
name: string,
|
|
114
|
+
needs: readonly string[],
|
|
115
|
+
server?: Omit<LayoutSetupServer, 'name'>,
|
|
116
|
+
): void {
|
|
117
|
+
this.add({
|
|
118
|
+
...(server !== undefined ? { server: { name, ...server } } : {}),
|
|
119
|
+
level: 'notUsed',
|
|
120
|
+
code: 'mcp-needs-setup',
|
|
121
|
+
field: `mcpServers.${name}`,
|
|
122
|
+
message: `${name} needs setup: ${needs.join('; ')}. It is not started.`,
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
readSource(source: McpSource): void {
|
|
127
|
+
for (const [name, spec] of Object.entries(source.map)) {
|
|
128
|
+
if (this.seen.has(name)) {
|
|
129
|
+
this.add({
|
|
130
|
+
level: 'ignored',
|
|
131
|
+
code: 'mcp-server-duplicate',
|
|
132
|
+
field: `mcpServers.${name}`,
|
|
133
|
+
message: `${name} is named twice; the first one in ${source.origin} order is kept.`,
|
|
134
|
+
})
|
|
135
|
+
continue
|
|
136
|
+
}
|
|
137
|
+
this.seen.add(name)
|
|
138
|
+
this.readOne(name, spec)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private readOne(name: string, spec: unknown): void {
|
|
143
|
+
if (!SERVER_NAME.test(name)) {
|
|
144
|
+
this.refuse(name, 'mcp-name-invalid', `"${name}" is not a usable server name.`)
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
if (!isMapping(spec)) {
|
|
148
|
+
this.add({
|
|
149
|
+
level: 'ignored',
|
|
150
|
+
code: 'mcp-server-empty',
|
|
151
|
+
field: `mcpServers.${name}`,
|
|
152
|
+
message: `${name} has no settings.`,
|
|
153
|
+
})
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
for (const key of Object.keys(spec)) {
|
|
157
|
+
if (!KNOWN_KEYS.has(key)) {
|
|
158
|
+
this.add({
|
|
159
|
+
level: 'ignored',
|
|
160
|
+
code: 'mcp-key-ignored',
|
|
161
|
+
field: `mcpServers.${name}.${key}`,
|
|
162
|
+
message: `${name}: "${key}" is not read.`,
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const hasCommand = typeof spec.command === 'string' && spec.command.length > 0
|
|
167
|
+
const hasUrl = typeof spec.url === 'string' && spec.url.length > 0
|
|
168
|
+
const type = typeof spec.type === 'string' ? spec.type : undefined
|
|
169
|
+
if (hasCommand && hasUrl) {
|
|
170
|
+
this.refuse(name, 'mcp-server-both', `${name} names both a command and an address; use one.`)
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
if (!hasCommand && !hasUrl) {
|
|
174
|
+
this.add({
|
|
175
|
+
level: 'ignored',
|
|
176
|
+
code: 'mcp-server-empty',
|
|
177
|
+
field: `mcpServers.${name}`,
|
|
178
|
+
message: `${name} names neither a command nor an address.`,
|
|
179
|
+
})
|
|
180
|
+
return
|
|
181
|
+
}
|
|
182
|
+
if (hasUrl) {
|
|
183
|
+
if (type !== undefined && !REMOTE_TYPES.has(type)) {
|
|
184
|
+
this.refuse(name, 'mcp-type-unsupported', `${name}: the type "${type}" is not supported.`)
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
this.readRemote(name, spec, type)
|
|
188
|
+
return
|
|
189
|
+
}
|
|
190
|
+
if (type !== undefined && type !== 'stdio') {
|
|
191
|
+
this.refuse(name, 'mcp-type-unsupported', `${name}: the type "${type}" is not supported.`)
|
|
192
|
+
return
|
|
193
|
+
}
|
|
194
|
+
this.readLocal(name, spec)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private readLocal(name: string, spec: Record<string, unknown>): void {
|
|
198
|
+
const needs: string[] = []
|
|
199
|
+
const command = this.expand(spec.command as string, 'command', name, 'none')
|
|
200
|
+
needs.push(...command.needs)
|
|
201
|
+
const looksRelative =
|
|
202
|
+
/[\\/]/.test(command.text) && !isAbsolute(command.text) && !/^[A-Za-z]:/.test(command.text)
|
|
203
|
+
if (looksRelative && command.text.split(/[\\/]/).includes('..')) {
|
|
204
|
+
this.refuse(name, 'mcp-command-escapes', `${name}: the command leaves the plugin with "..".`)
|
|
205
|
+
return
|
|
206
|
+
}
|
|
207
|
+
let args: string[] | undefined
|
|
208
|
+
if (spec.args !== undefined) {
|
|
209
|
+
if (!Array.isArray(spec.args) || !spec.args.every((arg) => typeof arg === 'string')) {
|
|
210
|
+
this.refuse(name, 'mcp-args-invalid', `${name}: "args" must be a list of text.`)
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
args = (spec.args as string[]).map((arg) => {
|
|
214
|
+
const expanded = this.expand(arg, 'args', name, 'none')
|
|
215
|
+
needs.push(...expanded.needs)
|
|
216
|
+
return expanded.text
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
let env: Record<string, string> | undefined
|
|
220
|
+
if (spec.env !== undefined) {
|
|
221
|
+
if (
|
|
222
|
+
!isMapping(spec.env) ||
|
|
223
|
+
!Object.values(spec.env).every((value) => typeof value === 'string')
|
|
224
|
+
) {
|
|
225
|
+
this.refuse(name, 'mcp-env-invalid', `${name}: "env" must map names to text.`)
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
env = {}
|
|
229
|
+
for (const [key, value] of Object.entries(spec.env as Record<string, string>)) {
|
|
230
|
+
const expanded = this.expand(value, `env.${key}`, name, 'env')
|
|
231
|
+
needs.push(...expanded.needs)
|
|
232
|
+
env[key] = expanded.text
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
let connectTimeoutMs: number | undefined
|
|
236
|
+
if (typeof spec.connectTimeoutMs === 'number') {
|
|
237
|
+
if (
|
|
238
|
+
!Number.isInteger(spec.connectTimeoutMs) ||
|
|
239
|
+
spec.connectTimeoutMs <= 0 ||
|
|
240
|
+
spec.connectTimeoutMs > 3_600_000
|
|
241
|
+
) {
|
|
242
|
+
this.refuse(name, 'mcp-timeout-invalid', `${name}: "connectTimeoutMs" is out of range.`)
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
connectTimeoutMs = spec.connectTimeoutMs
|
|
246
|
+
}
|
|
247
|
+
if (needs.length > 0) {
|
|
248
|
+
this.needsSetup(name, [...new Set(needs)], {
|
|
249
|
+
kind: 'local',
|
|
250
|
+
target: spec.command as string,
|
|
251
|
+
args: Array.isArray(spec.args) ? (spec.args as string[]) : [],
|
|
252
|
+
values: isMapping(spec.env) ? (spec.env as Record<string, string>) : {},
|
|
253
|
+
})
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
this.local.push({
|
|
257
|
+
name,
|
|
258
|
+
command: command.text,
|
|
259
|
+
...(args !== undefined ? { args } : {}),
|
|
260
|
+
...(env !== undefined ? { env } : {}),
|
|
261
|
+
...(connectTimeoutMs !== undefined ? { connectTimeoutMs } : {}),
|
|
262
|
+
})
|
|
263
|
+
this.add({
|
|
264
|
+
level: 'used',
|
|
265
|
+
code: 'mcp-server-local',
|
|
266
|
+
field: `mcpServers.${name}`,
|
|
267
|
+
message: `${name} starts as a local program while the plugin is on.`,
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private readRemote(name: string, spec: Record<string, unknown>, type: string | undefined): void {
|
|
272
|
+
const url = this.expand(spec.url as string, 'url', name, 'none')
|
|
273
|
+
const asWritten = (): Omit<LayoutSetupServer, 'name'> => ({
|
|
274
|
+
kind: 'remote',
|
|
275
|
+
target: spec.url as string,
|
|
276
|
+
transport: type === 'sse' ? 'sse' : 'http',
|
|
277
|
+
values:
|
|
278
|
+
isMapping(spec.headers) &&
|
|
279
|
+
Object.values(spec.headers).every((value) => typeof value === 'string')
|
|
280
|
+
? (spec.headers as Record<string, string>)
|
|
281
|
+
: {},
|
|
282
|
+
})
|
|
283
|
+
if (url.needs.length > 0) {
|
|
284
|
+
this.needsSetup(name, url.needs, asWritten())
|
|
285
|
+
return
|
|
286
|
+
}
|
|
287
|
+
let parsed: URL
|
|
288
|
+
try {
|
|
289
|
+
parsed = new URL(url.text)
|
|
290
|
+
} catch {
|
|
291
|
+
this.refuse(name, 'mcp-url-invalid', `${name}: the address is not a valid URL.`)
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
|
|
295
|
+
this.refuse(
|
|
296
|
+
name,
|
|
297
|
+
'mcp-url-invalid',
|
|
298
|
+
`${name}: the address must start with https:// or http://.`,
|
|
299
|
+
)
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
if (parsed.username !== '' || parsed.password !== '') {
|
|
303
|
+
this.refuse(
|
|
304
|
+
name,
|
|
305
|
+
'mcp-url-invalid',
|
|
306
|
+
`${name}: the address must not hold a user name or password.`,
|
|
307
|
+
)
|
|
308
|
+
return
|
|
309
|
+
}
|
|
310
|
+
let headers: Record<string, string> | undefined
|
|
311
|
+
if (spec.headers !== undefined) {
|
|
312
|
+
if (
|
|
313
|
+
!isMapping(spec.headers) ||
|
|
314
|
+
!Object.values(spec.headers).every((value) => typeof value === 'string')
|
|
315
|
+
) {
|
|
316
|
+
this.refuse(name, 'mcp-headers-invalid', `${name}: "headers" must map names to text.`)
|
|
317
|
+
return
|
|
318
|
+
}
|
|
319
|
+
headers = {}
|
|
320
|
+
const needs: string[] = []
|
|
321
|
+
for (const [key, value] of Object.entries(spec.headers as Record<string, string>)) {
|
|
322
|
+
// A `${VAR}` stays as written: the host that connects reads the variable
|
|
323
|
+
// then, and the plugin file never holds the value.
|
|
324
|
+
const expanded = this.expand(value, `headers.${key}`, name, 'keep')
|
|
325
|
+
needs.push(...expanded.needs)
|
|
326
|
+
headers[key] = expanded.text
|
|
327
|
+
}
|
|
328
|
+
if (needs.length > 0) {
|
|
329
|
+
this.needsSetup(name, [...new Set(needs)], asWritten())
|
|
330
|
+
return
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const transport = type === 'sse' ? 'sse' : 'http'
|
|
334
|
+
this.remote.push({
|
|
335
|
+
name,
|
|
336
|
+
url: url.text,
|
|
337
|
+
transport,
|
|
338
|
+
...(headers !== undefined ? { headers } : {}),
|
|
339
|
+
})
|
|
340
|
+
this.add({
|
|
341
|
+
level: 'notUsed',
|
|
342
|
+
code: 'mcp-server-remote',
|
|
343
|
+
field: `mcpServers.${name}`,
|
|
344
|
+
message: `${name} is a remote server at ${parsed.origin}${parsed.pathname === '/' ? '' : parsed.pathname}. It connects only after you approve it.`,
|
|
345
|
+
})
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** Read every server of every source, applying the path and environment rules. */
|
|
350
|
+
export function readMcpSources(
|
|
351
|
+
sources: readonly McpSource[],
|
|
352
|
+
values: PluginPathValues,
|
|
353
|
+
environment: Readonly<Record<string, string | undefined>>,
|
|
354
|
+
): McpReadResult {
|
|
355
|
+
const reader = new Reader(values, environment)
|
|
356
|
+
for (const source of sources) reader.readSource(source)
|
|
357
|
+
return {
|
|
358
|
+
local: reader.local,
|
|
359
|
+
remote: reader.remote,
|
|
360
|
+
findings: reader.findings,
|
|
361
|
+
}
|
|
362
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMMON_DATA_VARIABLE,
|
|
3
|
+
COMMON_PROJECT_VARIABLE,
|
|
4
|
+
COMMON_ROOT_VARIABLE,
|
|
5
|
+
NAMZU_DATA_VARIABLE,
|
|
6
|
+
NAMZU_PROJECT_VARIABLE,
|
|
7
|
+
NAMZU_ROOT_VARIABLE,
|
|
8
|
+
} from '../common-layout-names.js'
|
|
9
|
+
|
|
10
|
+
/** The folders the six path names stand for. A name with no folder here is left as written. */
|
|
11
|
+
export interface PluginPathValues {
|
|
12
|
+
/** The plugin's own folder. */
|
|
13
|
+
readonly root: string
|
|
14
|
+
/** The folder kept for the plugin's data. */
|
|
15
|
+
readonly data?: string | undefined
|
|
16
|
+
/** The folder the session was started for. */
|
|
17
|
+
readonly project?: string | undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The six names {@link expandPluginPaths} replaces, and nothing else. */
|
|
21
|
+
export const PLUGIN_PATH_VARIABLES: readonly string[] = [
|
|
22
|
+
COMMON_ROOT_VARIABLE,
|
|
23
|
+
NAMZU_ROOT_VARIABLE,
|
|
24
|
+
COMMON_DATA_VARIABLE,
|
|
25
|
+
NAMZU_DATA_VARIABLE,
|
|
26
|
+
COMMON_PROJECT_VARIABLE,
|
|
27
|
+
NAMZU_PROJECT_VARIABLE,
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
export interface ExpandedPaths {
|
|
31
|
+
readonly text: string
|
|
32
|
+
/** Path names that had no folder to stand for, in order of appearance. */
|
|
33
|
+
readonly unresolved: readonly string[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function folderFor(name: string, values: PluginPathValues): string | undefined {
|
|
37
|
+
if (name === COMMON_ROOT_VARIABLE || name === NAMZU_ROOT_VARIABLE) return values.root
|
|
38
|
+
if (name === COMMON_DATA_VARIABLE || name === NAMZU_DATA_VARIABLE) return values.data
|
|
39
|
+
if (name === COMMON_PROJECT_VARIABLE || name === NAMZU_PROJECT_VARIABLE) return values.project
|
|
40
|
+
return undefined
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* `${NAME}` for exactly the six path names becomes the folder. Nothing runs a
|
|
45
|
+
* shell and nothing else is touched: `$NAME`, `${OTHER}` and `${NAME:-x}` are
|
|
46
|
+
* left as written. A folder that is not absolute, or holds a NUL, is refused
|
|
47
|
+
* with a thrown reason, so a substituted value never turns into a relative
|
|
48
|
+
* or truncated path.
|
|
49
|
+
*/
|
|
50
|
+
export function expandPluginPaths(text: string, values: PluginPathValues): ExpandedPaths {
|
|
51
|
+
const unresolved: string[] = []
|
|
52
|
+
const out = text.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (whole: string, name: string) => {
|
|
53
|
+
if (!PLUGIN_PATH_VARIABLES.includes(name)) return whole
|
|
54
|
+
const folder = folderFor(name, values)
|
|
55
|
+
if (folder === undefined) {
|
|
56
|
+
unresolved.push(name)
|
|
57
|
+
return whole
|
|
58
|
+
}
|
|
59
|
+
if (folder.includes('\0') || !/^([A-Za-z]:[\\/]|[\\/])/.test(folder)) {
|
|
60
|
+
throw new Error(`The folder for ${name} must be an absolute path without NUL characters.`)
|
|
61
|
+
}
|
|
62
|
+
return folder
|
|
63
|
+
})
|
|
64
|
+
return { text: out, unresolved }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Only the plugin's own folder: the form skill, command and agent text gets. */
|
|
68
|
+
export function expandPluginRootText(text: string, root: string): string {
|
|
69
|
+
return expandPluginPaths(text, { root }).text
|
|
70
|
+
}
|