glirastes 0.2.1 → 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.
- package/CHANGELOG.md +96 -0
- package/CODE_OF_CONDUCT.md +85 -0
- package/CONTRIBUTING.md +87 -0
- package/README.md +268 -23
- package/SECURITY.md +46 -0
- package/codegen/package.json +5 -0
- package/dist/cjs/codegen/asset-sync.d.ts +20 -0
- package/dist/cjs/codegen/asset-sync.js +28 -0
- package/dist/cjs/codegen/coverage.d.ts +66 -0
- package/dist/cjs/codegen/coverage.js +408 -0
- package/dist/cjs/codegen/endpoint-scanner.d.ts +16 -0
- package/dist/cjs/codegen/endpoint-scanner.js +197 -0
- package/dist/cjs/codegen/format.d.ts +17 -0
- package/dist/cjs/codegen/format.js +34 -0
- package/dist/cjs/codegen/fs-utils.d.ts +45 -0
- package/dist/cjs/codegen/fs-utils.js +165 -0
- package/dist/cjs/codegen/index.d.ts +13 -0
- package/dist/cjs/codegen/index.js +33 -0
- package/dist/cjs/codegen/mcp-generator.d.ts +50 -0
- package/dist/cjs/codegen/mcp-generator.js +803 -0
- package/dist/cjs/codegen/module-generator.d.ts +11 -0
- package/dist/cjs/codegen/module-generator.js +353 -0
- package/dist/cjs/codegen/nestjs-scanner.d.ts +43 -0
- package/dist/cjs/codegen/nestjs-scanner.js +241 -0
- package/dist/cjs/codegen/output-recommender.d.ts +23 -0
- package/dist/cjs/codegen/output-recommender.js +33 -0
- package/dist/cjs/codegen/scaffolder.d.ts +36 -0
- package/dist/cjs/codegen/scaffolder.js +262 -0
- package/dist/cjs/codegen/skill-generator.d.ts +49 -0
- package/dist/cjs/codegen/skill-generator.js +967 -0
- package/dist/cjs/codegen/types.d.ts +52 -0
- package/dist/cjs/codegen/types.js +16 -0
- package/dist/cjs/codegen/ui-scanner.d.ts +24 -0
- package/dist/cjs/codegen/ui-scanner.js +202 -0
- package/dist/cjs/codegen/validator.d.ts +35 -0
- package/dist/cjs/codegen/validator.js +292 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/openapi/index.d.ts +78 -0
- package/dist/cjs/openapi/index.js +347 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/react/audio-worklet-processor.d.ts +16 -0
- package/dist/cjs/react/audio-worklet-processor.js +27 -0
- package/dist/cjs/react/bridges/rest-session-bridge.d.ts +113 -0
- package/dist/cjs/react/bridges/rest-session-bridge.js +209 -0
- package/dist/cjs/react/components/ai-chat-panel.d.ts +12 -0
- package/dist/cjs/react/components/ai-chat-panel.js +67 -0
- package/dist/cjs/react/components/ai-trigger-button.d.ts +2 -0
- package/dist/cjs/react/components/ai-trigger-button.js +239 -0
- package/dist/cjs/react/components/approval-card.d.ts +9 -0
- package/dist/cjs/react/components/approval-card.js +24 -0
- package/dist/cjs/react/components/bulk-approval-card.d.ts +9 -0
- package/dist/cjs/react/components/bulk-approval-card.js +36 -0
- package/dist/cjs/react/components/chat-input.d.ts +10 -0
- package/dist/cjs/react/components/chat-input.js +60 -0
- package/dist/cjs/react/components/chat-window.d.ts +2 -0
- package/dist/cjs/react/components/chat-window.js +134 -0
- package/dist/cjs/react/components/confirm-dialog.d.ts +32 -0
- package/dist/cjs/react/components/confirm-dialog.js +48 -0
- package/dist/cjs/react/components/floating-chat-ui.d.ts +90 -0
- package/dist/cjs/react/components/floating-chat-ui.js +163 -0
- package/dist/cjs/react/components/mention-chip.d.ts +16 -0
- package/dist/cjs/react/components/mention-chip.js +42 -0
- package/dist/cjs/react/components/mention-input.d.ts +8 -0
- package/dist/cjs/react/components/mention-input.js +117 -0
- package/dist/cjs/react/components/message-bubble.d.ts +11 -0
- package/dist/cjs/react/components/message-bubble.js +171 -0
- package/dist/cjs/react/components/message-list.d.ts +8 -0
- package/dist/cjs/react/components/message-list.js +52 -0
- package/dist/cjs/react/components/pipeline-timeline.d.ts +7 -0
- package/dist/cjs/react/components/pipeline-timeline.js +72 -0
- package/dist/cjs/react/components/recording-bar.d.ts +2 -0
- package/dist/cjs/react/components/recording-bar.js +81 -0
- package/dist/cjs/react/components/recording-controls.d.ts +18 -0
- package/dist/cjs/react/components/recording-controls.js +38 -0
- package/dist/cjs/react/components/rich-mention-input.d.ts +2 -0
- package/dist/cjs/react/components/rich-mention-input.js +571 -0
- package/dist/cjs/react/components/session-switcher.d.ts +14 -0
- package/dist/cjs/react/components/session-switcher.js +133 -0
- package/dist/cjs/react/components/suggestion-bar.d.ts +9 -0
- package/dist/cjs/react/components/suggestion-bar.js +47 -0
- package/dist/cjs/react/components/suggestion-chip.d.ts +9 -0
- package/dist/cjs/react/components/suggestion-chip.js +14 -0
- package/dist/cjs/react/components/voice-input-addon.d.ts +13 -0
- package/dist/cjs/react/components/voice-input-addon.js +31 -0
- package/dist/cjs/react/components/voice-input-button.d.ts +2 -0
- package/dist/cjs/react/components/voice-input-button.js +55 -0
- package/dist/cjs/react/components/wavesurfer-loader.d.ts +5 -0
- package/dist/cjs/react/components/wavesurfer-loader.js +36 -0
- package/dist/cjs/react/hooks/use-ai-chat.d.ts +22 -0
- package/dist/cjs/react/hooks/use-ai-chat.js +51 -0
- package/dist/cjs/react/hooks/use-approvals.d.ts +23 -0
- package/dist/cjs/react/hooks/use-approvals.js +63 -0
- package/dist/cjs/react/hooks/use-deepgram-transcription.d.ts +2 -0
- package/dist/cjs/react/hooks/use-deepgram-transcription.js +329 -0
- package/dist/cjs/react/hooks/use-drag-resize-panel.d.ts +48 -0
- package/dist/cjs/react/hooks/use-drag-resize-panel.js +308 -0
- package/dist/cjs/react/hooks/use-draggable-position.d.ts +25 -0
- package/dist/cjs/react/hooks/use-draggable-position.js +134 -0
- package/dist/cjs/react/hooks/use-keyboard-shortcut.d.ts +20 -0
- package/dist/cjs/react/hooks/use-keyboard-shortcut.js +93 -0
- package/dist/cjs/react/hooks/use-mentions.d.ts +23 -0
- package/dist/cjs/react/hooks/use-mentions.js +42 -0
- package/dist/cjs/react/hooks/use-suggestions.d.ts +22 -0
- package/dist/cjs/react/hooks/use-suggestions.js +39 -0
- package/dist/cjs/react/index.d.ts +43 -0
- package/dist/cjs/react/index.js +111 -0
- package/dist/cjs/react/provider/ai-chat-provider.d.ts +45 -0
- package/dist/cjs/react/provider/ai-chat-provider.js +1024 -0
- package/dist/cjs/react/provider/chat-context.d.ts +84 -0
- package/dist/cjs/react/provider/chat-context.js +13 -0
- package/dist/cjs/react/template.d.ts +84 -0
- package/dist/cjs/react/template.js +90 -0
- package/dist/cjs/react/themes.d.ts +24 -0
- package/dist/cjs/react/themes.js +273 -0
- package/dist/cjs/react/transports/langgraph/index.d.ts +2 -0
- package/dist/cjs/react/transports/langgraph/index.js +8 -0
- package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.d.ts +62 -0
- package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.js +94 -0
- package/dist/cjs/react/transports/langgraph.d.ts +71 -0
- package/dist/cjs/react/transports/langgraph.js +369 -0
- package/dist/cjs/react/transports/vercel/index.d.ts +2 -0
- package/dist/cjs/react/transports/vercel/index.js +8 -0
- package/dist/cjs/react/transports/vercel/vercel-ai-chat.d.ts +49 -0
- package/dist/cjs/react/transports/vercel/vercel-ai-chat.js +81 -0
- package/dist/cjs/react/transports/vercel.d.ts +30 -0
- package/dist/cjs/react/transports/vercel.js +69 -0
- package/dist/cjs/react/types.d.ts +760 -0
- package/dist/cjs/react/types.js +2 -0
- package/dist/cjs/react/ui.d.ts +73 -0
- package/dist/cjs/react/ui.js +183 -0
- package/dist/cjs/react/utils/create-approval-description.d.ts +53 -0
- package/dist/cjs/react/utils/create-approval-description.js +122 -0
- package/dist/cjs/react/utils/create-tool-result-handler.d.ts +90 -0
- package/dist/cjs/react/utils/create-tool-result-handler.js +168 -0
- package/dist/cjs/react/utils/mention-markup.d.ts +13 -0
- package/dist/cjs/react/utils/mention-markup.js +117 -0
- package/dist/cjs/react/utils/merge-pipeline-steps.d.ts +19 -0
- package/dist/cjs/react/utils/merge-pipeline-steps.js +81 -0
- package/dist/cjs/react/utils/sanitize-stored-messages.d.ts +23 -0
- package/dist/cjs/react/utils/sanitize-stored-messages.js +52 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.d.ts +10 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.js +42 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.d.ts +32 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.js +4 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.d.ts +11 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.js +80 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.d.ts +9 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.js +119 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.d.ts +13 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.js +131 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.d.ts +7 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.js +52 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.d.ts +19 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.js +108 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.d.ts +8 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.js +59 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/index.d.ts +3 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/index.js +9 -0
- package/dist/cjs/server/adapters/nestjs/chat/index.d.ts +3 -0
- package/dist/cjs/server/adapters/nestjs/chat/index.js +9 -0
- package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +4 -0
- package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.js +73 -0
- package/dist/cjs/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
- package/dist/cjs/server/adapters/nestjs/chat/ws-loader.js +72 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.d.ts +6 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.js +13 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.d.ts +5 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.js +15 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.d.ts +6 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.js +22 -0
- package/dist/cjs/server/adapters/nestjs/decorators/constants.d.ts +4 -0
- package/dist/cjs/server/adapters/nestjs/decorators/constants.js +7 -0
- package/dist/cjs/server/adapters/nestjs/index.d.ts +14 -0
- package/dist/cjs/server/adapters/nestjs/index.js +42 -0
- package/dist/cjs/server/adapters/nestjs/metadata.d.ts +39 -0
- package/dist/cjs/server/adapters/nestjs/metadata.js +36 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.d.ts +36 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.js +159 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.d.ts +37 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.js +44 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.d.ts +28 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.js +41 -0
- package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.d.ts +16 -0
- package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.js +117 -0
- package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.d.ts +26 -0
- package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.js +259 -0
- package/dist/cjs/server/adapters/nestjs/swagger.d.ts +7 -0
- package/dist/cjs/server/adapters/nestjs/swagger.js +39 -0
- package/dist/cjs/server/adapters/nextjs/context-helpers.d.ts +22 -0
- package/dist/cjs/server/adapters/nextjs/context-helpers.js +60 -0
- package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.d.ts +94 -0
- package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.js +965 -0
- package/dist/cjs/server/adapters/nextjs/filter-fallback-error.d.ts +11 -0
- package/dist/cjs/server/adapters/nextjs/filter-fallback-error.js +41 -0
- package/dist/cjs/server/adapters/nextjs/index.d.ts +8 -0
- package/dist/cjs/server/adapters/nextjs/index.js +22 -0
- package/dist/cjs/server/adapters/nextjs/prepare-model-messages.d.ts +58 -0
- package/dist/cjs/server/adapters/nextjs/prepare-model-messages.js +114 -0
- package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.d.ts +64 -0
- package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.js +489 -0
- package/dist/cjs/server/adapters/nextjs/server-action-helper.d.ts +7 -0
- package/dist/cjs/server/adapters/nextjs/server-action-helper.js +40 -0
- package/dist/cjs/server/adapters/nextjs/types.d.ts +246 -0
- package/dist/cjs/server/adapters/nextjs/types.js +2 -0
- package/dist/cjs/server/adapters/nextjs/with-ai-tool.d.ts +9 -0
- package/dist/cjs/server/adapters/nextjs/with-ai-tool.js +12 -0
- package/dist/cjs/server/core/followup-tool.d.ts +9 -0
- package/dist/cjs/server/core/followup-tool.js +82 -0
- package/dist/cjs/server/core/index.d.ts +139 -0
- package/dist/cjs/server/core/index.js +818 -0
- package/dist/cjs/server/core/intent-classifier.d.ts +94 -0
- package/dist/cjs/server/core/intent-classifier.js +324 -0
- package/dist/cjs/server/core/model-selector.d.ts +12 -0
- package/dist/cjs/server/core/model-selector.js +48 -0
- package/dist/cjs/server/core/module-router.d.ts +14 -0
- package/dist/cjs/server/core/module-router.js +110 -0
- package/dist/cjs/server/core/zod-compact.d.ts +18 -0
- package/dist/cjs/server/core/zod-compact.js +129 -0
- package/dist/cjs/server/index.d.ts +6 -0
- package/dist/cjs/server/index.js +28 -0
- package/dist/cjs/server/lancer/cache.d.ts +9 -0
- package/dist/cjs/server/lancer/cache.js +33 -0
- package/dist/cjs/server/lancer/client.d.ts +2 -0
- package/dist/cjs/server/lancer/client.js +279 -0
- package/dist/cjs/server/lancer/errors.d.ts +13 -0
- package/dist/cjs/server/lancer/errors.js +21 -0
- package/dist/cjs/server/lancer/index.d.ts +3 -0
- package/dist/cjs/server/lancer/index.js +7 -0
- package/dist/cjs/server/lancer/telemetry-buffer.d.ts +15 -0
- package/dist/cjs/server/lancer/telemetry-buffer.js +64 -0
- package/dist/cjs/server/lancer/types.d.ts +201 -0
- package/dist/cjs/server/lancer/types.js +5 -0
- package/dist/cjs/server/pii-shield/aegis-detector.d.ts +26 -0
- package/dist/cjs/server/pii-shield/aegis-detector.js +26 -0
- package/dist/cjs/server/pii-shield/create-pii-shield.d.ts +2 -0
- package/dist/cjs/server/pii-shield/create-pii-shield.js +191 -0
- package/dist/cjs/server/pii-shield/deep-walk.d.ts +1 -0
- package/dist/cjs/server/pii-shield/deep-walk.js +19 -0
- package/dist/cjs/server/pii-shield/fake-data.d.ts +5 -0
- package/dist/cjs/server/pii-shield/fake-data.js +170 -0
- package/dist/cjs/server/pii-shield/index.d.ts +4 -0
- package/dist/cjs/server/pii-shield/index.js +9 -0
- package/dist/cjs/server/pii-shield/leakage.d.ts +1 -0
- package/dist/cjs/server/pii-shield/leakage.js +15 -0
- package/dist/cjs/server/pii-shield/session-mapping.d.ts +12 -0
- package/dist/cjs/server/pii-shield/session-mapping.js +70 -0
- package/dist/cjs/server/pipeline.d.ts +26 -0
- package/dist/cjs/server/pipeline.js +127 -0
- package/dist/cjs/server/testing/approvals.d.ts +11 -0
- package/dist/cjs/server/testing/approvals.js +41 -0
- package/dist/cjs/server/testing/combination.d.ts +3 -0
- package/dist/cjs/server/testing/combination.js +83 -0
- package/dist/cjs/server/testing/create-test-suite.d.ts +29 -0
- package/dist/cjs/server/testing/create-test-suite.js +81 -0
- package/dist/cjs/server/testing/edge-cases.d.ts +8 -0
- package/dist/cjs/server/testing/edge-cases.js +277 -0
- package/dist/cjs/server/testing/guardrails.d.ts +14 -0
- package/dist/cjs/server/testing/guardrails.js +152 -0
- package/dist/cjs/server/testing/helpers.d.ts +14 -0
- package/dist/cjs/server/testing/helpers.js +119 -0
- package/dist/cjs/server/testing/index.d.ts +12 -0
- package/dist/cjs/server/testing/index.js +37 -0
- package/dist/cjs/server/testing/mock-executor.d.ts +8 -0
- package/dist/cjs/server/testing/mock-executor.js +40 -0
- package/dist/cjs/server/testing/regression.d.ts +7 -0
- package/dist/cjs/server/testing/regression.js +27 -0
- package/dist/cjs/server/testing/routing.d.ts +12 -0
- package/dist/cjs/server/testing/routing.js +63 -0
- package/dist/cjs/server/testing/schema-consistency.d.ts +6 -0
- package/dist/cjs/server/testing/schema-consistency.js +56 -0
- package/dist/cjs/server/testing/smoke.d.ts +11 -0
- package/dist/cjs/server/testing/smoke.js +64 -0
- package/dist/cjs/server/testing/types.d.ts +156 -0
- package/dist/cjs/server/testing/types.js +2 -0
- package/dist/cjs/types.d.ts +696 -0
- package/dist/cjs/types.js +91 -0
- package/dist/cli/commands/install-skills.d.ts +17 -0
- package/dist/cli/commands/install-skills.js +185 -0
- package/dist/cli/commands/install-skills.js.map +1 -0
- package/dist/cli/index.js +25 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/react/components/ai-trigger-button.js +4 -6
- package/dist/react/components/ai-trigger-button.js.map +1 -1
- package/dist/react/components/recording-bar.js +4 -6
- package/dist/react/components/recording-bar.js.map +1 -1
- package/dist/react/components/wavesurfer-loader.d.ts +5 -0
- package/dist/react/components/wavesurfer-loader.js +34 -0
- package/dist/react/components/wavesurfer-loader.js.map +1 -0
- package/dist/server/adapters/nestjs/chat/ai-chat.module.d.ts +1 -1
- package/dist/server/adapters/nestjs/chat/ai-chat.module.js +3 -2
- package/dist/server/adapters/nestjs/chat/ai-chat.module.js.map +1 -1
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +1 -1
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js +10 -8
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js.map +1 -1
- package/dist/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
- package/dist/server/adapters/nestjs/chat/ws-loader.js +37 -0
- package/dist/server/adapters/nestjs/chat/ws-loader.js.map +1 -0
- package/dist/server/adapters/nextjs/create-ai-chat-handler.d.ts +16 -0
- package/dist/server/adapters/nextjs/create-ai-chat-handler.js +14 -3
- package/dist/server/adapters/nextjs/create-ai-chat-handler.js.map +1 -1
- package/dist/server/adapters/nextjs/filter-fallback-error.d.ts +11 -0
- package/dist/server/adapters/nextjs/filter-fallback-error.js +38 -0
- package/dist/server/adapters/nextjs/filter-fallback-error.js.map +1 -0
- package/openapi/package.json +5 -0
- package/package.json +66 -21
- package/react/langgraph/package.json +5 -0
- package/react/package.json +5 -0
- package/react/vercel/package.json +5 -0
- package/server/nestjs/package.json +5 -0
- package/server/nextjs/package.json +5 -0
- package/server/package.json +5 -0
- package/server/testing/package.json +5 -0
- package/skills/README.md +107 -0
- package/skills/building-glirastes-chat-ui/SKILL.md +378 -0
- package/skills/integrating-glirastes-nestjs/SKILL.md +346 -0
- package/skills/integrating-glirastes-nextjs/SKILL.md +306 -0
- package/skills/integrating-glirastes-nextjs-with-nestjs-backend/SKILL.md +359 -0
- package/skills/maintaining-glirastes-tools/SKILL.md +463 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: integrating-glirastes-nextjs-with-nestjs-backend
|
|
3
|
+
description: Integrating Glirastes into a full-stack monorepo with Next.js frontend and a separate NestJS backend — chat route on the backend, widget on the frontend, CORS, JWT forwarding, env separation. Use when the same workspace contains both a Next.js app and a NestJS API service.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
tags:
|
|
6
|
+
- glirastes
|
|
7
|
+
- nextjs
|
|
8
|
+
- nestjs
|
|
9
|
+
- monorepo
|
|
10
|
+
- full-stack
|
|
11
|
+
triggers:
|
|
12
|
+
- integrate glirastes nextjs nestjs
|
|
13
|
+
- frontend backend chat
|
|
14
|
+
- monorepo glirastes
|
|
15
|
+
- next.js with nestjs
|
|
16
|
+
- chat across frontend backend
|
|
17
|
+
- full stack glirastes
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Integrating Glirastes — Next.js Frontend + NestJS Backend
|
|
21
|
+
|
|
22
|
+
> **Architectural rule:** When you have both a Next.js frontend and a separate NestJS backend, the chat route belongs on the **backend**. Putting it on the Next.js side means duplicating auth, an extra HTTP hop per tool call, and a forking source-of-truth for tool definitions. This skill assumes you've already accepted that — it walks the wiring.
|
|
23
|
+
>
|
|
24
|
+
> **Companion skills:**
|
|
25
|
+
> - [integrating-glirastes-nestjs](../integrating-glirastes-nestjs/SKILL.md) — pure NestJS deep-dive (decorators, DI, WS)
|
|
26
|
+
> - [maintaining-glirastes-tools](../maintaining-glirastes-tools/SKILL.md) — tool authoring + CLI
|
|
27
|
+
> - [building-glirastes-chat-ui](../building-glirastes-chat-ui/SKILL.md) — chat UI customization
|
|
28
|
+
|
|
29
|
+
## Stack detection
|
|
30
|
+
|
|
31
|
+
Confirm the workspace looks like this:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
my-app/
|
|
35
|
+
├── frontend/ ← Next.js (next.config.{ts,js,mjs}, React 19+)
|
|
36
|
+
│ ├── package.json
|
|
37
|
+
│ └── src/app/
|
|
38
|
+
├── backend/ ← NestJS (nest-cli.json, @nestjs/core)
|
|
39
|
+
│ ├── package.json
|
|
40
|
+
│ └── src/
|
|
41
|
+
├── shared/ ← optional shared DTOs
|
|
42
|
+
│ └── package.json
|
|
43
|
+
└── package.json ← optional workspace root
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
If only one of the two exists, switch to the appropriate single-stack skill — [Next.js](../integrating-glirastes-nextjs/SKILL.md) or [NestJS](../integrating-glirastes-nestjs/SKILL.md).
|
|
47
|
+
|
|
48
|
+
## Step 1 — Install in both packages
|
|
49
|
+
|
|
50
|
+
### Backend
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cd backend
|
|
54
|
+
npm install glirastes @ai-sdk/openai
|
|
55
|
+
# Optional: speech-to-text via Deepgram
|
|
56
|
+
# npm install ws
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Frontend
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cd frontend
|
|
63
|
+
npm install glirastes @ai-sdk/react react-markdown
|
|
64
|
+
# Optional: voice input UI
|
|
65
|
+
# npm install wavesurfer.js
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The frontend gets the React UI peers but not `@ai-sdk/openai` — the model never runs in the browser. The backend gets the model provider.
|
|
69
|
+
|
|
70
|
+
## Step 2 — Environment variables
|
|
71
|
+
|
|
72
|
+
### Backend `.env`
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
OPENAI_API_KEY=sk-...
|
|
76
|
+
# Optional speech-to-text:
|
|
77
|
+
# DEEPGRAM_API_KEY=...
|
|
78
|
+
# Optional Glirastes platform:
|
|
79
|
+
# GLIRASTES_API_KEY=glir_...
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Frontend `.env.local`
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
NEXT_PUBLIC_API_URL=http://localhost:3000
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The frontend only needs to know where the backend lives. **Never** put `OPENAI_API_KEY` in the frontend env — the model call lives on the backend.
|
|
89
|
+
|
|
90
|
+
## Step 3 — Backend tsconfig (no changes needed)
|
|
91
|
+
|
|
92
|
+
Glirastes 0.3.1+ ships dual CJS+ESM bundles plus subpath shims. The default NestJS template (`module: "commonjs"`, no explicit `moduleResolution`) works as-is. If your project is on a modern config (`module: "node16"` or similar), that's fine too.
|
|
93
|
+
|
|
94
|
+
## Step 4 — Annotate existing controllers (backend)
|
|
95
|
+
|
|
96
|
+
Pick controllers that should expose AI-callable methods. Annotate the class with `@AiModule` and each method with `@AiTool`:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
// backend/src/tasks/tasks.controller.ts
|
|
100
|
+
import { Body, Controller, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
|
|
101
|
+
import { AuthGuard } from '@nestjs/passport';
|
|
102
|
+
import { AiModule, AiTool } from 'glirastes/server/nestjs';
|
|
103
|
+
import { TasksService } from './tasks.service';
|
|
104
|
+
import { CreateTaskDto, ListTasksQueryDto } from 'shared'; // shared DTOs
|
|
105
|
+
|
|
106
|
+
@Controller('tasks')
|
|
107
|
+
@UseGuards(AuthGuard('jwt'))
|
|
108
|
+
@AiModule({
|
|
109
|
+
intent: 'task_management',
|
|
110
|
+
classification: {
|
|
111
|
+
hint: 'User asks about listing, filtering, creating, or updating tasks.',
|
|
112
|
+
examples: [
|
|
113
|
+
'show me open tasks',
|
|
114
|
+
'create a task: review PR',
|
|
115
|
+
'mark task 42 as done',
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
})
|
|
119
|
+
export class TasksController {
|
|
120
|
+
constructor(private readonly tasksService: TasksService) {}
|
|
121
|
+
|
|
122
|
+
@Get()
|
|
123
|
+
@AiTool({
|
|
124
|
+
name: 'list_tasks',
|
|
125
|
+
description: 'List tasks with an optional status filter.',
|
|
126
|
+
})
|
|
127
|
+
list(@Query() q: ListTasksQueryDto) {
|
|
128
|
+
return this.tasksService.list(q);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@Post()
|
|
132
|
+
@AiTool({
|
|
133
|
+
name: 'create_task',
|
|
134
|
+
description: 'Create a new task. Always confirm the title with the user first.',
|
|
135
|
+
})
|
|
136
|
+
create(@Body() dto: CreateTaskDto) {
|
|
137
|
+
return this.tasksService.create(dto);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
If you have a `shared/` package with DTOs, annotate the DTO fields with `@AiParam` so the LLM gets descriptions:
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
// shared/src/dtos/list-tasks.dto.ts
|
|
146
|
+
import { IsOptional, IsString } 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
|
+
@ApiProperty({ required: false })
|
|
154
|
+
@AiParam('Optional status filter — one of "open" | "done".')
|
|
155
|
+
status?: 'open' | 'done';
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
> **Watch the `shared/dist` cache.** If you previously experimented with `@AiTool`/`@AiParam` decorators in `shared/`, an old `dist/` copy may import a stale `glirastes/server/nestjs` path. Run `cd shared && npm run build` (or `./rebuild-shared.sh` if your workspace has one) to overwrite. Then `npm install` in the backend so the file:-dep refreshes.
|
|
160
|
+
|
|
161
|
+
## Step 5 — Wire AiChatModule on the backend
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
// backend/src/chat/chat.module.ts
|
|
165
|
+
import { openai } from '@ai-sdk/openai';
|
|
166
|
+
import { Module } from '@nestjs/common';
|
|
167
|
+
import { AuthGuard } from '@nestjs/passport';
|
|
168
|
+
import { AiChatModule } from 'glirastes/server/nestjs';
|
|
169
|
+
import { TasksModule } from '../tasks/tasks.module';
|
|
170
|
+
|
|
171
|
+
@Module({
|
|
172
|
+
imports: [
|
|
173
|
+
TasksModule,
|
|
174
|
+
AiChatModule.forRoot({
|
|
175
|
+
model: openai('gpt-4o-mini'),
|
|
176
|
+
systemPrompt: ({ currentDate }) =>
|
|
177
|
+
`You are a helpful assistant. Today is ${currentDate}.`,
|
|
178
|
+
authGuard: AuthGuard('jwt'),
|
|
179
|
+
}),
|
|
180
|
+
],
|
|
181
|
+
})
|
|
182
|
+
export class ChatModule {}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Register in `AppModule`:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
// backend/src/app.module.ts
|
|
189
|
+
import { Module } from '@nestjs/common';
|
|
190
|
+
import { ChatModule } from './chat/chat.module';
|
|
191
|
+
|
|
192
|
+
@Module({
|
|
193
|
+
imports: [
|
|
194
|
+
// ... existing modules (Auth, Tasks, etc.)
|
|
195
|
+
ChatModule,
|
|
196
|
+
],
|
|
197
|
+
})
|
|
198
|
+
export class AppModule {}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
The same JWT guard that protects your other endpoints now protects `/api/ai/chat` — single source of auth.
|
|
202
|
+
|
|
203
|
+
## Step 6 — CORS on the backend
|
|
204
|
+
|
|
205
|
+
The browser will hit the backend directly. Allow the frontend origin in `main.ts`:
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
// backend/src/main.ts
|
|
209
|
+
import { NestFactory } from '@nestjs/core';
|
|
210
|
+
import { AppModule } from './app.module';
|
|
211
|
+
|
|
212
|
+
async function bootstrap() {
|
|
213
|
+
const app = await NestFactory.create(AppModule);
|
|
214
|
+
|
|
215
|
+
app.enableCors({
|
|
216
|
+
origin: process.env.FRONTEND_URL ?? 'http://localhost:3001',
|
|
217
|
+
credentials: true,
|
|
218
|
+
methods: ['GET', 'POST', 'OPTIONS'],
|
|
219
|
+
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
await app.listen(3000);
|
|
223
|
+
}
|
|
224
|
+
bootstrap();
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
If your deployment puts both apps behind the same reverse proxy (nginx, Cloudflare) under a single hostname, you can skip CORS — same-origin requests don't need it.
|
|
228
|
+
|
|
229
|
+
## Step 7 — Mount the chat widget (frontend)
|
|
230
|
+
|
|
231
|
+
Use `VercelAiChat` and point `endpoint` at the backend. Pass the user's JWT through `headers`:
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
// frontend/src/components/chat/ChatWidget.tsx
|
|
235
|
+
'use client';
|
|
236
|
+
|
|
237
|
+
import { VercelAiChat } from 'glirastes/react/vercel';
|
|
238
|
+
import { getToken } from '@/lib/auth'; // your existing token reader
|
|
239
|
+
|
|
240
|
+
const API_URL = process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:3000';
|
|
241
|
+
|
|
242
|
+
export function ChatWidget() {
|
|
243
|
+
return (
|
|
244
|
+
<VercelAiChat
|
|
245
|
+
endpoint={`${API_URL}/api/ai/chat`}
|
|
246
|
+
headers={() => {
|
|
247
|
+
const token = getToken();
|
|
248
|
+
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
249
|
+
}}
|
|
250
|
+
/>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
```tsx
|
|
256
|
+
// frontend/src/app/layout.tsx
|
|
257
|
+
import { ChatWidget } from '@/components/chat/ChatWidget';
|
|
258
|
+
import 'glirastes/react/styles.css';
|
|
259
|
+
|
|
260
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
261
|
+
return (
|
|
262
|
+
<html>
|
|
263
|
+
<body>
|
|
264
|
+
{children}
|
|
265
|
+
<ChatWidget />
|
|
266
|
+
</body>
|
|
267
|
+
</html>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
`headers` is a function — re-evaluated on every request, so token rotation works without a remount.
|
|
273
|
+
|
|
274
|
+
## Step 8 — UI actions on the frontend (optional)
|
|
275
|
+
|
|
276
|
+
Endpoint tools that declare `uiPattern: { type: 'open-detail' | 'open-dialog' | 'refresh' | 'toast' }` emit a structured action through the `UiActionBus`. Register handlers in your frontend:
|
|
277
|
+
|
|
278
|
+
```tsx
|
|
279
|
+
'use client';
|
|
280
|
+
import { useAiClientAction } from 'glirastes/react';
|
|
281
|
+
import { useRouter } from 'next/navigation';
|
|
282
|
+
|
|
283
|
+
export function TaskList() {
|
|
284
|
+
const router = useRouter();
|
|
285
|
+
|
|
286
|
+
useAiClientAction('task-details.open', (payload) => {
|
|
287
|
+
router.push(`/tasks/${payload?.taskId}`);
|
|
288
|
+
});
|
|
289
|
+
useAiClientAction('tasks.refresh', () => {
|
|
290
|
+
queryClient.invalidateQueries({ queryKey: ['tasks'] });
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// ...
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
The action ID is derived from the tool's `uiPattern`. See [maintaining-glirastes-tools](../maintaining-glirastes-tools/SKILL.md) for the mapping.
|
|
298
|
+
|
|
299
|
+
## Step 9 — Verify
|
|
300
|
+
|
|
301
|
+
In two terminals:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# Terminal 1
|
|
305
|
+
cd backend && npm run start:dev
|
|
306
|
+
|
|
307
|
+
# Terminal 2
|
|
308
|
+
cd frontend && npm run dev
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Then:
|
|
312
|
+
|
|
313
|
+
1. Open the frontend (default `http://localhost:3001`)
|
|
314
|
+
2. Log in (so a JWT is in storage)
|
|
315
|
+
3. Click the floating chat trigger
|
|
316
|
+
4. Send *"show me my open tasks"*
|
|
317
|
+
|
|
318
|
+
Expected:
|
|
319
|
+
- Backend log shows `POST /api/ai/chat` and `GET /api/tasks` (the tool firing)
|
|
320
|
+
- Chat shows the result
|
|
321
|
+
- If a `uiPattern: 'filter-and-navigate'` is on the tool, the URL changes to `/tasks?status=open`
|
|
322
|
+
|
|
323
|
+
If the request fails with 401: the JWT isn't reaching the backend. Check `headers()` returns the right token. If 403: the JWT is valid but lacks permissions — the same RBAC your other endpoints enforce applies here.
|
|
324
|
+
|
|
325
|
+
## Step 10 — Optional: speech-to-text
|
|
326
|
+
|
|
327
|
+
Add `features: { speechToText: true }` to `AiChatModule.forRoot`, install `ws` on the backend, set `DEEPGRAM_API_KEY`, and call `await AiChatModule.attachWebSockets(app)` after `app.listen()`. Frontend: `showMic={true}` on `<VercelAiChat />` and install `wavesurfer.js`. Full instructions in [integrating-glirastes-nestjs](../integrating-glirastes-nestjs/SKILL.md) → "Speech-to-text WebSocket".
|
|
328
|
+
|
|
329
|
+
## Architectural decisions made
|
|
330
|
+
|
|
331
|
+
| Decision | Reason |
|
|
332
|
+
|---|---|
|
|
333
|
+
| Chat route on the backend, not Next.js Route Handler | Tools are NestJS controllers — annotating them in place avoids a duplicate code path. JWT guard already exists. No HTTP hop per tool call. |
|
|
334
|
+
| `@ai-sdk/openai` lives only in backend | Model calls are server-side; the API key must never reach the browser. |
|
|
335
|
+
| `@ai-sdk/react` and `react-markdown` only in frontend | Optional peers since 0.3.1; backend doesn't need React. |
|
|
336
|
+
| `wavesurfer.js` only in frontend (and only if voice) | Browser-only library; backend doesn't render waveforms. |
|
|
337
|
+
| `ws` only in backend (and only if speech-to-text) | Server-side WebSocket proxy to Deepgram. Loaded via runtime helper since 0.3.1 — won't crash if missing when the feature is off. |
|
|
338
|
+
| CORS configured backend-side | Same-origin convenience requires a reverse proxy; without one, CORS is the cleanest path. |
|
|
339
|
+
|
|
340
|
+
## Common pitfalls (specific to this stack combination)
|
|
341
|
+
|
|
342
|
+
| Symptom | Cause | Fix |
|
|
343
|
+
|---|---|---|
|
|
344
|
+
| `CORS: Access-Control-Allow-Origin missing` in browser console | `enableCors` not configured | Add `app.enableCors({ origin: FRONTEND_URL, credentials: true })` |
|
|
345
|
+
| Chat returns 401 even though user is logged in | `headers()` not passing JWT, or token in wrong cookie/storage | DevTools → Network → check the `Authorization` header on `POST /api/ai/chat` |
|
|
346
|
+
| Tool fires but UI never reacts | `useAiClientAction` handler in a component not mounted on the active page | Move the handler to a layout that's always rendered, or to a global provider |
|
|
347
|
+
| Backend imports `glirastes/server/nestjs` but build fails | Old SDK (≤0.3.0 was ESM-only); workspace contains stale `shared/dist` | Upgrade to ≥0.3.1; rebuild `shared` package |
|
|
348
|
+
| Chat works in dev but breaks in production | `NEXT_PUBLIC_API_URL` not set in the production env | Set in your hosting provider's env config |
|
|
349
|
+
| Two chat widgets render on the page | `<ChatWidget />` duplicated | Render exactly once in the root layout |
|
|
350
|
+
| Voice input fails silently | `ws` missing on backend, or `wavesurfer.js` missing on frontend | Install on the side that needs it; check both browser DevTools (WS frame) and backend logs |
|
|
351
|
+
|
|
352
|
+
## What this skill does NOT cover
|
|
353
|
+
|
|
354
|
+
- **Pure Next.js (no separate backend)** — see [integrating-glirastes-nextjs](../integrating-glirastes-nextjs/SKILL.md)
|
|
355
|
+
- **Pure NestJS (Swagger UI as client)** — see [integrating-glirastes-nestjs](../integrating-glirastes-nestjs/SKILL.md)
|
|
356
|
+
- **Tool authoring deep-dive** — see [maintaining-glirastes-tools](../maintaining-glirastes-tools/SKILL.md)
|
|
357
|
+
- **Chat UI customization** — see [building-glirastes-chat-ui](../building-glirastes-chat-ui/SKILL.md)
|
|
358
|
+
- **LangGraph backend** — swap `AiChatModule` (NestJS doesn't ship a LangGraph adapter directly); use the LangGraph transport on the React side
|
|
359
|
+
- **Glirastes platform features** — opt in via `GLIRASTES_API_KEY`; the SDK falls back to free-tier without it
|