glirastes 0.3.0 → 0.3.2
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 +86 -0
- package/README.md +154 -9
- 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/openapi/package.json +5 -0
- package/package.json +59 -16
- 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 +312 -0
- package/skills/integrating-glirastes-nextjs-with-nestjs-backend/SKILL.md +359 -0
- package/skills/maintaining-glirastes-tools/SKILL.md +467 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionSwitcher = SessionSwitcher;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const chat_context_js_1 = require("../provider/chat-context.js");
|
|
7
|
+
const confirm_dialog_js_1 = require("./confirm-dialog.js");
|
|
8
|
+
function defaultFormatTimestamp(value) {
|
|
9
|
+
if (value === undefined || value === null || value === '')
|
|
10
|
+
return '';
|
|
11
|
+
const d = new Date(value);
|
|
12
|
+
if (Number.isNaN(d.getTime()))
|
|
13
|
+
return '';
|
|
14
|
+
return d.toLocaleDateString(undefined, {
|
|
15
|
+
month: 'short',
|
|
16
|
+
day: 'numeric',
|
|
17
|
+
hour: 'numeric',
|
|
18
|
+
minute: '2-digit',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Compact dropdown that lists all chat sessions, lets the user switch
|
|
23
|
+
* between them, create new ones, and delete existing ones. Reads
|
|
24
|
+
* everything from `useChatContext()` — requires an `<AiChatProvider>`
|
|
25
|
+
* ancestor whose `session` config exposes `list`, `create`, and `remove`.
|
|
26
|
+
*/
|
|
27
|
+
function SessionSwitcher({ fallbackTitle, formatTimestamp = defaultFormatTimestamp, className, } = {}) {
|
|
28
|
+
const { sessions, activeSessionId, sessionsSupported, isSessionsLoading, switchSession, createSession, removeSession, renameSession, locale, } = (0, chat_context_js_1.useChatContext)();
|
|
29
|
+
const resolvedFallback = fallbackTitle ?? locale.newChatLabel;
|
|
30
|
+
const [editingId, setEditingId] = (0, react_1.useState)(null);
|
|
31
|
+
const [editDraft, setEditDraft] = (0, react_1.useState)('');
|
|
32
|
+
const editInputRef = (0, react_1.useRef)(null);
|
|
33
|
+
(0, react_1.useEffect)(() => {
|
|
34
|
+
if (editingId && editInputRef.current) {
|
|
35
|
+
editInputRef.current.focus();
|
|
36
|
+
editInputRef.current.select();
|
|
37
|
+
}
|
|
38
|
+
}, [editingId]);
|
|
39
|
+
const beginEdit = (0, react_1.useCallback)((e, id, title) => {
|
|
40
|
+
e.stopPropagation();
|
|
41
|
+
setEditingId(id);
|
|
42
|
+
setEditDraft(title);
|
|
43
|
+
}, []);
|
|
44
|
+
const cancelEdit = (0, react_1.useCallback)(() => {
|
|
45
|
+
setEditingId(null);
|
|
46
|
+
setEditDraft('');
|
|
47
|
+
}, []);
|
|
48
|
+
const commitEdit = (0, react_1.useCallback)(async () => {
|
|
49
|
+
const id = editingId;
|
|
50
|
+
const next = editDraft.trim();
|
|
51
|
+
setEditingId(null);
|
|
52
|
+
setEditDraft('');
|
|
53
|
+
if (!id)
|
|
54
|
+
return;
|
|
55
|
+
const current = sessions.find((s) => s.id === id)?.title ?? '';
|
|
56
|
+
if (!next || next === current)
|
|
57
|
+
return;
|
|
58
|
+
await renameSession(id, next);
|
|
59
|
+
}, [editingId, editDraft, renameSession, sessions]);
|
|
60
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
61
|
+
const [pendingDeleteId, setPendingDeleteId] = (0, react_1.useState)(null);
|
|
62
|
+
const rootRef = (0, react_1.useRef)(null);
|
|
63
|
+
(0, react_1.useEffect)(() => {
|
|
64
|
+
if (!open)
|
|
65
|
+
return;
|
|
66
|
+
const handler = (e) => {
|
|
67
|
+
if (!rootRef.current)
|
|
68
|
+
return;
|
|
69
|
+
if (!(e.target instanceof Node))
|
|
70
|
+
return;
|
|
71
|
+
if (rootRef.current.contains(e.target))
|
|
72
|
+
return;
|
|
73
|
+
setOpen(false);
|
|
74
|
+
};
|
|
75
|
+
window.addEventListener('mousedown', handler);
|
|
76
|
+
return () => window.removeEventListener('mousedown', handler);
|
|
77
|
+
}, [open]);
|
|
78
|
+
const onNew = (0, react_1.useCallback)(async () => {
|
|
79
|
+
setOpen(false);
|
|
80
|
+
await createSession({ title: locale.newChatLabel });
|
|
81
|
+
}, [createSession, locale.newChatLabel]);
|
|
82
|
+
const onPick = (0, react_1.useCallback)(async (id) => {
|
|
83
|
+
setOpen(false);
|
|
84
|
+
if (id === activeSessionId)
|
|
85
|
+
return;
|
|
86
|
+
await switchSession(id);
|
|
87
|
+
}, [switchSession, activeSessionId]);
|
|
88
|
+
const onDelete = (0, react_1.useCallback)((e, id) => {
|
|
89
|
+
e.stopPropagation();
|
|
90
|
+
setPendingDeleteId(id);
|
|
91
|
+
}, []);
|
|
92
|
+
const confirmDelete = (0, react_1.useCallback)(async () => {
|
|
93
|
+
const id = pendingDeleteId;
|
|
94
|
+
setPendingDeleteId(null);
|
|
95
|
+
if (!id)
|
|
96
|
+
return;
|
|
97
|
+
await removeSession(id);
|
|
98
|
+
}, [pendingDeleteId, removeSession]);
|
|
99
|
+
const cancelDelete = (0, react_1.useCallback)(() => {
|
|
100
|
+
setPendingDeleteId(null);
|
|
101
|
+
}, []);
|
|
102
|
+
if (!sessionsSupported) {
|
|
103
|
+
return (0, jsx_runtime_1.jsx)("strong", { "data-element": "title", children: resolvedFallback });
|
|
104
|
+
}
|
|
105
|
+
const sorted = [...sessions].sort((a, b) => {
|
|
106
|
+
const av = Number(new Date(a.updatedAt ?? a.createdAt ?? 0).getTime()) || 0;
|
|
107
|
+
const bv = Number(new Date(b.updatedAt ?? b.createdAt ?? 0).getTime()) || 0;
|
|
108
|
+
return bv - av;
|
|
109
|
+
});
|
|
110
|
+
const current = sorted.find((s) => s.id === activeSessionId);
|
|
111
|
+
const currentTitle = current?.title ?? resolvedFallback;
|
|
112
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: rootRef, className: className, "data-component": "session-switcher", "data-open": open || undefined, children: [(0, jsx_runtime_1.jsxs)("button", { type: "button", "data-element": "trigger", onMouseDown: (e) => e.stopPropagation(), onClick: () => setOpen((v) => !v), "aria-haspopup": "listbox", "aria-expanded": open, children: [(0, jsx_runtime_1.jsx)("span", { "data-element": "trigger-title", children: currentTitle }), (0, jsx_runtime_1.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("polyline", { points: "6 9 12 15 18 9" }) })] }), open && ((0, jsx_runtime_1.jsxs)("div", { "data-element": "popover", role: "listbox", onMouseDown: (e) => e.stopPropagation(), children: [(0, jsx_runtime_1.jsxs)("button", { type: "button", "data-element": "new-session", onClick: onNew, disabled: isSessionsLoading, children: [(0, jsx_runtime_1.jsx)("span", { "data-element": "plus", "aria-hidden": "true", children: "+" }), locale.newChatLabel] }), (0, jsx_runtime_1.jsx)("div", { "data-element": "session-list", children: sorted.length === 0 ? ((0, jsx_runtime_1.jsx)("div", { "data-element": "empty", children: isSessionsLoading ? locale.sessionsLoadingLabel : locale.noSessionsLabel })) : (sorted.map((s) => {
|
|
113
|
+
const isActive = s.id === activeSessionId;
|
|
114
|
+
const ts = formatTimestamp(s.updatedAt ?? s.createdAt);
|
|
115
|
+
const isEditing = editingId === s.id;
|
|
116
|
+
return ((0, jsx_runtime_1.jsxs)("div", { role: "option", "aria-selected": isActive, "data-element": "session-row", "data-active": isActive || undefined, "data-editing": isEditing || undefined, onClick: () => {
|
|
117
|
+
if (isEditing)
|
|
118
|
+
return;
|
|
119
|
+
void onPick(s.id);
|
|
120
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { "data-element": "row-main", children: [isEditing ? ((0, jsx_runtime_1.jsx)("input", { ref: editInputRef, type: "text", "data-element": "row-title-input", value: editDraft, placeholder: locale.renameSessionPlaceholder, onChange: (e) => setEditDraft(e.target.value), onClick: (e) => e.stopPropagation(), onMouseDown: (e) => e.stopPropagation(), onKeyDown: (e) => {
|
|
121
|
+
if (e.key === 'Enter') {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
void commitEdit();
|
|
124
|
+
}
|
|
125
|
+
else if (e.key === 'Escape') {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
cancelEdit();
|
|
128
|
+
}
|
|
129
|
+
}, onBlur: () => void commitEdit() })) : ((0, jsx_runtime_1.jsx)("div", { "data-element": "row-title", children: s.title || 'Untitled' })), ts && !isEditing && ((0, jsx_runtime_1.jsx)("div", { "data-element": "row-subtitle", children: ts }))] }), !isEditing && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { type: "button", "data-element": "row-edit", "aria-label": locale.renameSessionAriaLabel, title: locale.renameSessionAriaLabel, onClick: (e) => beginEdit(e, s.id, s.title || ''), onMouseDown: (e) => e.stopPropagation(), children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [(0, jsx_runtime_1.jsx)("path", { d: "M12 20h9" }), (0, jsx_runtime_1.jsx)("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z" })] }) }), (0, jsx_runtime_1.jsx)("button", { type: "button", "data-element": "row-delete", "aria-label": locale.deleteSessionAriaLabel, title: locale.deleteSessionAriaLabel, onClick: (e) => void onDelete(e, s.id), onMouseDown: (e) => e.stopPropagation(), children: (0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [(0, jsx_runtime_1.jsx)("polyline", { points: "3 6 5 6 21 6" }), (0, jsx_runtime_1.jsx)("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" })] }) })] }))] }, s.id));
|
|
130
|
+
})) })] })), (0, jsx_runtime_1.jsx)(confirm_dialog_js_1.ConfirmDialog, { open: pendingDeleteId !== null, title: locale.confirmDeleteSessionPrompt, message: sessions.find((s) => s.id === pendingDeleteId)?.title
|
|
131
|
+
? `"${sessions.find((s) => s.id === pendingDeleteId)?.title}" will be archived.`
|
|
132
|
+
: undefined, confirmLabel: locale.deleteSessionAriaLabel, cancelLabel: locale.cancelButton, destructive: true, onConfirm: () => void confirmDelete(), onCancel: cancelDelete })] }));
|
|
133
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SuggestionBarProps } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Suggestion bar with rotation/fade animation.
|
|
4
|
+
*
|
|
5
|
+
* Shows one suggestion at a time, rotating through the list
|
|
6
|
+
* with a configurable interval and fade transition.
|
|
7
|
+
* Pauses on hover.
|
|
8
|
+
*/
|
|
9
|
+
export declare function SuggestionBar({ className }: SuggestionBarProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SuggestionBar = SuggestionBar;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const chat_context_js_1 = require("../provider/chat-context.js");
|
|
7
|
+
const suggestion_chip_js_1 = require("./suggestion-chip.js");
|
|
8
|
+
const FADE_DURATION = 300;
|
|
9
|
+
/**
|
|
10
|
+
* Suggestion bar with rotation/fade animation.
|
|
11
|
+
*
|
|
12
|
+
* Shows one suggestion at a time, rotating through the list
|
|
13
|
+
* with a configurable interval and fade transition.
|
|
14
|
+
* Pauses on hover.
|
|
15
|
+
*/
|
|
16
|
+
function SuggestionBar({ className }) {
|
|
17
|
+
const { suggestionChips, selectSuggestion, classNames, suggestions, components } = (0, chat_context_js_1.useChatContext)();
|
|
18
|
+
const [currentIndex, setCurrentIndex] = (0, react_1.useState)(0);
|
|
19
|
+
const [isVisible, setIsVisible] = (0, react_1.useState)(true);
|
|
20
|
+
const [isPaused, setIsPaused] = (0, react_1.useState)(false);
|
|
21
|
+
const rotationInterval = suggestions.rotationInterval ?? 4000;
|
|
22
|
+
const SuggestionChipComponent = components.SuggestionChip ?? suggestion_chip_js_1.SuggestionChip;
|
|
23
|
+
// Reset index when chips change
|
|
24
|
+
(0, react_1.useEffect)(() => {
|
|
25
|
+
setCurrentIndex(0);
|
|
26
|
+
setIsVisible(true);
|
|
27
|
+
}, [suggestionChips]);
|
|
28
|
+
// Rotation timer
|
|
29
|
+
(0, react_1.useEffect)(() => {
|
|
30
|
+
if (isPaused || suggestionChips.length <= 1)
|
|
31
|
+
return;
|
|
32
|
+
const interval = setInterval(() => {
|
|
33
|
+
setIsVisible(false);
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
setCurrentIndex((prev) => (prev + 1) % suggestionChips.length);
|
|
36
|
+
setIsVisible(true);
|
|
37
|
+
}, FADE_DURATION);
|
|
38
|
+
}, rotationInterval);
|
|
39
|
+
return () => clearInterval(interval);
|
|
40
|
+
}, [isPaused, suggestionChips.length, rotationInterval]);
|
|
41
|
+
const handleClick = (0, react_1.useCallback)(() => {
|
|
42
|
+
selectSuggestion(suggestionChips[currentIndex]);
|
|
43
|
+
}, [selectSuggestion, suggestionChips, currentIndex]);
|
|
44
|
+
if (suggestionChips.length === 0)
|
|
45
|
+
return null;
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: className ?? classNames.suggestionChip, "data-component": "suggestion-bar", onMouseEnter: () => setIsPaused(true), onMouseLeave: () => setIsPaused(false), children: (0, jsx_runtime_1.jsx)(SuggestionChipComponent, { label: suggestionChips[currentIndex], onClick: handleClick, isVisible: isVisible }) }));
|
|
47
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SuggestionChipProps } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Single suggestion chip button.
|
|
4
|
+
*
|
|
5
|
+
* Supports `disabled` and `isVisible` for fade animation.
|
|
6
|
+
* The opacity transition is the only inline style — all other
|
|
7
|
+
* styling is driven via data-* attributes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function SuggestionChip({ label, onClick, className, disabled, isVisible, }: SuggestionChipProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SuggestionChip = SuggestionChip;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/**
|
|
6
|
+
* Single suggestion chip button.
|
|
7
|
+
*
|
|
8
|
+
* Supports `disabled` and `isVisible` for fade animation.
|
|
9
|
+
* The opacity transition is the only inline style — all other
|
|
10
|
+
* styling is driven via data-* attributes.
|
|
11
|
+
*/
|
|
12
|
+
function SuggestionChip({ label, onClick, className, disabled, isVisible = true, }) {
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("button", { className: className, onClick: onClick, disabled: disabled, "data-component": "suggestion-chip", "data-visible": isVisible, style: { opacity: isVisible ? 1 : 0, transition: 'opacity 300ms' }, children: label }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface VoiceInputAddonProps {
|
|
2
|
+
disabled: boolean;
|
|
3
|
+
language: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
/** Returns the current auth token for WebSocket authentication */
|
|
6
|
+
getToken?: () => string | null | undefined;
|
|
7
|
+
onTranscript: (text: string) => void;
|
|
8
|
+
onError?: (error: string) => void;
|
|
9
|
+
showRecordingBar?: boolean;
|
|
10
|
+
recordingBarVariant?: 'trigger' | 'inline';
|
|
11
|
+
}
|
|
12
|
+
export declare function VoiceInputAddon({ disabled, language, baseUrl, getToken, onTranscript, onError, showRecordingBar, recordingBarVariant, }: VoiceInputAddonProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoiceInputAddon = VoiceInputAddon;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const use_deepgram_transcription_js_1 = require("../hooks/use-deepgram-transcription.js");
|
|
7
|
+
const recording_bar_js_1 = require("./recording-bar.js");
|
|
8
|
+
function VoiceInputAddon({ disabled, language, baseUrl, getToken, onTranscript, onError, showRecordingBar = true, recordingBarVariant = 'inline', }) {
|
|
9
|
+
const { isRecording, isConnecting, startRecording, stopRecording, } = (0, use_deepgram_transcription_js_1.useDeepgramTranscription)({
|
|
10
|
+
language,
|
|
11
|
+
baseUrl,
|
|
12
|
+
getToken,
|
|
13
|
+
onError,
|
|
14
|
+
});
|
|
15
|
+
const stopAndSubmit = (0, react_1.useCallback)(() => {
|
|
16
|
+
const transcript = stopRecording().trim();
|
|
17
|
+
if (transcript.length > 0) {
|
|
18
|
+
onTranscript(transcript);
|
|
19
|
+
}
|
|
20
|
+
}, [onTranscript, stopRecording]);
|
|
21
|
+
const handleClick = (0, react_1.useCallback)(async () => {
|
|
22
|
+
if (isRecording) {
|
|
23
|
+
stopAndSubmit();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
await startRecording();
|
|
27
|
+
}, [isRecording, startRecording, stopAndSubmit]);
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => {
|
|
29
|
+
void handleClick();
|
|
30
|
+
}, disabled: disabled || isConnecting, "data-component": "voice-input-addon", "data-state": isConnecting ? 'connecting' : isRecording ? 'recording' : 'idle', children: isRecording ? 'stop' : 'mic' }), showRecordingBar && isRecording && ((0, jsx_runtime_1.jsx)(recording_bar_js_1.RecordingBar, { isConnecting: isConnecting, onCancel: stopRecording, onStop: stopAndSubmit, variant: recordingBarVariant }))] }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoiceInputButton = VoiceInputButton;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const use_deepgram_transcription_js_1 = require("../hooks/use-deepgram-transcription.js");
|
|
7
|
+
const PULSE_STYLE_ID = 'glirastes-voice-pulse-style';
|
|
8
|
+
const PULSE_CSS = `@keyframes glirastes-voice-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }`;
|
|
9
|
+
function useInjectPulseStyle() {
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
if (typeof document === 'undefined')
|
|
12
|
+
return;
|
|
13
|
+
if (document.getElementById(PULSE_STYLE_ID))
|
|
14
|
+
return;
|
|
15
|
+
const style = document.createElement('style');
|
|
16
|
+
style.id = PULSE_STYLE_ID;
|
|
17
|
+
style.textContent = PULSE_CSS;
|
|
18
|
+
document.head.appendChild(style);
|
|
19
|
+
}, []);
|
|
20
|
+
}
|
|
21
|
+
function joinClassNames(...values) {
|
|
22
|
+
return values.filter(Boolean).join(' ');
|
|
23
|
+
}
|
|
24
|
+
function StopIcon() {
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", "data-part": "stop", style: {
|
|
26
|
+
display: 'inline-block',
|
|
27
|
+
width: 12,
|
|
28
|
+
height: 12,
|
|
29
|
+
borderRadius: 2,
|
|
30
|
+
background: 'currentColor',
|
|
31
|
+
animation: 'glirastes-voice-pulse 1.5s ease-in-out infinite',
|
|
32
|
+
} }));
|
|
33
|
+
}
|
|
34
|
+
function VoiceInputButton({ onTranscript, disabled = false, className, language = 'de', baseUrl, getToken, onError, }) {
|
|
35
|
+
useInjectPulseStyle();
|
|
36
|
+
const { isRecording, isConnecting, startRecording, stopRecording } = (0, use_deepgram_transcription_js_1.useDeepgramTranscription)({
|
|
37
|
+
language,
|
|
38
|
+
baseUrl,
|
|
39
|
+
getToken,
|
|
40
|
+
onError,
|
|
41
|
+
});
|
|
42
|
+
const handleClick = (0, react_1.useCallback)(async () => {
|
|
43
|
+
if (isRecording) {
|
|
44
|
+
const finalText = stopRecording();
|
|
45
|
+
if (finalText.trim()) {
|
|
46
|
+
onTranscript(finalText);
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await startRecording();
|
|
51
|
+
}, [isRecording, onTranscript, startRecording, stopRecording]);
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => {
|
|
53
|
+
void handleClick();
|
|
54
|
+
}, disabled: disabled || isConnecting, className: joinClassNames('glirastes-voice-input-button', className), "data-component": "voice-input-button", "data-state": isConnecting ? 'connecting' : isRecording ? 'recording' : 'idle', title: isRecording ? 'Aufnahme stoppen' : 'Spracheingabe starten', "aria-label": isRecording ? 'Aufnahme stoppen' : 'Spracheingabe starten', children: isConnecting ? ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", "data-part": "spinner", children: "..." })) : isRecording ? ((0, jsx_runtime_1.jsx)(StopIcon, {})) : ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", "data-part": "icon", children: "mic" })) }));
|
|
55
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Runtime loader for the optional `wavesurfer.js` peer dependency.
|
|
3
|
+
//
|
|
4
|
+
// `wavesurfer.js` is only needed for the live waveform during voice input.
|
|
5
|
+
// A plain dynamic `import('wavesurfer.js')` would be statically analysed by
|
|
6
|
+
// browser-side bundlers (Webpack, Turbopack, Vite, esbuild) — even though
|
|
7
|
+
// the import only executes when the user clicks the mic, the bundler tries
|
|
8
|
+
// to resolve the specifier at *build* time and fails when the peer isn't
|
|
9
|
+
// installed.
|
|
10
|
+
//
|
|
11
|
+
// To make the optional peer truly optional, we hide the specifier behind a
|
|
12
|
+
// runtime-constructed function. Bundlers can't follow a string passed to
|
|
13
|
+
// `Function('s', 'return import(s)')`, so they don't try to resolve it.
|
|
14
|
+
//
|
|
15
|
+
// Trade-offs:
|
|
16
|
+
// - **CSP:** Pages with a strict Content-Security-Policy that disallows
|
|
17
|
+
// `unsafe-eval` will block the `Function` constructor. If you ship under
|
|
18
|
+
// such a CSP, install `wavesurfer.js` unconditionally — the bundler will
|
|
19
|
+
// then resolve the static path and the runtime trick is bypassed for free.
|
|
20
|
+
// - **Tree-shaking:** Bundlers can't tree-shake calls behind this function,
|
|
21
|
+
// but the loader itself is tiny and only the components that opt into
|
|
22
|
+
// voice (`AiTriggerButton`, `RecordingBar`) reach this path.
|
|
23
|
+
//
|
|
24
|
+
// If your deployment forbids `Function`/`eval` AND you don't want
|
|
25
|
+
// `wavesurfer.js` installed, build a Glirastes app without the `<showMic>`
|
|
26
|
+
// option — the voice components are then never mounted and `loadWaveSurfer`
|
|
27
|
+
// is never called.
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.loadWaveSurfer = loadWaveSurfer;
|
|
30
|
+
const runtimeImport = new Function('s', 'return import(s)');
|
|
31
|
+
function loadWaveSurfer() {
|
|
32
|
+
return Promise.all([
|
|
33
|
+
runtimeImport('wavesurfer.js').then((m) => m.default),
|
|
34
|
+
runtimeImport('wavesurfer.js/dist/plugins/record.esm.js').then((m) => m.default),
|
|
35
|
+
]).then(([WaveSurfer, RecordPlugin]) => ({ WaveSurfer, RecordPlugin }));
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { UseAiChatReturn } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for accessing the core chat functionality.
|
|
4
|
+
*
|
|
5
|
+
* Must be used within an `<AiChatProvider>`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* function MyChat() {
|
|
10
|
+
* const { messages, send, isLoading, clear } = useAiChat();
|
|
11
|
+
*
|
|
12
|
+
* return (
|
|
13
|
+
* <div>
|
|
14
|
+
* {messages.map(m => <div key={m.id}>{m.parts[0]?.text}</div>)}
|
|
15
|
+
* <button onClick={() => send('hello')}>Send</button>
|
|
16
|
+
* <button onClick={clear}>Clear</button>
|
|
17
|
+
* </div>
|
|
18
|
+
* );
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function useAiChat(): UseAiChatReturn;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAiChat = useAiChat;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const chat_context_js_1 = require("../provider/chat-context.js");
|
|
6
|
+
/**
|
|
7
|
+
* Hook for accessing the core chat functionality.
|
|
8
|
+
*
|
|
9
|
+
* Must be used within an `<AiChatProvider>`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* function MyChat() {
|
|
14
|
+
* const { messages, send, isLoading, clear } = useAiChat();
|
|
15
|
+
*
|
|
16
|
+
* return (
|
|
17
|
+
* <div>
|
|
18
|
+
* {messages.map(m => <div key={m.id}>{m.parts[0]?.text}</div>)}
|
|
19
|
+
* <button onClick={() => send('hello')}>Send</button>
|
|
20
|
+
* <button onClick={clear}>Clear</button>
|
|
21
|
+
* </div>
|
|
22
|
+
* );
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function useAiChat() {
|
|
27
|
+
const ctx = (0, chat_context_js_1.useChatContext)();
|
|
28
|
+
return (0, react_1.useMemo)(() => ({
|
|
29
|
+
messages: ctx.messages,
|
|
30
|
+
send: ctx.send,
|
|
31
|
+
stop: ctx.stop,
|
|
32
|
+
isLoading: ctx.isLoading,
|
|
33
|
+
error: ctx.error,
|
|
34
|
+
loadMore: ctx.loadMore,
|
|
35
|
+
hasMore: ctx.hasMore,
|
|
36
|
+
clear: ctx.clear,
|
|
37
|
+
pipelineSteps: ctx.pipelineSteps,
|
|
38
|
+
pipelineState: ctx.pipelineState,
|
|
39
|
+
}), [
|
|
40
|
+
ctx.messages,
|
|
41
|
+
ctx.send,
|
|
42
|
+
ctx.stop,
|
|
43
|
+
ctx.isLoading,
|
|
44
|
+
ctx.error,
|
|
45
|
+
ctx.loadMore,
|
|
46
|
+
ctx.hasMore,
|
|
47
|
+
ctx.clear,
|
|
48
|
+
ctx.pipelineSteps,
|
|
49
|
+
ctx.pipelineState,
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UseApprovalsReturn } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for managing tool call approvals.
|
|
4
|
+
*
|
|
5
|
+
* Provides pending approvals, grouped by tool name for bulk operations,
|
|
6
|
+
* and approve/reject actions (single and bulk).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* function ApprovalList() {
|
|
11
|
+
* const { pending, approve, reject, grouped, isProcessing } = useApprovals();
|
|
12
|
+
*
|
|
13
|
+
* return pending.map(a => (
|
|
14
|
+
* <div key={a.id}>
|
|
15
|
+
* <span>{a.toolName}</span>
|
|
16
|
+
* <button onClick={() => approve(a.id)} disabled={isProcessing}>Approve</button>
|
|
17
|
+
* <button onClick={() => reject(a.id)} disabled={isProcessing}>Reject</button>
|
|
18
|
+
* </div>
|
|
19
|
+
* ));
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function useApprovals(): UseApprovalsReturn;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useApprovals = useApprovals;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const chat_context_js_1 = require("../provider/chat-context.js");
|
|
6
|
+
/**
|
|
7
|
+
* Hook for managing tool call approvals.
|
|
8
|
+
*
|
|
9
|
+
* Provides pending approvals, grouped by tool name for bulk operations,
|
|
10
|
+
* and approve/reject actions (single and bulk).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* function ApprovalList() {
|
|
15
|
+
* const { pending, approve, reject, grouped, isProcessing } = useApprovals();
|
|
16
|
+
*
|
|
17
|
+
* return pending.map(a => (
|
|
18
|
+
* <div key={a.id}>
|
|
19
|
+
* <span>{a.toolName}</span>
|
|
20
|
+
* <button onClick={() => approve(a.id)} disabled={isProcessing}>Approve</button>
|
|
21
|
+
* <button onClick={() => reject(a.id)} disabled={isProcessing}>Reject</button>
|
|
22
|
+
* </div>
|
|
23
|
+
* ));
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
function useApprovals() {
|
|
28
|
+
const ctx = (0, chat_context_js_1.useChatContext)();
|
|
29
|
+
const grouped = (0, react_1.useMemo)(() => {
|
|
30
|
+
const map = new Map();
|
|
31
|
+
for (const approval of ctx.pendingApprovals) {
|
|
32
|
+
const existing = map.get(approval.toolName) ?? [];
|
|
33
|
+
existing.push(approval);
|
|
34
|
+
map.set(approval.toolName, existing);
|
|
35
|
+
}
|
|
36
|
+
return map;
|
|
37
|
+
}, [ctx.pendingApprovals]);
|
|
38
|
+
const approveGroup = (0, react_1.useMemo)(() => (toolName) => {
|
|
39
|
+
const group = grouped.get(toolName);
|
|
40
|
+
if (group) {
|
|
41
|
+
for (const approval of group) {
|
|
42
|
+
ctx.approve(approval.id);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, [grouped, ctx.approve]);
|
|
46
|
+
const rejectGroup = (0, react_1.useMemo)(() => (toolName) => {
|
|
47
|
+
const group = grouped.get(toolName);
|
|
48
|
+
if (group) {
|
|
49
|
+
for (const approval of group) {
|
|
50
|
+
ctx.reject(approval.id);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, [grouped, ctx.reject]);
|
|
54
|
+
return (0, react_1.useMemo)(() => ({
|
|
55
|
+
pending: ctx.pendingApprovals,
|
|
56
|
+
approve: ctx.approve,
|
|
57
|
+
reject: ctx.reject,
|
|
58
|
+
grouped,
|
|
59
|
+
approveGroup,
|
|
60
|
+
rejectGroup,
|
|
61
|
+
isProcessing: ctx.isProcessingApproval,
|
|
62
|
+
}), [ctx.pendingApprovals, ctx.approve, ctx.reject, grouped, approveGroup, rejectGroup, ctx.isProcessingApproval]);
|
|
63
|
+
}
|