@botonic/plugin-ai-agents 0.46.0 → 2.23.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 (181) hide show
  1. package/CHANGELOG.md +209 -0
  2. package/package.json +23 -41
  3. package/src/index.d.ts +2 -0
  4. package/src/index.js +3 -0
  5. package/src/index.js.map +1 -0
  6. package/{lib/cjs → src/lib}/agent-builder.d.ts +5 -10
  7. package/{lib/cjs → src/lib}/agent-builder.js +31 -25
  8. package/src/lib/agent-builder.js.map +1 -0
  9. package/{lib/cjs → src/lib}/constants.d.ts +1 -3
  10. package/src/lib/constants.js +13 -0
  11. package/src/lib/constants.js.map +1 -0
  12. package/{lib/esm → src/lib}/debug-logger.d.ts +3 -5
  13. package/{lib/esm → src/lib}/debug-logger.js +44 -29
  14. package/src/lib/debug-logger.js.map +1 -0
  15. package/src/lib/guardrails/index.js +2 -0
  16. package/src/lib/guardrails/index.js.map +1 -0
  17. package/src/lib/guardrails/input.d.ts +3 -0
  18. package/src/lib/guardrails/input.js +29 -0
  19. package/src/lib/guardrails/input.js.map +1 -0
  20. package/{lib/cjs/services → src/lib}/hubtype-api-client.d.ts +13 -5
  21. package/src/lib/hubtype-api-client.js +206 -0
  22. package/src/lib/hubtype-api-client.js.map +1 -0
  23. package/{lib/cjs → src/lib}/index.d.ts +2 -7
  24. package/src/lib/index.js +111 -0
  25. package/src/lib/index.js.map +1 -0
  26. package/src/lib/openai.d.ts +1 -0
  27. package/src/lib/openai.js +21 -0
  28. package/src/lib/openai.js.map +1 -0
  29. package/src/lib/runner.d.ts +12 -0
  30. package/src/lib/runner.js +96 -0
  31. package/src/lib/runner.js.map +1 -0
  32. package/{lib/esm → src/lib}/structured-output/carousel.d.ts +1 -1
  33. package/src/lib/structured-output/carousel.js +19 -0
  34. package/src/lib/structured-output/carousel.js.map +1 -0
  35. package/{lib/cjs → src/lib}/structured-output/exit.d.ts +1 -1
  36. package/src/lib/structured-output/exit.js +7 -0
  37. package/src/lib/structured-output/exit.js.map +1 -0
  38. package/{lib/cjs → src/lib}/structured-output/index.d.ts +10 -73
  39. package/src/lib/structured-output/index.js +11 -0
  40. package/src/lib/structured-output/index.js.map +1 -0
  41. package/{lib/esm → src/lib}/structured-output/text-with-buttons.d.ts +8 -8
  42. package/src/lib/structured-output/text-with-buttons.js +14 -0
  43. package/src/lib/structured-output/text-with-buttons.js.map +1 -0
  44. package/{lib/esm → src/lib}/structured-output/text.d.ts +1 -1
  45. package/src/lib/structured-output/text.js +10 -0
  46. package/src/lib/structured-output/text.js.map +1 -0
  47. package/{lib/esm → src/lib}/tools/index.d.ts +1 -1
  48. package/src/lib/tools/index.js +3 -0
  49. package/src/lib/tools/index.js.map +1 -0
  50. package/{lib/cjs → src/lib}/tools/retrieve-knowledge.d.ts +2 -2
  51. package/src/lib/tools/retrieve-knowledge.js +30 -0
  52. package/src/lib/tools/retrieve-knowledge.js.map +1 -0
  53. package/{lib/esm → src/lib}/types.d.ts +11 -21
  54. package/src/lib/types.js +2 -0
  55. package/src/lib/types.js.map +1 -0
  56. package/README.md +0 -156
  57. package/lib/cjs/agent-builder.js.map +0 -1
  58. package/lib/cjs/bot-config-tools.d.ts +0 -7
  59. package/lib/cjs/bot-config-tools.js +0 -19
  60. package/lib/cjs/bot-config-tools.js.map +0 -1
  61. package/lib/cjs/constants.js +0 -17
  62. package/lib/cjs/constants.js.map +0 -1
  63. package/lib/cjs/debug-logger.d.ts +0 -33
  64. package/lib/cjs/debug-logger.js +0 -97
  65. package/lib/cjs/debug-logger.js.map +0 -1
  66. package/lib/cjs/guardrails/index.js +0 -5
  67. package/lib/cjs/guardrails/index.js.map +0 -1
  68. package/lib/cjs/guardrails/input.d.ts +0 -10
  69. package/lib/cjs/guardrails/input.js +0 -77
  70. package/lib/cjs/guardrails/input.js.map +0 -1
  71. package/lib/cjs/index.js +0 -133
  72. package/lib/cjs/index.js.map +0 -1
  73. package/lib/cjs/llm-config.d.ts +0 -15
  74. package/lib/cjs/llm-config.js +0 -66
  75. package/lib/cjs/llm-config.js.map +0 -1
  76. package/lib/cjs/runner.d.ts +0 -18
  77. package/lib/cjs/runner.js +0 -181
  78. package/lib/cjs/runner.js.map +0 -1
  79. package/lib/cjs/services/hubtype-api-client.js +0 -206
  80. package/lib/cjs/services/hubtype-api-client.js.map +0 -1
  81. package/lib/cjs/services/types.d.ts +0 -85
  82. package/lib/cjs/services/types.js +0 -13
  83. package/lib/cjs/services/types.js.map +0 -1
  84. package/lib/cjs/structured-output/bot-executor.d.ts +0 -49
  85. package/lib/cjs/structured-output/bot-executor.js +0 -18
  86. package/lib/cjs/structured-output/bot-executor.js.map +0 -1
  87. package/lib/cjs/structured-output/carousel.d.ts +0 -90
  88. package/lib/cjs/structured-output/carousel.js +0 -22
  89. package/lib/cjs/structured-output/carousel.js.map +0 -1
  90. package/lib/cjs/structured-output/exit.js +0 -11
  91. package/lib/cjs/structured-output/exit.js.map +0 -1
  92. package/lib/cjs/structured-output/index.js +0 -21
  93. package/lib/cjs/structured-output/index.js.map +0 -1
  94. package/lib/cjs/structured-output/text-with-buttons.d.ts +0 -49
  95. package/lib/cjs/structured-output/text-with-buttons.js +0 -18
  96. package/lib/cjs/structured-output/text-with-buttons.js.map +0 -1
  97. package/lib/cjs/structured-output/text.d.ts +0 -23
  98. package/lib/cjs/structured-output/text.js +0 -13
  99. package/lib/cjs/structured-output/text.js.map +0 -1
  100. package/lib/cjs/tools/index.d.ts +0 -3
  101. package/lib/cjs/tools/index.js +0 -7
  102. package/lib/cjs/tools/index.js.map +0 -1
  103. package/lib/cjs/tools/retrieve-knowledge.js +0 -32
  104. package/lib/cjs/tools/retrieve-knowledge.js.map +0 -1
  105. package/lib/cjs/types.d.ts +0 -56
  106. package/lib/cjs/types.js +0 -3
  107. package/lib/cjs/types.js.map +0 -1
  108. package/lib/esm/agent-builder.d.ts +0 -34
  109. package/lib/esm/agent-builder.js +0 -105
  110. package/lib/esm/agent-builder.js.map +0 -1
  111. package/lib/esm/bot-config-tools.d.ts +0 -7
  112. package/lib/esm/bot-config-tools.js +0 -19
  113. package/lib/esm/bot-config-tools.js.map +0 -1
  114. package/lib/esm/constants.d.ts +0 -11
  115. package/lib/esm/constants.js +0 -17
  116. package/lib/esm/constants.js.map +0 -1
  117. package/lib/esm/debug-logger.js.map +0 -1
  118. package/lib/esm/guardrails/index.d.ts +0 -1
  119. package/lib/esm/guardrails/index.js +0 -5
  120. package/lib/esm/guardrails/index.js.map +0 -1
  121. package/lib/esm/guardrails/input.d.ts +0 -10
  122. package/lib/esm/guardrails/input.js +0 -77
  123. package/lib/esm/guardrails/input.js.map +0 -1
  124. package/lib/esm/index.d.ts +0 -18
  125. package/lib/esm/index.js +0 -133
  126. package/lib/esm/index.js.map +0 -1
  127. package/lib/esm/llm-config.d.ts +0 -15
  128. package/lib/esm/llm-config.js +0 -66
  129. package/lib/esm/llm-config.js.map +0 -1
  130. package/lib/esm/runner.d.ts +0 -18
  131. package/lib/esm/runner.js +0 -181
  132. package/lib/esm/runner.js.map +0 -1
  133. package/lib/esm/services/hubtype-api-client.d.ts +0 -14
  134. package/lib/esm/services/hubtype-api-client.js +0 -206
  135. package/lib/esm/services/hubtype-api-client.js.map +0 -1
  136. package/lib/esm/services/types.d.ts +0 -85
  137. package/lib/esm/services/types.js +0 -13
  138. package/lib/esm/services/types.js.map +0 -1
  139. package/lib/esm/structured-output/bot-executor.d.ts +0 -49
  140. package/lib/esm/structured-output/bot-executor.js +0 -18
  141. package/lib/esm/structured-output/bot-executor.js.map +0 -1
  142. package/lib/esm/structured-output/carousel.js +0 -22
  143. package/lib/esm/structured-output/carousel.js.map +0 -1
  144. package/lib/esm/structured-output/exit.d.ts +0 -10
  145. package/lib/esm/structured-output/exit.js +0 -11
  146. package/lib/esm/structured-output/exit.js.map +0 -1
  147. package/lib/esm/structured-output/index.d.ts +0 -291
  148. package/lib/esm/structured-output/index.js +0 -21
  149. package/lib/esm/structured-output/index.js.map +0 -1
  150. package/lib/esm/structured-output/text-with-buttons.js +0 -18
  151. package/lib/esm/structured-output/text-with-buttons.js.map +0 -1
  152. package/lib/esm/structured-output/text.js +0 -13
  153. package/lib/esm/structured-output/text.js.map +0 -1
  154. package/lib/esm/tools/index.js +0 -7
  155. package/lib/esm/tools/index.js.map +0 -1
  156. package/lib/esm/tools/retrieve-knowledge.d.ts +0 -9
  157. package/lib/esm/tools/retrieve-knowledge.js +0 -32
  158. package/lib/esm/tools/retrieve-knowledge.js.map +0 -1
  159. package/lib/esm/types.js +0 -3
  160. package/lib/esm/types.js.map +0 -1
  161. package/src/agent-builder.ts +0 -179
  162. package/src/bot-config-tools.ts +0 -21
  163. package/src/constants.ts +0 -21
  164. package/src/debug-logger.ts +0 -166
  165. package/src/guardrails/index.ts +0 -1
  166. package/src/guardrails/input.ts +0 -122
  167. package/src/index.ts +0 -209
  168. package/src/llm-config.ts +0 -96
  169. package/src/runner.ts +0 -287
  170. package/src/services/hubtype-api-client.ts +0 -240
  171. package/src/services/types.ts +0 -106
  172. package/src/structured-output/bot-executor.ts +0 -21
  173. package/src/structured-output/carousel.ts +0 -24
  174. package/src/structured-output/exit.ts +0 -12
  175. package/src/structured-output/index.ts +0 -25
  176. package/src/structured-output/text-with-buttons.ts +0 -21
  177. package/src/structured-output/text.ts +0 -13
  178. package/src/tools/index.ts +0 -5
  179. package/src/tools/retrieve-knowledge.ts +0 -37
  180. package/src/types.ts +0 -110
  181. /package/{lib/cjs → src/lib}/guardrails/index.d.ts +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,209 @@
