glirastes 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -0
- package/README.md +146 -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 +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,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names of Glirastes services that can be called by the Lancer client.
|
|
3
|
+
* Used to identify which service failed in degradation callbacks.
|
|
4
|
+
*/
|
|
5
|
+
export type LancerServiceName = 'warden' | 'primus' | 'aegis' | 'proctor' | 'config' | 'approvals';
|
|
6
|
+
/**
|
|
7
|
+
* What to do when a Glirastes service is unavailable:
|
|
8
|
+
* - 'fallback': Return the safe default value (calls onDegraded if set).
|
|
9
|
+
* - 'block': Throw a ServiceBlockedError — use for critical guardrails.
|
|
10
|
+
* - 'silent': Return the safe default value without calling onDegraded.
|
|
11
|
+
*/
|
|
12
|
+
export type DegradationAction = 'fallback' | 'block' | 'silent';
|
|
13
|
+
/** Context passed to the onServiceUnavailable callback. */
|
|
14
|
+
export interface DegradationContext {
|
|
15
|
+
/** Which Glirastes service could not be reached. */
|
|
16
|
+
service: LancerServiceName;
|
|
17
|
+
/** The underlying error from the failed API call. */
|
|
18
|
+
error: Error;
|
|
19
|
+
/** Arbitrary request context (e.g. ToolContext) forwarded by the caller, if available. */
|
|
20
|
+
requestContext?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Static per-service degradation action overrides.
|
|
24
|
+
* Any service not listed falls back to the built-in default
|
|
25
|
+
* ('fallback' for all services except proctor, which defaults to 'silent').
|
|
26
|
+
*/
|
|
27
|
+
export interface DegradationDefaults {
|
|
28
|
+
warden?: DegradationAction;
|
|
29
|
+
primus?: DegradationAction;
|
|
30
|
+
aegis?: DegradationAction;
|
|
31
|
+
proctor?: DegradationAction;
|
|
32
|
+
config?: DegradationAction;
|
|
33
|
+
approvals?: DegradationAction;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Dynamic per-request degradation decision.
|
|
37
|
+
* Called after static defaults are resolved; its return value takes precedence.
|
|
38
|
+
* May be async (e.g. for remote policy lookups).
|
|
39
|
+
*/
|
|
40
|
+
export type OnServiceUnavailable = (ctx: DegradationContext) => DegradationAction | Promise<DegradationAction>;
|
|
41
|
+
/** Configuration for creating a Lancer client instance. */
|
|
42
|
+
export interface LancerConfig {
|
|
43
|
+
apiKey: string;
|
|
44
|
+
baseUrl?: string;
|
|
45
|
+
cache?: {
|
|
46
|
+
ttl: number;
|
|
47
|
+
};
|
|
48
|
+
retry?: {
|
|
49
|
+
maxRetries: number;
|
|
50
|
+
};
|
|
51
|
+
/** Called whenever any service falls back (action='fallback'). */
|
|
52
|
+
onDegraded?: () => void;
|
|
53
|
+
/**
|
|
54
|
+
* Static per-service degradation action overrides.
|
|
55
|
+
* Overrides the built-in defaults ('fallback' / 'silent') per service.
|
|
56
|
+
*/
|
|
57
|
+
degradation?: DegradationDefaults;
|
|
58
|
+
/**
|
|
59
|
+
* Dynamic degradation callback. Invoked on every service failure;
|
|
60
|
+
* its return value overrides both built-in and static defaults.
|
|
61
|
+
*/
|
|
62
|
+
onServiceUnavailable?: OnServiceUnavailable;
|
|
63
|
+
/** Identifies which agent is calling (e.g. "claude-code", "gpt-4o"). Sent as X-Agent-Id header. */
|
|
64
|
+
agentId?: string;
|
|
65
|
+
/** Broad agent category. Sent as X-Agent-Type header. */
|
|
66
|
+
agentType?: 'claude' | 'openai' | 'open-source' | 'custom';
|
|
67
|
+
}
|
|
68
|
+
export interface PromptOverride {
|
|
69
|
+
moduleId: string;
|
|
70
|
+
mode: 'replace' | 'patch';
|
|
71
|
+
systemPrompt: string | null;
|
|
72
|
+
promptPrefix: string | null;
|
|
73
|
+
promptSuffix: string | null;
|
|
74
|
+
modelTierOverride: string | null;
|
|
75
|
+
}
|
|
76
|
+
export interface ConfigResult {
|
|
77
|
+
modules: Record<string, unknown>;
|
|
78
|
+
prompts?: PromptOverride[];
|
|
79
|
+
models?: Record<string, string>;
|
|
80
|
+
etag?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface ClassifyResult {
|
|
83
|
+
moduleId: string;
|
|
84
|
+
confidence: number;
|
|
85
|
+
modelTier: string;
|
|
86
|
+
}
|
|
87
|
+
export interface PiiEntity {
|
|
88
|
+
type: string;
|
|
89
|
+
value: string;
|
|
90
|
+
start: number;
|
|
91
|
+
end: number;
|
|
92
|
+
confidence?: number;
|
|
93
|
+
}
|
|
94
|
+
export interface AnalyzeResult {
|
|
95
|
+
entities: PiiEntity[];
|
|
96
|
+
anonymized: string;
|
|
97
|
+
mappingToken: string | null;
|
|
98
|
+
detector?: 'regex' | 'presidio';
|
|
99
|
+
}
|
|
100
|
+
export interface AnalyzeOptions {
|
|
101
|
+
locales?: string[];
|
|
102
|
+
mode?: 'anonymize' | 'pseudonymize';
|
|
103
|
+
sessionId?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface LeakageResult {
|
|
106
|
+
leaked: boolean;
|
|
107
|
+
entities: PiiEntity[];
|
|
108
|
+
totalDetected: number;
|
|
109
|
+
filteredAsKnown: number;
|
|
110
|
+
}
|
|
111
|
+
export interface Violation {
|
|
112
|
+
rule: string;
|
|
113
|
+
severity: string;
|
|
114
|
+
message: string;
|
|
115
|
+
}
|
|
116
|
+
export interface CheckResult {
|
|
117
|
+
passed: boolean;
|
|
118
|
+
violations: Violation[];
|
|
119
|
+
}
|
|
120
|
+
export interface TelemetryEvent {
|
|
121
|
+
eventType: string;
|
|
122
|
+
traceId?: string;
|
|
123
|
+
toolId?: string;
|
|
124
|
+
tokensIn?: number;
|
|
125
|
+
tokensOut?: number;
|
|
126
|
+
latencyMs?: number;
|
|
127
|
+
modelId?: string;
|
|
128
|
+
modelTier?: string;
|
|
129
|
+
/** ISO-8601 timestamp of when the event occurred on the client. Used for accurate timeline ordering. */
|
|
130
|
+
timestamp?: string;
|
|
131
|
+
payload?: Record<string, unknown>;
|
|
132
|
+
actor?: Record<string, unknown>;
|
|
133
|
+
}
|
|
134
|
+
export interface PrimusNamespace {
|
|
135
|
+
classify(message: string, modules: {
|
|
136
|
+
moduleId: string;
|
|
137
|
+
}[]): Promise<ClassifyResult>;
|
|
138
|
+
}
|
|
139
|
+
export interface WardenNamespace {
|
|
140
|
+
check(input: string, policies: string[]): Promise<CheckResult>;
|
|
141
|
+
}
|
|
142
|
+
export interface AegisNamespace {
|
|
143
|
+
analyze(text: string, options?: AnalyzeOptions): Promise<AnalyzeResult>;
|
|
144
|
+
rehydrate(text: string, mappingToken: string): Promise<string>;
|
|
145
|
+
checkLeakage(text: string, mappingToken: string, locales?: string[]): Promise<LeakageResult>;
|
|
146
|
+
}
|
|
147
|
+
export interface ConfigNamespace {
|
|
148
|
+
fetch(modules: string[]): Promise<ConfigResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Report the app's default model configuration to Glirastes.
|
|
151
|
+
* Fire-and-forget — errors are silently ignored.
|
|
152
|
+
* Called automatically by the SDK adapter on first request.
|
|
153
|
+
*/
|
|
154
|
+
reportModels(models: Record<string, string>): Promise<void>;
|
|
155
|
+
}
|
|
156
|
+
export interface TelemetryNamespace {
|
|
157
|
+
emit(event: TelemetryEvent): void;
|
|
158
|
+
flush(): Promise<void>;
|
|
159
|
+
}
|
|
160
|
+
export interface ApprovalCheckResult {
|
|
161
|
+
required: boolean;
|
|
162
|
+
requestId?: string | null;
|
|
163
|
+
status?: string;
|
|
164
|
+
}
|
|
165
|
+
export interface ApprovalDecideResult {
|
|
166
|
+
ok: boolean;
|
|
167
|
+
}
|
|
168
|
+
export interface ApprovalResolveResult {
|
|
169
|
+
resolved: boolean;
|
|
170
|
+
requestId?: string;
|
|
171
|
+
}
|
|
172
|
+
export interface ApprovalsNamespace {
|
|
173
|
+
check(req: {
|
|
174
|
+
toolId: string;
|
|
175
|
+
inputHash: string;
|
|
176
|
+
/** Optional trace/session ID forwarded to Glirastes for approval audit correlation. */
|
|
177
|
+
traceId?: string;
|
|
178
|
+
}): Promise<ApprovalCheckResult>;
|
|
179
|
+
decide(requestId: string, decision: {
|
|
180
|
+
decision: 'approved' | 'denied';
|
|
181
|
+
decidedBy: string;
|
|
182
|
+
}): Promise<ApprovalDecideResult>;
|
|
183
|
+
/** Resolve a pending approval by toolId + inputHash (no requestId needed). */
|
|
184
|
+
resolve(req: {
|
|
185
|
+
toolId: string;
|
|
186
|
+
inputHash: string;
|
|
187
|
+
decision: 'approved' | 'denied';
|
|
188
|
+
decidedBy: string;
|
|
189
|
+
}): Promise<ApprovalResolveResult>;
|
|
190
|
+
hashInput(args: Record<string, unknown>): string;
|
|
191
|
+
}
|
|
192
|
+
export interface Lancer {
|
|
193
|
+
primus: PrimusNamespace;
|
|
194
|
+
warden: WardenNamespace;
|
|
195
|
+
aegis: AegisNamespace;
|
|
196
|
+
config: ConfigNamespace;
|
|
197
|
+
telemetry: TelemetryNamespace;
|
|
198
|
+
/** Approval flows managed by Glirastes. Optional — only present when the Glirastes API supports approvals. */
|
|
199
|
+
approvals?: ApprovalsNamespace;
|
|
200
|
+
destroy(): void;
|
|
201
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PiiDetector } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Shape of an Aegis-compatible analyze method (duck-typed, no Lancer dep).
|
|
4
|
+
* Matches `lancer.aegis.analyze()`.
|
|
5
|
+
*/
|
|
6
|
+
export interface AegisLike {
|
|
7
|
+
analyze(text: string, locales: string[]): Promise<{
|
|
8
|
+
entities: Array<{
|
|
9
|
+
type: string;
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
value: string;
|
|
13
|
+
confidence?: number;
|
|
14
|
+
}>;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a PiiDetector that delegates to a Lancer Aegis namespace.
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { createAegisDetector } from './index.js';
|
|
23
|
+
* const detector = createAegisDetector(lancer.aegis);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function createAegisDetector(aegis: AegisLike): PiiDetector;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAegisDetector = createAegisDetector;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a PiiDetector that delegates to a Lancer Aegis namespace.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAegisDetector } from './index.js';
|
|
10
|
+
* const detector = createAegisDetector(lancer.aegis);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
function createAegisDetector(aegis) {
|
|
14
|
+
return {
|
|
15
|
+
async detect(text, locales) {
|
|
16
|
+
const result = await aegis.analyze(text, locales ?? ['de', 'en']);
|
|
17
|
+
return result.entities.map((e) => ({
|
|
18
|
+
type: e.type,
|
|
19
|
+
start: e.start,
|
|
20
|
+
end: e.end,
|
|
21
|
+
score: e.confidence ?? 1.0,
|
|
22
|
+
text: e.value,
|
|
23
|
+
}));
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPiiShield = createPiiShield;
|
|
4
|
+
const session_mapping_js_1 = require("./session-mapping.js");
|
|
5
|
+
const deep_walk_js_1 = require("./deep-walk.js");
|
|
6
|
+
const leakage_js_1 = require("./leakage.js");
|
|
7
|
+
function createPiiShield(config) {
|
|
8
|
+
const store = (0, session_mapping_js_1.createSessionStore)(config.locale);
|
|
9
|
+
const auditLog = new Map();
|
|
10
|
+
const sessionStats = new Map();
|
|
11
|
+
function getStats(sessionId) {
|
|
12
|
+
let stats = sessionStats.get(sessionId);
|
|
13
|
+
if (!stats) {
|
|
14
|
+
stats = { startedAt: Date.now(), totalMessages: 0, totalToolCalls: 0, leakageDetected: 0 };
|
|
15
|
+
sessionStats.set(sessionId, stats);
|
|
16
|
+
}
|
|
17
|
+
return stats;
|
|
18
|
+
}
|
|
19
|
+
function addAuditEntry(entry) {
|
|
20
|
+
let entries = auditLog.get(entry.sessionId);
|
|
21
|
+
if (!entries) {
|
|
22
|
+
entries = [];
|
|
23
|
+
auditLog.set(entry.sessionId, entries);
|
|
24
|
+
}
|
|
25
|
+
entries.push(entry);
|
|
26
|
+
config.onAudit?.(entry);
|
|
27
|
+
}
|
|
28
|
+
function buildAuditEntry(sessionId, direction, entities, opts) {
|
|
29
|
+
return {
|
|
30
|
+
sessionId,
|
|
31
|
+
timestamp: new Date().toISOString(),
|
|
32
|
+
direction,
|
|
33
|
+
leakage: opts?.leakage,
|
|
34
|
+
detections: entities.map((e) => ({
|
|
35
|
+
type: e.type,
|
|
36
|
+
detector: 'pii-shield',
|
|
37
|
+
confidence: e.score,
|
|
38
|
+
position: { start: e.start, end: e.end },
|
|
39
|
+
length: e.text.length,
|
|
40
|
+
})),
|
|
41
|
+
totalDetected: entities.length,
|
|
42
|
+
totalAnonymized: entities.length,
|
|
43
|
+
mode: 'pseudonymize',
|
|
44
|
+
locale: config.locale,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async function outbound(text, sessionId) {
|
|
48
|
+
const session = store.getOrCreate(sessionId);
|
|
49
|
+
const stats = getStats(sessionId);
|
|
50
|
+
stats.totalMessages++;
|
|
51
|
+
const detected = await config.detector.detect(text, [config.locale]);
|
|
52
|
+
if (detected.length === 0) {
|
|
53
|
+
addAuditEntry(buildAuditEntry(sessionId, 'outbound', []));
|
|
54
|
+
return text;
|
|
55
|
+
}
|
|
56
|
+
// Sort by start descending so replacements don't shift indices
|
|
57
|
+
const sorted = [...detected].sort((a, b) => b.start - a.start);
|
|
58
|
+
let result = text;
|
|
59
|
+
for (const entity of sorted) {
|
|
60
|
+
const pseudonym = session.getOrCreatePseudonym(entity.text, entity.type);
|
|
61
|
+
result = result.slice(0, entity.start) + pseudonym + result.slice(entity.end);
|
|
62
|
+
}
|
|
63
|
+
addAuditEntry(buildAuditEntry(sessionId, 'outbound', detected));
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
function inbound(text, sessionId) {
|
|
67
|
+
const session = store.getOrCreate(sessionId);
|
|
68
|
+
// Check for leakage BEFORE de-pseudonymization
|
|
69
|
+
if (config.leakageDetection) {
|
|
70
|
+
const originals = session.allOriginals();
|
|
71
|
+
const leaked = (0, leakage_js_1.detectLeakage)(text, originals);
|
|
72
|
+
if (leaked.length > 0) {
|
|
73
|
+
const stats = getStats(sessionId);
|
|
74
|
+
stats.leakageDetected += leaked.length;
|
|
75
|
+
const leakEntities = leaked.map((l) => ({
|
|
76
|
+
type: 'custom',
|
|
77
|
+
start: text.indexOf(l),
|
|
78
|
+
end: text.indexOf(l) + l.length,
|
|
79
|
+
score: 1.0,
|
|
80
|
+
text: l,
|
|
81
|
+
}));
|
|
82
|
+
addAuditEntry(buildAuditEntry(sessionId, 'inbound', leakEntities, { leakage: true }));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Replace pseudonyms with originals
|
|
86
|
+
const originals = session.allOriginals();
|
|
87
|
+
let result = text;
|
|
88
|
+
for (const original of originals) {
|
|
89
|
+
const pseudonym = session.getPseudonym(original);
|
|
90
|
+
if (!pseudonym)
|
|
91
|
+
continue;
|
|
92
|
+
result = result.split(pseudonym).join(original);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
function rehydrateArgs(args, sessionId) {
|
|
97
|
+
const session = store.getOrCreate(sessionId);
|
|
98
|
+
const result = (0, deep_walk_js_1.deepWalkReplace)(args, (s) => {
|
|
99
|
+
// Check if the entire string is a known pseudonym
|
|
100
|
+
const original = session.resolveOriginal(s);
|
|
101
|
+
if (original)
|
|
102
|
+
return original;
|
|
103
|
+
// Check if any known pseudonyms appear as substrings
|
|
104
|
+
const originals = session.allOriginals();
|
|
105
|
+
let replaced = s;
|
|
106
|
+
for (const orig of originals) {
|
|
107
|
+
const pseudonym = session.getPseudonym(orig);
|
|
108
|
+
if (!pseudonym)
|
|
109
|
+
continue;
|
|
110
|
+
replaced = replaced.split(pseudonym).join(orig);
|
|
111
|
+
}
|
|
112
|
+
return replaced;
|
|
113
|
+
});
|
|
114
|
+
addAuditEntry(buildAuditEntry(sessionId, 'rehydrate-args', []));
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
async function anonymizeResult(result, sessionId) {
|
|
118
|
+
const session = store.getOrCreate(sessionId);
|
|
119
|
+
const stats = getStats(sessionId);
|
|
120
|
+
stats.totalToolCalls++;
|
|
121
|
+
// Detect PII in stringified result
|
|
122
|
+
const text = typeof result === 'string' ? result : JSON.stringify(result);
|
|
123
|
+
const detected = await config.detector.detect(text, [config.locale]);
|
|
124
|
+
// Ensure pseudonyms exist for all detected entities
|
|
125
|
+
for (const entity of detected) {
|
|
126
|
+
session.getOrCreatePseudonym(entity.text, entity.type);
|
|
127
|
+
}
|
|
128
|
+
// Deep-walk and replace originals with pseudonyms
|
|
129
|
+
const originals = session.allOriginals();
|
|
130
|
+
const anonymized = (0, deep_walk_js_1.deepWalkReplace)(result, (s) => {
|
|
131
|
+
let replaced = s;
|
|
132
|
+
for (const original of originals) {
|
|
133
|
+
const pseudonym = session.getPseudonym(original);
|
|
134
|
+
if (!pseudonym)
|
|
135
|
+
continue;
|
|
136
|
+
replaced = replaced.split(original).join(pseudonym);
|
|
137
|
+
}
|
|
138
|
+
return replaced;
|
|
139
|
+
});
|
|
140
|
+
addAuditEntry(buildAuditEntry(sessionId, 'anonymize-result', detected));
|
|
141
|
+
return anonymized;
|
|
142
|
+
}
|
|
143
|
+
function getComplianceSummary(sessionId) {
|
|
144
|
+
const stats = getStats(sessionId);
|
|
145
|
+
const entries = auditLog.get(sessionId) ?? [];
|
|
146
|
+
const byType = {};
|
|
147
|
+
const byDetector = {};
|
|
148
|
+
const byDirection = {};
|
|
149
|
+
let totalDetected = 0;
|
|
150
|
+
for (const entry of entries) {
|
|
151
|
+
totalDetected += entry.totalDetected;
|
|
152
|
+
byDirection[entry.direction] = (byDirection[entry.direction] ?? 0) + entry.totalDetected;
|
|
153
|
+
for (const det of entry.detections) {
|
|
154
|
+
byType[det.type] = (byType[det.type] ?? 0) + 1;
|
|
155
|
+
byDetector[det.detector] = (byDetector[det.detector] ?? 0) + 1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const durationMs = Date.now() - stats.startedAt;
|
|
159
|
+
const durationSec = Math.floor(durationMs / 1000);
|
|
160
|
+
const minutes = Math.floor(durationSec / 60);
|
|
161
|
+
const seconds = durationSec % 60;
|
|
162
|
+
return {
|
|
163
|
+
sessionId,
|
|
164
|
+
duration: `${minutes}m ${seconds}s`,
|
|
165
|
+
totalMessages: stats.totalMessages,
|
|
166
|
+
totalToolCalls: stats.totalToolCalls,
|
|
167
|
+
piiStats: {
|
|
168
|
+
totalDetected,
|
|
169
|
+
byType,
|
|
170
|
+
byDetector,
|
|
171
|
+
byDirection,
|
|
172
|
+
},
|
|
173
|
+
mode: 'pseudonymize',
|
|
174
|
+
leakageDetected: stats.leakageDetected,
|
|
175
|
+
verdict: stats.leakageDetected > 0 ? 'LEAKAGE_DETECTED' : 'COMPLIANT',
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function clearSession(sessionId) {
|
|
179
|
+
store.clear(sessionId);
|
|
180
|
+
auditLog.delete(sessionId);
|
|
181
|
+
sessionStats.delete(sessionId);
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
outbound,
|
|
185
|
+
inbound,
|
|
186
|
+
rehydrateArgs,
|
|
187
|
+
anonymizeResult,
|
|
188
|
+
getComplianceSummary,
|
|
189
|
+
clearSession,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepWalkReplace(value: unknown, replacer: (s: string) => string): unknown;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepWalkReplace = deepWalkReplace;
|
|
4
|
+
function deepWalkReplace(value, replacer) {
|
|
5
|
+
if (typeof value === 'string') {
|
|
6
|
+
return replacer(value);
|
|
7
|
+
}
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
return value.map((item) => deepWalkReplace(item, replacer));
|
|
10
|
+
}
|
|
11
|
+
if (value !== null && typeof value === 'object') {
|
|
12
|
+
const result = {};
|
|
13
|
+
for (const [key, val] of Object.entries(value)) {
|
|
14
|
+
result[key] = deepWalkReplace(val, replacer);
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFakeDataGenerator = createFakeDataGenerator;
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// xorshift32 PRNG — deterministic, seedable
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
function createPrng(seed) {
|
|
8
|
+
let state = seed | 0 || 1; // must not be 0
|
|
9
|
+
return {
|
|
10
|
+
next() {
|
|
11
|
+
state ^= state << 13;
|
|
12
|
+
state ^= state >> 17;
|
|
13
|
+
state ^= state << 5;
|
|
14
|
+
return (state >>> 0) / 0xffffffff; // [0, 1)
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Name pools
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
const DE_FIRST = ['Lukas', 'Anna', 'Felix', 'Marie', 'Jonas', 'Lena', 'Maximilian', 'Sophie', 'Tobias', 'Katharina'];
|
|
22
|
+
const DE_LAST = ['Müller', 'Schmidt', 'Schneider', 'Fischer', 'Weber', 'Meyer', 'Wagner', 'Becker', 'Hoffmann', 'Schulz'];
|
|
23
|
+
const EN_FIRST = ['James', 'Emily', 'Robert', 'Sarah', 'William', 'Jessica', 'Michael', 'Ashley', 'David', 'Jennifer'];
|
|
24
|
+
const EN_LAST = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Garcia', 'Miller', 'Davis', 'Wilson', 'Taylor'];
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Address pools
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
const DE_STREETS = ['Berliner Str.', 'Hauptstr.', 'Bahnhofstr.', 'Gartenstr.', 'Schillerstr.', 'Goethestr.', 'Mozartstr.', 'Lindenstr.', 'Rosenweg', 'Waldstr.'];
|
|
29
|
+
const DE_CITIES = ['Berlin', 'München', 'Hamburg', 'Köln', 'Frankfurt', 'Stuttgart', 'Düsseldorf', 'Leipzig', 'Dresden', 'Hannover'];
|
|
30
|
+
const EN_STREETS = ['Main St', 'Oak Ave', 'Maple Dr', 'Cedar Ln', 'Elm St', 'Pine Rd', 'Birch Way', 'Park Blvd', 'Lake Dr', 'Hill Rd'];
|
|
31
|
+
const EN_CITIES = ['New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'Philadelphia', 'San Antonio', 'San Diego', 'Dallas', 'Austin'];
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// Email domains
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
const EMAIL_DOMAINS = ['example.com', 'mail.test', 'demo.org', 'sample.net', 'test.de'];
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Helpers
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
function transliterateDE(s) {
|
|
40
|
+
return s
|
|
41
|
+
.toLowerCase()
|
|
42
|
+
.replace(/[äöüß]/g, (c) => {
|
|
43
|
+
const map = { ä: 'ae', ö: 'oe', ü: 'ue', ß: 'ss' };
|
|
44
|
+
return map[c] ?? c;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function createFakeDataGenerator(seed, locale) {
|
|
48
|
+
const prng = createPrng(seed);
|
|
49
|
+
const pick = (arr) => arr[Math.floor(prng.next() * arr.length)];
|
|
50
|
+
const randInt = (min, max) => min + Math.floor(prng.next() * (max - min + 1));
|
|
51
|
+
const pad = (n, w = 2) => String(n).padStart(w, '0');
|
|
52
|
+
const isDE = locale.startsWith('de');
|
|
53
|
+
const firstPool = isDE ? DE_FIRST : EN_FIRST;
|
|
54
|
+
const lastPool = isDE ? DE_LAST : EN_LAST;
|
|
55
|
+
// Track last generated person for coherent email
|
|
56
|
+
let lastFirst = '';
|
|
57
|
+
let lastLast = '';
|
|
58
|
+
const generators = {
|
|
59
|
+
person() {
|
|
60
|
+
lastFirst = pick(firstPool);
|
|
61
|
+
lastLast = pick(lastPool);
|
|
62
|
+
return `${lastFirst} ${lastLast}`;
|
|
63
|
+
},
|
|
64
|
+
email() {
|
|
65
|
+
const first = lastFirst || pick(firstPool);
|
|
66
|
+
const last = lastLast || pick(lastPool);
|
|
67
|
+
const domain = pick(EMAIL_DOMAINS);
|
|
68
|
+
const f = transliterateDE(first);
|
|
69
|
+
const l = transliterateDE(last);
|
|
70
|
+
return `${f}.${l}@${domain}`;
|
|
71
|
+
},
|
|
72
|
+
phone() {
|
|
73
|
+
if (isDE) {
|
|
74
|
+
const area = randInt(30, 89);
|
|
75
|
+
const num = randInt(1000000, 9999999);
|
|
76
|
+
return `+49 ${area} ${num}`;
|
|
77
|
+
}
|
|
78
|
+
const area = randInt(200, 999);
|
|
79
|
+
const prefix = randInt(200, 999);
|
|
80
|
+
const line = randInt(1000, 9999);
|
|
81
|
+
return `+1 (${area}) ${prefix}-${line}`;
|
|
82
|
+
},
|
|
83
|
+
iban() {
|
|
84
|
+
if (isDE) {
|
|
85
|
+
const check = pad(randInt(10, 99));
|
|
86
|
+
const bankCode = pad(randInt(1000, 9999), 4);
|
|
87
|
+
const bankCode2 = pad(randInt(1000, 9999), 4);
|
|
88
|
+
const acct1 = pad(randInt(1000, 9999), 4);
|
|
89
|
+
const acct2 = pad(randInt(1000, 9999), 4);
|
|
90
|
+
const acct3 = pad(randInt(10, 99));
|
|
91
|
+
return `DE${check} ${bankCode} ${bankCode2} ${acct1} ${acct2} ${acct3}`;
|
|
92
|
+
}
|
|
93
|
+
// GB fallback
|
|
94
|
+
const check = pad(randInt(10, 99));
|
|
95
|
+
const sort = pad(randInt(100000, 999999), 6);
|
|
96
|
+
const acct = pad(randInt(10000000, 99999999), 8);
|
|
97
|
+
return `GB${check} ${sort} ${acct}`;
|
|
98
|
+
},
|
|
99
|
+
credit_card() {
|
|
100
|
+
const last4 = pad(randInt(1000, 9999), 4);
|
|
101
|
+
return `XXXX-XXXX-XXXX-${last4}`;
|
|
102
|
+
},
|
|
103
|
+
ip_address() {
|
|
104
|
+
return `10.${randInt(0, 255)}.${randInt(0, 255)}.${randInt(1, 254)}`;
|
|
105
|
+
},
|
|
106
|
+
date_of_birth() {
|
|
107
|
+
const year = randInt(1950, 2005);
|
|
108
|
+
const month = randInt(1, 12);
|
|
109
|
+
const day = randInt(1, 28);
|
|
110
|
+
if (isDE) {
|
|
111
|
+
return `${pad(day)}.${pad(month)}.${year}`;
|
|
112
|
+
}
|
|
113
|
+
return `${pad(month)}/${pad(day)}/${year}`;
|
|
114
|
+
},
|
|
115
|
+
address() {
|
|
116
|
+
const streets = isDE ? DE_STREETS : EN_STREETS;
|
|
117
|
+
const cities = isDE ? DE_CITIES : EN_CITIES;
|
|
118
|
+
const street = pick(streets);
|
|
119
|
+
const num = randInt(1, 200);
|
|
120
|
+
const city = pick(cities);
|
|
121
|
+
if (isDE) {
|
|
122
|
+
const zip = pad(randInt(10000, 99999), 5);
|
|
123
|
+
return `${street} ${num}, ${zip} ${city}`;
|
|
124
|
+
}
|
|
125
|
+
const zip = pad(randInt(10000, 99999), 5);
|
|
126
|
+
const state = pick(['CA', 'TX', 'NY', 'FL', 'IL', 'PA', 'OH', 'GA', 'NC', 'MI']);
|
|
127
|
+
return `${num} ${street}, ${city}, ${state} ${zip}`;
|
|
128
|
+
},
|
|
129
|
+
tax_id() {
|
|
130
|
+
if (isDE) {
|
|
131
|
+
// German Steuer-ID format: 11 digits
|
|
132
|
+
const digits = Array.from({ length: 11 }, () => randInt(0, 9)).join('');
|
|
133
|
+
return digits;
|
|
134
|
+
}
|
|
135
|
+
// US EIN format: XX-XXXXXXX
|
|
136
|
+
return `${pad(randInt(10, 99))}-${pad(randInt(1000000, 9999999), 7)}`;
|
|
137
|
+
},
|
|
138
|
+
ssn() {
|
|
139
|
+
if (isDE) {
|
|
140
|
+
// German Sozialversicherungsnummer: 12 chars
|
|
141
|
+
const digits = Array.from({ length: 12 }, () => randInt(0, 9)).join('');
|
|
142
|
+
return digits;
|
|
143
|
+
}
|
|
144
|
+
// US SSN format: XXX-XX-XXXX
|
|
145
|
+
return `${pad(randInt(100, 999), 3)}-${pad(randInt(10, 99))}-${pad(randInt(1000, 9999), 4)}`;
|
|
146
|
+
},
|
|
147
|
+
url() {
|
|
148
|
+
const tld = isDE ? '.de' : '.com';
|
|
149
|
+
const words = ['example', 'demo', 'test', 'sample', 'mock', 'fake', 'placeholder'];
|
|
150
|
+
return `https://${pick(words)}${tld}/${randInt(1000, 9999)}`;
|
|
151
|
+
},
|
|
152
|
+
cvv() {
|
|
153
|
+
return pad(randInt(100, 999), 3);
|
|
154
|
+
},
|
|
155
|
+
card_expiry() {
|
|
156
|
+
const month = pad(randInt(1, 12));
|
|
157
|
+
const year = randInt(26, 32);
|
|
158
|
+
return `${month}/${year}`;
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
generate(category) {
|
|
163
|
+
const gen = generators[category];
|
|
164
|
+
if (gen)
|
|
165
|
+
return gen();
|
|
166
|
+
// Unknown / custom category: fallback
|
|
167
|
+
return `[REDACTED_${pad(randInt(1000, 9999), 4)}]`;
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createPiiShield } from './create-pii-shield.js';
|
|
2
|
+
export { createAegisDetector } from './aegis-detector.js';
|
|
3
|
+
export type { AegisLike } from './aegis-detector.js';
|
|
4
|
+
export type { PiiCategory, PiiEntity, PiiDetector, PiiShield, PiiShieldConfig, PiiAuditEntry, ComplianceSummary, MappingEntry, } from '../../types.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAegisDetector = exports.createPiiShield = void 0;
|
|
4
|
+
// Factory
|
|
5
|
+
var create_pii_shield_js_1 = require("./create-pii-shield.js");
|
|
6
|
+
Object.defineProperty(exports, "createPiiShield", { enumerable: true, get: function () { return create_pii_shield_js_1.createPiiShield; } });
|
|
7
|
+
// Aegis (Pro) detector adapter
|
|
8
|
+
var aegis_detector_js_1 = require("./aegis-detector.js");
|
|
9
|
+
Object.defineProperty(exports, "createAegisDetector", { enumerable: true, get: function () { return aegis_detector_js_1.createAegisDetector; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function detectLeakage(text: string, knownOriginals: string[]): string[];
|