@kwonye/mcpx 0.1.105 → 0.1.106

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.
Files changed (75) hide show
  1. package/dist/adapters/codex.d.ts +2 -0
  2. package/dist/adapters/index.d.ts +2 -1
  3. package/dist/adapters/json.d.ts +26 -0
  4. package/dist/adapters/pi.d.ts +9 -0
  5. package/dist/chunk-0xt563m1.js +126 -0
  6. package/dist/{chunk-btbww96n.js → chunk-1mrkz29t.js} +69 -56
  7. package/dist/{chunk-6mxr34tc.js → chunk-1v66g9d6.js} +4 -3
  8. package/dist/chunk-1yq3yb66.js +126 -0
  9. package/dist/chunk-27mq4agf.js +33 -0
  10. package/dist/{chunk-t4hqf6yh.js → chunk-4aafp444.js} +8136 -8262
  11. package/dist/chunk-4xym942z.js +36 -0
  12. package/dist/{chunk-tnhekcpv.js → chunk-56z18csx.js} +1 -1
  13. package/dist/{chunk-bnbz55g6.js → chunk-65kshh9w.js} +1 -1
  14. package/dist/{chunk-xydajvzg.js → chunk-7ky3rsw9.js} +1 -1
  15. package/dist/chunk-7rq88hb3.js +563 -0
  16. package/dist/chunk-8v13hqrp.js +825 -0
  17. package/dist/chunk-a2gen8bn.js +730 -0
  18. package/dist/{chunk-01s7rhx3.js → chunk-brxwa30j.js} +130 -113
  19. package/dist/chunk-chaj8a8b.js +45 -0
  20. package/dist/chunk-e96643mj.js +26 -0
  21. package/dist/{chunk-d2v9rxy0.js → chunk-ew06e41w.js} +12 -6
  22. package/dist/chunk-ezk8txcy.js +23 -0
  23. package/dist/{chunk-4y0t0tfj.js → chunk-grkz21sq.js} +29 -3
  24. package/dist/{chunk-12vgqm89.js → chunk-gvjxpk98.js} +1 -1
  25. package/dist/chunk-h9kp47rp.js +18 -0
  26. package/dist/chunk-hahs24dv.js +127 -0
  27. package/dist/{chunk-y9a1rx7j.js → chunk-jv0s0cp6.js} +5 -3
  28. package/dist/{chunk-enzmq965.js → chunk-n0462d52.js} +1 -1
  29. package/dist/chunk-nh6hhv29.js +138 -0
  30. package/dist/chunk-p7yzyt87.js +19426 -0
  31. package/dist/chunk-q86c5s6r.js +7 -0
  32. package/dist/chunk-qf8bj9y7.js +254 -0
  33. package/dist/chunk-t20f49g3.js +30 -0
  34. package/dist/{chunk-am903qjk.js → chunk-v041118a.js} +11 -5
  35. package/dist/{chunk-91vcwk5m.js → chunk-v14bg5yp.js} +1 -1
  36. package/dist/chunk-wvzap0na.js +18166 -0
  37. package/dist/chunk-wztmp5b4.js +30479 -0
  38. package/dist/chunk-xvqr1q9b.js +14 -0
  39. package/dist/{chunk-h158rkts.js → chunk-yj7mpczw.js} +17 -5
  40. package/dist/chunk-yr0txkw0.js +31 -0
  41. package/dist/cli.js +3879 -1061
  42. package/dist/core/adoption.d.ts +62 -0
  43. package/dist/core/analytics.d.ts +17 -0
  44. package/dist/core/consumers.d.ts +8 -0
  45. package/dist/core/control.d.ts +12 -0
  46. package/dist/core/daemon.d.ts +2 -2
  47. package/dist/core/file-state.d.ts +5 -0
  48. package/dist/core/harnesses.d.ts +25 -0
  49. package/dist/core/index.d.ts +12 -4
  50. package/dist/core/index.js +109 -71
  51. package/dist/core/managed-index-lock.d.ts +1 -1
  52. package/dist/core/management.d.ts +32 -0
  53. package/dist/core/native-document.d.ts +4 -0
  54. package/dist/core/operations.d.ts +52 -0
  55. package/dist/core/plugin-projections.d.ts +1 -0
  56. package/dist/core/runtime-entry.d.ts +6 -0
  57. package/dist/core/runtime-snapshot.d.ts +6 -0
  58. package/dist/core/secret-keychain.d.ts +31 -0
  59. package/dist/core/secrets.d.ts +12 -2
  60. package/dist/core/served-skills.d.ts +62 -0
  61. package/dist/core/status.d.ts +1 -0
  62. package/dist/core/sync-plan.d.ts +14 -0
  63. package/dist/core/sync.d.ts +3 -0
  64. package/dist/core/telemetry.d.ts +2 -2
  65. package/dist/core/tui.d.ts +20 -0
  66. package/dist/core/verify-upstreams.d.ts +4 -0
  67. package/dist/core/work-limiter.d.ts +10 -0
  68. package/dist/gateway/server.d.ts +2 -0
  69. package/dist/types.d.ts +62 -1
  70. package/dist/util/fs.d.ts +2 -0
  71. package/dist/version.d.ts +1 -1
  72. package/package.json +1 -1
  73. package/dist/adapters/opencode.d.ts +0 -11
  74. package/dist/chunk-56whm3hm.js +0 -4055
  75. package/dist/chunk-fw8dyt89.js +0 -344
