@jini-ai/provider-plugins 0.7.3-next.2 → 0.7.4

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 (239) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/catalog.json +25 -20
  3. package/dist/model-proxy-anthropic/index.d.ts +18 -0
  4. package/dist/model-proxy-anthropic/index.js +32 -0
  5. package/dist/model-proxy-azure/index.d.ts +19 -0
  6. package/dist/model-proxy-azure/index.js +32 -0
  7. package/dist/model-proxy-google/index.d.ts +18 -0
  8. package/dist/model-proxy-google/index.js +25 -0
  9. package/dist/model-proxy-ollama/index.d.ts +8 -0
  10. package/dist/model-proxy-ollama/index.js +13 -0
  11. package/dist/model-proxy-openai/index.d.ts +8 -0
  12. package/dist/model-proxy-openai/index.js +13 -0
  13. package/dist/observability-opentelemetry/otel-port.d.ts +3 -1
  14. package/dist/observability-opentelemetry/otel-port.js +20 -7
  15. package/dist/xai/media/index.d.ts +67 -0
  16. package/dist/xai/media/index.js +132 -0
  17. package/dist/xai/oauth-port.d.ts +132 -0
  18. package/dist/xai/oauth-port.js +5 -0
  19. package/dist/xai/preset.d.ts +22 -0
  20. package/dist/xai/preset.js +28 -0
  21. package/dist/xai/routes.d.ts +108 -0
  22. package/dist/xai/routes.js +658 -0
  23. package/package.json +68 -27
  24. package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/jini.plugin.json +3 -3
  25. package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/package-license.json +1 -1
  26. package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/server/index.mjs +2 -2
  27. package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/README.md +1 -1
  28. package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/jini.plugin.json +4 -4
  29. package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/package-license.json +1 -1
  30. package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/server/index.mjs +2 -2
  31. package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/client/provider.js +1 -1
  32. package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/jini.plugin.json +3 -3
  33. package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/package-license.json +1 -1
  34. package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/jini.plugin.json +2 -2
  35. package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/package-license.json +1 -1
  36. package/plugins/fixture-provider/{0.7.3-next.2 → 0.7.4}/jini.plugin.json +2 -2
  37. package/plugins/fixture-provider/0.7.4/licenses/_jini-ai_provider-plugins/package-license.json +5 -0
  38. package/plugins/formspree/{0.7.3-next.2 → 0.7.4}/jini.plugin.json +2 -2
  39. package/plugins/formspree/0.7.4/licenses/_jini-ai_provider-plugins/package-license.json +5 -0
  40. package/plugins/google-forms/{0.7.3-next.2 → 0.7.4}/jini.plugin.json +2 -2
  41. package/plugins/google-forms/0.7.4/licenses/_jini-ai_provider-plugins/package-license.json +5 -0
  42. package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/README.md +1 -1
  43. package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/jini.plugin.json +5 -5
  44. package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_core/package-license.json +1 -1
  45. package/plugins/observability-opentelemetry/0.7.4/licenses/_jini-ai_provider-plugins/package-license.json +5 -0
  46. package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/server/index.mjs +22 -13
  47. package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/README.md +1 -1
  48. package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/jini.plugin.json +5 -5
  49. package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_core/package-license.json +1 -1
  50. package/plugins/observability-sentry/0.7.4/licenses/_jini-ai_provider-plugins/package-license.json +5 -0
  51. package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/server/index.mjs +18 -8
  52. package/plugins/payments-stripe/{0.7.3-next.2 → 0.7.4}/jini.plugin.json +2 -2
  53. package/plugins/payments-stripe/0.7.4/licenses/_jini-ai_provider-plugins/package-license.json +5 -0
  54. package/plugins/xai/0.7.4/jini.plugin.json +48 -0
  55. package/plugins/xai/0.7.4/licenses/_jini-ai_core/LICENSE +201 -0
  56. package/plugins/xai/0.7.4/licenses/_jini-ai_core/package-license.json +5 -0
  57. package/plugins/xai/0.7.4/licenses/_jini-ai_protocol/LICENSE +201 -0
  58. package/plugins/xai/0.7.4/licenses/_jini-ai_protocol/package-license.json +5 -0
  59. package/plugins/xai/0.7.4/licenses/_jini-ai_provider-plugins/LICENSE +201 -0
  60. package/plugins/xai/0.7.4/licenses/_jini-ai_provider-plugins/NOTICE +28 -0
  61. package/plugins/xai/0.7.4/licenses/_jini-ai_provider-plugins/package-license.json +5 -0
  62. package/plugins/xai/0.7.4/licenses/zod/LICENSE +21 -0
  63. package/plugins/xai/0.7.4/licenses/zod/package-license.json +5 -0
  64. package/plugins/xai/0.7.4/server/index.mjs +1621 -0
  65. package/plugins/fixture-provider/0.7.3-next.2/licenses/_jini-ai_provider-plugins/package-license.json +0 -5
  66. package/plugins/formspree/0.7.3-next.2/licenses/_jini-ai_provider-plugins/package-license.json +0 -5
  67. package/plugins/google-forms/0.7.3-next.2/licenses/_jini-ai_provider-plugins/package-license.json +0 -5
  68. package/plugins/observability-opentelemetry/0.7.3-next.2/licenses/_jini-ai_provider-plugins/package-license.json +0 -5
  69. package/plugins/observability-sentry/0.7.3-next.2/licenses/_jini-ai_provider-plugins/package-license.json +0 -5
  70. package/plugins/payments-stripe/0.7.3-next.2/licenses/_jini-ai_provider-plugins/package-license.json +0 -5
  71. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/CHANGELOG.md +0 -0
  72. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/LICENSE +0 -0
  73. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/NOTICE +0 -0
  74. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/README.md +0 -0
  75. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/LICENSE +0 -0
  76. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/NOTICE +0 -0
  77. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/langfuse/LICENSE +0 -0
  78. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/langfuse/LICENSE-SOURCE +0 -0
  79. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/langfuse/SOURCE +0 -0
  80. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/langfuse/package-license.json +0 -0
  81. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/langfuse-core/LICENSE +0 -0
  82. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/langfuse-core/LICENSE-SOURCE +0 -0
  83. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/langfuse-core/SOURCE +0 -0
  84. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/langfuse-core/package-license.json +0 -0
  85. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/mustache/LICENSE +0 -0
  86. /package/plugins/ai-trace-langfuse/{0.7.3-next.2 → 0.7.4}/licenses/mustache/package-license.json +0 -0
  87. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/CHANGELOG.md +0 -0
  88. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/LICENSE +0 -0
  89. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/NOTICE +0 -0
  90. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/LICENSE +0 -0
  91. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/NOTICE +0 -0
  92. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/licenses/_posthog_core/LICENSE +0 -0
  93. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/licenses/_posthog_core/package-license.json +0 -0
  94. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/licenses/posthog-js/LICENSE +0 -0
  95. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/licenses/posthog-js/package-license.json +0 -0
  96. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/licenses/posthog-node/LICENSE +0 -0
  97. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/licenses/posthog-node/package-license.json +0 -0
  98. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/server/consent-adapter.mjs +0 -0
  99. /package/plugins/analytics-posthog/{0.7.3-next.2 → 0.7.4}/server/posthog-browser.js +0 -0
  100. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/client/styles.css +0 -0
  101. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/LICENSE +0 -0
  102. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/NOTICE +0 -0
  103. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/licenses/echarts/LICENSE +0 -0
  104. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/licenses/echarts/NOTICE +0 -0
  105. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/licenses/echarts/package-license.json +0 -0
  106. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/licenses/tslib/LICENSE.txt +0 -0
  107. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/licenses/tslib/package-license.json +0 -0
  108. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/licenses/zrender/LICENSE +0 -0
  109. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/licenses/zrender/package-license.json +0 -0
  110. /package/plugins/charts-echarts/{0.7.3-next.2 → 0.7.4}/server/index.mjs +0 -0
  111. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/client/provider.js +0 -0
  112. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/client/styles.css +0 -0
  113. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/LICENSE +0 -0
  114. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/NOTICE +0 -0
  115. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/_reduxjs_toolkit/LICENSE +0 -0
  116. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/_reduxjs_toolkit/package-license.json +0 -0
  117. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/clsx/license +0 -0
  118. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/clsx/package-license.json +0 -0
  119. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-array/LICENSE +0 -0
  120. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-array/package-license.json +0 -0
  121. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-color/LICENSE +0 -0
  122. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-color/package-license.json +0 -0
  123. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-format/LICENSE +0 -0
  124. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-format/package-license.json +0 -0
  125. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-interpolate/LICENSE +0 -0
  126. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-interpolate/package-license.json +0 -0
  127. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-path/LICENSE +0 -0
  128. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-path/package-license.json +0 -0
  129. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-scale/LICENSE +0 -0
  130. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-scale/package-license.json +0 -0
  131. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-shape/LICENSE +0 -0
  132. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-shape/package-license.json +0 -0
  133. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-time/LICENSE +0 -0
  134. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-time/package-license.json +0 -0
  135. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-time-format/LICENSE +0 -0
  136. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/d3-time-format/package-license.json +0 -0
  137. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/decimal.js-light/LICENCE.md +0 -0
  138. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/decimal.js-light/package-license.json +0 -0
  139. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/es-toolkit/LICENSE +0 -0
  140. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/es-toolkit/package-license.json +0 -0
  141. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/eventemitter3/LICENSE +0 -0
  142. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/eventemitter3/package-license.json +0 -0
  143. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/immer/LICENSE +0 -0
  144. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/immer/package-license.json +0 -0
  145. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/internmap/LICENSE +0 -0
  146. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/internmap/package-license.json +0 -0
  147. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/react/LICENSE +0 -0
  148. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/react/package-license.json +0 -0
  149. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/react-dom/LICENSE +0 -0
  150. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/react-dom/package-license.json +0 -0
  151. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/react-is/LICENSE +0 -0
  152. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/react-is/package-license.json +0 -0
  153. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/react-redux/LICENSE.md +0 -0
  154. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/react-redux/package-license.json +0 -0
  155. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/recharts/LICENSE +0 -0
  156. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/recharts/package-license.json +0 -0
  157. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/redux/LICENSE.md +0 -0
  158. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/redux/package-license.json +0 -0
  159. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/redux-thunk/LICENSE.md +0 -0
  160. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/redux-thunk/package-license.json +0 -0
  161. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/reselect/LICENSE +0 -0
  162. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/reselect/package-license.json +0 -0
  163. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/scheduler/LICENSE +0 -0
  164. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/scheduler/package-license.json +0 -0
  165. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/tiny-invariant/LICENSE +0 -0
  166. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/tiny-invariant/package-license.json +0 -0
  167. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/use-sync-external-store/LICENSE +0 -0
  168. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/use-sync-external-store/package-license.json +0 -0
  169. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/victory-vendor/LICENSE.txt +0 -0
  170. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/licenses/victory-vendor/package-license.json +0 -0
  171. /package/plugins/charts-recharts/{0.7.3-next.2 → 0.7.4}/server/index.mjs +0 -0
  172. /package/plugins/fixture-provider/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/LICENSE +0 -0
  173. /package/plugins/fixture-provider/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/NOTICE +0 -0
  174. /package/plugins/fixture-provider/{0.7.3-next.2 → 0.7.4}/server/index.mjs +0 -0
  175. /package/plugins/formspree/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/LICENSE +0 -0
  176. /package/plugins/formspree/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/NOTICE +0 -0
  177. /package/plugins/formspree/{0.7.3-next.2 → 0.7.4}/server/index.mjs +0 -0
  178. /package/plugins/google-forms/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/LICENSE +0 -0
  179. /package/plugins/google-forms/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/NOTICE +0 -0
  180. /package/plugins/google-forms/{0.7.3-next.2 → 0.7.4}/server/index.mjs +0 -0
  181. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/CHANGELOG.md +0 -0
  182. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/LICENSE +0 -0
  183. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/NOTICE +0 -0
  184. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_core/LICENSE +0 -0
  185. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/LICENSE +0 -0
  186. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/NOTICE +0 -0
  187. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_api/LICENSE +0 -0
  188. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_api/package-license.json +0 -0
  189. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_api-logs/LICENSE +0 -0
  190. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_api-logs/package-license.json +0 -0
  191. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_context-async-hooks/LICENSE +0 -0
  192. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_context-async-hooks/package-license.json +0 -0
  193. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_core/LICENSE +0 -0
  194. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_core/package-license.json +0 -0
  195. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_otlp-exporter-base/LICENSE +0 -0
  196. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_otlp-exporter-base/package-license.json +0 -0
  197. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_otlp-transformer/LICENSE +0 -0
  198. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_otlp-transformer/package-license.json +0 -0
  199. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_resources/LICENSE +0 -0
  200. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_resources/package-license.json +0 -0
  201. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_sdk-metrics/LICENSE +0 -0
  202. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_sdk-metrics/package-license.json +0 -0
  203. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_sdk-trace/LICENSE +0 -0
  204. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_sdk-trace/package-license.json +0 -0
  205. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_sdk-trace-base/LICENSE +0 -0
  206. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_sdk-trace-base/package-license.json +0 -0
  207. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_sdk-trace-node/LICENSE +0 -0
  208. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_sdk-trace-node/package-license.json +0 -0
  209. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_semantic-conventions/LICENSE +0 -0
  210. /package/plugins/observability-opentelemetry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_semantic-conventions/package-license.json +0 -0
  211. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/CHANGELOG.md +0 -0
  212. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/LICENSE +0 -0
  213. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/NOTICE +0 -0
  214. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_core/LICENSE +0 -0
  215. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/LICENSE +0 -0
  216. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/NOTICE +0 -0
  217. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_api/LICENSE +0 -0
  218. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_opentelemetry_api/package-license.json +0 -0
  219. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_conventions/LICENSE +0 -0
  220. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_conventions/package-license.json +0 -0
  221. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_core/LICENSE +0 -0
  222. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_core/package-license.json +0 -0
  223. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_node/LICENSE +0 -0
  224. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_node/package-license.json +0 -0
  225. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_opentelemetry/LICENSE +0 -0
  226. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_opentelemetry/package-license.json +0 -0
  227. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_server-runtime-injection/LICENSE +0 -0
  228. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_server-runtime-injection/LICENSE-SOURCE +0 -0
  229. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_server-runtime-injection/package-license.json +0 -0
  230. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_server-utils/LICENSE +0 -0
  231. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_server-utils/LICENSE-SOURCE +0 -0
  232. /package/plugins/observability-sentry/{0.7.3-next.2 → 0.7.4}/licenses/_sentry_server-utils/package-license.json +0 -0
  233. /package/plugins/payments-stripe/{0.7.3-next.2 → 0.7.4}/CHANGELOG.md +0 -0
  234. /package/plugins/payments-stripe/{0.7.3-next.2 → 0.7.4}/LICENSE +0 -0
  235. /package/plugins/payments-stripe/{0.7.3-next.2 → 0.7.4}/NOTICE +0 -0
  236. /package/plugins/payments-stripe/{0.7.3-next.2 → 0.7.4}/README.md +0 -0
  237. /package/plugins/payments-stripe/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/LICENSE +0 -0
  238. /package/plugins/payments-stripe/{0.7.3-next.2 → 0.7.4}/licenses/_jini-ai_provider-plugins/NOTICE +0 -0
  239. /package/plugins/payments-stripe/{0.7.3-next.2 → 0.7.4}/server/index.mjs +0 -0
