glirastes 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +146 -9
  3. package/codegen/package.json +5 -0
  4. package/dist/cjs/codegen/asset-sync.d.ts +20 -0
  5. package/dist/cjs/codegen/asset-sync.js +28 -0
  6. package/dist/cjs/codegen/coverage.d.ts +66 -0
  7. package/dist/cjs/codegen/coverage.js +408 -0
  8. package/dist/cjs/codegen/endpoint-scanner.d.ts +16 -0
  9. package/dist/cjs/codegen/endpoint-scanner.js +197 -0
  10. package/dist/cjs/codegen/format.d.ts +17 -0
  11. package/dist/cjs/codegen/format.js +34 -0
  12. package/dist/cjs/codegen/fs-utils.d.ts +45 -0
  13. package/dist/cjs/codegen/fs-utils.js +165 -0
  14. package/dist/cjs/codegen/index.d.ts +13 -0
  15. package/dist/cjs/codegen/index.js +33 -0
  16. package/dist/cjs/codegen/mcp-generator.d.ts +50 -0
  17. package/dist/cjs/codegen/mcp-generator.js +803 -0
  18. package/dist/cjs/codegen/module-generator.d.ts +11 -0
  19. package/dist/cjs/codegen/module-generator.js +353 -0
  20. package/dist/cjs/codegen/nestjs-scanner.d.ts +43 -0
  21. package/dist/cjs/codegen/nestjs-scanner.js +241 -0
  22. package/dist/cjs/codegen/output-recommender.d.ts +23 -0
  23. package/dist/cjs/codegen/output-recommender.js +33 -0
  24. package/dist/cjs/codegen/scaffolder.d.ts +36 -0
  25. package/dist/cjs/codegen/scaffolder.js +262 -0
  26. package/dist/cjs/codegen/skill-generator.d.ts +49 -0
  27. package/dist/cjs/codegen/skill-generator.js +967 -0
  28. package/dist/cjs/codegen/types.d.ts +52 -0
  29. package/dist/cjs/codegen/types.js +16 -0
  30. package/dist/cjs/codegen/ui-scanner.d.ts +24 -0
  31. package/dist/cjs/codegen/ui-scanner.js +202 -0
  32. package/dist/cjs/codegen/validator.d.ts +35 -0
  33. package/dist/cjs/codegen/validator.js +292 -0
  34. package/dist/cjs/index.d.ts +1 -0
  35. package/dist/cjs/index.js +23 -0
  36. package/dist/cjs/openapi/index.d.ts +78 -0
  37. package/dist/cjs/openapi/index.js +347 -0
  38. package/dist/cjs/package.json +1 -0
  39. package/dist/cjs/react/audio-worklet-processor.d.ts +16 -0
  40. package/dist/cjs/react/audio-worklet-processor.js +27 -0
  41. package/dist/cjs/react/bridges/rest-session-bridge.d.ts +113 -0
  42. package/dist/cjs/react/bridges/rest-session-bridge.js +209 -0
  43. package/dist/cjs/react/components/ai-chat-panel.d.ts +12 -0
  44. package/dist/cjs/react/components/ai-chat-panel.js +67 -0
  45. package/dist/cjs/react/components/ai-trigger-button.d.ts +2 -0
  46. package/dist/cjs/react/components/ai-trigger-button.js +239 -0
  47. package/dist/cjs/react/components/approval-card.d.ts +9 -0
  48. package/dist/cjs/react/components/approval-card.js +24 -0
  49. package/dist/cjs/react/components/bulk-approval-card.d.ts +9 -0
  50. package/dist/cjs/react/components/bulk-approval-card.js +36 -0
  51. package/dist/cjs/react/components/chat-input.d.ts +10 -0
  52. package/dist/cjs/react/components/chat-input.js +60 -0
  53. package/dist/cjs/react/components/chat-window.d.ts +2 -0
  54. package/dist/cjs/react/components/chat-window.js +134 -0
  55. package/dist/cjs/react/components/confirm-dialog.d.ts +32 -0
  56. package/dist/cjs/react/components/confirm-dialog.js +48 -0
  57. package/dist/cjs/react/components/floating-chat-ui.d.ts +90 -0
  58. package/dist/cjs/react/components/floating-chat-ui.js +163 -0
  59. package/dist/cjs/react/components/mention-chip.d.ts +16 -0
  60. package/dist/cjs/react/components/mention-chip.js +42 -0
  61. package/dist/cjs/react/components/mention-input.d.ts +8 -0
  62. package/dist/cjs/react/components/mention-input.js +117 -0
  63. package/dist/cjs/react/components/message-bubble.d.ts +11 -0
  64. package/dist/cjs/react/components/message-bubble.js +171 -0
  65. package/dist/cjs/react/components/message-list.d.ts +8 -0
  66. package/dist/cjs/react/components/message-list.js +52 -0
  67. package/dist/cjs/react/components/pipeline-timeline.d.ts +7 -0
  68. package/dist/cjs/react/components/pipeline-timeline.js +72 -0
  69. package/dist/cjs/react/components/recording-bar.d.ts +2 -0
  70. package/dist/cjs/react/components/recording-bar.js +81 -0
  71. package/dist/cjs/react/components/recording-controls.d.ts +18 -0
  72. package/dist/cjs/react/components/recording-controls.js +38 -0
  73. package/dist/cjs/react/components/rich-mention-input.d.ts +2 -0
  74. package/dist/cjs/react/components/rich-mention-input.js +571 -0
  75. package/dist/cjs/react/components/session-switcher.d.ts +14 -0
  76. package/dist/cjs/react/components/session-switcher.js +133 -0
  77. package/dist/cjs/react/components/suggestion-bar.d.ts +9 -0
  78. package/dist/cjs/react/components/suggestion-bar.js +47 -0
  79. package/dist/cjs/react/components/suggestion-chip.d.ts +9 -0
  80. package/dist/cjs/react/components/suggestion-chip.js +14 -0
  81. package/dist/cjs/react/components/voice-input-addon.d.ts +13 -0
  82. package/dist/cjs/react/components/voice-input-addon.js +31 -0
  83. package/dist/cjs/react/components/voice-input-button.d.ts +2 -0
  84. package/dist/cjs/react/components/voice-input-button.js +55 -0
  85. package/dist/cjs/react/components/wavesurfer-loader.d.ts +5 -0
  86. package/dist/cjs/react/components/wavesurfer-loader.js +36 -0
  87. package/dist/cjs/react/hooks/use-ai-chat.d.ts +22 -0
  88. package/dist/cjs/react/hooks/use-ai-chat.js +51 -0
  89. package/dist/cjs/react/hooks/use-approvals.d.ts +23 -0
  90. package/dist/cjs/react/hooks/use-approvals.js +63 -0
  91. package/dist/cjs/react/hooks/use-deepgram-transcription.d.ts +2 -0
  92. package/dist/cjs/react/hooks/use-deepgram-transcription.js +329 -0
  93. package/dist/cjs/react/hooks/use-drag-resize-panel.d.ts +48 -0
  94. package/dist/cjs/react/hooks/use-drag-resize-panel.js +308 -0
  95. package/dist/cjs/react/hooks/use-draggable-position.d.ts +25 -0
  96. package/dist/cjs/react/hooks/use-draggable-position.js +134 -0
  97. package/dist/cjs/react/hooks/use-keyboard-shortcut.d.ts +20 -0
  98. package/dist/cjs/react/hooks/use-keyboard-shortcut.js +93 -0
  99. package/dist/cjs/react/hooks/use-mentions.d.ts +23 -0
  100. package/dist/cjs/react/hooks/use-mentions.js +42 -0
  101. package/dist/cjs/react/hooks/use-suggestions.d.ts +22 -0
  102. package/dist/cjs/react/hooks/use-suggestions.js +39 -0
  103. package/dist/cjs/react/index.d.ts +43 -0
  104. package/dist/cjs/react/index.js +111 -0
  105. package/dist/cjs/react/provider/ai-chat-provider.d.ts +45 -0
  106. package/dist/cjs/react/provider/ai-chat-provider.js +1024 -0
  107. package/dist/cjs/react/provider/chat-context.d.ts +84 -0
  108. package/dist/cjs/react/provider/chat-context.js +13 -0
  109. package/dist/cjs/react/template.d.ts +84 -0
  110. package/dist/cjs/react/template.js +90 -0
  111. package/dist/cjs/react/themes.d.ts +24 -0
  112. package/dist/cjs/react/themes.js +273 -0
  113. package/dist/cjs/react/transports/langgraph/index.d.ts +2 -0
  114. package/dist/cjs/react/transports/langgraph/index.js +8 -0
  115. package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.d.ts +62 -0
  116. package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.js +94 -0
  117. package/dist/cjs/react/transports/langgraph.d.ts +71 -0
  118. package/dist/cjs/react/transports/langgraph.js +369 -0
  119. package/dist/cjs/react/transports/vercel/index.d.ts +2 -0
  120. package/dist/cjs/react/transports/vercel/index.js +8 -0
  121. package/dist/cjs/react/transports/vercel/vercel-ai-chat.d.ts +49 -0
  122. package/dist/cjs/react/transports/vercel/vercel-ai-chat.js +81 -0
  123. package/dist/cjs/react/transports/vercel.d.ts +30 -0
  124. package/dist/cjs/react/transports/vercel.js +69 -0
  125. package/dist/cjs/react/types.d.ts +760 -0
  126. package/dist/cjs/react/types.js +2 -0
  127. package/dist/cjs/react/ui.d.ts +73 -0
  128. package/dist/cjs/react/ui.js +183 -0
  129. package/dist/cjs/react/utils/create-approval-description.d.ts +53 -0
  130. package/dist/cjs/react/utils/create-approval-description.js +122 -0
  131. package/dist/cjs/react/utils/create-tool-result-handler.d.ts +90 -0
  132. package/dist/cjs/react/utils/create-tool-result-handler.js +168 -0
  133. package/dist/cjs/react/utils/mention-markup.d.ts +13 -0
  134. package/dist/cjs/react/utils/mention-markup.js +117 -0
  135. package/dist/cjs/react/utils/merge-pipeline-steps.d.ts +19 -0
  136. package/dist/cjs/react/utils/merge-pipeline-steps.js +81 -0
  137. package/dist/cjs/react/utils/sanitize-stored-messages.d.ts +23 -0
  138. package/dist/cjs/react/utils/sanitize-stored-messages.js +52 -0
  139. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.d.ts +10 -0
  140. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.js +42 -0
  141. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.d.ts +32 -0
  142. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.js +4 -0
  143. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.d.ts +11 -0
  144. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.js +80 -0
  145. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.d.ts +9 -0
  146. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.js +119 -0
  147. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.d.ts +13 -0
  148. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.js +131 -0
  149. package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.d.ts +7 -0
  150. package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.js +52 -0
  151. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.d.ts +19 -0
  152. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.js +108 -0
  153. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.d.ts +8 -0
  154. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.js +59 -0
  155. package/dist/cjs/server/adapters/nestjs/chat/dto/index.d.ts +3 -0
  156. package/dist/cjs/server/adapters/nestjs/chat/dto/index.js +9 -0
  157. package/dist/cjs/server/adapters/nestjs/chat/index.d.ts +3 -0
  158. package/dist/cjs/server/adapters/nestjs/chat/index.js +9 -0
  159. package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +4 -0
  160. package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.js +73 -0
  161. package/dist/cjs/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
  162. package/dist/cjs/server/adapters/nestjs/chat/ws-loader.js +72 -0
  163. package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.d.ts +6 -0
  164. package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.js +13 -0
  165. package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.d.ts +5 -0
  166. package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.js +15 -0
  167. package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.d.ts +6 -0
  168. package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.js +22 -0
  169. package/dist/cjs/server/adapters/nestjs/decorators/constants.d.ts +4 -0
  170. package/dist/cjs/server/adapters/nestjs/decorators/constants.js +7 -0
  171. package/dist/cjs/server/adapters/nestjs/index.d.ts +14 -0
  172. package/dist/cjs/server/adapters/nestjs/index.js +42 -0
  173. package/dist/cjs/server/adapters/nestjs/metadata.d.ts +39 -0
  174. package/dist/cjs/server/adapters/nestjs/metadata.js +36 -0
  175. package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.d.ts +36 -0
  176. package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.js +159 -0
  177. package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.d.ts +37 -0
  178. package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.js +44 -0
  179. package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.d.ts +28 -0
  180. package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.js +41 -0
  181. package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.d.ts +16 -0
  182. package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.js +117 -0
  183. package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.d.ts +26 -0
  184. package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.js +259 -0
  185. package/dist/cjs/server/adapters/nestjs/swagger.d.ts +7 -0
  186. package/dist/cjs/server/adapters/nestjs/swagger.js +39 -0
  187. package/dist/cjs/server/adapters/nextjs/context-helpers.d.ts +22 -0
  188. package/dist/cjs/server/adapters/nextjs/context-helpers.js +60 -0
  189. package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.d.ts +94 -0
  190. package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.js +965 -0
  191. package/dist/cjs/server/adapters/nextjs/filter-fallback-error.d.ts +11 -0
  192. package/dist/cjs/server/adapters/nextjs/filter-fallback-error.js +41 -0
  193. package/dist/cjs/server/adapters/nextjs/index.d.ts +8 -0
  194. package/dist/cjs/server/adapters/nextjs/index.js +22 -0
  195. package/dist/cjs/server/adapters/nextjs/prepare-model-messages.d.ts +58 -0
  196. package/dist/cjs/server/adapters/nextjs/prepare-model-messages.js +114 -0
  197. package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.d.ts +64 -0
  198. package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.js +489 -0
  199. package/dist/cjs/server/adapters/nextjs/server-action-helper.d.ts +7 -0
  200. package/dist/cjs/server/adapters/nextjs/server-action-helper.js +40 -0
  201. package/dist/cjs/server/adapters/nextjs/types.d.ts +246 -0
  202. package/dist/cjs/server/adapters/nextjs/types.js +2 -0
  203. package/dist/cjs/server/adapters/nextjs/with-ai-tool.d.ts +9 -0
  204. package/dist/cjs/server/adapters/nextjs/with-ai-tool.js +12 -0
  205. package/dist/cjs/server/core/followup-tool.d.ts +9 -0
  206. package/dist/cjs/server/core/followup-tool.js +82 -0
  207. package/dist/cjs/server/core/index.d.ts +139 -0
  208. package/dist/cjs/server/core/index.js +818 -0
  209. package/dist/cjs/server/core/intent-classifier.d.ts +94 -0
  210. package/dist/cjs/server/core/intent-classifier.js +324 -0
  211. package/dist/cjs/server/core/model-selector.d.ts +12 -0
  212. package/dist/cjs/server/core/model-selector.js +48 -0
  213. package/dist/cjs/server/core/module-router.d.ts +14 -0
  214. package/dist/cjs/server/core/module-router.js +110 -0
  215. package/dist/cjs/server/core/zod-compact.d.ts +18 -0
  216. package/dist/cjs/server/core/zod-compact.js +129 -0
  217. package/dist/cjs/server/index.d.ts +6 -0
  218. package/dist/cjs/server/index.js +28 -0
  219. package/dist/cjs/server/lancer/cache.d.ts +9 -0
  220. package/dist/cjs/server/lancer/cache.js +33 -0
  221. package/dist/cjs/server/lancer/client.d.ts +2 -0
  222. package/dist/cjs/server/lancer/client.js +279 -0
  223. package/dist/cjs/server/lancer/errors.d.ts +13 -0
  224. package/dist/cjs/server/lancer/errors.js +21 -0
  225. package/dist/cjs/server/lancer/index.d.ts +3 -0
  226. package/dist/cjs/server/lancer/index.js +7 -0
  227. package/dist/cjs/server/lancer/telemetry-buffer.d.ts +15 -0
  228. package/dist/cjs/server/lancer/telemetry-buffer.js +64 -0
  229. package/dist/cjs/server/lancer/types.d.ts +201 -0
  230. package/dist/cjs/server/lancer/types.js +5 -0
  231. package/dist/cjs/server/pii-shield/aegis-detector.d.ts +26 -0
  232. package/dist/cjs/server/pii-shield/aegis-detector.js +26 -0
  233. package/dist/cjs/server/pii-shield/create-pii-shield.d.ts +2 -0
  234. package/dist/cjs/server/pii-shield/create-pii-shield.js +191 -0
  235. package/dist/cjs/server/pii-shield/deep-walk.d.ts +1 -0
  236. package/dist/cjs/server/pii-shield/deep-walk.js +19 -0
  237. package/dist/cjs/server/pii-shield/fake-data.d.ts +5 -0
  238. package/dist/cjs/server/pii-shield/fake-data.js +170 -0
  239. package/dist/cjs/server/pii-shield/index.d.ts +4 -0
  240. package/dist/cjs/server/pii-shield/index.js +9 -0
  241. package/dist/cjs/server/pii-shield/leakage.d.ts +1 -0
  242. package/dist/cjs/server/pii-shield/leakage.js +15 -0
  243. package/dist/cjs/server/pii-shield/session-mapping.d.ts +12 -0
  244. package/dist/cjs/server/pii-shield/session-mapping.js +70 -0
  245. package/dist/cjs/server/pipeline.d.ts +26 -0
  246. package/dist/cjs/server/pipeline.js +127 -0
  247. package/dist/cjs/server/testing/approvals.d.ts +11 -0
  248. package/dist/cjs/server/testing/approvals.js +41 -0
  249. package/dist/cjs/server/testing/combination.d.ts +3 -0
  250. package/dist/cjs/server/testing/combination.js +83 -0
  251. package/dist/cjs/server/testing/create-test-suite.d.ts +29 -0
  252. package/dist/cjs/server/testing/create-test-suite.js +81 -0
  253. package/dist/cjs/server/testing/edge-cases.d.ts +8 -0
  254. package/dist/cjs/server/testing/edge-cases.js +277 -0
  255. package/dist/cjs/server/testing/guardrails.d.ts +14 -0
  256. package/dist/cjs/server/testing/guardrails.js +152 -0
  257. package/dist/cjs/server/testing/helpers.d.ts +14 -0
  258. package/dist/cjs/server/testing/helpers.js +119 -0
  259. package/dist/cjs/server/testing/index.d.ts +12 -0
  260. package/dist/cjs/server/testing/index.js +37 -0
  261. package/dist/cjs/server/testing/mock-executor.d.ts +8 -0
  262. package/dist/cjs/server/testing/mock-executor.js +40 -0
  263. package/dist/cjs/server/testing/regression.d.ts +7 -0
  264. package/dist/cjs/server/testing/regression.js +27 -0
  265. package/dist/cjs/server/testing/routing.d.ts +12 -0
  266. package/dist/cjs/server/testing/routing.js +63 -0
  267. package/dist/cjs/server/testing/schema-consistency.d.ts +6 -0
  268. package/dist/cjs/server/testing/schema-consistency.js +56 -0
  269. package/dist/cjs/server/testing/smoke.d.ts +11 -0
  270. package/dist/cjs/server/testing/smoke.js +64 -0
  271. package/dist/cjs/server/testing/types.d.ts +156 -0
  272. package/dist/cjs/server/testing/types.js +2 -0
  273. package/dist/cjs/types.d.ts +696 -0
  274. package/dist/cjs/types.js +91 -0
  275. package/dist/cli/commands/install-skills.d.ts +17 -0
  276. package/dist/cli/commands/install-skills.js +185 -0
  277. package/dist/cli/commands/install-skills.js.map +1 -0
  278. package/dist/cli/index.js +25 -0
  279. package/dist/cli/index.js.map +1 -1
  280. package/dist/react/components/ai-trigger-button.js +4 -6
  281. package/dist/react/components/ai-trigger-button.js.map +1 -1
  282. package/dist/react/components/recording-bar.js +4 -6
  283. package/dist/react/components/recording-bar.js.map +1 -1
  284. package/dist/react/components/wavesurfer-loader.d.ts +5 -0
  285. package/dist/react/components/wavesurfer-loader.js +34 -0
  286. package/dist/react/components/wavesurfer-loader.js.map +1 -0
  287. package/dist/server/adapters/nestjs/chat/ai-chat.module.d.ts +1 -1
  288. package/dist/server/adapters/nestjs/chat/ai-chat.module.js +3 -2
  289. package/dist/server/adapters/nestjs/chat/ai-chat.module.js.map +1 -1
  290. package/dist/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +1 -1
  291. package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js +10 -8
  292. package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js.map +1 -1
  293. package/dist/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
  294. package/dist/server/adapters/nestjs/chat/ws-loader.js +37 -0
  295. package/dist/server/adapters/nestjs/chat/ws-loader.js.map +1 -0
  296. package/openapi/package.json +5 -0
  297. package/package.json +59 -16
  298. package/react/langgraph/package.json +5 -0
  299. package/react/package.json +5 -0
  300. package/react/vercel/package.json +5 -0
  301. package/server/nestjs/package.json +5 -0
  302. package/server/nextjs/package.json +5 -0
  303. package/server/package.json +5 -0
  304. package/server/testing/package.json +5 -0
  305. package/skills/README.md +107 -0
  306. package/skills/building-glirastes-chat-ui/SKILL.md +378 -0
  307. package/skills/integrating-glirastes-nestjs/SKILL.md +346 -0
  308. package/skills/integrating-glirastes-nextjs/SKILL.md +306 -0
  309. package/skills/integrating-glirastes-nextjs-with-nestjs-backend/SKILL.md +359 -0
  310. package/skills/maintaining-glirastes-tools/SKILL.md +463 -0
