@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
@@ -0,0 +1,36 @@
1
+ import {
2
+ buildDaemonChildEnv,
3
+ getDaemonStatus,
4
+ readDaemonLogs,
5
+ resolveGatewayPort,
6
+ restartDaemon,
7
+ runDaemonForeground,
8
+ startDaemon,
9
+ stopDaemon
10
+ } from "./chunk-5r4vs8ct.js";
11
+ import"./chunk-mztnw25b.js";
12
+ import"./chunk-naeqpnmf.js";
13
+ import"./chunk-2qbt2pxv.js";
14
+ import"./chunk-f7w0a9nn.js";
15
+ import"./chunk-qg1rbk0d.js";
16
+ import"./chunk-z4j5q2x0.js";
17
+ import"./chunk-131c6axh.js";
18
+ import"./chunk-jncje8g1.js";
19
+ import"./chunk-9bjabsqb.js";
20
+ import"./chunk-rbra8ws6.js";
21
+ import"./chunk-p7yzyt87.js";
22
+ import"./chunk-vnka4jbe.js";
23
+ import"./chunk-bjw71y54.js";
24
+ import"./chunk-wj4tjacg.js";
25
+ export {
26
+ buildDaemonChildEnv,
27
+ getDaemonStatus,
28
+ readDaemonLogs,
29
+ resolveGatewayPort,
30
+ restartDaemon,
31
+ runDaemonForeground,
32
+ startDaemon,
33
+ stopDaemon
34
+ };
35
+
36
+ //# debugId=7E85224A0D63747064756E2164756E21
@@ -1,15 +1,17 @@
1
+ import {
2
+ exports_external
3
+ } from "./chunk-p7yzyt87.js";
1
4
  import {
2
5
  findProjectConfigPath,
3
6
  getConfigPath,
4
7
  readJsonFile,
5
8
  writeJsonAtomic
6
- } from "./chunk-4y0t0tfj.js";
9
+ } from "./chunk-vnka4jbe.js";
7
10
  import {
8
11
  normalizeServerSpecEnabled
9
12
  } from "./chunk-bjw71y54.js";
10
13
 
11
14
  // src/core/config.ts
12
- import { z } from "zod";
13
15
  import path from "node:path";
14
16
  import fs from "node:fs";
15
17
 
@@ -321,7 +323,7 @@ function isHttpUrl2(value) {
321
323
  }
322
324
  }
323
325
  function isClientInternalCommand(command) {
324
- return /\.app\/Contents\//.test(command);
326
+ return /\.app\/Contents\//.test(command) && !/mcpx(?:-dev)?\.app\/Contents\//.test(command);
325
327
  }
