shield360 1.0.0

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 (520) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +310 -0
  3. package/dist/__tests__/manual-trace.test.d.ts +1 -0
  4. package/dist/__tests__/manual-trace.test.js +118 -0
  5. package/dist/__tests__/manual-trace.test.js.map +1 -0
  6. package/dist/__tests__/register.test.d.ts +0 -0
  7. package/dist/__tests__/register.test.js +90 -0
  8. package/dist/__tests__/register.test.js.map +1 -0
  9. package/dist/config.d.ts +28 -0
  10. package/dist/config.js +22 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/constant.d.ts +6 -0
  13. package/dist/constant.js +14 -0
  14. package/dist/constant.js.map +1 -0
  15. package/dist/evals/__tests__/offline.test.d.ts +1 -0
  16. package/dist/evals/__tests__/offline.test.js +427 -0
  17. package/dist/evals/__tests__/offline.test.js.map +1 -0
  18. package/dist/evals/index.d.ts +2 -0
  19. package/dist/evals/index.js +15 -0
  20. package/dist/evals/index.js.map +1 -0
  21. package/dist/evals/offline.d.ts +6 -0
  22. package/dist/evals/offline.js +350 -0
  23. package/dist/evals/offline.js.map +1 -0
  24. package/dist/evals/types.d.ts +74 -0
  25. package/dist/evals/types.js +23 -0
  26. package/dist/evals/types.js.map +1 -0
  27. package/dist/features/__tests__/rule-engine.test.d.ts +1 -0
  28. package/dist/features/__tests__/rule-engine.test.js +146 -0
  29. package/dist/features/__tests__/rule-engine.test.js.map +1 -0
  30. package/dist/features/base.d.ts +8 -0
  31. package/dist/features/base.js +15 -0
  32. package/dist/features/base.js.map +1 -0
  33. package/dist/features/prompt-hub.d.ts +4 -0
  34. package/dist/features/prompt-hub.js +66 -0
  35. package/dist/features/prompt-hub.js.map +1 -0
  36. package/dist/features/rule-engine.d.ts +6 -0
  37. package/dist/features/rule-engine.js +60 -0
  38. package/dist/features/rule-engine.js.map +1 -0
  39. package/dist/features/vault.d.ts +4 -0
  40. package/dist/features/vault.js +63 -0
  41. package/dist/features/vault.js.map +1 -0
  42. package/dist/guard/__tests__/findings.test.d.ts +1 -0
  43. package/dist/guard/__tests__/findings.test.js +79 -0
  44. package/dist/guard/__tests__/findings.test.js.map +1 -0
  45. package/dist/guard/__tests__/integration.test.d.ts +1 -0
  46. package/dist/guard/__tests__/integration.test.js +215 -0
  47. package/dist/guard/__tests__/integration.test.js.map +1 -0
  48. package/dist/guard/__tests__/pii.test.d.ts +1 -0
  49. package/dist/guard/__tests__/pii.test.js +131 -0
  50. package/dist/guard/__tests__/pii.test.js.map +1 -0
  51. package/dist/guard/__tests__/pipeline.test.d.ts +1 -0
  52. package/dist/guard/__tests__/pipeline.test.js +162 -0
  53. package/dist/guard/__tests__/pipeline.test.js.map +1 -0
  54. package/dist/guard/__tests__/prompt-injection.test.d.ts +1 -0
  55. package/dist/guard/__tests__/prompt-injection.test.js +92 -0
  56. package/dist/guard/__tests__/prompt-injection.test.js.map +1 -0
  57. package/dist/guard/__tests__/report.test.d.ts +1 -0
  58. package/dist/guard/__tests__/report.test.js +50 -0
  59. package/dist/guard/__tests__/report.test.js.map +1 -0
  60. package/dist/guard/base.d.ts +79 -0
  61. package/dist/guard/base.js +136 -0
  62. package/dist/guard/base.js.map +1 -0
  63. package/dist/guard/custom.d.ts +19 -0
  64. package/dist/guard/custom.js +46 -0
  65. package/dist/guard/custom.js.map +1 -0
  66. package/dist/guard/findings.d.ts +31 -0
  67. package/dist/guard/findings.js +156 -0
  68. package/dist/guard/findings.js.map +1 -0
  69. package/dist/guard/index.d.ts +24 -0
  70. package/dist/guard/index.js +42 -0
  71. package/dist/guard/index.js.map +1 -0
  72. package/dist/guard/integration.d.ts +44 -0
  73. package/dist/guard/integration.js +363 -0
  74. package/dist/guard/integration.js.map +1 -0
  75. package/dist/guard/moderation.d.ts +18 -0
  76. package/dist/guard/moderation.js +61 -0
  77. package/dist/guard/moderation.js.map +1 -0
  78. package/dist/guard/pii.d.ts +17 -0
  79. package/dist/guard/pii.js +114 -0
  80. package/dist/guard/pii.js.map +1 -0
  81. package/dist/guard/pipeline.d.ts +26 -0
  82. package/dist/guard/pipeline.js +139 -0
  83. package/dist/guard/pipeline.js.map +1 -0
  84. package/dist/guard/prompt-injection.d.ts +21 -0
  85. package/dist/guard/prompt-injection.js +70 -0
  86. package/dist/guard/prompt-injection.js.map +1 -0
  87. package/dist/guard/report.d.ts +34 -0
  88. package/dist/guard/report.js +182 -0
  89. package/dist/guard/report.js.map +1 -0
  90. package/dist/guard/schema.d.ts +20 -0
  91. package/dist/guard/schema.js +99 -0
  92. package/dist/guard/schema.js.map +1 -0
  93. package/dist/guard/sensitive-topic.d.ts +23 -0
  94. package/dist/guard/sensitive-topic.js +89 -0
  95. package/dist/guard/sensitive-topic.js.map +1 -0
  96. package/dist/guard/topic-restriction.d.ts +22 -0
  97. package/dist/guard/topic-restriction.js +54 -0
  98. package/dist/guard/topic-restriction.js.map +1 -0
  99. package/dist/helpers.d.ts +246 -0
  100. package/dist/helpers.js +903 -0
  101. package/dist/helpers.js.map +1 -0
  102. package/dist/index.d.ts +71 -0
  103. package/dist/index.js +234 -0
  104. package/dist/index.js.map +1 -0
  105. package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.d.ts +13 -0
  106. package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js +176 -0
  107. package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js.map +1 -0
  108. package/dist/instrumentation/__tests__/ai21-trace-comparison.test.d.ts +10 -0
  109. package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js +203 -0
  110. package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js.map +1 -0
  111. package/dist/instrumentation/__tests__/anthropic-wrapper.test.d.ts +1 -0
  112. package/dist/instrumentation/__tests__/anthropic-wrapper.test.js +284 -0
  113. package/dist/instrumentation/__tests__/anthropic-wrapper.test.js.map +1 -0
  114. package/dist/instrumentation/__tests__/assemblyai-wrapper.test.d.ts +1 -0
  115. package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js +284 -0
  116. package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js.map +1 -0
  117. package/dist/instrumentation/__tests__/astra-trace-comparison.test.d.ts +7 -0
  118. package/dist/instrumentation/__tests__/astra-trace-comparison.test.js +160 -0
  119. package/dist/instrumentation/__tests__/astra-trace-comparison.test.js.map +1 -0
  120. package/dist/instrumentation/__tests__/base-wrapper.test.d.ts +1 -0
  121. package/dist/instrumentation/__tests__/base-wrapper.test.js +171 -0
  122. package/dist/instrumentation/__tests__/base-wrapper.test.js.map +1 -0
  123. package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.d.ts +1 -0
  124. package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js +422 -0
  125. package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js.map +1 -0
  126. package/dist/instrumentation/__tests__/browser-use-wrapper.test.d.ts +1 -0
  127. package/dist/instrumentation/__tests__/browser-use-wrapper.test.js +284 -0
  128. package/dist/instrumentation/__tests__/browser-use-wrapper.test.js.map +1 -0
  129. package/dist/instrumentation/__tests__/cache-pricing.test.d.ts +15 -0
  130. package/dist/instrumentation/__tests__/cache-pricing.test.js +155 -0
  131. package/dist/instrumentation/__tests__/cache-pricing.test.js.map +1 -0
  132. package/dist/instrumentation/__tests__/chroma-trace-comparison.test.d.ts +18 -0
  133. package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js +209 -0
  134. package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js.map +1 -0
  135. package/dist/instrumentation/__tests__/cohere-wrapper.test.d.ts +1 -0
  136. package/dist/instrumentation/__tests__/cohere-wrapper.test.js +256 -0
  137. package/dist/instrumentation/__tests__/cohere-wrapper.test.js.map +1 -0
  138. package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.d.ts +1 -0
  139. package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js +282 -0
  140. package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js.map +1 -0
  141. package/dist/instrumentation/__tests__/firecrawl-wrapper.test.d.ts +1 -0
  142. package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js +238 -0
  143. package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js.map +1 -0
  144. package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.d.ts +4 -0
  145. package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js +229 -0
  146. package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js.map +1 -0
  147. package/dist/instrumentation/__tests__/gpu-collector.test.d.ts +1 -0
  148. package/dist/instrumentation/__tests__/gpu-collector.test.js +247 -0
  149. package/dist/instrumentation/__tests__/gpu-collector.test.js.map +1 -0
  150. package/dist/instrumentation/__tests__/gradient-trace-comparison.test.d.ts +11 -0
  151. package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js +391 -0
  152. package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js.map +1 -0
  153. package/dist/instrumentation/__tests__/groq-trace-comparison.test.d.ts +7 -0
  154. package/dist/instrumentation/__tests__/groq-trace-comparison.test.js +687 -0
  155. package/dist/instrumentation/__tests__/groq-trace-comparison.test.js.map +1 -0
  156. package/dist/instrumentation/__tests__/helpers-genai.test.d.ts +14 -0
  157. package/dist/instrumentation/__tests__/helpers-genai.test.js +347 -0
  158. package/dist/instrumentation/__tests__/helpers-genai.test.js.map +1 -0
  159. package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.d.ts +7 -0
  160. package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js +529 -0
  161. package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js.map +1 -0
  162. package/dist/instrumentation/__tests__/langchain-role-map.test.d.ts +1 -0
  163. package/dist/instrumentation/__tests__/langchain-role-map.test.js +19 -0
  164. package/dist/instrumentation/__tests__/langchain-role-map.test.js.map +1 -0
  165. package/dist/instrumentation/__tests__/langchain-wrapper.test.d.ts +1 -0
  166. package/dist/instrumentation/__tests__/langchain-wrapper.test.js +282 -0
  167. package/dist/instrumentation/__tests__/langchain-wrapper.test.js.map +1 -0
  168. package/dist/instrumentation/__tests__/letta-wrapper.test.d.ts +1 -0
  169. package/dist/instrumentation/__tests__/letta-wrapper.test.js +285 -0
  170. package/dist/instrumentation/__tests__/letta-wrapper.test.js.map +1 -0
  171. package/dist/instrumentation/__tests__/mem0-trace-comparison.test.d.ts +13 -0
  172. package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js +208 -0
  173. package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js.map +1 -0
  174. package/dist/instrumentation/__tests__/milvus-trace-comparison.test.d.ts +17 -0
  175. package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js +206 -0
  176. package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js.map +1 -0
  177. package/dist/instrumentation/__tests__/mistral-trace-comparison.test.d.ts +1 -0
  178. package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js +345 -0
  179. package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js.map +1 -0
  180. package/dist/instrumentation/__tests__/openai-wrapper.test.d.ts +1 -0
  181. package/dist/instrumentation/__tests__/openai-wrapper.test.js +179 -0
  182. package/dist/instrumentation/__tests__/openai-wrapper.test.js.map +1 -0
  183. package/dist/instrumentation/__tests__/pg-trace-comparison.test.d.ts +21 -0
  184. package/dist/instrumentation/__tests__/pg-trace-comparison.test.js +455 -0
  185. package/dist/instrumentation/__tests__/pg-trace-comparison.test.js.map +1 -0
  186. package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.d.ts +17 -0
  187. package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js +182 -0
  188. package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js.map +1 -0
  189. package/dist/instrumentation/__tests__/replicate-trace-comparison.test.d.ts +8 -0
  190. package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js +346 -0
  191. package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js.map +1 -0
  192. package/dist/instrumentation/__tests__/together-trace-comparison.test.d.ts +4 -0
  193. package/dist/instrumentation/__tests__/together-trace-comparison.test.js +289 -0
  194. package/dist/instrumentation/__tests__/together-trace-comparison.test.js.map +1 -0
  195. package/dist/instrumentation/__tests__/trace-comparison-utils.d.ts +67 -0
  196. package/dist/instrumentation/__tests__/trace-comparison-utils.js +255 -0
  197. package/dist/instrumentation/__tests__/trace-comparison-utils.js.map +1 -0
  198. package/dist/instrumentation/__tests__/transformers-trace-comparison.test.d.ts +11 -0
  199. package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js +214 -0
  200. package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js.map +1 -0
  201. package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.d.ts +8 -0
  202. package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js +446 -0
  203. package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js.map +1 -0
  204. package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.d.ts +6 -0
  205. package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js +409 -0
  206. package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js.map +1 -0
  207. package/dist/instrumentation/__tests__/vllm-trace-comparison.test.d.ts +1 -0
  208. package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js +519 -0
  209. package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js.map +1 -0
  210. package/dist/instrumentation/ai21/index.d.ts +11 -0
  211. package/dist/instrumentation/ai21/index.js +67 -0
  212. package/dist/instrumentation/ai21/index.js.map +1 -0
  213. package/dist/instrumentation/ai21/wrapper.d.ts +54 -0
  214. package/dist/instrumentation/ai21/wrapper.js +511 -0
  215. package/dist/instrumentation/ai21/wrapper.js.map +1 -0
  216. package/dist/instrumentation/anthropic/index.d.ts +11 -0
  217. package/dist/instrumentation/anthropic/index.js +45 -0
  218. package/dist/instrumentation/anthropic/index.js.map +1 -0
  219. package/dist/instrumentation/anthropic/wrapper.d.ts +34 -0
  220. package/dist/instrumentation/anthropic/wrapper.js +426 -0
  221. package/dist/instrumentation/anthropic/wrapper.js.map +1 -0
  222. package/dist/instrumentation/assemblyai/index.d.ts +12 -0
  223. package/dist/instrumentation/assemblyai/index.js +91 -0
  224. package/dist/instrumentation/assemblyai/index.js.map +1 -0
  225. package/dist/instrumentation/assemblyai/wrapper.d.ts +35 -0
  226. package/dist/instrumentation/assemblyai/wrapper.js +238 -0
  227. package/dist/instrumentation/assemblyai/wrapper.js.map +1 -0
  228. package/dist/instrumentation/astra/index.d.ts +11 -0
  229. package/dist/instrumentation/astra/index.js +87 -0
  230. package/dist/instrumentation/astra/index.js.map +1 -0
  231. package/dist/instrumentation/astra/wrapper.d.ts +39 -0
  232. package/dist/instrumentation/astra/wrapper.js +349 -0
  233. package/dist/instrumentation/astra/wrapper.js.map +1 -0
  234. package/dist/instrumentation/azure-ai-inference/index.d.ts +11 -0
  235. package/dist/instrumentation/azure-ai-inference/index.js +76 -0
  236. package/dist/instrumentation/azure-ai-inference/index.js.map +1 -0
  237. package/dist/instrumentation/azure-ai-inference/wrapper.d.ts +55 -0
  238. package/dist/instrumentation/azure-ai-inference/wrapper.js +580 -0
  239. package/dist/instrumentation/azure-ai-inference/wrapper.js.map +1 -0
  240. package/dist/instrumentation/base-wrapper.d.ts +16 -0
  241. package/dist/instrumentation/base-wrapper.js +139 -0
  242. package/dist/instrumentation/base-wrapper.js.map +1 -0
  243. package/dist/instrumentation/bedrock/index.d.ts +11 -0
  244. package/dist/instrumentation/bedrock/index.js +52 -0
  245. package/dist/instrumentation/bedrock/index.js.map +1 -0
  246. package/dist/instrumentation/bedrock/wrapper.d.ts +41 -0
  247. package/dist/instrumentation/bedrock/wrapper.js +494 -0
  248. package/dist/instrumentation/bedrock/wrapper.js.map +1 -0
  249. package/dist/instrumentation/browser-use/index.d.ts +11 -0
  250. package/dist/instrumentation/browser-use/index.js +98 -0
  251. package/dist/instrumentation/browser-use/index.js.map +1 -0
  252. package/dist/instrumentation/browser-use/wrapper.d.ts +12 -0
  253. package/dist/instrumentation/browser-use/wrapper.js +706 -0
  254. package/dist/instrumentation/browser-use/wrapper.js.map +1 -0
  255. package/dist/instrumentation/chroma/index.d.ts +11 -0
  256. package/dist/instrumentation/chroma/index.js +70 -0
  257. package/dist/instrumentation/chroma/index.js.map +1 -0
  258. package/dist/instrumentation/chroma/wrapper.d.ts +10 -0
  259. package/dist/instrumentation/chroma/wrapper.js +127 -0
  260. package/dist/instrumentation/chroma/wrapper.js.map +1 -0
  261. package/dist/instrumentation/claude-agent-sdk/index.d.ts +23 -0
  262. package/dist/instrumentation/claude-agent-sdk/index.js +83 -0
  263. package/dist/instrumentation/claude-agent-sdk/index.js.map +1 -0
  264. package/dist/instrumentation/claude-agent-sdk/wrapper.d.ts +13 -0
  265. package/dist/instrumentation/claude-agent-sdk/wrapper.js +1123 -0
  266. package/dist/instrumentation/claude-agent-sdk/wrapper.js.map +1 -0
  267. package/dist/instrumentation/cohere/index.d.ts +11 -0
  268. package/dist/instrumentation/cohere/index.js +53 -0
  269. package/dist/instrumentation/cohere/index.js.map +1 -0
  270. package/dist/instrumentation/cohere/wrapper.d.ts +50 -0
  271. package/dist/instrumentation/cohere/wrapper.js +452 -0
  272. package/dist/instrumentation/cohere/wrapper.js.map +1 -0
  273. package/dist/instrumentation/cursor-sdk/index.d.ts +21 -0
  274. package/dist/instrumentation/cursor-sdk/index.js +58 -0
  275. package/dist/instrumentation/cursor-sdk/index.js.map +1 -0
  276. package/dist/instrumentation/cursor-sdk/wrapper.d.ts +17 -0
  277. package/dist/instrumentation/cursor-sdk/wrapper.js +789 -0
  278. package/dist/instrumentation/cursor-sdk/wrapper.js.map +1 -0
  279. package/dist/instrumentation/elevenlabs/index.d.ts +12 -0
  280. package/dist/instrumentation/elevenlabs/index.js +92 -0
  281. package/dist/instrumentation/elevenlabs/index.js.map +1 -0
  282. package/dist/instrumentation/elevenlabs/wrapper.d.ts +34 -0
  283. package/dist/instrumentation/elevenlabs/wrapper.js +280 -0
  284. package/dist/instrumentation/elevenlabs/wrapper.js.map +1 -0
  285. package/dist/instrumentation/firecrawl/index.d.ts +13 -0
  286. package/dist/instrumentation/firecrawl/index.js +115 -0
  287. package/dist/instrumentation/firecrawl/index.js.map +1 -0
  288. package/dist/instrumentation/firecrawl/wrapper.d.ts +22 -0
  289. package/dist/instrumentation/firecrawl/wrapper.js +378 -0
  290. package/dist/instrumentation/firecrawl/wrapper.js.map +1 -0
  291. package/dist/instrumentation/google-adk/index.d.ts +57 -0
  292. package/dist/instrumentation/google-adk/index.js +371 -0
  293. package/dist/instrumentation/google-adk/index.js.map +1 -0
  294. package/dist/instrumentation/google-adk/utils.d.ts +45 -0
  295. package/dist/instrumentation/google-adk/utils.js +663 -0
  296. package/dist/instrumentation/google-adk/utils.js.map +1 -0
  297. package/dist/instrumentation/google-adk/wrapper.d.ts +11 -0
  298. package/dist/instrumentation/google-adk/wrapper.js +391 -0
  299. package/dist/instrumentation/google-adk/wrapper.js.map +1 -0
  300. package/dist/instrumentation/google-ai/index.d.ts +11 -0
  301. package/dist/instrumentation/google-ai/index.js +48 -0
  302. package/dist/instrumentation/google-ai/index.js.map +1 -0
  303. package/dist/instrumentation/google-ai/wrapper.d.ts +52 -0
  304. package/dist/instrumentation/google-ai/wrapper.js +466 -0
  305. package/dist/instrumentation/google-ai/wrapper.js.map +1 -0
  306. package/dist/instrumentation/gpu/index.d.ts +38 -0
  307. package/dist/instrumentation/gpu/index.js +233 -0
  308. package/dist/instrumentation/gpu/index.js.map +1 -0
  309. package/dist/instrumentation/gradient/index.d.ts +12 -0
  310. package/dist/instrumentation/gradient/index.js +74 -0
  311. package/dist/instrumentation/gradient/index.js.map +1 -0
  312. package/dist/instrumentation/gradient/utils.d.ts +14 -0
  313. package/dist/instrumentation/gradient/utils.js +119 -0
  314. package/dist/instrumentation/gradient/utils.js.map +1 -0
  315. package/dist/instrumentation/gradient/wrapper.d.ts +76 -0
  316. package/dist/instrumentation/gradient/wrapper.js +584 -0
  317. package/dist/instrumentation/gradient/wrapper.js.map +1 -0
  318. package/dist/instrumentation/groq/index.d.ts +11 -0
  319. package/dist/instrumentation/groq/index.js +43 -0
  320. package/dist/instrumentation/groq/index.js.map +1 -0
  321. package/dist/instrumentation/groq/wrapper.d.ts +35 -0
  322. package/dist/instrumentation/groq/wrapper.js +442 -0
  323. package/dist/instrumentation/groq/wrapper.js.map +1 -0
  324. package/dist/instrumentation/huggingface/index.d.ts +13 -0
  325. package/dist/instrumentation/huggingface/index.js +110 -0
  326. package/dist/instrumentation/huggingface/index.js.map +1 -0
  327. package/dist/instrumentation/huggingface/wrapper.d.ts +54 -0
  328. package/dist/instrumentation/huggingface/wrapper.js +514 -0
  329. package/dist/instrumentation/huggingface/wrapper.js.map +1 -0
  330. package/dist/instrumentation/index.d.ts +7 -0
  331. package/dist/instrumentation/index.js +176 -0
  332. package/dist/instrumentation/index.js.map +1 -0
  333. package/dist/instrumentation/langchain/index.d.ts +16 -0
  334. package/dist/instrumentation/langchain/index.js +91 -0
  335. package/dist/instrumentation/langchain/index.js.map +1 -0
  336. package/dist/instrumentation/langchain/wrapper.d.ts +41 -0
  337. package/dist/instrumentation/langchain/wrapper.js +1235 -0
  338. package/dist/instrumentation/langchain/wrapper.js.map +1 -0
  339. package/dist/instrumentation/langgraph/index.d.ts +12 -0
  340. package/dist/instrumentation/langgraph/index.js +99 -0
  341. package/dist/instrumentation/langgraph/index.js.map +1 -0
  342. package/dist/instrumentation/langgraph/wrapper.d.ts +20 -0
  343. package/dist/instrumentation/langgraph/wrapper.js +620 -0
  344. package/dist/instrumentation/langgraph/wrapper.js.map +1 -0
  345. package/dist/instrumentation/letta/index.d.ts +10 -0
  346. package/dist/instrumentation/letta/index.js +122 -0
  347. package/dist/instrumentation/letta/index.js.map +1 -0
  348. package/dist/instrumentation/letta/utils.d.ts +24 -0
  349. package/dist/instrumentation/letta/utils.js +343 -0
  350. package/dist/instrumentation/letta/utils.js.map +1 -0
  351. package/dist/instrumentation/letta/wrapper.d.ts +37 -0
  352. package/dist/instrumentation/letta/wrapper.js +180 -0
  353. package/dist/instrumentation/letta/wrapper.js.map +1 -0
  354. package/dist/instrumentation/llamaindex/index.d.ts +36 -0
  355. package/dist/instrumentation/llamaindex/index.js +221 -0
  356. package/dist/instrumentation/llamaindex/index.js.map +1 -0
  357. package/dist/instrumentation/llamaindex/wrapper.d.ts +36 -0
  358. package/dist/instrumentation/llamaindex/wrapper.js +811 -0
  359. package/dist/instrumentation/llamaindex/wrapper.js.map +1 -0
  360. package/dist/instrumentation/mcp/index.d.ts +20 -0
  361. package/dist/instrumentation/mcp/index.js +282 -0
  362. package/dist/instrumentation/mcp/index.js.map +1 -0
  363. package/dist/instrumentation/mcp/wrapper.d.ts +72 -0
  364. package/dist/instrumentation/mcp/wrapper.js +571 -0
  365. package/dist/instrumentation/mcp/wrapper.js.map +1 -0
  366. package/dist/instrumentation/mem0/index.d.ts +17 -0
  367. package/dist/instrumentation/mem0/index.js +113 -0
  368. package/dist/instrumentation/mem0/index.js.map +1 -0
  369. package/dist/instrumentation/mem0/wrapper.d.ts +37 -0
  370. package/dist/instrumentation/mem0/wrapper.js +298 -0
  371. package/dist/instrumentation/mem0/wrapper.js.map +1 -0
  372. package/dist/instrumentation/milvus/index.d.ts +11 -0
  373. package/dist/instrumentation/milvus/index.js +67 -0
  374. package/dist/instrumentation/milvus/index.js.map +1 -0
  375. package/dist/instrumentation/milvus/wrapper.d.ts +15 -0
  376. package/dist/instrumentation/milvus/wrapper.js +219 -0
  377. package/dist/instrumentation/milvus/wrapper.js.map +1 -0
  378. package/dist/instrumentation/mistral/index.d.ts +11 -0
  379. package/dist/instrumentation/mistral/index.js +66 -0
  380. package/dist/instrumentation/mistral/index.js.map +1 -0
  381. package/dist/instrumentation/mistral/wrapper.d.ts +49 -0
  382. package/dist/instrumentation/mistral/wrapper.js +482 -0
  383. package/dist/instrumentation/mistral/wrapper.js.map +1 -0
  384. package/dist/instrumentation/ollama/index.d.ts +11 -0
  385. package/dist/instrumentation/ollama/index.js +72 -0
  386. package/dist/instrumentation/ollama/index.js.map +1 -0
  387. package/dist/instrumentation/ollama/wrapper.d.ts +73 -0
  388. package/dist/instrumentation/ollama/wrapper.js +629 -0
  389. package/dist/instrumentation/ollama/wrapper.js.map +1 -0
  390. package/dist/instrumentation/openai/index.d.ts +11 -0
  391. package/dist/instrumentation/openai/index.js +79 -0
  392. package/dist/instrumentation/openai/index.js.map +1 -0
  393. package/dist/instrumentation/openai/wrapper.d.ts +80 -0
  394. package/dist/instrumentation/openai/wrapper.js +1121 -0
  395. package/dist/instrumentation/openai/wrapper.js.map +1 -0
  396. package/dist/instrumentation/openai-agents/index.d.ts +20 -0
  397. package/dist/instrumentation/openai-agents/index.js +174 -0
  398. package/dist/instrumentation/openai-agents/index.js.map +1 -0
  399. package/dist/instrumentation/openai-agents/processor.d.ts +35 -0
  400. package/dist/instrumentation/openai-agents/processor.js +249 -0
  401. package/dist/instrumentation/openai-agents/processor.js.map +1 -0
  402. package/dist/instrumentation/openai-agents/utils.d.ts +20 -0
  403. package/dist/instrumentation/openai-agents/utils.js +624 -0
  404. package/dist/instrumentation/openai-agents/utils.js.map +1 -0
  405. package/dist/instrumentation/pg/index.d.ts +20 -0
  406. package/dist/instrumentation/pg/index.js +74 -0
  407. package/dist/instrumentation/pg/index.js.map +1 -0
  408. package/dist/instrumentation/pg/wrapper.d.ts +66 -0
  409. package/dist/instrumentation/pg/wrapper.js +441 -0
  410. package/dist/instrumentation/pg/wrapper.js.map +1 -0
  411. package/dist/instrumentation/pinecone/index.d.ts +11 -0
  412. package/dist/instrumentation/pinecone/index.js +79 -0
  413. package/dist/instrumentation/pinecone/index.js.map +1 -0
  414. package/dist/instrumentation/pinecone/wrapper.d.ts +14 -0
  415. package/dist/instrumentation/pinecone/wrapper.js +198 -0
  416. package/dist/instrumentation/pinecone/wrapper.js.map +1 -0
  417. package/dist/instrumentation/qdrant/index.d.ts +11 -0
  418. package/dist/instrumentation/qdrant/index.js +67 -0
  419. package/dist/instrumentation/qdrant/index.js.map +1 -0
  420. package/dist/instrumentation/qdrant/wrapper.d.ts +14 -0
  421. package/dist/instrumentation/qdrant/wrapper.js +213 -0
  422. package/dist/instrumentation/qdrant/wrapper.js.map +1 -0
  423. package/dist/instrumentation/replicate/index.d.ts +11 -0
  424. package/dist/instrumentation/replicate/index.js +57 -0
  425. package/dist/instrumentation/replicate/index.js.map +1 -0
  426. package/dist/instrumentation/replicate/wrapper.d.ts +28 -0
  427. package/dist/instrumentation/replicate/wrapper.js +242 -0
  428. package/dist/instrumentation/replicate/wrapper.js.map +1 -0
  429. package/dist/instrumentation/strands/index.d.ts +21 -0
  430. package/dist/instrumentation/strands/index.js +83 -0
  431. package/dist/instrumentation/strands/index.js.map +1 -0
  432. package/dist/instrumentation/strands/processor.d.ts +51 -0
  433. package/dist/instrumentation/strands/processor.js +625 -0
  434. package/dist/instrumentation/strands/processor.js.map +1 -0
  435. package/dist/instrumentation/strands/utils.d.ts +24 -0
  436. package/dist/instrumentation/strands/utils.js +373 -0
  437. package/dist/instrumentation/strands/utils.js.map +1 -0
  438. package/dist/instrumentation/together/index.d.ts +11 -0
  439. package/dist/instrumentation/together/index.js +43 -0
  440. package/dist/instrumentation/together/index.js.map +1 -0
  441. package/dist/instrumentation/together/wrapper.d.ts +48 -0
  442. package/dist/instrumentation/together/wrapper.js +409 -0
  443. package/dist/instrumentation/together/wrapper.js.map +1 -0
  444. package/dist/instrumentation/transformers/index.d.ts +35 -0
  445. package/dist/instrumentation/transformers/index.js +119 -0
  446. package/dist/instrumentation/transformers/index.js.map +1 -0
  447. package/dist/instrumentation/transformers/wrapper.d.ts +49 -0
  448. package/dist/instrumentation/transformers/wrapper.js +472 -0
  449. package/dist/instrumentation/transformers/wrapper.js.map +1 -0
  450. package/dist/instrumentation/vercel-ai/index.d.ts +10 -0
  451. package/dist/instrumentation/vercel-ai/index.js +59 -0
  452. package/dist/instrumentation/vercel-ai/index.js.map +1 -0
  453. package/dist/instrumentation/vercel-ai/wrapper.d.ts +50 -0
  454. package/dist/instrumentation/vercel-ai/wrapper.js +539 -0
  455. package/dist/instrumentation/vercel-ai/wrapper.js.map +1 -0
  456. package/dist/instrumentation/vertexai/index.d.ts +11 -0
  457. package/dist/instrumentation/vertexai/index.js +70 -0
  458. package/dist/instrumentation/vertexai/index.js.map +1 -0
  459. package/dist/instrumentation/vertexai/wrapper.d.ts +67 -0
  460. package/dist/instrumentation/vertexai/wrapper.js +530 -0
  461. package/dist/instrumentation/vertexai/wrapper.js.map +1 -0
  462. package/dist/instrumentation/vllm/index.d.ts +13 -0
  463. package/dist/instrumentation/vllm/index.js +67 -0
  464. package/dist/instrumentation/vllm/index.js.map +1 -0
  465. package/dist/instrumentation/vllm/wrapper.d.ts +60 -0
  466. package/dist/instrumentation/vllm/wrapper.js +482 -0
  467. package/dist/instrumentation/vllm/wrapper.js.map +1 -0
  468. package/dist/llm/anthropic.d.ts +5 -0
  469. package/dist/llm/anthropic.js +39 -0
  470. package/dist/llm/anthropic.js.map +1 -0
  471. package/dist/llm/index.d.ts +10 -0
  472. package/dist/llm/index.js +93 -0
  473. package/dist/llm/index.js.map +1 -0
  474. package/dist/llm/openai.d.ts +6 -0
  475. package/dist/llm/openai.js +52 -0
  476. package/dist/llm/openai.js.map +1 -0
  477. package/dist/llm/providers.d.ts +7 -0
  478. package/dist/llm/providers.js +10 -0
  479. package/dist/llm/providers.js.map +1 -0
  480. package/dist/manual-trace.d.ts +40 -0
  481. package/dist/manual-trace.js +103 -0
  482. package/dist/manual-trace.js.map +1 -0
  483. package/dist/otel/__tests__/metrics.test.d.ts +1 -0
  484. package/dist/otel/__tests__/metrics.test.js +40 -0
  485. package/dist/otel/__tests__/metrics.test.js.map +1 -0
  486. package/dist/otel/events.d.ts +11 -0
  487. package/dist/otel/events.js +74 -0
  488. package/dist/otel/events.js.map +1 -0
  489. package/dist/otel/metrics.d.ts +35 -0
  490. package/dist/otel/metrics.js +219 -0
  491. package/dist/otel/metrics.js.map +1 -0
  492. package/dist/otel/tracing.d.ts +12 -0
  493. package/dist/otel/tracing.js +93 -0
  494. package/dist/otel/tracing.js.map +1 -0
  495. package/dist/otel/utils.d.ts +11 -0
  496. package/dist/otel/utils.js +34 -0
  497. package/dist/otel/utils.js.map +1 -0
  498. package/dist/pricing.json +951 -0
  499. package/dist/prompt-hub.d.ts +4 -0
  500. package/dist/prompt-hub.js +66 -0
  501. package/dist/prompt-hub.js.map +1 -0
  502. package/dist/register.d.ts +4 -0
  503. package/dist/register.js +52 -0
  504. package/dist/register.js.map +1 -0
  505. package/dist/score/__tests__/score.test.d.ts +1 -0
  506. package/dist/score/__tests__/score.test.js +143 -0
  507. package/dist/score/__tests__/score.test.js.map +1 -0
  508. package/dist/score/index.d.ts +2 -0
  509. package/dist/score/index.js +6 -0
  510. package/dist/score/index.js.map +1 -0
  511. package/dist/score/score.d.ts +15 -0
  512. package/dist/score/score.js +135 -0
  513. package/dist/score/score.js.map +1 -0
  514. package/dist/semantic-convention.d.ts +555 -0
  515. package/dist/semantic-convention.js +630 -0
  516. package/dist/semantic-convention.js.map +1 -0
  517. package/dist/types.d.ts +131 -0
  518. package/dist/types.js +3 -0
  519. package/dist/types.js.map +1 -0
  520. package/package.json +136 -0