@@ -0,0 +1,7 @@
1
+ import {
2
+ require_src
3
+ } from "./chunk-56z18csx.js";
4
+ import"./chunk-wj4tjacg.js";
5
+ export default require_src();
6
+
7
+ //# debugId=77E3506C217553FF64756E2164756E21
@@ -0,0 +1,254 @@
1
+ import {
2
+ mutateConfig
3
+ } from "./chunk-hahs24dv.js";
4
+ import {
5
+ listSkills,
6
+ validateSkillId,
7
+ validateSkillPackage
8
+ } from "./chunk-7rq88hb3.js";
9
+ import {
10
+ loadConfig
11
+ } from "./chunk-brxwa30j.js";
12
+ import {
13
+ exports_external
14
+ } from "./chunk-p7yzyt87.js";
15
+ import {
16
+ ensureDir,
17
+ getSkillsDir
18
+ } from "./chunk-grkz21sq.js";
19
+ import {
20
+ __require
21
+ } from "./chunk-wj4tjacg.js";
22
+
23
+ // src/core/share.ts
24
+ import fs from "node:fs";
25
+ import path from "node:path";
26
+ import crypto from "node:crypto";
27
+ var ENVIRONMENT_FILE = "mcpx.environment.json";
28
+ var LOCK_FILE = "mcpx.environment.lock.json";
29
+ var packageEntrySchema = exports_external.object({
30
+ id: exports_external.string().min(1),
31
+ kind: exports_external.enum(["skill", "plugin"]),
32
+ path: exports_external.string().min(1),
33
+ source: exports_external.string().optional()
34
+ });
35
+ var shareServerSchema = exports_external.discriminatedUnion("transport", [
36
+ exports_external.object({ transport: exports_external.literal("http"), url: exports_external.url(), headers: exports_external.record(exports_external.string(), exports_external.string()).optional(), enabled: exports_external.boolean().default(true) }),
37
+ exports_external.object({ transport: exports_external.literal("stdio"), command: exports_external.string().min(1), args: exports_external.array(exports_external.string()).default([]), env: exports_external.record(exports_external.string(), exports_external.string()).optional(), cwd: exports_external.string().optional(), enabled: exports_external.boolean().default(true) })
38
+ ]);
39
+ var environmentSchema = exports_external.object({
40
+ version: exports_external.literal(1),
41
+ generatedBy: exports_external.string().min(1),
42
+ servers: exports_external.record(exports_external.string(), shareServerSchema).default({}),
43
+ skills: exports_external.array(packageEntrySchema).default([]),
44
+ plugins: exports_external.array(packageEntrySchema).default([]),
45
+ clients: exports_external.array(exports_external.string()).default([]),
46
+ inputs: exports_external.array(exports_external.object({ name: exports_external.string(), description: exports_external.string().optional() })).default([])
47
+ });
48
+ var lockSchema = exports_external.object({
49
+ version: exports_external.literal(1),
50
+ mcpxCompatibility: exports_external.string().min(1),
51
+ manifestSha256: exports_external.string().regex(/^[a-f0-9]{64}$/),
52
+ packages: exports_external.record(exports_external.string(), exports_external.object({ sha256: exports_external.string().regex(/^[a-f0-9]{64}$/), revision: exports_external.string().optional() })).default({})
53
+ });
54
+ function sha256File(filePath) {
55
+ return crypto.createHash("sha256").update(fs.readFileSync(filePath)).digest("hex");
56
+ }
57
+ function sha256Tree(root) {
58
+ const hash = crypto.createHash("sha256");
59
+ const visit = (current, relative = "") => {
60
+ const entries = fs.readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
61
+ for (const entry of entries) {
62
+ if (entry.name === ".DS_Store" || entry.name === ".git")
63
+ continue;
64
+ const child = path.join(current, entry.name);
65
+ const childRelative = path.join(relative, entry.name);
66
+ hash.update(childRelative);
67
+ if (entry.isDirectory())
68
+ visit(child, childRelative);
69
+ else if (entry.isFile())
70
+ hash.update(fs.readFileSync(child));
71
+ }
72
+ };
73
+ visit(root);
74
+ return hash.digest("hex");
75
+ }
76
+ function copyDirectory(source, destination) {
77
+ ensureDir(destination);
78
+ fs.cpSync(source, destination, { recursive: true, dereference: true, filter: (sourcePath) => !sourcePath.split(path.sep).includes(".git") && !sourcePath.endsWith(`${path.sep}.DS_Store`) });
79
+ }
80
+ function resolveSharePath(root, relativePath) {
81
+ const resolvedRoot = path.resolve(root);
82
+ const resolved = path.resolve(root, relativePath);
83
+ if (resolved !== resolvedRoot && !resolved.startsWith(resolvedRoot + path.sep))
84
+ throw new Error(`Package path escapes the environment folder: ${relativePath}`);
85
+ return resolved;
86
+ }
87
+ function scrubServer(name, spec, inputs) {
88
+ const result = { transport: spec.transport, enabled: spec.enabled ?? true };
89
+ if (spec.transport === "http") {
90
+ const parsedUrl = new URL(spec.url);
91
+ if (parsedUrl.username || parsedUrl.password || /(?:token|secret|key|password|auth)/i.test(parsedUrl.search)) {
92
+ throw new Error(`Server ${name} URL contains credentials and cannot be shared`);
93
+ }
94
+ result.url = spec.url;
95
+ if (spec.headers) {
96
+ result.headers = Object.fromEntries(Object.entries(spec.headers).map(([key, value]) => {
97
+ if (value.startsWith("secret://"))
98
+ return [key, value];
99
+ const inputName = `server.${name}.header.${key}`;
100
+ inputs.push({ name: inputName, description: `HTTP header ${key} for ${name}` });
101
+ return [key, `{{input:${inputName}}}`];
102
+ }));
103
+ }
104
+ } else {
105
+ if (path.isAbsolute(spec.command))
106
+ throw new Error(`Server ${name} uses an absolute command path and cannot be shared`);
107
+ result.command = spec.command;
108
+ result.args = spec.args ?? [];
109
+ if (spec.cwd) {
110
+ if (path.isAbsolute(spec.cwd))
111
+ throw new Error(`Server ${name} uses an absolute cwd and cannot be shared`);
112
+ result.cwd = spec.cwd;
113
+ }
114
+ if (spec.env) {
115
+ result.env = Object.fromEntries(Object.entries(spec.env).map(([key, value]) => {
116
+ if (value.startsWith("secret://"))
117
+ return [key, value];
118
+ const inputName = `server.${name}.env.${key}`;
119
+ inputs.push({ name: inputName, description: `Environment variable ${key} for ${name}` });
120
+ return [key, `{{input:${inputName}}}`];
121
+ }));
122
+ }
123
+ }
124
+ return result;
125
+ }
126
+ function replaceInputs(value, inputs) {
127
+ if (typeof value === "string") {
128
+ const match = value.match(/^\{\{input:([^}]+)\}\}$/);
129
+ return match ? inputs[match[1]] ?? value : value;
130
+ }
131
+ if (Array.isArray(value))
132
+ return value.map((entry) => replaceInputs(entry, inputs));
133
+ if (value && typeof value === "object")
134
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, replaceInputs(entry, inputs)]));
135
+ return value;
136
+ }
137
+ function exportEnvironment(destination, options = {}) {
138
+ const root = path.resolve(destination);
139
+ ensureDir(root);
140
+ const config = loadConfig();
141
+ const inputs = [];
142
+ const generatedServerNames = new Set(Object.values(config.plugins ?? {}).flatMap((plugin) => plugin.serverNames));
143
+ const servers = Object.fromEntries(Object.entries(config.servers).filter(([name]) => !generatedServerNames.has(name)).map(([name, spec]) => [name, scrubServer(name, spec, inputs)]));
144
+ const packagesDir = path.join(root, "packages");
145
+ ensureDir(packagesDir);
146
+ const selectedSkills = listSkills().filter((skill) => !options.skills || options.skills.includes(skill.id));
147
+ const skills = selectedSkills.map((skill) => {
148
+ const packagePath = path.join(packagesDir, "skills", skill.id);
149
+ ensureDir(path.dirname(packagePath));
150
+ if (skill.root)
151
+ copyDirectory(skill.root, packagePath);
152
+ else {
153
+ ensureDir(packagePath);
154
+ fs.writeFileSync(path.join(packagePath, "SKILL.md"), skill.content, "utf8");
155
+ }
156
+ return { id: skill.id, kind: "skill", path: `packages/skills/${skill.id}`, source: skill.source ?? "authored" };
157
+ });
158
+ const selectedPlugins = Object.values(config.plugins ?? {}).filter((plugin) => !options.plugins || options.plugins.includes(plugin.id) || options.plugins.includes(plugin.name));
159
+ const plugins = selectedPlugins.map((plugin) => {
160
+ const packagePath = path.join(packagesDir, "plugins", plugin.name);
161
+ copyDirectory(plugin.root, packagePath);
162
+ return { id: plugin.name, kind: "plugin", path: `packages/plugins/${plugin.name}`, source: plugin.source };
163
+ });
164
+ const environment = environmentSchema.parse({ version: 1, generatedBy: "mcpx", servers, skills, plugins, clients: Object.keys(config.clients ?? {}), inputs });
165
+ const manifestPath = path.join(root, ENVIRONMENT_FILE);
166
+ fs.writeFileSync(manifestPath, JSON.stringify(environment, null, 2) + `
167
+ `, "utf8");
168
+ const lock = {
169
+ version: 1,
170
+ mcpxCompatibility: "1",
171
+ manifestSha256: sha256File(manifestPath),
172
+ packages: Object.fromEntries([
173
+ ...skills.map((entry) => [`${entry.kind}:${entry.id}`, { sha256: sha256Tree(path.join(root, entry.path)) }]),
174
+ ...plugins.map((entry) => {
175
+ const plugin = selectedPlugins.find((candidate) => candidate.name === entry.id);
176
+ return [`${entry.kind}:${entry.id}`, { sha256: sha256Tree(path.join(root, entry.path)), revision: plugin?.resolvedSha }];
177
+ })
178
+ ])
179
+ };
180
+ fs.writeFileSync(path.join(root, LOCK_FILE), JSON.stringify(lock, null, 2) + `
181
+ `, "utf8");
182
+ return { environment, lock };
183
+ }
184
+ async function importEnvironment(sourceDirectory, options = {}) {
185
+ const root = path.resolve(sourceDirectory);
186
+ const manifestPath = path.join(root, ENVIRONMENT_FILE);
187
+ const lockPath = path.join(root, LOCK_FILE);
188
+ const environment = environmentSchema.parse(JSON.parse(fs.readFileSync(manifestPath, "utf8")));
189
+ const lock = lockSchema.parse(JSON.parse(fs.readFileSync(lockPath, "utf8")));
190
+ if (options.locked && lock.manifestSha256 !== sha256File(manifestPath))
191
+ throw new Error("Environment manifest does not match its lockfile");
192
+ const allEntries = [...environment.skills, ...environment.plugins];
193
+ for (const entry of allEntries) {
194
+ const packagePath = resolveSharePath(root, entry.path);
195
+ if (!fs.existsSync(packagePath))
196
+ throw new Error(`Missing package content: ${entry.path}`);
197
+ if (entry.kind === "skill")
198
+ validateSkillPackage(packagePath);
199
+ const expected = lock.packages[`${entry.kind}:${entry.id}`]?.sha256;
200
+ if (options.locked && expected && expected !== sha256Tree(packagePath))
201
+ throw new Error(`Package integrity check failed: ${entry.id}`);
202
+ }
203
+ const inputs = options.inputs ?? {};
204
+ const missingInputs = environment.inputs.map((input) => input.name).filter((name) => !inputs[name]);
205
+ if (options.dryRun)
206
+ return { importedSkills: environment.skills.map((entry) => entry.id), importedPlugins: environment.plugins.map((entry) => entry.id), importedServers: Object.keys(environment.servers), missingInputs };
207
+ const currentConfig = loadConfig();
208
+ for (const entry of environment.skills) {
209
+ validateSkillId(entry.id);
210
+ const target = path.join(getSkillsDir(), entry.id);
211
+ if (fs.existsSync(target) && sha256Tree(target) !== sha256Tree(resolveSharePath(root, entry.path)))
212
+ throw new Error(`Skill already exists with different content: ${entry.id}`);
213
+ }
214
+ for (const [name, raw] of Object.entries(environment.servers)) {
215
+ if (currentConfig.servers[name] && JSON.stringify(currentConfig.servers[name]) !== JSON.stringify(replaceInputs(raw, inputs)))
216
+ throw new Error(`Server already exists with different configuration: ${name}`);
217
+ }
218
+ for (const entry of environment.plugins) {
219
+ if (Object.values(currentConfig.plugins ?? {}).some((plugin) => plugin.name === entry.id))
220
+ throw new Error(`Plugin already exists: ${entry.id}`);
221
+ }
222
+ const targetSkills = getSkillsDir();
223
+ for (const entry of environment.skills) {
224
+ validateSkillId(entry.id);
225
+ const target = path.join(targetSkills, entry.id);
226
+ if (fs.existsSync(target)) {
227
+ if (sha256Tree(target) !== sha256Tree(resolveSharePath(root, entry.path)))
228
+ throw new Error(`Skill already exists with different content: ${entry.id}`);
229
+ continue;
230
+ }
231
+ copyDirectory(resolveSharePath(root, entry.path), target);
232
+ }
233
+ const importedPlugins = [];
234
+ for (const entry of environment.plugins) {
235
+ const packagePath = resolveSharePath(root, entry.path);
236
+ const { installPlugin } = await import("./chunk-v041118a.js");
237
+ await installPlugin(packagePath, { name: entry.id, enabled: true });
238
+ importedPlugins.push(entry.id);
239
+ }
240
+ const importedServers = [];
241
+ await mutateConfig((fresh) => {
242
+ for (const [name, raw] of Object.entries(environment.servers)) {
243
+ if (fresh.servers[name])
244
+ continue;
245
+ fresh.servers[name] = replaceInputs(raw, inputs);
246
+ importedServers.push(name);
247
+ }
248
+ });
249
+ return { importedSkills: environment.skills.map((entry) => entry.id), importedPlugins, importedServers, missingInputs };
250
+ }
251
+
252
+ export { exportEnvironment, importEnvironment };
253
+
254
+ //# debugId=2FCD1EB3744CFAA764756E2164756E21
@@ -0,0 +1,30 @@
1
+ import {
2
+ getManagedIndexPath,
3
+ readJsonFile,
4
+ writeJsonAtomic
5
+ } from "./chunk-grkz21sq.js";
6
+
7
+ // src/core/managed-index.ts
8
+ function defaultManagedIndex() {
9
+ return {
10
+ schemaVersion: 1,
11
+ managed: {}
12
+ };
13
+ }
14
+ function loadManagedIndex(filePath = getManagedIndexPath()) {
15
+ const raw = readJsonFile(filePath, defaultManagedIndex());
16
+ if (!raw || typeof raw !== "object") {
17
+ return defaultManagedIndex();
18
+ }
19
+ if (raw.schemaVersion !== 1) {
20
+ return defaultManagedIndex();
21
+ }
22
+ return raw;
23
+ }
24
+ function saveManagedIndex(index, filePath = getManagedIndexPath()) {
25
+ writeJsonAtomic(filePath, index);
26
+ }
27
+
28
+ export { defaultManagedIndex, loadManagedIndex, saveManagedIndex };
29
+
30
+ //# debugId=3E2C9A4BFDB1663764756E2164756E21
@@ -18,10 +18,16 @@ import {
18
18
  uninstallPlugin,
19
19
  unpinPlugin,
20
20
  updatePlugin
21
- } from "./chunk-56whm3hm.js";
22
- import"./chunk-01s7rhx3.js";
23
- import"./chunk-fw8dyt89.js";
24
- import"./chunk-4y0t0tfj.js";
21
+ } from "./chunk-4aafp444.js";
22
+ import"./chunk-wztmp5b4.js";
23
+ import"./chunk-8v13hqrp.js";
24
+ import"./chunk-t20f49g3.js";
25
+ import"./chunk-hahs24dv.js";
26
+ import"./chunk-chaj8a8b.js";
27
+ import"./chunk-7rq88hb3.js";
28
+ import"./chunk-brxwa30j.js";
29
+ import"./chunk-p7yzyt87.js";
30
+ import"./chunk-grkz21sq.js";
25
31
  import"./chunk-bjw71y54.js";
26
32
  import"./chunk-wj4tjacg.js";
27
33
  export {
@@ -46,4 +52,4 @@ export {
46
52
  updatePlugin
47
53
  };
48
54
 
49
- //# debugId=F3AE0823719415BE64756E2164756E21
55
+ //# debugId=6778094E987D66A464756E2164756E21
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  require_src
3
- } from "./chunk-tnhekcpv.js";
3
+ } from "./chunk-56z18csx.js";
4
4
  import {
5
5
  __commonJS
6
6
  } from "./chunk-wj4tjacg.js";