326
328
  function repairServerSpec(spec) {
327
329
  if (spec.transport !== "stdio") {
@@ -428,130 +430,140 @@ class ConfigLoadError extends Error {
428
430
  this.issues = issues;
429
431
  }
430
432
  }
431
- var clientStateSchema = z.object({
432
- status: z.enum(["SYNCED", "UNSUPPORTED_HTTP", "ERROR", "SKIPPED"]),
433
- lastSyncAt: z.string().optional(),
434
- message: z.string().optional(),
435
- configPath: z.string().optional()
433
+ var clientStateSchema = exports_external.object({
434
+ status: exports_external.enum(["SYNCED", "UNSUPPORTED_HTTP", "ERROR", "SKIPPED"]),
435
+ lastSyncAt: exports_external.string().optional(),
436
+ message: exports_external.string().optional(),
437
+ configPath: exports_external.string().optional()
436
438
  });
437
- var httpServerSchema = z.object({
438
- transport: z.literal("http"),
439
- url: z.url(),
440
- headers: z.record(z.string(), z.string()).optional(),
441
- enabled: z.boolean().default(true)
439
+ var httpServerSchema = exports_external.object({
440
+ scope: exports_external.string().optional(),
441
+ transport: exports_external.literal("http"),
442
+ url: exports_external.url(),
443
+ headers: exports_external.record(exports_external.string(), exports_external.string()).optional(),
444
+ enabled: exports_external.boolean().default(true)
442
445
  });
443
- var stdioServerSchema = z.object({
444
- transport: z.literal("stdio"),
445
- command: z.string().min(1),
446
- args: z.array(z.string()).optional(),
447
- env: z.record(z.string(), z.string()).optional(),
448
- cwd: z.string().min(1).optional(),
449
- enabled: z.boolean().default(true)
446
+ var stdioServerSchema = exports_external.object({
447
+ scope: exports_external.string().optional(),
448
+ transport: exports_external.literal("stdio"),
449
+ command: exports_external.string().min(1),
450
+ args: exports_external.array(exports_external.string()).optional(),
451
+ env: exports_external.record(exports_external.string(), exports_external.string()).optional(),
452
+ cwd: exports_external.string().min(1).optional(),
453
+ enabled: exports_external.boolean().default(true)
450
454
  });
451
- var serverSchema = z.discriminatedUnion("transport", [httpServerSchema, stdioServerSchema]);
452
- var projectEntrySchema = z.object({
453
- name: z.string(),
454
- path: z.string(),
455
- disabledServers: z.array(z.string()).default([])
455
+ var serverSchema = exports_external.discriminatedUnion("transport", [httpServerSchema, stdioServerSchema]);
456
+ var projectEntrySchema = exports_external.object({
457
+ name: exports_external.string(),
458
+ path: exports_external.string(),
459
+ disabledServers: exports_external.array(exports_external.string()).default([])
456
460
  });
457
- var pluginComponentSchema = z.enum(["mcpServers", "skills", "hooks", "agents", "commands"]);
458
- var discoveredComponentSchema = z.object({
459
- id: z.string(),
461
+ var pluginComponentSchema = exports_external.enum(["mcpServers", "skills", "hooks", "agents", "commands"]);
462
+ var discoveredComponentSchema = exports_external.object({
463
+ id: exports_external.string(),
460
464
  type: pluginComponentSchema,
461
- path: z.string(),
462
- description: z.string().optional()
465
+ path: exports_external.string(),
466
+ description: exports_external.string().optional()
463
467
  });
464
- var discoveredMcpServerSchema = z.object({
465
- id: z.string(),
466
- transport: z.enum(["stdio", "http"]).optional(),
467
- command: z.string(),
468
- args: z.array(z.string()).optional(),
469
- env: z.record(z.string(), z.string()).optional(),
470
- cwd: z.string().optional(),
471
- url: z.string().optional(),
472
- oauthResource: z.string().optional()
468
+ var discoveredMcpServerSchema = exports_external.object({
469
+ id: exports_external.string(),
470
+ transport: exports_external.enum(["stdio", "http"]).optional(),
471
+ command: exports_external.string(),
472
+ args: exports_external.array(exports_external.string()).optional(),
473
+ env: exports_external.record(exports_external.string(), exports_external.string()).optional(),
474
+ cwd: exports_external.string().optional(),
475
+ url: exports_external.string().optional(),
476
+ oauthResource: exports_external.string().optional()
473
477
  });
474
- var discoveredComponentsSchema = z.object({
475
- skills: z.array(discoveredComponentSchema).default([]),
476
- commands: z.array(discoveredComponentSchema).default([]),
477
- agents: z.array(discoveredComponentSchema).default([]),
478
- hooks: z.array(discoveredComponentSchema).default([]),
479
- mcpServers: z.array(discoveredMcpServerSchema).default([])
478
+ var discoveredComponentsSchema = exports_external.object({
479
+ skills: exports_external.array(discoveredComponentSchema).default([]),
480
+ commands: exports_external.array(discoveredComponentSchema).default([]),
481
+ agents: exports_external.array(discoveredComponentSchema).default([]),
482
+ hooks: exports_external.array(discoveredComponentSchema).default([]),
483
+ mcpServers: exports_external.array(discoveredMcpServerSchema).default([])
480
484
  });
481
- var managedPluginSchema = z.object({
482
- id: z.string(),
483
- name: z.string(),
484
- source: z.string(),
485
- version: z.string(),
486
- ref: z.string(),
487
- resolvedSha: z.string(),
488
- installedAt: z.string(),
489
- root: z.string(),
490
- dataDir: z.string(),
491
- components: z.record(pluginComponentSchema, z.boolean()).default({}),
485
+ var managedPluginSchema = exports_external.object({
486
+ id: exports_external.string(),
487
+ name: exports_external.string(),
488
+ source: exports_external.string(),
489
+ version: exports_external.string(),
490
+ ref: exports_external.string(),
491
+ resolvedSha: exports_external.string(),
492
+ installedAt: exports_external.string(),
493
+ root: exports_external.string(),
494
+ dataDir: exports_external.string(),
495
+ components: exports_external.record(pluginComponentSchema, exports_external.boolean()).default({}),
492
496
  discovered: discoveredComponentsSchema.default({}),
493
- enabled: z.boolean().default(true),
494
- status: z.enum(["healthy", "unhealthy", "preparing", "updating", "error"]).default("healthy"),
495
- error: z.string().optional(),
496
- serverNames: z.array(z.string()).default([]),
497
- projectedClients: z.array(z.string()).default([]),
498
- approvals: z.object({
499
- mcpServers: z.boolean().optional(),
500
- skills: z.boolean().optional(),
501
- hooks: z.boolean().optional(),
502
- agents: z.boolean().optional(),
503
- commands: z.boolean().optional()
497
+ enabled: exports_external.boolean().default(true),
498
+ status: exports_external.enum(["healthy", "unhealthy", "preparing", "updating", "error"]).default("healthy"),
499
+ error: exports_external.string().optional(),
500
+ serverNames: exports_external.array(exports_external.string()).default([]),
501
+ projectedClients: exports_external.array(exports_external.string()).default([]),
502
+ approvals: exports_external.object({
503
+ mcpServers: exports_external.boolean().optional(),
504
+ skills: exports_external.boolean().optional(),
505
+ hooks: exports_external.boolean().optional(),
506
+ agents: exports_external.boolean().optional(),
507
+ commands: exports_external.boolean().optional()
504
508
  }).optional(),
505
- marketplace: z.object({
506
- name: z.string(),
507
- pluginName: z.string(),
508
- sourceFingerprint: z.string()
509
+ marketplace: exports_external.object({
510
+ name: exports_external.string(),
511
+ pluginName: exports_external.string(),
512
+ sourceFingerprint: exports_external.string()
509
513
  }).optional(),
510
- updateError: z.string().optional(),
511
- pinned: z.boolean().default(false),
512
- previous: z.object({ version: z.string(), resolvedSha: z.string(), root: z.string() }).optional(),
513
- projectOverrides: z.record(z.string(), z.object({
514
- enabled: z.boolean().optional(),
515
- components: z.record(pluginComponentSchema, z.boolean()).optional(),
516
- config: z.record(z.string(), z.unknown()).optional()
514
+ updateError: exports_external.string().optional(),
515
+ pinned: exports_external.boolean().default(false),
516
+ previous: exports_external.object({ version: exports_external.string(), resolvedSha: exports_external.string(), root: exports_external.string() }).optional(),
517
+ projectOverrides: exports_external.record(exports_external.string(), exports_external.object({
518
+ enabled: exports_external.boolean().optional(),
519
+ components: exports_external.partialRecord(pluginComponentSchema, exports_external.boolean()).optional(),
520
+ config: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
517
521
  })).optional()
518
522
  });
519
- var managedMarketplaceSchema = z.object({
520
- name: z.string(),
521
- displayName: z.string(),
522
- source: z.string(),
523
- sourceType: z.enum(["github", "git", "local", "hosted-json"]).default("github"),
524
- manifestPath: z.string().optional(),
525
- format: z.enum(["claude", "codex"]).optional(),
526
- builtIn: z.boolean().default(false),
527
- autoUpdate: z.boolean().default(false),
528
- addedAt: z.string(),
529
- lastCheckedAt: z.string().optional(),
530
- lastUpdatedAt: z.string().optional(),
531
- resolvedRevision: z.string().optional(),
532
- status: z.enum(["ready", "stale", "error", "unavailable"]).default("unavailable"),
533
- error: z.string().optional()
523
+ var managedMarketplaceSchema = exports_external.object({
524
+ name: exports_external.string(),
525
+ displayName: exports_external.string(),
526
+ source: exports_external.string(),
527
+ sourceType: exports_external.enum(["github", "git", "local", "hosted-json"]).default("github"),
528
+ manifestPath: exports_external.string().optional(),
529
+ format: exports_external.enum(["claude", "codex"]).optional(),
530
+ builtIn: exports_external.boolean().default(false),
531
+ autoUpdate: exports_external.boolean().default(false),
532
+ addedAt: exports_external.string(),
533
+ lastCheckedAt: exports_external.string().optional(),
534
+ lastUpdatedAt: exports_external.string().optional(),
535
+ resolvedRevision: exports_external.string().optional(),
536
+ status: exports_external.enum(["ready", "stale", "error", "unavailable"]).default("unavailable"),
537
+ error: exports_external.string().optional()
534
538
  });
535
- var configSchema = z.object({
536
- schemaVersion: z.literal(1).default(1),
537
- gateway: z.object({
538
- port: z.number().int().min(1).max(65535).default(37373),
539
- tokenRef: z.string().default("secret://local_gateway_token"),
540
- autoStart: z.boolean().default(true)
539
+ var configSchema = exports_external.object({
540
+ schemaVersion: exports_external.literal(1).default(1),
541
+ consumers: exports_external.record(exports_external.string(), exports_external.object({ tokenRef: exports_external.string().regex(/^secret:\/\/[A-Za-z0-9._-]+$/), projectPath: exports_external.string().optional() })).default({}),
542
+ packages: exports_external.record(exports_external.string(), exports_external.object({ id: exports_external.string(), root: exports_external.string(), source: exports_external.string(), harness: exports_external.string(), fingerprint: exports_external.string(), pinned: exports_external.boolean(), name: exports_external.string().optional(), identity: exports_external.string().optional(), servers: exports_external.array(exports_external.string()).optional(), skills: exports_external.array(exports_external.object({ id: exports_external.string(), path: exports_external.string(), projectionPath: exports_external.string() })).optional(), scope: exports_external.string().optional(), previous: exports_external.object({ root: exports_external.string(), fingerprint: exports_external.string() }).optional() })).default({}),
543
+ revision: exports_external.number().int().nonnegative().default(0),
544
+ harnesses: exports_external.record(exports_external.string(), exports_external.object({ mode: exports_external.enum(["observe", "selected", "automatic"]) })).default({}),
545
+ origins: exports_external.record(exports_external.string(), exports_external.object({ id: exports_external.string(), kind: exports_external.string(), harness: exports_external.string(), source: exports_external.string(), nativeKey: exports_external.string(), fingerprint: exports_external.string(), operationId: exports_external.string() })).default({}),
546
+ gateway: exports_external.object({
547
+ port: exports_external.number().int().min(1).max(65535).default(37373),
548
+ tokenRef: exports_external.string().regex(/^secret:\/\/[A-Za-z0-9._-]+$/).default("secret://local_gateway_token"),
549
+ autoStart: exports_external.boolean().default(true)
541
550
  }).default({
542
551
  port: 37373,
543
552
  tokenRef: "secret://local_gateway_token",
544
553
  autoStart: true
545
554
  }),
546
- servers: z.record(z.string(), serverSchema).default({}),
547
- clients: z.record(z.string(), clientStateSchema).default({}),
548
- projects: z.record(z.string(), projectEntrySchema).default({}),
549
- plugins: z.record(z.string(), managedPluginSchema).default({}),
550
- marketplaces: z.record(z.string(), managedMarketplaceSchema).default({})
555
+ servers: exports_external.record(exports_external.string(), serverSchema).default({}),
556
+ clients: exports_external.record(exports_external.string(), clientStateSchema).default({}),
557
+ projects: exports_external.record(exports_external.string(), projectEntrySchema).default({}),
558
+ plugins: exports_external.record(exports_external.string(), managedPluginSchema).default({}),
559
+ marketplaces: exports_external.record(exports_external.string(), managedMarketplaceSchema).default({}),
560
+ secrets: exports_external.object({
561
+ backend: exports_external.enum(["file", "keychain"]).default("file")
562
+ }).default({ backend: "file" })
551
563
  });
552
- var projectConfigSchema = z.object({
553
- name: z.string().min(1).optional(),
554
- servers: z.record(z.string(), serverSchema).default({})
564
+ var projectConfigSchema = exports_external.object({
565
+ name: exports_external.string().min(1).optional(),
566
+ servers: exports_external.record(exports_external.string(), serverSchema).default({})
555
567
  });
556
568
  function defaultConfig() {
557
569
  return {
@@ -565,7 +577,8 @@ function defaultConfig() {
565
577
  clients: {},
566
578
  projects: {},
567
579
  plugins: {},
568
- marketplaces: ensureDefaultMarketplaces(undefined)
580
+ marketplaces: ensureDefaultMarketplaces(undefined),
581
+ secrets: { backend: "file" }
569
582
  };
570
583
  }
571
584
  function loadConfig(configPath = getConfigPath()) {
@@ -596,19 +609,23 @@ function loadConfig(configPath = getConfigPath()) {
596
609
  }
597
610
  const clientEntries = {};
598
611
  for (const [key, value] of Object.entries(parsed.data.clients)) {
599
- if (["claude", "claude-desktop", "codex", "cursor", "cline", "opencode", "kiro", "vscode", "qwen", "openclaw", "hermes"].includes(key)) {
600
- clientEntries[key] = value;
601
- }
612
+ clientEntries[key] = value;
602
613
  }
603
614
  const servers = Object.fromEntries(Object.entries(parsed.data.servers).map(([name, spec]) => [name, normalizeServerSpecEnabled(spec)]));
604
615
  return repairConfig({
605
616
  schemaVersion: 1,
617
+ consumers: parsed.data.consumers,
618
+ packages: parsed.data.packages,
619
+ revision: parsed.data.revision,
620
+ harnesses: parsed.data.harnesses,
621
+ origins: parsed.data.origins,
606
622
  gateway: parsed.data.gateway,
607
623
  servers,
608
624
  clients: clientEntries,
609
625
  projects: parsed.data.projects,
610
626
  plugins: parsed.data.plugins,
611
- marketplaces: ensureDefaultMarketplaces(parsed.data.marketplaces)
627
+ marketplaces: ensureDefaultMarketplaces(parsed.data.marketplaces),
628
+ secrets: parsed.data.secrets
612
629
  });
613
630
  }
614
631
  function saveConfig(config, configPath = getConfigPath()) {
@@ -737,4 +754,4 @@ function resolveActiveConfig(options = {}) {
737
754
 
738
755
  export { tokenizeCommandLine, parseCliAddCommand, ConfigLoadError, defaultConfig, loadConfig, saveConfig, loadProjectConfig, saveProjectConfig, loadMergedConfig, migrateProjectServers, resolveActiveConfig };
739
756
 
740
- //# debugId=5F19AEF9E1E9E38564756E2164756E21
757
+ //# debugId=E2636B557C478E8864756E2164756E21
@@ -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";
@@ -126,18 +126,54 @@ function readJsonFile(filePath, fallback) {
126
126
  return fallback;
127
127
  }
128
128
  }
129
+ function fsyncBestEffort(descriptor) {
130
+ try {
131
+ fs2.fsyncSync(descriptor);
132
+ } catch (error) {
133
+ const code = error.code;
134
+ if (code === "EPERM" || code === "EINVAL" || code === "ENOTSUP")
135
+ return;
136
+ throw error;
137
+ }
138
+ }
129
139
  function writeJsonAtomic(filePath, data) {
130
140
  fs2.mkdirSync(path2.dirname(filePath), { recursive: true });
131
141
  const tempPath = `${filePath}.tmp-${process.pid}-${Date.now()}`;
132
142
  const content = `${JSON.stringify(data, null, 2)}
133
143
  `;
134
- fs2.writeFileSync(tempPath, content, { mode: 384 });
144
+ const descriptor = fs2.openSync(tempPath, "w", 384);
145
+ try {
146
+ fs2.writeFileSync(descriptor, content);
147
+ fsyncBestEffort(descriptor);
148
+ } finally {
149
+ fs2.closeSync(descriptor);
150
+ }
135
151
  fs2.renameSync(tempPath, filePath);
152
+ if (process.platform !== "win32") {
153
+ const directory = fs2.openSync(path2.dirname(filePath), "r");
154
+ try {
155
+ fsyncBestEffort(directory);
156
+ } finally {
157
+ fs2.closeSync(directory);
158
+ }
159
+ }
136
160
  }
137
161
  function sha256(value) {
138
162
  return crypto2.createHash("sha256").update(value).digest("hex");
139
163
  }
164
+ function readJsonStrict(filePath, fallback) {
165
+ if (!fs2.existsSync(filePath))
166
+ return fallback;
167
+ try {
168
+ const value = JSON.parse(fs2.readFileSync(filePath, "utf8"));
169
+ if (!value || typeof value !== "object" || Array.isArray(value))
170
+ throw new Error("Expected an object");
171
+ return value;
172
+ } catch {
173
+ throw new Error(`Native configuration is invalid JSON: ${filePath}`);
174
+ }
175
+ }
140
176
 
141
- export { homeDir, getConfigPath, getTelemetryPath, getSkillsDir, getSkillPackagesRoot, getSkillStatePath, getManagedIndexPath, getSecretsStorePath, getSecretsKeyPath, getPidPath, getLogPath, getGatewayTokenPath, getUpdatesDir, getStagedVersionPath, getUpdateLockPath, getOAuthLockPath, getPluginCacheRoot, getPluginDataRoot, getMarketplaceCacheRoot, getMarketplaceUpdateStatePath, getMarketplaceUpdateLockPath, ensureDir, ensureParentDir, findProjectConfigPath, readJsonFile, writeJsonAtomic, sha256 };
177
+ export { homeDir, getConfigRoot, getDataRoot, getStateRoot, getConfigPath, getTelemetryPath, getSkillsDir, getSkillPackagesRoot, getSkillStatePath, getManagedIndexPath, getSecretsStorePath, getSecretsKeyPath, getRuntimeDir, getPidPath, getLogPath, getGatewayTokenPath, getUpdatesDir, getStagedVersionPath, getUpdateLockPath, getOAuthLockPath, getPluginCacheRoot, getPluginDataRoot, getMarketplaceCacheRoot, getMarketplaceUpdateStatePath, getMarketplaceUpdateLockPath, ensureDir, ensureParentDir, findProjectConfigPath, readJsonFile, writeJsonAtomic, sha256, readJsonStrict };
142
178
 
143
- //# debugId=BCB55F79AB94B71A64756E2164756E21
179
+ //# debugId=4649C9BC7E52DA8164756E2164756E21
@@ -0,0 +1,30 @@
1
+ import {
2
+ getManagedIndexPath,
3
+ readJsonFile,
4
+ writeJsonAtomic
5
+ } from "./chunk-vnka4jbe.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
@@ -0,0 +1,138 @@
1
+ import {
2
+ listAuthBindings,
3
+ secretRefName
4
+ } from "./chunk-0xt563m1.js";
5
+ import {
6
+ getDaemonStatus
7
+ } from "./chunk-5r4vs8ct.js";
8
+ import {
9
+ getAdapters,
10
+ getGatewayInternalUrl,
11
+ getGatewayUrl,
12
+ installationAdapters
13
+ } from "./chunk-f7w0a9nn.js";
14
+ import {
15
+ SecretsManager,
16
+ ensureGatewayToken
17
+ } from "./chunk-qg1rbk0d.js";
18
+ import {
19
+ isServerEnabled
20
+ } from "./chunk-bjw71y54.js";
21
+
22
+ // src/core/status.ts
23
+ var STATUS_CLIENTS = getAdapters().map((adapter) => adapter.id);
24
+ function describeServerTarget(spec) {
25
+ if (spec.transport === "http") {
26
+ return spec.url;
27
+ }
28
+ const args = (spec.args ?? []).join(" ");
29
+ const command = `${spec.command}${args ? ` ${args}` : ""}`;
30
+ return spec.cwd ? `${command} (cwd: ${spec.cwd})` : command;
31
+ }
32
+ function deriveClientStatus(managed, configured) {
33
+ if (configured) {
34
+ return configured;
35
+ }
36
+ return managed ? "SYNCED" : "SKIPPED";
37
+ }
38
+ function buildClientMappings(config, managedIndex, serverName) {
39
+ return installationAdapters(config).map(({ adapter }) => {
40
+ const clientId = adapter.id;
41
+ const configState = config.clients[clientId];
42
+ const managedClient = managedIndex.managed[clientId];
43
+ const managedEntry = managedClient?.entries?.[adapter.managedName?.(serverName) ?? `${serverName} (mcpx)`];
44
+ const managed = Boolean(managedEntry);
45
+ return {
46
+ clientId,
47
+ managed,
48
+ status: deriveClientStatus(managed, configState?.status),
49
+ configPath: managedClient?.configPath ?? configState?.configPath,
50
+ message: configState?.message,
51
+ lastSyncAt: managedEntry?.lastSyncedAt ?? configState?.lastSyncAt
52
+ };
53
+ });
54
+ }
55
+ function buildAuthBindings(spec) {
56
+ return listAuthBindings(spec).map((binding) => ({
57
+ kind: binding.kind,
58
+ key: binding.key,
59
+ value: binding.value,
60
+ secretName: secretRefName(binding.value) ?? undefined
61
+ }));
62
+ }
63
+ async function fetchTokenCounts(gatewayUrl, token) {
64
+ try {
65
+ const res = await fetch(gatewayUrl, {
66
+ method: "POST",
67
+ headers: {
68
+ authorization: `Bearer ${token}`
69
+ },
70
+ signal: AbortSignal.timeout(65000)
71
+ });
72
+ if (!res.ok) {
73
+ return { counts: {}, fetchError: `HTTP ${res.status}` };
74
+ }
75
+ const data = await res.json();
76
+ return { counts: data?.counts ?? {} };
77
+ } catch (error) {
78
+ return { counts: {}, fetchError: error instanceof Error ? error.message : String(error) };
79
+ }
80
+ }
81
+ async function buildStatusReport(config, managedIndex, daemon = getDaemonStatus(config)) {
82
+ const secrets = new SecretsManager;
83
+ const token = ensureGatewayToken(config, secrets);
84
+ const gatewayUrl = getGatewayUrl(config);
85
+ let tokenCounts = {};
86
+ let tokenCountFetchError;
87
+ if (daemon.running) {
88
+ const result = await fetchTokenCounts(getGatewayInternalUrl(config, "/internal/token-counts"), token);
89
+ tokenCounts = result.counts;
90
+ tokenCountFetchError = result.fetchError;
91
+ }
92
+ const projectEntries = Object.values(config.projects ?? {});
93
+ let totalGlobalTokens = 0;
94
+ const totalProjectTokens = {};
95
+ const serverNames = Object.keys(config.servers).sort((left, right) => left.localeCompare(right));
96
+ const servers = serverNames.map((name) => {
97
+ const spec = config.servers[name];
98
+ let tokenCount = tokenCounts[name];
99
+ if (tokenCount?.error && buildAuthBindings(spec).length > 0 && tokenCount.total > 0) {
100
+ tokenCount = { ...tokenCount, error: undefined };
101
+ }
102
+ const health = tokenCount ? tokenCount.error || tokenCount.runtimeError ? "error" : "ok" : "unknown";
103
+ const serverEntry = {
104
+ name,
105
+ enabled: isServerEnabled(spec),
106
+ transport: spec.transport,
107
+ target: describeServerTarget(spec),
108
+ authBindings: buildAuthBindings(spec),
109
+ clients: buildClientMappings(config, managedIndex, name),
110
+ tokenCount,
111
+ health
112
+ };
113
+ if (serverEntry.enabled && tokenCount) {
114
+ totalGlobalTokens += tokenCount.total;
115
+ for (const projectEntry of projectEntries) {
116
+ if (!(projectEntry.disabledServers ?? []).includes(name)) {
117
+ totalProjectTokens[projectEntry.path] = (totalProjectTokens[projectEntry.path] ?? 0) + tokenCount.total;
118
+ }
119
+ }
120
+ }
121
+ return serverEntry;
122
+ });
123
+ return {
124
+ gatewayUrl,
125
+ fetchError: tokenCountFetchError,
126
+ daemon,
127
+ upstreamCount: servers.length,
128
+ servers,
129
+ clients: config.clients,
130
+ projects: config.projects,
131
+ totalGlobalTokens,
132
+ totalProjectTokens
133
+ };
134
+ }
135
+
136
+ export { STATUS_CLIENTS, buildStatusReport };
137
+
138
+ //# debugId=5813D4CDEF97EC7C64756E2164756E21
@@ -11,11 +11,17 @@ import {
11
11
  resolveMarketplacePluginSource,
12
12
  setMarketplaceAutoUpdate,
13
13
  updateMarketplaceInstalledPlugin
14
- } from "./chunk-btbww96n.js";
15
- import"./chunk-56whm3hm.js";
16
- import"./chunk-01s7rhx3.js";
17
- import"./chunk-fw8dyt89.js";
18
- import"./chunk-4y0t0tfj.js";
14
+ } from "./chunk-mztnw25b.js";
15
+ import"./chunk-naeqpnmf.js";
16
+ import"./chunk-f7w0a9nn.js";
17
+ import"./chunk-qg1rbk0d.js";
18
+ import"./chunk-z4j5q2x0.js";
19
+ import"./chunk-131c6axh.js";
20
+ import"./chunk-jncje8g1.js";
21
+ import"./chunk-9bjabsqb.js";
22
+ import"./chunk-rbra8ws6.js";
23
+ import"./chunk-p7yzyt87.js";
24
+ import"./chunk-vnka4jbe.js";
19
25
  import"./chunk-bjw71y54.js";
20
26
  import"./chunk-wj4tjacg.js";
21
27
  export {
@@ -33,4 +39,4 @@ export {
33
39
  updateMarketplaceInstalledPlugin
34
40
  };
35
41
 
36
- //# debugId=AB01773EEA66F21764756E2164756E21
42
+ //# debugId=76A638EA438F529364756E2164756E21