@botonic/plugin-ai-agents 0.36.0-alpha.1 → 0.36.0-alpha.10

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 (129) hide show
  1. package/README.md +14 -0
  2. package/lib/cjs/agent-builder.d.ts +10 -0
  3. package/lib/cjs/agent-builder.js +43 -0
  4. package/lib/cjs/agent-builder.js.map +1 -0
  5. package/lib/cjs/constants.d.ts +3 -2
  6. package/lib/cjs/constants.js +5 -4
  7. package/lib/cjs/constants.js.map +1 -1
  8. package/lib/{esm/hubtype-client.d.ts → cjs/hubtype-api-client.d.ts} +3 -1
  9. package/lib/cjs/hubtype-api-client.js +76 -0
  10. package/lib/cjs/hubtype-api-client.js.map +1 -0
  11. package/lib/cjs/index.d.ts +5 -2
  12. package/lib/cjs/index.js +40 -17
  13. package/lib/cjs/index.js.map +1 -1
  14. package/lib/cjs/openai.d.ts +1 -0
  15. package/lib/cjs/openai.js +23 -0
  16. package/lib/cjs/openai.js.map +1 -0
  17. package/lib/cjs/runner.d.ts +7 -0
  18. package/lib/cjs/runner.js +35 -0
  19. package/lib/cjs/runner.js.map +1 -0
  20. package/lib/cjs/structured-output/carousel.d.ts +100 -0
  21. package/lib/cjs/structured-output/carousel.js +21 -0
  22. package/lib/cjs/structured-output/carousel.js.map +1 -0
  23. package/lib/cjs/structured-output/exit.d.ts +12 -0
  24. package/lib/cjs/structured-output/exit.js +11 -0
  25. package/lib/cjs/structured-output/exit.js.map +1 -0
  26. package/lib/cjs/structured-output/index.d.ts +198 -0
  27. package/lib/cjs/structured-output/index.js +14 -0
  28. package/lib/cjs/structured-output/index.js.map +1 -0
  29. package/lib/cjs/structured-output/shared.d.ts +3 -0
  30. package/lib/cjs/structured-output/shared.js +3 -0
  31. package/lib/cjs/structured-output/shared.js.map +1 -0
  32. package/lib/cjs/structured-output/text-with-buttons.d.ts +34 -0
  33. package/lib/cjs/structured-output/text-with-buttons.js +15 -0
  34. package/lib/cjs/structured-output/text-with-buttons.js.map +1 -0
  35. package/lib/cjs/structured-output/text.d.ts +28 -0
  36. package/lib/cjs/structured-output/text.js +13 -0
  37. package/lib/cjs/structured-output/text.js.map +1 -0
  38. package/lib/cjs/tools/index.d.ts +2 -0
  39. package/lib/cjs/tools/index.js +5 -0
  40. package/lib/cjs/tools/index.js.map +1 -0
  41. package/lib/cjs/types.d.ts +20 -22
  42. package/lib/esm/agent-builder.d.ts +10 -0
  43. package/lib/esm/agent-builder.js +39 -0
  44. package/lib/esm/agent-builder.js.map +1 -0
  45. package/lib/esm/constants.d.ts +3 -2
  46. package/lib/esm/constants.js +4 -3
  47. package/lib/esm/constants.js.map +1 -1
  48. package/lib/{cjs/hubtype-client.d.ts → esm/hubtype-api-client.d.ts} +3 -1
  49. package/lib/esm/hubtype-api-client.js +72 -0
  50. package/lib/esm/hubtype-api-client.js.map +1 -0
  51. package/lib/esm/index.d.ts +5 -2
  52. package/lib/esm/index.js +39 -16
  53. package/lib/esm/index.js.map +1 -1
  54. package/lib/esm/openai.d.ts +1 -0
  55. package/lib/esm/openai.js +19 -0
  56. package/lib/esm/openai.js.map +1 -0
  57. package/lib/esm/runner.d.ts +7 -0
  58. package/lib/esm/runner.js +31 -0
  59. package/lib/esm/runner.js.map +1 -0
  60. package/lib/esm/structured-output/carousel.d.ts +100 -0
  61. package/lib/esm/structured-output/carousel.js +18 -0
  62. package/lib/esm/structured-output/carousel.js.map +1 -0
  63. package/lib/esm/structured-output/exit.d.ts +12 -0
  64. package/lib/esm/structured-output/exit.js +7 -0
  65. package/lib/esm/structured-output/exit.js.map +1 -0
  66. package/lib/esm/structured-output/index.d.ts +198 -0
  67. package/lib/esm/structured-output/index.js +11 -0
  68. package/lib/esm/structured-output/index.js.map +1 -0
  69. package/lib/esm/structured-output/shared.d.ts +3 -0
  70. package/lib/esm/structured-output/shared.js +2 -0
  71. package/lib/esm/structured-output/shared.js.map +1 -0
  72. package/lib/esm/structured-output/text-with-buttons.d.ts +34 -0
  73. package/lib/esm/structured-output/text-with-buttons.js +11 -0
  74. package/lib/esm/structured-output/text-with-buttons.js.map +1 -0
  75. package/lib/esm/structured-output/text.d.ts +28 -0
  76. package/lib/esm/structured-output/text.js +10 -0
  77. package/lib/esm/structured-output/text.js.map +1 -0
  78. package/lib/esm/tools/index.d.ts +2 -0
  79. package/lib/esm/tools/index.js +2 -0
  80. package/lib/esm/tools/index.js.map +1 -0
  81. package/lib/esm/types.d.ts +20 -22
  82. package/package.json +7 -7
  83. package/src/agent-builder.ts +48 -0
  84. package/src/constants.ts +7 -4
  85. package/src/hubtype-api-client.ts +89 -0
  86. package/src/index.ts +56 -19
  87. package/src/openai.ts +30 -0
  88. package/src/runner.ts +43 -0
  89. package/src/structured-output/carousel.ts +36 -0
  90. package/src/structured-output/exit.ts +15 -0
  91. package/src/structured-output/index.ts +27 -0
  92. package/src/structured-output/shared.ts +3 -0
  93. package/src/structured-output/text-with-buttons.ts +23 -0
  94. package/src/structured-output/text.ts +19 -0
  95. package/src/tools/index.ts +3 -0
  96. package/src/types.ts +27 -29
  97. package/lib/cjs/ai-agent-client.d.ts +0 -11
  98. package/lib/cjs/ai-agent-client.js +0 -50
  99. package/lib/cjs/ai-agent-client.js.map +0 -1
  100. package/lib/cjs/errors.d.ts +0 -3
  101. package/lib/cjs/errors.js +0 -11
  102. package/lib/cjs/errors.js.map +0 -1
  103. package/lib/cjs/hubtype-client.js +0 -36
  104. package/lib/cjs/hubtype-client.js.map +0 -1
  105. package/lib/cjs/tools.d.ts +0 -6
  106. package/lib/cjs/tools.js +0 -41
  107. package/lib/cjs/tools.js.map +0 -1
  108. package/lib/cjs/utils.d.ts +0 -2
  109. package/lib/cjs/utils.js +0 -22
  110. package/lib/cjs/utils.js.map +0 -1
  111. package/lib/esm/ai-agent-client.d.ts +0 -11
  112. package/lib/esm/ai-agent-client.js +0 -46
  113. package/lib/esm/ai-agent-client.js.map +0 -1
  114. package/lib/esm/errors.d.ts +0 -3
  115. package/lib/esm/errors.js +0 -7
  116. package/lib/esm/errors.js.map +0 -1
  117. package/lib/esm/hubtype-client.js +0 -32
  118. package/lib/esm/hubtype-client.js.map +0 -1
  119. package/lib/esm/tools.d.ts +0 -6
  120. package/lib/esm/tools.js +0 -38
  121. package/lib/esm/tools.js.map +0 -1
  122. package/lib/esm/utils.d.ts +0 -2
  123. package/lib/esm/utils.js +0 -18
  124. package/lib/esm/utils.js.map +0 -1
  125. package/src/ai-agent-client.ts +0 -73
  126. package/src/errors.ts +0 -6
  127. package/src/hubtype-client.ts +0 -43
  128. package/src/tools.ts +0 -51
  129. package/src/utils.ts +0 -24
