@botonic/plugin-ai-agents 0.36.0-alpha.0 → 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 (110) 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 +5 -0
  6. package/lib/cjs/constants.js +6 -1
  7. package/lib/cjs/constants.js.map +1 -1
  8. package/lib/cjs/hubtype-api-client.d.ts +9 -0
  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 +8 -5
  12. package/lib/cjs/index.js +52 -4
  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 +21 -25
  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 +5 -0
  46. package/lib/esm/constants.js +5 -0
  47. package/lib/esm/constants.js.map +1 -1
  48. package/lib/esm/hubtype-api-client.d.ts +9 -0
  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 +8 -5
  52. package/lib/esm/index.js +52 -4
  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 +21 -25
  82. package/package.json +7 -4
  83. package/src/agent-builder.ts +48 -0
  84. package/src/constants.ts +9 -0
  85. package/src/hubtype-api-client.ts +89 -0
  86. package/src/index.ts +77 -7
  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 -23
  97. package/lib/cjs/ai-agent-client.d.ts +0 -12
  98. package/lib/cjs/ai-agent-client.js +0 -78
  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/esm/ai-agent-client.d.ts +0 -12
  104. package/lib/esm/ai-agent-client.js +0 -74
  105. package/lib/esm/ai-agent-client.js.map +0 -1
  106. package/lib/esm/errors.d.ts +0 -3
  107. package/lib/esm/errors.js +0 -7
  108. package/lib/esm/errors.js.map +0 -1
  109. package/src/ai-agent-client.ts +0 -112
  110. package/src/errors.ts +0 -6
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGjD,MAAM,CAAC,OAAO,OAAO,qBAAqB;IAGxC;QACE,IAAI,CAAC,aAA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AAC,cAAc,CAAC,EAAE;YACzC,OAAO,IAAI,CAAoB;gBAC7B,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,WAAW,EAAE,cAAc,CAAC,WAAW;gBACvC,UAAU,EAAE,cAAc,CAAC,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"}
@@ -1,31 +1,27 @@
1
- export interface AiAgentArgs {
2
- name: string;
3
- instructions: string;
1
+ import { Agent, AgentInputItem, RunContext, Tool as OpenAITool } from '@openai/agents';
2
+ import { ZodSchema } from 'zod';
3
+ import { OutputMessage, OutputSchema } from './structured-output';
4
+ export interface Context {
5
+ authToken: string;
4
6
  }
5
- export interface Config {
6
- headers: {
7
- Authorization: string;
8
- 'Content-Type': string;
9
- };
10
- }
11
- export interface AiAgentRequestDataTest {
12
- messages: {
13
- role: MessageRole;
14
- content: string;
15
- }[];
7
+ export interface CustomTool {
16
8
  name: string;
17
- instructions: string;
9
+ description: string;
10
+ schema: ZodSchema;
11
+ func: (input?: any, runContext?: RunContext<Context>) => Promise<any>;
12
+ }
13
+ export type Tool = OpenAITool<Context>;
14
+ export type AIAgent = Agent<Context, typeof OutputSchema>;
15
+ export interface PluginAiAgentOptions {
16
+ authToken?: string;
17
+ customTools?: CustomTool[];
18
18
  }
19
- export type MessageRole = 'user' | 'assistant';
20
- export interface AiAgentRequestData {
21
- message: string;
22
- memory_length: number;
19
+ export interface AiAgentArgs {
23
20
  name: string;
24
21
  instructions: string;
22
+ activeTools?: {
23
+ name: string;
24
+ }[];
25
25
  }
26
- export interface AiAgentResponse {
27
- message: {
28
- role: string;
29
- content: string;
30
- };
31
- }
26
+ export type AgenticInputMessage = AgentInputItem;
27
+ export type AgenticOutputMessage = OutputMessage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botonic/plugin-ai-agents",
3
- "version": "0.36.0-alpha.0",
3
+ "version": "0.36.0-alpha.10",
4
4
  "main": "./lib/cjs/index.js",
5
5
  "module": "./lib/esm/index.js",
6
6
  "description": "Use AI Agents to generate your contents",
@@ -13,9 +13,12 @@
13
13
  "lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.ts*'"
14
14
  },
15
15
  "dependencies": {
16
- "@botonic/core": "^0.35.0",
17
- "axios": "^1.9.0",
18
- "uuid": "^10.0.0"
16
+ "@botonic/core": "^0.36.0",
17
+ "@openai/agents": "^0.0.10",
18
+ "axios": "^1.10.0",
19
+ "openai": "^5.8.3",
20
+ "uuid": "^10.0.0",
21
+ "zod": "^3.25.57"
19
22
  },
20
23
  "devDependencies": {
21
24
  "@types/uuid": "^10.0.0"