@namzu/sdk 69.2.0 → 69.3.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 +14 -0
- 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/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/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/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/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/public-runtime.ts +35 -0
- package/src/skills/loader.ts +26 -9
- package/src/skills/registry.ts +9 -1
- package/src/types/plugin/index.ts +81 -24
- package/src/types/skills/index.ts +7 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { MAX_AGENT_DIRS_PER_PLUGIN, MAX_COMMAND_DIRS_PER_PLUGIN, MAX_CONNECTORS_PER_PLUGIN, MAX_HOOKS_PER_PLUGIN, MAX_MCP_SERVERS_PER_PLUGIN, MAX_PERSONAS_PER_PLUGIN, MAX_SKILLS_PER_PLUGIN, MAX_TOOLS_PER_PLUGIN, PLUGIN_NAME_MAX_LENGTH, } from '../../constants/plugin/index.js';
|
|
2
|
+
import { COMMON_LAYOUT_MAX_AGENTS, COMMON_LAYOUT_MAX_COMMANDS, COMMON_LAYOUT_MAX_MCP_SERVERS, COMMON_LAYOUT_MAX_SKILLS, MAX_AGENT_DIRS_PER_PLUGIN, MAX_COMMAND_DIRS_PER_PLUGIN, MAX_CONNECTORS_PER_PLUGIN, MAX_HOOKS_PER_PLUGIN, MAX_MCP_SERVERS_PER_PLUGIN, MAX_PERSONAS_PER_PLUGIN, MAX_SKILLS_PER_PLUGIN, MAX_TOOLS_PER_PLUGIN, PLUGIN_NAME_MAX_LENGTH, } from '../../constants/plugin/index.js';
|
|
3
3
|
export function assertPluginScope(scope) {
|
|
4
4
|
switch (scope) {
|
|
5
5
|
case 'project':
|
|
@@ -126,12 +126,20 @@ export const PluginMCPServerConfigSchema = z
|
|
|
126
126
|
connectTimeoutMs: z.number().int().positive().max(3_600_000).optional(),
|
|
127
127
|
})
|
|
128
128
|
.strict();
|
|
129
|
+
export const PluginRemoteMCPServerConfigSchema = z
|
|
130
|
+
.object({
|
|
131
|
+
name: z.string().min(1),
|
|
132
|
+
url: z.string().min(1).max(2048),
|
|
133
|
+
transport: z.enum(['http', 'sse']).optional(),
|
|
134
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
135
|
+
})
|
|
136
|
+
.strict();
|
|
129
137
|
/** A folder inside the plugin: relative, no `..` step, no drive or root. */
|
|
130
138
|
const PluginRelativeDirSchema = z
|
|
131
139
|
.string()
|
|
132
140
|
.min(1)
|
|
133
141
|
.refine((value) => !/^([a-zA-Z]:|[\\/])/.test(value) && !value.split(/[\\/]/).some((part) => part === '..'), 'must be a folder inside the plugin, with no ".." and no absolute path');
|
|
134
|
-
|
|
142
|
+
const makePluginManifestSchema = (limits) => z.object({
|
|
135
143
|
name: z
|
|
136
144
|
.string()
|
|
137
145
|
.min(1)
|
|
@@ -142,17 +150,31 @@ export const PluginManifestSchema = z.object({
|
|
|
142
150
|
author: z.string().optional(),
|
|
143
151
|
instructions: z.string().min(1).optional(),
|
|
144
152
|
tools: z.array(z.string()).max(MAX_TOOLS_PER_PLUGIN).optional(),
|
|
145
|
-
skills: z.array(z.string()).max(
|
|
153
|
+
skills: z.array(z.string()).max(limits.skills).optional(),
|
|
146
154
|
hooks: z.array(z.string()).max(MAX_HOOKS_PER_PLUGIN).optional(),
|
|
147
155
|
hookEntries: z.record(z.string(), z.unknown()).optional(),
|
|
148
|
-
mcpServers: z.array(PluginMCPServerConfigSchema).max(
|
|
156
|
+
mcpServers: z.array(PluginMCPServerConfigSchema).max(limits.mcpServers).optional(),
|
|
157
|
+
remoteMcpServers: z.array(PluginRemoteMCPServerConfigSchema).max(limits.mcpServers).optional(),
|
|
149
158
|
connectors: z.array(z.string()).max(MAX_CONNECTORS_PER_PLUGIN).optional(),
|
|
150
159
|
personas: z.array(z.string()).max(MAX_PERSONAS_PER_PLUGIN).optional(),
|
|
151
|
-
commands: z.array(PluginRelativeDirSchema).max(
|
|
152
|
-
agents: z.array(PluginRelativeDirSchema).max(
|
|
160
|
+
commands: z.array(PluginRelativeDirSchema).max(limits.commands).optional(),
|
|
161
|
+
agents: z.array(PluginRelativeDirSchema).max(limits.agents).optional(),
|
|
153
162
|
/** Operating systems the plugin supports, as `process.platform` names them. Absent means all. */
|
|
154
163
|
platforms: z.array(z.string().min(1)).max(16).optional(),
|
|
155
164
|
/** Runtime versions the plugin supports. Absent means any. */
|
|
156
165
|
engines: z.object({ namzu: z.string().min(1).max(200).optional() }).optional(),
|
|
157
166
|
});
|
|
167
|
+
export const PluginManifestSchema = makePluginManifestSchema({
|
|
168
|
+
mcpServers: MAX_MCP_SERVERS_PER_PLUGIN,
|
|
169
|
+
skills: MAX_SKILLS_PER_PLUGIN,
|
|
170
|
+
commands: MAX_COMMAND_DIRS_PER_PLUGIN,
|
|
171
|
+
agents: MAX_AGENT_DIRS_PER_PLUGIN,
|
|
172
|
+
});
|
|
173
|
+
/** The same shape with the larger limits a plugin in the common plugin layout may use. */
|
|
174
|
+
export const CommonLayoutManifestSchema = makePluginManifestSchema({
|
|
175
|
+
mcpServers: COMMON_LAYOUT_MAX_MCP_SERVERS,
|
|
176
|
+
skills: COMMON_LAYOUT_MAX_SKILLS,
|
|
177
|
+
commands: COMMON_LAYOUT_MAX_COMMANDS,
|
|
178
|
+
agents: COMMON_LAYOUT_MAX_AGENTS,
|
|
179
|
+
});
|
|
158
180
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACN,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,GACtB,MAAM,iCAAiC,CAAA;AAgBxC,MAAM,UAAU,iBAAiB,CAAC,KAAkB;IACnD,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,MAAM;YACV,OAAM;QACP,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,WAAW,GAAU,KAAK,CAAA;YAChC,MAAM,IAAI,KAAK,CAAC,wBAAwB,WAAW,EAAE,CAAC,CAAA;QACvD,CAAC;IACF,CAAC;AACF,CAAC;AAQD,MAAM,UAAU,kBAAkB,CAAC,MAAoB;IACtD,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,WA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;YACb,MAAK;QACN,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,WAAW,GAAU,MAAM,CAAA;YACjC,MAAM,IAAI,KAAK,CAAC,oCAAoC,WAAW,EAAE,CAAC,CAAA;QACnE,CAAC;IACF,CAAC;AACF,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACN,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAC7B,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,GACtB,MAAM,iCAAiC,CAAA;AAgBxC,MAAM,UAAU,iBAAiB,CAAC,KAAkB;IACnD,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,MAAM;YACV,OAAM;QACP,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,WAAW,GAAU,KAAK,CAAA;YAChC,MAAM,IAAI,KAAK,CAAC,wBAAwB,WAAW,EAAE,CAAC,CAAA;QACvD,CAAC;IACF,CAAC;AACF,CAAC;AAQD,MAAM,UAAU,kBAAkB,CAAC,MAAoB;IACtD,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,WAAW,CAAC;QACjB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,OAAO;YACX,OAAM;QACP,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,WAAW,GAAU,MAAM,CAAA;YACjC,MAAM,IAAI,KAAK,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAA;QACxD,CAAC;IACF,CAAC;AACF,CAAC;AAcD,MAAM,UAAU,4BAA4B,CAAC,IAA4B;IACxE,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,MAAM,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M,EAAE,wBAAwB;IAChC,QAAQ,EAAE,0BAA0B;IACpC,MAAM,EAAE,wBAAwB;CAChC,CAAC,CAAA"}
|
|
@@ -102,6 +102,12 @@ export interface Skill {
|
|
|
102
102
|
metadata: SkillMetadata;
|
|
103
103
|
body?: string;
|
|
104
104
|
dirPath: string;
|
|
105
|
+
/**
|
|
106
|
+
* The folder of the plugin that contributed this skill. Set by the plugin
|
|
107
|
+
* lifecycle; the registry puts it in for `\${NAMZU_PLUGIN_ROOT}` (and the
|
|
108
|
+
* common layout's spelling of it) when the body is read.
|
|
109
|
+
*/
|
|
110
|
+
pluginRoot?: string;
|
|
105
111
|
}
|
|
106
112
|
export type SkillDisclosureLevel = 'metadata' | 'full' | 'assets';
|
|
107
113
|
export interface SkillLoadResult {
|
|
@@ -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,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AAU,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.3.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",
|
|
@@ -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
|
+
}
|