@kwonye/mcpx 0.1.105 → 0.1.107

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-131c6axh.js +127 -0
  7. package/dist/chunk-1yq3yb66.js +126 -0
  8. package/dist/chunk-2qbt2pxv.js +755 -0
  9. package/dist/chunk-3j4g9141.js +18 -0
  10. package/dist/{chunk-tnhekcpv.js → chunk-56z18csx.js} +1 -1
  11. package/dist/chunk-5r4vs8ct.js +18166 -0
  12. package/dist/{chunk-bnbz55g6.js → chunk-65kshh9w.js} +1 -1
  13. package/dist/{chunk-xydajvzg.js → chunk-7ky3rsw9.js} +1 -1
  14. package/dist/chunk-9bjabsqb.js +563 -0
  15. package/dist/chunk-9jqdtz2y.js +26 -0
  16. package/dist/{chunk-y9a1rx7j.js → chunk-ad74zhbk.js} +5 -3
  17. package/dist/chunk-eqcsd1kw.js +33 -0
  18. package/dist/chunk-ezk8txcy.js +23 -0
  19. package/dist/chunk-f7w0a9nn.js +30542 -0
  20. package/dist/{chunk-12vgqm89.js → chunk-gvjxpk98.js} +1 -1
  21. package/dist/{chunk-am903qjk.js → chunk-h2ex6pmn.js} +11 -5
  22. package/dist/chunk-jncje8g1.js +60 -0
  23. package/dist/{chunk-h158rkts.js → chunk-kjd00ez5.js} +17 -5
  24. package/dist/{chunk-6mxr34tc.js → chunk-mazydv41.js} +4 -3
  25. package/dist/chunk-mkf7gc7q.js +14 -0
  26. package/dist/{chunk-btbww96n.js → chunk-mztnw25b.js} +69 -56
  27. package/dist/{chunk-enzmq965.js → chunk-n0462d52.js} +1 -1
  28. package/dist/chunk-n5ahyh0j.js +254 -0
  29. package/dist/{chunk-t4hqf6yh.js → chunk-naeqpnmf.js} +8136 -8262
  30. package/dist/chunk-nx22h1y3.js +33 -0
  31. package/dist/chunk-p7yzyt87.js +19426 -0
  32. package/dist/chunk-q86c5s6r.js +7 -0
  33. package/dist/chunk-qg1rbk0d.js +825 -0
  34. package/dist/chunk-r1aebtwm.js +36 -0
  35. package/dist/{chunk-01s7rhx3.js → chunk-rbra8ws6.js} +130 -113
  36. package/dist/{chunk-91vcwk5m.js → chunk-v14bg5yp.js} +1 -1
  37. package/dist/{chunk-4y0t0tfj.js → chunk-vnka4jbe.js} +39 -3
  38. package/dist/chunk-z4j5q2x0.js +30 -0
  39. package/dist/chunk-z7ykm4da.js +138 -0
  40. package/dist/{chunk-d2v9rxy0.js → chunk-zmf014br.js} +12 -6
  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 +18 -0
  46. package/dist/core/daemon.d.ts +2 -2
  47. package/dist/core/file-state.d.ts +7 -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
@@ -5,6 +5,8 @@ export declare class CodexAdapter implements ClientAdapter {
5
5
  supportsHttp(): boolean;
6
6
  syncPlugins(plugins: PluginSyncInput[]): PluginSyncResult;
7
7
  syncSkills(skills: Skill[]): void;
8
+ skillDirectory(): string;
9
+ additionalSkillDirectories(): string[];
8
10
  scanForImports(_config: McpxConfig, managedIndex: ManagedIndex): import("../types.js").ClientImportScanResult;
9
11
  syncGateway(_config: McpxConfig, options: SyncClientOptions): SyncResult;
10
12
  }
