@wootsup/yt-builder-mcp 1.2.0 → 1.4.0

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 (241) hide show
  1. package/README.md +16 -12
  2. package/dist/catalog/build-catalog.d.ts +63 -0
  3. package/dist/catalog/build-catalog.d.ts.map +1 -0
  4. package/dist/catalog/build-catalog.js +166 -0
  5. package/dist/catalog/build-catalog.js.map +1 -0
  6. package/dist/cli/doctor-command.d.ts +21 -0
  7. package/dist/cli/doctor-command.d.ts.map +1 -0
  8. package/dist/cli/doctor-command.js +111 -0
  9. package/dist/cli/doctor-command.js.map +1 -0
  10. package/dist/cli/invocation-decision.d.ts.map +1 -1
  11. package/dist/cli/invocation-decision.js +2 -0
  12. package/dist/cli/invocation-decision.js.map +1 -1
  13. package/dist/client.d.ts +14 -0
  14. package/dist/client.d.ts.map +1 -1
  15. package/dist/client.js +9 -0
  16. package/dist/client.js.map +1 -1
  17. package/dist/diagnostics/ca-trust.d.ts +16 -0
  18. package/dist/diagnostics/ca-trust.d.ts.map +1 -0
  19. package/dist/diagnostics/ca-trust.js +54 -0
  20. package/dist/diagnostics/ca-trust.js.map +1 -0
  21. package/dist/diagnostics/diagnose-network-error.d.ts +37 -0
  22. package/dist/diagnostics/diagnose-network-error.d.ts.map +1 -0
  23. package/dist/diagnostics/diagnose-network-error.js +158 -0
  24. package/dist/diagnostics/diagnose-network-error.js.map +1 -0
  25. package/dist/diagnostics/doctor.d.ts +62 -0
  26. package/dist/diagnostics/doctor.d.ts.map +1 -0
  27. package/dist/diagnostics/doctor.js +165 -0
  28. package/dist/diagnostics/doctor.js.map +1 -0
  29. package/dist/gateway/advanced-read-tool.d.ts +37 -0
  30. package/dist/gateway/advanced-read-tool.d.ts.map +1 -0
  31. package/dist/gateway/advanced-read-tool.js +156 -0
  32. package/dist/gateway/advanced-read-tool.js.map +1 -0
  33. package/dist/gateway/advanced-tool/domains.d.ts +18 -3
  34. package/dist/gateway/advanced-tool/domains.d.ts.map +1 -1
  35. package/dist/gateway/advanced-tool/domains.js +28 -9
  36. package/dist/gateway/advanced-tool/domains.js.map +1 -1
  37. package/dist/gateway/advanced-tool/register.d.ts.map +1 -1
  38. package/dist/gateway/advanced-tool/register.js +43 -11
  39. package/dist/gateway/advanced-tool/register.js.map +1 -1
  40. package/dist/gateway/essentials.d.ts +14 -4
  41. package/dist/gateway/essentials.d.ts.map +1 -1
  42. package/dist/gateway/essentials.js +46 -5
  43. package/dist/gateway/essentials.js.map +1 -1
  44. package/dist/gateway/test-support.d.ts +2 -2
  45. package/dist/gateway/test-support.js +2 -2
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +45 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/install-skill.d.ts +1 -1
  50. package/dist/install-skill.js +2 -2
  51. package/dist/net/extra-headers.d.ts +66 -0
  52. package/dist/net/extra-headers.d.ts.map +1 -0
  53. package/dist/net/extra-headers.js +164 -0
  54. package/dist/net/extra-headers.js.map +1 -0
  55. package/dist/net/internal-host.d.ts +45 -0
  56. package/dist/net/internal-host.d.ts.map +1 -0
  57. package/dist/net/internal-host.js +164 -0
  58. package/dist/net/internal-host.js.map +1 -0
  59. package/dist/net/proxy-dispatcher.d.ts +40 -0
  60. package/dist/net/proxy-dispatcher.d.ts.map +1 -0
  61. package/dist/net/proxy-dispatcher.js +65 -0
  62. package/dist/net/proxy-dispatcher.js.map +1 -0
  63. package/dist/proxy/bridge.d.ts +43 -0
  64. package/dist/proxy/bridge.d.ts.map +1 -0
  65. package/dist/proxy/bridge.js +155 -0
  66. package/dist/proxy/bridge.js.map +1 -0
  67. package/dist/proxy/mode.d.ts +10 -0
  68. package/dist/proxy/mode.d.ts.map +1 -0
  69. package/dist/proxy/mode.js +20 -0
  70. package/dist/proxy/mode.js.map +1 -0
  71. package/dist/server.d.ts +5 -3
  72. package/dist/server.d.ts.map +1 -1
  73. package/dist/server.js +13 -3
  74. package/dist/server.js.map +1 -1
  75. package/dist/setup-ca-env.d.ts +40 -0
  76. package/dist/setup-ca-env.d.ts.map +1 -0
  77. package/dist/setup-ca-env.js +58 -0
  78. package/dist/setup-ca-env.js.map +1 -0
  79. package/dist/setup-ca-reprobe.d.ts +38 -0
  80. package/dist/setup-ca-reprobe.d.ts.map +1 -0
  81. package/dist/setup-ca-reprobe.js +68 -0
  82. package/dist/setup-ca-reprobe.js.map +1 -0
  83. package/dist/setup-cli.d.ts +37 -2
  84. package/dist/setup-cli.d.ts.map +1 -1
  85. package/dist/setup-cli.js +178 -4
  86. package/dist/setup-cli.js.map +1 -1
  87. package/dist/setup-npx-spec.d.ts +44 -0
  88. package/dist/setup-npx-spec.d.ts.map +1 -0
  89. package/dist/setup-npx-spec.js +66 -0
  90. package/dist/setup-npx-spec.js.map +1 -0
  91. package/dist/setup-prompts.d.ts +14 -1
  92. package/dist/setup-prompts.d.ts.map +1 -1
  93. package/dist/setup-prompts.js +53 -1
  94. package/dist/setup-prompts.js.map +1 -1
  95. package/dist/setup-wizard-defaults.d.ts.map +1 -1
  96. package/dist/setup-wizard-defaults.js +29 -5
  97. package/dist/setup-wizard-defaults.js.map +1 -1
  98. package/dist/setup-wizard-handshake.d.ts +4 -4
  99. package/dist/setup-wizard-handshake.d.ts.map +1 -1
  100. package/dist/setup-wizard-handshake.js +46 -12
  101. package/dist/setup-wizard-handshake.js.map +1 -1
  102. package/dist/setup-wizard-types.d.ts +81 -0
  103. package/dist/setup-wizard-types.d.ts.map +1 -1
  104. package/dist/setup-wizard.d.ts +2 -2
  105. package/dist/setup-wizard.d.ts.map +1 -1
  106. package/dist/setup-wizard.js +140 -18
  107. package/dist/setup-wizard.js.map +1 -1
  108. package/dist/sites/client-pool.d.ts +8 -1
  109. package/dist/sites/client-pool.d.ts.map +1 -1
  110. package/dist/sites/client-pool.js +34 -4
  111. package/dist/sites/client-pool.js.map +1 -1
  112. package/dist/sites/registry.d.ts +30 -0
  113. package/dist/sites/registry.d.ts.map +1 -1
  114. package/dist/sites/registry.js.map +1 -1
  115. package/dist/sites/store.d.ts +8 -1
  116. package/dist/sites/store.d.ts.map +1 -1
  117. package/dist/sites/store.js +17 -2
  118. package/dist/sites/store.js.map +1 -1
  119. package/dist/sites/tools/use-site.d.ts.map +1 -1
  120. package/dist/sites/tools/use-site.js +26 -6
  121. package/dist/sites/tools/use-site.js.map +1 -1
  122. package/dist/tools/bind-guidance.d.ts +80 -0
  123. package/dist/tools/bind-guidance.d.ts.map +1 -0
  124. package/dist/tools/bind-guidance.js +95 -0
  125. package/dist/tools/bind-guidance.js.map +1 -0
  126. package/dist/tools/elements/builders.d.ts.map +1 -1
  127. package/dist/tools/elements/builders.js +63 -13
  128. package/dist/tools/elements/builders.js.map +1 -1
  129. package/dist/tools/elements/handlers-write.d.ts +19 -2
  130. package/dist/tools/elements/handlers-write.d.ts.map +1 -1
  131. package/dist/tools/elements/handlers-write.js +179 -10
  132. package/dist/tools/elements/handlers-write.js.map +1 -1
  133. package/dist/tools/elements/handlers.d.ts +8 -2
  134. package/dist/tools/elements/handlers.d.ts.map +1 -1
  135. package/dist/tools/elements/handlers.js +76 -28
  136. package/dist/tools/elements/handlers.js.map +1 -1
  137. package/dist/tools/elements/layout-hierarchy-rules.d.ts +62 -0
  138. package/dist/tools/elements/layout-hierarchy-rules.d.ts.map +1 -0
  139. package/dist/tools/elements/layout-hierarchy-rules.js +154 -0
  140. package/dist/tools/elements/layout-hierarchy-rules.js.map +1 -0
  141. package/dist/tools/format/elements-format.d.ts +35 -0
  142. package/dist/tools/format/elements-format.d.ts.map +1 -1
  143. package/dist/tools/format/elements-format.js +124 -1
  144. package/dist/tools/format/elements-format.js.map +1 -1
  145. package/dist/tools/format/health-format.d.ts +3 -0
  146. package/dist/tools/format/health-format.d.ts.map +1 -1
  147. package/dist/tools/format/health-format.js +21 -4
  148. package/dist/tools/format/health-format.js.map +1 -1
  149. package/dist/tools/format/inspection-format.d.ts +18 -0
  150. package/dist/tools/format/inspection-format.d.ts.map +1 -1
  151. package/dist/tools/format/inspection-format.js +22 -1
  152. package/dist/tools/format/inspection-format.js.map +1 -1
  153. package/dist/tools/format/pages-format.d.ts.map +1 -1
  154. package/dist/tools/format/pages-format.js +7 -0
  155. package/dist/tools/format/pages-format.js.map +1 -1
  156. package/dist/tools/format/sources-format.d.ts +8 -0
  157. package/dist/tools/format/sources-format.d.ts.map +1 -1
  158. package/dist/tools/format/sources-format.js +10 -0
  159. package/dist/tools/format/sources-format.js.map +1 -1
  160. package/dist/tools/health.d.ts.map +1 -1
  161. package/dist/tools/health.js +56 -0
  162. package/dist/tools/health.js.map +1 -1
  163. package/dist/tools/index.d.ts.map +1 -1
  164. package/dist/tools/index.js +4 -0
  165. package/dist/tools/index.js.map +1 -1
  166. package/dist/tools/inspection.d.ts +24 -0
  167. package/dist/tools/inspection.d.ts.map +1 -1
  168. package/dist/tools/inspection.js +140 -41
  169. package/dist/tools/inspection.js.map +1 -1
  170. package/dist/tools/layout-flatten.d.ts +11 -8
  171. package/dist/tools/layout-flatten.d.ts.map +1 -1
  172. package/dist/tools/layout-flatten.js +17 -6
  173. package/dist/tools/layout-flatten.js.map +1 -1
  174. package/dist/tools/multi-items/builders.d.ts.map +1 -1
  175. package/dist/tools/multi-items/builders.js +11 -2
  176. package/dist/tools/multi-items/builders.js.map +1 -1
  177. package/dist/tools/multi-items/inspect-handler.d.ts +13 -0
  178. package/dist/tools/multi-items/inspect-handler.d.ts.map +1 -1
  179. package/dist/tools/multi-items/inspect-handler.js +147 -3
  180. package/dist/tools/multi-items/inspect-handler.js.map +1 -1
  181. package/dist/tools/pages/builders.d.ts.map +1 -1
  182. package/dist/tools/pages/builders.js +153 -39
  183. package/dist/tools/pages/builders.js.map +1 -1
  184. package/dist/tools/pages/handlers-read.d.ts +40 -5
  185. package/dist/tools/pages/handlers-read.d.ts.map +1 -1
  186. package/dist/tools/pages/handlers-read.js +404 -76
  187. package/dist/tools/pages/handlers-read.js.map +1 -1
  188. package/dist/tools/pages/handlers-write.d.ts +95 -1
  189. package/dist/tools/pages/handlers-write.d.ts.map +1 -1
  190. package/dist/tools/pages/handlers-write.js +137 -8
  191. package/dist/tools/pages/handlers-write.js.map +1 -1
  192. package/dist/tools/pages/index.d.ts +1 -1
  193. package/dist/tools/pages/index.d.ts.map +1 -1
  194. package/dist/tools/pages/index.js +1 -1
  195. package/dist/tools/pages/index.js.map +1 -1
  196. package/dist/tools/pages/schemas.d.ts +74 -5
  197. package/dist/tools/pages/schemas.d.ts.map +1 -1
  198. package/dist/tools/pages/schemas.js +243 -8
  199. package/dist/tools/pages/schemas.js.map +1 -1
  200. package/dist/tools/shared-schemas.d.ts +3 -0
  201. package/dist/tools/shared-schemas.d.ts.map +1 -1
  202. package/dist/tools/shared-schemas.js +43 -13
  203. package/dist/tools/shared-schemas.js.map +1 -1
  204. package/dist/tools/sources/builders.d.ts.map +1 -1
  205. package/dist/tools/sources/builders.js +93 -10
  206. package/dist/tools/sources/builders.js.map +1 -1
  207. package/dist/tools/sources/handlers-bind.d.ts +13 -1
  208. package/dist/tools/sources/handlers-bind.d.ts.map +1 -1
  209. package/dist/tools/sources/handlers-bind.js +163 -1
  210. package/dist/tools/sources/handlers-bind.js.map +1 -1
  211. package/dist/tools/sources/handlers.d.ts +12 -1
  212. package/dist/tools/sources/handlers.d.ts.map +1 -1
  213. package/dist/tools/sources/handlers.js +103 -16
  214. package/dist/tools/sources/handlers.js.map +1 -1
  215. package/dist/tools/sparse-fields.d.ts +73 -0
  216. package/dist/tools/sparse-fields.d.ts.map +1 -1
  217. package/dist/tools/sparse-fields.js +136 -0
  218. package/dist/tools/sparse-fields.js.map +1 -1
  219. package/dist/tools/sublayout/builders.d.ts +23 -0
  220. package/dist/tools/sublayout/builders.d.ts.map +1 -0
  221. package/dist/tools/sublayout/builders.js +54 -0
  222. package/dist/tools/sublayout/builders.js.map +1 -0
  223. package/dist/tools/sublayout/index.d.ts +13 -0
  224. package/dist/tools/sublayout/index.d.ts.map +1 -0
  225. package/dist/tools/sublayout/index.js +13 -0
  226. package/dist/tools/sublayout/index.js.map +1 -0
  227. package/dist/tools/sublayout/inspect-sublayout-handler.d.ts +95 -0
  228. package/dist/tools/sublayout/inspect-sublayout-handler.d.ts.map +1 -0
  229. package/dist/tools/sublayout/inspect-sublayout-handler.js +181 -0
  230. package/dist/tools/sublayout/inspect-sublayout-handler.js.map +1 -0
  231. package/dist/tools/tool-builder/results.d.ts +31 -0
  232. package/dist/tools/tool-builder/results.d.ts.map +1 -1
  233. package/dist/tools/tool-builder/results.js +95 -4
  234. package/dist/tools/tool-builder/results.js.map +1 -1
  235. package/dist/update/update-check.d.ts +56 -0
  236. package/dist/update/update-check.d.ts.map +1 -0
  237. package/dist/update/update-check.js +155 -0
  238. package/dist/update/update-check.js.map +1 -0
  239. package/manifest.json +1 -1
  240. package/package.json +5 -2
  241. package/skills/yt-builder-mcp/SKILL.md +148 -82
