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.
Files changed (310) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +154 -9
  3. package/codegen/package.json +5 -0
  4. package/dist/cjs/codegen/asset-sync.d.ts +20 -0
  5. package/dist/cjs/codegen/asset-sync.js +28 -0
  6. package/dist/cjs/codegen/coverage.d.ts +66 -0
  7. package/dist/cjs/codegen/coverage.js +408 -0
  8. package/dist/cjs/codegen/endpoint-scanner.d.ts +16 -0
  9. package/dist/cjs/codegen/endpoint-scanner.js +197 -0
  10. package/dist/cjs/codegen/format.d.ts +17 -0
  11. package/dist/cjs/codegen/format.js +34 -0
  12. package/dist/cjs/codegen/fs-utils.d.ts +45 -0
  13. package/dist/cjs/codegen/fs-utils.js +165 -0
  14. package/dist/cjs/codegen/index.d.ts +13 -0
  15. package/dist/cjs/codegen/index.js +33 -0
  16. package/dist/cjs/codegen/mcp-generator.d.ts +50 -0
  17. package/dist/cjs/codegen/mcp-generator.js +803 -0
  18. package/dist/cjs/codegen/module-generator.d.ts +11 -0
  19. package/dist/cjs/codegen/module-generator.js +353 -0
  20. package/dist/cjs/codegen/nestjs-scanner.d.ts +43 -0
  21. package/dist/cjs/codegen/nestjs-scanner.js +241 -0
  22. package/dist/cjs/codegen/output-recommender.d.ts +23 -0
  23. package/dist/cjs/codegen/output-recommender.js +33 -0
  24. package/dist/cjs/codegen/scaffolder.d.ts +36 -0
  25. package/dist/cjs/codegen/scaffolder.js +262 -0
  26. package/dist/cjs/codegen/skill-generator.d.ts +49 -0
  27. package/dist/cjs/codegen/skill-generator.js +967 -0
  28. package/dist/cjs/codegen/types.d.ts +52 -0
  29. package/dist/cjs/codegen/types.js +16 -0
  30. package/dist/cjs/codegen/ui-scanner.d.ts +24 -0
  31. package/dist/cjs/codegen/ui-scanner.js +202 -0
  32. package/dist/cjs/codegen/validator.d.ts +35 -0
  33. package/dist/cjs/codegen/validator.js +292 -0
  34. package/dist/cjs/index.d.ts +1 -0
  35. package/dist/cjs/index.js +23 -0
  36. package/dist/cjs/openapi/index.d.ts +78 -0
  37. package/dist/cjs/openapi/index.js +347 -0
  38. package/dist/cjs/package.json +1 -0
  39. package/dist/cjs/react/audio-worklet-processor.d.ts +16 -0
  40. package/dist/cjs/react/audio-worklet-processor.js +27 -0
  41. package/dist/cjs/react/bridges/rest-session-bridge.d.ts +113 -0
  42. package/dist/cjs/react/bridges/rest-session-bridge.js +209 -0
  43. package/dist/cjs/react/components/ai-chat-panel.d.ts +12 -0
  44. package/dist/cjs/react/components/ai-chat-panel.js +67 -0
  45. package/dist/cjs/react/components/ai-trigger-button.d.ts +2 -0
  46. package/dist/cjs/react/components/ai-trigger-button.js +239 -0
  47. package/dist/cjs/react/components/approval-card.d.ts +9 -0
  48. package/dist/cjs/react/components/approval-card.js +24 -0
  49. package/dist/cjs/react/components/bulk-approval-card.d.ts +9 -0
  50. package/dist/cjs/react/components/bulk-approval-card.js +36 -0
  51. package/dist/cjs/react/components/chat-input.d.ts +10 -0
  52. package/dist/cjs/react/components/chat-input.js +60 -0
  53. package/dist/cjs/react/components/chat-window.d.ts +2 -0
  54. package/dist/cjs/react/components/chat-window.js +134 -0
  55. package/dist/cjs/react/components/confirm-dialog.d.ts +32 -0
  56. package/dist/cjs/react/components/confirm-dialog.js +48 -0
  57. package/dist/cjs/react/components/floating-chat-ui.d.ts +90 -0
  58. package/dist/cjs/react/components/floating-chat-ui.js +163 -0
  59. package/dist/cjs/react/components/mention-chip.d.ts +16 -0
  60. package/dist/cjs/react/components/mention-chip.js +42 -0
  61. package/dist/cjs/react/components/mention-input.d.ts +8 -0
  62. package/dist/cjs/react/components/mention-input.js +117 -0
  63. package/dist/cjs/react/components/message-bubble.d.ts +11 -0
  64. package/dist/cjs/react/components/message-bubble.js +171 -0
  65. package/dist/cjs/react/components/message-list.d.ts +8 -0
  66. package/dist/cjs/react/components/message-list.js +52 -0
  67. package/dist/cjs/react/components/pipeline-timeline.d.ts +7 -0
  68. package/dist/cjs/react/components/pipeline-timeline.js +72 -0
  69. package/dist/cjs/react/components/recording-bar.d.ts +2 -0
  70. package/dist/cjs/react/components/recording-bar.js +81 -0
  71. package/dist/cjs/react/components/recording-controls.d.ts +18 -0
  72. package/dist/cjs/react/components/recording-controls.js +38 -0
  73. package/dist/cjs/react/components/rich-mention-input.d.ts +2 -0
  74. package/dist/cjs/react/components/rich-mention-input.js +571 -0
  75. package/dist/cjs/react/components/session-switcher.d.ts +14 -0
  76. package/dist/cjs/react/components/session-switcher.js +133 -0
  77. package/dist/cjs/react/components/suggestion-bar.d.ts +9 -0
  78. package/dist/cjs/react/components/suggestion-bar.js +47 -0
  79. package/dist/cjs/react/components/suggestion-chip.d.ts +9 -0
  80. package/dist/cjs/react/components/suggestion-chip.js +14 -0
  81. package/dist/cjs/react/components/voice-input-addon.d.ts +13 -0
  82. package/dist/cjs/react/components/voice-input-addon.js +31 -0
  83. package/dist/cjs/react/components/voice-input-button.d.ts +2 -0
  84. package/dist/cjs/react/components/voice-input-button.js +55 -0
  85. package/dist/cjs/react/components/wavesurfer-loader.d.ts +5 -0
  86. package/dist/cjs/react/components/wavesurfer-loader.js +36 -0
  87. package/dist/cjs/react/hooks/use-ai-chat.d.ts +22 -0
  88. package/dist/cjs/react/hooks/use-ai-chat.js +51 -0
  89. package/dist/cjs/react/hooks/use-approvals.d.ts +23 -0
  90. package/dist/cjs/react/hooks/use-approvals.js +63 -0
  91. package/dist/cjs/react/hooks/use-deepgram-transcription.d.ts +2 -0
  92. package/dist/cjs/react/hooks/use-deepgram-transcription.js +329 -0
  93. package/dist/cjs/react/hooks/use-drag-resize-panel.d.ts +48 -0
  94. package/dist/cjs/react/hooks/use-drag-resize-panel.js +308 -0
  95. package/dist/cjs/react/hooks/use-draggable-position.d.ts +25 -0
  96. package/dist/cjs/react/hooks/use-draggable-position.js +134 -0
  97. package/dist/cjs/react/hooks/use-keyboard-shortcut.d.ts +20 -0
  98. package/dist/cjs/react/hooks/use-keyboard-shortcut.js +93 -0
  99. package/dist/cjs/react/hooks/use-mentions.d.ts +23 -0
  100. package/dist/cjs/react/hooks/use-mentions.js +42 -0
  101. package/dist/cjs/react/hooks/use-suggestions.d.ts +22 -0
  102. package/dist/cjs/react/hooks/use-suggestions.js +39 -0
  103. package/dist/cjs/react/index.d.ts +43 -0
  104. package/dist/cjs/react/index.js +111 -0
  105. package/dist/cjs/react/provider/ai-chat-provider.d.ts +45 -0
  106. package/dist/cjs/react/provider/ai-chat-provider.js +1024 -0
  107. package/dist/cjs/react/provider/chat-context.d.ts +84 -0
  108. package/dist/cjs/react/provider/chat-context.js +13 -0
  109. package/dist/cjs/react/template.d.ts +84 -0
  110. package/dist/cjs/react/template.js +90 -0
  111. package/dist/cjs/react/themes.d.ts +24 -0
  112. package/dist/cjs/react/themes.js +273 -0
  113. package/dist/cjs/react/transports/langgraph/index.d.ts +2 -0
  114. package/dist/cjs/react/transports/langgraph/index.js +8 -0
  115. package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.d.ts +62 -0
  116. package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.js +94 -0
  117. package/dist/cjs/react/transports/langgraph.d.ts +71 -0
  118. package/dist/cjs/react/transports/langgraph.js +369 -0
  119. package/dist/cjs/react/transports/vercel/index.d.ts +2 -0
  120. package/dist/cjs/react/transports/vercel/index.js +8 -0
  121. package/dist/cjs/react/transports/vercel/vercel-ai-chat.d.ts +49 -0
  122. package/dist/cjs/react/transports/vercel/vercel-ai-chat.js +81 -0
  123. package/dist/cjs/react/transports/vercel.d.ts +30 -0
  124. package/dist/cjs/react/transports/vercel.js +69 -0
  125. package/dist/cjs/react/types.d.ts +760 -0
  126. package/dist/cjs/react/types.js +2 -0
  127. package/dist/cjs/react/ui.d.ts +73 -0
  128. package/dist/cjs/react/ui.js +183 -0
  129. package/dist/cjs/react/utils/create-approval-description.d.ts +53 -0
  130. package/dist/cjs/react/utils/create-approval-description.js +122 -0
  131. package/dist/cjs/react/utils/create-tool-result-handler.d.ts +90 -0
  132. package/dist/cjs/react/utils/create-tool-result-handler.js +168 -0
  133. package/dist/cjs/react/utils/mention-markup.d.ts +13 -0
  134. package/dist/cjs/react/utils/mention-markup.js +117 -0
  135. package/dist/cjs/react/utils/merge-pipeline-steps.d.ts +19 -0
  136. package/dist/cjs/react/utils/merge-pipeline-steps.js +81 -0
  137. package/dist/cjs/react/utils/sanitize-stored-messages.d.ts +23 -0
  138. package/dist/cjs/react/utils/sanitize-stored-messages.js +52 -0
  139. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.d.ts +10 -0
  140. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.js +42 -0
  141. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.d.ts +32 -0
  142. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.js +4 -0
  143. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.d.ts +11 -0
  144. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.js +80 -0
  145. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.d.ts +9 -0
  146. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.js +119 -0
  147. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.d.ts +13 -0
  148. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.js +131 -0
  149. package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.d.ts +7 -0
  150. package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.js +52 -0
  151. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.d.ts +19 -0
  152. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.js +108 -0
  153. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.d.ts +8 -0
  154. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.js +59 -0
  155. package/dist/cjs/server/adapters/nestjs/chat/dto/index.d.ts +3 -0
  156. package/dist/cjs/server/adapters/nestjs/chat/dto/index.js +9 -0
  157. package/dist/cjs/server/adapters/nestjs/chat/index.d.ts +3 -0
  158. package/dist/cjs/server/adapters/nestjs/chat/index.js +9 -0
  159. package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +4 -0
  160. package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.js +73 -0
  161. package/dist/cjs/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
  162. package/dist/cjs/server/adapters/nestjs/chat/ws-loader.js +72 -0
  163. package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.d.ts +6 -0
  164. package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.js +13 -0
  165. package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.d.ts +5 -0
  166. package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.js +15 -0
  167. package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.d.ts +6 -0
  168. package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.js +22 -0
  169. package/dist/cjs/server/adapters/nestjs/decorators/constants.d.ts +4 -0
  170. package/dist/cjs/server/adapters/nestjs/decorators/constants.js +7 -0
  171. package/dist/cjs/server/adapters/nestjs/index.d.ts +14 -0
  172. package/dist/cjs/server/adapters/nestjs/index.js +42 -0
  173. package/dist/cjs/server/adapters/nestjs/metadata.d.ts +39 -0
  174. package/dist/cjs/server/adapters/nestjs/metadata.js +36 -0
  175. package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.d.ts +36 -0
  176. package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.js +159 -0
  177. package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.d.ts +37 -0
  178. package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.js +44 -0
  179. package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.d.ts +28 -0
  180. package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.js +41 -0
  181. package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.d.ts +16 -0
  182. package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.js +117 -0
  183. package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.d.ts +26 -0
  184. package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.js +259 -0
  185. package/dist/cjs/server/adapters/nestjs/swagger.d.ts +7 -0
  186. package/dist/cjs/server/adapters/nestjs/swagger.js +39 -0
  187. package/dist/cjs/server/adapters/nextjs/context-helpers.d.ts +22 -0
  188. package/dist/cjs/server/adapters/nextjs/context-helpers.js +60 -0
  189. package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.d.ts +94 -0
  190. package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.js +965 -0
  191. package/dist/cjs/server/adapters/nextjs/filter-fallback-error.d.ts +11 -0
  192. package/dist/cjs/server/adapters/nextjs/filter-fallback-error.js +41 -0
  193. package/dist/cjs/server/adapters/nextjs/index.d.ts +8 -0
  194. package/dist/cjs/server/adapters/nextjs/index.js +22 -0
  195. package/dist/cjs/server/adapters/nextjs/prepare-model-messages.d.ts +58 -0
  196. package/dist/cjs/server/adapters/nextjs/prepare-model-messages.js +114 -0
  197. package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.d.ts +64 -0
  198. package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.js +489 -0
  199. package/dist/cjs/server/adapters/nextjs/server-action-helper.d.ts +7 -0
  200. package/dist/cjs/server/adapters/nextjs/server-action-helper.js +40 -0
  201. package/dist/cjs/server/adapters/nextjs/types.d.ts +246 -0
  202. package/dist/cjs/server/adapters/nextjs/types.js +2 -0
  203. package/dist/cjs/server/adapters/nextjs/with-ai-tool.d.ts +9 -0
  204. package/dist/cjs/server/adapters/nextjs/with-ai-tool.js +12 -0
  205. package/dist/cjs/server/core/followup-tool.d.ts +9 -0
  206. package/dist/cjs/server/core/followup-tool.js +82 -0
  207. package/dist/cjs/server/core/index.d.ts +139 -0
  208. package/dist/cjs/server/core/index.js +818 -0
  209. package/dist/cjs/server/core/intent-classifier.d.ts +94 -0
  210. package/dist/cjs/server/core/intent-classifier.js +324 -0
  211. package/dist/cjs/server/core/model-selector.d.ts +12 -0
  212. package/dist/cjs/server/core/model-selector.js +48 -0
  213. package/dist/cjs/server/core/module-router.d.ts +14 -0
  214. package/dist/cjs/server/core/module-router.js +110 -0
  215. package/dist/cjs/server/core/zod-compact.d.ts +18 -0
  216. package/dist/cjs/server/core/zod-compact.js +129 -0
  217. package/dist/cjs/server/index.d.ts +6 -0
  218. package/dist/cjs/server/index.js +28 -0
  219. package/dist/cjs/server/lancer/cache.d.ts +9 -0
  220. package/dist/cjs/server/lancer/cache.js +33 -0
  221. package/dist/cjs/server/lancer/client.d.ts +2 -0
  222. package/dist/cjs/server/lancer/client.js +279 -0
  223. package/dist/cjs/server/lancer/errors.d.ts +13 -0
  224. package/dist/cjs/server/lancer/errors.js +21 -0
  225. package/dist/cjs/server/lancer/index.d.ts +3 -0
  226. package/dist/cjs/server/lancer/index.js +7 -0
  227. package/dist/cjs/server/lancer/telemetry-buffer.d.ts +15 -0
  228. package/dist/cjs/server/lancer/telemetry-buffer.js +64 -0
  229. package/dist/cjs/server/lancer/types.d.ts +201 -0
  230. package/dist/cjs/server/lancer/types.js +5 -0
  231. package/dist/cjs/server/pii-shield/aegis-detector.d.ts +26 -0
  232. package/dist/cjs/server/pii-shield/aegis-detector.js +26 -0
  233. package/dist/cjs/server/pii-shield/create-pii-shield.d.ts +2 -0
  234. package/dist/cjs/server/pii-shield/create-pii-shield.js +191 -0
  235. package/dist/cjs/server/pii-shield/deep-walk.d.ts +1 -0
  236. package/dist/cjs/server/pii-shield/deep-walk.js +19 -0
  237. package/dist/cjs/server/pii-shield/fake-data.d.ts +5 -0
  238. package/dist/cjs/server/pii-shield/fake-data.js +170 -0
  239. package/dist/cjs/server/pii-shield/index.d.ts +4 -0
  240. package/dist/cjs/server/pii-shield/index.js +9 -0
  241. package/dist/cjs/server/pii-shield/leakage.d.ts +1 -0
  242. package/dist/cjs/server/pii-shield/leakage.js +15 -0
  243. package/dist/cjs/server/pii-shield/session-mapping.d.ts +12 -0
  244. package/dist/cjs/server/pii-shield/session-mapping.js +70 -0
  245. package/dist/cjs/server/pipeline.d.ts +26 -0
  246. package/dist/cjs/server/pipeline.js +127 -0
  247. package/dist/cjs/server/testing/approvals.d.ts +11 -0
  248. package/dist/cjs/server/testing/approvals.js +41 -0
  249. package/dist/cjs/server/testing/combination.d.ts +3 -0
  250. package/dist/cjs/server/testing/combination.js +83 -0
  251. package/dist/cjs/server/testing/create-test-suite.d.ts +29 -0
  252. package/dist/cjs/server/testing/create-test-suite.js +81 -0
  253. package/dist/cjs/server/testing/edge-cases.d.ts +8 -0
  254. package/dist/cjs/server/testing/edge-cases.js +277 -0
  255. package/dist/cjs/server/testing/guardrails.d.ts +14 -0
  256. package/dist/cjs/server/testing/guardrails.js +152 -0
  257. package/dist/cjs/server/testing/helpers.d.ts +14 -0
  258. package/dist/cjs/server/testing/helpers.js +119 -0
  259. package/dist/cjs/server/testing/index.d.ts +12 -0
  260. package/dist/cjs/server/testing/index.js +37 -0
  261. package/dist/cjs/server/testing/mock-executor.d.ts +8 -0
  262. package/dist/cjs/server/testing/mock-executor.js +40 -0
  263. package/dist/cjs/server/testing/regression.d.ts +7 -0
  264. package/dist/cjs/server/testing/regression.js +27 -0
  265. package/dist/cjs/server/testing/routing.d.ts +12 -0
  266. package/dist/cjs/server/testing/routing.js +63 -0
  267. package/dist/cjs/server/testing/schema-consistency.d.ts +6 -0
  268. package/dist/cjs/server/testing/schema-consistency.js +56 -0
  269. package/dist/cjs/server/testing/smoke.d.ts +11 -0
  270. package/dist/cjs/server/testing/smoke.js +64 -0
  271. package/dist/cjs/server/testing/types.d.ts +156 -0
  272. package/dist/cjs/server/testing/types.js +2 -0
  273. package/dist/cjs/types.d.ts +696 -0
  274. package/dist/cjs/types.js +91 -0
  275. package/dist/cli/commands/install-skills.d.ts +17 -0
  276. package/dist/cli/commands/install-skills.js +185 -0
  277. package/dist/cli/commands/install-skills.js.map +1 -0
  278. package/dist/cli/index.js +25 -0
  279. package/dist/cli/index.js.map +1 -1
  280. package/dist/react/components/ai-trigger-button.js +4 -6
  281. package/dist/react/components/ai-trigger-button.js.map +1 -1
  282. package/dist/react/components/recording-bar.js +4 -6
  283. package/dist/react/components/recording-bar.js.map +1 -1
  284. package/dist/react/components/wavesurfer-loader.d.ts +5 -0
  285. package/dist/react/components/wavesurfer-loader.js +34 -0
  286. package/dist/react/components/wavesurfer-loader.js.map +1 -0
  287. package/dist/server/adapters/nestjs/chat/ai-chat.module.d.ts +1 -1
  288. package/dist/server/adapters/nestjs/chat/ai-chat.module.js +3 -2
  289. package/dist/server/adapters/nestjs/chat/ai-chat.module.js.map +1 -1
  290. package/dist/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +1 -1
  291. package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js +10 -8
  292. package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js.map +1 -1
  293. package/dist/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
  294. package/dist/server/adapters/nestjs/chat/ws-loader.js +37 -0
  295. package/dist/server/adapters/nestjs/chat/ws-loader.js.map +1 -0
  296. package/openapi/package.json +5 -0
  297. package/package.json +59 -16
  298. package/react/langgraph/package.json +5 -0
  299. package/react/package.json +5 -0
  300. package/react/vercel/package.json +5 -0
  301. package/server/nestjs/package.json +5 -0
  302. package/server/nextjs/package.json +5 -0
  303. package/server/package.json +5 -0
  304. package/server/testing/package.json +5 -0
  305. package/skills/README.md +107 -0
  306. package/skills/building-glirastes-chat-ui/SKILL.md +378 -0
  307. package/skills/integrating-glirastes-nestjs/SKILL.md +346 -0
  308. package/skills/integrating-glirastes-nextjs/SKILL.md +312 -0
  309. package/skills/integrating-glirastes-nextjs-with-nestjs-backend/SKILL.md +359 -0
  310. package/skills/maintaining-glirastes-tools/SKILL.md +467 -0