@@ -0,0 +1,346 @@
1
+ ---
2
+ name: integrating-glirastes-nestjs
3
+ description: Integrating the Glirastes SDK into a NestJS backend — AiChatModule wiring, @AiTool / @AiModule / @AiParam decorators, scanNestJsControllers, attachWebSockets for speech-to-text. Use when adding AI chat to a NestJS service or to a NestJS+Next.js full-stack app.
4
+ version: 1.0.0
5
+ tags:
6
+ - glirastes
7
+ - nestjs
8
+ - ai
9
+ - decorators
10
+ triggers:
11
+ - integrate glirastes nestjs
12
+ - AiChatModule
13
+ - AiModule decorator
14
+ - AiTool decorator
15
+ - AiParam
16
+ - scanNestJsControllers
17
+ - chat module nestjs
18
+ - ai chat backend
19
+ - attachWebSockets
20
+ ---
21
+
22
+ # Integrating Glirastes into NestJS
23
+
24
+ > **Why pick this adapter:** NestJS already has your auth (JWT guard), tenant context, services and controllers. The decorators turn existing controllers into AI-callable tools — no second code path, no HTTP hop from frontend to backend per tool call. If you also have a Next.js frontend in the same workspace, the chat route still belongs **here**, not in a Next.js Route Handler.
25
+ >
26
+ > **Companion skills:**
27
+ > - [maintaining-glirastes-tools](../maintaining-glirastes-tools/SKILL.md) — tool authoring deep-dive, all CLI commands, codegen workflow
28
+ > - [building-glirastes-chat-ui](../building-glirastes-chat-ui/SKILL.md) — chat UI in your frontend (talks to this backend)
29
+
30
+ ## Stack detection
31
+
32
+ Confirm before applying:
33
+
34
+ - `nest-cli.json` exists at the project root → NestJS ✅
35
+ - `package.json` has `@nestjs/core` and `@nestjs/common`
36
+ - TypeScript backend (this adapter is type-driven)
37
+
38
+ ## Step 1 — Install
39
+
40
+ ```bash
41
+ npm install glirastes @ai-sdk/openai
42
+ # Optional: speech-to-text proxy via Deepgram WebSocket
43
+ npm install ws
44
+ ```
45
+
46
+ `@ai-sdk/openai` is the OpenAI provider — swap for `@ai-sdk/anthropic`, `@ai-sdk/mistral`, etc. as needed.
47
+
48
+ `ws` is **only** needed if you enable `features.speechToText` and call `AiChatModule.attachWebSockets(app)`. Without that feature it's never loaded.
49
+
50
+ ## Step 2 — Environment variables
51
+
52
+ `.env`:
53
+
54
+ ```
55
+ OPENAI_API_KEY=sk-...
56
+ # Optional speech-to-text:
57
+ # DEEPGRAM_API_KEY=...
58
+ # Optional Glirastes platform (PII Shield, intent routing, telemetry):
59
+ # GLIRASTES_API_KEY=glir_...
60
+ ```
61
+
62
+ ## Step 3 — `tsconfig.json`
63
+
64
+ The default NestJS template (`module: "commonjs"`) works as-is on Glirastes 0.3.1+ — no changes needed. The package ships dual CJS+ESM bundles plus subpath shims.
65
+
66
+ If you're on a modern setup, this also works:
67
+
68
+ ```jsonc
69
+ {
70
+ "compilerOptions": {
71
+ "module": "node16", // or "nodenext" / "esnext"
72
+ "moduleResolution": "node16", // or "nodenext" / "bundler"
73
+ "target": "ES2022",
74
+ "esModuleInterop": true,
75
+ "experimentalDecorators": true,
76
+ "emitDecoratorMetadata": true
77
+ }
78
+ }
79
+ ```
80
+
81
+ `emitDecoratorMetadata` and `experimentalDecorators` are **required** — Glirastes' decorator scanner reads metadata.
82
+
83
+ ## Step 4 — Annotate existing controllers
84
+
85
+ Two decorators turn an existing controller into an AI module:
86
+
87
+ - `@AiModule({ intent, classification })` on the class — declares the intent group + classification hints
88
+ - `@AiTool({ name, description })` on each AI-callable method
89
+ - `@AiParam('description')` on DTO fields the LLM should fill (only needed for body/query DTOs; path params from `@Param()` are auto-extracted)
90
+
91
+ ```ts
92
+ // src/tasks/tasks.controller.ts
93
+ import { Body, Controller, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
94
+ import { AuthGuard } from '@nestjs/passport';
95
+ import { AiModule, AiTool } from 'glirastes/server/nestjs';
96
+ import { TasksService } from './tasks.service';
97
+ import { CreateTaskDto, ListTasksQueryDto } from './dto';
98
+
99
+ @Controller('tasks')
100
+ @UseGuards(AuthGuard('jwt'))
101
+ @AiModule({
102
+ intent: 'task_management',
103
+ classification: {
104
+ hint: 'User asks about listing, filtering, creating, or updating tasks.',
105
+ examples: [
106
+ 'show me open tasks',
107
+ 'create a task: review PR',
108
+ 'mark task 42 as done',
109
+ ],
110
+ },
111
+ })
112
+ export class TasksController {
113
+ constructor(private readonly tasksService: TasksService) {}
114
+
115
+ @Get()
116
+ @AiTool({
117
+ name: 'list_tasks',
118
+ description: 'List tasks with an optional status filter.',
119
+ })
120
+ list(@Query() q: ListTasksQueryDto) {
121
+ return this.tasksService.list(q);
122
+ }
123
+
124
+ @Get(':id')
125
+ @AiTool({
126
+ name: 'get_task',
127
+ description: 'Fetch a single task by its ID.',
128
+ })
129
+ get(@Param('id') id: string) {
130
+ return this.tasksService.get(id);
131
+ }
132
+
133
+ @Post()
134
+ @AiTool({
135
+ name: 'create_task',
136
+ description: 'Create a new task. Always confirm the title with the user first.',
137
+ })
138
+ create(@Body() dto: CreateTaskDto) {
139
+ return this.tasksService.create(dto);
140
+ }
141
+ }
142
+ ```
143
+
144
+ ```ts
145
+ // src/tasks/dto.ts
146
+ import { IsOptional, IsString, IsEnum } from 'class-validator';
147
+ import { ApiProperty } from '@nestjs/swagger';
148
+ import { AiParam } from 'glirastes/server/nestjs';
149
+
150
+ export class ListTasksQueryDto {
151
+ @IsString()
152
+ @IsOptional()
153
+ @AiParam('Optional status filter — one of "open" | "done".')
154
+ @ApiProperty({ required: false })
155
+ status?: 'open' | 'done';
156
+ }
157
+
158
+ export class CreateTaskDto {
159
+ @IsString()
160
+ @AiParam('The task title (required). Must be confirmed with the user.')
161
+ @ApiProperty()
162
+ title!: string;
163
+
164
+ @IsString()
165
+ @IsOptional()
166
+ @AiParam('Optional assignee user ID — never invent, look up via find_user first.')
167
+ @ApiProperty({ required: false })
168
+ assigneeId?: string;
169
+ }
170
+ ```
171
+
172
+ The scanner derives the Zod input schema from your DTOs (`class-validator` decorators + `@AiParam` descriptions) and auto-extracts path params from `@Param()`. You write DTOs once for HTTP, Swagger, validation, and AI.
173
+
174
+ ## Step 5 — Wire AiChatModule
175
+
176
+ Create a `ChatModule` that:
177
+ 1. Imports the modules whose controllers carry `@AiTool` decorators.
178
+ 2. Calls `AiChatModule.forRoot({ ... })` with model, system prompt, and your existing auth guard.
179
+
180
+ ```ts
181
+ // src/chat/chat.module.ts
182
+ import { openai } from '@ai-sdk/openai';
183
+ import { Module } from '@nestjs/common';
184
+ import { AuthGuard } from '@nestjs/passport';
185
+ import { AiChatModule } from 'glirastes/server/nestjs';
186
+ import { TasksModule } from '../tasks/tasks.module';
187
+
188
+ @Module({
189
+ imports: [
190
+ TasksModule,
191
+ AiChatModule.forRoot({
192
+ model: openai('gpt-4o-mini'),
193
+ systemPrompt: ({ currentDate }) =>
194
+ `You are a helpful assistant. Today is ${currentDate}.`,
195
+ authGuard: AuthGuard('jwt'),
196
+ }),
197
+ ],
198
+ })
199
+ export class ChatModule {}
200
+ ```
201
+
202
+ Register `ChatModule` in `AppModule`:
203
+
204
+ ```ts
205
+ // src/app.module.ts
206
+ import { Module } from '@nestjs/common';
207
+ import { ChatModule } from './chat/chat.module';
208
+ // ... your other imports
209
+
210
+ @Module({
211
+ imports: [
212
+ // ... existing modules
213
+ ChatModule,
214
+ ],
215
+ })
216
+ export class AppModule {}
217
+ ```
218
+
219
+ `AiChatModule` exposes `POST /api/ai/chat` (and `GET /api/ai/tools` to inspect the registered tools). The `authGuard` runs before every chat request, so the same JWT validation that protects your other endpoints applies here too.
220
+
221
+ ## Step 6 — Verify
222
+
223
+ ```bash
224
+ npm run build # NestJS build
225
+ npm start # or npm run start:dev for watch mode
226
+ ```
227
+
228
+ Then check the tool registry directly:
229
+
230
+ ```bash
231
+ curl -H "Authorization: Bearer <jwt>" http://localhost:3000/api/ai/tools
232
+ ```
233
+
234
+ You should see a JSON list of all tools the scanner discovered. Send a chat request:
235
+
236
+ ```bash
237
+ curl -X POST http://localhost:3000/api/ai/chat \
238
+ -H "Authorization: Bearer <jwt>" \
239
+ -H "Content-Type: application/json" \
240
+ -d '{"messages":[{"role":"user","content":"list my open tasks"}]}'
241
+ ```
242
+
243
+ The response is a streaming SSE — your frontend's `<VercelAiChat endpoint="...api/ai/chat" />` consumes it directly.
244
+
245
+ ## Step 7 — Frontend connection
246
+
247
+ Your React frontend (any framework — Next.js, Vite + React, etc.) connects via the `endpoint` prop:
248
+
249
+ ```tsx
250
+ 'use client';
251
+ import { VercelAiChat } from 'glirastes/react/vercel';
252
+
253
+ const API_URL = process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:3000';
254
+
255
+ export function ChatWidget() {
256
+ return (
257
+ <VercelAiChat
258
+ endpoint={`${API_URL}/api/ai/chat`}
259
+ headers={() => ({ Authorization: `Bearer ${getToken()}` })}
260
+ />
261
+ );
262
+ }
263
+ ```
264
+
265
+ CORS: ensure your NestJS app enables CORS for the frontend origin (typically in `main.ts` via `app.enableCors({ origin: '...', credentials: true })`).
266
+
267
+ For UI customization, see [building-glirastes-chat-ui](../building-glirastes-chat-ui/SKILL.md).
268
+
269
+ ## Step 8 — Optional: Speech-to-text WebSocket
270
+
271
+ To enable live voice transcription via Deepgram:
272
+
273
+ 1. Set `features.speechToText: true` and provide an env var `DEEPGRAM_API_KEY`:
274
+
275
+ ```ts
276
+ AiChatModule.forRoot({
277
+ model: openai('gpt-4o-mini'),
278
+ authGuard: AuthGuard('jwt'),
279
+ features: { speechToText: true },
280
+ })
281
+ ```
282
+
283
+ 2. In your `main.ts`, attach the WebSocket server **after** `app.listen()`:
284
+
285
+ ```ts
286
+ // src/main.ts
287
+ import { NestFactory } from '@nestjs/core';
288
+ import { AiChatModule } from 'glirastes/server/nestjs';
289
+ import { AppModule } from './app.module';
290
+
291
+ async function bootstrap() {
292
+ const app = await NestFactory.create(AppModule);
293
+ await app.listen(3000);
294
+ await AiChatModule.attachWebSockets(app); // async since 0.3.1
295
+ }
296
+ bootstrap();
297
+ ```
298
+
299
+ 3. Install `ws`: `npm install ws` (only needed for this feature).
300
+
301
+ 4. Frontend: pass `showMic={true}` and install `wavesurfer.js` for the live waveform UI.
302
+
303
+ The WebSocket lives at `/api/ai/speech-stream`. The browser sends audio frames; the SDK proxies them to Deepgram with your `DEEPGRAM_API_KEY` server-side and streams transcriptions back.
304
+
305
+ ## Multi-controller scanning (advanced)
306
+
307
+ By default, `AiChatModule.forRoot` discovers tools at runtime via the `DiscoveryService`. For build-time scanning (e.g. to validate the registry before deploy), use `scanNestJsControllers`:
308
+
309
+ ```ts
310
+ import { scanNestJsControllers } from 'glirastes/server/nestjs';
311
+ import { endpointToolsToRegistry } from 'glirastes/server';
312
+ import { TasksController } from './tasks/tasks.controller';
313
+ import { UsersController } from './users/users.controller';
314
+
315
+ const scan = scanNestJsControllers({
316
+ controllers: [TasksController, UsersController],
317
+ });
318
+
319
+ // scan.tools — flat array of tool definitions
320
+ // scan.modules — module metadata
321
+ // scan.toolsByModule — grouped by module
322
+ const registry = endpointToolsToRegistry(scan.tools);
323
+ ```
324
+
325
+ You typically don't need this — runtime DI is simpler — but it's useful when generating skill files (`glirastes generate-skills`) or MCP servers without booting NestJS.
326
+
327
+ ## Common pitfalls
328
+
329
+ | Symptom | Cause | Fix |
330
+ |---|---|---|
331
+ | `Cannot find module 'glirastes/server/nestjs'` | Old SDK version (≤0.3.0 was ESM-only) | Upgrade to ≥0.3.1 — dual-bundle works with default CJS NestJS template |
332
+ | `TS1479: ECMAScript module cannot be imported with require` | Same as above | Upgrade to ≥0.3.1 |
333
+ | Tools missing from `/api/ai/tools` | Module not in `imports: [...]` of `ChatModule` | Add the module that owns the controller — DI must reach it |
334
+ | `attachWebSockets is not async` warning | Old SDK pre-0.3.1 | Upgrade to ≥0.3.1 and add `await` |
335
+ | `ERR_MODULE_NOT_FOUND: Cannot find package 'ws'` at startup | `features.speechToText: true` without `ws` installed | `npm install ws` (only required when speech-to-text is on) |
336
+ | Tool description ignored by the LLM | Description too vague | Rewrite as *"WHEN to call: ... WHAT it returns: ..."* — descriptions are the primary LLM hint |
337
+ | Path param missing in tool input | DTO field with the same name shadows it | Path params are auto-extracted from `@Param()` — don't add them to your DTO |
338
+ | LLM hallucinates IDs | No lookup tool exposed | Add a `find_user` / `list_*` tool the LLM can call to resolve IDs first |
339
+
340
+ ## What this skill does NOT cover
341
+
342
+ - **Tool authoring deep-dive** (input schemas, UI patterns, output schemas, approvals, `module`/`sharedWith`, classification, codegen) — see [maintaining-glirastes-tools](../maintaining-glirastes-tools/SKILL.md)
343
+ - **Chat UI customization** (theming, mentions, voice input UI, approval cards, action bus, ChatWindow portal) — see [building-glirastes-chat-ui](../building-glirastes-chat-ui/SKILL.md)
344
+ - **Next.js standalone integration** (Next.js as the only backend) — see [integrating-glirastes-nextjs](../integrating-glirastes-nextjs/SKILL.md)
345
+ - **LangGraph transport** — if your backend speaks LangGraph instead, swap `AiChatModule` for the LangGraph wiring patterns; client-side, swap `VercelAiChat` for `LangGraphAiChat` from `glirastes/react/langgraph`
346
+ - **Glirastes platform features** (PII Shield via `createPiiShield`, intent routing via `createLancer`, guardrails, telemetry) — opt in via `GLIRASTES_API_KEY` env var; the SDK falls back to free-tier behaviour without it
@@ -0,0 +1,306 @@
1
+ ---
2
+ name: integrating-glirastes-nextjs
3
+ description: Integrating the Glirastes SDK into a Next.js App Router project — chat route handler, VercelAiChat widget, co-located ai-tool.ts files, codegen pipeline. Use when adding AI chat to a Next.js app where Next.js itself is the backend.
4
+ version: 1.0.0
5
+ tags:
6
+ - glirastes
7
+ - nextjs
8
+ - ai
9
+ - app-router
10
+ triggers:
11
+ - integrate glirastes
12
+ - integrate glirastes nextjs
13
+ - add glirastes to next
14
+ - add chat to next.js
15
+ - createAiChatHandler
16
+ - VercelAiChat
17
+ - chat route nextjs
18
+ - ai chat next.js
19
+ ---
20
+
21
+ # Integrating Glirastes into Next.js
22
+
23
+ > **Scope:** Next.js is the only backend in this project. If a separate NestJS / Express backend exists, use [integrating-glirastes-nestjs](../integrating-glirastes-nestjs/SKILL.md) instead — putting the chat route on the real backend avoids duplicate auth and an extra HTTP hop per tool call.
24
+ >
25
+ > **Companion skills:**
26
+ > - [maintaining-glirastes-tools](../maintaining-glirastes-tools/SKILL.md) — tool authoring deep-dive, all CLI commands, codegen workflow
27
+ > - [building-glirastes-chat-ui](../building-glirastes-chat-ui/SKILL.md) — chat UI customization, mentions, voice input, action bus
28
+
29
+ ## Stack detection
30
+
31
+ Confirm before applying:
32
+
33
+ - `next.config.{ts,js,mjs}` exists at the project root → Next.js ✅
34
+ - No `nest-cli.json` or sibling backend workspace
35
+ - `package.json` shows React 19+, Next.js 15+
36
+
37
+ If a NestJS backend lives in the same workspace (e.g. `apps/api/`), stop and use the NestJS skill — the chat route belongs there.
38
+
39
+ ## Step 1 — Install
40
+
41
+ ```bash
42
+ # Core + a model provider
43
+ npm install glirastes @ai-sdk/openai
44
+
45
+ # React UI peers (declared as optional peerDeps in glirastes 0.3.1+)
46
+ npm install @ai-sdk/react react-markdown
47
+
48
+ # Optional: voice input with live waveform
49
+ npm install wavesurfer.js
50
+ ```
51
+
52
+ `@ai-sdk/openai` is the OpenAI provider. Swap for `@ai-sdk/anthropic`, `@ai-sdk/mistral`, etc. — Glirastes accepts any AI SDK v6 provider.
53
+
54
+ ## Step 2 — Environment variables
55
+
56
+ Add to `.env.local`:
57
+
58
+ ```
59
+ OPENAI_API_KEY=sk-...
60
+ # Optional — unlocks Glirastes platform features (PII Shield, intent routing, telemetry)
61
+ # GLIRASTES_API_KEY=glir_...
62
+ ```
63
+
64
+ API keys must stay server-side. Next.js Route Handlers run on the server, so this is safe — never reference `OPENAI_API_KEY` from a client component.
65
+
66
+ ## Step 3 — File structure convention
67
+
68
+ Co-locate `ai-tool.ts` next to the route it wraps. The codegen scanner discovers tools by this convention:
69
+
70
+ ```
71
+ src/app/api/
72
+ ├── chat/route.ts # createAiChatHandler with the registry
73
+ ├── tasks/
74
+ │ ├── route.ts # The actual API handler
75
+ │ └── ai-tool.ts # AI-callable wrapper (defineEndpointTool)
76
+ ├── tasks/[id]/
77
+ │ ├── route.ts
78
+ │ └── ai-tool.ts
79
+ └── users/search/
80
+ ├── route.ts
81
+ └── ai-tool.ts
82
+
83
+ src/components/
84
+ ├── tasks/ai-ui-tool.ts # UI tool definitions (defineUiTool)
85
+ └── layout/ai-ui-tool.ts
86
+
87
+ src/generated/ai-tools/
88
+ ├── endpoint.generated.ts # AUTO — produced by `glirastes generate-tools`
89
+ ├── ui.generated.ts
90
+ ├── modules.generated.ts
91
+ └── action-ids.generated.ts
92
+ ```
93
+
94
+ Ignore the `src/generated/ai-tools/` directory in your editor — it's regenerated by the CLI on every `predev` / `prebuild`.
95
+
96
+ ## Step 4 — Bootstrap your first tool
97
+
98
+ Use the CLI scaffolder. Pass an existing route file:
99
+
100
+ ```bash
101
+ npx glirastes scaffold --route src/app/api/tasks/route.ts
102
+ # Add --dry-run to preview without writing
103
+ # Add --force to overwrite existing ai-tool.ts
104
+ ```
105
+
106
+ The scaffolder analyzes the route (HTTP methods, path params, body fields, search params) and emits a starter `src/app/api/tasks/ai-tool.ts`:
107
+
108
+ ```ts
109
+ import { z } from 'zod';
110
+ import { defineEndpointTool } from 'glirastes';
111
+
112
+ export const aiTool = defineEndpointTool({
113
+ id: 'tasks.list',
114
+ toolName: 'list_tasks',
115
+ module: 'task_query',
116
+ description: 'list tasks. TODO: write a clear description for the AI.',
117
+ method: 'GET',
118
+ path: '/api/tasks',
119
+ inputSchema: z.object({
120
+ status: z.enum(['open', 'done']).optional(),
121
+ }),
122
+ // uiPattern: { type: 'filter-and-navigate', target: 'tasks', filterMapping: { status: 'status' } },
123
+ });
124
+ ```
125
+
126
+ Edit `description` (the LLM reads this to decide when to call the tool), refine the schema, optionally add a `uiPattern`. For the full tool authoring API, see [maintaining-glirastes-tools](../maintaining-glirastes-tools/SKILL.md).
127
+
128
+ ## Step 5 — Wire the chat route handler
129
+
130
+ Two paths depending on tool count:
131
+
132
+ ### Few tools — manual import
133
+
134
+ ```ts
135
+ // src/app/api/chat/route.ts
136
+ import { openai } from '@ai-sdk/openai';
137
+ import { endpointToolsToRegistry } from 'glirastes/server';
138
+ import { createAiChatHandler } from 'glirastes/server/nextjs';
139
+ import { aiTool as listTasks } from '../tasks/ai-tool';
140
+
141
+ export const POST = createAiChatHandler({
142
+ tools: endpointToolsToRegistry([listTasks]),
143
+ model: openai('gpt-4o-mini'),
144
+ systemPrompt: 'You are a helpful assistant for our app.',
145
+ });
146
+ ```
147
+
148
+ ### Many tools — codegen pipeline
149
+
150
+ Add to `package.json`:
151
+
152
+ ```json
153
+ {
154
+ "scripts": {
155
+ "predev": "glirastes generate-tools --quiet",
156
+ "prebuild": "glirastes generate-tools --quiet",
157
+ "ai:scaffold": "glirastes scaffold",
158
+ "ai:coverage": "glirastes coverage",
159
+ "ai:coverage:ci": "glirastes coverage --ci",
160
+ "ai:validate": "glirastes validate-tools",
161
+ "ai:validate:ci": "glirastes validate-tools --ci"
162
+ }
163
+ }
164
+ ```
165
+
166
+ Then import the generated registry instead of individual tools:
167
+
168
+ ```ts
169
+ // src/app/api/chat/route.ts
170
+ import { openai } from '@ai-sdk/openai';
171
+ import { createAiChatHandler } from 'glirastes/server/nextjs';
172
+ import { endpointToolRegistry } from '@/generated/ai-tools/endpoint.generated';
173
+ import { uiToolRegistry } from '@/generated/ai-tools/ui.generated';
174
+
175
+ export const POST = createAiChatHandler({
176
+ tools: { ...endpointToolRegistry, ...uiToolRegistry },
177
+ model: openai('gpt-4o-mini'),
178
+ systemPrompt: 'You are a helpful assistant for our app.',
179
+ });
180
+ ```
181
+
182
+ The registries are typed as `ToolRegistry` (Record<string, Tool>) — pass them straight to `createAiChatHandler({ tools })`.
183
+
184
+ ## Step 6 — Mount the chat widget
185
+
186
+ Client-side component, then drop into the root layout:
187
+
188
+ ```tsx
189
+ // src/components/chat/ChatWidget.tsx
190
+ 'use client';
191
+
192
+ import { VercelAiChat } from 'glirastes/react/vercel';
193
+
194
+ export function ChatWidget() {
195
+ return <VercelAiChat endpoint="/api/chat" />;
196
+ }
197
+ ```
198
+
199
+ ```tsx
200
+ // src/app/layout.tsx
201
+ import { ChatWidget } from '@/components/chat/ChatWidget';
202
+ import 'glirastes/react/styles.css';
203
+
204
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
205
+ return (
206
+ <html>
207
+ <body>
208
+ {children}
209
+ <ChatWidget />
210
+ </body>
211
+ </html>
212
+ );
213
+ }
214
+ ```
215
+
216
+ For UI customization (props on `VercelAiChat`, theming, mentions, voice input, custom approval cards), see [building-glirastes-chat-ui](../building-glirastes-chat-ui/SKILL.md).
217
+
218
+ ## Step 7 — Verify
219
+
220
+ Run the codegen + production build first — surfaces most issues:
221
+
222
+ ```bash
223
+ npm run ai:validate # catches malformed ai-tool.ts files
224
+ npm run ai:coverage # lists routes without ai-tool.ts (informational)
225
+ npm run build # full Next.js build, runs `predev`/`prebuild` scripts
226
+ ```
227
+
228
+ Build output should list `/api/chat` as a dynamic route (`ƒ /api/chat`). Then:
229
+
230
+ ```bash
231
+ npm run dev
232
+ ```
233
+
234
+ Open the app, click the floating chat trigger (bottom-right by default), send a message that should fire your tool (*"show me my open tasks"*). The tool result must show up; `uiPattern` actions fire automatically (e.g. `filter-and-navigate` rewrites the URL).
235
+
236
+ ## Step 8 — Hook up frontend UI actions (optional)
237
+
238
+ If your tools declare `uiPattern: { type: 'open-dialog' | 'open-detail' | 'refresh' | 'toast' }`, the SDK derives an action ID and fires it through the `UiActionBus`. Register handlers anywhere a relevant component mounts:
239
+
240
+ ```tsx
241
+ 'use client';
242
+ import { useAiClientAction } from 'glirastes/react';
243
+ import { useRouter } from 'next/navigation';
244
+
245
+ export function TaskList() {
246
+ const router = useRouter();
247
+ useAiClientAction('task-details.open', (payload) => {
248
+ router.push(`/tasks/${payload?.taskId}`);
249
+ });
250
+ // ...
251
+ }
252
+ ```
253
+
254
+ Action IDs are derived from `uiPattern`:
255
+
256
+ | `uiPattern.type` | Action ID |
257
+ |---|---|
258
+ | `open-detail`, `entity: 'task'` | `task-details.open` |
259
+ | `open-dialog`, `dialog: 'create-task'` | `task-create-dialog.open` |
260
+ | `refresh`, `target: 'tasks'` | `tasks.refresh` |
261
+ | `toast` | dispatched directly via your toast lib (sonner/react-hot-toast) |
262
+
263
+ `glirastes coverage` reports any UI action ID declared in tools but not handled in `.tsx` files (and vice versa).
264
+
265
+ ## CLI quick reference
266
+
267
+ | Command | Purpose | Common flags |
268
+ |---|---|---|
269
+ | `glirastes scaffold --route <file>` | Create `ai-tool.ts` next to a `route.ts` | `--dry-run`, `--force` |
270
+ | `glirastes generate-tools` | Scan all `*.ai-tool.ts` files, emit `src/generated/ai-tools/*.generated.ts` | `--quiet` (predev/prebuild) |
271
+ | `glirastes generate-endpoint-tools` | Endpoint registry only | `--quiet` |
272
+ | `glirastes generate-ui-tools` | UI tool registry + action IDs | `--quiet` |
273
+ | `glirastes generate-modules` | Module/intent registry | `--meta @/lib/ai/module-meta` |
274
+ | `glirastes generate-auto` | Auto-detect repo layout, run the right generator | — |
275
+ | `glirastes validate-tools` | Validate naming, duplicates, missing approvals | `--ci`, `--fix`, `--quiet` |
276
+ | `glirastes coverage` | Report routes without `ai-tool.ts`, orphan handlers | `--ci`, `--quiet` |
277
+ | `glirastes test` | Scaffold an AI behavior test file | — |
278
+ | `glirastes generate-skills` | Export current tool registry as Claude Code / Codex skills (for *agents to call your tools*) | `--app-name`, `--base-url`, `--auth bearer` |
279
+ | `glirastes generate-mcp-server` | Export current tool registry as a standalone MCP server project | `--app-name`, `--base-url` |
280
+ | `glirastes generate <openapi.yaml>` | Generate endpoint tools from an OpenAPI spec | `--out <file>` |
281
+ | `glirastes check-upgrade` | Analyze release notes for breaking changes against your code | `--from-version <ver>` |
282
+ | `glirastes sync` | Upload tool schemas to the Glirastes platform (Pro) | `--api-key` (or `GLIRASTES_API_KEY` env) |
283
+
284
+ For the full deep-dive, see [maintaining-glirastes-tools](../maintaining-glirastes-tools/SKILL.md).
285
+
286
+ ## Common pitfalls
287
+
288
+ | Symptom | Cause | Fix |
289
+ |---|---|---|
290
+ | `Cannot resolve '@ai-sdk/react'` at build | Optional peer not installed | `npm install @ai-sdk/react react-markdown` |
291
+ | `Cannot resolve 'wavesurfer.js/dist/plugins/record.esm.js'` | Voice input components reachable in bundle without peer | Either install `wavesurfer.js` or set `showMic={false}` on `<VercelAiChat />` |
292
+ | Chat widget unstyled | `styles.css` not imported | Add `import 'glirastes/react/styles.css'` to root layout |
293
+ | Tool never fires | `path` mismatches the actual route | Endpoint tool's `path` must match the URL the route handler serves exactly |
294
+ | `OPENAI_API_KEY is not configured` | Env var missing | `.env.local` + restart dev server (Next caches env at startup) |
295
+ | `endpointToolRegistry is undefined` | Codegen script never ran | `npm run predev` or run `glirastes generate-tools` once manually |
296
+ | LLM ignores a tool | Description missing or vague | Rewrite to *"WHEN to call: ... WHAT it returns: ..."* in the description |
297
+ | UI action `task-details.open` fires but nothing happens | No `useAiClientAction` registered | Add handler in a mounted component; verify with `glirastes coverage` |
298
+ | OpenAPI spec generation fails | Spec not validated | Run `glirastes validate <openapi.yaml>` first |
299
+
300
+ ## What this skill does NOT cover
301
+
302
+ - **NestJS adapter** — see [integrating-glirastes-nestjs](../integrating-glirastes-nestjs/SKILL.md)
303
+ - **Tool authoring deep-dive** (UI patterns, output schemas, approvals, `module`/`sharedWith`, classification metadata) — see [maintaining-glirastes-tools](../maintaining-glirastes-tools/SKILL.md)
304
+ - **Chat UI customization** (theming, mentions, voice input, approval cards, action bus, ChatWindow portal) — see [building-glirastes-chat-ui](../building-glirastes-chat-ui/SKILL.md)
305
+ - **LangGraph transport** — replace `createAiChatHandler` + `VercelAiChat` with the LangGraph variants from `glirastes/server/nextjs` and `glirastes/react/langgraph`
306
+ - **Glirastes platform features** (PII Shield via `createPiiShield`, intent routing via `createLancer`, guardrails, usage telemetry) — opt in via `GLIRASTES_API_KEY` env var; the SDK falls back to free-tier behaviour without it