@@ -0,0 +1,65 @@
1
+ // packages/mcp/src/net/proxy-dispatcher.ts
2
+ import { EnvHttpProxyAgent, setGlobalDispatcher as undiciSetGlobalDispatcher } from 'undici';
3
+ import { deriveNoProxyForInternalSite } from './internal-host.js';
4
+ /** Is any forward-proxy configured in the environment? */
5
+ function hasProxyConfigured(env) {
6
+ return Boolean(env.HTTPS_PROXY ?? env.https_proxy ?? env.HTTP_PROXY ?? env.http_proxy);
7
+ }
8
+ /**
9
+ * Install a process-global undici dispatcher that honors the enterprise
10
+ * `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` environment variables at request
11
+ * time (undici's {@link EnvHttpProxyAgent}).
12
+ *
13
+ * Why this exists: Node's global `fetch` only auto-honors proxy env vars from
14
+ * **Node 24** (`NODE_USE_ENV_PROXY`). On the Node 18–23 floor this package
15
+ * supports, an enterprise forward/auth proxy is otherwise ignored and outbound
16
+ * MCP traffic silently fails. Node's global `fetch` reads the global dispatcher,
17
+ * and so does the MCP SDK's `StreamableHTTPClientTransport` (proxy mode) and the
18
+ * fat-mode `RestClient` — so one global dispatcher covers every outbound call.
19
+ *
20
+ * Installed ONLY when a forward proxy is actually configured
21
+ * (`HTTP_PROXY`/`HTTPS_PROXY`). With no proxy env, the default dispatcher (a
22
+ * direct connection) is already correct, so we skip — this also avoids undici's
23
+ * `EnvHttpProxyAgent is experimental` startup warning for the common, direct
24
+ * case. Corporate TLS-inspection root CAs are handled separately by Node's
25
+ * native `NODE_EXTRA_CA_CERTS` (undici's default connector honors it).
26
+ *
27
+ * Never throws: a failure to install (exotic runtime, frozen global) degrades
28
+ * to a stderr warning and a direct connection, returning `false`.
29
+ *
30
+ * @returns `true` if the dispatcher was installed, `false` if skipped/degraded.
31
+ */
32
+ export function installGlobalProxyDispatcher(deps = {}) {
33
+ const env = deps.env ?? process.env;
34
+ if (!hasProxyConfigured(env)) {
35
+ // No proxy to honor — leave the default (direct) dispatcher in place.
36
+ return false;
37
+ }
38
+ const setDispatcher = deps.setGlobalDispatcher ?? undiciSetGlobalDispatcher;
39
+ const makeAgent = deps.makeEnvHttpProxyAgent ?? (() => new EnvHttpProxyAgent());
40
+ const warn = deps.stderr ?? ((message) => console.error(message));
41
+ // Glöckle gap #9 — when the configured site is INTERNAL (RFC1918 / .local /
42
+ // bare hostname / loopback), make sure its host is in NO_PROXY so intranet
43
+ // traffic bypasses the corporate proxy. Idempotent + non-clobbering: the
44
+ // operator's NO_PROXY is preserved verbatim, the host is only appended.
45
+ // We mutate `env` BEFORE constructing the agent because EnvHttpProxyAgent
46
+ // snapshots NO_PROXY at construction. Public hosts are never touched.
47
+ const noProxy = deriveNoProxyForInternalSite({ env, siteUrl: env.YTB_MCP_SITE_URL });
48
+ if (noProxy.changed && noProxy.noProxy !== undefined) {
49
+ // Set BOTH cases so undici reads it regardless of which it prefers.
50
+ env.NO_PROXY = noProxy.noProxy;
51
+ env.no_proxy = noProxy.noProxy;
52
+ warn(`[yt-builder-mcp] internal site host "${noProxy.addedHost ?? ''}" added to NO_PROXY so it bypasses the configured proxy.`);
53
+ }
54
+ try {
55
+ setDispatcher(makeAgent());
56
+ return true;
57
+ }
58
+ catch (err) {
59
+ const message = err instanceof Error ? err.message : String(err);
60
+ // stderr only — stdout is the JSON-RPC channel in stdio transport.
61
+ warn(`[yt-builder-mcp] proxy dispatcher init failed (continuing with a direct connection): ${message}`);
62
+ return false;
63
+ }
64
+ }
65
+ //# sourceMappingURL=proxy-dispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy-dispatcher.js","sourceRoot":"","sources":["../../src/net/proxy-dispatcher.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,IAAI,yBAAyB,EAAmB,MAAM,QAAQ,CAAC;AAE9G,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAgBlE,0DAA0D;AAC1D,SAAS,kBAAkB,CAAC,GAAsB;IAC9C,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;AAC3F,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,4BAA4B,CAAC,OAA4B,EAAE;IACvE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACpC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,sEAAsE;QACtE,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,IAAI,yBAAyB,CAAC;IAC5E,MAAM,SAAS,GAAG,IAAI,CAAC,qBAAqB,IAAI,CAAC,GAAe,EAAE,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;IAC5F,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,OAAe,EAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAEhF,4EAA4E;IAC5E,2EAA2E;IAC3E,yEAAyE;IACzE,wEAAwE;IACxE,0EAA0E;IAC1E,sEAAsE;IACtE,MAAM,OAAO,GAAG,4BAA4B,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACrF,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACnD,oEAAoE;QACpE,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,wCAAwC,OAAO,CAAC,SAAS,IAAI,EAAE,0DAA0D,CAAC,CAAC;IACpI,CAAC;IAED,IAAI,CAAC;QACD,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,mEAAmE;QACnE,IAAI,CAAC,wFAAwF,OAAO,EAAE,CAAC,CAAC;QACxG,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
2
+ /**
3
+ * Wire two MCP transports into a transparent pipe: every message from one side
4
+ * is relayed verbatim to the other, and a close/error on either side tears down
5
+ * the other. No transformation — the PHP server owns the protocol semantics.
6
+ * The caller is responsible for start()ing both transports.
7
+ *
8
+ * `StreamableHTTPClientTransport.send()` re-throws on any upstream failure
9
+ * (401/5xx/connection refused / missing PHP endpoint). The forwarders MUST NOT
10
+ * fire-and-forget that rejection: an unhandled rejection crashes the Node
11
+ * process, so a wrong key / unreachable site would kill the proxy on the first
12
+ * `initialize` instead of surfacing an actionable error. Each direction
13
+ * therefore `.catch()`es its `send()`.
14
+ */
15
+ export declare function bridgeTransports(local: Transport, remote: Transport): void;
16
+ /** Config the proxy run needs: the upstream endpoint, the Bearer, and any
17
+ * corporate extra headers (Glöckle gap #14) to attach to every upstream
18
+ * request. The Bearer always wins on collision. */
19
+ interface ProxyConfig {
20
+ endpointUrl: URL;
21
+ token: string;
22
+ /** Extra headers from `YTB_MCP_EXTRA_HEADERS` (Basic-Auth / WAF / gateway). */
23
+ extraHeaders?: Record<string, string>;
24
+ }
25
+ /**
26
+ * Build the upstream `requestInit.headers` for proxy mode: the Bearer is
27
+ * authoritative; corporate extra headers (Glöckle gap #14) only fill gaps —
28
+ * `Authorization` can NEVER be overwritten. Exported for unit tests.
29
+ */
30
+ export declare function buildProxyRequestHeaders(config: ProxyConfig): Record<string, string>;
31
+ /** Build the real transports + bridge them; resolves when EITHER side closes. */
32
+ export declare function runProxy(config: ProxyConfig, deps?: {
33
+ makeTransports?: (c: ProxyConfig) => {
34
+ local: Transport;
35
+ remote: Transport;
36
+ };
37
+ }): Promise<void>;
38
+ /** Returns true if proxy mode handled the run; false → caller continues with fat. */
39
+ export declare function maybeRunProxy(env: NodeJS.ProcessEnv, deps?: {
40
+ runProxy?: (c: ProxyConfig) => Promise<void>;
41
+ }): Promise<boolean>;
42
+ export {};
43
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/proxy/bridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AA+B/E;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAoD1E;AAED;;mDAEmD;AACnD,UAAU,WAAW;IACnB,WAAW,EAAE,GAAG,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKpF;AAcD,iFAAiF;AACjF,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,WAAW,EACnB,IAAI,GAAE;IACJ,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK;QACnC,KAAK,EAAE,SAAS,CAAC;QACjB,MAAM,EAAE,SAAS,CAAC;KACnB,CAAC;CACE,GACL,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,qFAAqF;AACrF,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAAO,GAC1D,OAAO,CAAC,OAAO,CAAC,CAalB"}
@@ -0,0 +1,155 @@
1
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
2
+ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
3
+ import { resolveMode } from './mode.js';
4
+ import { diagnoseNetworkError } from '../diagnostics/diagnose-network-error.js';
5
+ import { mergeExtraHeaders, parseExtraHeaders } from '../net/extra-headers.js';
6
+ /** Narrow an unknown caught value to a human-readable message (no `any`). */
7
+ function errorMessage(err) {
8
+ if (err instanceof Error)
9
+ return err.message;
10
+ if (typeof err === 'string')
11
+ return err;
12
+ try {
13
+ return String(err);
14
+ }
15
+ catch {
16
+ return 'unknown error';
17
+ }
18
+ }
19
+ /**
20
+ * A forwarded message is request-shaped (and therefore answerable with a
21
+ * JSON-RPC error) iff it carries a non-null `id`. Notifications have no `id`.
22
+ */
23
+ function requestId(msg) {
24
+ if (msg !== null && typeof msg === 'object' && 'id' in msg) {
25
+ const id = msg.id;
26
+ if (typeof id === 'string' || typeof id === 'number')
27
+ return id;
28
+ }
29
+ return null;
30
+ }
31
+ /**
32
+ * Wire two MCP transports into a transparent pipe: every message from one side
33
+ * is relayed verbatim to the other, and a close/error on either side tears down
34
+ * the other. No transformation — the PHP server owns the protocol semantics.
35
+ * The caller is responsible for start()ing both transports.
36
+ *
37
+ * `StreamableHTTPClientTransport.send()` re-throws on any upstream failure
38
+ * (401/5xx/connection refused / missing PHP endpoint). The forwarders MUST NOT
39
+ * fire-and-forget that rejection: an unhandled rejection crashes the Node
40
+ * process, so a wrong key / unreachable site would kill the proxy on the first
41
+ * `initialize` instead of surfacing an actionable error. Each direction
42
+ * therefore `.catch()`es its `send()`.
43
+ */
44
+ export function bridgeTransports(local, remote) {
45
+ local.onmessage = (msg) => {
46
+ remote.send(msg).catch((err) => {
47
+ const message = errorMessage(err);
48
+ // Turn an opaque transport failure (TLS-inspection CA, proxy, DNS,
49
+ // timeout) into an actionable hint — the Glöckle stress-test died with a
50
+ // 30s timeout that looked like an auth problem. Falls back to the generic
51
+ // config hint when the cause is not recognised.
52
+ const diag = diagnoseNetworkError(err);
53
+ const hint = diag !== null ? `${diag.summary} Fix: ${diag.fix}` : 'Check YTB_MCP_SITE_URL / YTB_MCP_BEARER_TOKEN.';
54
+ // stderr only — stdout is the JSON-RPC channel.
55
+ console.error('[yt-builder-proxy] upstream send failed:', message + (diag !== null ? `\n → ${diag.fix}` : ''));
56
+ const id = requestId(msg);
57
+ if (id !== null) {
58
+ // Hand the client an actionable error instead of a dead pipe.
59
+ const frame = {
60
+ jsonrpc: '2.0',
61
+ id,
62
+ error: {
63
+ code: -32000,
64
+ message: `Proxy upstream error: ${message}. ${hint}`,
65
+ },
66
+ };
67
+ local.send(frame).catch((sendErr) => {
68
+ console.error('[yt-builder-proxy] failed to deliver error frame:', errorMessage(sendErr));
69
+ });
70
+ }
71
+ else {
72
+ // A notification has no id to answer — tear the pipe down instead.
73
+ void remote.close();
74
+ }
75
+ });
76
+ };
77
+ remote.onmessage = (msg) => {
78
+ local.send(msg).catch((err) => {
79
+ console.error('[yt-builder-proxy] downstream send failed:', errorMessage(err));
80
+ });
81
+ };
82
+ local.onclose = () => {
83
+ void remote.close();
84
+ };
85
+ remote.onclose = () => {
86
+ void local.close();
87
+ };
88
+ local.onerror = (err) => {
89
+ console.error('[yt-builder-proxy] local transport error:', err.message);
90
+ };
91
+ remote.onerror = (err) => {
92
+ console.error('[yt-builder-proxy] remote transport error:', err.message);
93
+ };
94
+ }
95
+ /**
96
+ * Build the upstream `requestInit.headers` for proxy mode: the Bearer is
97
+ * authoritative; corporate extra headers (Glöckle gap #14) only fill gaps —
98
+ * `Authorization` can NEVER be overwritten. Exported for unit tests.
99
+ */
100
+ export function buildProxyRequestHeaders(config) {
101
+ const base = { Authorization: `Bearer ${config.token}` };
102
+ return config.extraHeaders !== undefined && Object.keys(config.extraHeaders).length > 0
103
+ ? mergeExtraHeaders(base, config.extraHeaders)
104
+ : base;
105
+ }
106
+ /** Injection seam for tests — production builds the real SDK transports. */
107
+ function defaultTransports(config) {
108
+ const remote = new StreamableHTTPClientTransport(config.endpointUrl, {
109
+ requestInit: { headers: buildProxyRequestHeaders(config) },
110
+ });
111
+ const local = new StdioServerTransport();
112
+ return { local, remote };
113
+ }
114
+ /** Build the real transports + bridge them; resolves when EITHER side closes. */
115
+ export async function runProxy(config, deps = {}) {
116
+ const { local, remote } = (deps.makeTransports ?? defaultTransports)(config);
117
+ // Resolve the moment EITHER transport closes — never hang if the remote
118
+ // (upstream) drops first. Capture the bridge's own onclose handlers so the
119
+ // cross-teardown wiring still runs.
120
+ const closed = new Promise((resolve) => {
121
+ bridgeTransports(local, remote);
122
+ const prevLocalClose = local.onclose;
123
+ const prevRemoteClose = remote.onclose;
124
+ local.onclose = () => {
125
+ prevLocalClose?.();
126
+ resolve();
127
+ };
128
+ remote.onclose = () => {
129
+ prevRemoteClose?.();
130
+ resolve();
131
+ };
132
+ });
133
+ // Start LOCAL (stdio) first so the listener is installed before any client
134
+ // message can race in; only then open the upstream connection.
135
+ await local.start();
136
+ await remote.start();
137
+ await closed;
138
+ }
139
+ /** Returns true if proxy mode handled the run; false → caller continues with fat. */
140
+ export async function maybeRunProxy(env, deps = {}) {
141
+ const resolved = resolveMode(env);
142
+ if (resolved.mode !== 'proxy')
143
+ return false;
144
+ const run = deps.runProxy ?? runProxy;
145
+ // Glöckle gap #14 — attach corporate extra headers (Basic-Auth / WAF / gateway)
146
+ // to every upstream request. parseExtraHeaders reads YTB_MCP_EXTRA_HEADERS.
147
+ const { headers: extraHeaders } = parseExtraHeaders(env);
148
+ await run({
149
+ endpointUrl: resolved.endpointUrl,
150
+ token: resolved.token,
151
+ ...(Object.keys(extraHeaders).length > 0 ? { extraHeaders } : {}),
152
+ });
153
+ return true;
154
+ }
155
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/proxy/bridge.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE/E,6EAA6E;AAC7E,SAAS,YAAY,CAAC,GAAY;IAChC,IAAI,GAAG,YAAY,KAAK;QAAE,OAAO,GAAG,CAAC,OAAO,CAAC;IAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,eAAe,CAAC;IACzB,CAAC;AACH,CAAC;A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QACF,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;YACpB,eAAe,EAAE,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,2EAA2E;IAC3E,+DAA+D;IAC/D,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,MAAM,MAAM,CAAC;AACf,CAAC;AAED,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAsB,EACtB,OAAyD,EAAE;IAE3D,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC;IACtC,gFAAgF;IAChF,4EAA4E;IAC5E,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,GAAG,CAAC;QACR,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type ModeResolution = {
2
+ mode: 'fat';
3
+ } | {
4
+ mode: 'proxy';
5
+ endpointUrl: URL;
6
+ token: string;
7
+ };
8
+ /** Resolve the MCP run mode from the environment. Default is the legacy fat path. */
9
+ export declare function resolveMode(env: NodeJS.ProcessEnv): ModeResolution;
10
+ //# sourceMappingURL=mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../../src/proxy/mode.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACf;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,qFAAqF;AACrF,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,cAAc,CAqBlE"}
@@ -0,0 +1,20 @@
1
+ /** Resolve the MCP run mode from the environment. Default is the legacy fat path. */
2
+ export function resolveMode(env) {
3
+ if (env.YTB_MCP_MODE !== 'proxy') {
4
+ return { mode: 'fat' };
5
+ }
6
+ const token = env.YTB_MCP_BEARER_TOKEN?.trim();
7
+ if (!token) {
8
+ throw new Error('Proxy mode requires YTB_MCP_BEARER_TOKEN (the ytb_* MCP key).');
9
+ }
10
+ const override = env.YTB_MCP_MCP_URL?.trim();
11
+ const site = env.YTB_MCP_SITE_URL?.trim();
12
+ if (!override && !site) {
13
+ throw new Error('Proxy mode requires YTB_MCP_SITE_URL (or YTB_MCP_MCP_URL override).');
14
+ }
15
+ const endpointUrl = override
16
+ ? new URL(override)
17
+ : new URL(`${site.replace(/\/+$/, '')}/wp-json/yt-builder-mcp/mcp`);
18
+ return { mode: 'proxy', endpointUrl, token };
19
+ }
20
+ //# sourceMappingURL=mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode.js","sourceRoot":"","sources":["../../src/proxy/mode.ts"],"names":[],"mappings":"AAIA,qFAAqF;AACrF,MAAM,UAAU,WAAW,CAAC,GAAsB;IAChD,IAAI,GAAG,CAAC,YAAY,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,MAAM,KAAK,GAAG,GAAG,CAAC,oBAAoB,EAAE,IAAI,EAAE,CAAC;IAC/C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IAED,MAAM,QAAQ,GAAG,GAAG,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC;IAC7C,MAAM,IAAI,GAAG,GAAG,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC;IAC1C,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IAED,MAAM,WAAW,GAAG,QAAQ;QAC1B,CAAC,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC;QACnB,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,IAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,6BAA6B,CAAC,CAAC;IAEvE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AAC/C,CAAC"}
package/dist/server.d.ts CHANGED
@@ -23,9 +23,11 @@
23
23
  * Registered LAST on the real server, after every L1/L2 tool is