@@ -0,0 +1,696 @@
1
+ import { z } from 'zod';
2
+ export type EndpointMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
3
+ /**
4
+ * Runtime context for tool execution (transport-level info).
5
+ * Used so tools can forward the caller's auth (cookies, origin) to backend APIs.
6
+ * The SDK itself does NOT handle authentication or authorization — the backend API
7
+ * that each tool calls is responsible for checking permissions.
8
+ */
9
+ export interface RuntimeContext {
10
+ origin?: string;
11
+ cookieHeader?: string;
12
+ [key: string]: unknown;
13
+ }
14
+ /**
15
+ * Context passed to every tool execution.
16
+ */
17
+ export interface ToolContext {
18
+ currentDate: Date;
19
+ locale: string;
20
+ runtime?: RuntimeContext;
21
+ }
22
+ /**
23
+ * A Tool defines a single action that can be performed in the system.
24
+ * Permission enforcement is the responsibility of the backend API that each tool calls —
25
+ * the SDK does not perform authorization checks.
26
+ */
27
+ export interface Tool {
28
+ /** Unique identifier, e.g., "groups.create" */
29
+ id: string;
30
+ /** Human-readable description for AI to understand when to use this */
31
+ description: string;
32
+ /** Zod schema for input validation — shared between AI and API */
33
+ inputSchema: z.ZodType;
34
+ /** Optional Zod schema describing the tool's response shape */
35
+ outputSchema?: z.ZodType;
36
+ /** HTTP method of the underlying endpoint (e.g. GET, POST). Used by test suites to derive approval defaults. */
37
+ method?: string;
38
+ /**
39
+ * Whether the tool call requires explicit user approval.
40
+ * @deprecated Use Glirastes approval flows via `lancer.approvals` instead. Kept for backward compatibility.
41
+ */
42
+ needsApproval?: boolean | ((input: unknown, context: ToolContext) => boolean | Promise<boolean>);
43
+ /** The actual implementation */
44
+ execute: (input: unknown, context: ToolContext) => Promise<unknown>;
45
+ }
46
+ /**
47
+ * Helper to define a tool with full type inference at definition site.
48
+ */
49
+ export declare function defineTool<TInput extends z.ZodType, TOutput>(tool: {
50
+ id: string;
51
+ description: string;
52
+ inputSchema: TInput;
53
+ outputSchema?: z.ZodType<TOutput>;
54
+ method?: string;
55
+ /** @deprecated Use Glirastes approval flows via `lancer.approvals` instead. Kept for backward compatibility. */
56
+ needsApproval?: boolean | ((input: z.infer<TInput>, context: ToolContext) => boolean | Promise<boolean>);
57
+ execute: (input: z.infer<TInput>, context: ToolContext) => Promise<TOutput>;
58
+ }): Tool;
59
+ /**
60
+ * Registry of all tools in the system.
61
+ * Keys are tool names (e.g., "create_group").
62
+ */
63
+ export type ToolRegistry = Record<string, Tool>;
64
+ export interface UiActionTemplate {
65
+ type: string;
66
+ [key: string]: unknown;
67
+ }
68
+ /**
69
+ * Creates a Zod schema for validating UI actions at runtime.
70
+ * Consumers provide their app-specific action schemas.
71
+ *
72
+ * Built-in action types that every app gets:
73
+ * - run-client-action: Dispatch to a registered action handler
74
+ * - navigate: Navigate to a path
75
+ * - entity actions: {entity}-{created|updated|deleted} pattern
76
+ *
77
+ * @param extraSchemas - Additional Zod schemas for app-specific action types
78
+ */
79
+ export declare function createUiActionSchema(extraSchemas?: z.ZodTypeAny[]): z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>;
80
+ export type UiPatternType = 'filter-and-navigate' | 'open-detail' | 'open-dialog' | 'refresh' | 'toast';
81
+ export interface FilterAndNavigatePattern {
82
+ type: 'filter-and-navigate';
83
+ /** Target page identifier (app-specific, e.g., 'tasks', 'dashboard') */
84
+ target: string;
85
+ /** Maps response/input fields to filter keys. Array-wrapped: status, priority, assignee. String: rest. */
86
+ filterMapping?: Record<string, string>;
87
+ /** Fields whose values should be auto-wrapped in arrays */
88
+ arrayFields?: string[];
89
+ /** Only emit uiAction if this response field is truthy */
90
+ condition?: string;
91
+ }
92
+ export interface OpenDetailPattern {
93
+ type: 'open-detail';
94
+ /** Entity type — used to derive actionId (e.g., 'task' → 'task-details.open') */
95
+ entity: string;
96
+ /** Response field containing the entity ID */
97
+ idField: string;
98
+ }
99
+ export interface OpenDialogPattern {
100
+ type: 'open-dialog';
101
+ /** Dialog actionId suffix (e.g., 'create-task' → 'task-create-dialog.open') */
102
+ dialog: string;
103
+ /** Response field containing entity ID (for edit/delete) */
104
+ idField?: string;
105
+ }
106
+ export interface RefreshPattern {
107
+ type: 'refresh';
108
+ /** What to refresh (e.g., 'tasks', 'dashboard', 'current') */
109
+ target: string;
110
+ }
111
+ export interface ToastPattern {
112
+ type: 'toast';
113
+ /** Response field reference (starting with $) or static message */
114
+ message: string;
115
+ /** Toast variant */
116
+ variant?: 'default' | 'success' | 'error' | 'warning';
117
+ }
118
+ export type UiPattern = FilterAndNavigatePattern | OpenDetailPattern | OpenDialogPattern | RefreshPattern | ToastPattern;
119
+ export interface AiEndpointToolDefinition<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny> {
120
+ id: string;
121
+ toolName: string;
122
+ /** Which intent module this tool belongs to */
123
+ module?: string;
124
+ /** Additional modules where this tool should also be available */
125
+ sharedWith?: string[];
126
+ description: string;
127
+ method: EndpointMethod;
128
+ path: string;
129
+ inputSchema: TInput;
130
+ /**
131
+ * Optional Zod schema describing the API response shape.
132
+ * When provided, a compact description is auto-appended to the tool description.
133
+ */
134
+ outputSchema?: TOutput;
135
+ /** @deprecated Use Glirastes approval flows via `lancer.approvals` instead. Kept for backward compatibility. */
136
+ needsApproval?: boolean;
137
+ /**
138
+ * Static uiAction template with $variable placeholders.
139
+ * Use for simple cases where action is always the same.
140
+ * Pass an array for compound actions (e.g., toast + refresh).
141
+ */
142
+ uiActionOnSuccess?: UiActionTemplate | UiActionTemplate[];
143
+ /**
144
+ * Dynamic uiAction pattern. Evaluated at runtime based on input + response.
145
+ * Takes precedence over uiActionOnSuccess if both are defined.
146
+ * Pass an array for compound actions (e.g., toast + refresh).
147
+ */
148
+ uiPattern?: UiPattern | UiPattern[];
149
+ }
150
+ export declare function defineEndpointTool<TInput extends z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny>(definition: AiEndpointToolDefinition<TInput, TOutput>): AiEndpointToolDefinition<TInput, TOutput>;
151
+ export interface AiUiToolDefinition<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny> {
152
+ id: string;
153
+ toolName: string;
154
+ /** Which intent module this tool belongs to */
155
+ module?: string;
156
+ /** Additional modules where this tool should also be available */
157
+ sharedWith?: string[];
158
+ description: string;
159
+ inputSchema: TInput;
160
+ /**
161
+ * Optional Zod schema describing the tool's response shape.
162
+ * When provided, a compact description is auto-appended to the tool description.
163
+ */
164
+ outputSchema?: TOutput;
165
+ /** @deprecated Use Glirastes approval flows via `lancer.approvals` instead. Kept for backward compatibility. */
166
+ needsApproval?: boolean;
167
+ successMessage?: string;
168
+ /**
169
+ * Static uiAction template with $variable placeholders.
170
+ * Pass an array for compound actions (e.g., toast + refresh).
171
+ */
172
+ uiAction?: UiActionTemplate | UiActionTemplate[];
173
+ /**
174
+ * Dynamic uiAction pattern. Takes precedence over uiAction if both defined.
175
+ * Pass an array for compound actions (e.g., toast + refresh).
176
+ */
177
+ uiPattern?: UiPattern | UiPattern[];
178
+ }
179
+ export declare function defineUiTool<TInput extends z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny>(definition: AiUiToolDefinition<TInput, TOutput>): AiUiToolDefinition<TInput, TOutput>;
180
+ /**
181
+ * Model tier for selecting appropriate model based on task complexity.
182
+ * - fast: Quick responses, simple lookups
183
+ * - standard: Balanced performance
184
+ * - powerful: Complex reasoning, planning
185
+ */
186
+ export type ModelTier = 'fast' | 'standard' | 'powerful';
187
+ export interface ModuleExecutionConfig {
188
+ maxSteps: number;
189
+ contextWindow: number;
190
+ modelTier: ModelTier;
191
+ }
192
+ /**
193
+ * Sensible baseline execution parameters.
194
+ * Modules spread these defaults and override only what differs.
195
+ */
196
+ export declare const EXECUTION_DEFAULTS: ModuleExecutionConfig;
197
+ export interface ModuleClassificationConfig {
198
+ hint: string;
199
+ examples: string[];
200
+ }
201
+ export interface ModuleMeta {
202
+ classification: ModuleClassificationConfig;
203
+ /** Partial — missing fields fall back to EXECUTION_DEFAULTS at build time. */
204
+ execution?: Partial<ModuleExecutionConfig>;
205
+ systemPrompt?: string;
206
+ }
207
+ export interface IntentModule {
208
+ type: string;
209
+ toolNames: string[];
210
+ systemPromptAddition?: string;
211
+ /** Resolved execution fields (merged with EXECUTION_DEFAULTS). */
212
+ maxSteps?: number;
213
+ contextWindow?: number;
214
+ modelTier?: ModelTier;
215
+ meta: ModuleMeta;
216
+ }
217
+ export interface OpenApiAiExtension {
218
+ enabled?: boolean;
219
+ toolName?: string;
220
+ description?: string;
221
+ module?: string;
222
+ sharedWith?: string[];
223
+ /** @deprecated Use Glirastes approval flows via `lancer.approvals` instead. Kept for backward compatibility. */
224
+ needsApproval?: boolean;
225
+ uiActionOnSuccess?: Record<string, unknown> | Record<string, unknown>[];
226
+ uiPattern?: UiPattern | UiPattern[];
227
+ }
228
+ export interface OpenApiOperationLike {
229
+ operationId?: string;
230
+ summary?: string;
231
+ description?: string;
232
+ 'x-ai'?: OpenApiAiExtension;
233
+ }
234
+ export interface ActionIdEntry {
235
+ tools: Array<{
236
+ toolName: string;
237
+ sourceFile: string;
238
+ }>;
239
+ payloadKeys: readonly string[];
240
+ }
241
+ export type ActionIdRegistry = Record<string, ActionIdEntry>;
242
+ /**
243
+ * Authentication strategy for agent skill access.
244
+ * Describes how an autonomous agent authenticates against the platform API.
245
+ */
246
+ export type AgentAuthStrategy = {
247
+ type: 'bearer';
248
+ tokenEnvVar: string;
249
+ description?: string;
250
+ } | {
251
+ type: 'api-key';
252
+ headerName: string;
253
+ keyEnvVar: string;
254
+ description?: string;
255
+ } | {
256
+ type: 'oauth2';
257
+ tokenUrl: string;
258
+ clientIdEnvVar: string;
259
+ clientSecretEnvVar: string;
260
+ scopes?: string[];
261
+ description?: string;
262
+ } | {
263
+ type: 'cookie';
264
+ description?: string;
265
+ };
266
+ /**
267
+ * A single tool exposed in an agent skill file.
268
+ * Contains everything an LLM agent needs to call the tool via HTTP.
269
+ */
270
+ export interface AgentSkillTool {
271
+ name: string;
272
+ description: string;
273
+ method: EndpointMethod;
274
+ path: string;
275
+ /** JSON Schema representation of inputSchema (Zod → JSON Schema) */
276
+ parameters: Record<string, unknown>;
277
+ /** JSON Schema representation of outputSchema, if available */
278
+ response?: Record<string, unknown>;
279
+ /**
280
+ * Whether the tool requires explicit user confirmation before execution.
281
+ * @deprecated Use Glirastes approval flows via `lancer.approvals` instead. Kept for backward compatibility.
282
+ */
283
+ needsApproval?: boolean;
284
+ }
285
+ /**
286
+ * Configuration for generating agent skill files.
287
+ */
288
+ export interface AgentSkillConfig {
289
+ /** Human-readable name of the platform/app (e.g., "My Task Manager") */
290
+ appName: string;
291
+ /** Base URL of the API (e.g., "https://api.example.com") */
292
+ baseUrl: string;
293
+ /** How the agent authenticates */
294
+ auth: AgentAuthStrategy;
295
+ /** Optional version string */
296
+ version?: string;
297
+ /** Optional description of the platform */
298
+ description?: string;
299
+ }
300
+ /**
301
+ * All audit event types emitted across the SDK.
302
+ * Each package emits a subset of these via an optional `onAudit` callback.
303
+ */
304
+ export type AuditEventType = 'session.started' | 'session.ended' | 'guardrail.passed' | 'guardrail.blocked' | 'intent.classified' | 'routing.resolved' | 'pii.detected' | 'pii.anonymized' | 'pii.rehydrated' | 'pii.leakage' | 'tool.executed' | 'tool.failed' | 'approval.requested' | 'approval.granted' | 'approval.denied';
305
+ /**
306
+ * A single audit event emitted by any SDK package.
307
+ *
308
+ * Consumers receive these via the `onAudit` callback and can forward them
309
+ * to any SIEM, logging backend, or compliance store.
310
+ */
311
+ export interface AuditEvent {
312
+ /** Event type */
313
+ type: AuditEventType;
314
+ /** ISO 8601 timestamp */
315
+ timestamp: string;
316
+ /** Session identifier */
317
+ sessionId: string;
318
+ /** Source package that emitted this event */
319
+ source: 'server-core' | 'server-pro' | 'lancer' | 'adapter';
320
+ /** Event-specific payload (varies by event type) */
321
+ details: Record<string, unknown>;
322
+ }
323
+ /**
324
+ * Callback type for receiving audit events.
325
+ * Passed as `onAudit` option to each package.
326
+ */
327
+ export type AuditEmitter = (event: AuditEvent) => void;
328
+ /**
329
+ * Lightweight telemetry sink for forwarding SDK events to a remote backend.
330
+ *
331
+ * Compatible with `lancer.telemetry` — pass it directly:
332
+ * ```typescript
333
+ * const lancer = createLancer({ apiKey: '...' });
334
+ * createAiChatHandler({ telemetry: lancer.telemetry, ... });
335
+ * ```
336
+ *
337
+ * Free-tier users get monitoring/analytics on Glirastes without Pro features.
338
+ */
339
+ export interface TelemetrySink {
340
+ /** Buffer an event for async delivery. Fire-and-forget — must never throw. */
341
+ emit(event: {
342
+ eventType: string;
343
+ traceId?: string;
344
+ toolId?: string;
345
+ tokensIn?: number;
346
+ tokensOut?: number;
347
+ latencyMs?: number;
348
+ modelId?: string;
349
+ modelTier?: string;
350
+ /** ISO-8601 timestamp of when the event occurred on the client. */
351
+ timestamp?: string;
352
+ payload?: Record<string, unknown>;
353
+ actor?: Record<string, unknown>;
354
+ }): void;
355
+ /** Flush buffered events. Called on session end / process shutdown. */
356
+ flush(): Promise<void>;
357
+ }
358
+ /**
359
+ * A lightweight message representation passed to the intent classifier
360
+ * so it can consider conversation history when classifying follow-up messages.
361
+ */
362
+ export interface ConversationMessage {
363
+ role: 'user' | 'assistant';
364
+ content: string;
365
+ }
366
+ export interface IntentClassification {
367
+ intent: string;
368
+ confidence: number;
369
+ }
370
+ export interface ModuleDefinition {
371
+ id: string;
372
+ name: string;
373
+ description: string;
374
+ tools: string[];
375
+ sharedTools?: string[];
376
+ executionDefaults?: {
377
+ maxSteps?: number;
378
+ contextWindow?: number;
379
+ modelTier?: ModelTier;
380
+ };
381
+ classification?: {
382
+ hint: string;
383
+ examples: string[];
384
+ };
385
+ systemPrompt?: string;
386
+ }
387
+ export interface PromptOverride {
388
+ moduleId: string;
389
+ mode: 'replace' | 'patch';
390
+ /** Full replacement prompt (replace mode) */
391
+ systemPrompt: string | null;
392
+ /** Prepended before generated prompt (patch mode) */
393
+ promptPrefix: string | null;
394
+ /** Appended after generated prompt (patch mode) */
395
+ promptSuffix: string | null;
396
+ /** Override the module's model tier */
397
+ modelTierOverride: string | null;
398
+ }
399
+ /**
400
+ * Apply a prompt override to a base system prompt.
401
+ * - replace mode: returns the override's systemPrompt (or base if null)
402
+ * - patch mode: prepends prefix and/or appends suffix to base
403
+ */
404
+ export declare function applyPromptOverride(base: string, override: PromptOverride): string;
405
+ export interface AiRouterConfig {
406
+ modules: ModuleDefinition[];
407
+ expansionStrategy?: 'minimal' | 'shared' | 'full';
408
+ relatedModules?: Record<string, string[]>;
409
+ confidenceThresholds?: {
410
+ high?: number;
411
+ medium?: number;
412
+ };
413
+ }
414
+ export interface SelectedTools {
415
+ tools: string[];
416
+ module: ModuleDefinition | null;
417
+ strategy: 'single' | 'expanded' | 'all';
418
+ }
419
+ export interface AiRouter {
420
+ route(intent: IntentClassification, allToolNames: string[]): SelectedTools;
421
+ }
422
+ export interface ModelConfig {
423
+ modelId: string;
424
+ /** Ready-to-use LanguageModel instance. When provided, the adapter
425
+ * uses this directly instead of requiring a separate model callback. */
426
+ instance?: unknown;
427
+ [key: string]: unknown;
428
+ }
429
+ export interface ModelSelectorConfig {
430
+ fast: ModelConfig;
431
+ standard: ModelConfig;
432
+ premium: ModelConfig;
433
+ }
434
+ export interface ModelSelector {
435
+ select(intent: IntentClassification, context?: ToolContext): ModelConfig;
436
+ }
437
+ export interface Validator {
438
+ name: string;
439
+ validate(input: string): ValidationResult;
440
+ }
441
+ export interface GuardrailsConfig {
442
+ maxInputLength?: number;
443
+ enableInjectionDetection?: boolean;
444
+ customValidators?: Validator[];
445
+ injectionPatterns?: RegExp[];
446
+ }
447
+ export interface ValidationResult {
448
+ valid: boolean;
449
+ blocked: boolean;
450
+ reason?: string;
451
+ sanitized: string;
452
+ }
453
+ export interface Guardrails {
454
+ validate(input: string): ValidationResult;
455
+ /** Async validation with Lancer delegation (falls back to local validate) */
456
+ validateAsync?(input: string): Promise<ValidationResult>;
457
+ sanitize(input: string): string;
458
+ }
459
+ export interface FollowupLocale {
460
+ description: string;
461
+ suggestionHint: string;
462
+ examples?: {
463
+ good: string[];
464
+ bad: string[];
465
+ };
466
+ }
467
+ export interface FollowupsConfig {
468
+ enabled?: boolean;
469
+ count?: number;
470
+ locale?: FollowupLocale;
471
+ }
472
+ export interface LearnedPattern {
473
+ pattern: string;
474
+ intent: string;
475
+ confidence: number;
476
+ hitCount: number;
477
+ lastSeen: number;
478
+ promotedAt?: number;
479
+ }
480
+ export interface FastPathConfig {
481
+ maxPatterns?: number;
482
+ confidenceThreshold?: number;
483
+ promotionThreshold?: number;
484
+ minConfidence?: number;
485
+ patternTtlMs?: number;
486
+ enableLearning?: boolean;
487
+ initialPatterns?: LearnedPattern[];
488
+ }
489
+ export interface FastPathStorage {
490
+ load(): Promise<LearnedPattern[]>;
491
+ save(patterns: LearnedPattern[]): Promise<void>;
492
+ }
493
+ export interface AdaptiveFastPathInstance {
494
+ match(input: string): IntentClassification | null;
495
+ learn(input: string, intent: IntentClassification): void;
496
+ getPatterns(): LearnedPattern[];
497
+ getPromotedPatterns(): LearnedPattern[];
498
+ importPatterns(patterns: LearnedPattern[]): void;
499
+ getStats(): FastPathStats;
500
+ clear(): void;
501
+ loadFromStorage(): Promise<void>;
502
+ saveToStorage(): Promise<void>;
503
+ }
504
+ export interface FastPathStats {
505
+ totalPatterns: number;
506
+ promotedPatterns: number;
507
+ avgHitCount: number;
508
+ oldestPattern: number;
509
+ }
510
+ export interface IntentClassifierConfig {
511
+ /** Module definitions to classify against */
512
+ modules: ModuleDefinition[];
513
+ /** Model used for classification */
514
+ model?: unknown;
515
+ /** Classification timeout in ms (default: 2000) */
516
+ timeoutMs?: number;
517
+ /** Minimum confidence threshold (default: 0.5) */
518
+ confidenceThreshold?: number;
519
+ /** Minimum token count in input to attempt classification (default: 2) */
520
+ minTokens?: number;
521
+ /** BCP-47 locale for language-aware stemming (e.g. "de", "en-US", "fr") */
522
+ locale?: string;
523
+ }
524
+ export interface IntentClassifier {
525
+ classify(input: string, context?: ToolContext, conversationHistory?: ConversationMessage[]): Promise<IntentClassification>;
526
+ }
527
+ export interface AiPipelineConfig {
528
+ modules: ModuleDefinition[];
529
+ guardrails?: GuardrailsConfig;
530
+ modelSelector?: ModelSelectorConfig;
531
+ /**
532
+ * Flat tier→modelId map as a simpler alternative to `modelSelector`.
533
+ * Keys are tier names (fast, standard, powerful).
534
+ * Requires `modelInstanceFactory` to turn IDs into LanguageModel instances.
535
+ */
536
+ models?: Record<string, string>;
537
+ /**
538
+ * Factory that turns a modelId string into a ready-to-use LanguageModel instance.
539
+ * Required when using the flat `models` map.
540
+ */
541
+ modelInstanceFactory?: (modelId: string) => unknown;
542
+ classifier?: IntentClassifierConfig;
543
+ fastPath?: FastPathConfig;
544
+ fastPathStorage?: FastPathStorage;
545
+ followups?: FollowupsConfig;
546
+ relatedModules?: Record<string, string[]>;
547
+ confidenceThresholds?: {
548
+ high?: number;
549
+ medium?: number;
550
+ };
551
+ /** Audit event emitter for compliance logging */
552
+ onAudit?: AuditEmitter;
553
+ }
554
+ export interface PipelineResult {
555
+ model: ModelConfig;
556
+ tools: string[];
557
+ sanitizedInput: string;
558
+ intent: IntentClassification;
559
+ module: ModuleDefinition | null;
560
+ followupsEnabled: boolean;
561
+ /** True when guardrails blocked the input (warden check failed or service unavailable with block policy). */
562
+ blocked?: boolean;
563
+ }
564
+ export interface AiPipeline {
565
+ process(input: string, context: ToolContext, conversationHistory?: ConversationMessage[]): Promise<PipelineResult>;
566
+ }
567
+ export interface EvalCase {
568
+ id: string;
569
+ input: string;
570
+ expectedTools: string[];
571
+ expectedIntent?: string;
572
+ expectedModule?: string;
573
+ requiresApproval?: boolean;
574
+ assertResult?: (result: unknown) => boolean;
575
+ }
576
+ export interface SmokeResult {
577
+ passed: boolean;
578
+ summary: string;
579
+ details: Array<{
580
+ caseId: string;
581
+ passed: boolean;
582
+ reason?: string;
583
+ }>;
584
+ }
585
+ export interface RoutingResult {
586
+ passed: boolean;
587
+ summary: string;
588
+ details: Array<{
589
+ caseId: string;
590
+ passed: boolean;
591
+ actualIntent?: string;
592
+ actualModule?: string;
593
+ reason?: string;
594
+ }>;
595
+ }
596
+ export interface E2EResult {
597
+ passed: boolean;
598
+ summary: string;
599
+ details: Array<{
600
+ caseId: string;
601
+ passed: boolean;
602
+ toolsCalled?: string[];
603
+ reason?: string;
604
+ }>;
605
+ }
606
+ export interface EvalSuiteConfig {
607
+ tools: Record<string, unknown>;
608
+ pipeline?: AiPipeline;
609
+ cases: EvalCase[];
610
+ }
611
+ export interface EvalSuite {
612
+ runSmoke(): Promise<SmokeResult>;
613
+ runRouting(): Promise<RoutingResult>;
614
+ runE2E(): Promise<E2EResult>;
615
+ }
616
+ export type PiiCategory = 'person' | 'email' | 'phone' | 'iban' | 'credit_card' | 'cvv' | 'card_expiry' | 'address' | 'date_of_birth' | 'tax_id' | 'ssn' | 'ip_address' | 'url' | 'custom';
617
+ export interface PiiEntity {
618
+ type: PiiCategory | string;
619
+ start: number;
620
+ end: number;
621
+ score: number;
622
+ text: string;
623
+ }
624
+ export interface MappingEntry {
625
+ original: string;
626
+ pseudonym: string;
627
+ type: PiiCategory | string;
628
+ variants: {
629
+ forward: Map<string, string>;
630
+ reverse: Map<string, string>;
631
+ };
632
+ firstSeen: number;
633
+ source: 'user-input' | 'tool-result';
634
+ }
635
+ export interface PiiAuditEntry {
636
+ sessionId: string;
637
+ timestamp: string;
638
+ direction: 'outbound' | 'inbound' | 'rehydrate-args' | 'anonymize-result';
639
+ leakage?: boolean;
640
+ detections: {
641
+ type: PiiCategory | string;
642
+ detector: string;
643
+ confidence: number;
644
+ position: {
645
+ start: number;
646
+ end: number;
647
+ };
648
+ length: number;
649
+ }[];
650
+ totalDetected: number;
651
+ totalAnonymized: number;
652
+ mode: 'anonymize' | 'pseudonymize';
653
+ locale: string;
654
+ }
655
+ export interface ComplianceSummary {
656
+ sessionId: string;
657
+ duration: string;
658
+ totalMessages: number;
659
+ totalToolCalls: number;
660
+ piiStats: {
661
+ totalDetected: number;
662
+ byType: Record<string, number>;
663
+ byDetector: Record<string, number>;
664
+ byDirection: Record<string, number>;
665
+ };
666
+ mode: 'anonymize' | 'pseudonymize';
667
+ leakageDetected: number;
668
+ verdict: 'COMPLIANT' | 'LEAKAGE_DETECTED';
669
+ }
670
+ export interface PiiDetector {
671
+ detect(text: string, locales?: string[]): PiiEntity[] | Promise<PiiEntity[]>;
672
+ }
673
+ export interface PiiShieldConfig {
674
+ locale: string;
675
+ detector: PiiDetector;
676
+ leakageDetection?: boolean;
677
+ onAudit?: (entry: PiiAuditEntry) => void;
678
+ }
679
+ export interface PiiShield {
680
+ /** Anonymize user message before LLM sees it */
681
+ outbound(text: string, sessionId: string): Promise<string>;
682
+ /** Sync de-anonymize */
683
+ inbound(text: string, sessionId: string): string;
684
+ /** Async de-anonymize */
685
+ inboundAsync?(text: string, sessionId: string): Promise<string>;
686
+ /** Sync re-hydrate tool-call arguments */
687
+ rehydrateArgs(args: Record<string, unknown>, sessionId: string): Record<string, unknown>;
688
+ /** Async rehydrate */
689
+ rehydrateArgsAsync?(args: Record<string, unknown>, sessionId: string): Promise<Record<string, unknown>>;
690
+ /** Anonymize tool-result before LLM sees it */
691
+ anonymizeResult(result: unknown, sessionId: string): Promise<unknown>;
692
+ /** Get compliance summary for a session */
693
+ getComplianceSummary(sessionId: string): ComplianceSummary;
694
+ /** Clear session mapping */
695
+ clearSession(sessionId: string): void;
696
+ }