@botonic/plugin-ai-agents 0.46.1 → 2.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/CHANGELOG.md +209 -0
  2. package/README.md +13 -149
  3. package/package.json +23 -41
  4. package/src/index.d.ts +2 -0
  5. package/src/index.js +3 -0
  6. package/src/index.js.map +1 -0
  7. package/{lib/cjs → src/lib}/agent-builder.d.ts +5 -13
  8. package/{lib/cjs → src/lib}/agent-builder.js +31 -26
  9. package/src/lib/agent-builder.js.map +1 -0
  10. package/{lib/cjs → src/lib}/constants.d.ts +1 -3
  11. package/src/lib/constants.js +13 -0
  12. package/src/lib/constants.js.map +1 -0
  13. package/{lib/esm → src/lib}/debug-logger.d.ts +3 -5
  14. package/{lib/cjs → src/lib}/debug-logger.js +44 -29
  15. package/src/lib/debug-logger.js.map +1 -0
  16. package/src/lib/guardrails/index.js +2 -0
  17. package/src/lib/guardrails/index.js.map +1 -0
  18. package/src/lib/guardrails/input.d.ts +3 -0
  19. package/src/lib/guardrails/input.js +29 -0
  20. package/src/lib/guardrails/input.js.map +1 -0
  21. package/{lib/cjs/services → src/lib}/hubtype-api-client.d.ts +13 -5
  22. package/src/lib/hubtype-api-client.js +206 -0
  23. package/src/lib/hubtype-api-client.js.map +1 -0
  24. package/{lib/esm → src/lib}/index.d.ts +2 -7
  25. package/src/lib/index.js +111 -0
  26. package/src/lib/index.js.map +1 -0
  27. package/src/lib/openai.d.ts +1 -0
  28. package/src/lib/openai.js +21 -0
  29. package/src/lib/openai.js.map +1 -0
  30. package/src/lib/runner.d.ts +12 -0
  31. package/src/lib/runner.js +96 -0
  32. package/src/lib/runner.js.map +1 -0
  33. package/{lib/esm → src/lib}/structured-output/carousel.d.ts +1 -1
  34. package/src/lib/structured-output/carousel.js +19 -0
  35. package/src/lib/structured-output/carousel.js.map +1 -0
  36. package/{lib/cjs → src/lib}/structured-output/exit.d.ts +1 -1
  37. package/src/lib/structured-output/exit.js +7 -0
  38. package/src/lib/structured-output/exit.js.map +1 -0
  39. package/src/lib/structured-output/index.d.ts +228 -0
  40. package/src/lib/structured-output/index.js +11 -0
  41. package/src/lib/structured-output/index.js.map +1 -0
  42. package/{lib/esm/structured-output/bot-executor.d.ts → src/lib/structured-output/text-with-buttons.d.ts} +13 -13
  43. package/src/lib/structured-output/text-with-buttons.js +14 -0
  44. package/src/lib/structured-output/text-with-buttons.js.map +1 -0
  45. package/{lib/esm → src/lib}/structured-output/text.d.ts +1 -1
  46. package/src/lib/structured-output/text.js +10 -0
  47. package/src/lib/structured-output/text.js.map +1 -0
  48. package/{lib/esm → src/lib}/tools/index.d.ts +1 -1
  49. package/src/lib/tools/index.js +3 -0
  50. package/src/lib/tools/index.js.map +1 -0
  51. package/{lib/cjs → src/lib}/tools/retrieve-knowledge.d.ts +2 -2
  52. package/src/lib/tools/retrieve-knowledge.js +30 -0
  53. package/src/lib/tools/retrieve-knowledge.js.map +1 -0
  54. package/{lib/esm → src/lib}/types.d.ts +11 -21
  55. package/src/lib/types.js +2 -0
  56. package/src/lib/types.js.map +1 -0
  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.map +0 -1
  65. package/lib/cjs/guardrails/index.js +0 -5
  66. package/lib/cjs/guardrails/index.js.map +0 -1
  67. package/lib/cjs/guardrails/input.d.ts +0 -10
  68. package/lib/cjs/guardrails/input.js +0 -77
  69. package/lib/cjs/guardrails/input.js.map +0 -1
  70. package/lib/cjs/index.d.ts +0 -18
  71. package/lib/cjs/index.js +0 -134
  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.d.ts +0 -603
  93. package/lib/cjs/structured-output/index.js +0 -28
  94. package/lib/cjs/structured-output/index.js.map +0 -1
  95. package/lib/cjs/structured-output/text-with-buttons.d.ts +0 -56
  96. package/lib/cjs/structured-output/text-with-buttons.js +0 -24
  97. package/lib/cjs/structured-output/text-with-buttons.js.map +0 -1
  98. package/lib/cjs/structured-output/text.d.ts +0 -23
  99. package/lib/cjs/structured-output/text.js +0 -13
  100. package/lib/cjs/structured-output/text.js.map +0 -1
  101. package/lib/cjs/tools/index.d.ts +0 -3
  102. package/lib/cjs/tools/index.js +0 -7
  103. package/lib/cjs/tools/index.js.map +0 -1
  104. package/lib/cjs/tools/retrieve-knowledge.js +0 -32
  105. package/lib/cjs/tools/retrieve-knowledge.js.map +0 -1
  106. package/lib/cjs/types.d.ts +0 -56
  107. package/lib/cjs/types.js +0 -3
  108. package/lib/cjs/types.js.map +0 -1
  109. package/lib/esm/agent-builder.d.ts +0 -37
  110. package/lib/esm/agent-builder.js +0 -106
  111. package/lib/esm/agent-builder.js.map +0 -1
  112. package/lib/esm/bot-config-tools.d.ts +0 -7
  113. package/lib/esm/bot-config-tools.js +0 -19
  114. package/lib/esm/bot-config-tools.js.map +0 -1
  115. package/lib/esm/constants.d.ts +0 -11
  116. package/lib/esm/constants.js +0 -17
  117. package/lib/esm/constants.js.map +0 -1
  118. package/lib/esm/debug-logger.js +0 -97
  119. package/lib/esm/debug-logger.js.map +0 -1
  120. package/lib/esm/guardrails/index.d.ts +0 -1
  121. package/lib/esm/guardrails/index.js +0 -5
  122. package/lib/esm/guardrails/index.js.map +0 -1
  123. package/lib/esm/guardrails/input.d.ts +0 -10
  124. package/lib/esm/guardrails/input.js +0 -77
  125. package/lib/esm/guardrails/input.js.map +0 -1
  126. package/lib/esm/index.js +0 -134
  127. package/lib/esm/index.js.map +0 -1
  128. package/lib/esm/llm-config.d.ts +0 -15
  129. package/lib/esm/llm-config.js +0 -66
  130. package/lib/esm/llm-config.js.map +0 -1
  131. package/lib/esm/runner.d.ts +0 -18
  132. package/lib/esm/runner.js +0 -181
  133. package/lib/esm/runner.js.map +0 -1
  134. package/lib/esm/services/hubtype-api-client.d.ts +0 -14
  135. package/lib/esm/services/hubtype-api-client.js +0 -206
  136. package/lib/esm/services/hubtype-api-client.js.map +0 -1
  137. package/lib/esm/services/types.d.ts +0 -85
  138. package/lib/esm/services/types.js +0 -13
  139. package/lib/esm/services/types.js.map +0 -1
  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 -603
  148. package/lib/esm/structured-output/index.js +0 -28
  149. package/lib/esm/structured-output/index.js.map +0 -1
  150. package/lib/esm/structured-output/text-with-buttons.d.ts +0 -56
  151. package/lib/esm/structured-output/text-with-buttons.js +0 -24
  152. package/lib/esm/structured-output/text-with-buttons.js.map +0 -1
  153. package/lib/esm/structured-output/text.js +0 -13
  154. package/lib/esm/structured-output/text.js.map +0 -1
  155. package/lib/esm/tools/index.js +0 -7
  156. package/lib/esm/tools/index.js.map +0 -1
  157. package/lib/esm/tools/retrieve-knowledge.d.ts +0 -9
  158. package/lib/esm/tools/retrieve-knowledge.js +0 -32
  159. package/lib/esm/tools/retrieve-knowledge.js.map +0 -1
  160. package/lib/esm/types.js +0 -3
  161. package/lib/esm/types.js.map +0 -1
  162. package/src/agent-builder.ts +0 -183
  163. package/src/bot-config-tools.ts +0 -21
  164. package/src/constants.ts +0 -21
  165. package/src/debug-logger.ts +0 -166
  166. package/src/guardrails/index.ts +0 -1
  167. package/src/guardrails/input.ts +0 -122
  168. package/src/index.ts +0 -210
  169. package/src/llm-config.ts +0 -96
  170. package/src/runner.ts +0 -287
  171. package/src/services/hubtype-api-client.ts +0 -240
  172. package/src/services/types.ts +0 -106
  173. package/src/structured-output/bot-executor.ts +0 -21
  174. package/src/structured-output/carousel.ts +0 -24
  175. package/src/structured-output/exit.ts +0 -12
  176. package/src/structured-output/index.ts +0 -34
  177. package/src/structured-output/text-with-buttons.ts +0 -29
  178. package/src/structured-output/text.ts +0 -13
  179. package/src/tools/index.ts +0 -5
  180. package/src/tools/retrieve-knowledge.ts +0 -37
  181. package/src/types.ts +0 -110
  182. /package/{lib/cjs → src/lib}/guardrails/index.d.ts +0 -0