24
24
  * placed and the advanced registry is final.
25
25
  *
26
- * Result: `tools/list.length === 23` (20 L1 + 2 L3 + 1 gateway), and the
27
- * full callable tool surface is 30 (23 advertised + 7 advanced reachable
28
- * through the gateway).
26
+ * Result: `tools/list.length === 26` (23 L1 + 2 L3 + 1 gateway), and the
27
+ * full callable tool surface is 30 (26 advertised + 4 advanced reachable
28
+ * through the gateway). F116 (2026-06-11) promoted the bind→save→publish
29
+ * chain (element_bind_source / page_save / page_publish) L2 → L1, so the
30
+ * advertised surface grew 23 → 26 and the advanced lane shrank 7 → 4.
29
31
  *
30
32
  * @license MIT
31
33
  */
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAMH,OAAO,EAAE,SAAS,EAAE,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Q,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IACnD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACrC,QAAQ,EAAE,YAAY,GACvB,oBAAoB,CAmBtB;AAED,MAAM,WAAW,mBAAmB;IAChC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CAC9C;AAED,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IAC1C,qEAAqE;IACrE,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;CACvC;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,aAAa,CA+IxE"}
package/dist/server.js CHANGED
@@ -23,9 +23,11 @@
23
23
  * Registered LAST on the real server, after every L1/L2 tool is
