@padua/cli 1.13.1 → 2.0.1

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 (265) hide show
  1. package/README.md +121 -6
  2. package/dist/commands/doctor/index.d.ts.map +1 -1
  3. package/dist/commands/doctor/index.js +85 -0
  4. package/dist/commands/doctor/index.js.map +1 -1
  5. package/dist/commands/doctor/mcp-checks.d.ts +36 -0
  6. package/dist/commands/doctor/mcp-checks.d.ts.map +1 -0
  7. package/dist/commands/doctor/mcp-checks.js +235 -0
  8. package/dist/commands/doctor/mcp-checks.js.map +1 -0
  9. package/dist/commands/doctor/mcp-service-checks.d.ts +35 -0
  10. package/dist/commands/doctor/mcp-service-checks.d.ts.map +1 -0
  11. package/dist/commands/doctor/mcp-service-checks.js +146 -0
  12. package/dist/commands/doctor/mcp-service-checks.js.map +1 -0
  13. package/dist/commands/doctor/types.d.ts +4 -1
  14. package/dist/commands/doctor/types.d.ts.map +1 -1
  15. package/dist/commands/doctor/types.js +1 -0
  16. package/dist/commands/doctor/types.js.map +1 -1
  17. package/dist/commands/login/index.d.ts +1 -1
  18. package/dist/commands/login/index.d.ts.map +1 -1
  19. package/dist/commands/login/index.js +44 -185
  20. package/dist/commands/login/index.js.map +1 -1
  21. package/dist/commands/login/mcp-steps.d.ts +38 -0
  22. package/dist/commands/login/mcp-steps.d.ts.map +1 -0
  23. package/dist/commands/login/mcp-steps.js +176 -0
  24. package/dist/commands/login/mcp-steps.js.map +1 -0
  25. package/dist/commands/login/orchestrator.d.ts +9 -0
  26. package/dist/commands/login/orchestrator.d.ts.map +1 -0
  27. package/dist/commands/login/orchestrator.js +251 -0
  28. package/dist/commands/login/orchestrator.js.map +1 -0
  29. package/dist/commands/login/types.d.ts +11 -0
  30. package/dist/commands/login/types.d.ts.map +1 -1
  31. package/dist/commands/login/types.js.map +1 -1
  32. package/dist/commands/status/aws-checks.d.ts +14 -0
  33. package/dist/commands/status/aws-checks.d.ts.map +1 -0
  34. package/dist/commands/status/aws-checks.js +145 -0
  35. package/dist/commands/status/aws-checks.js.map +1 -0
  36. package/dist/commands/status/checks.d.ts +9 -25
  37. package/dist/commands/status/checks.d.ts.map +1 -1
  38. package/dist/commands/status/checks.js +52 -254
  39. package/dist/commands/status/checks.js.map +1 -1
  40. package/dist/commands/status/index.d.ts.map +1 -1
  41. package/dist/commands/status/index.js +53 -1
  42. package/dist/commands/status/index.js.map +1 -1
  43. package/dist/commands/status/mcp-checks.d.ts +35 -0
  44. package/dist/commands/status/mcp-checks.d.ts.map +1 -0
  45. package/dist/commands/status/mcp-checks.js +175 -0
  46. package/dist/commands/status/mcp-checks.js.map +1 -0
  47. package/dist/commands/status/types.d.ts +34 -0
  48. package/dist/commands/status/types.d.ts.map +1 -1
  49. package/dist/mcp/config/index.d.ts +4 -0
  50. package/dist/mcp/config/index.d.ts.map +1 -0
  51. package/dist/mcp/config/index.js +14 -0
  52. package/dist/mcp/config/index.js.map +1 -0
  53. package/dist/mcp/config/loaders.d.ts +45 -0
  54. package/dist/mcp/config/loaders.d.ts.map +1 -0
  55. package/dist/mcp/config/loaders.js +149 -0
  56. package/dist/mcp/config/loaders.js.map +1 -0
  57. package/dist/mcp/config/types.d.ts +234 -0
  58. package/dist/mcp/config/types.d.ts.map +1 -0
  59. package/dist/mcp/config/types.js +45 -0
  60. package/dist/mcp/config/types.js.map +1 -0
  61. package/dist/mcp/daemon/entry-logic.d.ts +28 -0
  62. package/dist/mcp/daemon/entry-logic.d.ts.map +1 -0
  63. package/dist/mcp/daemon/entry-logic.js +82 -0
  64. package/dist/mcp/daemon/entry-logic.js.map +1 -0
  65. package/dist/mcp/daemon/entry.d.ts +8 -0
  66. package/dist/mcp/daemon/entry.d.ts.map +1 -0
  67. package/dist/mcp/daemon/entry.js +34 -0
  68. package/dist/mcp/daemon/entry.js.map +1 -0
  69. package/dist/mcp/daemon/fork.d.ts +21 -0
  70. package/dist/mcp/daemon/fork.d.ts.map +1 -0
  71. package/dist/mcp/daemon/fork.js +188 -0
  72. package/dist/mcp/daemon/fork.js.map +1 -0
  73. package/dist/mcp/daemon/health.d.ts +8 -0
  74. package/dist/mcp/daemon/health.d.ts.map +1 -0
  75. package/dist/mcp/daemon/health.js +50 -0
  76. package/dist/mcp/daemon/health.js.map +1 -0
  77. package/dist/mcp/daemon/index.d.ts +6 -0
  78. package/dist/mcp/daemon/index.d.ts.map +1 -0
  79. package/dist/mcp/daemon/index.js +22 -0
  80. package/dist/mcp/daemon/index.js.map +1 -0
  81. package/dist/mcp/daemon/types.d.ts +63 -0
  82. package/dist/mcp/daemon/types.d.ts.map +1 -0
  83. package/dist/mcp/daemon/types.js +18 -0
  84. package/dist/mcp/daemon/types.js.map +1 -0
  85. package/dist/mcp/errors/index.d.ts +3 -0
  86. package/dist/mcp/errors/index.d.ts.map +1 -0
  87. package/dist/mcp/errors/index.js +13 -0
  88. package/dist/mcp/errors/index.js.map +1 -0
  89. package/dist/mcp/errors/types.d.ts +83 -0
  90. package/dist/mcp/errors/types.d.ts.map +1 -0
  91. package/dist/mcp/errors/types.js +148 -0
  92. package/dist/mcp/errors/types.js.map +1 -0
  93. package/dist/mcp/providers/atlassian/auth.d.ts +34 -0
  94. package/dist/mcp/providers/atlassian/auth.d.ts.map +1 -0
  95. package/dist/mcp/providers/atlassian/auth.js +107 -0
  96. package/dist/mcp/providers/atlassian/auth.js.map +1 -0
  97. package/dist/mcp/providers/atlassian/client.d.ts +15 -0
  98. package/dist/mcp/providers/atlassian/client.d.ts.map +1 -0
  99. package/dist/mcp/providers/atlassian/client.js +38 -0
  100. package/dist/mcp/providers/atlassian/client.js.map +1 -0
  101. package/dist/mcp/providers/atlassian/index.d.ts +6 -0
  102. package/dist/mcp/providers/atlassian/index.d.ts.map +1 -0
  103. package/dist/mcp/providers/atlassian/index.js +11 -0
  104. package/dist/mcp/providers/atlassian/index.js.map +1 -0
  105. package/dist/mcp/providers/atlassian/markdown-to-adf/index.d.ts +17 -0
  106. package/dist/mcp/providers/atlassian/markdown-to-adf/index.d.ts.map +1 -0
  107. package/dist/mcp/providers/atlassian/markdown-to-adf/index.js +29 -0
  108. package/dist/mcp/providers/atlassian/markdown-to-adf/index.js.map +1 -0
  109. package/dist/mcp/providers/atlassian/markdown-to-adf/nodes.d.ts +43 -0
  110. package/dist/mcp/providers/atlassian/markdown-to-adf/nodes.d.ts.map +1 -0
  111. package/dist/mcp/providers/atlassian/markdown-to-adf/nodes.js +101 -0
  112. package/dist/mcp/providers/atlassian/markdown-to-adf/nodes.js.map +1 -0
  113. package/dist/mcp/providers/atlassian/markdown-to-adf/parser.d.ts +14 -0
  114. package/dist/mcp/providers/atlassian/markdown-to-adf/parser.d.ts.map +1 -0
  115. package/dist/mcp/providers/atlassian/markdown-to-adf/parser.js +250 -0
  116. package/dist/mcp/providers/atlassian/markdown-to-adf/parser.js.map +1 -0
  117. package/dist/mcp/providers/atlassian/provider.d.ts +38 -0
  118. package/dist/mcp/providers/atlassian/provider.d.ts.map +1 -0
  119. package/dist/mcp/providers/atlassian/provider.js +101 -0
  120. package/dist/mcp/providers/atlassian/provider.js.map +1 -0
  121. package/dist/mcp/providers/atlassian/resources.d.ts +4 -0
  122. package/dist/mcp/providers/atlassian/resources.d.ts.map +1 -0
  123. package/dist/mcp/providers/atlassian/resources.js +67 -0
  124. package/dist/mcp/providers/atlassian/resources.js.map +1 -0
  125. package/dist/mcp/providers/atlassian/tools/confluence.d.ts +4 -0
  126. package/dist/mcp/providers/atlassian/tools/confluence.d.ts.map +1 -0
  127. package/dist/mcp/providers/atlassian/tools/confluence.js +169 -0
  128. package/dist/mcp/providers/atlassian/tools/confluence.js.map +1 -0
  129. package/dist/mcp/providers/atlassian/tools/jira.d.ts +4 -0
  130. package/dist/mcp/providers/atlassian/tools/jira.d.ts.map +1 -0
  131. package/dist/mcp/providers/atlassian/tools/jira.js +274 -0
  132. package/dist/mcp/providers/atlassian/tools/jira.js.map +1 -0
  133. package/dist/mcp/providers/gitlab/auth.d.ts +10 -0
  134. package/dist/mcp/providers/gitlab/auth.d.ts.map +1 -0
  135. package/dist/mcp/providers/gitlab/auth.js +23 -0
  136. package/dist/mcp/providers/gitlab/auth.js.map +1 -0
  137. package/dist/mcp/providers/gitlab/client.d.ts +23 -0
  138. package/dist/mcp/providers/gitlab/client.d.ts.map +1 -0
  139. package/dist/mcp/providers/gitlab/client.js +17 -0
  140. package/dist/mcp/providers/gitlab/client.js.map +1 -0
  141. package/dist/mcp/providers/gitlab/index.d.ts +5 -0
  142. package/dist/mcp/providers/gitlab/index.d.ts.map +1 -0
  143. package/dist/mcp/providers/gitlab/index.js +10 -0
  144. package/dist/mcp/providers/gitlab/index.js.map +1 -0
  145. package/dist/mcp/providers/gitlab/provider.d.ts +25 -0
  146. package/dist/mcp/providers/gitlab/provider.d.ts.map +1 -0
  147. package/dist/mcp/providers/gitlab/provider.js +48 -0
  148. package/dist/mcp/providers/gitlab/provider.js.map +1 -0
  149. package/dist/mcp/providers/gitlab/resources.d.ts +11 -0
  150. package/dist/mcp/providers/gitlab/resources.d.ts.map +1 -0
  151. package/dist/mcp/providers/gitlab/resources.js +54 -0
  152. package/dist/mcp/providers/gitlab/resources.js.map +1 -0
  153. package/dist/mcp/providers/gitlab/tools/issues.d.ts +4 -0
  154. package/dist/mcp/providers/gitlab/tools/issues.d.ts.map +1 -0
  155. package/dist/mcp/providers/gitlab/tools/issues.js +120 -0
  156. package/dist/mcp/providers/gitlab/tools/issues.js.map +1 -0
  157. package/dist/mcp/providers/gitlab/tools/merge-requests.d.ts +11 -0
  158. package/dist/mcp/providers/gitlab/tools/merge-requests.d.ts.map +1 -0
  159. package/dist/mcp/providers/gitlab/tools/merge-requests.js +282 -0
  160. package/dist/mcp/providers/gitlab/tools/merge-requests.js.map +1 -0
  161. package/dist/mcp/providers/gitlab/tools/pipelines.d.ts +10 -0
  162. package/dist/mcp/providers/gitlab/tools/pipelines.d.ts.map +1 -0
  163. package/dist/mcp/providers/gitlab/tools/pipelines.js +173 -0
  164. package/dist/mcp/providers/gitlab/tools/pipelines.js.map +1 -0
  165. package/dist/mcp/providers/gitlab/tools/repository.d.ts +4 -0
  166. package/dist/mcp/providers/gitlab/tools/repository.d.ts.map +1 -0
  167. package/dist/mcp/providers/gitlab/tools/repository.js +191 -0
  168. package/dist/mcp/providers/gitlab/tools/repository.js.map +1 -0
  169. package/dist/mcp/providers/index.d.ts +4 -0
  170. package/dist/mcp/providers/index.d.ts.map +1 -0
  171. package/dist/mcp/providers/index.js +6 -0
  172. package/dist/mcp/providers/index.js.map +1 -0
  173. package/dist/mcp/providers/registry.d.ts +90 -0
  174. package/dist/mcp/providers/registry.d.ts.map +1 -0
  175. package/dist/mcp/providers/registry.js +128 -0
  176. package/dist/mcp/providers/registry.js.map +1 -0
  177. package/dist/mcp/providers/tool-helpers.d.ts +14 -0
  178. package/dist/mcp/providers/tool-helpers.d.ts.map +1 -0
  179. package/dist/mcp/providers/tool-helpers.js +12 -0
  180. package/dist/mcp/providers/tool-helpers.js.map +1 -0
  181. package/dist/mcp/providers/types.d.ts +80 -0
  182. package/dist/mcp/providers/types.d.ts.map +1 -0
  183. package/dist/mcp/providers/types.js +13 -0
  184. package/dist/mcp/providers/types.js.map +1 -0
  185. package/dist/mcp/server/auth.d.ts +8 -0
  186. package/dist/mcp/server/auth.d.ts.map +1 -0
  187. package/dist/mcp/server/auth.js +36 -0
  188. package/dist/mcp/server/auth.js.map +1 -0
  189. package/dist/mcp/server/health.d.ts +24 -0
  190. package/dist/mcp/server/health.d.ts.map +1 -0
  191. package/dist/mcp/server/health.js +37 -0
  192. package/dist/mcp/server/health.js.map +1 -0
  193. package/dist/mcp/server/index.d.ts +11 -0
  194. package/dist/mcp/server/index.d.ts.map +1 -0
  195. package/dist/mcp/server/index.js +27 -0
  196. package/dist/mcp/server/index.js.map +1 -0
  197. package/dist/mcp/server/logging.d.ts +46 -0
  198. package/dist/mcp/server/logging.d.ts.map +1 -0
  199. package/dist/mcp/server/logging.js +109 -0
  200. package/dist/mcp/server/logging.js.map +1 -0
  201. package/dist/mcp/server/ratelimit.d.ts +3 -0
  202. package/dist/mcp/server/ratelimit.d.ts.map +1 -0
  203. package/dist/mcp/server/ratelimit.js +70 -0
  204. package/dist/mcp/server/ratelimit.js.map +1 -0
  205. package/dist/mcp/server/routes.d.ts +3 -0
  206. package/dist/mcp/server/routes.d.ts.map +1 -0
  207. package/dist/mcp/server/routes.js +8 -0
  208. package/dist/mcp/server/routes.js.map +1 -0
  209. package/dist/mcp/server/server.d.ts +21 -0
  210. package/dist/mcp/server/server.d.ts.map +1 -0
  211. package/dist/mcp/server/server.js +114 -0
  212. package/dist/mcp/server/server.js.map +1 -0
  213. package/dist/mcp/server/validation.d.ts +22 -0
  214. package/dist/mcp/server/validation.d.ts.map +1 -0
  215. package/dist/mcp/server/validation.js +32 -0
  216. package/dist/mcp/server/validation.js.map +1 -0
  217. package/dist/mcp/store/encrypt.d.ts +22 -0
  218. package/dist/mcp/store/encrypt.d.ts.map +1 -0
  219. package/dist/mcp/store/encrypt.js +66 -0
  220. package/dist/mcp/store/encrypt.js.map +1 -0
  221. package/dist/mcp/store/index.d.ts +12 -0
  222. package/dist/mcp/store/index.d.ts.map +1 -0
  223. package/dist/mcp/store/index.js +16 -0
  224. package/dist/mcp/store/index.js.map +1 -0
  225. package/dist/mcp/store/migrate.d.ts +70 -0
  226. package/dist/mcp/store/migrate.d.ts.map +1 -0
  227. package/dist/mcp/store/migrate.js +211 -0
  228. package/dist/mcp/store/migrate.js.map +1 -0
  229. package/dist/mcp/store/null-token-store.d.ts +22 -0
  230. package/dist/mcp/store/null-token-store.d.ts.map +1 -0
  231. package/dist/mcp/store/null-token-store.js +40 -0
  232. package/dist/mcp/store/null-token-store.js.map +1 -0
  233. package/dist/mcp/store/sqlite.d.ts +27 -0
  234. package/dist/mcp/store/sqlite.d.ts.map +1 -0
  235. package/dist/mcp/store/sqlite.js +100 -0
  236. package/dist/mcp/store/sqlite.js.map +1 -0
  237. package/dist/mcp/store/types.d.ts +183 -0
  238. package/dist/mcp/store/types.d.ts.map +1 -0
  239. package/dist/mcp/store/types.js +13 -0
  240. package/dist/mcp/store/types.js.map +1 -0
  241. package/dist/mcp/token/http-client.d.ts +3 -0
  242. package/dist/mcp/token/http-client.d.ts.map +1 -0
  243. package/dist/mcp/token/http-client.js +186 -0
  244. package/dist/mcp/token/http-client.js.map +1 -0
  245. package/dist/mcp/token/index.d.ts +5 -0
  246. package/dist/mcp/token/index.d.ts.map +1 -0
  247. package/dist/mcp/token/index.js +15 -0
  248. package/dist/mcp/token/index.js.map +1 -0
  249. package/dist/mcp/token/manager.d.ts +54 -0
  250. package/dist/mcp/token/manager.d.ts.map +1 -0
  251. package/dist/mcp/token/manager.js +194 -0
  252. package/dist/mcp/token/manager.js.map +1 -0
  253. package/dist/mcp/token/null-token-manager.d.ts +19 -0
  254. package/dist/mcp/token/null-token-manager.d.ts.map +1 -0
  255. package/dist/mcp/token/null-token-manager.js +50 -0
  256. package/dist/mcp/token/null-token-manager.js.map +1 -0
  257. package/dist/mcp/token/oauth.d.ts +44 -0
  258. package/dist/mcp/token/oauth.d.ts.map +1 -0
  259. package/dist/mcp/token/oauth.js +257 -0
  260. package/dist/mcp/token/oauth.js.map +1 -0
  261. package/dist/mcp/token/types.d.ts +81 -0
  262. package/dist/mcp/token/types.d.ts.map +1 -0
  263. package/dist/mcp/token/types.js +6 -0
  264. package/dist/mcp/token/types.js.map +1 -0
  265. package/package.json +10 -3
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setPathResolver = setPathResolver;
4
+ exports.resetPathResolver = resetPathResolver;
5
+ exports.getPidFilePath = getPidFilePath;
6
+ exports.getAuthFilePath = getAuthFilePath;
7
+ exports.getStartupFilePath = getStartupFilePath;
8
+ exports.isProcessAlive = isProcessAlive;
9
+ exports.readExistingDaemon = readExistingDaemon;
10
+ exports.forkDaemon = forkDaemon;
11
+ exports.stopDaemon = stopDaemon;
12
+ exports.cleanupDaemonFiles = cleanupDaemonFiles;
13
+ const node_child_process_1 = require("node:child_process");
14
+ const node_fs_1 = require("node:fs");
15
+ const node_path_1 = require("node:path");
16
+ const node_os_1 = require("node:os");
17
+ const node_crypto_1 = require("node:crypto");
18
+ const errors_1 = require("../errors");
19
+ const types_1 = require("./types");
20
+ let resolver = {
21
+ pidFile: () => (0, node_path_1.join)((0, node_os_1.homedir)(), '.padua', 'mcp-server.pid'),
22
+ authFile: () => (0, node_path_1.join)((0, node_os_1.homedir)(), '.padua', 'mcp-auth.json'),
23
+ startupFile: (pid) => (0, node_path_1.join)((0, node_os_1.tmpdir)(), `padua-mcp-${pid}.ready`),
24
+ paduaDir: () => (0, node_path_1.join)((0, node_os_1.homedir)(), '.padua'),
25
+ };
26
+ /** Override path resolution — intended for tests only. */
27
+ function setPathResolver(r) {
28
+ resolver = { ...resolver, ...r };
29
+ }
30
+ /** Reset path resolution to production defaults. */
31
+ function resetPathResolver() {
32
+ resolver = {
33
+ pidFile: () => (0, node_path_1.join)((0, node_os_1.homedir)(), '.padua', 'mcp-server.pid'),
34
+ authFile: () => (0, node_path_1.join)((0, node_os_1.homedir)(), '.padua', 'mcp-auth.json'),
35
+ startupFile: (pid) => (0, node_path_1.join)((0, node_os_1.tmpdir)(), `padua-mcp-${pid}.ready`),
36
+ paduaDir: () => (0, node_path_1.join)((0, node_os_1.homedir)(), '.padua'),
37
+ };
38
+ }
39
+ // ---------------------------------------------------------------------------
40
+ // Public path accessors (delegates to resolver)
41
+ // ---------------------------------------------------------------------------
42
+ function getPidFilePath() {
43
+ return resolver.pidFile();
44
+ }
45
+ function getAuthFilePath() {
46
+ return resolver.authFile();
47
+ }
48
+ function getStartupFilePath(pid) {
49
+ return resolver.startupFile(pid);
50
+ }
51
+ // ---------------------------------------------------------------------------
52
+ // Process liveness check
53
+ // ---------------------------------------------------------------------------
54
+ function isProcessAlive(pid) {
55
+ try {
56
+ process.kill(pid, 0);
57
+ return true;
58
+ }
59
+ catch {
60
+ return false;
61
+ }
62
+ }
63
+ // ---------------------------------------------------------------------------
64
+ // Read existing daemon from PID + auth files
65
+ // ---------------------------------------------------------------------------
66
+ function readExistingDaemon() {
67
+ const pidPath = resolver.pidFile();
68
+ if (!(0, node_fs_1.existsSync)(pidPath)) {
69
+ return null;
70
+ }
71
+ const pid = parseInt((0, node_fs_1.readFileSync)(pidPath, 'utf8').trim(), 10);
72
+ if (!isProcessAlive(pid)) {
73
+ cleanupDaemonFiles(pid);
74
+ return null;
75
+ }
76
+ const authPath = resolver.authFile();
77
+ const raw = JSON.parse((0, node_fs_1.readFileSync)(authPath, 'utf8'));
78
+ const parsed = types_1.McpAuthFileSchema.safeParse(raw);
79
+ if (!parsed.success) {
80
+ cleanupDaemonFiles(pid);
81
+ return null;
82
+ }
83
+ const auth = parsed.data;
84
+ return { pid: auth.pid, port: auth.port, bearerToken: auth.bearerToken, startedAt: auth.startedAt };
85
+ }
86
+ // ---------------------------------------------------------------------------
87
+ // Fork a new daemon process
88
+ // ---------------------------------------------------------------------------
89
+ async function forkDaemon(entryScript, port) {
90
+ const existing = readExistingDaemon();
91
+ if (existing !== null) {
92
+ return existing;
93
+ }
94
+ const bearerToken = (0, node_crypto_1.randomUUID)();
95
+ (0, node_fs_1.mkdirSync)(resolver.paduaDir(), { recursive: true });
96
+ const env = {
97
+ ...process.env,
98
+ PADUA_MCP_PORT: String(port),
99
+ PADUA_MCP_BEARER_TOKEN: bearerToken,
100
+ };
101
+ const child = (0, node_child_process_1.fork)(entryScript, [], { detached: true, stdio: 'ignore', env });
102
+ const childPid = child.pid;
103
+ child.unref();
104
+ writePidFile(childPid);
105
+ writeAuthFile({ bearerToken, port, pid: childPid, startedAt: new Date().toISOString() });
106
+ return pollForStartup(childPid, port, bearerToken);
107
+ }
108
+ // ---------------------------------------------------------------------------
109
+ // Stop daemon by SIGTERM
110
+ // ---------------------------------------------------------------------------
111
+ function stopDaemon() {
112
+ const pidPath = resolver.pidFile();
113
+ if (!(0, node_fs_1.existsSync)(pidPath)) {
114
+ return false;
115
+ }
116
+ const pid = parseInt((0, node_fs_1.readFileSync)(pidPath, 'utf8').trim(), 10);
117
+ try {
118
+ process.kill(pid, 'SIGTERM');
119
+ }
120
+ catch {
121
+ // Process may have already exited — continue to cleanup
122
+ }
123
+ cleanupDaemonFiles(pid);
124
+ return true;
125
+ }
126
+ // ---------------------------------------------------------------------------
127
+ // Cleanup all daemon-related files silently
128
+ // ---------------------------------------------------------------------------
129
+ function cleanupDaemonFiles(pid) {
130
+ removeFileSilently(resolver.pidFile());
131
+ removeFileSilently(resolver.authFile());
132
+ if (pid !== undefined) {
133
+ removeFileSilently(resolver.startupFile(pid));
134
+ }
135
+ }
136
+ // ---------------------------------------------------------------------------
137
+ // Private helpers
138
+ // ---------------------------------------------------------------------------
139
+ function writePidFile(pid) {
140
+ const pidPath = resolver.pidFile();
141
+ (0, node_fs_1.writeFileSync)(pidPath, String(pid), 'utf8');
142
+ (0, node_fs_1.chmodSync)(pidPath, 0o600);
143
+ }
144
+ function writeAuthFile(auth) {
145
+ const authPath = resolver.authFile();
146
+ (0, node_fs_1.writeFileSync)(authPath, JSON.stringify(auth), 'utf8');
147
+ (0, node_fs_1.chmodSync)(authPath, 0o600);
148
+ }
149
+ function removeFileSilently(filePath) {
150
+ try {
151
+ (0, node_fs_1.unlinkSync)(filePath);
152
+ }
153
+ catch (err) {
154
+ if (err.code !== 'ENOENT') {
155
+ throw err;
156
+ }
157
+ }
158
+ }
159
+ function pollForStartup(pid, port, bearerToken) {
160
+ const startupPath = resolver.startupFile(pid);
161
+ const timeoutMs = 10_000;
162
+ const intervalMs = 100;
163
+ const deadline = Date.now() + timeoutMs;
164
+ return new Promise((resolve, reject) => {
165
+ const interval = setInterval(() => {
166
+ if ((0, node_fs_1.existsSync)(startupPath)) {
167
+ clearInterval(interval);
168
+ if (!isProcessAlive(pid)) {
169
+ cleanupDaemonFiles(pid);
170
+ reject(new errors_1.DaemonError('Daemon process died after startup file written', errors_1.ErrorCodes.DAEMON_START_TIMEOUT));
171
+ return;
172
+ }
173
+ resolve({ pid, port, bearerToken, startedAt: new Date().toISOString() });
174
+ return;
175
+ }
176
+ if (Date.now() >= deadline) {
177
+ clearInterval(interval);
178
+ try {
179
+ process.kill(pid, 'SIGKILL');
180
+ }
181
+ catch { /* already dead */ }
182
+ cleanupDaemonFiles(pid);
183
+ reject(new errors_1.DaemonError(`Daemon did not become ready within ${timeoutMs}ms`, errors_1.ErrorCodes.DAEMON_START_TIMEOUT));
184
+ }
185
+ }, intervalMs);
186
+ });
187
+ }
188
+ //# sourceMappingURL=fork.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fork.js","sourceRoot":"","sources":["../../../src/mcp/daemon/fork.ts"],"names":[],"mappings":";;AAmCA,0CAEC;AAGD,8CAOC;AAMD,wCAEC;AAED,0CAEC;AAED,gDAEC;AAMD,wCAOC;AAMD,gDAyBC;AAMD,gCAuBC;AAMD,gCAgBC;AAMD,gDAMC;AA1KD,2DAAoD;AACpD,qCAOiB;AACjB,yCAAiC;AACjC,qCAA0C;AAC1C,6CAAyC;AACzC,sCAAoD;AAEpD,mCAA4C;AAa5C,IAAI,QAAQ,GAAiB;IAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,QAAQ,EAAE,gBAAgB,CAAC;IAC1D,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,QAAQ,EAAE,eAAe,CAAC;IAC1D,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,gBAAI,EAAC,IAAA,gBAAM,GAAE,EAAE,aAAa,GAAG,QAAQ,CAAC;IAC9D,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,QAAQ,CAAC;CAC1C,CAAC;AAEF,0DAA0D;AAC1D,SAAgB,eAAe,CAAC,CAAwB;I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"}
@@ -0,0 +1,8 @@
1
+ import type { DaemonHealthResult } from './types';
2
+ /**
3
+ * Check daemon health by calling GET /health.
4
+ * @param port - Daemon port
5
+ * @param timeoutMs - Request timeout (default 3000ms)
6
+ */
7
+ export declare function checkHealth(port: number, timeoutMs?: number): Promise<DaemonHealthResult>;
8
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/mcp/daemon/health.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,SAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA4CvF"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkHealth = checkHealth;
4
+ const node_http_1 = require("node:http");
5
+ /**
6
+ * Check daemon health by calling GET /health.
7
+ * @param port - Daemon port
8
+ * @param timeoutMs - Request timeout (default 3000ms)
9
+ */
10
+ function checkHealth(port, timeoutMs = 3000) {
11
+ return new Promise((resolve, reject) => {
12
+ const req = (0, node_http_1.request)({
13
+ hostname: '127.0.0.1',
14
+ port,
15
+ path: '/health',
16
+ method: 'GET',
17
+ timeout: timeoutMs,
18
+ }, (res) => {
19
+ let body = '';
20
+ res.on('data', (chunk) => {
21
+ body += chunk;
22
+ });
23
+ res.on('end', () => {
24
+ try {
25
+ const data = JSON.parse(body);
26
+ resolve({
27
+ healthy: res.statusCode === 200,
28
+ status: data.status ?? 'error',
29
+ providers: data.providers ?? {},
30
+ uptime: data.uptime ?? 0,
31
+ version: data.version ?? 'unknown',
32
+ metrics: data.metrics,
33
+ });
34
+ }
35
+ catch {
36
+ reject(new Error(`Invalid health response: ${body}`));
37
+ }
38
+ });
39
+ });
40
+ req.on('timeout', () => {
41
+ req.destroy();
42
+ reject(new Error(`Health check timed out after ${timeoutMs}ms`));
43
+ });
44
+ req.on('error', (err) => {
45
+ reject(new Error(`Health check failed: ${err.message}`));
46
+ });
47
+ req.end();
48
+ });
49
+ }
50
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../../src/mcp/daemon/health.ts"],"names":[],"mappings":";;AAQA,kCA4CC;AApDD,yCAAoC;AAGpC;;;;GAIG;AACH,SAAgB,WAAW,CAAC,IAAY,EAAE,SAAS,GAAG,IAAI;IACxD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,GAAG,GAAG,IAAA,mBAAO,EACjB;YACE,QAAQ,EAAE,WAAW;YACrB,IAAI;YACJ,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,SAAS;SACnB,EACD,CAAC,GAAG,EAAE,EAAE;YACN,IAAI,IAAI,GAAG,EAAE,CAAC;YACd,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBACvB,IAAI,IAAI,KAAK,CAAC;YAChB,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBACjB,IAAI,CAAC;oBACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;oBACzD,OAAO,CAAC;wBACN,OAAO,EAAE,GAAG,CAAC,UAAU,KAAK,GAAG;wBAC/B,MAAM,EAAG,IAAI,CAAC,MAAuC,IAAI,OAAO;wBAChE,SAAS,EAAG,IAAI,CAAC,SAA6C,IAAI,EAAE;wBACpE,MAAM,EAAG,IAAI,CAAC,MAAiB,IAAI,CAAC;wBACpC,OAAO,EAAG,IAAI,CAAC,OAAkB,IAAI,SAAS;wBAC9C,OAAO,EAAE,IAAI,CAAC,OAAwC;qBACvD,CAAC,CAAC;gBACL,CAAC;gBAAC,MAAM,CAAC;oBACP,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,IAAI,EAAE,CAAC,CAAC,CAAC;gBACxD,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CACF,CAAC;QAEF,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YACrB,GAAG,CAAC,OAAO,EAAE,CAAC;YACd,MAAM,CAAC,IAAI,KAAK,CAAC,gCAAgC,SAAS,IAAI,CAAC,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACtB,MAAM,CAAC,IAAI,KAAK,CAAC,wBAAwB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type { DaemonInfo, DaemonHealthResult, McpAuthFile, DaemonStartupFile } from './types';
2
+ export { McpAuthFileSchema, DaemonStartupFileSchema } from './types';
3
+ export { checkHealth } from './health';
4
+ export { forkDaemon, stopDaemon, readExistingDaemon, isProcessAlive, cleanupDaemonFiles, getPidFilePath, getAuthFilePath, getStartupFilePath, } from './fork';
5
+ export { writeStartupFile, cleanupOnShutdown, getPackageVersion } from './entry-logic';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/daemon/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPackageVersion = exports.cleanupOnShutdown = exports.writeStartupFile = exports.getStartupFilePath = exports.getAuthFilePath = exports.getPidFilePath = exports.cleanupDaemonFiles = exports.isProcessAlive = exports.readExistingDaemon = exports.stopDaemon = exports.forkDaemon = exports.checkHealth = exports.DaemonStartupFileSchema = exports.McpAuthFileSchema = void 0;
4
+ var types_1 = require("./types");
5
+ Object.defineProperty(exports, "McpAuthFileSchema", { enumerable: true, get: function () { return types_1.McpAuthFileSchema; } });
6
+ Object.defineProperty(exports, "DaemonStartupFileSchema", { enumerable: true, get: function () { return types_1.DaemonStartupFileSchema; } });
7
+ var health_1 = require("./health");
8
+ Object.defineProperty(exports, "checkHealth", { enumerable: true, get: function () { return health_1.checkHealth; } });
9
+ var fork_1 = require("./fork");
10
+ Object.defineProperty(exports, "forkDaemon", { enumerable: true, get: function () { return fork_1.forkDaemon; } });
11
+ Object.defineProperty(exports, "stopDaemon", { enumerable: true, get: function () { return fork_1.stopDaemon; } });
12
+ Object.defineProperty(exports, "readExistingDaemon", { enumerable: true, get: function () { return fork_1.readExistingDaemon; } });
13
+ Object.defineProperty(exports, "isProcessAlive", { enumerable: true, get: function () { return fork_1.isProcessAlive; } });
14
+ Object.defineProperty(exports, "cleanupDaemonFiles", { enumerable: true, get: function () { return fork_1.cleanupDaemonFiles; } });
15
+ Object.defineProperty(exports, "getPidFilePath", { enumerable: true, get: function () { return fork_1.getPidFilePath; } });
16
+ Object.defineProperty(exports, "getAuthFilePath", { enumerable: true, get: function () { return fork_1.getAuthFilePath; } });
17
+ Object.defineProperty(exports, "getStartupFilePath", { enumerable: true, get: function () { return fork_1.getStartupFilePath; } });
18
+ var entry_logic_1 = require("./entry-logic");
19
+ Object.defineProperty(exports, "writeStartupFile", { enumerable: true, get: function () { return entry_logic_1.writeStartupFile; } });
20
+ Object.defineProperty(exports, "cleanupOnShutdown", { enumerable: true, get: function () { return entry_logic_1.cleanupOnShutdown; } });
21
+ Object.defineProperty(exports, "getPackageVersion", { enumerable: true, get: function () { return entry_logic_1.getPackageVersion; } });
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/daemon/index.ts"],"names":[],"mappings":";;;AACA,iCAAqE;AAA5D,0GAAA,iBAAiB,OAAA;AAAE,gHAAA,uBAAuB,OAAA;AAEnD,mCAAuC;AAA9B,qGAAA,WAAW,OAAA;AACpB,+BASgB;AARd,kGAAA,UAAU,OAAA;AACV,kGAAA,UAAU,OAAA;AACV,0GAAA,kBAAkB,OAAA;AAClB,sGAAA,cAAc,OAAA;AACd,0GAAA,kBAAkB,OAAA;AAClB,sGAAA,cAAc,OAAA;AACd,uGAAA,eAAe,OAAA;AACf,0GAAA,kBAAkB,OAAA;AAGpB,6CAAuF;AAA9E,+GAAA,gBAAgB,OAAA;AAAE,gHAAA,iBAAiB,OAAA;AAAE,gHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,63 @@
1
+ import { z } from 'zod';
2
+ export interface DaemonInfo {
3
+ pid: number;
4
+ port: number;
5
+ bearerToken: string;
6
+ startedAt: string;
7
+ }
8
+ export interface DaemonHealthResult {
9
+ healthy: boolean;
10
+ status: 'ok' | 'degraded' | 'error';
11
+ providers: Record<string, 'ready' | 'error'>;
12
+ uptime: number;
13
+ version: string;
14
+ metrics?: {
15
+ toolCallsTotal: number;
16
+ toolCallErrors: number;
17
+ tokenRefreshTotal: number;
18
+ tokenRefreshErrors: number;
19
+ };
20
+ }
21
+ export interface McpAuthFile {
22
+ bearerToken: string;
23
+ port: number;
24
+ pid: number;
25
+ startedAt: string;
26
+ }
27
+ export interface DaemonStartupFile {
28
+ pid: number;
29
+ port: number;
30
+ readyAt: string;
31
+ }
32
+ /** Zod schema for mcp-auth.json validation on read */
33
+ export declare const McpAuthFileSchema: z.ZodObject<{
34
+ bearerToken: z.ZodString;
35
+ port: z.ZodNumber;
36
+ pid: z.ZodNumber;
37
+ startedAt: z.ZodString;
38
+ }, "strip", z.ZodTypeAny, {
39
+ port: number;
40
+ bearerToken: string;
41
+ pid: number;
42
+ startedAt: string;
43
+ }, {
44
+ port: number;
45
+ bearerToken: string;
46
+ pid: number;
47
+ startedAt: string;
48
+ }>;
49
+ /** Zod schema for startup confirmation file */
50
+ export declare const DaemonStartupFileSchema: z.ZodObject<{
51
+ pid: z.ZodNumber;
52
+ port: z.ZodNumber;
53
+ readyAt: z.ZodString;
54
+ }, "strip", z.ZodTypeAny, {
55
+ port: number;
56
+ pid: number;
57
+ readyAt: string;
58
+ }, {
59
+ port: number;
60
+ pid: number;
61
+ readyAt: string;
62
+ }>;
63
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/mcp/daemon/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,IAAI,GAAG,UAAU,GAAG,OAAO,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE;QACR,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,sDAAsD;AACtD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;EAK5B,CAAC;AAEH,+CAA+C;AAC/C,eAAO,MAAM,uBAAuB;;;;;;;;;;;;EAIlC,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DaemonStartupFileSchema = exports.McpAuthFileSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /** Zod schema for mcp-auth.json validation on read */
6
+ exports.McpAuthFileSchema = zod_1.z.object({
7
+ bearerToken: zod_1.z.string().uuid(),
8
+ port: zod_1.z.number().int().min(1025).max(65535),
9
+ pid: zod_1.z.number().int().positive(),
10
+ startedAt: zod_1.z.string(),
11
+ });
12
+ /** Zod schema for startup confirmation file */
13
+ exports.DaemonStartupFileSchema = zod_1.z.object({
14
+ pid: zod_1.z.number().int().positive(),
15
+ port: zod_1.z.number().int().min(1025).max(65535),
16
+ readyAt: zod_1.z.string(),
17
+ });
18
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/mcp/daemon/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAoCxB,sDAAsD;AACzC,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC9B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;IAC3C,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAEH,+CAA+C;AAClC,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAChC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;IAC3C,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { redactTokens, PaduaError, StoreError, AuthError, DaemonError, ValidationError, ProviderError, ErrorCodes, } from './types';
2
+ export type { ErrorCode } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorCodes = exports.ProviderError = exports.ValidationError = exports.DaemonError = exports.AuthError = exports.StoreError = exports.PaduaError = exports.redactTokens = void 0;
4
+ var types_1 = require("./types");
5
+ Object.defineProperty(exports, "redactTokens", { enumerable: true, get: function () { return types_1.redactTokens; } });
6
+ Object.defineProperty(exports, "PaduaError", { enumerable: true, get: function () { return types_1.PaduaError; } });
7
+ Object.defineProperty(exports, "StoreError", { enumerable: true, get: function () { return types_1.StoreError; } });
8
+ Object.defineProperty(exports, "AuthError", { enumerable: true, get: function () { return types_1.AuthError; } });
9
+ Object.defineProperty(exports, "DaemonError", { enumerable: true, get: function () { return types_1.DaemonError; } });
10
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return types_1.ValidationError; } });
11
+ Object.defineProperty(exports, "ProviderError", { enumerable: true, get: function () { return types_1.ProviderError; } });
12
+ Object.defineProperty(exports, "ErrorCodes", { enumerable: true, get: function () { return types_1.ErrorCodes; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/errors/index.ts"],"names":[],"mappings":";;;AAAA,iCASiB;AARf,qGAAA,YAAY,OAAA;AACZ,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AACV,kGAAA,SAAS,OAAA;AACT,oGAAA,WAAW,OAAA;AACX,wGAAA,eAAe,OAAA;AACf,sGAAA,aAAa,OAAA;AACb,mGAAA,UAAU,OAAA"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Error hierarchy for the MCP server integration.
3
+ *
4
+ * All errors extend PaduaError so callers can catch at different granularities.
5
+ * Token redaction is applied to every message at construction time to prevent
6
+ * credential exposure in logs and error reporting pipelines.
7
+ */
8
+ /**
9
+ * Replaces credential-like patterns in a message string with [REDACTED].
10
+ *
11
+ * Patterns covered:
12
+ * - Bearer <token> in Authorization headers
13
+ * - access_token / refresh_token / accessToken / refreshToken in JSON or query strings
14
+ * - Hex strings longer than 20 characters (encryption keys, nonces)
15
+ * - Base64-like strings longer than 30 characters (JWT segments, encoded secrets)
16
+ */
17
+ export declare function redactTokens(message: string): string;
18
+ /**
19
+ * Base error for all Padua MCP operations.
20
+ * Carries a machine-readable code alongside the human-readable message.
21
+ * Messages are token-redacted at construction time.
22
+ */
23
+ export declare class PaduaError extends Error {
24
+ readonly code: string;
25
+ constructor(message: string, code: string);
26
+ }
27
+ /** Errors originating from the encrypted SQLite token store. */
28
+ export declare class StoreError extends PaduaError {
29
+ constructor(message: string, code: string);
30
+ }
31
+ /** Errors originating from OAuth flows and token lifecycle management. */
32
+ export declare class AuthError extends PaduaError {
33
+ constructor(message: string, code: string);
34
+ }
35
+ /** Errors originating from the background daemon process lifecycle. */
36
+ export declare class DaemonError extends PaduaError {
37
+ constructor(message: string, code: string);
38
+ }
39
+ /** Errors originating from config or input validation failures. */
40
+ export declare class ValidationError extends PaduaError {
41
+ constructor(message: string, code: string);
42
+ }
43
+ /**
44
+ * Errors originating from a specific provider (GitLab, Atlassian).
45
+ * The `provider` property identifies which provider produced the error.
46
+ */
47
+ export declare class ProviderError extends PaduaError {
48
+ readonly provider: string;
49
+ constructor(message: string, code: string, provider: string);
50
+ }
51
+ /**
52
+ * Exhaustive catalog of machine-readable error codes used throughout the MCP
53
+ * server integration. Every error instantiation must use one of these constants.
54
+ *
55
+ * Grouped by the error subclass that typically throws them.
56
+ */
57
+ export declare const ErrorCodes: {
58
+ readonly ENCRYPTION_KEY_UNAVAILABLE: "ENCRYPTION_KEY_UNAVAILABLE";
59
+ readonly TOKEN_DECRYPTION_FAILED: "TOKEN_DECRYPTION_FAILED";
60
+ readonly DB_OPEN_FAILED: "DB_OPEN_FAILED";
61
+ readonly DB_WRITE_FAILED: "DB_WRITE_FAILED";
62
+ readonly CALLBACK_PORT_IN_USE: "CALLBACK_PORT_IN_USE";
63
+ readonly OAUTH_CALLBACK_ERROR: "OAUTH_CALLBACK_ERROR";
64
+ readonly OAUTH_STATE_EXPIRED: "OAUTH_STATE_EXPIRED";
65
+ readonly OAUTH_CALLBACK_TIMEOUT: "OAUTH_CALLBACK_TIMEOUT";
66
+ readonly OAUTH_CODE_EXCHANGE_FAILED: "OAUTH_CODE_EXCHANGE_FAILED";
67
+ readonly TOKEN_REFRESH_FAILED: "TOKEN_REFRESH_FAILED";
68
+ readonly CIRCUIT_BREAKER_OPEN: "CIRCUIT_BREAKER_OPEN";
69
+ readonly DAEMON_START_TIMEOUT: "DAEMON_START_TIMEOUT";
70
+ readonly DAEMON_ALREADY_RUNNING: "DAEMON_ALREADY_RUNNING";
71
+ readonly DAEMON_STALE_PID: "DAEMON_STALE_PID";
72
+ readonly DAEMON_HEALTH_FAILED: "DAEMON_HEALTH_FAILED";
73
+ readonly DAEMON_PORT_IN_USE: "DAEMON_PORT_IN_USE";
74
+ readonly INVALID_CONFIG: "INVALID_CONFIG";
75
+ readonly MARKDOWN_TOO_LARGE: "MARKDOWN_TOO_LARGE";
76
+ readonly API_TIMEOUT: "API_TIMEOUT";
77
+ readonly API_RATE_LIMITED: "API_RATE_LIMITED";
78
+ readonly API_UNAUTHORIZED: "API_UNAUTHORIZED";
79
+ readonly CLOUD_ID_RESOLUTION_FAILED: "CLOUD_ID_RESOLUTION_FAILED";
80
+ };
81
+ /** Union type of all valid error code string literals. */
82
+ export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
83
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/mcp/errors/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAqBpD;AAMD;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAO1C;AAMD,gEAAgE;AAChE,qBAAa,UAAW,SAAQ,UAAU;gBAC5B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAK1C;AAED,0EAA0E;AAC1E,qBAAa,SAAU,SAAQ,UAAU;gBAC3B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAK1C;AAED,uEAAuE;AACvE,qBAAa,WAAY,SAAQ,UAAU;gBAC7B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAK1C;AAED,mEAAmE;AACnE,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAK1C;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,UAAU;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAM5D;AAMD;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;CAgCb,CAAC;AAEX,0DAA0D;AAC1D,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC"}