@@ -0,0 +1,658 @@
1
+ /**
2
+ * @module xai/routes
3
+ *
4
+ * `POST /api/xai/oauth/start`, `POST /api/xai/oauth/complete`, `POST /api/xai/oauth/cancel`,
5
+ * `GET /api/xai/auth/status`, `POST /api/xai/oauth/disconnect`, `POST /api/xai/search` — ported
6
+ * from OD's real `apps/daemon/src/routes/xai.ts` (read directly in the sibling
7
+ * `/Users/la/Desktop/Programming/OSS-Repos/open-design` checkout on this machine, per this repo's
8
+ * "verify against the real source, don't guess" convention), and from that same file's own
9
+ * `5bd5e6b3d^:packages/http/source-map.md` routes-classification row #27 ("MIXED, OD-leaning... the OAuth
10
+ * start/complete/status/cancel/disconnect shape is a recognizable generic pattern, but this file is
11
+ * fused to a transitional xAI PoC arrangement"). Deliberately left out of the 2026-07-22
12
+ * azure/google/ollama/connectors/health/research route-parity pass pending a product decision on
13
+ * whether to build xAI OAuth support at all — approved after that pass landed; this is that build.
14
+ *
15
+ * **Reused `@jini-ai/agent-runtime`'s existing generic OAuth+PKCE machinery instead of building a
16
+ * second OAuth stack.** `packages/agent-runtime/src/providers/{pkce,oauth-provider,oauth-callback-
17
+ * server,oauth-tokens,oauth-credentials}.ts` (all ported 2026-07-18, see that package's
18
+ * `archived provenance ledger` "providers/ — LLM-provider integrations" section) already generalized this exact
19
+ * origin file's OAuth sibling files — OD's `integrations/xai-oauth.ts` → `oauth-provider.ts`
20
+ * (`beginOAuthPkce`/`completeOAuthPkce`/`refreshOAuthPkceToken`, config-driven via
21
+ * `OAuthPkceProviderConfig`, with `XAI_OAUTH_PROVIDER_CONFIG` kept as the concrete xAI preset the
22
+ * origin actually shipped), `integrations/xai-oauth-server.ts` → `oauth-callback-server.ts`
23
+ * (`startOAuthCallbackListener`, de-branded, `host`/`port`/`path` now caller-supplied instead of
24
+ * xAI-hardcoded constants), `integrations/xai-tokens.ts` → `oauth-tokens.ts`
25
+ * (`getStoredOAuthToken`/`setStoredOAuthToken`/`clearStoredOAuthToken`, filename now a parameter),
26
+ * `integrations/xai-credentials.ts` → `oauth-credentials.ts` (`resolveOAuthBearer`, refresh-on-read).
27
+ * That prior port had **no HTTP route consumer anywhere** — this file is the first one. Nothing new
28
+ * was built for PKCE/callback-listener/token-storage/refresh; this module supplies only the pieces
29
+ * that machinery doesn't already have an opinion on: xAI's concrete `providerConfig`/callback
30
+ * host-port-path defaults (still overridable — see `XaiHttpDeps`), the HTTP wire shapes
31
+ * (`RouteInputContext` parsing, `Result`/`ApiError` responses, `requireSameOrigin`), and the
32
+ * `x_search` Responses-API call itself (genuinely xAI-specific, no existing home in
33
+ * `@jini-ai/agent-runtime`).
34
+ *
35
+ * **The one genuinely xAI-specific quirk carried over verbatim: the fixed loopback port.** xAI's
36
+ * PoC `client_id` (`XAI_OAUTH_PROVIDER_CONFIG.clientId`, reused from NousResearch/hermes-agent —
37
+ * xAI does not yet publish a public client-registration flow) has its `redirect_uri` locked to
38
+ * `http://127.0.0.1:56121/callback` server-side; a daemon can't register its own. `oauth-callback-
39
+ * server.ts` already made `host`/`port`/`path` generic parameters rather than hardcoded constants,
40
+ * so this file just supplies xAI's fixed values as `XaiHttpDeps`' (overridable, for tests) default
41
+ * (`XAI_OAUTH_REDIRECT_HOST`/`_PORT`/`_PATH`, all from `@jini-ai/agent-runtime`) — no new
42
+ * listener-mechanics code needed.
43
+ *
44
+ * **Dropped: OD's "SuperGrok subscription" gate.** The origin's `POST /api/xai/search` resolved
45
+ * credentials through OD's own multi-source cascade (`resolveProviderConfig(..., 'grok')`:
46
+ * OD-native OAuth token → a separate "Hermes" tool's `auth.json` → `OD_GROK_API_KEY` env var →
47
+ * `XAI_API_KEY` env var) and returned a 401 with product-specific copy
48
+ * ("sign in with your SuperGrok subscription...") when nothing resolved. Both are OD product/billing
49
+ * decisions, not generic engine concerns — a SuperGrok subscription is an OD-specific entitlement
50
+ * concept this daemon route pack does not model. This port checks only "is an xAI OAuth account
51
+ * connected" (via `resolveOAuthBearer` against this file's own token store) and returns a clean
52
+ * `NOT_CONFIGURED` (503) when it isn't; if a connected account isn't actually entitled to
53
+ * `x_search`, xAI's own `/responses` endpoint returns its own real error, which this route surfaces
54
+ * through the same SEC-005 `INTERNAL_ERROR` path as any other upstream failure — no hardcoded
55
+ * pre-flight entitlement check is layered on top of xAI's own answer.
56
+ *
57
+ * **Wire shapes changed from OD's snake_case request body to this package's established camelCase
58
+ * convention** (`allowedXHandles`/`excludedXHandles`/`fromDate`/`toDate`/
59
+ * `enableImageUnderstanding`/`enableVideoUnderstanding`, matching `media.ts`/`connectors.ts`'s own
60
+ * camelCase JSON surfaces) — converted to xAI's real snake_case (`allowed_x_handles`, ...) only when
61
+ * building the actual upstream `x_search` tool payload, the same "camelCase API surface, vendor
62
+ * snake_case is an internal implementation detail" split `research.ts` already applies to Tavily's
63
+ * `search_depth`/`max_results`.
64
+ *
65
+ * **State sharing across requests, resolved once, not per-call.** Unlike `research.ts`'s
66
+ * `resolveCredentials` (stateless — a fresh default is harmless every call) or `connectors.ts`'s
67
+ * per-capability `deps.auth`/`deps.storage` (genuinely-optional-forever, not defaulted at all), this
68
+ * file's `pending` (`PendingAuthCache`) and `listenerRef` (the in-flight loopback listener slot) are
69
+ * mutable state that must be the *same instance* across `oauth/start` → `oauth/complete`/
70
+ * `oauth/cancel`/`oauth/disconnect` calls for the dance to work at all — a fresh `PendingAuthCache`
71
+ * minted independently on every request would mean `start` and `complete` never see each other's
72
+ * state. `xaiRoutes` resolves every optional default exactly once (`resolveXaiHttpDeps`)
73
+ * and hands that single resolved object to every mounted route, so a zero-config
74
+ * `xaiRoutes({ deps: {}, host })` call still shares one cache/listener-slot across the whole
75
+ * mounted lifetime. Each route's own `handle` also calls `resolveXaiHttpDeps` at its top (a
76
+ * defensive, idempotent pass-through when deps are already concrete) purely so individual routes
77
+ * stay directly unit-testable without going through `xaiRoutes` first, matching every other
78
+ * route pack in this package's own test convention — a test exercising a multi-call flow (e.g.
79
+ * start then complete) must pass the same concrete `pending`/`listenerRef` across both calls, the
80
+ * same way a real mounted server does.
81
+ *
82
+ * **SEC-005 throughout**: every thrown error (listener bind failure, token-exchange/refresh
83
+ * failure, token read/write failure, the `x_search` upstream call) is converted to a redacted,
84
+ * correlation-id-bearing generic `INTERNAL_ERROR` before reaching the caller — the HTTP *response*
85
+ * never carries the raw error regardless of source. For the two paths that actually touch an
86
+ * untrusted upstream response body — token exchange/refresh (`handleListenerCallback`/
87
+ * `xaiOauthCompleteRoute`) and `callXaiSearch` (which sends this file's own just-issued bearer
88
+ * token as a header, the highest-risk path) — `redactSecrets` (reused from `@jini-ai/core`'s
89
+ * `connection-guard.ts`, already this package's `research.ts` precedent) additionally strips any
90
+ * Bearer/api-key-shaped text out of the message before it is even logged to the host's own sink
91
+ * (`callXaiSearch`'s own inline redaction; token exchange/refresh failures reach the host sink as the
92
+ * original error, which the host redacts under its own policy), belt-and-braces beyond the generic-message
93
+ * substitution the caller already gets. Purely local failures (a listener-bind `EADDRINUSE`, an
94
+ * `fs` read/write error) carry no upstream text and are passed through to the sink unredacted — the
95
+ * generic response substitution alone already satisfies SEC-005 for those. The one deliberate
96
+ * exception: `completeOAuthPkce`'s own "state not found or expired" / "state mismatch" validation
97
+ * errors (thrown before any network call, carrying no secret) are surfaced verbatim as
98
+ * `BAD_REQUEST` — a legitimate client-correctable error, not an internal failure to redact.
99
+ *
100
+ * **Two known, deliberate, non-functional divergences from OD's exact wire text, both confirmed
101
+ * against the real OD daemon (2026-07-22 live-parity pass) and left as-is:**
102
+ * 1. `GET /api/xai/auth/status` when disconnected: OD's real handler (`routes/xai.ts:205-207`)
103
+ * returns only `{ connected: false, listening }` — `expiresAt`/`scope`/`savedAt` are *omitted*
104
+ * entirely, confirmed live (`{"connected":false,"listening":false}`, no other keys). This file's
105
+ * `XaiAuthStatusResponse` always includes those three keys, set to `null` when disconnected —
106
+ * a deliberate stable-typed-envelope choice (avoids an `expiresAt?: number` optional-vs-null split
107
+ * for callers) consistent with this package's established camelCase/typed-shape departures from
108
+ * OD elsewhere in this same file; not changed to avoid weakening the typed response contract.
109
+ * 2. The "state not found or expired" / "state mismatch" `BAD_REQUEST` text
110
+ * (`@jini-ai/agent-runtime`'s `oauth-provider.ts`) reads `xai OAuth state ...` (lowercase, from the
111
+ * generic `providerId: 'xai'` config field shared across providers), where OD's real, hardcoded
112
+ * string (`integrations/xai-oauth.ts:131,134-136`) reads `xAI OAuth state ...` (mixed-case, a
113
+ * literal specific to that one file). Confirmed live (`{"error":"xAI OAuth state not found or
114
+ * expired"}` from the real daemon). Purely cosmetic — same meaning, same `BAD_REQUEST` classifi-
115
+ * cation either way (`xaiOauthCompleteRoute`'s own prefix check uses the same `providerId` for
116
+ * both generation and matching, so it's internally self-consistent) — and the casing lives in
117
+ * `@jini-ai/agent-runtime`'s already-shipped generic module, outside this file's own scope to alter
118
+ * without special-casing one provider's capitalization inside otherwise-generic code.
119
+ */
120
+ import { redactSecrets } from '@jini-ai/core';
121
+ import { createApiError } from '@jini-ai/protocol';
122
+ import { defineJsonRoute, jsonRoute, validationError, err, ok } from '@jini-ai/core/contracts/server';
123
+ import { trimCharsEnd } from '@jini-ai/core/text';
124
+ import { XAI_OAUTH_PROVIDER_CONFIG, XAI_OAUTH_REDIRECT_HOST, XAI_OAUTH_REDIRECT_PATH, XAI_OAUTH_REDIRECT_PORT } from './preset.js';
125
+ /** Plain words per failing operation; the caller also gets the request ID. */
126
+ const XAI_FAILURE_MESSAGES = {
127
+ 'oauth-start': 'xAI sign-in could not start. Try again; if it keeps failing, copy the request ID and report this problem.',
128
+ 'oauth-complete': 'xAI sign-in could not be completed. Try again; if it keeps failing, copy the request ID and report this problem.',
129
+ 'oauth-disconnect': 'xAI could not be disconnected. Try again; if it keeps failing, copy the request ID and report this problem.',
130
+ 'auth-status': 'The xAI connection status could not be read. Try again; if it keeps failing, copy the request ID and report this problem.',
131
+ search: 'The X search could not be completed. Try again; if it keeps failing, copy the request ID and report this problem.',
132
+ };
133
+ const DEFAULT_TOKEN_FILE_NAME = 'xai-oauth-token.json';
134
+ /** Matches the loopback listener's own 30-minute self-close timeout (OD's real comment: keeps the
135
+ * PKCE state, the open socket, and any paste-back UI expiring together). */
136
+ const DEFAULT_PENDING_AUTH_TTL_MS = 30 * 60 * 1000;
137
+ const DEFAULT_SEARCH_BASE_URL = 'https://api.x.ai/v1';
138
+ /** xAI's real Responses-API model id for `x_search`, per OD's origin `X_SEARCH_DEFAULT_MODEL`. */
139
+ const DEFAULT_SEARCH_MODEL = 'grok-4.20-reasoning';
140
+ /** Deadline for one xAI search request, covering the response body as well as the request. Matches `research.ts`'s `DEFAULT_TAVILY_TIMEOUT_MS` — the two outbound-provider paths in this package should not disagree about how long a stalled upstream may pin a handler. */
141
+ const DEFAULT_SEARCH_TIMEOUT_MS = 30_000;
142
+ /** The one incident owner for every xAI route failure (local wrapper: it picks the message). */
143
+ function reportXaiInternalError({ resolved, source, error }, _optional = {}) {
144
+ return resolved.reportInternalError({ report: { source, error }, logSource: `xai/${source}`, message: XAI_FAILURE_MESSAGES[source] });
145
+ }
146
+ /** Resolves every optional `XaiHttpDeps` field to a concrete value. Idempotent — calling this again on an already-resolved object (e.g. `xaiRoutes`'s own single resolution, passed through to each route's `handle`) is a harmless pass-through. See module doc on why stateful fields (`pending`/`listenerRef`) must be resolved once per registration, not once per request. */
147
+ function resolveXaiHttpDeps(deps) {
148
+ return { ...resolveOAuthFlowDeps(deps), ...resolveStorageAndSearchDeps(deps) };
149
+ }
150
+ /** The OAuth dance's provider, loopback-callback and in-flight state defaults. */
151
+ function resolveOAuthFlowDeps(deps) {
152
+ return {
153
+ providerConfig: deps.providerConfig ?? XAI_OAUTH_PROVIDER_CONFIG,
154
+ callbackHost: deps.callbackHost ?? XAI_OAUTH_REDIRECT_HOST,
155
+ callbackPort: deps.callbackPort ?? XAI_OAUTH_REDIRECT_PORT,
156
+ callbackPath: deps.callbackPath ?? XAI_OAUTH_REDIRECT_PATH,
157
+ pending: deps.pending ?? deps.oauth.createPendingCache({}, { ttlMs: DEFAULT_PENDING_AUTH_TTL_MS }),
158
+ listenerRef: deps.listenerRef ?? { current: null },
159
+ oauth: deps.oauth,
160
+ baseUrlGuard: deps.baseUrlGuard,
161
+ now: deps.now,
162
+ };
163
+ }
164
+ /** Token storage, search transport and error-sink defaults. */
165
+ function resolveStorageAndSearchDeps(deps) {
166
+ return {
167
+ dataDir: deps.dataDir ?? process.cwd(),
168
+ tokenFileName: deps.tokenFileName ?? DEFAULT_TOKEN_FILE_NAME,
169
+ searchBaseUrl: deps.searchBaseUrl ?? DEFAULT_SEARCH_BASE_URL,
170
+ searchDefaultModel: deps.searchDefaultModel ?? DEFAULT_SEARCH_MODEL,
171
+ fetchImpl: deps.fetchImpl ?? fetch,
172
+ searchTimeoutMs: deps.searchTimeoutMs ?? DEFAULT_SEARCH_TIMEOUT_MS,
173
+ reportInternalError: deps.reportInternalError,
174
+ };
175
+ }
176
+ function xaiRedirectUri(resolved) {
177
+ return `http://${resolved.callbackHost}:${resolved.callbackPort}${resolved.callbackPath}`;
178
+ }
179
+ /** Tracks only the state's lookup key; `PendingAuthCache` remains the single-use authorization owner.
180
+ * Keying by the shared listener slot keeps cancellation scoped to one mounted route pack. */
181
+ const pendingOAuthStates = new WeakMap();
182
+ /** Revokes the pending state before stopping and clearing its listener. Listener shutdown is
183
+ * best-effort — the listener self-closes on completion/timeout anyway, matching OD's origin
184
+ * `stopActiveListener`. Revocation must precede the await so a late paste-back cannot reconnect. */
185
+ async function stopListener({ listenerRef, pending }, _optional = {}) {
186
+ const state = pendingOAuthStates.get(listenerRef);
187
+ pendingOAuthStates.delete(listenerRef);
188
+ if (state !== undefined)
189
+ pending.consume({ state });
190
+ const current = listenerRef.current;
191
+ listenerRef.current = null;
192
+ if (!current)
193
+ return;
194
+ try {
195
+ await current.stop();
196
+ }
197
+ catch {
198
+ // Best-effort only — see this function's own doc.
199
+ }
200
+ }
201
+ /**
202
+ * Serializes OAuth starts that share one `listenerRef`, keyed by the ref object itself (a
203
+ * `WeakMap`, so a host that discards a registration's deps does not leak an entry here).
204
+ *
205
+ * The loopback callback port is a singleton, and `oauth/start` both checks and claims it
206
+ * (`listenerRef.current`) across two `await`s (`beginOAuthPkce` then `startCallbackListener`).
207
+ * Without serializing, two concurrent starts could both observe `listenerRef.current === null`
208
+ * before either claimed it, both proceed to open a listener, and the second's write would
209
+ * silently clobber the first's — the first caller would already have been handed an
210
+ * `authorizeUrl` whose callback endpoint just died, with no error ever surfaced to it. That is
211
+ * the exact race `xaiOauthStartRoute`'s own `OAUTH_FLOW_IN_PROGRESS` conflict check exists to
212
+ * reject instead of silently losing. Serializing makes "check the slot, then claim it" the single
213
+ * indivisible step it always needed to be, so that check can never race with itself.
214
+ */
215
+ const oauthStartQueues = new WeakMap();
216
+ function serializeOauthStart(key, task) {
217
+ const previous = oauthStartQueues.get(key) ?? Promise.resolve();
218
+ // `then(task, task)` so a rejected predecessor still lets the next start run — this is a mutex,
219
+ // not a dependency chain.
220
+ const next = previous.then(task, task);
221
+ // The stored link must never reject, or an unhandled rejection escapes and every later start
222
+ // inherits it. Only the returned promise carries the outcome.
223
+ oauthStartQueues.set(key, next.then(() => undefined, () => undefined));
224
+ return next;
225
+ }
226
+ /**
227
+ * Maps a token-endpoint response onto the persisted record. Pure (the save instant is a parameter)
228
+ * so the mapping is testable on its own. `token_type` is optional on the wire type; today's
229
+ * exchange path always supplies it (openid-client rejects a response without one), and an absent
230
+ * value is stored as RFC 6750's `Bearer`. Exported for this module's tests; not re-exported.
231
+ */
232
+ export function toStoredOAuthToken({ tokenResp, nowMs }) {
233
+ const stored = {
234
+ accessToken: tokenResp.access_token,
235
+ tokenType: tokenResp.token_type ?? 'Bearer',
236
+ savedAt: nowMs,
237
+ };
238
+ if (tokenResp.refresh_token)
239
+ stored.refreshToken = tokenResp.refresh_token;
240
+ if (tokenResp.scope)
241
+ stored.scope = tokenResp.scope;
242
+ if (typeof tokenResp.expires_in === 'number') {
243
+ stored.expiresAt = nowMs + tokenResp.expires_in * 1000;
244
+ }
245
+ return stored;
246
+ }
247
+ async function persistToken(resolved, tokenResp) {
248
+ const stored = toStoredOAuthToken({ tokenResp, nowMs: resolved.now() });
249
+ await resolved.oauth.tokens.set({ dataDir: resolved.dataDir, fileName: resolved.tokenFileName, token: stored });
250
+ }
251
+ /** Invoked when the loopback listener actually receives xAI's redirect (the real-browser path, as opposed to `oauth/complete`'s manual paste-back path — xAI's own docs note the loopback redirect commonly shows the user a code to paste rather than following the redirect). No HTTP response to write here; failures are only reported through the internal-error sink. */
252
+ async function handleListenerCallback(resolved, outcome) {
253
+ resolved.listenerRef.current = null;
254
+ if (outcome.kind !== 'ok') {
255
+ reportXaiInternalError({ resolved, source: 'oauth-start', error: new Error(`xAI OAuth callback failed: ${outcome.error}`) });
256
+ return;
257
+ }
258
+ try {
259
+ const tokenResp = await resolved.oauth.complete({
260
+ config: resolved.providerConfig,
261
+ pending: resolved.pending,
262
+ state: outcome.state,
263
+ code: outcome.code
264
+ }, {
265
+ fetchImpl: resolved.fetchImpl
266
+ });
267
+ await persistToken(resolved, tokenResp);
268
+ }
269
+ catch (error) {
270
+ reportXaiInternalError({ resolved, source: 'oauth-start', error });
271
+ }
272
+ }
273
+ function isRecord(value) {
274
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
275
+ }
276
+ /** Trims before checking/returning — matches OD's real route handlers, which trim `state`/`code`
277
+ * (`routes/xai.ts:154-157`) and `query` (`routes/xai.ts:258`) before ever using them, so a
278
+ * paste-back value with incidental leading/trailing whitespace (the common case for xAI's own
279
+ * loopback-redirect UX, which shows the user a code to copy rather than following a redirect — see
280
+ * this file's own `xaiOauthCompleteRoute` doc) still matches the exact state string the pending-auth
281
+ * cache stored it under. Live-verified against the real OD daemon (2026-07-22 live-parity pass):
282
+ * `POST /oauth/complete` with a state padded in extra spaces around a real, still-pending state
283
+ * proceeded straight to the token exchange (reaching `auth.x.ai`'s real "invalid_grant" response)
284
+ * instead of failing with "state not found or expired" — proving OD's server-side trim, not just its
285
+ * request-body parsing, is load-bearing. This file's own three `nonEmptyString` call sites
286
+ * (`state`/`code` in `parseXaiOauthComplete`, `query` in `parseXaiSearch`) are exactly OD's three
287
+ * trimmed fields — `fromDate`/`toDate`/`model` deliberately go through `parseOptionalString` instead,
288
+ * which does not trim, matching OD's own untrimmed `from_date`/`to_date`/`model` handling. */
289
+ function nonEmptyString(value) {
290
+ if (typeof value !== 'string')
291
+ return null;
292
+ const trimmed = value.trim();
293
+ return trimmed.length > 0 ? trimmed : null;
294
+ }
295
+ function parseOptionalString(body, key) {
296
+ const value = body[key];
297
+ if (value === undefined)
298
+ return ok({ value: undefined });
299
+ if (typeof value !== 'string')
300
+ return err({ error: validationError({ message: `${key} must be a string when provided` }) });
301
+ return ok({ value });
302
+ }
303
+ function parseOptionalBoolean(body, key) {
304
+ const value = body[key];
305
+ if (value === undefined)
306
+ return ok({ value: undefined });
307
+ if (typeof value !== 'boolean')
308
+ return err({ error: validationError({ message: `${key} must be a boolean when provided` }) });
309
+ return ok({ value });
310
+ }
311
+ function parseOptionalStringArray(body, key) {
312
+ const value = body[key];
313
+ if (value === undefined)
314
+ return ok({ value: undefined });
315
+ if (!Array.isArray(value) || !value.every((v) => typeof v === 'string')) {
316
+ return err({ error: validationError({ message: `${key} must be an array of strings when provided` }) });
317
+ }
318
+ return ok({ value: value });
319
+ }
320
+ export const xaiOauthStartRoute = defineJsonRoute({
321
+ method: 'post', path: '/api/xai/oauth/start', parse: () => ok({ value: undefined }), handle: async ({ input: _input, deps }) => {
322
+ const resolved = resolveXaiHttpDeps(deps);
323
+ // Only one OAuth dance can be in flight at a time — the loopback port is a singleton. A
324
+ // second `start` arriving while a listener from a prior `start` is still bound/waiting used
325
+ // to silently stop that listener and open a new one: the first caller's already-returned
326
+ // `authorizeUrl` would point at a now-dead callback endpoint with no error ever surfaced to
327
+ // it. Fail loud instead: reject with a conflict and require the caller to finish
328
+ // (`oauth/complete`) or explicitly cancel (`POST /api/xai/oauth/cancel`) the in-flight flow
329
+ // first. The check-then-claim runs under `serializeOauthStart` so two concurrent starts can't
330
+ // both observe an empty slot — see that function's doc.
331
+ return serializeOauthStart(resolved.listenerRef, async () => {
332
+ if (resolved.listenerRef.current !== null) {
333
+ return err({
334
+ error: createApiError({ code: 'OAUTH_FLOW_IN_PROGRESS', message: 'an xAI OAuth flow is already in progress — complete it, or cancel it via POST /api/xai/oauth/cancel, before starting a new one' })
335
+ });
336
+ }
337
+ try {
338
+ const { authorizeUrl, state } = resolved.oauth.begin({
339
+ config: resolved.providerConfig,
340
+ pending: resolved.pending,
341
+ redirectUri: xaiRedirectUri(resolved),
342
+ });
343
+ pendingOAuthStates.set(resolved.listenerRef, state);
344
+ const listener = await resolved.oauth.startCallbackListener({
345
+ host: resolved.callbackHost,
346
+ port: resolved.callbackPort,
347
+ path: resolved.callbackPath,
348
+ expectedState: state,
349
+ onCallback: (outcome) => handleListenerCallback(resolved, outcome),
350
+ });
351
+ resolved.listenerRef.current = listener;
352
+ return ok({
353
+ value: {
354
+ authorizeUrl,
355
+ state,
356
+ callback: { host: listener.address.host, port: listener.address.port },
357
+ }
358
+ });
359
+ }
360
+ catch (error) {
361
+ await stopListener(resolved);
362
+ return err({ error: reportXaiInternalError({ resolved, source: 'oauth-start', error }) });
363
+ }
364
+ });
365
+ }
366
+ }, { requireSameOrigin: true });
367
+ function parseXaiOauthComplete(input) {
368
+ if (!isRecord(input.body))
369
+ return err({ error: validationError({ message: 'body must be a JSON object' }) });
370
+ const state = nonEmptyString(input.body.state);
371
+ if (!state)
372
+ return err({ error: validationError({ message: 'state must be a non-empty string' }, { issues: [{ path: 'state', message: 'required non-empty string' }] }) });
373
+ const code = nonEmptyString(input.body.code);
374
+ if (!code)
375
+ return err({ error: validationError({ message: 'code must be a non-empty string' }, { issues: [{ path: 'code', message: 'required non-empty string' }] }) });
376
+ return ok({ value: { state, code } });
377
+ }
378
+ export const xaiOauthCompleteRoute = defineJsonRoute({
379
+ method: 'post', path: '/api/xai/oauth/complete', parse: parseXaiOauthComplete, handle: async ({ input: { state, code }, deps }) => {
380
+ const resolved = resolveXaiHttpDeps(deps);
381
+ try {
382
+ const tokenResp = await resolved.oauth.complete({
383
+ config: resolved.providerConfig,
384
+ pending: resolved.pending,
385
+ state,
386
+ code
387
+ }, {
388
+ fetchImpl: resolved.fetchImpl
389
+ });
390
+ await persistToken(resolved, tokenResp);
391
+ // We won the race against the loopback listener (or it was never going to resolve in the
392
+ // first place); shut it down so the next `oauth/start` has a clean slate — matching OD's
393
+ // origin behavior on a successful manual paste-back.
394
+ await stopListener(resolved);
395
+ return ok({ value: { ok: true } });
396
+ }
397
+ catch (error) {
398
+ const message = error instanceof Error ? error.message : String(error);
399
+ // `completeOAuthPkce`'s own pre-network validation errors ("state not found or expired",
400
+ // "state mismatch...") carry no secret and are a legitimate client-correctable failure —
401
+ // surfaced verbatim as BAD_REQUEST rather than folded into the SEC-005 INTERNAL_ERROR path
402
+ // below (see module doc's "SEC-005 throughout" section). Exact-prefix match, not substring:
403
+ // pkce.ts#tokenRequest's upstream-error message ("token endpoint rejected request: ...")
404
+ // can legitimately contain the substring "OAuth state" inside an attacker-influenced token
405
+ // endpoint error body, which must never be reflected raw to the caller.
406
+ if (message.startsWith(`${resolved.providerConfig.providerId} OAuth state`)) {
407
+ return err({ error: validationError({ message }) });
408
+ }
409
+ return err({ error: reportXaiInternalError({ resolved, source: 'oauth-complete', error }) });
410
+ }
411
+ }
412
+ }, { requireSameOrigin: true });
413
+ // ---------------------------------------------------------------------------
414
+ // POST /api/xai/oauth/cancel
415
+ // ---------------------------------------------------------------------------
416
+ export const xaiOauthCancelRoute = defineJsonRoute({
417
+ method: 'post', path: '/api/xai/oauth/cancel', parse: () => ok({ value: undefined }), handle: async ({ input: _input, deps }) => {
418
+ const resolved = resolveXaiHttpDeps(deps);
419
+ // Cancel revokes the pending state and stops the listener; it must never wipe a stored
420
+ // token — a user clicking Cancel mid-reconnect would otherwise lose their existing grant. Disconnect
421
+ // (below) is the destructive path. Preserves OD's origin `oauth/cancel` token-retention behavior.
422
+ await stopListener(resolved);
423
+ return ok({ value: { ok: true } });
424
+ }
425
+ }, { requireSameOrigin: true });
426
+ export const xaiAuthStatusRoute = defineJsonRoute({
427
+ method: 'get', path: '/api/xai/auth/status', parse: () => ok({ value: undefined }), handle: async ({ input: _input, deps }) => {
428
+ const resolved = resolveXaiHttpDeps(deps);
429
+ try {
430
+ const token = await resolved.oauth.tokens.get({ dataDir: resolved.dataDir, fileName: resolved.tokenFileName });
431
+ const listening = resolved.listenerRef.current !== null;
432
+ if (!token)
433
+ return ok({ value: { connected: false, expiresAt: null, scope: null, savedAt: null, listening } });
434
+ return ok({
435
+ value: {
436
+ connected: true,
437
+ expiresAt: token.expiresAt ?? null,
438
+ scope: token.scope ?? null,
439
+ savedAt: token.savedAt,
440
+ listening,
441
+ }
442
+ });
443
+ }
444
+ catch (error) {
445
+ return err({ error: reportXaiInternalError({ resolved, source: 'auth-status', error }) });
446
+ }
447
+ }
448
+ }, { requireSameOrigin: true });
449
+ // ---------------------------------------------------------------------------
450
+ // POST /api/xai/oauth/disconnect
451
+ // ---------------------------------------------------------------------------
452
+ export const xaiOauthDisconnectRoute = defineJsonRoute({
453
+ method: 'post', path: '/api/xai/oauth/disconnect', parse: () => ok({ value: undefined }), handle: async ({ input: _input, deps }) => {
454
+ const resolved = resolveXaiHttpDeps(deps);
455
+ try {
456
+ await stopListener(resolved);
457
+ await resolved.oauth.tokens.clear({ dataDir: resolved.dataDir, fileName: resolved.tokenFileName });
458
+ return ok({ value: { ok: true } });
459
+ }
460
+ catch (error) {
461
+ return err({ error: reportXaiInternalError({ resolved, source: 'oauth-disconnect', error }) });
462
+ }
463
+ }
464
+ }, { requireSameOrigin: true });
465
+ function parseXaiSearch(input) {
466
+ if (!isRecord(input.body))
467
+ return err({ error: validationError({ message: 'body must be a JSON object' }) });
468
+ const body = input.body;
469
+ const query = nonEmptyString(body.query);
470
+ if (!query)
471
+ return err({ error: validationError({ message: 'query must be a non-empty string' }, { issues: [{ path: 'query', message: 'required non-empty string' }] }) });
472
+ const fields = {};
473
+ for (const [key, parse] of XAI_SEARCH_OPTIONAL_FIELDS) {
474
+ const parsed = parse(body, key);
475
+ if (!parsed.ok)
476
+ return parsed;
477
+ if (isProvidedSearchValue(parsed.value))
478
+ fields[key] = parsed.value;
479
+ }
480
+ return ok({ value: { query, ...fields } });
481
+ }
482
+ /** Table order is the validation order: the first failing field is the one a caller sees. */
483
+ const XAI_SEARCH_OPTIONAL_FIELDS = [
484
+ ['allowedXHandles', parseOptionalStringArray],
485
+ ['excludedXHandles', parseOptionalStringArray],
486
+ ['fromDate', parseOptionalString],
487
+ ['toDate', parseOptionalString],
488
+ ['enableImageUnderstanding', parseOptionalBoolean],
489
+ ['enableVideoUnderstanding', parseOptionalBoolean],
490
+ ['model', parseOptionalString],
491
+ ];
492
+ /** An empty string or empty handle list counts as not provided (dropped from the request); `false` is kept. */
493
+ function isProvidedSearchValue(value) {
494
+ if (Array.isArray(value))
495
+ return value.length > 0;
496
+ return value !== undefined && value !== '';
497
+ }
498
+ /** Every well-formed `output[].content[]` block of a Responses-API payload, skipping malformed items and blocks. */
499
+ function outputContentBlocks(data) {
500
+ const output = data.output;
501
+ if (!Array.isArray(output))
502
+ return [];
503
+ return output.filter(isRecord).flatMap((item) => (Array.isArray(item.content) ? item.content.filter(isRecord) : []));
504
+ }
505
+ /** Pulls the assistant's main text out of an xAI Responses-API payload — the convenience `output_text` field, or the structured `output[].content[].text` form. Ported from OD's `extractAnswerText` (same behaviour; the walk is shared with `extractUrlCitations` via `outputContentBlocks`). */
506
+ function extractAnswerText(data) {
507
+ if (!isRecord(data))
508
+ return '';
509
+ const direct = data.output_text;
510
+ if (typeof direct === 'string' && direct.trim())
511
+ return direct;
512
+ const chunks = outputContentBlocks(data)
513
+ .map((block) => block.text)
514
+ .filter((text) => typeof text === 'string' && text.length > 0);
515
+ return chunks.join('\n').trim();
516
+ }
517
+ /** The trimmed URL of one `url_citation` annotation, or `''` for anything else. */
518
+ function urlCitationOf(annotation) {
519
+ if (!isRecord(annotation) || annotation.type !== 'url_citation')
520
+ return '';
521
+ return typeof annotation.url === 'string' ? annotation.url.trim() : '';
522
+ }
523
+ /** Walks every annotation in the Responses-API output and returns the unique URL citations (`type: 'url_citation'`). Ported from OD's `extractUrlCitations` (same behaviour, first-seen order). */
524
+ function extractUrlCitations(data) {
525
+ if (!isRecord(data))
526
+ return [];
527
+ const urls = outputContentBlocks(data)
528
+ .flatMap((block) => (Array.isArray(block.annotations) ? block.annotations : []))
529
+ .map(urlCitationOf)
530
+ .filter((url) => url.length > 0);
531
+ return [...new Set(urls)];
532
+ }
533
+ /** Builds the `x_search` native tool payload, translating only the provided fields to xAI's snake_case names. */
534
+ function buildXSearchTool(request) {
535
+ const xSearchTool = { type: 'x_search' };
536
+ if (request.allowedXHandles?.length)
537
+ xSearchTool.allowed_x_handles = request.allowedXHandles;
538
+ if (request.excludedXHandles?.length)
539
+ xSearchTool.excluded_x_handles = request.excludedXHandles;
540
+ if (request.fromDate)
541
+ xSearchTool.from_date = request.fromDate;
542
+ if (request.toDate)
543
+ xSearchTool.to_date = request.toDate;
544
+ if (request.enableImageUnderstanding === true)
545
+ xSearchTool.enable_image_understanding = true;
546
+ if (request.enableVideoUnderstanding === true)
547
+ xSearchTool.enable_video_understanding = true;
548
+ return xSearchTool;
549
+ }
550
+ /** A thrown fetch/body-read failure as the timeout message when the deadline fired, else as a `prefix: message` with `accessToken` redacted. */
551
+ function xaiCallFailure(guard, prefix, error) {
552
+ if (guard.signal.aborted)
553
+ return new Error(guard.timedOutMessage);
554
+ const message = error instanceof Error ? error.message : String(error);
555
+ return new Error(redactSecrets({ input: `${prefix}: ${message}` }, { exactSecrets: [guard.accessToken] }));
556
+ }
557
+ async function postXaiResponses({ fetchImpl, url, requestBody, guard }) {
558
+ let response;
559
+ try {
560
+ response = await fetchImpl(url, {
561
+ method: 'POST',
562
+ headers: { authorization: `Bearer ${guard.accessToken}`, 'content-type': 'application/json' },
563
+ body: JSON.stringify(requestBody),
564
+ signal: guard.signal,
565
+ });
566
+ }
567
+ catch (error) {
568
+ throw xaiCallFailure(guard, 'xAI request failed', error);
569
+ }
570
+ if (!response.ok) {
571
+ const text = await response.text().catch(() => '');
572
+ throw new Error(redactSecrets({ input: `xAI ${response.status}: ${text.slice(0, 240) || 'no body'}` }, { exactSecrets: [guard.accessToken] }));
573
+ }
574
+ return response;
575
+ }
576
+ async function readXaiJson(response, guard) {
577
+ try {
578
+ return await response.json();
579
+ }
580
+ catch (error) {
581
+ throw xaiCallFailure(guard, 'xAI response could not be read', error);
582
+ }
583
+ }
584
+ /** Calls xAI's real `POST {searchBaseUrl}/responses` endpoint with the `x_search` native tool, using `accessToken` as the bearer credential. Throws (never a `Result`) on any failure — `xaiSearchRoute.handle` is the one place that converts a thrown error into this package's SEC-005 response shape. Any thrown message is pre-redacted of `accessToken` here so the sink never even logs it unredacted. */
585
+ async function callXaiSearch(resolved, accessToken, request) {
586
+ const baseUrlCheck = resolved.baseUrlGuard.validate({ baseUrl: resolved.searchBaseUrl });
587
+ if (baseUrlCheck.error)
588
+ throw new Error(baseUrlCheck.error);
589
+ const base = trimCharsEnd({ text: resolved.searchBaseUrl, chars: '/' });
590
+ const model = request.model ?? resolved.searchDefaultModel;
591
+ const requestBody = {
592
+ model,
593
+ input: [{ role: 'user', content: request.query }],
594
+ tools: [buildXSearchTool(request)],
595
+ store: false,
596
+ };
597
+ // One deadline covering the request *and* the body read, mirroring `research.ts`'s Tavily call.
598
+ // Arming it only around `fetch` would leave the far more common stall unbounded: an upstream that
599
+ // returns headers promptly and then never finishes the body still pins this handler, its socket
600
+ // and the caller's connection forever. The timer is cleared in a `finally` so a fast response
601
+ // does not leave one armed.
602
+ const timeoutController = new AbortController();
603
+ const timeoutHandle = setTimeout(() => timeoutController.abort(), resolved.searchTimeoutMs);
604
+ const guard = {
605
+ signal: timeoutController.signal,
606
+ timedOutMessage: `xAI request timed out after ${resolved.searchTimeoutMs}ms`,
607
+ accessToken,
608
+ };
609
+ try {
610
+ const response = await postXaiResponses({ fetchImpl: resolved.fetchImpl, url: `${base}/responses`, requestBody, guard });
611
+ const data = await readXaiJson(response, guard);
612
+ return { answer: extractAnswerText(data), citations: extractUrlCitations(data), model };
613
+ }
614
+ finally {
615
+ clearTimeout(timeoutHandle);
616
+ }
617
+ }
618
+ export const xaiSearchRoute = defineJsonRoute({
619
+ method: 'post', path: '/api/xai/search', parse: parseXaiSearch, handle: async ({ input: request, deps }) => {
620
+ const resolved = resolveXaiHttpDeps(deps);
621
+ let credential;
622
+ try {
623
+ credential = await resolved.oauth.resolveBearer({ config: resolved.providerConfig, tokenFileName: resolved.tokenFileName, dataDir: resolved.dataDir }, { fetchImpl: resolved.fetchImpl });
624
+ }
625
+ catch (error) {
626
+ return err({ error: reportXaiInternalError({ resolved, source: 'search', error }) });
627
+ }
628
+ if (!credential) {
629
+ // No entitlement gate here — see module doc's "Dropped: OD's SuperGrok subscription gate"
630
+ // section. This is only "no connected/refreshable xAI account," an honest, non-exceptional
631
+ // NOT_CONFIGURED (503), matching `research.ts`'s "capability exists, reachable, inert until
632
+ // configured" shape.
633
+ return err({ error: createApiError({ code: 'NOT_CONFIGURED', message: 'no xAI account connected — sign in via /api/xai/oauth/start first' }) });
634
+ }
635
+ try {
636
+ const result = await callXaiSearch(resolved, credential.accessToken, request);
637
+ return ok({ value: result });
638
+ }
639
+ catch (error) {
640
+ return err({ error: reportXaiInternalError({ resolved, source: 'search', error }) });
641
+ }
642
+ }
643
+ }, { requireSameOrigin: true });
644
+ /** `deps` with the host's reporter added, without copying `deps`: every member stays readable through the original object. */
645
+ function withHostReporter({ deps, host }, _optional = {}) {
646
+ return Object.create(deps, { reportInternalError: { value: host.reportInternalError, enumerable: true } });
647
+ }
648
+ /** One JSON spec as a server route: the host's body limit bounds (never replaces) the spec's, and the host's reporter is applied. The same-origin check is the JSON route's own, driven by `requireSameOrigin`. */
649
+ function hostedJsonRoute({ spec, deps, host }, _optional = {}) {
650
+ const maxBodyBytes = Math.min(spec.maxBodyBytes ?? host.jsonBodyMaxBytes, host.jsonBodyMaxBytes);
651
+ return jsonRoute({ spec: { ...spec, maxBodyBytes }, deps, reportInternalError: host.reportInternalError }, { host: host.context });
652
+ }
653
+ /** Every xAI route as data, each behind the same-origin gate its spec declares. Defaults are resolved once per call, so the routes share one pending-auth cache and listener slot. Internal failures are reported through the host's reporter. */
654
+ export function xaiRoutes({ deps, host }, _optional = {}) {
655
+ const routeDeps = resolveXaiHttpDeps(withHostReporter({ deps, host }));
656
+ const json = (spec) => hostedJsonRoute({ spec, deps: routeDeps, host });
657
+ return [json(xaiOauthStartRoute), json(xaiOauthCompleteRoute), json(xaiOauthCancelRoute), json(xaiAuthStatusRoute), json(xaiOauthDisconnectRoute), json(xaiSearchRoute)];
658
+ }