24
24
  * placed and the advanced registry is final.
25
25
  *
26
- * Result: `tools/list.length === 23` (20 L1 + 2 L3 + 1 gateway), and the
27
- * full callable tool surface is 30 (23 advertised + 7 advanced reachable
28
- * through the gateway).
26
+ * Result: `tools/list.length === 26` (23 L1 + 2 L3 + 1 gateway), and the
27
+ * full callable tool surface is 30 (26 advertised + 4 advanced reachable
28
+ * through the gateway). F116 (2026-06-11) promoted the bind→save→publish
29
+ * chain (element_bind_source / page_save / page_publish) L2 → L1, so the
30
+ * advertised surface grew 23 → 26 and the advanced lane shrank 7 → 4.
29
31
  *
30
32
  * @license MIT
31
33
  */
@@ -33,6 +35,7 @@ import { readFileSync } from 'node:fs';
33
35
  import { dirname, resolve } from 'node:path';
34
36
  import { fileURLToPath } from 'node:url';
35
37
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
38
+ import { registerAdvancedReadTool } from './gateway/advanced-read-tool.js';
36
39
  import { registerAdvancedTool } from './gateway/advanced-tool.js';
37
40
  import { CapturingServer } from './gateway/capturing-server.js';
38
41
  import { isDirectTopLevel } from './gateway/essentials.js';
