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,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectLeakage = detectLeakage;
|
|
4
|
+
const MIN_LENGTH = 3;
|
|
5
|
+
function detectLeakage(text, knownOriginals) {
|
|
6
|
+
const leaked = [];
|
|
7
|
+
for (const original of knownOriginals) {
|
|
8
|
+
if (original.length < MIN_LENGTH)
|
|
9
|
+
continue;
|
|
10
|
+
if (text.includes(original)) {
|
|
11
|
+
leaked.push(original);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return leaked;
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PiiCategory } from '../../types.js';
|
|
2
|
+
export interface Session {
|
|
3
|
+
getOrCreatePseudonym(original: string, category: PiiCategory | string): string;
|
|
4
|
+
getPseudonym(original: string): string | undefined;
|
|
5
|
+
resolveOriginal(pseudonym: string): string | undefined;
|
|
6
|
+
allOriginals(): string[];
|
|
7
|
+
}
|
|
8
|
+
export interface SessionStore {
|
|
9
|
+
getOrCreate(sessionId: string): Session;
|
|
10
|
+
clear(sessionId: string): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function createSessionStore(locale: string): SessionStore;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSessionStore = createSessionStore;
|
|
4
|
+
const fake_data_js_1 = require("./fake-data.js");
|
|
5
|
+
function seedFromString(str) {
|
|
6
|
+
let hash = 0;
|
|
7
|
+
for (let i = 0; i < str.length; i++) {
|
|
8
|
+
hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0;
|
|
9
|
+
}
|
|
10
|
+
return hash || 1;
|
|
11
|
+
}
|
|
12
|
+
function createSession(sessionId, locale) {
|
|
13
|
+
const forward = new Map();
|
|
14
|
+
const reverse = new Map();
|
|
15
|
+
const gen = (0, fake_data_js_1.createFakeDataGenerator)(seedFromString(sessionId), locale);
|
|
16
|
+
return {
|
|
17
|
+
getOrCreatePseudonym(original, category) {
|
|
18
|
+
const existing = forward.get(original);
|
|
19
|
+
if (existing)
|
|
20
|
+
return existing;
|
|
21
|
+
let pseudonym = gen.generate(category);
|
|
22
|
+
// Collision detection: if this pseudonym already maps to a different original, regenerate
|
|
23
|
+
const MAX_RETRIES = 10;
|
|
24
|
+
let retries = 0;
|
|
25
|
+
while (reverse.has(pseudonym) && reverse.get(pseudonym) !== original) {
|
|
26
|
+
retries++;
|
|
27
|
+
if (retries > MAX_RETRIES) {
|
|
28
|
+
// Append numeric suffix to guarantee uniqueness
|
|
29
|
+
let suffix = 1;
|
|
30
|
+
let candidate = `${pseudonym}-${suffix}`;
|
|
31
|
+
while (reverse.has(candidate) && reverse.get(candidate) !== original) {
|
|
32
|
+
suffix++;
|
|
33
|
+
candidate = `${pseudonym}-${suffix}`;
|
|
34
|
+
}
|
|
35
|
+
pseudonym = candidate;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
pseudonym = gen.generate(category);
|
|
39
|
+
}
|
|
40
|
+
forward.set(original, pseudonym);
|
|
41
|
+
reverse.set(pseudonym, original);
|
|
42
|
+
return pseudonym;
|
|
43
|
+
},
|
|
44
|
+
getPseudonym(original) {
|
|
45
|
+
return forward.get(original);
|
|
46
|
+
},
|
|
47
|
+
resolveOriginal(pseudonym) {
|
|
48
|
+
return reverse.get(pseudonym);
|
|
49
|
+
},
|
|
50
|
+
allOriginals() {
|
|
51
|
+
return [...forward.keys()];
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function createSessionStore(locale) {
|
|
56
|
+
const sessions = new Map();
|
|
57
|
+
return {
|
|
58
|
+
getOrCreate(sessionId) {
|
|
59
|
+
let session = sessions.get(sessionId);
|
|
60
|
+
if (!session) {
|
|
61
|
+
session = createSession(sessionId, locale);
|
|
62
|
+
sessions.set(sessionId, session);
|
|
63
|
+
}
|
|
64
|
+
return session;
|
|
65
|
+
},
|
|
66
|
+
clear(sessionId) {
|
|
67
|
+
sessions.delete(sessionId);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI pipeline: multi-stage workflow that composes guardrails, intent
|
|
3
|
+
* classification, tool routing, and model selection into a single
|
|
4
|
+
* `process()` call. Requires a Lancer client (Glirastes platform).
|
|
5
|
+
*/
|
|
6
|
+
import { type LocalClassifierConfig } from './core/index.js';
|
|
7
|
+
import type { AiPipelineConfig, AiPipeline } from '../types.js';
|
|
8
|
+
import type { DegradationDefaults, Lancer, OnServiceUnavailable } from './lancer/index.js';
|
|
9
|
+
export interface ProPipelineConfig extends AiPipelineConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Lancer platform client. Required for the pipeline.
|
|
12
|
+
* Guardrail checks delegate to Glirastes Warden.
|
|
13
|
+
*/
|
|
14
|
+
lancer: Lancer;
|
|
15
|
+
degradation?: DegradationDefaults;
|
|
16
|
+
onServiceUnavailable?: OnServiceUnavailable;
|
|
17
|
+
/**
|
|
18
|
+
* Optional generateText callback (from Vercel AI SDK or compatible).
|
|
19
|
+
*/
|
|
20
|
+
generateText?: LocalClassifierConfig['generateText'];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create an AI pipeline that composes guardrails, classification, routing,
|
|
24
|
+
* and model selection into a single `process()` call.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createAiPipeline(config: ProPipelineConfig): AiPipeline;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AI pipeline: multi-stage workflow that composes guardrails, intent
|
|
4
|
+
* classification, tool routing, and model selection into a single
|
|
5
|
+
* `process()` call. Requires a Lancer client (Glirastes platform).
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.createAiPipeline = createAiPipeline;
|
|
9
|
+
const index_js_1 = require("./core/index.js");
|
|
10
|
+
const index_js_2 = require("./lancer/index.js");
|
|
11
|
+
/**
|
|
12
|
+
* Create an AI pipeline that composes guardrails, classification, routing,
|
|
13
|
+
* and model selection into a single `process()` call.
|
|
14
|
+
*/
|
|
15
|
+
function createAiPipeline(config) {
|
|
16
|
+
const { modules, modelSelector: modelSelectorConfig, models: modelsMap, modelInstanceFactory, followups: followupsConfig, relatedModules, confidenceThresholds, onAudit, lancer, generateText, } = config;
|
|
17
|
+
if (!lancer) {
|
|
18
|
+
throw new Error('createAiPipeline requires a Lancer client. ' +
|
|
19
|
+
'Create one with createLancer({ apiKey }) from glirastes/server/lancer.');
|
|
20
|
+
}
|
|
21
|
+
const router = (0, index_js_1.createAiRouter)({
|
|
22
|
+
modules,
|
|
23
|
+
relatedModules,
|
|
24
|
+
confidenceThresholds,
|
|
25
|
+
});
|
|
26
|
+
const modelSelector = modelsMap && modelInstanceFactory
|
|
27
|
+
? (0, index_js_1.createModelSelectorFromMap)(modelsMap, modelInstanceFactory, modules)
|
|
28
|
+
: modelSelectorConfig
|
|
29
|
+
? (0, index_js_1.createModelSelector)(modelSelectorConfig, modules)
|
|
30
|
+
: null;
|
|
31
|
+
const classifierModel = modelsMap && modelInstanceFactory
|
|
32
|
+
? modelInstanceFactory(modelsMap.fast ?? modelsMap.standard ?? 'default')
|
|
33
|
+
: undefined;
|
|
34
|
+
const classifier = (0, index_js_1.createIntentClassifier)({
|
|
35
|
+
modules,
|
|
36
|
+
model: classifierModel,
|
|
37
|
+
generateText,
|
|
38
|
+
locale: config.classifier?.locale,
|
|
39
|
+
});
|
|
40
|
+
const followupsEnabled = followupsConfig?.enabled ?? false;
|
|
41
|
+
const defaultModel = { modelId: 'default' };
|
|
42
|
+
return {
|
|
43
|
+
async process(input, context, _conversationHistory) {
|
|
44
|
+
const auditCtx = { sessionId: '' };
|
|
45
|
+
let sanitizedInput = input;
|
|
46
|
+
let blocked = false;
|
|
47
|
+
try {
|
|
48
|
+
const wardenResult = await lancer.warden.check(input, []);
|
|
49
|
+
if (!wardenResult.passed) {
|
|
50
|
+
blocked = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
if (err instanceof index_js_2.ServiceBlockedError) {
|
|
55
|
+
blocked = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
onAudit?.({
|
|
59
|
+
type: blocked ? 'guardrail.blocked' : 'guardrail.passed',
|
|
60
|
+
timestamp: new Date().toISOString(),
|
|
61
|
+
sessionId: auditCtx.sessionId,
|
|
62
|
+
source: 'server-pro',
|
|
63
|
+
details: {
|
|
64
|
+
inputLength: input.length,
|
|
65
|
+
blocked,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
if (blocked) {
|
|
69
|
+
const ambiguous = { intent: 'ambiguous', confidence: 0 };
|
|
70
|
+
return {
|
|
71
|
+
model: modelSelector?.select(ambiguous, context) ?? defaultModel,
|
|
72
|
+
tools: [],
|
|
73
|
+
sanitizedInput,
|
|
74
|
+
intent: ambiguous,
|
|
75
|
+
module: null,
|
|
76
|
+
followupsEnabled,
|
|
77
|
+
blocked: true,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
let intent = { intent: 'ambiguous', confidence: 0 };
|
|
81
|
+
const classifyStart = Date.now();
|
|
82
|
+
try {
|
|
83
|
+
intent = await classifier.classify(sanitizedInput, context);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// Graceful degradation
|
|
87
|
+
}
|
|
88
|
+
onAudit?.({
|
|
89
|
+
type: 'intent.classified',
|
|
90
|
+
timestamp: new Date().toISOString(),
|
|
91
|
+
sessionId: auditCtx.sessionId,
|
|
92
|
+
source: 'server-pro',
|
|
93
|
+
details: {
|
|
94
|
+
intent: intent.intent,
|
|
95
|
+
confidence: intent.confidence,
|
|
96
|
+
latencyMs: Date.now() - classifyStart,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const allToolNames = modules.flatMap((m) => [...m.tools, ...(m.sharedTools ?? [])]);
|
|
100
|
+
const selected = router.route(intent, allToolNames);
|
|
101
|
+
onAudit?.({
|
|
102
|
+
type: 'routing.resolved',
|
|
103
|
+
timestamp: new Date().toISOString(),
|
|
104
|
+
sessionId: auditCtx.sessionId,
|
|
105
|
+
source: 'server-pro',
|
|
106
|
+
details: {
|
|
107
|
+
module: selected.module?.id ?? null,
|
|
108
|
+
strategy: selected.strategy,
|
|
109
|
+
toolCount: selected.tools.length,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
const tools = [...selected.tools];
|
|
113
|
+
if (followupsEnabled) {
|
|
114
|
+
tools.push('suggest_followups');
|
|
115
|
+
}
|
|
116
|
+
const model = modelSelector?.select(intent, context) ?? defaultModel;
|
|
117
|
+
return {
|
|
118
|
+
model,
|
|
119
|
+
tools: [...new Set(tools)],
|
|
120
|
+
sanitizedInput,
|
|
121
|
+
intent,
|
|
122
|
+
module: selected.module,
|
|
123
|
+
followupsEnabled,
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generates approval flag tests from a tool registry.
|
|
3
|
+
*
|
|
4
|
+
* Convention:
|
|
5
|
+
* - Tools with method POST/PATCH/PUT/DELETE should resolve to needsApproval: true
|
|
6
|
+
* (this is the default in server-node when needsApproval is omitted)
|
|
7
|
+
* - Tools with method GET (or no method, i.e. UI tools) should have needsApproval: false/undefined
|
|
8
|
+
*
|
|
9
|
+
* This test verifies that mutation tools have not been explicitly set to needsApproval: false.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runApprovalTest(toolRegistry: Record<string, unknown>): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runApprovalTest = runApprovalTest;
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
/**
|
|
6
|
+
* Auto-generates approval flag tests from a tool registry.
|
|
7
|
+
*
|
|
8
|
+
* Convention:
|
|
9
|
+
* - Tools with method POST/PATCH/PUT/DELETE should resolve to needsApproval: true
|
|
10
|
+
* (this is the default in server-node when needsApproval is omitted)
|
|
11
|
+
* - Tools with method GET (or no method, i.e. UI tools) should have needsApproval: false/undefined
|
|
12
|
+
*
|
|
13
|
+
* This test verifies that mutation tools have not been explicitly set to needsApproval: false.
|
|
14
|
+
*/
|
|
15
|
+
function runApprovalTest(toolRegistry) {
|
|
16
|
+
const tools = Object.entries(toolRegistry);
|
|
17
|
+
if (tools.length === 0) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const mutationMethods = new Set(['POST', 'PATCH', 'PUT', 'DELETE']);
|
|
21
|
+
(0, vitest_1.describe)('AI Tool Approval Flags', () => {
|
|
22
|
+
const mutationTools = tools.filter(([, def]) => def.method && mutationMethods.has(def.method.toUpperCase()));
|
|
23
|
+
const queryTools = tools.filter(([, def]) => !def.method || def.method.toUpperCase() === 'GET');
|
|
24
|
+
if (mutationTools.length > 0) {
|
|
25
|
+
(0, vitest_1.describe)('mutation tools require approval', () => {
|
|
26
|
+
vitest_1.it.each(mutationTools.map(([name, def]) => [name, def.method]))('%s (%s) has needsApproval: true', (name) => {
|
|
27
|
+
const tool = toolRegistry[name];
|
|
28
|
+
(0, vitest_1.expect)(tool.needsApproval, `${name} is a mutation tool and should require approval`).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (queryTools.length > 0) {
|
|
33
|
+
(0, vitest_1.describe)('query/UI tools do not require approval', () => {
|
|
34
|
+
vitest_1.it.each(queryTools.map(([name]) => [name]))('%s does not require approval', (name) => {
|
|
35
|
+
const tool = toolRegistry[name];
|
|
36
|
+
(0, vitest_1.expect)(tool.needsApproval, `${name} is a query tool and should not require approval`).toBeFalsy();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PipelineComponents } from './helpers.js';
|
|
2
|
+
import type { CombinationTestCase, CombinationTestOptions } from './types.js';
|
|
3
|
+
export declare function runCombinationTest(components: PipelineComponents, cases?: CombinationTestCase[], options?: CombinationTestOptions): void;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCombinationTest = runCombinationTest;
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const helpers_js_1 = require("./helpers.js");
|
|
6
|
+
function runCombinationTest(components, cases, options) {
|
|
7
|
+
const { modules } = components;
|
|
8
|
+
(0, vitest_1.describe)('AI Tool Combinations', () => {
|
|
9
|
+
// ── Auto-generated: shared tool availability ──────────────────────
|
|
10
|
+
const modulesWithSharedTools = modules.filter((mod) => mod.sharedTools && mod.sharedTools.length > 0);
|
|
11
|
+
if (modulesWithSharedTools.length > 0) {
|
|
12
|
+
(0, vitest_1.describe)('shared tool availability', () => {
|
|
13
|
+
for (const mod of modulesWithSharedTools) {
|
|
14
|
+
for (const sharedTool of mod.sharedTools) {
|
|
15
|
+
(0, vitest_1.it)(`${sharedTool} available in ${mod.id} (shared tool)`, () => {
|
|
16
|
+
const result = (0, helpers_js_1.simulatePipeline)(components, `test ${mod.id}`, {
|
|
17
|
+
intent: mod.id,
|
|
18
|
+
confidence: 0.95,
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.expect)(result.tools, `${sharedTool} should be in ${mod.id} tool set`).toContain(sharedTool);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// ── Auto-generated: core tools present at high confidence ────────
|
|
27
|
+
(0, vitest_1.describe)('core tool availability', () => {
|
|
28
|
+
for (const mod of modules) {
|
|
29
|
+
(0, vitest_1.it)(`${mod.id} includes all declared core tools at high confidence`, () => {
|
|
30
|
+
const result = (0, helpers_js_1.simulatePipeline)(components, `test ${mod.id}`, {
|
|
31
|
+
intent: mod.id,
|
|
32
|
+
confidence: 0.95,
|
|
33
|
+
});
|
|
34
|
+
for (const tool of mod.tools) {
|
|
35
|
+
(0, vitest_1.expect)(result.tools, `Core tool "${tool}" should be in ${mod.id}`).toContain(tool);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
// ── User-defined workflow chains ─────────────────────────────────
|
|
41
|
+
if (cases && cases.length > 0) {
|
|
42
|
+
(0, vitest_1.describe)('workflow chains', () => {
|
|
43
|
+
for (const testCase of cases) {
|
|
44
|
+
const confidence = testCase.confidence ?? 0.95;
|
|
45
|
+
(0, vitest_1.it)(`${testCase.name}: all tools available`, () => {
|
|
46
|
+
const result = (0, helpers_js_1.simulatePipeline)(components, testCase.name, {
|
|
47
|
+
intent: testCase.intent,
|
|
48
|
+
confidence,
|
|
49
|
+
});
|
|
50
|
+
(0, vitest_1.expect)(result.blocked).toBe(false);
|
|
51
|
+
for (const tool of testCase.requiredToolChain) {
|
|
52
|
+
(0, vitest_1.expect)(result.tools, `Workflow "${testCase.name}" requires "${tool}" in ${testCase.intent}`).toContain(tool);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
// ── HTTP execution chains (optional) ─────────────────────────
|
|
58
|
+
const executor = options?.toolExecutor;
|
|
59
|
+
const casesWithExecution = cases.filter((c) => c.execution && c.execution.length > 0);
|
|
60
|
+
if (executor && casesWithExecution.length > 0) {
|
|
61
|
+
(0, vitest_1.describe)('HTTP execution chains', () => {
|
|
62
|
+
for (const testCase of casesWithExecution) {
|
|
63
|
+
(0, vitest_1.it)(`${testCase.name}: mock execution succeeds`, () => {
|
|
64
|
+
const results = [];
|
|
65
|
+
for (const step of testCase.execution) {
|
|
66
|
+
const result = executor.execute(step.tool, step.input, step.mockResponse);
|
|
67
|
+
results.push({ tool: step.tool, success: result.success });
|
|
68
|
+
if (result.validationError) {
|
|
69
|
+
vitest_1.expect.fail(`Tool "${step.tool}" input validation failed: ${result.validationError}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (testCase.expect?.allToolsSucceeded) {
|
|
73
|
+
for (const r of results) {
|
|
74
|
+
(0, vitest_1.expect)(r.success, `${r.tool} should succeed`).toBe(true);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TestSuiteConfig, AiTestSuite } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create an AI test suite for testing pipeline behavior without LLM calls.
|
|
4
|
+
*
|
|
5
|
+
* Each method registers `describe`/`it` blocks via Vitest globals.
|
|
6
|
+
* Call the methods at the top level of your test file (outside `describe`).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createAiTestSuite } from './index.js';
|
|
11
|
+
* import { modules } from '@/lib/ai/module-definitions';
|
|
12
|
+
*
|
|
13
|
+
* const suite = createAiTestSuite({
|
|
14
|
+
* modules,
|
|
15
|
+
* pipeline: {
|
|
16
|
+
* guardrails: { enableInjectionDetection: true, maxInputLength: 4000 },
|
|
17
|
+
* confidenceThresholds: { high: 0.85, medium: 0.65 },
|
|
18
|
+
* },
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* suite.smokeTest();
|
|
22
|
+
* suite.guardrailsTest();
|
|
23
|
+
*
|
|
24
|
+
* suite.routingTest([
|
|
25
|
+
* { input: 'show my tasks', expectModule: 'task_query', expectTools: ['list_tasks'] },
|
|
26
|
+
* ]);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function createAiTestSuite(config: TestSuiteConfig): AiTestSuite;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAiTestSuite = createAiTestSuite;
|
|
4
|
+
const helpers_js_1 = require("./helpers.js");
|
|
5
|
+
const smoke_js_1 = require("./smoke.js");
|
|
6
|
+
const routing_js_1 = require("./routing.js");
|
|
7
|
+
const guardrails_js_1 = require("./guardrails.js");
|
|
8
|
+
const approvals_js_1 = require("./approvals.js");
|
|
9
|
+
const combination_js_1 = require("./combination.js");
|
|
10
|
+
const edge_cases_js_1 = require("./edge-cases.js");
|
|
11
|
+
const schema_consistency_js_1 = require("./schema-consistency.js");
|
|
12
|
+
const regression_js_1 = require("./regression.js");
|
|
13
|
+
/**
|
|
14
|
+
* Create an AI test suite for testing pipeline behavior without LLM calls.
|
|
15
|
+
*
|
|
16
|
+
* Each method registers `describe`/`it` blocks via Vitest globals.
|
|
17
|
+
* Call the methods at the top level of your test file (outside `describe`).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { createAiTestSuite } from './index.js';
|
|
22
|
+
* import { modules } from '@/lib/ai/module-definitions';
|
|
23
|
+
*
|
|
24
|
+
* const suite = createAiTestSuite({
|
|
25
|
+
* modules,
|
|
26
|
+
* pipeline: {
|
|
27
|
+
* guardrails: { enableInjectionDetection: true, maxInputLength: 4000 },
|
|
28
|
+
* confidenceThresholds: { high: 0.85, medium: 0.65 },
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* suite.smokeTest();
|
|
33
|
+
* suite.guardrailsTest();
|
|
34
|
+
*
|
|
35
|
+
* suite.routingTest([
|
|
36
|
+
* { input: 'show my tasks', expectModule: 'task_query', expectTools: ['list_tasks'] },
|
|
37
|
+
* ]);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
function createAiTestSuite(config) {
|
|
41
|
+
const { modules, tools: toolRegistry, pipeline, } = config;
|
|
42
|
+
const components = (0, helpers_js_1.buildPipelineComponents)(modules, pipeline?.guardrails, pipeline?.confidenceThresholds);
|
|
43
|
+
return {
|
|
44
|
+
smokeTest() {
|
|
45
|
+
(0, smoke_js_1.runSmokeTest)(modules, toolRegistry);
|
|
46
|
+
},
|
|
47
|
+
routingTest(cases) {
|
|
48
|
+
(0, routing_js_1.runRoutingTest)(components, cases);
|
|
49
|
+
},
|
|
50
|
+
guardrailsTest(options) {
|
|
51
|
+
(0, guardrails_js_1.runGuardrailsTest)(pipeline?.guardrails, options);
|
|
52
|
+
},
|
|
53
|
+
approvalTest() {
|
|
54
|
+
if (!toolRegistry) {
|
|
55
|
+
throw new Error('approvalTest() requires a tool registry. Pass `tools` to createAiTestSuite().');
|
|
56
|
+
}
|
|
57
|
+
(0, approvals_js_1.runApprovalTest)(toolRegistry);
|
|
58
|
+
},
|
|
59
|
+
simulatePipeline(input, intent) {
|
|
60
|
+
return (0, helpers_js_1.simulatePipeline)(components, input, intent);
|
|
61
|
+
},
|
|
62
|
+
combinationTest(cases, options) {
|
|
63
|
+
(0, combination_js_1.runCombinationTest)(components, cases, options);
|
|
64
|
+
},
|
|
65
|
+
edgeCaseTest(options) {
|
|
66
|
+
if (!toolRegistry) {
|
|
67
|
+
throw new Error('edgeCaseTest() requires a tool registry. Pass `tools` to createAiTestSuite().');
|
|
68
|
+
}
|
|
69
|
+
(0, edge_cases_js_1.runEdgeCaseTest)(toolRegistry, options);
|
|
70
|
+
},
|
|
71
|
+
schemaConsistencyTest(options) {
|
|
72
|
+
if (!toolRegistry) {
|
|
73
|
+
throw new Error('schemaConsistencyTest() requires a tool registry. Pass `tools` to createAiTestSuite().');
|
|
74
|
+
}
|
|
75
|
+
(0, schema_consistency_js_1.runSchemaConsistencyTest)(toolRegistry, options);
|
|
76
|
+
},
|
|
77
|
+
regressionTest(cases) {
|
|
78
|
+
(0, regression_js_1.runRegressionTest)(components, toolRegistry ?? {}, cases);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EdgeCaseTestOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Auto-generates edge case tests from tool Zod schemas + custom cases.
|
|
4
|
+
*
|
|
5
|
+
* For each tool with an `inputSchema`, introspects the Zod schema to generate
|
|
6
|
+
* boundary tests for required fields, enums, arrays with limits, etc.
|
|
7
|
+
*/
|
|
8
|
+
export declare function runEdgeCaseTest(toolRegistry: Record<string, unknown>, options?: EdgeCaseTestOptions): void;
|