1
+ ## 2.23.0 (2026-03-23)
2
+
3
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
4
+
5
+ ## 2.22.1 (2026-03-19)
6
+
7
+ ### 🩹 Fixes
8
+
9
+ - try to improve CI speed ([#751](https://github.com/metis-ai/hubtype-product/pull/751))
10
+
11
+ ### ❤️ Thank You
12
+
13
+ - Marc Rabat @vanbasten17
14
+
15
+ ## 2.22.0 (2026-03-16)
16
+
17
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
18
+
19
+ ## 2.21.0 (2026-03-16)
20
+
21
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
22
+
23
+ ## 2.20.0 (2026-03-13)
24
+
25
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
26
+
27
+ ## 2.19.0 (2026-03-12)
28
+
29
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
30
+
31
+ ## 2.18.0 (2026-03-04)
32
+
33
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
34
+
35
+ ## 2.17.0 (2026-03-02)
36
+
37
+ ### 🚀 Features
38
+
39
+ - botonic working with v2 input format ([#660](https://github.com/metis-ai/hubtype-product/pull/660))
40
+
41
+ ### ❤️ Thank You
42
+
43
+ - Marc Rabat @vanbasten17
44
+
45
+ ## 2.16.0 (2026-02-23)
46
+
47
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
48
+
49
+ ## 2.15.0 (2026-02-13)
50
+
51
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
52
+
53
+ ## 2.14.0 (2026-02-05)
54
+
55
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
56
+
57
+ ## 2.13.4 (2026-02-02)
58
+
59
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
60
+
61
+ ## 2.13.3 (2026-01-30)
62
+
63
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
64
+
65
+ ## 2.13.2 (2026-01-30)
66
+
67
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
68
+
69
+ ## 2.13.1 (2026-01-30)
70
+
71
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
72
+
73
+ ## 2.13.0 (2026-01-29)
74
+
75
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
76
+
77
+ ## 2.12.0 (2026-01-28)
78
+
79
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
80
+
81
+ ## 2.11.5 (2026-01-28)
82
+
83
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
84
+
85
+ ## 2.11.4 (2026-01-28)
86
+
87
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
88
+
89
+ ## 2.11.3 (2026-01-28)
90
+
91
+ ### 🩹 Fixes
92
+
93
+ - update entrypoints to use .js and .d.ts extensions for module and types ([#552](https://github.com/metis-ai/hubtype-product/pull/552))
94
+
95
+ ### ❤️ Thank You
96
+
97
+ - David Hidalgo @Davidhidalgo
98
+
99
+ ## 2.11.2 (2026-01-21)
100
+
101
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
102
+
103
+ ## 2.11.1 (2026-01-21)
104
+
105
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
106
+
107
+ ## 2.11.0 (2026-01-21)
108
+
109
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
110
+
111
+ ## 2.10.1 (2026-01-19)
112
+
113
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
114
+
115
+ ## 2.10.0 (2026-01-18)
116
+
117
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
118
+
119
+ ## 2.9.1 (2026-01-17)
120
+
121
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
122
+
123
+ ## 2.9.0 (2026-01-17)
124
+
125
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
126
+
127
+ ## 2.8.1 (2026-01-16)
128
+
129
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
130
+
131
+ ## 2.8.0 (2026-01-16)
132
+
133
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
134
+
135
+ ## 2.7.1 (2026-01-16)
136
+
137
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
138
+
139
+ ## 2.7.0 (2026-01-15)
140
+
141
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
142
+
143
+ ## 2.6.0 (2025-12-09)
144
+
145
+ ### 🚀 Features
146
+
147
+ - plugin-flow-builder enable SmartIntents and add tests ([#469](https://github.com/metis-ai/hubtype-product/pull/469))
148
+
149
+ ### ❤️ Thank You
150
+
151
+ - Oriol Raventós @Iru89
152
+
153
+ ## 2.5.0 (2025-12-09)
154
+
155
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
156
+
157
+ ## 2.4.1 (2025-12-08)
158
+
159
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
160
+
161
+ ## 2.4.0 (2025-12-05)
162
+
163
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
164
+
165
+ ## 2.3.3 (2025-12-04)
166
+
167
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
168
+
169
+ ## 2.3.2 (2025-12-04)
170
+
171
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
172
+
173
+ ## 2.3.1 (2025-12-04)
174
+
175
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
176
+
177
+ ## 2.3.0 (2025-12-04)
178
+
179
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
180
+
181
+ ## 2.2.1 (2025-12-04)
182
+
183
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
184
+
185
+ ## 2.2.0 (2025-12-04)
186
+
187
+ ### 🚀 Features
188
+
189
+ - add custom tool and bot action ([#452](https://github.com/metis-ai/hubtype-product/pull/452))
190
+ - fine tuning botonic release #BLT-2010 ([#428](https://github.com/metis-ai/hubtype-product/pull/428))
191
+
192
+ ### ❤️ Thank You
193
+
194
+ - David Hidalgo @Davidhidalgo
195
+ - Oriol Raventós @Iru89
196
+
197
+ ## 2.1.0 (2025-12-02)
198
+
199
+ ### 🚀 Features
200
+
201
+ - fine tuning botonic release #BLT-2010 ([#428](https://github.com/metis-ai/hubtype-product/pull/428))
202
+
203
+ ### ❤️ Thank You
204
+
205
+ - David Hidalgo @Davidhidalgo
206
+
207
+ ## 2.0.1-alpha.0 (2025-11-27)
208
+
209
+ This was a version bump only for @botonic/plugin-ai-agents to align it with other projects, there were no code changes.
package/package.json CHANGED
@@ -1,50 +1,32 @@
1
1
  {
2
2
  "name": "@botonic/plugin-ai-agents",
3
- "version": "0.46.0",
4
- "main": "./lib/cjs/index.js",
5
- "module": "./lib/esm/index.js",
6
- "description": "Use AI Agents to generate your contents",
7
- "scripts": {
8
- "build": "rm -rf lib && ../../node_modules/.bin/tsc -p tsconfig.json && ../../node_modules/.bin/tsc -p tsconfig.esm.json",
9
- "build:watch": "npm run build -- --watch",
10
- "test": "../../node_modules/.bin/jest --coverage",
11
- "prepublishOnly": "rm -rf lib && npm i && npm run build",
12
- "lint": "biome check --write src/ tests/",
13
- "lint:check": "biome check src/ tests/",
14
- "format": "biome format --write src/ tests/"
3
+ "version": "2.23.0",
4
+ "type": "module",
5
+ "types": "./src/index.d.ts",
6
+ "module": "./src/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./src/index.d.ts",
10
+ "import": "./src/index.js"
11
+ }
15
12
  },
16
13
  "dependencies": {
17
- "@botonic/core": "^0.46.0",
14
+ "@botonic/shared": "2.23.0",
18
15
  "@openai/agents": "^0.3.9",
19
- "axios": "^1.13.6",
20
16
  "openai": "^6.0.0",
21
- "uuid": "^10.0.0",
22
- "zod": "3.25.76",
23
- "zod-to-json-schema": "^3.25.1"
17
+ "tslib": "^2.3.0",
18
+ "zod": "^3.25.76"
24
19
  },
25
- "devDependencies": {
26
- "@types/uuid": "^10.0.0"
27
- },
28
- "files": [
29
- "lib/**",
30
- "src/**",
31
- "README.md"
20
+ "references": [
21
+ {
22
+ "path": "../core/tsconfig.lib.json"
23
+ },
24
+ {
25
+ "path": "../shared/tsconfig.lib.json"
26
+ }
32
27
  ],
33
- "engines": {
34
- "node": ">=22.19.0",
35
- "npm": ">=10.0.0"
36
- },
37
- "repository": {
38
- "type": "git",
39
- "url": "git+https://github.com/hubtype/botonic.git"
28
+ "publishConfig": {
29
+ "access": "public"
40
30
  },
41
- "keywords": [
42
- "bot-framework",
43
- "chatbot",
44
- "ai-agents",
45
- "conversational-app",
46
- "typescript",
47
- "javascript"
48
- ],
49
- "author": ""
50
- }
31
+ "main": "./src/index.js"
32
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { BotonicPluginAiAgents } from './lib';
2
+ export * from './lib/types';
package/src/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { BotonicPluginAiAgents } from './lib';
2
+ export * from './lib/types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/botonic/plugin-ai-agents/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAC7C,cAAc,aAAa,CAAA"}
@@ -1,9 +1,7 @@
1
- import type { CampaignV2, ContactInfo, ResolvedPlugins } from '@botonic/core';
2
- import type { DebugLogger } from './debug-logger';
3
- import type { GuardrailTrackingContext } from './guardrails/input';
4
- import type { LLMConfig } from './llm-config';
5
- import type { AIAgent, GuardrailRule, Tool } from './types';
6
- interface AIAgentBuilderOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> {
1
+ import type { CampaignV2, ContactInfo, ResolvedPlugins, UserExtraData } from '@botonic/shared';
2
+ import { DebugLogger } from './debug-logger';
3
+ import { AIAgent, GuardrailRule, Tool } from './types';
4
+ interface AIAgentBuilderOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> {
7
5
  name: string;
8
6
  instructions: string;
9
7
  tools: Tool<TPlugins, TExtraData>[];
@@ -11,16 +9,13 @@ interface AIAgentBuilderOptions<TPlugins extends ResolvedPlugins = ResolvedPlugi
11
9
  contactInfo: ContactInfo[];
12
10
  inputGuardrailRules: GuardrailRule[];
13
11
  sourceIds: string[];
14
- llmConfig: LLMConfig;
15
12
  logger: DebugLogger;
16
- guardrailTrackingContext: GuardrailTrackingContext;
17
13
  }
18
- export declare class AIAgentBuilder<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> {
14
+ export declare class AIAgentBuilder<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> {
19
15
  private name;
20
16
  private instructions;
21
17
  private tools;
22
18
  private inputGuardrails;
23
- llmConfig: LLMConfig;
24
19
  private logger;
25
20
  constructor(options: AIAgentBuilderOptions<TPlugins, TExtraData>);
26
21
  build(): AIAgent<TPlugins, TExtraData>;
@@ -1,45 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AIAgentBuilder = void 0;
4
- const agents_1 = require("@openai/agents");
5
- const constants_1 = require("./constants");
6
- const guardrails_1 = require("./guardrails");
7
- const structured_output_1 = require("./structured-output");
8
- const tools_1 = require("./tools");
9
- class AIAgentBuilder {
1
+ import { Agent, } from '@openai/agents';
2
+ import { OPENAI_MODEL, OPENAI_PROVIDER } from './constants';
3
+ import { createInputGuardrail } from './guardrails';
4
+ import { OutputSchema } from './structured-output';
5
+ import { mandatoryTools, retrieveKnowledge } from './tools';
6
+ export class AIAgentBuilder {
10
7
  constructor(options) {
11
8
  this.name = options.name;
12
9
  this.instructions = this.addExtraInstructions(options.instructions, options.contactInfo, options.campaignsContext);
13
10
  this.tools = this.addHubtypeTools(options.tools, options.sourceIds);
14
11
  this.inputGuardrails = [];
15
- this.llmConfig = options.llmConfig;
16
12
  this.logger = options.logger;
17
13
  if (options.inputGuardrailRules.length > 0) {
18
- const inputGuardrail = (0, guardrails_1.createInputGuardrail)(options.inputGuardrailRules, options.llmConfig, options.guardrailTrackingContext);
14
+ const inputGuardrail = createInputGuardrail(options.inputGuardrailRules);
19
15
  this.inputGuardrails.push(inputGuardrail);
20
16
  }
21
17
  }
22
18
  build() {
19
+ const modelSettings = {};
20
+ if (OPENAI_PROVIDER === 'openai') {
21
+ modelSettings.reasoning = { effort: 'none' }; // Specific to OpenAI API
22
+ modelSettings.text = { verbosity: 'medium' };
23
+ }
24
+ const hasRetrieveKnowledge = this.tools.some(t => t.name === retrieveKnowledge.name);
25
+ if (hasRetrieveKnowledge && OPENAI_PROVIDER === 'azure') {
26
+ modelSettings.toolChoice = retrieveKnowledge.name;
27
+ }
23
28
  // When using standard OpenAI API, we need to specify the model
24
29
  // Azure OpenAI uses deployment name instead
25
- const model = this.llmConfig.modelName;
26
- const hasRetrieveKnowledge = this.tools.includes(tools_1.retrieveKnowledge);
30
+ const model = OPENAI_PROVIDER === 'openai' ? OPENAI_MODEL : undefined;
27
31
  this.logger.logModelSettings({
28
- provider: constants_1.OPENAI_PROVIDER,
32
+ provider: OPENAI_PROVIDER,
29
33
  model,
30
- reasoning: this.llmConfig.modelSettings.reasoning,
31
- text: this.llmConfig.modelSettings.text,
32
- toolChoice: this.llmConfig.modelSettings.toolChoice,
34
+ reasoning: modelSettings.reasoning,
35
+ text: modelSettings.text,
36
+ toolChoice: modelSettings.toolChoice,
33
37
  hasRetrieveKnowledge,
34
38
  });
35
- return new agents_1.Agent({
39
+ return new Agent({
36
40
  name: this.name,
37
41
  model,
38
42
  instructions: this.instructions,
39
43
  tools: this.tools,
40
- outputType: structured_output_1.OutputSchema,
44
+ outputType: OutputSchema,
41
45
  inputGuardrails: this.inputGuardrails,
42
46
  outputGuardrails: [],
47
+ modelSettings,
43
48
  });
44
49
  }
45
50
  addExtraInstructions(initialInstructions, contactInfo, campaignsContext) {
@@ -94,12 +99,13 @@ class AIAgentBuilder {
94
99
  return `<output>\n${output}\n</output>`;
95
100
  }
96
101
  addHubtypeTools(tools, sourceIds) {
97
- const hubtypeTools = [...tools_1.mandatoryTools];
98
- if (sourceIds.length > 0) {
99
- hubtypeTools.push(tools_1.retrieveKnowledge);
100
- }
101
- return [...hubtypeTools, ...tools];
102
+ // Cast needed: mandatoryTools/retrieveKnowledge are Tool<ResolvedPlugins, ExtraData> at runtime but compatible with Tool<TPlugins, TExtraData>
103
+ const hubtypeTools = [
104
+ ...mandatoryTools,
105
+ ...(sourceIds.length > 0 ? [retrieveKnowledge] : []),
106
+ ...tools,
107
+ ];
108
+ return hubtypeTools;
102
109
  }
103
110
  }
104
- exports.AIAgentBuilder = AIAgentBuilder;
105
111
  //# sourceMappingURL=agent-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-builder.js","sourceRoot":"","sources":["../../../../../../libs/botonic/plugin-ai-agents/src/lib/agent-builder.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,GAIN,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAiB3D,MAAM,OAAO,cAAc;IAUzB,YAAY,OAAoD;QAC9D,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,oBAAoB,CAC3C,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,gBAAgB,CACzB,CAAA;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;QACnE,IAAI,CAAC,eAA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ure';
5
5
  export declare const AZURE_OPENAI_API_KEY: string | undefined;
6
6
  export declare const AZURE_OPENAI_API_BASE: string | undefined;
7
+ export declare const AZURE_OPENAI_API_DEPLOYMENT_NAME: string;
7
8
  export declare const AZURE_OPENAI_API_VERSION: string;
8
- export declare const isProd: boolean;
9
9
  export declare const MAX_MEMORY_LENGTH = 25;
10
- export declare const DEFAULT_TIMEOUT_16_SECONDS = 16000;
11
- export declare const DEFAULT_MAX_RETRIES = 2;
@@ -0,0 +1,13 @@
1
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2
+ export const HUBTYPE_API_URL = ((_a = import.meta.env) === null || _a === void 0 ? void 0 : _a['VITE_HUBTYPE_API_URL']) || 'https://api.hubtype.com';
3
+ // OpenAI Provider Configuration
4
+ export const OPENAI_API_KEY = (_b = import.meta.env) === null || _b === void 0 ? void 0 : _b['VITE_OPENAI_API_KEY']; // pragma: allowlist secret
5
+ export const OPENAI_MODEL = ((_c = import.meta.env) === null || _c === void 0 ? void 0 : _c['VITE_OPENAI_MODEL']) || 'gpt-4.1-mini';
6
+ export const OPENAI_PROVIDER = ((_d = import.meta.env) === null || _d === void 0 ? void 0 : _d['VITE_OPENAI_PROVIDER']) || 'azure';
7
+ // Azure OpenAI Configuration
8
+ export const AZURE_OPENAI_API_KEY = (_e = import.meta.env) === null || _e === void 0 ? void 0 : _e['VITE_AZURE_OPENAI_API_KEY']; // pragma: allowlist secret
9
+ export const AZURE_OPENAI_API_BASE = (_f = import.meta.env) === null || _f === void 0 ? void 0 : _f['VITE_AZURE_OPENAI_API_BASE'];
10
+ export const AZURE_OPENAI_API_DEPLOYMENT_NAME = ((_g = import.meta.env) === null || _g === void 0 ? void 0 : _g['VITE_AZURE_OPENAI_API_DEPLOYMENT_NAME']) || 'gpt-41-mini_p1';
11
+ export const AZURE_OPENAI_API_VERSION = ((_h = import.meta.env) === null || _h === void 0 ? void 0 : _h['VITE_AZURE_OPENAI_API_VERSION']) || '2025-01-01-preview';
12
+ export const MAX_MEMORY_LENGTH = 25;
13
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../libs/botonic/plugin-ai-agents/src/lib/constants.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,MAAM,eAAe,GAC1B,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,0CAAG,sBAAsB,CAAC,KAAI,yBAAyB,CAAA;AAExE,gCAAgC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,0CAAG,qBAAqB,CAAC,CAAA,CAAC,2BAA2B;AAClG,MAAM,CAAC,MAAM,YAAY,GACvB,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,0CAAG,mBAAmB,CAAC,KAAI,cAAc,CAAA;AAC1D,MAAM,CAAC,MAAM,eAAe,GAC1B,CAAC,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,0CAAG,sBAAsB,CAAwB,KAAI,OAAO,CAAA;AAE9E,6BAA6B;AAC7B,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,0CACjD,2BAA2B,CAC5B,CAAA,CAAC,2BAA2B;AAC7B,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,0CAClD,4BAA4B,CAC7B,CAAA;AACD,MAAM,CAAC,MAAM,gCAAgC,GAC3C,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,0CAAG,uCAAuC,CAAC,KAAI,gBAAgB,CAAA;AAChF,MAAM,CAAC,MAAM,wBAAwB,GACnC,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,0CAAG,+BAA+B,CAAC,KAAI,oBAAoB,CAAA;AAE5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA"}
@@ -1,6 +1,5 @@
1
- import type { AiAgentArgs, ToolExecution } from '@botonic/core';
2
- import type { ModelSettings } from '@openai/agents';
3
- import type { AgenticInputMessage, MemoryOptions, RunResult } from './types';
1
+ import { AiAgentArgs } from '@botonic/shared';
2
+ import { AgenticInputMessage, MemoryOptions, RunResult } from './types';
4
3
  export interface DebugLoggerConfig {
5
4
  messageHistoryApiVersion: string;
6
5
  maxRetries: number;
@@ -24,10 +23,9 @@ export interface DebugLogger {
24
23
  logInitialConfig(config: DebugLoggerConfig): void;
25
24
  logAgentDebugInfo(aiAgentArgs: AiAgentArgs, toolNames: string[], messages: AgenticInputMessage[]): void;
26
25
  logModelSettings(settings: ModelSettingsInfo): void;
27
- logRunnerStart(model: string, modelSettings: ModelSettings): void;
26
+ logRunnerStart(): void;
28
27
  logRunResult(runResult: RunResult, startTime: number): void;
29
28
  logGuardrailTriggered(): void;
30
29
  logRunnerError(startTime: number, error: unknown): void;
31
- logToolExecution(toolExecution: ToolExecution): void;
32
30
  }
33
31
  export declare function createDebugLogger(enableDebug: boolean): DebugLogger;
@@ -1,31 +1,42 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDebugLogger = createDebugLogger;
4
- const constants_1 = require("./constants");
1
+ import { AZURE_OPENAI_API_BASE, AZURE_OPENAI_API_DEPLOYMENT_NAME, MAX_MEMORY_LENGTH, OPENAI_MODEL, OPENAI_PROVIDER, } from './constants';
5
2
  const PREFIX = '[BotonicPluginAiAgents]';
6
3
  class EnabledDebugLogger {
4
+ getModelInfo() {
5
+ const model = OPENAI_PROVIDER === 'azure'
6
+ ? AZURE_OPENAI_API_DEPLOYMENT_NAME
7
+ : OPENAI_MODEL;
8
+ const apiBase = OPENAI_PROVIDER === 'azure' && AZURE_OPENAI_API_BASE
9
+ ? AZURE_OPENAI_API_BASE
10
+ : 'OpenAI API';
11
+ return { model, apiBase };
12
+ }
7
13
  logInitialConfig(config) {
14
+ var _a, _b, _c, _d;
15
+ const { model, apiBase } = this.getModelInfo();
8
16
  console.log(`${PREFIX} === Plugin Initialization ===`);
9
- console.log(`${PREFIX} Provider: ${constants_1.OPENAI_PROVIDER}`);
17
+ console.log(`${PREFIX} Provider: ${OPENAI_PROVIDER}`);
18
+ console.log(`${PREFIX} Model/Deployment: ${model}`);
19
+ console.log(`${PREFIX} API Base: ${apiBase}`);
10
20
  console.log(`${PREFIX} Message History API Version: ${config.messageHistoryApiVersion}`);
11
21
  console.log(`${PREFIX} Max Retries: ${config.maxRetries}`);
12
22
  console.log(`${PREFIX} Timeout: ${config.timeout}ms`);
13
23
  console.log(`${PREFIX} Custom Tools Registered: ${config.customToolNames.join(', ') || 'none'}`);
14
24
  console.log(`${PREFIX} Memory Options:`, {
15
- maxMessages: config.memory.maxMessages ?? constants_1.MAX_MEMORY_LENGTH,
16
- includeToolCalls: config.memory.includeToolCalls ?? true,
17
- maxFullToolResults: config.memory.maxFullToolResults ?? 1,
18
- debugMode: config.memory.debugMode ?? false,
25
+ maxMessages: (_a = config.memory.maxMessages) !== null && _a !== void 0 ? _a : MAX_MEMORY_LENGTH,
26
+ includeToolCalls: (_b = config.memory.includeToolCalls) !== null && _b !== void 0 ? _b : true,
27
+ maxFullToolResults: (_c = config.memory.maxFullToolResults) !== null && _c !== void 0 ? _c : 1,
28
+ debugMode: (_d = config.memory.debugMode) !== null && _d !== void 0 ? _d : false,
19
29
  });
20
30
  console.log(`${PREFIX} === End Plugin Initialization ===`);
21
31
  }
22
32
  logAgentDebugInfo(aiAgentArgs, toolNames, messages) {
33
+ var _a;
23
34
  console.log(`${PREFIX} === AI Agent Debug Info ===`);
24
35
  console.log(`${PREFIX} Agent Name: ${aiAgentArgs.name}`);
25
36
  console.log(`${PREFIX} Active Tools: ${JSON.stringify(toolNames)}`);
26
37
  console.log(`${PREFIX} Source IDs: ${JSON.stringify(aiAgentArgs.sourceIds || [])}`);
27
38
  console.log(`${PREFIX} Message History Count: ${messages.length}`);
28
- console.log(`${PREFIX} Input Guardrail Rules: ${aiAgentArgs.inputGuardrailRules?.length || 0}`);
39
+ console.log(`${PREFIX} Input Guardrail Rules: ${((_a = aiAgentArgs.inputGuardrailRules) === null || _a === void 0 ? void 0 : _a.length) || 0}`);
29
40
  console.log(`${PREFIX} Instructions:`);
30
41
  console.log(aiAgentArgs.instructions);
31
42
  console.log(`${PREFIX} === End Debug Info ===`);
@@ -44,10 +55,8 @@ class EnabledDebugLogger {
44
55
  }
45
56
  console.log(`${PREFIX} === End Model Settings ===`);
46
57
  }
47
- logRunnerStart(model, modelSettings) {
58
+ logRunnerStart() {
48
59
  console.log(`${PREFIX} === Runner Execution Start ===`);
49
- console.log(`${PREFIX} Model: ${model}`);
50
- console.log(`${PREFIX} Model Settings: ${JSON.stringify(modelSettings)}`);
51
60
  }
52
61
  logRunResult(runResult, startTime) {
53
62
  const elapsedMs = Date.now() - startTime;
@@ -73,25 +82,31 @@ class EnabledDebugLogger {
73
82
  console.log(`${PREFIX} Runner execution failed after ${elapsedMs}ms`);
74
83
  console.log(`${PREFIX} Error:`, error);
75
84
  }
76
- logToolExecution(toolExecution) {
77
- console.log(`${PREFIX} Tool Execution: ${toolExecution.toolName}`);
78
- console.log(`${PREFIX} Tool Arguments: ${JSON.stringify(toolExecution.toolArguments)}`);
79
- console.log(`${PREFIX} Tool Results: ${toolExecution.toolResults}`);
80
- console.log(`${PREFIX} Knowledgebase Sources IDs: ${JSON.stringify(toolExecution.knowledgebaseSourcesIds)}`);
81
- console.log(`${PREFIX} Knowledgebase Chunks IDs: ${JSON.stringify(toolExecution.knowledgebaseChunksIds)}`);
82
- }
83
85
  }
84
86
  class DisabledDebugLogger {
85
- logInitialConfig() { }
86
- logAgentDebugInfo() { }
87
- logModelSettings() { }
88
- logRunnerStart(_model, _modelSettings) { }
89
- logRunResult() { }
90
- logGuardrailTriggered() { }
91
- logRunnerError() { }
92
- logToolExecution() { }
87
+ logInitialConfig() {
88
+ return;
89
+ }
90
+ logAgentDebugInfo() {
91
+ return;
92
+ }
93
+ logModelSettings() {
94
+ return;
95
+ }
96
+ logRunnerStart() {
97
+ return;
98
+ }
99
+ logRunResult() {
100
+ return;
101
+ }
102
+ logGuardrailTriggered() {
103
+ return;
104
+ }
105
+ logRunnerError() {
106
+ return;
107
+ }
93
108
  }
94
- function createDebugLogger(enableDebug) {
109
+ export function createDebugLogger(enableDebug) {
95
110
  return enableDebug ? new EnabledDebugLogger() : new DisabledDebugLogger();
96
111
  }
97
112
  //# sourceMappingURL=debug-logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-logger.js","sourceRoot":"","sources":["../../../../../../libs/botonic/plugin-ai-agents/src/lib/debug-logger.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,gCAAgC,EAChC,iBAAiB,EACjB,YAAY,EACZ,eAAe,GAChB,MAAM,aAAa,CAAA;AAGpB,MAAM,MAAM,GAAG,yBAAyB,CAAA;AAiCxC,MAAM,kBAAkB;IACd,YAAY;QAClB,MAAM,KAAK,GACT,eAAe,KAAK,OAAO;YACzB,CAAC,CAAC,gCAAgC;YAClC,CAAC,CAAC,YAAY,CAAA;QAClB,MAAM,OAAO,GACX,eAAe,KAAK,OAAO,IAAI,qBAAqB;YAClD,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,YAAY,CAAA;QAClB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;IAC3B,CAAC;IAED,gBAAgB,CAAC,MAAyB;;QACxC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,CAAA;QAE9C,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,gCAAgC,CAAC,CAAA;QACtD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,cAAc,eAAe,EAAE,CAAC,CAAA;QACrD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,sBAAsB,KAAK,EAAE,CAAC,CAAA;QACnD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,cAAc,OAAO,EAAE,CAAC,CAAA;QAC7C,OAAO,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,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAA;QACxC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,kCAAkC,SAAS,IAAI,CAAC,CAAA;QACrE,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,SAAS,EAAE,KAAK,CAAC,CAAA;IACxC,CAAC;CACF;AAED,MAAM,mBAAmB;IACvB,gBAAgB;QACd,OAAM;IACR,CAAC;IACD,iBAAiB;QACf,OAAM;IACR,CAAC;IACD,gBAAgB;QACd,OAAM;IACR,CAAC;IACD,cAAc;QACZ,OAAM;IACR,CAAC;IACD,YAAY;QACV,OAAM;IACR,CAAC;IACD,qBAAqB;QACnB,OAAM;IACR,CAAC;IACD,cAAc;QACZ,OAAM;IACR,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,WAAoB;IACpD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAC,CAAC,IAAI,mBAAmB,EAAE,CAAA;AAC3E,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './input';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/plugin-ai-agents/src/lib/guardrails/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { InputGuardrail } from '@openai/agents';
2
+ import { GuardrailRule } from '../types';
3
+ export declare function createInputGuardrail(rules: GuardrailRule[]): InputGuardrail;
@@ -0,0 +1,29 @@
1
+ import { __awaiter } from "tslib";
2
+ import { Agent, run } from '@openai/agents';
3
+ import { z } from 'zod';
4
+ export function createInputGuardrail(rules) {
5
+ const outputType = z.object(Object.fromEntries(rules.map(rule => [rule.name, z.boolean().describe(rule.description)])));
6
+ const agent = new Agent({
7
+ name: 'InputGuardrail',
8
+ instructions: 'Check if the user triggers some of the following guardrails.',
9
+ outputType,
10
+ });
11
+ return {
12
+ name: 'InputGuardrail',
13
+ execute: (_a) => __awaiter(this, [_a], void 0, function* ({ input, context }) {
14
+ const lastMessage = input[input.length - 1];
15
+ const result = yield run(agent, [lastMessage], { context });
16
+ const finalOutput = result.finalOutput;
17
+ if (finalOutput === undefined) {
18
+ throw new Error('Guardrail agent failed to produce output');
19
+ }
20
+ const triggered = Object.values(finalOutput).some(value => value === true);
21
+ const triggeredGuardrails = Object.keys(finalOutput).filter(key => finalOutput[key] === true);
22
+ return {
23
+ outputInfo: triggeredGuardrails,
24
+ tripwireTriggered: triggered,
25
+ };
26
+ }),
27
+ };
28
+ }
29
+ //# sourceMappingURL=input.js.map