@structured-world/gitlab-mcp 6.62.1 → 7.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 (435) hide show
  1. package/README.md +22 -1
  2. package/README.md.in +21 -0
  3. package/dist/generated/prisma/client.js.map +1 -1
  4. package/dist/generated/prisma/internal/class.js +2 -2
  5. package/dist/generated/prisma/internal/class.js.map +1 -1
  6. package/dist/generated/prisma/internal/prismaNamespace.js +2 -2
  7. package/dist/generated/prisma/models/AuthCodeFlowState.d.ts +1 -2
  8. package/dist/generated/prisma/models/AuthorizationCode.d.ts +1 -2
  9. package/dist/generated/prisma/models/DeviceFlowState.d.ts +1 -2
  10. package/dist/generated/prisma/models/McpSessionMapping.d.ts +1 -2
  11. package/dist/generated/prisma/models/OAuthSession.d.ts +1 -2
  12. package/dist/src/cli/docker/container-runtime.d.ts +1 -1
  13. package/dist/src/cli/docker/container-runtime.js +14 -14
  14. package/dist/src/cli/docker/docker-command.d.ts +1 -1
  15. package/dist/src/cli/docker/docker-command.js +113 -113
  16. package/dist/src/cli/docker/docker-command.js.map +1 -1
  17. package/dist/src/cli/docker/docker-utils.d.ts +3 -3
  18. package/dist/src/cli/docker/docker-utils.js +74 -74
  19. package/dist/src/cli/docker/docker-utils.js.map +1 -1
  20. package/dist/src/cli/docker/index.d.ts +4 -4
  21. package/dist/src/cli/docker/types.d.ts +3 -3
  22. package/dist/src/cli/docker/types.js +5 -5
  23. package/dist/src/cli/init/browser.js +2 -2
  24. package/dist/src/cli/init/config-generator.d.ts +2 -2
  25. package/dist/src/cli/init/config-generator.js +22 -22
  26. package/dist/src/cli/init/connection.d.ts +1 -1
  27. package/dist/src/cli/init/connection.js +27 -27
  28. package/dist/src/cli/init/connection.js.map +1 -1
  29. package/dist/src/cli/init/index.d.ts +4 -4
  30. package/dist/src/cli/init/types.d.ts +3 -3
  31. package/dist/src/cli/init/types.js +36 -36
  32. package/dist/src/cli/init/wizard.js +80 -80
  33. package/dist/src/cli/init/wizard.js.map +1 -1
  34. package/dist/src/cli/inject-tool-refs.js +47 -47
  35. package/dist/src/cli/inject-tool-refs.js.map +1 -1
  36. package/dist/src/cli/install/backup.d.ts +1 -1
  37. package/dist/src/cli/install/backup.js +3 -3
  38. package/dist/src/cli/install/detector.d.ts +2 -2
  39. package/dist/src/cli/install/detector.js +18 -18
  40. package/dist/src/cli/install/detector.js.map +1 -1
  41. package/dist/src/cli/install/index.d.ts +5 -5
  42. package/dist/src/cli/install/install-command.d.ts +2 -2
  43. package/dist/src/cli/install/install-command.js +68 -68
  44. package/dist/src/cli/install/install-command.js.map +1 -1
  45. package/dist/src/cli/install/installers.d.ts +2 -2
  46. package/dist/src/cli/install/installers.js +55 -55
  47. package/dist/src/cli/install/installers.js.map +1 -1
  48. package/dist/src/cli/install/types.d.ts +4 -4
  49. package/dist/src/cli/install/types.js +48 -48
  50. package/dist/src/cli/instances/index.d.ts +2 -2
  51. package/dist/src/cli/instances/instances-command.d.ts +1 -1
  52. package/dist/src/cli/instances/instances-command.js +70 -66
  53. package/dist/src/cli/instances/instances-command.js.map +1 -1
  54. package/dist/src/cli/list-tools.js +396 -396
  55. package/dist/src/cli/list-tools.js.map +1 -1
  56. package/dist/src/cli/setup/discovery.d.ts +1 -1
  57. package/dist/src/cli/setup/discovery.js +10 -10
  58. package/dist/src/cli/setup/discovery.js.map +1 -1
  59. package/dist/src/cli/setup/flows/configure-existing.d.ts +1 -1
  60. package/dist/src/cli/setup/flows/configure-existing.js +57 -57
  61. package/dist/src/cli/setup/flows/configure-existing.js.map +1 -1
  62. package/dist/src/cli/setup/flows/local-setup.d.ts +1 -1
  63. package/dist/src/cli/setup/flows/local-setup.js +51 -51
  64. package/dist/src/cli/setup/flows/local-setup.js.map +1 -1
  65. package/dist/src/cli/setup/flows/server-setup.d.ts +1 -1
  66. package/dist/src/cli/setup/flows/server-setup.js +50 -50
  67. package/dist/src/cli/setup/flows/server-setup.js.map +1 -1
  68. package/dist/src/cli/setup/flows/tool-selection.d.ts +1 -1
  69. package/dist/src/cli/setup/flows/tool-selection.js +94 -94
  70. package/dist/src/cli/setup/flows/tool-selection.js.map +1 -1
  71. package/dist/src/cli/setup/index.d.ts +4 -4
  72. package/dist/src/cli/setup/presets.d.ts +1 -1
  73. package/dist/src/cli/setup/presets.js +157 -157
  74. package/dist/src/cli/setup/presets.js.map +1 -1
  75. package/dist/src/cli/setup/types.d.ts +7 -7
  76. package/dist/src/cli/setup/wizard.d.ts +1 -1
  77. package/dist/src/cli/setup/wizard.js +25 -25
  78. package/dist/src/cli/utils/index.d.ts +1 -1
  79. package/dist/src/cli/utils/path-utils.js +3 -3
  80. package/dist/src/cli-utils.d.ts +2 -2
  81. package/dist/src/cli-utils.js +46 -46
  82. package/dist/src/config/index.d.ts +4 -4
  83. package/dist/src/config/instances-loader.d.ts +3 -3
  84. package/dist/src/config/instances-loader.js +53 -53
  85. package/dist/src/config/instances-loader.js.map +1 -1
  86. package/dist/src/config/instances-schema.d.ts +1 -1
  87. package/dist/src/config/instances-schema.js +33 -33
  88. package/dist/src/config/instances-schema.js.map +1 -1
  89. package/dist/src/config.d.ts +11 -4
  90. package/dist/src/config.js +112 -111
  91. package/dist/src/config.js.map +1 -1
  92. package/dist/src/dashboard/handler.d.ts +2 -2
  93. package/dist/src/dashboard/handler.js +7 -7
  94. package/dist/src/dashboard/html-template.d.ts +1 -1
  95. package/dist/src/dashboard/html-template.js +44 -44
  96. package/dist/src/dashboard/html-template.js.map +1 -1
  97. package/dist/src/dashboard/index.d.ts +4 -4
  98. package/dist/src/dashboard/metrics.d.ts +3 -3
  99. package/dist/src/dashboard/metrics.js +42 -42
  100. package/dist/src/discovery/auto.d.ts +3 -3
  101. package/dist/src/discovery/auto.js +28 -28
  102. package/dist/src/discovery/git-remote.d.ts +2 -2
  103. package/dist/src/discovery/git-remote.js +18 -18
  104. package/dist/src/discovery/index.d.ts +3 -3
  105. package/dist/src/discovery/profile-matcher.d.ts +2 -2
  106. package/dist/src/discovery/profile-matcher.js +8 -8
  107. package/dist/src/discovery/profile-matcher.js.map +1 -1
  108. package/dist/src/entities/context/context-manager.d.ts +3 -3
  109. package/dist/src/entities/context/context-manager.js +34 -34
  110. package/dist/src/entities/context/context-manager.js.map +1 -1
  111. package/dist/src/entities/context/handlers.d.ts +2 -2
  112. package/dist/src/entities/context/handlers.js +8 -8
  113. package/dist/src/entities/context/index.d.ts +8 -8
  114. package/dist/src/entities/context/index.js +1 -1
  115. package/dist/src/entities/context/registry.d.ts +1 -1
  116. package/dist/src/entities/context/registry.js +4 -4
  117. package/dist/src/entities/context/schema.d.ts +1 -1
  118. package/dist/src/entities/context/schema.js +19 -19
  119. package/dist/src/entities/context/types.d.ts +9 -9
  120. package/dist/src/entities/context/whoami.d.ts +1 -1
  121. package/dist/src/entities/context/whoami.js +31 -31
  122. package/dist/src/entities/context/whoami.js.map +1 -1
  123. package/dist/src/entities/core/index.d.ts +5 -5
  124. package/dist/src/entities/core/index.js +1 -1
  125. package/dist/src/entities/core/registry.d.ts +1 -1
  126. package/dist/src/entities/core/registry.js +194 -194
  127. package/dist/src/entities/core/registry.js.map +1 -1
  128. package/dist/src/entities/core/schema-readonly.d.ts +1 -1
  129. package/dist/src/entities/core/schema-readonly.js +117 -117
  130. package/dist/src/entities/core/schema.d.ts +1 -1
  131. package/dist/src/entities/core/schema.js +67 -67
  132. package/dist/src/entities/files/index.d.ts +5 -5
  133. package/dist/src/entities/files/index.js +1 -1
  134. package/dist/src/entities/files/registry.d.ts +1 -1
  135. package/dist/src/entities/files/registry.js +45 -45
  136. package/dist/src/entities/files/registry.js.map +1 -1
  137. package/dist/src/entities/files/schema-readonly.d.ts +1 -1
  138. package/dist/src/entities/files/schema-readonly.js +13 -13
  139. package/dist/src/entities/files/schema.d.ts +1 -1
  140. package/dist/src/entities/files/schema.js +29 -29
  141. package/dist/src/entities/index.d.ts +17 -17
  142. package/dist/src/entities/integrations/index.d.ts +4 -4
  143. package/dist/src/entities/integrations/registry.d.ts +1 -1
  144. package/dist/src/entities/integrations/registry.js +17 -17
  145. package/dist/src/entities/integrations/registry.js.map +1 -1
  146. package/dist/src/entities/integrations/schema-readonly.d.ts +1 -1
  147. package/dist/src/entities/integrations/schema-readonly.js +5 -5
  148. package/dist/src/entities/integrations/schema.d.ts +1 -1
  149. package/dist/src/entities/integrations/schema.js +69 -69
  150. package/dist/src/entities/iterations/index.d.ts +2 -2
  151. package/dist/src/entities/iterations/registry.d.ts +1 -1
  152. package/dist/src/entities/iterations/registry.js +13 -13
  153. package/dist/src/entities/iterations/registry.js.map +1 -1
  154. package/dist/src/entities/iterations/schema-readonly.d.ts +1 -1
  155. package/dist/src/entities/iterations/schema-readonly.js +9 -9
  156. package/dist/src/entities/labels/index.d.ts +5 -5
  157. package/dist/src/entities/labels/index.js +1 -1
  158. package/dist/src/entities/labels/registry.d.ts +1 -1
  159. package/dist/src/entities/labels/registry.js +19 -19
  160. package/dist/src/entities/labels/registry.js.map +1 -1
  161. package/dist/src/entities/labels/schema-readonly.d.ts +1 -1
  162. package/dist/src/entities/labels/schema-readonly.js +8 -8
  163. package/dist/src/entities/labels/schema.d.ts +1 -1
  164. package/dist/src/entities/labels/schema.js +11 -11
  165. package/dist/src/entities/members/index.d.ts +3 -3
  166. package/dist/src/entities/members/registry.d.ts +1 -1
  167. package/dist/src/entities/members/registry.js +26 -26
  168. package/dist/src/entities/members/registry.js.map +1 -1
  169. package/dist/src/entities/members/schema-readonly.d.ts +1 -1
  170. package/dist/src/entities/members/schema-readonly.js +32 -32
  171. package/dist/src/entities/members/schema-readonly.js.map +1 -1
  172. package/dist/src/entities/members/schema.d.ts +1 -1
  173. package/dist/src/entities/members/schema.js +28 -28
  174. package/dist/src/entities/milestones/index.d.ts +5 -5
  175. package/dist/src/entities/milestones/index.js +1 -1
  176. package/dist/src/entities/milestones/registry.d.ts +1 -1
  177. package/dist/src/entities/milestones/registry.js +25 -25
  178. package/dist/src/entities/milestones/registry.js.map +1 -1
  179. package/dist/src/entities/milestones/schema-readonly.d.ts +2 -2
  180. package/dist/src/entities/milestones/schema-readonly.js +15 -15
  181. package/dist/src/entities/milestones/schema.d.ts +1 -1
  182. package/dist/src/entities/milestones/schema.js +16 -16
  183. package/dist/src/entities/milestones/schema.js.map +1 -1
  184. package/dist/src/entities/mrs/index.d.ts +5 -5
  185. package/dist/src/entities/mrs/index.js +1 -1
  186. package/dist/src/entities/mrs/registry.d.ts +1 -1
  187. package/dist/src/entities/mrs/registry.js +102 -102
  188. package/dist/src/entities/mrs/registry.js.map +1 -1
  189. package/dist/src/entities/mrs/schema-readonly.d.ts +1 -1
  190. package/dist/src/entities/mrs/schema-readonly.js +126 -126
  191. package/dist/src/entities/mrs/schema-readonly.js.map +1 -1
  192. package/dist/src/entities/mrs/schema.d.ts +1 -1
  193. package/dist/src/entities/mrs/schema.js +111 -111
  194. package/dist/src/entities/mrs/schema.js.map +1 -1
  195. package/dist/src/entities/pipelines/index.d.ts +5 -5
  196. package/dist/src/entities/pipelines/index.js +1 -1
  197. package/dist/src/entities/pipelines/registry.d.ts +1 -1
  198. package/dist/src/entities/pipelines/registry.js +45 -45
  199. package/dist/src/entities/pipelines/registry.js.map +1 -1
  200. package/dist/src/entities/pipelines/schema-readonly.d.ts +2 -2
  201. package/dist/src/entities/pipelines/schema-readonly.js +73 -73
  202. package/dist/src/entities/pipelines/schema.d.ts +1 -1
  203. package/dist/src/entities/pipelines/schema.js +21 -21
  204. package/dist/src/entities/refs/index.d.ts +3 -3
  205. package/dist/src/entities/refs/registry.d.ts +1 -1
  206. package/dist/src/entities/refs/registry.js +31 -31
  207. package/dist/src/entities/refs/registry.js.map +1 -1
  208. package/dist/src/entities/refs/schema-readonly.d.ts +1 -1
  209. package/dist/src/entities/refs/schema-readonly.js +21 -21
  210. package/dist/src/entities/refs/schema.d.ts +1 -1
  211. package/dist/src/entities/refs/schema.js +56 -56
  212. package/dist/src/entities/releases/index.d.ts +3 -3
  213. package/dist/src/entities/releases/registry.d.ts +1 -1
  214. package/dist/src/entities/releases/registry.js +21 -21
  215. package/dist/src/entities/releases/registry.js.map +1 -1
  216. package/dist/src/entities/releases/schema-readonly.d.ts +1 -1
  217. package/dist/src/entities/releases/schema-readonly.js +13 -13
  218. package/dist/src/entities/releases/schema.d.ts +1 -1
  219. package/dist/src/entities/releases/schema.js +21 -21
  220. package/dist/src/entities/search/index.d.ts +2 -2
  221. package/dist/src/entities/search/registry.d.ts +1 -1
  222. package/dist/src/entities/search/registry.js +13 -13
  223. package/dist/src/entities/search/schema-readonly.d.ts +1 -1
  224. package/dist/src/entities/search/schema-readonly.js +23 -23
  225. package/dist/src/entities/shared.d.ts +1 -1
  226. package/dist/src/entities/shared.js +5 -5
  227. package/dist/src/entities/snippets/index.d.ts +5 -5
  228. package/dist/src/entities/snippets/index.js +1 -1
  229. package/dist/src/entities/snippets/registry.d.ts +1 -1
  230. package/dist/src/entities/snippets/registry.js +24 -24
  231. package/dist/src/entities/snippets/registry.js.map +1 -1
  232. package/dist/src/entities/snippets/schema-readonly.d.ts +1 -1
  233. package/dist/src/entities/snippets/schema-readonly.js +11 -11
  234. package/dist/src/entities/snippets/schema.d.ts +1 -1
  235. package/dist/src/entities/snippets/schema.js +27 -27
  236. package/dist/src/entities/snippets/schema.js.map +1 -1
  237. package/dist/src/entities/utils.d.ts +2 -2
  238. package/dist/src/entities/utils.js +8 -8
  239. package/dist/src/entities/utils.js.map +1 -1
  240. package/dist/src/entities/variables/index.d.ts +5 -5
  241. package/dist/src/entities/variables/index.js +1 -1
  242. package/dist/src/entities/variables/registry.d.ts +1 -1
  243. package/dist/src/entities/variables/registry.js +22 -22
  244. package/dist/src/entities/variables/registry.js.map +1 -1
  245. package/dist/src/entities/variables/schema-readonly.d.ts +1 -1
  246. package/dist/src/entities/variables/schema-readonly.js +6 -6
  247. package/dist/src/entities/variables/schema.d.ts +1 -1
  248. package/dist/src/entities/variables/schema.js +21 -21
  249. package/dist/src/entities/variables/schema.js.map +1 -1
  250. package/dist/src/entities/webhooks/index.d.ts +4 -4
  251. package/dist/src/entities/webhooks/registry.d.ts +1 -1
  252. package/dist/src/entities/webhooks/registry.js +29 -29
  253. package/dist/src/entities/webhooks/registry.js.map +1 -1
  254. package/dist/src/entities/webhooks/schema-readonly.d.ts +1 -1
  255. package/dist/src/entities/webhooks/schema-readonly.js +9 -9
  256. package/dist/src/entities/webhooks/schema.d.ts +1 -1
  257. package/dist/src/entities/webhooks/schema.js +59 -59
  258. package/dist/src/entities/wiki/index.d.ts +5 -5
  259. package/dist/src/entities/wiki/index.js +1 -1
  260. package/dist/src/entities/wiki/registry.d.ts +1 -1
  261. package/dist/src/entities/wiki/registry.js +19 -19
  262. package/dist/src/entities/wiki/registry.js.map +1 -1
  263. package/dist/src/entities/wiki/schema-readonly.d.ts +1 -1
  264. package/dist/src/entities/wiki/schema-readonly.js +6 -6
  265. package/dist/src/entities/wiki/schema.d.ts +1 -1
  266. package/dist/src/entities/wiki/schema.js +12 -12
  267. package/dist/src/entities/workitems/index.d.ts +5 -5
  268. package/dist/src/entities/workitems/index.js +1 -1
  269. package/dist/src/entities/workitems/registry.d.ts +1 -1
  270. package/dist/src/entities/workitems/registry.js +101 -101
  271. package/dist/src/entities/workitems/registry.js.map +1 -1
  272. package/dist/src/entities/workitems/schema-readonly.d.ts +1 -1
  273. package/dist/src/entities/workitems/schema-readonly.js +27 -27
  274. package/dist/src/entities/workitems/schema-readonly.js.map +1 -1
  275. package/dist/src/entities/workitems/schema.d.ts +1 -1
  276. package/dist/src/entities/workitems/schema.js +58 -58
  277. package/dist/src/graphql/DynamicWorkItemsQuery.d.ts +2 -2
  278. package/dist/src/graphql/DynamicWorkItemsQuery.js +47 -47
  279. package/dist/src/graphql/DynamicWorkItemsQuery.js.map +1 -1
  280. package/dist/src/graphql/client.d.ts +1 -1
  281. package/dist/src/graphql/client.js +4 -4
  282. package/dist/src/graphql/client.js.map +1 -1
  283. package/dist/src/graphql/index.d.ts +2 -2
  284. package/dist/src/graphql/workItems.d.ts +38 -38
  285. package/dist/src/graphql/workItems.js +30 -30
  286. package/dist/src/handlers.d.ts +2 -1
  287. package/dist/src/handlers.js +258 -86
  288. package/dist/src/handlers.js.map +1 -1
  289. package/dist/src/http-client.js +3 -3
  290. package/dist/src/logger.js +25 -25
  291. package/dist/src/logging/access-log.d.ts +2 -2
  292. package/dist/src/logging/access-log.js +25 -25
  293. package/dist/src/logging/connection-tracker.d.ts +1 -1
  294. package/dist/src/logging/connection-tracker.js +3 -3
  295. package/dist/src/logging/index.d.ts +5 -5
  296. package/dist/src/logging/request-tracker.d.ts +3 -3
  297. package/dist/src/logging/request-tracker.js +4 -4
  298. package/dist/src/logging/types.d.ts +3 -3
  299. package/dist/src/logging/types.js +1 -1
  300. package/dist/src/logging/types.js.map +1 -1
  301. package/dist/src/main.js +28 -28
  302. package/dist/src/middleware/index.d.ts +3 -2
  303. package/dist/src/middleware/index.js +3 -1
  304. package/dist/src/middleware/index.js.map +1 -1
  305. package/dist/src/middleware/oauth-auth.d.ts +1 -1
  306. package/dist/src/middleware/oauth-auth.js +17 -17
  307. package/dist/src/middleware/rate-limiter.d.ts +1 -1
  308. package/dist/src/middleware/rate-limiter.js +32 -32
  309. package/dist/src/middleware/response-write-timeout.d.ts +2 -0
  310. package/dist/src/middleware/response-write-timeout.js +62 -0
  311. package/dist/src/middleware/response-write-timeout.js.map +1 -0
  312. package/dist/src/oauth/config.d.ts +1 -1
  313. package/dist/src/oauth/config.js +18 -18
  314. package/dist/src/oauth/config.js.map +1 -1
  315. package/dist/src/oauth/endpoints/authorize.d.ts +1 -1
  316. package/dist/src/oauth/endpoints/authorize.js +32 -32
  317. package/dist/src/oauth/endpoints/callback.d.ts +1 -1
  318. package/dist/src/oauth/endpoints/callback.js +26 -26
  319. package/dist/src/oauth/endpoints/index.d.ts +5 -5
  320. package/dist/src/oauth/endpoints/metadata.d.ts +1 -1
  321. package/dist/src/oauth/endpoints/metadata.js +12 -12
  322. package/dist/src/oauth/endpoints/register.d.ts +1 -1
  323. package/dist/src/oauth/endpoints/register.js +9 -9
  324. package/dist/src/oauth/endpoints/token.d.ts +1 -1
  325. package/dist/src/oauth/endpoints/token.js +28 -28
  326. package/dist/src/oauth/gitlab-device-flow.d.ts +2 -2
  327. package/dist/src/oauth/gitlab-device-flow.js +73 -68
  328. package/dist/src/oauth/gitlab-device-flow.js.map +1 -1
  329. package/dist/src/oauth/index.d.ts +10 -10
  330. package/dist/src/oauth/session-store.d.ts +2 -2
  331. package/dist/src/oauth/session-store.js +40 -40
  332. package/dist/src/oauth/session-store.js.map +1 -1
  333. package/dist/src/oauth/storage/factory.d.ts +2 -2
  334. package/dist/src/oauth/storage/factory.js +16 -16
  335. package/dist/src/oauth/storage/file.d.ts +2 -2
  336. package/dist/src/oauth/storage/file.js +22 -22
  337. package/dist/src/oauth/storage/file.js.map +1 -1
  338. package/dist/src/oauth/storage/index.d.ts +5 -5
  339. package/dist/src/oauth/storage/memory.d.ts +2 -2
  340. package/dist/src/oauth/storage/memory.js +18 -18
  341. package/dist/src/oauth/storage/memory.js.map +1 -1
  342. package/dist/src/oauth/storage/postgresql.d.ts +2 -2
  343. package/dist/src/oauth/storage/postgresql.js +11 -11
  344. package/dist/src/oauth/storage/postgresql.js.map +1 -1
  345. package/dist/src/oauth/storage/types.d.ts +3 -3
  346. package/dist/src/oauth/token-context.d.ts +1 -1
  347. package/dist/src/oauth/token-context.js +1 -1
  348. package/dist/src/oauth/token-utils.d.ts +1 -1
  349. package/dist/src/oauth/token-utils.js +20 -20
  350. package/dist/src/oauth/types.d.ts +3 -3
  351. package/dist/src/profiles/applicator.d.ts +1 -1
  352. package/dist/src/profiles/applicator.js +48 -48
  353. package/dist/src/profiles/index.d.ts +5 -5
  354. package/dist/src/profiles/loader.d.ts +3 -3
  355. package/dist/src/profiles/loader.js +25 -25
  356. package/dist/src/profiles/loader.js.map +1 -1
  357. package/dist/src/profiles/project-loader.d.ts +1 -1
  358. package/dist/src/profiles/project-loader.js +23 -23
  359. package/dist/src/profiles/project-loader.js.map +1 -1
  360. package/dist/src/profiles/scope-enforcer.d.ts +2 -2
  361. package/dist/src/profiles/scope-enforcer.js +25 -25
  362. package/dist/src/profiles/scope-enforcer.js.map +1 -1
  363. package/dist/src/profiles/types.d.ts +2 -2
  364. package/dist/src/profiles/types.js +50 -48
  365. package/dist/src/profiles/types.js.map +1 -1
  366. package/dist/src/registry-manager.d.ts +19 -11
  367. package/dist/src/registry-manager.js +257 -172
  368. package/dist/src/registry-manager.js.map +1 -1
  369. package/dist/src/server.js +165 -149
  370. package/dist/src/server.js.map +1 -1
  371. package/dist/src/services/ConnectionManager.d.ts +33 -24
  372. package/dist/src/services/ConnectionManager.js +304 -179
  373. package/dist/src/services/ConnectionManager.js.map +1 -1
  374. package/dist/src/services/GitLabVersionDetector.d.ts +2 -2
  375. package/dist/src/services/GitLabVersionDetector.js +45 -45
  376. package/dist/src/services/GitLabVersionDetector.js.map +1 -1
  377. package/dist/src/services/HealthMonitor.d.ts +42 -0
  378. package/dist/src/services/HealthMonitor.js +544 -0
  379. package/dist/src/services/HealthMonitor.js.map +1 -0
  380. package/dist/src/services/InstanceConnectionPool.d.ts +2 -2
  381. package/dist/src/services/InstanceConnectionPool.js +13 -13
  382. package/dist/src/services/InstanceConnectionPool.js.map +1 -1
  383. package/dist/src/services/InstanceRateLimiter.js +6 -6
  384. package/dist/src/services/InstanceRateLimiter.js.map +1 -1
  385. package/dist/src/services/InstanceRegistry.d.ts +4 -5
  386. package/dist/src/services/InstanceRegistry.js +29 -41
  387. package/dist/src/services/InstanceRegistry.js.map +1 -1
  388. package/dist/src/services/NamespaceTierDetector.d.ts +2 -2
  389. package/dist/src/services/NamespaceTierDetector.js +30 -30
  390. package/dist/src/services/NamespaceTierDetector.js.map +1 -1
  391. package/dist/src/services/SchemaIntrospector.d.ts +2 -1
  392. package/dist/src/services/SchemaIntrospector.js +45 -42
  393. package/dist/src/services/SchemaIntrospector.js.map +1 -1
  394. package/dist/src/services/TokenScopeDetector.d.ts +4 -4
  395. package/dist/src/services/TokenScopeDetector.js +133 -110
  396. package/dist/src/services/TokenScopeDetector.js.map +1 -1
  397. package/dist/src/services/ToolAvailability.d.ts +15 -11
  398. package/dist/src/services/ToolAvailability.js +150 -130
  399. package/dist/src/services/ToolAvailability.js.map +1 -1
  400. package/dist/src/services/WidgetAvailability.d.ts +5 -5
  401. package/dist/src/services/WidgetAvailability.js +40 -39
  402. package/dist/src/services/WidgetAvailability.js.map +1 -1
  403. package/dist/src/session-manager.d.ts +3 -2
  404. package/dist/src/session-manager.js +17 -14
  405. package/dist/src/session-manager.js.map +1 -1
  406. package/dist/src/types.js +4 -4
  407. package/dist/src/utils/description-utils.js +4 -4
  408. package/dist/src/utils/description-utils.js.map +1 -1
  409. package/dist/src/utils/error-handler.d.ts +19 -10
  410. package/dist/src/utils/error-handler.js +272 -187
  411. package/dist/src/utils/error-handler.js.map +1 -1
  412. package/dist/src/utils/fetch.d.ts +7 -0
  413. package/dist/src/utils/fetch.js +136 -122
  414. package/dist/src/utils/fetch.js.map +1 -1
  415. package/dist/src/utils/gitlab-api.d.ts +1 -1
  416. package/dist/src/utils/gitlab-api.js +29 -26
  417. package/dist/src/utils/gitlab-api.js.map +1 -1
  418. package/dist/src/utils/idConversion.js +47 -47
  419. package/dist/src/utils/idConversion.js.map +1 -1
  420. package/dist/src/utils/namespace.d.ts +2 -2
  421. package/dist/src/utils/namespace.js +15 -15
  422. package/dist/src/utils/projectIdentifier.js +4 -4
  423. package/dist/src/utils/request-logger.d.ts +4 -4
  424. package/dist/src/utils/request-logger.js +5 -5
  425. package/dist/src/utils/schema-utils.js +24 -24
  426. package/dist/src/utils/schema-utils.js.map +1 -1
  427. package/dist/src/utils/smart-user-search.d.ts +1 -1
  428. package/dist/src/utils/smart-user-search.js +10 -10
  429. package/dist/src/utils/url.d.ts +1 -0
  430. package/dist/src/utils/url.js +38 -0
  431. package/dist/src/utils/url.js.map +1 -0
  432. package/dist/src/utils/version.js +1 -1
  433. package/dist/tsconfig.build.tsbuildinfo +1 -1
  434. package/package.json +22 -31
  435. package/dist/structured-world-gitlab-mcp-6.62.1.tgz +0 -0