package/lib/esm/index.js CHANGED
@@ -1,34 +1,36 @@
1
1
  import { __awaiter } from "tslib";
2
- import { AiAgentClient } from './ai-agent-client';
3
- import { HubtypeClient } from './hubtype-client';
4
- import { MANDATORY_TOOLS } from './tools';
5
- import { loadChatModel } from './utils';
6
- const isProd = process.env.NODE_ENV === 'production';
2
+ import { tool } from '@openai/agents';
3
+ import { AIAgentBuilder } from './agent-builder';
4
+ import { isProd } from './constants';
5
+ import { HubtypeApiClient } from './hubtype-api-client';
6
+ import { setUpOpenAI } from './openai';
7
+ import { AIAgentRunner } from './runner';
7
8
  export default class BotonicPluginAiAgents {
8
9
  constructor(options) {
10
+ this.toolDefinitions = [];
11
+ setUpOpenAI();
9
12
  this.authToken = options === null || options === void 0 ? void 0 : options.authToken;
13
+ this.toolDefinitions = (options === null || options === void 0 ? void 0 : options.customTools) || [];
10
14
  }
11
15
  pre() {
12
16
  return;
13
17
  }
14
18
  getInference(request, aiAgentArgs) {
19
+ var _a;
15
20
  return __awaiter(this, void 0, void 0, function* () {
16
21
  try {
17
22
  const authToken = isProd ? request.session._access_token : this.authToken;
18
23
  if (!authToken) {
19
24
  throw new Error('Auth token is required');
20
25
  }
21
- const hubtypeClient = new HubtypeClient(authToken);
22
- const messages = isProd
23
- ? yield hubtypeClient.getMessages(request, 10)
24
- : [{ role: 'user', content: request.input.data }];
25
- const customTools = [];
26
- const chatModel = loadChatModel('azureOpenAI');
27
- const aiAgentClient = new AiAgentClient(aiAgentArgs, chatModel, [
28
- ...customTools,
29
- ...MANDATORY_TOOLS,
30
- ]);
31
- return yield aiAgentClient.runAgent(messages);
26
+ const tools = this.buildTools(((_a = aiAgentArgs.activeTools) === null || _a === void 0 ? void 0 : _a.map(tool => tool.name)) || []);
27
+ const agent = new AIAgentBuilder(aiAgentArgs.name, aiAgentArgs.instructions, tools).build();
28
+ const messages = yield this.getMessages(request, authToken, 25);
29
+ const context = {
30
+ authToken,
31
+ };
32
+ const runner = new AIAgentRunner(agent);
33
+ return yield runner.run(messages, context);
32
34
  }
33
35
  catch (error) {
34
36
  console.error('error plugin returns undefined', error);
@@ -36,6 +38,27 @@ export default class BotonicPluginAiAgents {
36
38
  }
37
39
  });
38
40
  }
41
+ getMessages(request, authToken, memoryLength) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ if (isProd) {
44
+ const hubtypeClient = new HubtypeApiClient(authToken);
45
+ return yield hubtypeClient.getMessages(request, memoryLength);
46
+ }
47
+ const hubtypeClient = new HubtypeApiClient(authToken);
48
+ return yield hubtypeClient.getLocalMessages(memoryLength);
49
+ });
50
+ }
51
+ buildTools(activeToolNames) {
52
+ const availableTools = this.toolDefinitions.filter(tool => activeToolNames.includes(tool.name));
53
+ return availableTools.map(toolDefinition => {
54
+ return tool({
55
+ name: toolDefinition.name,
56
+ description: toolDefinition.description,
57
+ parameters: toolDefinition.schema,
58
+ execute: toolDefinition.func,
59
+ });
60
+ });
61
+ }
39
62
  }