@@ -0,0 +1,363 @@
1
+ "use strict";
2
+ /**
3
+ * Auto-guard integration layer.
4
+ *
5
+ * setupAutoGuards wraps LLM provider methods so that guards run on every
6
+ * call without any changes to existing instrumentation code.
7
+ *
8
+ * Call chain after setup:
9
+ *
10
+ * User call
11
+ * -> Guard wrapper (preflight -> may deny/redact)
12
+ * -> Instrumentor wrapper (OTel telemetry)
13
+ * -> Original SDK method (actual API call)
14
+ * <- Instrumentor wrapper
15
+ * <- Guard wrapper (postflight -> may redact/warn)
16
+ * <- Returns to user
17
+ *
18
+ * **Streaming limitation**: postflight guards require a complete response
19
+ * object with `choices[].message.content` (or equivalent). Streaming
20
+ * responses yield incremental chunks that extractors cannot fully
21
+ * reassemble, so postflight guards are silently skipped for streamed
22
+ * completions. Preflight guards always run.
23
+ *
24
+ * Must stay in sync with: sdk/python/src/shield360/guard/_integration.py
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.extractOpenAIInput = extractOpenAIInput;
28
+ exports.extractOpenAIOutput = extractOpenAIOutput;
29
+ exports.extractAnthropicInput = extractAnthropicInput;
30
+ exports.extractAnthropicOutput = extractAnthropicOutput;
31
+ exports.extractGenericInput = extractGenericInput;
32
+ exports.extractGenericOutput = extractGenericOutput;
33
+ exports.applyPreflight = applyPreflight;
34
+ exports.applyPostflight = applyPostflight;
35
+ exports.setupAutoGuards = setupAutoGuards;
36
+ const base_1 = require("./base");
37
+ const pipeline_1 = require("./pipeline");
38
+ function extractOpenAIInput(kwargs) {
39
+ const messages = kwargs.messages || kwargs.input || [];
40
+ if (typeof messages === 'string')
41
+ return messages;
42
+ const parts = [];
43
+ if (Array.isArray(messages)) {
44
+ for (const m of messages) {
45
+ if (typeof m === 'object' && m !== null) {
46
+ const content = m.content ?? '';
47
+ if (typeof content === 'string')
48
+ parts.push(content);
49
+ }
50
+ else if (typeof m === 'string') {
51
+ parts.push(m);
52
+ }
53
+ }
54
+ }
55
+ return parts.join(' ');
56
+ }
57
+ function extractOpenAIOutput(response) {
58
+ try {
59
+ const choices = response?.choices;
60
+ if (choices && Array.isArray(choices)) {
61
+ return choices
62
+ .map((c) => c?.message?.content || '')
63
+ .join(' ');
64
+ }
65
+ const output = response?.output;
66
+ if (output && Array.isArray(output)) {
67
+ const parts = [];
68
+ for (const item of output) {
69
+ const content = item?.content;
70
+ if (Array.isArray(content)) {
71
+ for (const block of content) {
72
+ const text = block?.text;
73
+ if (text)
74
+ parts.push(text);
75
+ }
76
+ }
77
+ else if (typeof content === 'string') {
78
+ parts.push(content);
79
+ }
80
+ }
81
+ return parts.join(' ');
82
+ }
83
+ }
84
+ catch {
85
+ // ignore
86
+ }
87
+ return '';
88
+ }
89
+ function extractAnthropicInput(kwargs) {
90
+ const messages = kwargs.messages || [];
91
+ const parts = [];
92
+ if (Array.isArray(messages)) {
93
+ for (const m of messages) {
94
+ if (typeof m === 'object' && m !== null) {
95
+ const content = m.content ?? '';
96
+ if (typeof content === 'string') {
97
+ parts.push(content);
98
+ }
99
+ else if (Array.isArray(content)) {
100
+ for (const block of content) {
101
+ if (typeof block === 'object' && block?.type === 'text') {
102
+ parts.push(block.text || '');
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ return parts.join(' ');
110
+ }
111
+ function extractAnthropicOutput(response) {
112
+ try {
113
+ const content = response?.content;
114
+ if (Array.isArray(content)) {
115
+ const parts = [];
116
+ for (const block of content) {
117
+ const text = block?.text;
118
+ if (text)
119
+ parts.push(text);
120
+ }
121
+ return parts.join(' ');
122
+ }
123
+ }
124
+ catch {
125
+ // ignore
126
+ }
127
+ return '';
128
+ }
129
+ function extractGenericInput(kwargs) {
130
+ for (const key of ['messages', 'message', 'prompt', 'input', 'text']) {
131
+ const val = kwargs[key];
132
+ if (val == null)
133
+ continue;
134
+ if (typeof val === 'string')
135
+ return val;
136
+ if (Array.isArray(val)) {
137
+ const parts = [];
138
+ for (const item of val) {
139
+ if (typeof item === 'string') {
140
+ parts.push(item);
141
+ }
142
+ else if (typeof item === 'object' && item !== null) {
143
+ parts.push(item.content || '');
144
+ }
145
+ }
146
+ return parts.join(' ');
147
+ }
148
+ }
149
+ return '';
150
+ }
151
+ function extractGenericOutput(response) {
152
+ try {
153
+ const choices = response?.choices;
154
+ if (choices && Array.isArray(choices)) {
155
+ return choices
156
+ .map((c) => c?.message?.content || '')
157
+ .join(' ');
158
+ }
159
+ }
160
+ catch {
161
+ // ignore
162
+ }
163
+ try {
164
+ const content = response?.content;
165
+ if (typeof content === 'string')
166
+ return content;
167
+ if (Array.isArray(content)) {
168
+ const parts = [];
169
+ for (const block of content) {
170
+ const text = block?.text;
171
+ if (text)
172
+ parts.push(text);
173
+ }
174
+ if (parts.length)
175
+ return parts.join(' ');
176
+ }
177
+ }
178
+ catch {
179
+ // ignore
180
+ }
181
+ try {
182
+ if (response?.text)
183
+ return response.text;
184
+ }
185
+ catch {
186
+ // ignore
187
+ }
188
+ return '';
189
+ }
190
+ const GUARDED_METHODS = [
191
+ // OpenAI
192
+ { npmPackage: 'openai', protoPath: ['OpenAI', 'Chat', 'Completions', 'prototype'], methodName: 'create', extractInput: extractOpenAIInput, extractOutput: extractOpenAIOutput },
193
+ { npmPackage: 'openai', protoPath: ['OpenAI', 'Responses', 'prototype'], methodName: 'create', extractInput: extractOpenAIInput, extractOutput: extractOpenAIOutput },
194
+ // Anthropic
195
+ { npmPackage: '@anthropic-ai/sdk', protoPath: ['Anthropic', 'Messages', 'prototype'], methodName: 'create', extractInput: extractAnthropicInput, extractOutput: extractAnthropicOutput },
196
+ // Groq
197
+ { npmPackage: 'groq-sdk', protoPath: ['Groq', 'Chat', 'Completions', 'prototype'], methodName: 'create', extractInput: extractGenericInput, extractOutput: extractGenericOutput },
198
+ // Mistral
199
+ { npmPackage: '@mistralai/mistralai', protoPath: ['Mistral', 'chat', 'prototype'], methodName: 'complete', extractInput: extractGenericInput, extractOutput: extractGenericOutput },
200
+ // Cohere
201
+ { npmPackage: 'cohere-ai', protoPath: ['CohereClientV2', 'prototype'], methodName: 'chat', extractInput: extractGenericInput, extractOutput: extractGenericOutput },
202
+ // Together
203
+ { npmPackage: 'together-ai', protoPath: ['Together', 'Chat', 'Completions', 'prototype'], methodName: 'create', extractInput: extractGenericInput, extractOutput: extractGenericOutput },
204
+ // Bedrock (AWS)
205
+ { npmPackage: '@aws-sdk/client-bedrock-runtime', protoPath: ['BedrockRuntimeClient', 'prototype'], methodName: 'send', extractInput: extractGenericInput, extractOutput: extractGenericOutput },
206
+ // Google Generative AI
207
+ { npmPackage: '@google/generative-ai', protoPath: ['GenerativeModel', 'prototype'], methodName: 'generateContent', extractInput: extractGenericInput, extractOutput: extractGenericOutput },
208
+ ];
209
+ // ---------------------------------------------------------------------------
210
+ // Preflight / Postflight
211
+ // ---------------------------------------------------------------------------
212
+ /**
213
+ * Redact a prompt or message list one message (and text block) at a time.
214
+ *
215
+ * The decision to redact is made on all the input together, but each message
216
+ * is rewritten on its own: writing the joined text into one message would copy
217
+ * the system prompt and earlier turns into it, and leave the originals --
218
+ * secrets included -- untouched.
219
+ */
220
+ function redactMessages(pipeline, value, phase) {
221
+ if (typeof value === 'string')
222
+ return pipeline.redact(value, phase);
223
+ if (!Array.isArray(value))
224
+ return value;
225
+ return value.map((m) => {
226
+ if (typeof m === 'string')
227
+ return pipeline.redact(m, phase);
228
+ if (typeof m !== 'object' || m === null)
229
+ return m;
230
+ if (typeof m.content === 'string')
231
+ return { ...m, content: pipeline.redact(m.content, phase) };
232
+ if (Array.isArray(m.content)) {
233
+ return {
234
+ ...m,
235
+ content: m.content.map((b) => b && typeof b === 'object' && typeof b.text === 'string'
236
+ ? { ...b, text: pipeline.redact(b.text, phase) }
237
+ : b),
238
+ };
239
+ }
240
+ return m;
241
+ });
242
+ }
243
+ /** @internal exported for tests */
244
+ function applyPreflight(pipeline, kwargs, extractInput) {
245
+ const inputText = extractInput(kwargs);
246
+ if (!inputText)
247
+ return kwargs;
248
+ const result = pipeline.evaluate(inputText, 'preflight');
249
+ if (result.action === base_1.GuardAction.DENY) {
250
+ throw new base_1.GuardDeniedError(result);
251
+ }
252
+ if (result.action === base_1.GuardAction.REDACT && result.transformedText !== null) {
253
+ for (const key of ['messages', 'input', 'prompt', 'text']) {
254
+ if (key in kwargs) {
255
+ return { ...kwargs, [key]: redactMessages(pipeline, kwargs[key], 'preflight') };
256
+ }
257
+ }
258
+ }
259
+ return kwargs;
260
+ }
261
+ function redactTextField(pipeline, obj, field) {
262
+ if (obj && typeof obj[field] === 'string' && obj[field]) {
263
+ obj[field] = pipeline.redact(obj[field], 'postflight');
264
+ }
265
+ }
266
+ /**
267
+ * Each choice and text block is redacted on its own, so none is left holding
268
+ * the original text or another block's.
269
+ *
270
+ * @internal exported for tests
271
+ */
272
+ function applyPostflight(pipeline, response, extractOutput) {
273
+ const outputText = extractOutput(response);
274
+ if (!outputText)
275
+ return response;
276
+ const result = pipeline.evaluate(outputText, 'postflight');
277
+ if (result.action === base_1.GuardAction.DENY) {
278
+ throw new base_1.GuardDeniedError(result);
279
+ }
280
+ if (result.action === base_1.GuardAction.REDACT && result.transformedText !== null) {
281
+ try {
282
+ if (Array.isArray(response?.choices) && response.choices.length > 0) {
283
+ // OpenAI chat completions.
284
+ for (const choice of response.choices)
285
+ redactTextField(pipeline, choice?.message, 'content');
286
+ }
287
+ else if (Array.isArray(response?.output) && response.output.length > 0) {
288
+ // OpenAI Responses API: output items hold text blocks.
289
+ for (const item of response.output) {
290
+ if (Array.isArray(item?.content)) {
291
+ for (const block of item.content)
292
+ redactTextField(pipeline, block, 'text');
293
+ }
294
+ }
295
+ if (typeof response.output_text === 'string')
296
+ redactTextField(pipeline, response, 'output_text');
297
+ }
298
+ else if (Array.isArray(response?.content) && response.content.length > 0) {
299
+ // Anthropic messages.
300
+ for (const block of response.content)
301
+ redactTextField(pipeline, block, 'text');
302
+ }
303
+ else {
304
+ redactTextField(pipeline, response, 'text');
305
+ }
306
+ }
307
+ catch {
308
+ // best-effort redaction
309
+ }
310
+ }
311
+ return response;
312
+ }
313
+ // ---------------------------------------------------------------------------
314
+ // Prototype resolver
315
+ // ---------------------------------------------------------------------------
316
+ function resolveProto(moduleExports, protoPath) {
317
+ let obj = moduleExports;
318
+ for (const key of protoPath) {
319
+ if (obj == null)
320
+ return null;
321
+ obj = obj[key];
322
+ }
323
+ return obj;
324
+ }
325
+ // ---------------------------------------------------------------------------
326
+ // Public entry point
327
+ // ---------------------------------------------------------------------------
328
+ function setupAutoGuards(guards, failOpen = true) {
329
+ const pipeline = new pipeline_1.Pipeline({ guards, failOpen });
330
+ try {
331
+ const Shield360Config = require('../config').default;
332
+ Shield360Config.guardPipeline = pipeline;
333
+ }
334
+ catch {
335
+ // config not available
336
+ }
337
+ let wrappedCount = 0;
338
+ for (const { npmPackage, protoPath, methodName, extractInput, extractOutput } of GUARDED_METHODS) {
339
+ try {
340
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
341
+ const mod = require(npmPackage);
342
+ const proto = resolveProto(mod, protoPath);
343
+ if (!proto || typeof proto[methodName] !== 'function')
344
+ continue;
345
+ const original = proto[methodName];
346
+ proto[methodName] = async function (...args) {
347
+ let params = args[0] || {};
348
+ params = applyPreflight(pipeline, params, extractInput);
349
+ args[0] = params;
350
+ const response = await original.apply(this, args);
351
+ return applyPostflight(pipeline, response, extractOutput);
352
+ };
353
+ wrappedCount++;
354
+ }
355
+ catch {
356
+ // module not installed, skip silently
357
+ }
358
+ }
359
+ if (wrappedCount > 0) {
360
+ console.log(`[shield360] Auto-guards: wrapped ${wrappedCount}/${GUARDED_METHODS.length} provider methods`);
361
+ }
362
+ }
363
+ //# sourceMappingURL=integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.js","sourceRoot":"","sources":["../../src/guard/integration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAWH,gDAeC;AAED,kDA4BC;AAED,sDAoBC;AAED,wDAeC;AAED,kDAkBC;AAED,oDA+BC;AAoED,wCAuBC;AAcD,0CAuCC;AAmBD,0CAyCC;AA9VD,iCAA8D;AAC9D,yCAAsC;AAQtC,SAAgB,kBAAkB,CAAC,MAA2B;IAC5D,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;IACvD,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAClD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;gBACxC,MAAM,OAAO,GAAG,CAAC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B,CAAC;QAAC,MAAM,CAAC;YACP,sCAAsC;QACxC,CAAC;IACH,CAAC;IAED,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,oCAAoC,YAAY,IAAI,eAAe,CAAC,MAAM,mBAAmB,CAAC,CAAC;IAC7G,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Content moderation guard -- profanity & toxicity detection.
3
+ *
4
+ * Uses local keyword/regex patterns.
5
+ *
6
+ * Patterns must stay in sync with: sdk/python/src/shield360/guard/moderation.py
7
+ */
8
+ import { Guard, GuardPhase, GuardResult, GuardOptions } from './base';
9
+ export interface ModerationOptions extends GuardOptions {
10
+ customWords?: string[];
11
+ }
12
+ export declare class Moderation extends Guard {
13
+ readonly name = "moderation";
14
+ readonly phases: GuardPhase[];
15
+ private readonly _profanityRe;
16
+ constructor(opts?: ModerationOptions);
17
+ evaluate(text: string): GuardResult;
18
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * Content moderation guard -- profanity & toxicity detection.
4
+ *
5
+ * Uses local keyword/regex patterns.
6
+ *
7
+ * Patterns must stay in sync with: sdk/python/src/shield360/guard/moderation.py
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Moderation = void 0;
11
+ const base_1 = require("./base");
12
+ const BUILTIN_WORDS = [
13
+ 'fuck', 'shit', 'ass', 'bitch', 'damn', 'bastard', 'crap',
14
+ 'dick', 'piss', 'cock', 'cunt', 'slut', 'whore',
15
+ 'nigger', 'nigga', 'faggot', 'retard', 'kike', 'spic',
16
+ ];
17
+ const TOXICITY_PATTERNS = [
18
+ /\b(?:kill\s+yourself|kys|go\s+die|hope\s+you\s+die)\b/i,
19
+ /\b(?:i(?:'ll| will)\s+(?:kill|hurt|destroy)\s+you)\b/i,
20
+ ];
21
+ function buildProfanityPattern(words) {
22
+ const escaped = words.map((w) => w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
23
+ return new RegExp('\\b(?:' + escaped.join('|') + ')\\b', 'gi');
24
+ }
25
+ class Moderation extends base_1.Guard {
26
+ constructor(opts = {}) {
27
+ super({ action: opts.action ?? 'warn', maxScanLength: opts.maxScanLength });
28
+ this.name = 'moderation';
29
+ this.phases = [base_1.GuardPhase.PREFLIGHT, base_1.GuardPhase.POSTFLIGHT];
30
+ const allWords = [...BUILTIN_WORDS, ...(opts.customWords || [])];
31
+ this._profanityRe = buildProfanityPattern(allWords);
32
+ }
33
+ evaluate(text) {
34
+ const profanityMatches = text.match(this._profanityRe);
35
+ const toxicityHits = TOXICITY_PATTERNS.some((pat) => pat.test(text));
36
+ if (!profanityMatches && !toxicityHits) {
37
+ return (0, base_1.makeGuardResult)({ guardName: this.name });
38
+ }
39
+ const classifications = [];
40
+ if (profanityMatches)
41
+ classifications.push('profanity');
42
+ if (toxicityHits)
43
+ classifications.push('toxicity');
44
+ const classification = classifications.join(', ');
45
+ const score = toxicityHits ? 0.95 : 0.7;
46
+ let transformedText = null;
47
+ if (this._action === 'redact') {
48
+ transformedText = text.replace(this._profanityRe, '[REDACTED:profanity]');
49
+ }
50
+ return (0, base_1.makeGuardResult)({
51
+ action: this._action,
52
+ score,
53
+ guardName: this.name,
54
+ classification,
55
+ explanation: `Moderation flag: ${classification}`,
56
+ transformedText,
57
+ });
58
+ }
59
+ }
60
+ exports.Moderation = Moderation;
61
+ //# sourceMappingURL=moderation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moderation.js","sourceRoot":"","sources":["../../src/guard/moderation.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,iCAAuF;AAEvF,MAAM,aAAa,GAAa;IAC9B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IACzD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAC/C,QAAQ,EAAE,OAAO,EAAE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AAS,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,eAAe,GAAa,EAAE,CAAC;QACrC,IAAI,gBAAgB;YAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxD,IAAI,YAAY;YAAE,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEnD,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;QAExC,IAAI,eAAe,GAAkB,IAAI,CAAC;QAC1C,IAAI,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC9B,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,IAAA,sBAAe,EAAC;YACrB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,KAAK;YACL,SAAS,EAAE,IAAI,CAAC,IAAI;YACpB,cAAc;YACd,WAAW,EAAE,oBAAoB,cAAc,EAAE;YACjD,eAAe;SAChB,CAAC,CAAC;IACL,CAAC;CACF;AAzCD,gCAyCC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * PII guard -- detects and optionally redacts personally identifiable
3
+ * information, API keys, and secrets using regex patterns.
4
+ *
5
+ * Patterns must stay in sync with: sdk/python/src/shield360/guard/pii.py
6
+ */
7
+ import { Guard, GuardPhase, GuardResult, GuardOptions } from './base';
8
+ export interface PIIOptions extends GuardOptions {
9
+ customPatterns?: Record<string, string>;
10
+ }
11
+ export declare class PII extends Guard {
12
+ readonly name = "pii";
13
+ readonly phases: GuardPhase[];
14
+ private readonly _allPatterns;
15
+ constructor(opts?: PIIOptions);
16
+ evaluate(text: string): GuardResult;
17
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ /**
3
+ * PII guard -- detects and optionally redacts personally identifiable
4
+ * information, API keys, and secrets using regex patterns.
5
+ *
6
+ * Patterns must stay in sync with: sdk/python/src/shield360/guard/pii.py
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.PII = void 0;
10
+ const base_1 = require("./base");
11
+ const findings_1 = require("./findings");
12
+ // ---- API keys / tokens ----
13
+ const PATTERNS = [
14
+ { label: 'openai-api-key', regex: /sk-(?:proj-)?[A-Za-z0-9_-]{20,}/ },
15
+ { label: 'anthropic-api-key', regex: /sk-ant-[A-Za-z0-9_-]{20,}/ },
16
+ { label: 'aws-access-key', regex: /(?<![A-Za-z0-9/+=])AKIA[0-9A-Z]{16}(?![A-Za-z0-9/+=])/ },
17
+ { label: 'gcp-api-key', regex: /AIza[0-9A-Za-z_-]{35}/ },
18
+ { label: 'github-token', regex: /(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{36,}/ },
19
+ { label: 'github-fine-grained', regex: /github_pat_[A-Za-z0-9_]{22,}/ },
20
+ { label: 'stripe-key', regex: /(?:sk|pk)_(?:live|test)_[A-Za-z0-9]{24,}/ },
21
+ { label: 'slack-token', regex: /xox[bpoas]-[A-Za-z0-9-]{10,}/ },
22
+ { label: 'slack-webhook', regex: /https:\/\/hooks\.slack\.com\/services\/T[A-Za-z0-9]+\/B[A-Za-z0-9]+\/[A-Za-z0-9]+/ },
23
+ { label: 'twilio-api-key', regex: /SK[0-9a-fA-F]{32}/ },
24
+ { label: 'sendgrid-api-key', regex: /SG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}/ },
25
+ { label: 'mailgun-api-key', regex: /key-[0-9a-zA-Z]{32}/ },
26
+ { label: 'azure-key', regex: /[0-9a-f]{32}/ },
27
+ { label: 'heroku-api-key', regex: /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ },
28
+ // ---- PII ----
29
+ { label: 'email', regex: /[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,}/ },
30
+ { label: 'phone-us', regex: /(?<!\d)(?:\+?1[-.\s]?)?(?:\(?\d{3}\)?[-.\s]?)\d{3}[-.\s]?\d{4}(?!\d)/ },
31
+ { label: 'ssn', regex: /(?<!\d)\d{3}-\d{2}-\d{4}(?!\d)/ },
32
+ { label: 'credit-card', regex: /(?<!\d)(?:4\d{3}|5[1-5]\d{2}|3[47]\d{2}|6(?:011|5\d{2}))[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}(?!\d)/ },
33
+ { label: 'ipv4', regex: /(?<!\d)(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)){3}(?!\d)/ },
34
+ // ---- Secrets / credentials ----
35
+ { label: 'bearer-token', regex: /Bearer\s+[A-Za-z0-9_\-.~+/]+=*/i },
36
+ { label: 'basic-auth', regex: /Basic\s+[A-Za-z0-9+/]+=*/i },
37
+ { label: 'private-key', regex: /-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----/ },
38
+ { label: 'connection-string', regex: /(?:mongodb(?:\+srv)?|postgres(?:ql)?|mysql|redis|amqp):\/\/\S+/ },
39
+ { label: 'env-secret', regex: /(?:password|secret|token|api_key|apikey)\s*[=:]\s*\S+/i },
40
+ ];
41
+ class PII extends base_1.Guard {
42
+ constructor(opts = {}) {
43
+ super({ action: opts.action ?? 'redact', maxScanLength: opts.maxScanLength });
44
+ this.name = 'pii';
45
+ this.phases = [base_1.GuardPhase.PREFLIGHT, base_1.GuardPhase.POSTFLIGHT];
46
+ const extra = [];
47
+ if (opts.customPatterns) {
48
+ for (const [label, pat] of Object.entries(opts.customPatterns)) {
49
+ extra.push({ label, regex: new RegExp(pat, 'gi') });
50
+ }
51
+ }
52
+ this._allPatterns = [
53
+ ...PATTERNS.map(({ label, regex }) => ({
54
+ label,
55
+ regex: new RegExp(regex.source, regex.flags.includes('g') ? regex.flags : regex.flags + 'g'),
56
+ })),
57
+ ...extra,
58
+ ];
59
+ }
60
+ evaluate(text) {
61
+ const matches = [];
62
+ for (const { label, regex } of this._allPatterns) {
63
+ regex.lastIndex = 0;
64
+ let m;
65
+ while ((m = regex.exec(text)) !== null) {
66
+ matches.push({ label, start: m.index, end: m.index + m[0].length, value: m[0] });
67
+ }
68
+ }
69
+ if (matches.length === 0) {
70
+ return (0, base_1.makeGuardResult)({ guardName: this.name });
71
+ }
72
+ const labels = [...new Set(matches.map((m) => m.label))].sort();
73
+ const classification = labels.join(', ');
74
+ const bestScore = Math.min(1.0, matches.length * 0.2 + 0.5);
75
+ let transformedText = null;
76
+ if (this._action === base_1.GuardAction.REDACT) {
77
+ // Patterns can match overlapping spans of the same text. Every span's offsets
78
+ // refer to the original string, so replacing them one at a time lets an earlier
79
+ // replacement resize the string out from under a later one -- the later slice
80
+ // then stops short and leaves the tail of the value in the output. Merge
81
+ // overlapping spans first so each replacement covers a region no other touches.
82
+ const ordered = matches
83
+ .map((match, index) => ({ ...match, index }))
84
+ .sort((a, b) => a.start - b.start || b.end - a.end || b.index - a.index);
85
+ const spans = [];
86
+ for (const { label, start, end } of ordered) {
87
+ const previous = spans[spans.length - 1];
88
+ if (previous && start < previous.end) {
89
+ previous.end = Math.max(previous.end, end);
90
+ }
91
+ else {
92
+ spans.push({ label, start, end });
93
+ }
94
+ }
95
+ let resultText = text;
96
+ for (let i = spans.length - 1; i >= 0; i--) {
97
+ const { label, start, end } = spans[i];
98
+ resultText = resultText.slice(0, start) + `[REDACTED:${label}]` + resultText.slice(end);
99
+ }
100
+ transformedText = resultText;
101
+ }
102
+ return (0, base_1.makeGuardResult)({
103
+ action: this._action,
104
+ score: Math.round(bestScore * 100) / 100,
105
+ guardName: this.name,
106
+ classification,
107
+ explanation: `Detected ${matches.length} PII/secret match(es): ${classification}`,
108
+ transformedText,
109
+ findings: (0, findings_1.collectFindings)(matches.map((m) => [m.label, m.value])),
110
+ });
111
+ }
112
+ }
113
+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AU,GAAG,IAAI,CAAC;YACtB,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC3C,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACvC,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,aAAa,KAAK,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC1F,CAAC;YACD,eAAe,GAAG,UAAU,CAAC;QAC/B,CAAC;QAED,OAAO,IAAA,sBAAe,EAAC;YACrB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,GAAG;YACxC,SAAS,EAAE,IAAI,CAAC,IAAI;YACpB,cAAc;YACd,WAAW,EAAE,YAAY,OAAO,CAAC,MAAM,0BAA0B,cAAc,EAAE;YACjF,eAAe;YACf,QAAQ,EAAE,IAAA,0BAAe,EAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;SAClE,CAAC,CAAC;IACL,CAAC;CACF;AA/ED,kBA+EC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Guard Pipeline -- composes multiple guards into an ordered evaluation chain.
3
+ *
4
+ * Must stay in sync with: sdk/python/src/shield360/guard/_pipeline.py
5
+ */
6
+ import { Guard, PipelineResult } from './base';
7
+ export interface PipelineOptions {
8
+ guards?: Guard[];
9
+ failOpen?: boolean;
10
+ }
11
+ export declare class Pipeline {
12
+ private readonly _guards;
13
+ private readonly _failOpen;
14
+ constructor(opts?: PipelineOptions);
15
+ get guards(): Guard[];
16
+ evaluate(text: string, phase?: string): PipelineResult;
17
+ /**
18
+ * Apply every redacting guard to `text` and return the result.
19
+ *
20
+ * Used after `evaluate` has already decided a call is redacted, to rewrite
21
+ * each message on its own. Emits nothing: the decision, and its telemetry,
22
+ * came from `evaluate`.
23
+ */
24
+ redact(text: string, phase?: string): string;
25
+ private static _emitOtel;
26
+ }