@@ -1,3 +1,4 @@
1
- import type { ClientAdapter } from "../types.js";
1
+ import type { ClientAdapter, HarnessDescriptor } from "../types.js";
2
+ export declare function registerHarness(id: string, factory: () => ClientAdapter, descriptor?: HarnessDescriptor): void;
2
3
  export declare function getAdapters(): ClientAdapter[];
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,26 @@
1
+ import type { ClientAdapter, ManagedIndex, McpxConfig, SyncClientOptions, SyncResult, Skill, PluginSyncInput } from "../types.js";
2
+ export declare function readNativeJson(file: string): Record<string, any>;
3
+ export interface JsonHarnessOptions {
4
+ id: string;
5
+ configPath: () => string;
6
+ skillsPath: () => string;
7
+ format?: "opencode" | "standard";
8
+ }
9
+ /** Shared codec; a new JSON harness supplies paths and its native format. */
10
+ export declare class JsonHarnessAdapter implements ClientAdapter {
11
+ readonly options: JsonHarnessOptions;
12
+ readonly id: string;
13
+ constructor(options: JsonHarnessOptions);
14
+ detectConfigPath(): string;
15
+ supportsHttp(): boolean;
16
+ skillDirectory(): string;
17
+ syncSkills(skills: Skill[]): void;
18
+ syncPlugins(plugins: PluginSyncInput[]): import("../types.js").PluginSyncResult;
19
+ private get key();
20
+ scanForImports(_config: McpxConfig, index: ManagedIndex): import("../types.js").ClientImportScanResult;
21
+ syncGateway(_config: McpxConfig, options: SyncClientOptions): SyncResult;
22
+ }
23
+ export declare class OpenCodeAdapter extends JsonHarnessAdapter {
24
+ constructor();
25
+ }
26
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { JsonHarnessAdapter } from "./json.js";
2
+ import type { McpxConfig, SyncClientOptions, SyncResult } from "../types.js";
3
+ export declare class PiAdapter extends JsonHarnessAdapter {
4
+ constructor(projectPath?: string);
5
+ additionalSkillDirectories(): string[];
6
+ managedName(name: string): string;
7
+ syncGateway(config: McpxConfig, options: SyncClientOptions): SyncResult;
8
+ }
9
+ //# sourceMappingURL=pi.d.ts.map
@@ -0,0 +1,126 @@
1
+ // src/core/server-auth.ts
2
+ function normalizeNamePart(value) {
3
+ return value.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "_").replace(/^_+|_+$/g, "") || "value";
4
+ }
5
+ function requireNonEmpty(value, label) {
6
+ const normalized = value?.trim();
7
+ if (!normalized) {
8
+ throw new Error(`${label} must be non-empty.`);
9
+ }
10
+ return normalized;
11
+ }
12
+ function toSecretRef(secretName) {
13
+ return `secret://${secretName}`;
14
+ }
15
+ function secretRefName(ref) {
16
+ if (!ref.startsWith("secret://")) {
17
+ return null;
18
+ }
19
+ const name = ref.slice("secret://".length).trim();
20
+ return name.length > 0 ? name : null;
21
+ }
22
+ function defaultAuthSecretName(serverName, target) {
23
+ return `auth_${normalizeNamePart(serverName)}_${target.kind}_${normalizeNamePart(target.key)}`;
24
+ }
25
+ function resolveAuthTarget(spec, header, env) {
26
+ if (spec.transport === "http") {
27
+ if (env) {
28
+ throw new Error("--env is only valid for stdio upstreams.");
29
+ }
30
+ return {
31
+ kind: "header",
32
+ key: requireNonEmpty(header ?? "Authorization", "Header name")
33
+ };
34
+ }
35
+ if (header) {
36
+ throw new Error("--header is only valid for HTTP upstreams.");
37
+ }
38
+ return {
39
+ kind: "env",
40
+ key: requireEnvName(env)
41
+ };
42
+ }
43
+ function requireEnvName(value) {
44
+ const name = requireNonEmpty(value, "Env var name");
45
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name))
46
+ throw new Error("Invalid environment variable name.");
47
+ return name;
48
+ }
49
+ function applyAuthReference(spec, target, secretRef) {
50
+ if (target.kind === "header") {
51
+ if (spec.transport !== "http") {
52
+ throw new Error(`Cannot set header auth on ${spec.transport} upstream.`);
53
+ }
54
+ const headers = { ...spec.headers ?? {} };
55
+ for (const key of Object.keys(headers)) {
56
+ if (key.toLowerCase() === target.key.toLowerCase())
57
+ delete headers[key];
58
+ }
59
+ headers[target.key] = secretRef;
60
+ spec.headers = headers;
61
+ return;
62
+ }
63
+ if (spec.transport !== "stdio") {
64
+ throw new Error(`Cannot set env auth on ${spec.transport} upstream.`);
65
+ }
66
+ const env = { ...spec.env ?? {} };
67
+ env[target.key] = secretRef;
68
+ spec.env = env;
69
+ }
70
+ function removeAuthReference(spec, target) {
71
+ if (target.kind === "header") {
72
+ if (spec.transport !== "http") {
73
+ throw new Error(`Cannot remove header auth from ${spec.transport} upstream.`);
74
+ }
75
+ if (!spec.headers || !(target.key in spec.headers)) {
76
+ return null;
77
+ }
78
+ const previous2 = spec.headers[target.key] ?? null;
79
+ const next2 = { ...spec.headers };
80
+ delete next2[target.key];
81
+ spec.headers = Object.keys(next2).length > 0 ? next2 : undefined;
82
+ return previous2;
83
+ }
84
+ if (spec.transport !== "stdio") {
85
+ throw new Error(`Cannot remove env auth from ${spec.transport} upstream.`);
86
+ }
87
+ if (!spec.env || !(target.key in spec.env)) {
88
+ return null;
89
+ }
90
+ const previous = spec.env[target.key] ?? null;
91
+ const next = { ...spec.env };
92
+ delete next[target.key];
93
+ spec.env = Object.keys(next).length > 0 ? next : undefined;
94
+ return previous;
95
+ }
96
+ function listAuthBindings(spec) {
97
+ if (spec.transport === "http") {
98
+ return Object.entries(spec.headers ?? {}).map(([key, value]) => ({
99
+ kind: "header",
100
+ key,
101
+ value
102
+ }));
103
+ }
104
+ return Object.entries(spec.env ?? {}).map(([key, value]) => ({
105
+ kind: "env",
106
+ key,
107
+ value
108
+ }));
109
+ }
110
+ var TOKEN68 = /^[A-Za-z0-9\-._~+/]+=*$/;
111
+ function maybePrefixBearer(target, value, raw = false) {
112
+ if (raw || target.kind !== "header" || target.key.toLowerCase() !== "authorization") {
113
+ return value;
114
+ }
115
+ if (/^\S+\s+\S+/.test(value)) {
116
+ return value;
117
+ }
118
+ if (TOKEN68.test(value)) {
119
+ return `Bearer ${value}`;
120
+ }
121
+ return value;
122
+ }
123
+
124
+ export { toSecretRef, secretRefName, defaultAuthSecretName, resolveAuthTarget, applyAuthReference, removeAuthReference, listAuthBindings, maybePrefixBearer };
125
+
126
+ //# debugId=DF42F5BEBE285FB064756E2164756E21
@@ -0,0 +1,127 @@
1
+ import {
2
+ lockOwnerAlive
3
+ } from "./chunk-jncje8g1.js";
4
+ import {
5
+ loadConfig,
6
+ loadProjectConfig,
7
+ saveConfig,
8
+ saveProjectConfig
9
+ } from "./chunk-rbra8ws6.js";
10
+ import {
11
+ findProjectConfigPath,
12
+ getConfigPath
13
+ } from "./chunk-vnka4jbe.js";
14
+
15
+ // src/core/config-store.ts
16
+ import fs from "node:fs";
17
+ import path from "node:path";
18
+ var LOCK_RETRY_MS = 50;
19
+ var LOCK_MAX_RETRIES = 40;
20
+ var inProcessQueues = new Map;
21
+ function getLockPath(filePath) {
22
+ return `${filePath}.lock`;
23
+ }
24
+ function acquireLock(filePath) {
25
+ const lockPath = getLockPath(filePath);
26
+ try {
27
+ fs.mkdirSync(path.dirname(lockPath), { recursive: true });
28
+ const fd = fs.openSync(lockPath, "wx");
29
+ fs.writeSync(fd, String(process.pid));
30
+ fs.closeSync(fd);
31
+ return true;
32
+ } catch (err) {
33
+ if (err.code !== "EEXIST") {
34
+ return false;
35
+ }
36
+ try {
37
+ if (!lockOwnerAlive(lockPath)) {
38
+ fs.unlinkSync(lockPath);
39
+ return acquireLock(filePath);
40
+ }
41
+ } catch {
42
+ return acquireLock(filePath);
43
+ }
44
+ return false;
45
+ }
46
+ }
47
+ function releaseLock(filePath) {
48
+ try {
49
+ fs.unlinkSync(getLockPath(filePath));
50
+ } catch {}
51
+ }
52
+ function mutateFile(filePath, load, save, fn) {
53
+ const prevQueue = inProcessQueues.get(filePath) ?? Promise.resolve();
54
+ const nextQueue = prevQueue.then(() => executeWithLock(filePath, load, save, fn), () => executeWithLock(filePath, load, save, fn));
55
+ inProcessQueues.set(filePath, nextQueue.catch(() => {
56
+ return;
57
+ }));
58
+ return nextQueue;
59
+ }
60
+ async function executeWithLock(filePath, load, save, fn) {
61
+ let acquired = false;
62
+ for (let attempt = 0;attempt < LOCK_MAX_RETRIES; attempt++) {
63
+ acquired = acquireLock(filePath);
64
+ if (acquired)
65
+ break;
66
+ await new Promise((r) => setTimeout(r, LOCK_RETRY_MS));
67
+ }
68
+ if (!acquired) {
69
+ throw new Error(`Could not acquire lock for ${filePath}.`);
70
+ }
71
+ try {
72
+ const data = load(filePath);
73
+ const result = await fn(data);
74
+ save(data, filePath);
75
+ return result;
76
+ } finally {
77
+ releaseLock(filePath);
78
+ }
79
+ }
80
+ function mutateConfig(fn, configPath) {
81
+ return mutateFile(configPath ?? getConfigPath(), loadConfig, saveConfig, async (config) => {
82
+ const result = await fn(config);
83
+ config.revision = (config.revision ?? 0) + 1;
84
+ return result;
85
+ });
86
+ }
87
+ function mutateProjectConfig(projectConfigPath, fn) {
88
+ return mutateFile(projectConfigPath, (p) => loadProjectConfig(p), saveProjectConfig, fn);
89
+ }
90
+ async function mutateActiveConfig(options, mutator) {
91
+ const globalPath = getConfigPath();
92
+ if (!options.global) {
93
+ const projectConfigPath = findProjectConfigPath();
94
+ if (options.local) {
95
+ const projectPath = projectConfigPath ? path.dirname(projectConfigPath) : process.cwd();
96
+ const localPath = path.join(projectPath, ".mcpx.json");
97
+ const globalConfig = loadConfig(globalPath);
98
+ const result2 = await mutateProjectConfig(localPath, async (projectConfig) => {
99
+ const mergedConfig = {
100
+ ...globalConfig,
101
+ servers: { ...globalConfig.servers, ...projectConfig.servers }
102
+ };
103
+ const mutatorResult = await mutator(mergedConfig, { type: "project", projectPath });
104
+ const localServers = {};
105
+ for (const [name, spec] of Object.entries(mergedConfig.servers)) {
106
+ if (!(name in globalConfig.servers)) {
107
+ localServers[name] = spec;
108
+ }
109
+ }
110
+ projectConfig.servers = localServers;
111
+ return mutatorResult;
112
+ });
113
+ return { type: "project", configPath: localPath, projectPath, result: result2 };
114
+ }
115
+ if (projectConfigPath) {
116
+ const projectPath = path.dirname(projectConfigPath);
117
+ const result2 = await mutateConfig((config) => mutator(config, { type: "project", projectPath }), globalPath);
118
+ return { type: "project", configPath: globalPath, projectPath, result: result2 };
119
+ }
120
+ }
121
+ const result = await mutateConfig((config) => mutator(config, { type: "global" }), globalPath);
122
+ return { type: "global", configPath: globalPath, result };
123
+ }
124
+
125
+ export { mutateConfig, mutateProjectConfig, mutateActiveConfig };
126
+
127
+ //# debugId=F410213A0C687F0164756E2164756E21
@@ -0,0 +1,126 @@
1
+ // src/core/registry-client.ts
2
+ var REGISTRY_BASE = "https://registry.modelcontextprotocol.io";
3
+ async function fetchRegistryServerDetail(name) {
4
+ const encoded = encodeURIComponent(name);
5
+ const response = await fetch(`${REGISTRY_BASE}/v0.1/servers/${encoded}/versions/latest`, {
6
+ headers: { accept: "application/json" }
7
+ });
8
+ if (!response.ok) {
9
+ throw new Error(`Registry API error: ${response.status}`);
10
+ }
11
+ const data = await response.json();
12
+ return data.server;
13
+ }
14
+ var PACKAGE_PRIORITY = {
15
+ npm: 1,
16
+ pypi: 2,
17
+ nuget: 3,
18
+ oci: 4,
19
+ mcpb: 5
20
+ };
21
+ var RUNTIME_HINT = {
22
+ npm: "npx",
23
+ pypi: "uvx",
24
+ nuget: "dnx"
25
+ };
26
+ function selectBestPackage(packages = [], remotes = []) {
27
+ const stdioPkgs = packages.filter((p) => p.transport.type === "stdio").sort((a, b) => (PACKAGE_PRIORITY[a.registryType] ?? 99) - (PACKAGE_PRIORITY[b.registryType] ?? 99));
28
+ if (stdioPkgs.length > 0) {
29
+ return { kind: "package", package: stdioPkgs[0] };
30
+ }
31
+ const httpRemotes = remotes.filter((r) => r.type === "streamable-http");
32
+ if (httpRemotes.length > 0) {
33
+ return { kind: "remote", remote: httpRemotes[0] };
34
+ }
35
+ if (packages.length > 0) {
36
+ return { kind: "package", package: packages[0] };
37
+ }
38
+ if (remotes.length > 0) {
39
+ throw new Error("Server has no MCP v2-compatible streamable HTTP remote");
40
+ }
41
+ throw new Error("Server has no packages or remotes");
42
+ }
43
+ function extractRequiredInputs(option) {
44
+ const inputs = [];
45
+ if (option.kind === "package" && option.package?.environmentVariables) {
46
+ for (const env of option.package.environmentVariables) {
47
+ if (env.isRequired && !env.default) {
48
+ inputs.push({
49
+ name: env.name,
50
+ description: env.description,
51
+ isSecret: env.isSecret ?? false,
52
+ kind: "env"
53
+ });
54
+ }
55
+ }
56
+ for (const arg of option.package.packageArguments ?? []) {
57
+ if (arg.isRequired && !arg.value && !arg.default) {
58
+ inputs.push({
59
+ name: arg.name ?? arg.valueHint ?? "arg",
60
+ description: arg.description,
61
+ isSecret: false,
62
+ kind: "arg"
63
+ });
64
+ }
65
+ }
66
+ }
67
+ if (option.kind === "remote" && option.remote?.headers) {
68
+ for (const header of option.remote.headers) {
69
+ if (header.isRequired && !header.default) {
70
+ inputs.push({
71
+ name: header.name,
72
+ description: header.description,
73
+ isSecret: header.isSecret ?? false,
74
+ kind: "header"
75
+ });
76
+ }
77
+ }
78
+ }
79
+ return inputs;
80
+ }
81
+ function mapRegistryToSpec(_name, option, resolvedValues) {
82
+ if (option.kind === "remote") {
83
+ const headers = {};
84
+ for (const header of option.remote?.headers ?? []) {
85
+ const value = resolvedValues[header.name] ?? header.default;
86
+ if (value)
87
+ headers[header.name] = value;
88
+ }
89
+ return {
90
+ transport: "http",
91
+ url: option.remote.url,
92
+ ...Object.keys(headers).length > 0 ? { headers } : {}
93
+ };
94
+ }
95
+ const pkg = option.package;
96
+ const runtime = pkg.runtimeHint ?? RUNTIME_HINT[pkg.registryType] ?? "npx";
97
+ const args = [];
98
+ const identifier = pkg.version ? `${pkg.identifier}@${pkg.version}` : pkg.identifier;
99
+ args.push(identifier);
100
+ for (const arg of pkg.packageArguments ?? []) {
101
+ const value = arg.value ?? resolvedValues[arg.name ?? arg.valueHint ?? ""] ?? arg.default;
102
+ if (!value)
103
+ continue;
104
+ if (arg.type === "named" && arg.name) {
105
+ args.push(arg.name, value);
106
+ } else {
107
+ args.push(value);
108
+ }
109
+ }
110
+ const env = {};
111
+ for (const envVar of pkg.environmentVariables ?? []) {
112
+ const value = resolvedValues[envVar.name] ?? envVar.default;
113
+ if (value)
114
+ env[envVar.name] = value;
115
+ }
116
+ return {
117
+ transport: "stdio",
118
+ command: runtime,
119
+ args,
120
+ ...Object.keys(env).length > 0 ? { env } : {}
121
+ };
122
+ }
123
+
124
+ export { fetchRegistryServerDetail, selectBestPackage, extractRequiredInputs, mapRegistryToSpec };
125
+
126
+ //# debugId=E7449C596396DD3864756E2164756E21