40
63
  export * from './types';
41
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO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AAC,MAAM;gBACjC,OAAO,EAAE,cAAc,CAAC,IAAI;aAC7B,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAED,cAAc,SAAS,CAAA"}
@@ -0,0 +1 @@
1
+ export declare function setUpOpenAI(): void;
@@ -0,0 +1,19 @@
1
+ import { setDefaultOpenAIClient, setOpenAIAPI, setTracingDisabled, } from '@openai/agents';
2
+ import { AzureOpenAI } from 'openai';
3
+ import { AZURE_OPENAI_API_BASE, AZURE_OPENAI_API_DEPLOYMENT_NAME, AZURE_OPENAI_API_KEY, AZURE_OPENAI_API_VERSION, isProd, } from './constants';
4
+ export function setUpOpenAI() {
5
+ setAzureOpenAIClient();
6
+ setOpenAIAPI('chat_completions');
7
+ setTracingDisabled(true);
8
+ }
9
+ function setAzureOpenAIClient() {
10
+ const client = new AzureOpenAI({
11
+ apiKey: AZURE_OPENAI_API_KEY,
12
+ apiVersion: AZURE_OPENAI_API_VERSION,
13
+ deployment: AZURE_OPENAI_API_DEPLOYMENT_NAME,
14
+ baseURL: AZURE_OPENAI_API_BASE,
15
+ dangerouslyAllowBrowser: !isProd,
16
+ });
17
+ setDefaultOpenAIClient(client);
18
+ }
19
+ //# sourceMappingURL=openai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/openai.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EACL,qBAAqB,EACrB,gCAAgC,EAChC,oBAAoB,EACpB,wBAAwB,EACxB,MAAM,GACP,MAAM,aAAa,CAAA;AAEpB,MAAM,UAAU,WAAW;IACzB,oBAAoB,EAAE,CAAA;IACtB,YAAY,CAAC,kBAAkB,CAAC,CAAA;IAChC,kBAAkB,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAED,SAAS,oBAAoB;IAC3B,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC;QAC7B,MAAM,EAAE,oBAAoB;QAC5B,UAAU,EAAE,wBAAwB;QACpC,UAAU,EAAE,gCAAgC;QAC5C,OAAO,EAAE,qBAAqB;QAC9B,uBAAuB,EAAE,CAAC,MAAM;KACjC,CAAC,CAAA;IACF,sBAAsB,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { AIAgent, AgenticInputMessage, AgenticOutputMessage, Context } from './types';
2
+ export declare class AIAgentRunner {
3
+ private agent;
4
+ constructor(agent: AIAgent);
5
+ run(messages: AgenticInputMessage[], context: Context, maxRetries?: number): Promise<AgenticOutputMessage[]>;
6
+ private runWithRetry;
7
+ }
@@ -0,0 +1,31 @@
1
+ import { __awaiter } from "tslib";
2
+ import { Runner } from '@openai/agents';
3
+ export class AIAgentRunner {
4
+ constructor(agent) {
5
+ this.agent = agent;
6
+ }
7
+ run(messages, context, maxRetries = 1) {
8
+ return __awaiter(this, void 0, void 0, function* () {
9
+ return this.runWithRetry(messages, context, maxRetries, 1);
10
+ });
11
+ }
12
+ runWithRetry(messages, context, maxRetries, attempt) {
13
+ var _a;
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ try {
16
+ const runner = new Runner({
17
+ modelSettings: { temperature: 0 },
18
+ });
19
+ const result = yield runner.run(this.agent, messages, { context });
20
+ return ((_a = result.finalOutput) === null || _a === void 0 ? void 0 : _a.messages) || [];
21
+ }
22
+ catch (error) {
23
+ if (attempt > maxRetries) {
24
+ throw error;
25
+ }
26
+ return this.runWithRetry(messages, context, maxRetries, attempt + 1);
27
+ }
28
+ });
29
+ }
30
+ }
31
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAQvC,MAAM,OAAO,aAAa;IAGxB,YAAY,KAAc;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEK,GAAG,CACP,QAA+B,EAC/B,OAAgB,EAChB,aAAqB,CAAC;;YAEtB,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;QAC5D,CAAC;KAAA;IAEa,YAAY,CACxB,QAA+B,EAC/B,OAAgB,EAChB,UAAkB,EAClB,OAAe;;;YAEf,IAAI;gBACF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;oBACxB,aAAa,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;iBAClC,CAAC,CAAA;gBACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;gBAClE,OAAO,CAAA,MAAA,MAAM,CAAC,WAAW,0CAAE,QAAQ,KAAI,EAAE,CAAA;aAC1C;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,OAAO,GAAG,UAAU,EAAE;oBACxB,MAAM,KAAK,CAAA;iBACZ;gBACD,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,GAAG,CAAC,CAAC,CAAA;aACrE;;KACF;CACF"}
@@ -0,0 +1,100 @@
1
+ import { z } from 'zod';
2
+ import { BaseMessage } from './shared';
3
+ interface CarouselElement {
4
+ title: string;
5
+ subtitle: string;
6
+ image: string;
7
+ button: {
8
+ text: string;
9
+ url: string;
10
+ };
11
+ }
12
+ export interface CarouselMessage extends BaseMessage {
13
+ type: 'carousel';
14
+ content: {
15
+ elements: CarouselElement[];
16
+ };
17
+ }
18
+ export declare const CarouselSchema: z.ZodObject<{
19
+ type: z.ZodEnum<["carousel"]>;
20
+ content: z.ZodObject<{
21
+ elements: z.ZodArray<z.ZodObject<{
22
+ title: z.ZodString;
23
+ subtitle: z.ZodString;
24
+ image: z.ZodString;
25
+ button: z.ZodObject<{
26
+ text: z.ZodString;
27
+ url: z.ZodString;
28
+ }, "strip", z.ZodTypeAny, {
29
+ text: string;
30
+ url: string;
31
+ }, {
32
+ text: string;
33
+ url: string;
34
+ }>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ title: string;
37
+ subtitle: string;
38
+ image: string;
39
+ button: {
40
+ text: string;
41
+ url: string;
42
+ };
43
+ }, {
44
+ title: string;
45
+ subtitle: string;
46
+ image: string;
47
+ button: {
48
+ text: string;
49
+ url: string;
50
+ };
51
+ }>, "many">;
52
+ }, "strip", z.ZodTypeAny, {
53
+ elements: {
54
+ title: string;
55
+ subtitle: string;
56
+ image: string;
57
+ button: {
58
+ text: string;
59
+ url: string;
60
+ };
61
+ }[];
62
+ }, {
63
+ elements: {
64
+ title: string;
65
+ subtitle: string;
66
+ image: string;
67
+ button: {
68
+ text: string;
69
+ url: string;
70
+ };
71
+ }[];
72
+ }>;
73
+ }, "strip", z.ZodTypeAny, {
74
+ type: "carousel";
75
+ content: {
76
+ elements: {
77
+ title: string;
78
+ subtitle: string;
79
+ image: string;
80
+ button: {
81
+ text: string;
82
+ url: string;
83
+ };
84
+ }[];
85
+ };
86
+ }, {
87
+ type: "carousel";
88
+ content: {
89
+ elements: {
90
+ title: string;
91
+ subtitle: string;
92
+ image: string;
93
+ button: {
94
+ text: string;
95
+ url: string;
96
+ };
97
+ }[];
98
+ };
99
+ }>;
100
+ export {};
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ export const CarouselSchema = z
3
+ .object({
4
+ type: z.enum(['carousel']),
5
+ content: z.object({
6
+ elements: z.array(z.object({
7
+ title: z.string(),
8
+ subtitle: z.string(),
9
+ image: z.string(),
10
+ button: z.object({
11
+ text: z.string(),
12
+ url: z.string(),
13
+ }),
14
+ })),
15
+ }),
16
+ })
17
+ .describe('A carousel message containing a list of elements');
18
+ //# sourceMappingURL=carousel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carousel.js","sourceRoot":"","sources":["../../../src/structured-output/carousel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAkBvB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC;IAC1B,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,QAAQ,EAAE,CAAC,CAAC,KAAK,CACf,CAAC,CAAC,MAAM,CAAC;YACP,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;YACjB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;YACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;YACjB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;gBACf,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;gBAChB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;aAChB,CAAC;SACH,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,kDAAkD,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import z from 'zod';
2
+ import { BaseMessage } from './shared';
3
+ export interface ExitMessage extends BaseMessage {
4
+ type: 'exit';
5
+ }
6
+ export declare const ExitSchema: z.ZodObject<{
7
+ type: z.ZodEnum<["exit"]>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ type: "exit";
10
+ }, {
11
+ type: "exit";
12
+ }>;
@@ -0,0 +1,7 @@
1
+ import z from 'zod';
2
+ export const ExitSchema = z
3
+ .object({
4
+ type: z.enum(['exit']),
5
+ })
6
+ .describe('An exit message. This message should only be used to exit the agent due to out of context or the user asking to exit the conversation');
7
+ //# sourceMappingURL=exit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit.js","sourceRoot":"","sources":["../../../src/structured-output/exit.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAQnB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;CACvB,CAAC;KACD,QAAQ,CACP,uIAAuI,CACxI,CAAA"}
@@ -0,0 +1,198 @@
1
+ import { z } from 'zod';
2
+ import { CarouselMessage } from './carousel';
3
+ import { ExitMessage } from './exit';
4
+ import { TextMessage } from './text';
5
+ import { TextWithButtonsMessage } from './text-with-buttons';
6
+ export type OutputMessage = TextMessage | TextWithButtonsMessage | CarouselMessage | ExitMessage;
7
+ export interface Output {
8
+ messages: OutputMessage[];
9
+ }
10
+ export declare const OutputSchema: z.ZodObject<{
11
+ messages: z.ZodArray<z.ZodUnion<[z.ZodObject<{
12
+ type: z.ZodEnum<["text"]>;
13
+ content: z.ZodObject<{
14
+ text: z.ZodString;
15
+ }, "strip", z.ZodTypeAny, {
16
+ text: string;
17
+ }, {
18
+ text: string;
19
+ }>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ type: "text";
22
+ content: {
23
+ text: string;
24
+ };
25
+ }, {
26
+ type: "text";
27
+ content: {
28
+ text: string;
29
+ };
30
+ }>, z.ZodObject<{
31
+ type: z.ZodEnum<["textWithButtons"]>;
32
+ content: z.ZodObject<{
33
+ text: z.ZodString;
34
+ buttons: z.ZodArray<z.ZodString, "many">;
35
+ }, "strip", z.ZodTypeAny, {
36
+ text: string;
37
+ buttons: string[];
38
+ }, {
39
+ text: string;
40
+ buttons: string[];
41
+ }>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ type: "textWithButtons";
44
+ content: {
45
+ text: string;
46
+ buttons: string[];
47
+ };
48
+ }, {
49
+ type: "textWithButtons";
50
+ content: {
51
+ text: string;
52
+ buttons: string[];
53
+ };
54
+ }>, z.ZodObject<{
55
+ type: z.ZodEnum<["carousel"]>;
56
+ content: z.ZodObject<{
57
+ elements: z.ZodArray<z.ZodObject<{
58
+ title: z.ZodString;
59
+ subtitle: z.ZodString;
60
+ image: z.ZodString;
61
+ button: z.ZodObject<{
62
+ text: z.ZodString;
63
+ url: z.ZodString;
64
+ }, "strip", z.ZodTypeAny, {
65
+ text: string;
66
+ url: string;
67
+ }, {
68
+ text: string;
69
+ url: string;
70
+ }>;
71
+ }, "strip", z.ZodTypeAny, {
72
+ title: string;
73
+ subtitle: string;
74
+ image: string;
75
+ button: {
76
+ text: string;
77
+ url: string;
78
+ };
79
+ }, {
80
+ title: string;
81
+ subtitle: string;
82
+ image: string;
83
+ button: {
84
+ text: string;
85
+ url: string;
86
+ };
87
+ }>, "many">;
88
+ }, "strip", z.ZodTypeAny, {
89
+ elements: {
90
+ title: string;
91
+ subtitle: string;
92
+ image: string;
93
+ button: {
94
+ text: string;
95
+ url: string;
96
+ };
97
+ }[];
98
+ }, {
99
+ elements: {
100
+ title: string;
101
+ subtitle: string;
102
+ image: string;
103
+ button: {
104
+ text: string;
105
+ url: string;
106
+ };
107
+ }[];
108
+ }>;
109
+ }, "strip", z.ZodTypeAny, {
110
+ type: "carousel";
111
+ content: {
112
+ elements: {
113
+ title: string;
114
+ subtitle: string;
115
+ image: string;
116
+ button: {
117
+ text: string;
118
+ url: string;
119
+ };
120
+ }[];
121
+ };
122
+ }, {
123
+ type: "carousel";
124
+ content: {
125
+ elements: {
126
+ title: string;
127
+ subtitle: string;
128
+ image: string;
129
+ button: {
130
+ text: string;
131
+ url: string;
132
+ };
133
+ }[];
134
+ };
135
+ }>, z.ZodObject<{
136
+ type: z.ZodEnum<["exit"]>;
137
+ }, "strip", z.ZodTypeAny, {
138
+ type: "exit";
139
+ }, {
140
+ type: "exit";
141
+ }>]>, "many">;
142
+ }, "strip", z.ZodTypeAny, {
143
+ messages: ({
144
+ type: "carousel";
145
+ content: {
146
+ elements: {
147
+ title: string;
148
+ subtitle: string;
149
+ image: string;
150
+ button: {
151
+ text: string;
152
+ url: string;
153
+ };
154
+ }[];
155
+ };
156
+ } | {
157
+ type: "exit";
158
+ } | {
159
+ type: "text";
160
+ content: {
161
+ text: string;
162
+ };
163
+ } | {
164
+ type: "textWithButtons";
165
+ content: {
166
+ text: string;
167
+ buttons: string[];
168
+ };
169
+ })[];
170
+ }, {
171
+ messages: ({
172
+ type: "carousel";
173
+ content: {
174
+ elements: {
175
+ title: string;
176
+ subtitle: string;
177
+ image: string;
178
+ button: {
179
+ text: string;
180
+ url: string;
181
+ };
182
+ }[];
183
+ };
184
+ } | {
185
+ type: "exit";
186
+ } | {
187
+ type: "text";
188
+ content: {
189
+ text: string;
190
+ };
191
+ } | {
192
+ type: "textWithButtons";
193
+ content: {
194
+ text: string;
195
+ buttons: string[];
196
+ };
197
+ })[];
198
+ }>;
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ import { CarouselSchema } from './carousel';
3
+ import { ExitSchema } from './exit';
4
+ import { TextSchema } from './text';
5
+ import { TextWithButtonsSchema, } from './text-with-buttons';
6
+ export const OutputSchema = z
7
+ .object({
8
+ messages: z.array(z.union([TextSchema, TextWithButtonsSchema, CarouselSchema, ExitSchema])),
9
+ })
10
+ .describe('The messages to be sent to the user');
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structured-output/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAmB,cAAc,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAe,UAAU,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAe,UAAU,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAEL,qBAAqB,GACtB,MAAM,qBAAqB,CAAA;AAY5B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,KAAK,CACf,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,qBAAqB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CACzE;CACF,CAAC;KACD,QAAQ,CAAC,qCAAqC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export interface BaseMessage {
2
+ type: 'text' | 'textWithButtons' | 'carousel' | 'exit';
3
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/structured-output/shared.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import z from 'zod';
2
+ import { BaseMessage } from './shared';
3
+ export interface TextWithButtonsMessage extends BaseMessage {
4
+ type: 'textWithButtons';
5
+ content: {
6
+ text: string;
7
+ buttons: string[];
8
+ };
9
+ }
10
+ export declare const TextWithButtonsSchema: z.ZodObject<{
11
+ type: z.ZodEnum<["textWithButtons"]>;
12
+ content: z.ZodObject<{
13
+ text: z.ZodString;
14
+ buttons: z.ZodArray<z.ZodString, "many">;
15
+ }, "strip", z.ZodTypeAny, {
16
+ text: string;
17
+ buttons: string[];
18
+ }, {
19
+ text: string;
20
+ buttons: string[];
21
+ }>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ type: "textWithButtons";
24
+ content: {
25
+ text: string;
26
+ buttons: string[];
27
+ };
28
+ }, {
29
+ type: "textWithButtons";
30
+ content: {
31
+ text: string;
32
+ buttons: string[];
33
+ };
34
+ }>;
@@ -0,0 +1,11 @@
1
+ import z from 'zod';
2
+ export const TextWithButtonsSchema = z
3
+ .object({
4
+ type: z.enum(['textWithButtons']),
5
+ content: z.object({
6
+ text: z.string(),
7
+ buttons: z.array(z.string()),
8
+ }),
9
+ })
10
+ .describe('A text message with buttons to allow the user to use quick replies');
11
+ //# sourceMappingURL=text-with-buttons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-with-buttons.js","sourceRoot":"","sources":["../../../src/structured-output/text-with-buttons.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAYnB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACjC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KAC7B,CAAC;CACH,CAAC;KACD,QAAQ,CACP,oEAAoE,CACrE,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import { BaseMessage } from './shared';
3
+ export interface TextMessage extends BaseMessage {
4
+ type: 'text';
5
+ content: {
6
+ text: string;
7
+ };
8
+ }
9
+ export declare const TextSchema: z.ZodObject<{
10
+ type: z.ZodEnum<["text"]>;
11
+ content: z.ZodObject<{
12
+ text: z.ZodString;
13
+ }, "strip", z.ZodTypeAny, {
14
+ text: string;
15
+ }, {
16
+ text: string;
17
+ }>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ type: "text";
20
+ content: {
21
+ text: string;
22
+ };
23
+ }, {
24
+ type: "text";
25
+ content: {
26
+ text: string;
27
+ };
28
+ }>;
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export const TextSchema = z
3
+ .object({
4
+ type: z.enum(['text']),
5
+ content: z.object({
6
+ text: z.string(),
7
+ }),
8
+ })
9
+ .describe('A text message');
10
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/structured-output/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAWvB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;KACjB,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,gBAAgB,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { Tool } from '../types';
2
+ export declare const mandatoryTools: Tool[];
@@ -0,0 +1,2 @@
1
+ export const mandatoryTools = [];
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAW,EAAE,CAAA"}