@@ -1,56 +0,0 @@
1
- import type { TextWithButtonsMessage } from '@botonic/core';
2
- import z from 'zod';
3
- export type { TextWithButtonsMessage };
4
- export declare const TextWithButtonsSchema: z.ZodObject<{
5
- type: z.ZodEnum<["textWithButtons"]>;
6
- content: z.ZodObject<{
7
- text: z.ZodString;
8
- buttons: z.ZodArray<z.ZodObject<{
9
- text: z.ZodString;
10
- url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
- target: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodEnum<["_blank", "_self"]>>>>;
12
- }, "strip", z.ZodTypeAny, {
13
- text: string;
14
- url?: string | null | undefined;
15
- target?: "_blank" | "_self" | null | undefined;
16
- }, {
17
- text: string;
18
- url?: string | null | undefined;
19
- target?: "_blank" | "_self" | null | undefined;
20
- }>, "many">;
21
- }, "strip", z.ZodTypeAny, {
22
- text: string;
23
- buttons: {
24
- text: string;
25
- url?: string | null | undefined;
26
- target?: "_blank" | "_self" | null | undefined;
27
- }[];
28
- }, {
29
- text: string;
30
- buttons: {
31
- text: string;
32
- url?: string | null | undefined;
33
- target?: "_blank" | "_self" | null | undefined;
34
- }[];
35
- }>;
36
- }, "strip", z.ZodTypeAny, {
37
- type: "textWithButtons";
38
- content: {
39
- text: string;
40
- buttons: {
41
- text: string;
42
- url?: string | null | undefined;
43
- target?: "_blank" | "_self" | null | undefined;
44
- }[];
45
- };
46
- }, {
47
- type: "textWithButtons";
48
- content: {
49
- text: string;
50
- buttons: {
51
- text: string;
52
- url?: string | null | undefined;
53
- target?: "_blank" | "_self" | null | undefined;
54
- }[];
55
- };
56
- }>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TextWithButtonsSchema = void 0;
4
- const tslib_1 = require("tslib");
5
- const zod_1 = tslib_1.__importDefault(require("zod"));
6
- exports.TextWithButtonsSchema = zod_1.default
7
- .object({
8
- type: zod_1.default.enum(['textWithButtons']),
9
- content: zod_1.default.object({
10
- text: zod_1.default.string(),
11
- buttons: zod_1.default.array(zod_1.default.object({
12
- text: zod_1.default.string(),
13
- url: zod_1.default.string().nullable().optional(),
14
- target: zod_1.default
15
- .enum(['_blank', '_self'])
16
- .default('_blank')
17
- .nullable()
18
- .optional()
19
- .describe('The target of the button when it has an url. If not provided, it will default to _blank.'),
20
- })),
21
- }),
22
- })
23
- .describe('A text message with buttons to allow the user to use quick replies');
24
- //# sourceMappingURL=text-with-buttons.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text-with-buttons.js","sourceRoot":"","sources":["../../../src/structured-output/text-with-buttons.ts"],"names":[],"mappings":";;;;AACA,sDAAmB;AAIN,QAAA,qBAAqB,GAAG,aAAC;KACnC,MAAM,CAAC;IACN,IAAI,EAAE,aAAC,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACjC,OAAO,EAAE,aAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,aAAC,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,aAAC,CAAC,KAAK,CACd,aAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,aAAC,CAAC,MAAM,EAAE;YAChB,GAAG,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;YACrC,MAAM,EAAE,aAAC;iBACN,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;iBACzB,OAAO,CAAC,QAAQ,CAAC;iBACjB,QAAQ,EAAE;iBACV,QAAQ,EAAE;iBACV,QAAQ,CACP,0FAA0F,CAC3F;SACJ,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CACP,oEAAoE,CACrE,CAAA"}
@@ -1,23 +0,0 @@
1
- import type { TextMessage } from '@botonic/core';
2
- import { z } from 'zod';
3
- export type { TextMessage };
4
- export declare const TextSchema: z.ZodObject<{
5
- type: z.ZodEnum<["text"]>;
6
- content: z.ZodObject<{
7
- text: z.ZodString;
8
- }, "strip", z.ZodTypeAny, {
9
- text: string;
10
- }, {
11
- text: string;
12
- }>;
13
- }, "strip", z.ZodTypeAny, {
14
- type: "text";
15
- content: {
16
- text: string;
17
- };
18
- }, {
19
- type: "text";
20
- content: {
21
- text: string;
22
- };
23
- }>;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TextSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.TextSchema = zod_1.z
6
- .object({
7
- type: zod_1.z.enum(['text']),
8
- content: zod_1.z.object({
9
- text: zod_1.z.string(),
10
- }),
11
- })
12
- .describe('A text message');
13
- //# sourceMappingURL=text.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/structured-output/text.ts"],"names":[],"mappings":";;;AACA,6BAAuB;AAIV,QAAA,UAAU,GAAG,OAAC;KACxB,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;KACjB,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,gBAAgB,CAAC,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { Tool } from '../types';
2
- export { retrieveKnowledge } from './retrieve-knowledge';
3
- export declare const mandatoryTools: Tool[];
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mandatoryTools = exports.retrieveKnowledge = void 0;
4
- var retrieve_knowledge_1 = require("./retrieve-knowledge");
5
- Object.defineProperty(exports, "retrieveKnowledge", { enumerable: true, get: function () { return retrieve_knowledge_1.retrieveKnowledge; } });
6
- exports.mandatoryTools = [];
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/index.ts"],"names":[],"mappings":";;;AAEA,2DAAwD;AAA/C,uHAAA,iBAAiB,OAAA;AAEb,QAAA,cAAc,GAAW,EAAE,CAAA"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.retrieveKnowledge = void 0;
4
- const agents_1 = require("@openai/agents");
5
- const zod_1 = require("zod");
6
- const hubtype_api_client_1 = require("../services/hubtype-api-client");
7
- exports.retrieveKnowledge = (0, agents_1.tool)({
8
- name: 'retrieve_knowledge',
9
- description: 'Consult the knowledge base for information before answering. Use this tool to make sure the information you provide is faithful.',
10
- parameters: zod_1.z.object({
11
- query: zod_1.z.string().describe('The query to search the knowledge base for'),
12
- }),
13
- execute: async (input, runContext) => {
14
- const context = runContext?.context;
15
- const query = input.query;
16
- if (!context) {
17
- throw new Error('Context is required');
18
- }
19
- const sourceIds = context.sourceIds;
20
- const client = new hubtype_api_client_1.HubtypeApiClient(context.authToken);
21
- const chunks = await client.retrieveSimilarChunks(query, sourceIds);
22
- const chunkTexts = chunks.map(chunk => chunk.text);
23
- context.knowledgeUsed = {
24
- query,
25
- sourceIds,
26
- chunksIds: chunks.map(chunk => chunk.id),
27
- chunkTexts,
28
- };
29
- return chunkTexts;
30
- },
31
- });
32
- //# sourceMappingURL=retrieve-knowledge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retrieve-knowledge.js","sourceRoot":"","sources":["../../../src/tools/retrieve-knowledge.ts"],"names":[],"mappings":";;;AAAA,2CAAsD;AACtD,6BAAuB;AAEvB,uEAAiE;AAGpD,QAAA,iBAAiB,GAAG,IAAA,aAAI,EAAC;IACpC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACT,kIAAkI;IACpI,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;KACzE,CAAC;IACF,OAAO,EAAE,KAAK,EACZ,KAAwB,EACxB,UAAgC,EACb,EAAE;QACrB,MAAM,OAAO,GAAG,UAAU,EAAE,OAAO,CAAA;QACnC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QACzB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACxC,CAAC;QACD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QACnC,MAAM,MAAM,GAAG,IAAI,qCAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACtD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QACnE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAElD,OAAO,CAAC,aAAa,GAAG;YACtB,KAAK;YACL,SAAS;YACT,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACxC,UAAU;SACX,CAAA;QAED,OAAO,UAAU,CAAA;IACnB,CAAC;CACF,CAAC,CAAA"}
@@ -1,56 +0,0 @@
1
- import { AgenticOutputMessage, AiAgentArgs, type BotContext, GuardrailRule, InferenceResponse, type ResolvedPlugins, RunResult } from '@botonic/core';
2
- import type { Agent, AgentInputItem, AgentOutputType, RunContext as OpenAIRunContext, Tool as OpenAITool } from '@openai/agents';
3
- import type { ZodSchema } from 'zod';
4
- import type { OutputSchema } from './structured-output';
5
- export interface Context<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> {
6
- authToken: string;
7
- sourceIds: string[];
8
- knowledgeUsed: {
9
- query: string;
10
- sourceIds: string[];
11
- chunksIds: string[];
12
- chunkTexts: string[];
13
- };
14
- request: BotContext<TPlugins, TExtraData>;
15
- }
16
- export type RunContext<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = OpenAIRunContext<Context<TPlugins, TExtraData>>;
17
- export interface CustomTool<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> {
18
- name: string;
19
- description: string;
20
- schema: ZodSchema;
21
- func: (input?: any, runContext?: RunContext<TPlugins, TExtraData>) => Promise<any>;
22
- }
23
- export interface Chunk {
24
- id: string;
25
- text: string;
26
- }
27
- export type Tool<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = OpenAITool<Context<TPlugins, TExtraData>>;
28
- export type AIAgent<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = Agent<Context<TPlugins, TExtraData>, AgentOutputType<typeof OutputSchema>>;
29
- export type MessageHistoryApiVersion = 'v1' | 'v2';
30
- export interface MemoryOptions {
31
- maxMessages?: number;
32
- includeToolCalls?: boolean;
33
- maxFullToolResults?: number;
34
- debugMode?: boolean;
35
- }
36
- export interface PluginAiAgentOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> {
37
- authToken?: string;
38
- customTools?: CustomTool<TPlugins, TExtraData>[];
39
- maxRetries?: number;
40
- timeout?: number;
41
- /** API version for message history endpoint. Defaults to 'v2'. */
42
- messageHistoryApiVersion?: MessageHistoryApiVersion;
43
- /** Options for V2 message history API. Only used when messageHistoryApiVersion is 'v2'. */
44
- memory?: MemoryOptions;
45
- /** Enable debug logging for AI agent configuration and execution details. */
46
- enableDebug?: boolean;
47
- }
48
- export interface ResultRawResponse {
49
- usage: {
50
- inputTokens: number;
51
- outputTokens: number;
52
- };
53
- providerData?: Record<string, unknown>;
54
- }
55
- export type AgenticInputMessage = AgentInputItem;
56
- export { AgenticOutputMessage, AiAgentArgs, GuardrailRule, InferenceResponse, RunResult, };
package/lib/cjs/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -1,37 +0,0 @@
1
- import type { CampaignV2, ContactInfo, ResolvedPlugins } from '@botonic/core';
2
- import type { z } from 'zod';
3
- import type { DebugLogger } from './debug-logger';
4
- import type { GuardrailTrackingContext } from './guardrails/input';
5
- import type { LLMConfig } from './llm-config';
6
- import type { AIAgent, GuardrailRule, Tool } from './types';
7
- interface AIAgentBuilderOptions<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> {
8
- name: string;
9
- instructions: string;
10
- tools: Tool<TPlugins, TExtraData>[];
11
- campaignsContext?: CampaignV2[];
12
- contactInfo: ContactInfo[];
13
- inputGuardrailRules: GuardrailRule[];
14
- sourceIds: string[];
15
- outputMessagesSchemas?: z.ZodObject<any>[];
16
- llmConfig: LLMConfig;
17
- logger: DebugLogger;
18
- guardrailTrackingContext: GuardrailTrackingContext;
19
- }
20
- export declare class AIAgentBuilder<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> {
21
- private name;
22
- private instructions;
23
- private tools;
24
- private externalOutputMessagesSchemas;
25
- private inputGuardrails;
26
- llmConfig: LLMConfig;
27
- private logger;
28
- constructor(options: AIAgentBuilderOptions<TPlugins, TExtraData>);
29
- build(): AIAgent<TPlugins, TExtraData>;
30
- private addExtraInstructions;
31
- private getContactInfoInstructions;
32
- private getMetadataInstructions;
33
- private getCampaignInstructions;
34
- private getOutputInstructions;
35
- private addHubtypeTools;
36
- }
37
- export {};
@@ -1,106 +0,0 @@
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 {
10
- constructor(options) {
11
- this.name = options.name;
12
- this.instructions = this.addExtraInstructions(options.instructions, options.contactInfo, options.campaignsContext);
13
- this.tools = this.addHubtypeTools(options.tools, options.sourceIds);
14
- this.externalOutputMessagesSchemas = options.outputMessagesSchemas || [];
15
- this.inputGuardrails = [];
16
- this.llmConfig = options.llmConfig;
17
- this.logger = options.logger;
18
- if (options.inputGuardrailRules.length > 0) {
19
- const inputGuardrail = (0, guardrails_1.createInputGuardrail)(options.inputGuardrailRules, options.llmConfig, options.guardrailTrackingContext);
20
- this.inputGuardrails.push(inputGuardrail);
21
- }
22
- }
23
- build() {
24
- // When using standard OpenAI API, we need to specify the model
25
- // Azure OpenAI uses deployment name instead
26
- const model = this.llmConfig.modelName;
27
- const hasRetrieveKnowledge = this.tools.includes(tools_1.retrieveKnowledge);
28
- this.logger.logModelSettings({
29
- provider: constants_1.OPENAI_PROVIDER,
30
- model,
31
- reasoning: this.llmConfig.modelSettings.reasoning,
32
- text: this.llmConfig.modelSettings.text,
33
- toolChoice: this.llmConfig.modelSettings.toolChoice,
34
- hasRetrieveKnowledge,
35
- });
36
- return new agents_1.Agent({
37
- name: this.name,
38
- model,
39
- instructions: this.instructions,
40
- tools: this.tools,
41
- outputType: (0, structured_output_1.getOutputSchema)(this.externalOutputMessagesSchemas),
42
- inputGuardrails: this.inputGuardrails,
43
- outputGuardrails: [],
44
- });
45
- }
46
- addExtraInstructions(initialInstructions, contactInfo, campaignsContext) {
47
- const instructions = `<instructions>\n${initialInstructions.trim()}\n</instructions>`;
48
- const metadataInstructions = this.getMetadataInstructions();
49
- const contactInfoInstructions = this.getContactInfoInstructions(contactInfo);
50
- const campaignInstructions = this.getCampaignInstructions(campaignsContext);
51
- const outputInstructions = this.getOutputInstructions();
52
- return `${instructions}\n\n${metadataInstructions}\n\n${contactInfoInstructions}\n\n${campaignInstructions}\n\n${outputInstructions}`;
53
- }
54
- getContactInfoInstructions(contactInfo) {
55
- const structuredContactInfo = contactInfo
56
- .map(info => ` <contact_info>
57
- <name>${info.name}</name>
58
- <value>${info.value}</value>
59
- <type>${info.type}</type>
60
- ${info.description
61
- ? `<description>${info.description}</description>`
62
- : ''}
63
- </contact_info>`)
64
- .join('\n');
65
- return `<contact_info_fields>\n${structuredContactInfo}</contact_info_fields>`;
66
- }
67
- getMetadataInstructions() {
68
- const metadata = `Current Date: ${new Date().toISOString()}`;
69
- return `<metadata>\n${metadata}\n</metadata>`;
70
- }
71
- getCampaignInstructions(campaignsContext) {
72
- if (!campaignsContext || campaignsContext.length === 0) {
73
- return '';
74
- }
75
- const campaignsWithContext = campaignsContext.filter(campaign => campaign.agent_context);
76
- if (campaignsWithContext.length === 0) {
77
- return '';
78
- }
79
- return campaignsWithContext
80
- .map((campaign, index) => `<campaign_context_${index + 1}>\n${campaign.agent_context}\n</campaign_context_${index + 1}>`)
81
- .join('\n');
82
- }
83
- getOutputInstructions() {
84
- const example = {
85
- messages: [
86
- {
87
- type: 'text',
88
- content: {
89
- text: 'Hello, how can I help you today?',
90
- },
91
- },
92
- ],
93
- };
94
- const output = `Return a JSON that follows the output schema provided. Never return multiple output schemas concatenated by a line break.\n<example>\n${JSON.stringify(example)}\n</example>`;
95
- return `<output>\n${output}\n</output>`;
96
- }
97
- addHubtypeTools(tools, sourceIds) {
98
- const hubtypeTools = [...tools_1.mandatoryTools];
99
- if (sourceIds.length > 0) {
100
- hubtypeTools.push(tools_1.retrieveKnowledge);
101
- }
102
- return [...hubtypeTools, ...tools];
103
- }
104
- }
105
- exports.AIAgentBuilder = AIAgentBuilder;
106
- //# sourceMappingURL=agent-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-builder.js","sourceRoot":"","sources":["../../src/agent-builder.ts"],"names":[],"mappings":";;;AACA,2CAIuB;AAGvB,2CAA6C;AAE7C,6CAAmD;AAGnD,2DAAwE;AACxE,mCAA2D;AAoB3D,MAAa,cAAc;IAYzB,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,6BAA6B,GAAG,OAAO,CAAC,qBAAqB,IAAI,EAAE,CAAA;QACxE,IAAI,CAAC,eAAe,GAAG,EAAE,CAAA;QACzB,IAAI,CAAC,SAAS,GAAG,OAAO,CAA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EAAE,CAAC;YACtC,OAAO,EAAE,CAAA;QACX,CAAC;QACD,OAAO,oBAAoB;aACxB,GAAG,CACF,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAClB,qBAAqB,KAAK,GAAG,CAAC,MAAM,QAAQ,CAAC,aAAa,wBAAwB,KAAK,GAAG,CAAC,GAAG,CACjG;aACA,IAAI,CAAC,IAAI,CAAC,CAAA;IACf,CAAC;IAEO,qBAAqB;QAC3B,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,kCAAkC;qBACzC;iBACF;aACF;SACF,CAAA;QACD,MAAM,MAAM,GAAG,yIAAyI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,cAAc,CAAA;QAC7L,OAAO,aAAa,MAAM,aAAa,CAAA;IACzC,CAAC;IAEO,eAAe,CACrB,KAAmC,EACnC,SAAmB;QAEnB,MAAM,YAAY,GAAW,CAAC,GAAG,sBAAc,CAAC,CAAA;QAChD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,YAAY,CAAC,IAAI,CAAC,yBAAiB,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC,CAAA;IACpC,CAAC;CACF;AApJD,wCAoJC"}
@@ -1,7 +0,0 @@
1
- import type { ToolConfigJSON } from '@botonic/core';
2
- import type { CustomTool } from './types';
3
- /**
4
- * Maps custom AI agent tools to the format expected by bot config (e.g. for flow-builder).
5
- * Converts each tool's Zod schema to JSON Schema so it can be serialized in the config.
6
- */
7
- export declare function getToolsForBotConfig(customTools: CustomTool[]): ToolConfigJSON[];
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getToolsForBotConfig = getToolsForBotConfig;
4
- const zod_to_json_schema_1 = require("zod-to-json-schema");
5
- /**
6
- * Maps custom AI agent tools to the format expected by bot config (e.g. for flow-builder).
7
- * Converts each tool's Zod schema to JSON Schema so it can be serialized in the config.
8
- */
9
- function getToolsForBotConfig(customTools) {
10
- return customTools.map(tool => ({
11
- name: tool.name,
12
- description: tool.description,
13
- // Cast to avoid TS "Type instantiation is excessively deep" with zodToJsonSchema + ZodSchema
14
- schema: (0, zod_to_json_schema_1.zodToJsonSchema)(tool.schema, {
15
- $refStrategy: 'none',
16
- }),
17
- }));
18
- }
19
- //# sourceMappingURL=bot-config-tools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bot-config-tools.js","sourceRoot":"","sources":["../../src/bot-config-tools.ts"],"names":[],"mappings":";;AASA,oDAWC;AAnBD,2DAAoD;AAIpD;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,WAAyB;IAEzB,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,6FAA6F;QAC7F,MAAM,EAAE,IAAA,oCAAe,EAAC,IAAI,CAAC,MAAe,EAAE;YAC5C,YAAY,EAAE,MAAM;SACrB,CAA6B;KAC/B,CAAC,CAAC,CAAA;AACL,CAAC"}
@@ -1,11 +0,0 @@
1
- export declare const HUBTYPE_API_URL: string;
2
- export declare const OPENAI_API_KEY: string | undefined;
3
- export declare const OPENAI_MODEL: string;
4
- export declare const OPENAI_PROVIDER: 'openai' | 'azure';
5
- export declare const AZURE_OPENAI_API_KEY: string | undefined;
6
- export declare const AZURE_OPENAI_API_BASE: string | undefined;
7
- export declare const AZURE_OPENAI_API_VERSION: string;
8
- export declare const isProd: boolean;
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;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_TIMEOUT_16_SECONDS = exports.MAX_MEMORY_LENGTH = exports.isProd = exports.AZURE_OPENAI_API_VERSION = exports.AZURE_OPENAI_API_BASE = exports.AZURE_OPENAI_API_KEY = exports.OPENAI_PROVIDER = exports.OPENAI_MODEL = exports.OPENAI_API_KEY = exports.HUBTYPE_API_URL = void 0;
4
- exports.HUBTYPE_API_URL = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com';
5
- // OpenAI Provider Configuration
6
- exports.OPENAI_API_KEY = process.env.OPENAI_API_KEY; // pragma: allowlist secret
7
- exports.OPENAI_MODEL = process.env.OPENAI_MODEL || 'gpt-4.1-mini';
8
- exports.OPENAI_PROVIDER = process.env.OPENAI_PROVIDER || 'azure';
9
- // Azure OpenAI Configuration
10
- exports.AZURE_OPENAI_API_KEY = process.env.AZURE_OPENAI_API_KEY; // pragma: allowlist secret
11
- exports.AZURE_OPENAI_API_BASE = process.env.AZURE_OPENAI_API_BASE;
12
- exports.AZURE_OPENAI_API_VERSION = process.env.AZURE_OPENAI_API_VERSION || '2025-01-01-preview';
13
- exports.isProd = process.env.NODE_ENV === 'production';
14
- exports.MAX_MEMORY_LENGTH = 25;
15
- exports.DEFAULT_TIMEOUT_16_SECONDS = 16000;
16
- exports.DEFAULT_MAX_RETRIES = 2;
17
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;AAE1D,gCAAgC;AACnB,QAAA,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA,CAAC,2BAA2B;AACvE,QAAA,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,cAAc,CAAA;AACzD,QAAA,eAAe,GACzB,OAAO,CAAC,GAAG,CAAC,eAAsC,IAAI,OAAO,CAAA;AAEhE,6BAA6B;AAChB,QAAA,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA,CAAC,2BAA2B;AACnF,QAAA,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAA;AACzD,QAAA,wBAAwB,GACnC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,oBAAoB,CAAA;AAEjD,QAAA,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA;AAE9C,QAAA,iBAAiB,GAAG,EAAE,CAAA;AAEtB,QAAA,0BAA0B,GAAG,KAAK,CAAA;AAClC,QAAA,mBAAmB,GAAG,CAAC,CAAA"}
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDebugLogger = createDebugLogger;
4
- const constants_1 = require("./constants");
5
- const PREFIX = '[BotonicPluginAiAgents]';
6
- class EnabledDebugLogger {
7
- logInitialConfig(config) {
8
- console.log(`${PREFIX} === Plugin Initialization ===`);
9
- console.log(`${PREFIX} Provider: ${constants_1.OPENAI_PROVIDER}`);
10
- console.log(`${PREFIX} Message History API Version: ${config.messageHistoryApiVersion}`);
11
- console.log(`${PREFIX} Max Retries: ${config.maxRetries}`);
12
- console.log(`${PREFIX} Timeout: ${config.timeout}ms`);
13
- console.log(`${PREFIX} Custom Tools Registered: ${config.customToolNames.join(', ') || 'none'}`);
14
- 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,
19
- });
20
- console.log(`${PREFIX} === End Plugin Initialization ===`);
21
- }
22
- logAgentDebugInfo(aiAgentArgs, toolNames, messages) {
23
- console.log(`${PREFIX} === AI Agent Debug Info ===`);
24
- console.log(`${PREFIX} Agent Name: ${aiAgentArgs.name}`);
25
- console.log(`${PREFIX} Active Tools: ${JSON.stringify(toolNames)}`);
26
- console.log(`${PREFIX} Source IDs: ${JSON.stringify(aiAgentArgs.sourceIds || [])}`);
27
- console.log(`${PREFIX} Message History Count: ${messages.length}`);
28
- console.log(`${PREFIX} Input Guardrail Rules: ${aiAgentArgs.inputGuardrailRules?.length || 0}`);
29
- console.log(`${PREFIX} Instructions:`);
30
- console.log(aiAgentArgs.instructions);
31
- console.log(`${PREFIX} === End Debug Info ===`);
32
- }
33
- logModelSettings(settings) {
34
- console.log(`${PREFIX} === Agent Model Settings ===`);
35
- console.log(`${PREFIX} Has Retrieve Knowledge Tool: ${settings.hasRetrieveKnowledge}`);
36
- if (settings.reasoning) {
37
- console.log(`${PREFIX} Reasoning Effort: ${settings.reasoning.effort}`);
38
- }
39
- if (settings.text) {
40
- console.log(`${PREFIX} Text Verbosity: ${settings.text.verbosity}`);
41
- }
42
- if (settings.toolChoice) {
43
- console.log(`${PREFIX} Tool Choice: ${settings.toolChoice}`);
44
- }
45
- console.log(`${PREFIX} === End Model Settings ===`);
46
- }
47
- logRunnerStart(model, modelSettings) {
48
- console.log(`${PREFIX} === Runner Execution Start ===`);
49
- console.log(`${PREFIX} Model: ${model}`);
50
- console.log(`${PREFIX} Model Settings: ${JSON.stringify(modelSettings)}`);
51
- }
52
- logRunResult(runResult, startTime) {
53
- const elapsedMs = Date.now() - startTime;
54
- console.log(`${PREFIX} === Runner Execution Complete ===`);
55
- console.log(`${PREFIX} Execution Time: ${elapsedMs}ms`);
56
- console.log(`${PREFIX} Output Messages Count: ${runResult.messages.length}`);
57
- console.log(`${PREFIX} Exit: ${runResult.exit}`);
58
- console.log(`${PREFIX} Error: ${runResult.error}`);
59
- console.log(`${PREFIX} Tools Executed: ${JSON.stringify(runResult.toolsExecuted.map(t => t.toolName))}`);
60
- if (runResult.inputGuardrailsTriggered.length > 0) {
61
- console.log(`${PREFIX} Input Guardrails Triggered: ${runResult.inputGuardrailsTriggered.length}`);
62
- }
63
- if (runResult.outputGuardrailsTriggered.length > 0) {
64
- console.log(`${PREFIX} Output Guardrails Triggered: ${runResult.outputGuardrailsTriggered.length}`);
65
- }
66
- console.log(`${PREFIX} === End Runner Execution ===`);
67
- }
68
- logGuardrailTriggered() {
69
- console.log(`${PREFIX} Input guardrail triggered`);
70
- }
71
- logRunnerError(startTime, error) {
72
- const elapsedMs = Date.now() - startTime;
73
- console.log(`${PREFIX} Runner execution failed after ${elapsedMs}ms`);
74
- console.log(`${PREFIX} Error:`, error);
75
- }
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
- }
84
- class DisabledDebugLogger {
85
- logInitialConfig() { }
86
- logAgentDebugInfo() { }
87
- logModelSettings() { }
88
- logRunnerStart(_model, _modelSettings) { }
89
- logRunResult() { }
90
- logGuardrailTriggered() { }
91
- logRunnerError() { }
92
- logToolExecution() { }
93
- }
94
- function createDebugLogger(enableDebug) {
95
- return enableDebug ? new EnabledDebugLogger() : new DisabledDebugLogger();
96
- }
97
- //# sourceMappingURL=debug-logger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug-logger.js","sourceRoot":"","sources":["../../src/debug-logger.ts"],"names":[],"mappings":";;AAmKA,8CAEC;AAnKD,2CAAgE;AAGhE,MAAM,MAAM,GAAG,yBAAyB,CAAA;AAkCxC,MAAM,kBAAkB;IACtB,gBAAgB,CAAC,MAAyB;QACxC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,gCAAgC,CAAC,CA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U,CAAC;IAChC,cAAc,KAAU,CAAC;IACzB,gBAAgB,KAAU,CAAC;CAC5B;AAED,SAAgB,iBAAiB,CAAC,WAAoB;IACpD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAC,CAAC,IAAI,mBAAmB,EAAE,CAAA;AAC3E,CAAC"}
@@ -1 +0,0 @@
1
- export * from './input';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./input"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/guardrails/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB"}
@@ -1,10 +0,0 @@
1
- import { type InputGuardrail } from '@openai/agents';
2
- import type { LLMConfig } from '../llm-config';
3
- import type { GuardrailRule } from '../types';
4
- export interface GuardrailTrackingContext {
5
- botId: string;
6
- isTest: boolean;
7
- authToken: string;
8
- inferenceId: string;
9
- }
10
- export declare function createInputGuardrail(rules: GuardrailRule[], llmConfig: LLMConfig, trackingContext: GuardrailTrackingContext): InputGuardrail;