@@ -9,148 +9,197 @@ const config_1 = require("../config");
9
9
  const index_1 = require("../oauth/index");
10
10
  const fetch_1 = require("../utils/fetch");
11
11
  const logger_1 = require("../logger");
12
- const InstanceRegistry_js_1 = require("./InstanceRegistry.js");
12
+ const InstanceRegistry_1 = require("./InstanceRegistry");
13
+ const url_1 = require("../utils/url");
13
14
  class ConnectionManager {
14
15
  static instance = null;
15
- client = null;
16
- versionDetector = null;
17
- schemaIntrospector = null;
18
- instanceInfo = null;
19
- schemaInfo = null;
20
- tokenScopeInfo = null;
21
- isInitialized = false;
16
+ instances = new Map();
22
17
  currentInstanceUrl = null;
23
- introspectedInstanceUrl = null;
24
18
  introspectionPromises = new Map();
25
19
  static introspectionCache = new Map();
26
20
  static CACHE_TTL = 10 * 60 * 1000;
21
+ initializePromises = new Map();
22
+ latestRequestedUrl = null;
27
23
  constructor() { }
28
24
  static getInstance() {
29
25
  ConnectionManager.instance ??= new ConnectionManager();
30
26
  return ConnectionManager.instance;
31
27
  }
32
28
  async initialize(instanceUrl) {
33
- if (this.isInitialized) {
29
+ const url = (0, url_1.normalizeInstanceUrl)(instanceUrl ?? config_1.GITLAB_BASE_URL);
30
+ this.latestRequestedUrl = url;
31
+ const existing = this.instances.get(url);
32
+ if (existing?.isInitialized) {
33
+ this.currentInstanceUrl = url;
34
34
  return;
35
35
  }
36
+ const inflight = this.initializePromises.get(url);
37
+ if (inflight) {
38
+ return inflight;
39
+ }
40
+ const promise = this.doInitialize(url);
41
+ this.initializePromises.set(url, promise);
42
+ try {
43
+ await promise;
44
+ const isOurPromise = this.initializePromises.get(url) === promise;
45
+ const initSucceeded = this.instances.get(url)?.isInitialized === true;
46
+ if ((isOurPromise && url === this.latestRequestedUrl) ||
47
+ (!this.currentInstanceUrl && initSucceeded)) {
48
+ this.currentInstanceUrl = url;
49
+ }
50
+ }
51
+ finally {
52
+ if (this.initializePromises.get(url) === promise) {
53
+ this.initializePromises.delete(url);
54
+ }
55
+ }
56
+ }
57
+ async doInitialize(baseUrl) {
58
+ let state;
36
59
  try {
37
60
  const oauthMode = (0, index_1.isOAuthEnabled)();
38
- const registry = InstanceRegistry_js_1.InstanceRegistry.getInstance();
61
+ const registry = InstanceRegistry_1.InstanceRegistry.getInstance();
39
62
  if (!registry.isInitialized()) {
40
63
  await registry.initialize();
41
64
  }
42
- const baseUrl = instanceUrl ?? config_1.GITLAB_BASE_URL;
43
- this.currentInstanceUrl = baseUrl;
44
65
  if (!baseUrl) {
45
- throw new Error("GitLab base URL is required");
66
+ throw new Error('GitLab base URL is required');
46
67
  }
47
68
  if (!oauthMode && !config_1.GITLAB_TOKEN) {
48
- throw new Error("GITLAB_TOKEN is required in static authentication mode. " +
49
- "Run `npx @structured-world/gitlab-mcp setup` for interactive configuration, " +
50
- "or set the environment variable and restart. " +
51
- "Docs: https://gitlab-mcp.sw.foundation/guide/quick-start");
69
+ throw new Error('GITLAB_TOKEN is required in static authentication mode. ' +
70
+ 'Run `npx @structured-world/gitlab-mcp setup` for interactive configuration, ' +
71
+ 'or set the environment variable and restart. ' +
72
+ 'Docs: https://gitlab-mcp.sw.foundation/guide/quick-start');
52
73
  }
53
74
  const endpoint = `${baseUrl}/api/graphql`;
54
75
  const clientOptions = oauthMode
55
76
  ? {}
56
- : { headers: { "PRIVATE-TOKEN": String(config_1.GITLAB_TOKEN) } };
57
- this.client = new client_1.GraphQLClient(endpoint, clientOptions);
58
- this.versionDetector = new GitLabVersionDetector_1.GitLabVersionDetector(this.client);
59
- this.schemaIntrospector = new SchemaIntrospector_1.SchemaIntrospector(this.client);
77
+ : { headers: { 'PRIVATE-TOKEN': String(config_1.GITLAB_TOKEN) } };
78
+ const client = new client_1.GraphQLClient(endpoint, clientOptions);
79
+ const versionDetector = new GitLabVersionDetector_1.GitLabVersionDetector(client);
80
+ const schemaIntrospector = new SchemaIntrospector_1.SchemaIntrospector(client);
81
+ state = {
82
+ client,
83
+ versionDetector,
84
+ schemaIntrospector,
85
+ instanceInfo: null,
86
+ schemaInfo: null,
87
+ tokenScopeInfo: null,
88
+ isInitialized: false,
89
+ introspectedInstanceUrl: null,
90
+ };
91
+ this.instances.set(baseUrl, state);
60
92
  if (oauthMode) {
61
- (0, logger_1.logInfo)("OAuth mode: attempting unauthenticated version detection");
93
+ (0, logger_1.logInfo)('OAuth mode: attempting unauthenticated version detection');
62
94
  try {
63
- const versionResponse = await fetch(`${baseUrl}/api/v4/version`);
95
+ const versionResponse = await (0, fetch_1.enhancedFetch)(`${baseUrl}/api/v4/version`, {
96
+ retry: false,
97
+ skipAuth: true,
98
+ });
64
99
  if (versionResponse.ok) {
65
100
  const versionData = (await versionResponse.json());
66
- (0, logger_1.logInfo)("Detected GitLab version without authentication", {
101
+ (0, logger_1.logInfo)('Detected GitLab version without authentication', {
67
102
  version: versionData.version,
68
103
  });
69
- this.instanceInfo = {
104
+ state.instanceInfo = {
70
105
  version: versionData.version,
71
- tier: versionData.enterprise ? "premium" : "free",
106
+ tier: versionData.enterprise ? 'premium' : 'free',
72
107
  features: this.getDefaultFeatures(versionData.enterprise ?? false),
73
108
  detectedAt: new Date(),
74
109
  };
75
- (0, logger_1.logInfo)("OAuth mode: version detected, full introspection deferred until first authenticated request");
110
+ (0, logger_1.logInfo)('OAuth mode: version detected, full introspection deferred until first authenticated request');
76
111
  }
77
112
  else {
78
- (0, logger_1.logInfo)("OAuth mode: unauthenticated version detection failed, deferring all introspection", {
113
+ (0, logger_1.logInfo)('OAuth mode: unauthenticated version detection failed, deferring all introspection', {
79
114
  status: versionResponse.status,
80
115
  });
81
116
  }
82
117
  }
83
118
  catch (error) {
84
- (0, logger_1.logInfo)("OAuth mode: unauthenticated version detection failed, deferring all introspection", {
119
+ (0, logger_1.logInfo)('OAuth mode: unauthenticated version detection failed, deferring all introspection', {
85
120
  error: error instanceof Error ? error.message : String(error),
86
121
  });
87
122
  }
88
- this.isInitialized = true;
123
+ if (this.instances.get(baseUrl) !== state)
124
+ return;
125
+ state.isInitialized = true;
89
126
  return;
90
127
  }
91
- this.tokenScopeInfo = await (0, TokenScopeDetector_1.detectTokenScopes)();
92
- if (this.tokenScopeInfo) {
128
+ state.tokenScopeInfo = await (0, TokenScopeDetector_1.detectTokenScopes)(baseUrl);
129
+ if (state.tokenScopeInfo) {
93
130
  const totalTools = Object.keys((0, TokenScopeDetector_1.getToolScopeRequirements)()).length;
94
- (0, TokenScopeDetector_1.logTokenScopeInfo)(this.tokenScopeInfo, totalTools);
95
- if (!this.tokenScopeInfo.hasGraphQLAccess) {
96
- this.instanceInfo = await this.detectVersionViaREST();
97
- this.isInitialized = true;
131
+ (0, TokenScopeDetector_1.logTokenScopeInfo)(state.tokenScopeInfo, totalTools, baseUrl);
132
+ if (!state.tokenScopeInfo.hasGraphQLAccess) {
133
+ state.instanceInfo = await this.detectVersionViaREST(baseUrl);
134
+ state.isInitialized = true;
98
135
  return;
99
136
  }
100
137
  }
101
138
  const cached = ConnectionManager.introspectionCache.get(endpoint);
102
139
  const now = Date.now();
103
140
  if (cached && now - cached.timestamp < ConnectionManager.CACHE_TTL) {
104
- (0, logger_1.logInfo)("Using cached GraphQL introspection data");
105
- this.instanceInfo = cached.instanceInfo;
106
- this.schemaInfo = cached.schemaInfo;
107
- this.introspectedInstanceUrl = baseUrl;
141
+ if (this.instances.get(baseUrl) !== state)
142
+ return;
143
+ (0, logger_1.logInfo)('Using cached GraphQL introspection data');
144
+ state.instanceInfo = cached.instanceInfo;
145
+ state.schemaInfo = cached.schemaInfo;
146
+ state.schemaIntrospector.rehydrate(cached.schemaInfo);
147
+ state.introspectedInstanceUrl = baseUrl;
108
148
  }
109
149
  else {
110
- (0, logger_1.logDebug)("Introspecting GitLab GraphQL schema...");
150
+ (0, logger_1.logDebug)('Introspecting GitLab GraphQL schema...');
111
151
  const [instanceInfo, schemaInfo] = await Promise.all([
112
- this.versionDetector.detectInstance(),
113
- this.schemaIntrospector.introspectSchema(),
152
+ versionDetector.detectInstance(),
153
+ schemaIntrospector.introspectSchema(),
114
154
  ]);
115
- this.instanceInfo = instanceInfo;
116
- this.schemaInfo = schemaInfo;
117
- this.introspectedInstanceUrl = baseUrl;
155
+ if (this.instances.get(baseUrl) !== state)
156
+ return;
157
+ state.instanceInfo = instanceInfo;
158
+ state.schemaInfo = schemaInfo;
159
+ state.introspectedInstanceUrl = baseUrl;
118
160
  ConnectionManager.introspectionCache.set(endpoint, {
119
161
  instanceInfo,
120
162
  schemaInfo,
121
163
  timestamp: now,
122
164
  });
123
- (0, logger_1.logInfo)("GraphQL schema introspection completed");
165
+ (0, logger_1.logInfo)('GraphQL schema introspection completed');
124
166
  }
125
- this.isInitialized = true;
126
- (0, logger_1.logInfo)("GitLab instance and schema detected", {
127
- version: this.instanceInfo?.version,
128
- tier: this.instanceInfo?.tier,
129
- features: this.instanceInfo
130
- ? Object.entries(this.instanceInfo.features)
167
+ state.isInitialized = true;
168
+ (0, logger_1.logInfo)('GitLab instance and schema detected', {
169
+ version: state.instanceInfo?.version,
170
+ tier: state.instanceInfo?.tier,
171
+ features: state.instanceInfo
172
+ ? Object.entries(state.instanceInfo.features)
131
173
  .filter(([, enabled]) => enabled)
132
174
  .map(([feature]) => feature)
133
175
  : [],
134
- widgetTypes: this.schemaInfo?.workItemWidgetTypes.length || 0,
135
- schemaTypes: this.schemaInfo?.typeDefinitions.size || 0,
176
+ widgetTypes: state.schemaInfo?.workItemWidgetTypes.length || 0,
177
+ schemaTypes: state.schemaInfo?.typeDefinitions.size || 0,
136
178
  });
137
179
  }
138
180
  catch (error) {
139
- (0, logger_1.logError)("Failed to initialize connection", { err: error });
181
+ if (state && this.instances.get(baseUrl) === state) {
182
+ this.instances.delete(baseUrl);
183
+ }
184
+ (0, logger_1.logError)('Failed to initialize connection', { err: error });
140
185
  throw error;
141
186
  }
142
187
  }
143
- async ensureIntrospected() {
144
- if (!this.client || !this.versionDetector || !this.schemaIntrospector) {
145
- throw new Error("Connection not initialized. Call initialize() first.");
188
+ async ensureIntrospected(explicitUrl) {
189
+ const instanceUrl = (0, url_1.normalizeInstanceUrl)(explicitUrl ?? (0, index_1.getGitLabApiUrlFromContext)() ?? this.currentInstanceUrl ?? config_1.GITLAB_BASE_URL);
190
+ const state = this.instances.get(instanceUrl);
191
+ if (!state?.client || !state.versionDetector || !state.schemaIntrospector) {
192
+ throw new Error('Connection not initialized. Call initialize() first.');
193
+ }
194
+ if (state.instanceInfo && state.schemaInfo && state.introspectedInstanceUrl === instanceUrl) {
195
+ return;
146
196
  }
147
- const instanceUrl = (0, index_1.getGitLabApiUrlFromContext)() ?? this.currentInstanceUrl ?? config_1.GITLAB_BASE_URL;
148
- if (this.instanceInfo && this.schemaInfo && this.introspectedInstanceUrl === instanceUrl) {
197
+ if (state.tokenScopeInfo && !state.tokenScopeInfo.hasGraphQLAccess) {
149
198
  return;
150
199
  }
151
200
  const existingPromise = this.introspectionPromises.get(instanceUrl);
152
201
  if (existingPromise) {
153
- (0, logger_1.logDebug)("Awaiting existing introspection for instance", { url: instanceUrl });
202
+ (0, logger_1.logDebug)('Awaiting existing introspection for instance', { url: instanceUrl });
154
203
  await existingPromise;
155
204
  return;
156
205
  }
@@ -160,34 +209,37 @@ class ConnectionManager {
160
209
  await promise;
161
210
  }
162
211
  finally {
163
- this.introspectionPromises.delete(instanceUrl);
212
+ if (this.introspectionPromises.get(instanceUrl) === promise) {
213
+ this.introspectionPromises.delete(instanceUrl);
214
+ }
164
215
  }
165
216
  }
166
217
  async doIntrospection(instanceUrl) {
167
- const client = this.client;
168
- const versionDet = this.versionDetector;
169
- const schemaDet = this.schemaIntrospector;
170
- if (!client || !versionDet || !schemaDet) {
171
- throw new Error("Connection not initialized. Call initialize() first.");
218
+ const state = this.instances.get(instanceUrl);
219
+ if (!state?.client || !state.versionDetector || !state.schemaIntrospector) {
220
+ throw new Error('Connection not initialized. Call initialize() first.');
172
221
  }
222
+ const { client, versionDetector, schemaIntrospector } = state;
173
223
  const endpoint = client.endpoint;
174
- const registry = InstanceRegistry_js_1.InstanceRegistry.getInstance();
224
+ const registry = InstanceRegistry_1.InstanceRegistry.getInstance();
175
225
  if (registry.isInitialized()) {
176
226
  const cachedIntrospection = registry.getIntrospection(instanceUrl);
177
227
  if (cachedIntrospection) {
178
- (0, logger_1.logInfo)("Using cached introspection from InstanceRegistry", { url: instanceUrl });
179
- this.instanceInfo = {
228
+ (0, logger_1.logInfo)('Using cached introspection from InstanceRegistry', { url: instanceUrl });
229
+ state.instanceInfo = {
180
230
  version: cachedIntrospection.version,
181
231
  tier: cachedIntrospection.tier,
182
232
  features: cachedIntrospection.features,
183
233
  detectedAt: cachedIntrospection.cachedAt,
184
234
  };
185
- this.schemaInfo = cachedIntrospection.schemaInfo;
186
- this.introspectedInstanceUrl = instanceUrl;
235
+ const restoredSchema = cachedIntrospection.schemaInfo;
236
+ state.schemaInfo = restoredSchema;
237
+ state.schemaIntrospector.rehydrate(restoredSchema);
238
+ state.introspectedInstanceUrl = instanceUrl;
187
239
  return;
188
240
  }
189
241
  }
190
- const primaryCacheKey = instanceUrl ?? endpoint;
242
+ const primaryCacheKey = instanceUrl;
191
243
  const legacyCacheKey = endpoint;
192
244
  let cached = ConnectionManager.introspectionCache.get(primaryCacheKey);
193
245
  if (!cached && primaryCacheKey !== legacyCacheKey) {
@@ -195,30 +247,23 @@ class ConnectionManager {
195
247
  }
196
248
  const now = Date.now();
197
249
  if (cached && now - cached.timestamp < ConnectionManager.CACHE_TTL) {
198
- (0, logger_1.logInfo)("Using cached GraphQL introspection data");
199
- this.instanceInfo = cached.instanceInfo;
200
- this.schemaInfo = cached.schemaInfo;
201
- this.introspectedInstanceUrl = instanceUrl;
250
+ (0, logger_1.logInfo)('Using cached GraphQL introspection data');
251
+ state.instanceInfo = cached.instanceInfo;
252
+ state.schemaInfo = cached.schemaInfo;
253
+ state.schemaIntrospector.rehydrate(cached.schemaInfo);
254
+ state.introspectedInstanceUrl = instanceUrl;
202
255
  return;
203
256
  }
204
- (0, logger_1.logDebug)("Introspecting GitLab GraphQL schema (deferred OAuth mode)...");
205
- let versionDetector = versionDet;
206
- let schemaIntrospector = schemaDet;
207
- if (registry.isInitialized() && instanceUrl !== this.currentInstanceUrl) {
208
- const instanceClient = this.getInstanceClient(instanceUrl);
209
- if (instanceClient !== client) {
210
- versionDetector = new GitLabVersionDetector_1.GitLabVersionDetector(instanceClient);
211
- schemaIntrospector = new SchemaIntrospector_1.SchemaIntrospector(instanceClient);
212
- (0, logger_1.logDebug)("Using per-instance detectors for introspection", { instanceUrl });
213
- }
214
- }
257
+ (0, logger_1.logDebug)('Introspecting GitLab GraphQL schema (deferred OAuth mode)...');
215
258
  const [instanceInfo, schemaInfo] = await Promise.all([
216
259
  versionDetector.detectInstance(),
217
260
  schemaIntrospector.introspectSchema(),
218
261
  ]);
219
- this.instanceInfo = instanceInfo;
220
- this.schemaInfo = schemaInfo;
221
- this.introspectedInstanceUrl = instanceUrl;
262
+ if (this.instances.get(instanceUrl) !== state)
263
+ return;
264
+ state.instanceInfo = instanceInfo;
265
+ state.schemaInfo = schemaInfo;
266
+ state.introspectedInstanceUrl = instanceUrl;
222
267
  ConnectionManager.introspectionCache.set(primaryCacheKey, {
223
268
  instanceInfo,
224
269
  schemaInfo,
@@ -234,105 +279,147 @@ class ConnectionManager {
234
279
  };
235
280
  registry.setIntrospection(instanceUrl, cachedIntrospection);
236
281
  }
237
- (0, logger_1.logInfo)("GraphQL schema introspection completed (deferred)", {
238
- version: this.instanceInfo?.version,
239
- tier: this.instanceInfo?.tier,
240
- widgetTypes: this.schemaInfo?.workItemWidgetTypes.length || 0,
282
+ (0, logger_1.logInfo)('GraphQL schema introspection completed (deferred)', {
283
+ version: state.instanceInfo?.version,
284
+ tier: state.instanceInfo?.tier,
285
+ widgetTypes: state.schemaInfo?.workItemWidgetTypes.length || 0,
241
286
  });
242
287
  }
243
- getClient() {
244
- if (!this.client) {
245
- throw new Error("Connection not initialized. Call initialize() first.");
288
+ resolveState(instanceUrl) {
289
+ const url = instanceUrl ? (0, url_1.normalizeInstanceUrl)(instanceUrl) : this.currentInstanceUrl;
290
+ if (!url) {
291
+ throw new Error('Connection not initialized. Call initialize() first.');
292
+ }
293
+ const state = this.instances.get(url);
294
+ if (!state) {
295
+ throw new Error(`Connection not initialized for ${url}. Call initialize() first.`);
246
296
  }
247
- return this.client;
297
+ return [state, url];
298
+ }
299
+ getClient(instanceUrl) {
300
+ const [state] = this.resolveState(instanceUrl);
301
+ return state.client;
248
302
  }
249
303
  getInstanceClient(instanceUrl, authHeaders) {
250
- const registry = InstanceRegistry_js_1.InstanceRegistry.getInstance();
251
- const targetUrl = instanceUrl ?? (0, index_1.getGitLabApiUrlFromContext)() ?? this.currentInstanceUrl;
304
+ const registry = InstanceRegistry_1.InstanceRegistry.getInstance();
305
+ const rawTargetUrl = instanceUrl ?? (0, index_1.getGitLabApiUrlFromContext)() ?? this.currentInstanceUrl;
306
+ const targetUrl = rawTargetUrl ? (0, url_1.normalizeInstanceUrl)(rawTargetUrl) : null;
252
307
  if (targetUrl && registry.isInitialized() && registry.has(targetUrl)) {
253
308
  const client = registry.getGraphQLClient(targetUrl, authHeaders);
254
309
  if (client) {
255
310
  return client;
256
311
  }
257
312
  }
258
- if (!this.client) {
259
- throw new Error("Connection not initialized. Call initialize() first.");
313
+ if (targetUrl) {
314
+ const state = this.instances.get(targetUrl);
315
+ if (state)
316
+ return state.client;
317
+ throw new Error(`Connection not initialized for ${targetUrl}. Call initialize() first.`);
260
318
  }
261
- return this.client;
319
+ return this.getClient();
262
320
  }
263
- getVersionDetector() {
264
- if (!this.versionDetector) {
265
- throw new Error("Connection not initialized. Call initialize() first.");
266
- }
267
- return this.versionDetector;
321
+ getVersionDetector(instanceUrl) {
322
+ const [state] = this.resolveState(instanceUrl);
323
+ return state.versionDetector;
268
324
  }
269
- getSchemaIntrospector() {
270
- if (!this.schemaIntrospector) {
271
- throw new Error("Connection not initialized. Call initialize() first.");
272
- }
273
- return this.schemaIntrospector;
325
+ getSchemaIntrospector(instanceUrl) {
326
+ const [state] = this.resolveState(instanceUrl);
327
+ return state.schemaIntrospector;
274
328
  }
275
- getInstanceInfo() {
276
- if (!this.instanceInfo) {
277
- throw new Error("Connection not initialized. Call initialize() first.");
329
+ getInstanceInfo(instanceUrl) {
330
+ const [state, resolvedUrl] = this.resolveState(instanceUrl);
331
+ if (!state.instanceInfo) {
332
+ throw new Error(`Instance information is not available for ${resolvedUrl}. Initialization may have completed without version detection (OAuth deferred/REST-only mode).`);
278
333
  }
279
- return this.instanceInfo;
334
+ return state.instanceInfo;
280
335
  }
281
- getSchemaInfo() {
282
- if (!this.schemaInfo) {
283
- throw new Error("Connection not initialized. Call initialize() first.");
336
+ getSchemaInfo(instanceUrl) {
337
+ const [state, resolvedUrl] = this.resolveState(instanceUrl);
338
+ if (!state.schemaInfo) {
339
+ throw new Error(`Schema information is not available for ${resolvedUrl}. Initialization may have completed without schema introspection.`);
284
340
  }
285
- return this.schemaInfo;
341
+ return state.schemaInfo;
286
342
  }
287
343
  getCurrentInstanceUrl() {
288
344
  return this.currentInstanceUrl;
289
345
  }
290
- isFeatureAvailable(feature) {
291
- if (!this.instanceInfo) {
346
+ isConnected(instanceUrl) {
347
+ const url = instanceUrl ? (0, url_1.normalizeInstanceUrl)(instanceUrl) : this.currentInstanceUrl;
348
+ if (!url)
292
349
  return false;
293
- }
294
- return this.instanceInfo.features[feature];
350
+ const state = this.instances.get(url);
351
+ return state?.isInitialized ?? false;
295
352
  }
296
- getTier() {
297
- if (!this.instanceInfo) {
298
- return "unknown";
299
- }
300
- return this.instanceInfo.tier;
353
+ isFeatureAvailable(feature, instanceUrl) {
354
+ const url = instanceUrl ? (0, url_1.normalizeInstanceUrl)(instanceUrl) : this.currentInstanceUrl;
355
+ if (!url)
356
+ return false;
357
+ const state = this.instances.get(url);
358
+ if (!state?.instanceInfo)
359
+ return false;
360
+ return state.instanceInfo.features[feature];
301
361
  }
302
- getVersion() {
303
- if (!this.instanceInfo) {
304
- return "unknown";
305
- }
306
- return this.instanceInfo.version;
362
+ getTier(instanceUrl) {
363
+ const url = instanceUrl ? (0, url_1.normalizeInstanceUrl)(instanceUrl) : this.currentInstanceUrl;
364
+ if (!url)
365
+ return 'unknown';
366
+ const state = this.instances.get(url);
367
+ if (!state?.instanceInfo)
368
+ return 'unknown';
369
+ return state.instanceInfo.tier;
307
370
  }
308
- isWidgetAvailable(widgetType) {
309
- if (!this.schemaIntrospector) {
371
+ getVersion(instanceUrl) {
372
+ const url = instanceUrl ? (0, url_1.normalizeInstanceUrl)(instanceUrl) : this.currentInstanceUrl;
373
+ if (!url)
374
+ return 'unknown';
375
+ const state = this.instances.get(url);
376
+ if (!state?.instanceInfo)
377
+ return 'unknown';
378
+ return state.instanceInfo.version;
379
+ }
380
+ isWidgetAvailable(widgetType, instanceUrl) {
381
+ const url = instanceUrl ? (0, url_1.normalizeInstanceUrl)(instanceUrl) : this.currentInstanceUrl;
382
+ if (!url)
310
383
  return false;
311
- }
312
- return this.schemaIntrospector.isWidgetTypeAvailable(widgetType);
384
+ const state = this.instances.get(url);
385
+ return state?.schemaInfo?.workItemWidgetTypes.includes(widgetType) ?? false;
313
386
  }
314
- getTokenScopeInfo() {
315
- return this.tokenScopeInfo;
387
+ getTokenScopeInfo(instanceUrl) {
388
+ const url = instanceUrl ? (0, url_1.normalizeInstanceUrl)(instanceUrl) : this.currentInstanceUrl;
389
+ if (!url)
390
+ return null;
391
+ const state = this.instances.get(url);
392
+ return state?.tokenScopeInfo ?? null;
316
393
  }
317
394
  async refreshTokenScopes() {
318
395
  if ((0, index_1.isOAuthEnabled)()) {
319
396
  return false;
320
397
  }
321
- const previousScopes = this.tokenScopeInfo?.scopes ?? [];
322
- const previousHasGraphQL = this.tokenScopeInfo?.hasGraphQLAccess ?? false;
323
- const previousHasWrite = this.tokenScopeInfo?.hasWriteAccess ?? false;
324
- const newScopeInfo = await (0, TokenScopeDetector_1.detectTokenScopes)();
398
+ const url = this.currentInstanceUrl;
399
+ if (!url)
400
+ return false;
401
+ const state = this.instances.get(url);
402
+ if (!state)
403
+ return false;
404
+ const previousScopes = state.tokenScopeInfo?.scopes ?? [];
405
+ const previousHasGraphQL = state.tokenScopeInfo?.hasGraphQLAccess ?? false;
406
+ const previousHasWrite = state.tokenScopeInfo?.hasWriteAccess ?? false;
407
+ const newScopeInfo = await (0, TokenScopeDetector_1.detectTokenScopes)(url);
325
408
  if (!newScopeInfo) {
326
409
  return false;
327
410
  }
328
411
  const newScopes = newScopeInfo.scopes;
329
412
  const scopesChanged = previousScopes.length !== newScopes.length ||
330
- !previousScopes.every(s => newScopes.includes(s)) ||
413
+ !previousScopes.every((s) => newScopes.includes(s)) ||
331
414
  previousHasGraphQL !== newScopeInfo.hasGraphQLAccess ||
332
415
  previousHasWrite !== newScopeInfo.hasWriteAccess;
416
+ const currentState = this.instances.get(url);
417
+ if (currentState !== state) {
418
+ return false;
419
+ }
420
+ state.tokenScopeInfo = newScopeInfo;
333
421
  if (scopesChanged) {
334
- this.tokenScopeInfo = newScopeInfo;
335
- (0, logger_1.logInfo)("Token scopes changed - tool registry will be refreshed", {
422
+ (0, logger_1.logInfo)('Token scopes changed - tool registry will be refreshed', {
336
423
  previousScopes,
337
424
  newScopes,
338
425
  hasGraphQLAccess: newScopeInfo.hasGraphQLAccess,
@@ -341,39 +428,39 @@ class ConnectionManager {
341
428
  }
342
429
  return scopesChanged;
343
430
  }
344
- async detectVersionViaREST() {
431
+ async detectVersionViaREST(baseUrl) {
345
432
  try {
346
- const baseUrl = this.currentInstanceUrl ?? config_1.GITLAB_BASE_URL;
347
- const response = await (0, fetch_1.enhancedFetch)(`${baseUrl}/api/v4/version`, {
433
+ const url = baseUrl ?? this.currentInstanceUrl ?? config_1.GITLAB_BASE_URL;
434
+ const response = await (0, fetch_1.enhancedFetch)(`${url}/api/v4/version`, {
348
435
  headers: {
349
- "PRIVATE-TOKEN": config_1.GITLAB_TOKEN ?? "",
350
- Accept: "application/json",
436
+ 'PRIVATE-TOKEN': config_1.GITLAB_TOKEN ?? '',
437
+ Accept: 'application/json',
351
438
  },
352
439
  retry: false,
353
440
  });
354
441
  if (response.ok) {
355
442
  const data = (await response.json());
356
- (0, logger_1.logInfo)("Detected GitLab version via REST (GraphQL unavailable)", {
443
+ (0, logger_1.logInfo)('Detected GitLab version via REST (GraphQL unavailable)', {
357
444
  version: data.version,
358
445
  enterprise: data.enterprise,
359
446
  });
360
447
  return {
361
448
  version: data.version,
362
- tier: data.enterprise ? "premium" : "free",
449
+ tier: data.enterprise ? 'premium' : 'free',
363
450
  features: this.getDefaultFeatures(data.enterprise ?? false),
364
451
  detectedAt: new Date(),
365
452
  };
366
453
  }
367
- (0, logger_1.logInfo)("REST version detection failed, using defaults", { status: response.status });
454
+ (0, logger_1.logInfo)('REST version detection failed, using defaults', { status: response.status });
368
455
  }
369
456
  catch (error) {
370
- (0, logger_1.logInfo)("REST version detection failed, using defaults", {
457
+ (0, logger_1.logInfo)('REST version detection failed, using defaults', {
371
458
  error: error instanceof Error ? error.message : String(error),
372
459
  });
373
460
  }
374
461
  return {
375
- version: "unknown",
376
- tier: "free",
462
+ version: 'unknown',
463
+ tier: 'free',
377
464
  features: this.getDefaultFeatures(false),
378
465
  detectedAt: new Date(),
379
466
  };
@@ -407,31 +494,69 @@ class ConnectionManager {
407
494
  emailParticipants: true,
408
495
  };
409
496
  }
410
- async reinitialize(newInstanceUrl) {
411
- (0, logger_1.logInfo)("Re-initializing ConnectionManager for new instance", {
497
+ async reinitialize(rawInstanceUrl) {
498
+ const newInstanceUrl = (0, url_1.normalizeInstanceUrl)(rawInstanceUrl);
499
+ (0, logger_1.logInfo)('Re-initializing ConnectionManager for new instance', {
412
500
  newInstanceUrl,
413
501
  });
414
- this.reset();
415
- const registry = InstanceRegistry_js_1.InstanceRegistry.getInstance();
416
- registry.clearIntrospectionCache(newInstanceUrl);
417
- await this.initialize(newInstanceUrl);
418
- (0, logger_1.logInfo)("ConnectionManager re-initialized", {
419
- version: this.instanceInfo?.version,
420
- tier: this.instanceInfo?.tier,
502
+ const previousUrl = this.currentInstanceUrl;
503
+ const savedState = this.instances.get(newInstanceUrl);
504
+ const restorableState = savedState?.isInitialized ? savedState : undefined;
505
+ this.initializePromises.delete(newInstanceUrl);
506
+ this.introspectionPromises.delete(newInstanceUrl);
507
+ this.instances.delete(newInstanceUrl);
508
+ try {
509
+ const registry = InstanceRegistry_1.InstanceRegistry.getInstance();
510
+ registry.clearIntrospectionCache(newInstanceUrl);
511
+ }
512
+ catch {
513
+ }
514
+ ConnectionManager.introspectionCache.delete(newInstanceUrl);
515
+ ConnectionManager.introspectionCache.delete(`${newInstanceUrl}/api/graphql`);
516
+ try {
517
+ await this.initialize(newInstanceUrl);
518
+ }
519
+ catch (error) {
520
+ if (restorableState) {
521
+ this.instances.set(newInstanceUrl, restorableState);
522
+ }
523
+ if (previousUrl && this.instances.has(previousUrl)) {
524
+ this.currentInstanceUrl = previousUrl;
525
+ }
526
+ else if (restorableState) {
527
+ this.currentInstanceUrl = newInstanceUrl;
528
+ }
529
+ throw error;
530
+ }
531
+ if (previousUrl && previousUrl !== newInstanceUrl) {
532
+ this.initializePromises.delete(previousUrl);
533
+ this.introspectionPromises.delete(previousUrl);
534
+ this.instances.delete(previousUrl);
535
+ }
536
+ const state = this.instances.get(newInstanceUrl);
537
+ (0, logger_1.logInfo)('ConnectionManager re-initialized', {
538
+ version: state?.instanceInfo?.version,
539
+ tier: state?.instanceInfo?.tier,
421
540
  instanceUrl: this.currentInstanceUrl,
422
541
  });
423
542
  }
543
+ clearInflight(rawUrl) {
544
+ const url = (0, url_1.normalizeInstanceUrl)(rawUrl);
545
+ this.initializePromises.delete(url);
546
+ this.introspectionPromises.delete(url);
547
+ }
424
548
  reset() {
425
- this.client = null;
426
- this.versionDetector = null;
427
- this.schemaIntrospector = null;
428
- this.instanceInfo = null;
429
- this.schemaInfo = null;
430
- this.tokenScopeInfo = null;
549
+ this.instances.clear();
431
550
  this.currentInstanceUrl = null;
432
- this.introspectedInstanceUrl = null;
551
+ this.latestRequestedUrl = null;
433
552
  this.introspectionPromises.clear();
434
- this.isInitialized = false;
553
+ this.initializePromises.clear();
554
+ ConnectionManager.introspectionCache.clear();
555
+ try {
556
+ InstanceRegistry_1.InstanceRegistry.getInstance().clearIntrospectionCache();
557
+ }
558
+ catch {
559
+ }
435
560
  }
436
561
  }
437
562
  exports.ConnectionManager = ConnectionManager;