@@ -221,6 +224,13 @@ export function createServer(options) {
221
224
  }
222
225
  // Gateway — registered LAST so the advanced registry is final.
223
226
  registerAdvancedTool(mcp, capturing.getAdvancedRegistry());
227
+ // F200a — READ-ONLY gateway sibling. Routes ONLY the read-only L2 subtools
228
+ // (annotation readOnlyHint:true) and is itself readOnly-annotated, so MCP
229
+ // hosts auto-allow it instead of gating every advanced inspection call (the
230
+ // Desktop-E2E #2 per-call approval tax). Writing tools stay reachable only
231
+ // through the (gated) write gateway above. It does NOT capture or duplicate
232
+ // the L2 subtools — it shares the same advanced registry, read-filtered.
233
+ registerAdvancedReadTool(mcp, capturing.getAdvancedRegistry());
224
234
  return { mcp, tools, capturing };
225
235
  }
226
236
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAsB,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CA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ChC,CAAC,CAAE,IAAI,CAAC,iBAAkD;QAC1D,CAAC,CAAE,IAAI,CAAC,WAAiC,CAAC;IAElD,wEAAwE;IACxE,wEAAwE;IACxE,yEAAyE;IACzE,qEAAqE;IACrE,iCAAiC;IACjC,MAAM,YAAY,GACd,IAAI,CAAC,YAAY,KAAK,SAAS;QAC3B,CAAC,CAAE,IAAI,CAAC,YAA6C;QACrD,CAAC,CAAC,SAAS,CAAC;IAEpB,SAAS,CAAC,YAAY,CAClB,IAAI,CAAC,IAAI,EACT;QACI,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW;QACX,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,WAAW,EAAE,IAAI,CAAC,WAAW;KAChC;IACD,oEAAoE;IACpE,+DAA+D;IAC/D,iEAAiE;IACjE,iEAAiE;IACjE,kEAAkE;IAClE,8DAA8D;IAC9D,iEAAiE;IACjE,gEAAgE;IAChE,yCAAyC;IACzC,4IAA4I;IAC5I,CAAC,KAAK,EAAE,IAAS,EAAE,KAAU,EAAE,EAAE;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC,CAAU,CACd,CAAC;AACN,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * `setup-ca-env` — translate a wizard/CLI CA choice into MCP-server env keys.
3
+ *
4
+ * G-D #7: corporate TLS-inspection has two trust strategies, and exactly which
5
+ * env the server entry needs depends on the running Node:
6
+ *
7
+ * - **file mode** (`caCertPath`): write `NODE_EXTRA_CA_CERTS=<path>`. Works on
8
+ * every supported Node; the only option below the system-CA floor.
9
+ * - **system mode** (`caMode: 'system'`): write `NODE_OPTIONS=--use-system-ca`
10
+ * so Node reads the OS trust store (Windows CryptoAPI / macOS Keychain) —
11
+ * the zero-export path, but only on Node ≥ 22.15. Below that floor we emit
12
+ * NOTHING and warn to supply a `.pem` instead, so we never write a flag the
13
+ * target Node would reject at startup.
14
+ *
15
+ * Pure + Node-version-injectable so it is unit-testable offline. Never disables
16
+ * TLS verification.
17
+ *
18
+ * @license MIT
19
+ */
20
+ /** The CA-trust portion of a {@link WizardAnswers}. */
21
+ export interface CaChoice {
22
+ readonly caCertPath?: string;
23
+ readonly caMode?: 'system';
24
+ }
25
+ export interface CaEnvResult {
26
+ /** Env keys to merge into the MCP server entry's env block. */
27
+ readonly env: Record<string, string>;
28
+ /** Non-fatal warnings (e.g. system-CA requested on too-old a Node). */
29
+ readonly warnings: readonly string[];
30
+ }
31
+ /**
32
+ * Resolve the CA env-block keys for `choice` under `nodeVersion` (default
33
+ * `process.version`). `currentEnv` (default `process.env`) is only read to
34
+ * preserve a pre-existing `NODE_OPTIONS` when appending the system-CA flag.
35
+ *
36
+ * File mode wins deterministically if both are set (an explicit `.pem` is the
37
+ * stronger signal). Pure — returns a fresh object, mutates nothing.
38
+ */
39
+ export declare function buildCaEnv(choice: CaChoice, nodeVersion?: string, currentEnv?: NodeJS.ProcessEnv): CaEnvResult;
40
+ //# sourceMappingURL=setup-ca-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-ca-env.d.ts","sourceRoot":"","sources":["../src/setup-ca-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,uDAAuD;AACvD,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAED,MAAM,WAAW,WAAW;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAYD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACtB,MAAM,EAAE,QAAQ,EAChB,WAAW,GAAE,MAAwB,EACrC,UAAU,GAAE,MAAM,CAAC,UAAwB,GAC5C,WAAW,CAoBb"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * `setup-ca-env` — translate a wizard/CLI CA choice into MCP-server env keys.
3
+ *
4
+ * G-D #7: corporate TLS-inspection has two trust strategies, and exactly which
5
+ * env the server entry needs depends on the running Node:
6
+ *
7
+ * - **file mode** (`caCertPath`): write `NODE_EXTRA_CA_CERTS=<path>`. Works on
8
+ * every supported Node; the only option below the system-CA floor.
9
+ * - **system mode** (`caMode: 'system'`): write `NODE_OPTIONS=--use-system-ca`
10
+ * so Node reads the OS trust store (Windows CryptoAPI / macOS Keychain) —
11
+ * the zero-export path, but only on Node ≥ 22.15. Below that floor we emit
12
+ * NOTHING and warn to supply a `.pem` instead, so we never write a flag the
13
+ * target Node would reject at startup.
14
+ *
15
+ * Pure + Node-version-injectable so it is unit-testable offline. Never disables
16
+ * TLS verification.
17
+ *
18
+ * @license MIT
19
+ */
20
+ import { supportsSystemCa } from './diagnostics/ca-trust.js';
21
+ const SYSTEM_CA_FLAG = '--use-system-ca';
22
+ /** Append `--use-system-ca` to an existing NODE_OPTIONS without duplicating it. */
23
+ function withSystemCaFlag(existing) {
24
+ const trimmed = (existing ?? '').trim();
25
+ if (trimmed === '')
26
+ return SYSTEM_CA_FLAG;
27
+ if (trimmed.split(/\s+/).includes(SYSTEM_CA_FLAG))
28
+ return trimmed;
29
+ return `${trimmed} ${SYSTEM_CA_FLAG}`;
30
+ }
31
+ /**
32
+ * Resolve the CA env-block keys for `choice` under `nodeVersion` (default
33
+ * `process.version`). `currentEnv` (default `process.env`) is only read to
34
+ * preserve a pre-existing `NODE_OPTIONS` when appending the system-CA flag.
35
+ *
36
+ * File mode wins deterministically if both are set (an explicit `.pem` is the
37
+ * stronger signal). Pure — returns a fresh object, mutates nothing.
38
+ */
39
+ export function buildCaEnv(choice, nodeVersion = process.version, currentEnv = process.env) {
40
+ const path = choice.caCertPath?.trim();
41
+ if (path !== undefined && path !== '') {
42
+ return { env: { NODE_EXTRA_CA_CERTS: path }, warnings: [] };
43
+ }
44
+ if (choice.caMode === 'system') {
45
+ if (supportsSystemCa(nodeVersion)) {
46
+ return { env: { NODE_OPTIONS: withSystemCaFlag(currentEnv.NODE_OPTIONS) }, warnings: [] };
47
+ }
48
+ return {
49
+ env: {},
50
+ warnings: [
51
+ `OS trust store (--use-system-ca) needs Node ≥ 22.15 — this Node is ${nodeVersion}. ` +
52
+ 'Re-run setup with `--ca <path-to-corp-root-ca.pem>` (export your corporate root CA to a .pem) instead. Never disable TLS verification.',
53
+ ],
54
+ };
55
+ }
56
+ return { env: {}, warnings: [] };
57
+ }
58
+ //# sourceMappingURL=setup-ca-env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-ca-env.js","sourceRoot":"","sources":["../src/setup-ca-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAe7D,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAEzC,mFAAmF;AACnF,SAAS,gBAAgB,CAAC,QAA4B;IAClD,MAAM,OAAO,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,cAAc,CAAC;IAC1C,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC;QAAE,OAAO,OAAO,CAAC;IAClE,OAAO,GAAG,OAAO,IAAI,cAAc,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CACtB,MAAgB,EAChB,cAAsB,OAAO,CAAC,OAAO,EACrC,aAAgC,OAAO,CAAC,GAAG;IAE3C,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC;IACvC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QACpC,OAAO,EAAE,GAAG,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAChE,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,gBAAgB,CAAC,WAAW,CAAC,EAAE,CAAC;YAChC,OAAO,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,gBAAgB,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QAC9F,CAAC;QACD,OAAO;YACH,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE;gBACN,sEAAsE,WAAW,IAAI;oBACjF,wIAAwI;aAC/I;SACJ,CAAC;IACN,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AACrC,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * `setup-ca-reprobe` — default `WizardDeps.applyAndReProbe` (G-D #6/#8).
3
+ *
4
+ * After the user picks a corporate-CA strategy, RE-PROBE the connection so the
5
+ * wizard can print ✅/❌ now instead of leaving a silent first-tool-call
6
+ * timeout for after the restart:
7
+ *
8
+ * - **file mode**: read the `.pem` and run the probes through an undici
9
+ * `Agent` whose connector trusts that CA — this validates in-process,
10
+ * immediately, without a restart.
11
+ * - **system mode**: the OS trust store is only consulted when Node is
12
+ * (re)started with `--use-system-ca`, which the written config now does —
13
+ * so we re-run the ordinary probes (best-effort) and report the truthful
14
+ * current state; the config is already correct for the next launch.
15
+ *
16
+ * Never disables TLS verification.
17
+ *
18
+ * @license MIT
19
+ */
20
+ import type { AuthProbeResult, CaPromptChoice, HealthProbeResult } from './setup-wizard-types.js';
21
+ /**
22
+ * Probe health + auth for `wpUrl`/`bearer` under the chosen CA. The probes are
23
+ * injected (default to the real handshake probes) so this stays testable; the
24
+ * file-mode CA wiring is the only real-I/O part and is exercised by an
25
+ * integration probe, never a unit mock.
26
+ */
27
+ export declare function defaultApplyAndReProbe(input: {
28
+ readonly wpUrl: string;
29
+ readonly bearer: string;
30
+ readonly choice: CaPromptChoice;
31
+ }, probes?: {
32
+ probeHealth?: (wpUrl: string, fetchImpl?: typeof fetch) => Promise<HealthProbeResult>;
33
+ probeAuth?: (wpUrl: string, bearer: string, fetchImpl?: typeof fetch) => Promise<AuthProbeResult>;
34
+ }): Promise<{
35
+ health: HealthProbeResult;
36
+ auth: AuthProbeResult;
37
+ }>;
38
+ //# sourceMappingURL=setup-ca-reprobe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-ca-reprobe.d.ts","sourceRoot":"","sources":["../src/setup-ca-reprobe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAElG;;;;;GAKG;AACH,wBAAsB,sBAAsB,CACxC,KAAK,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAAE,EAC3F,MAAM,GAAE;IACJ,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACtF,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;CAChG,GACP,OAAO,CAAC;IAAE,MAAM,EAAE,iBAAiB,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC,CAkB/D"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * `setup-ca-reprobe` — default `WizardDeps.applyAndReProbe` (G-D #6/#8).
3
+ *
4
+ * After the user picks a corporate-CA strategy, RE-PROBE the connection so the
5
+ * wizard can print ✅/❌ now instead of leaving a silent first-tool-call
6
+ * timeout for after the restart:
7
+ *
8
+ * - **file mode**: read the `.pem` and run the probes through an undici
9
+ * `Agent` whose connector trusts that CA — this validates in-process,
10
+ * immediately, without a restart.
11
+ * - **system mode**: the OS trust store is only consulted when Node is
12
+ * (re)started with `--use-system-ca`, which the written config now does —
13
+ * so we re-run the ordinary probes (best-effort) and report the truthful
14
+ * current state; the config is already correct for the next launch.
15
+ *
16
+ * Never disables TLS verification.
17
+ *
18
+ * @license MIT
19
+ */
20
+ import { readFile } from 'node:fs/promises';
21
+ import { Agent, fetch as undiciFetch } from 'undici';
22
+ import { defaultProbeAuth, defaultProbeHealth } from './setup-wizard-handshake.js';
23
+ /**
24
+ * Probe health + auth for `wpUrl`/`bearer` under the chosen CA. The probes are
25
+ * injected (default to the real handshake probes) so this stays testable; the
26
+ * file-mode CA wiring is the only real-I/O part and is exercised by an
27
+ * integration probe, never a unit mock.
28
+ */
29
+ export async function defaultApplyAndReProbe(input, probes = {}) {
30
+ const probeHealth = probes.probeHealth ?? defaultProbeHealth;
31
+ const probeAuth = probes.probeAuth ?? defaultProbeAuth;
32
+ if (input.choice.choice === 'file') {
33
+ const fetchImpl = await caBoundFetch(input.choice.path);
34
+ if (fetchImpl !== null) {
35
+ const health = await probeHealth(input.wpUrl, fetchImpl);
36
+ const auth = await probeAuth(input.wpUrl, input.bearer, fetchImpl);
37
+ return { health, auth };
38
+ }
39
+ // Could not read the .pem — fall through to a plain re-probe so the
40
+ // operator still gets a (failing) verdict + the file warning above.
41
+ }
42
+ const health = await probeHealth(input.wpUrl);
43
+ const auth = await probeAuth(input.wpUrl, input.bearer);
44
+ return { health, auth };
45
+ }
46
+ /**
47
+ * A `fetch` whose TLS connector additionally trusts the PEM at `caPath`, or
48
+ * `null` when the file cannot be read. The CA is ADDED to the default trust
49
+ * set (undici merges it with the system roots) — verification stays on.
50
+ */
51
+ async function caBoundFetch(caPath) {
52
+ let ca;
53
+ try {
54
+ ca = await readFile(caPath, 'utf8');
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ const agent = new Agent({ connect: { ca } });
60
+ // undici's fetch accepts a per-call `dispatcher`; wrap it to match the
61
+ // global `fetch` signature the RestClient expects.
62
+ const bound = ((input, init) => undiciFetch(input, {
63
+ ...init,
64
+ dispatcher: agent,
65
+ }));
66
+ return bound;
67
+ }
68
+ //# sourceMappingURL=setup-ca-reprobe.js.map