@botonic/plugin-ai-agents 0.57.0-rslib-esm.1 → 0.57.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 (224) hide show
  1. package/lib/{agents → cjs/agents}/base-agent.d.ts +4 -4
  2. package/lib/cjs/agents/base-agent.js +39 -0
  3. package/lib/cjs/agents/base-agent.js.map +1 -0
  4. package/lib/cjs/agents/index.d.ts +2 -0
  5. package/lib/cjs/agents/index.js +8 -0
  6. package/lib/cjs/agents/index.js.map +1 -0
  7. package/lib/{agents → cjs/agents}/router-agent.d.ts +5 -5
  8. package/lib/cjs/agents/router-agent.js +33 -0
  9. package/lib/cjs/agents/router-agent.js.map +1 -0
  10. package/lib/{agents → cjs/agents}/specialist-agent.d.ts +5 -5
  11. package/lib/{agents → cjs/agents}/specialist-agent.js +45 -65
  12. package/lib/cjs/agents/specialist-agent.js.map +1 -0
  13. package/lib/{bot-config-tools.d.ts → cjs/bot-config-tools.d.ts} +1 -1
  14. package/lib/cjs/bot-config-tools.js +18 -0
  15. package/lib/cjs/bot-config-tools.js.map +1 -0
  16. package/lib/cjs/constants.js +25 -0
  17. package/lib/cjs/constants.js.map +1 -0
  18. package/lib/{debug-logger.d.ts → cjs/debug-logger.d.ts} +1 -1
  19. package/lib/{debug-logger.js → cjs/debug-logger.js} +9 -14
  20. package/lib/cjs/debug-logger.js.map +1 -0
  21. package/lib/cjs/guardrails/index.d.ts +1 -0
  22. package/lib/cjs/guardrails/index.js +5 -0
  23. package/lib/cjs/guardrails/index.js.map +1 -0
  24. package/lib/{guardrails → cjs/guardrails}/input.d.ts +2 -2
  25. package/lib/cjs/guardrails/input.js +96 -0
  26. package/lib/cjs/guardrails/input.js.map +1 -0
  27. package/lib/{index.d.ts → cjs/index.d.ts} +3 -3
  28. package/lib/{index.js → cjs/index.js} +75 -114
  29. package/lib/cjs/index.js.map +1 -0
  30. package/lib/{llm-config.d.ts → cjs/llm-config.d.ts} +1 -1
  31. package/lib/cjs/llm-config.js +121 -0
  32. package/lib/cjs/llm-config.js.map +1 -0
  33. package/lib/{runners → cjs/runners}/base-runner.d.ts +4 -4
  34. package/lib/{runners → cjs/runners}/base-runner.js +74 -81
  35. package/lib/cjs/runners/base-runner.js.map +1 -0
  36. package/lib/cjs/runners/index.d.ts +2 -0
  37. package/lib/cjs/runners/index.js +8 -0
  38. package/lib/cjs/runners/index.js.map +1 -0
  39. package/lib/{runners → cjs/runners}/router-runner.d.ts +2 -2
  40. package/lib/{runners → cjs/runners}/router-runner.js +14 -19
  41. package/lib/cjs/runners/router-runner.js.map +1 -0
  42. package/lib/{runners → cjs/runners}/specialist-runner.d.ts +1 -1
  43. package/lib/cjs/runners/specialist-runner.js +8 -0
  44. package/lib/cjs/runners/specialist-runner.js.map +1 -0
  45. package/lib/{services → cjs/services}/hubtype-api-client.d.ts +2 -2
  46. package/lib/cjs/services/hubtype-api-client.js +176 -0
  47. package/lib/cjs/services/hubtype-api-client.js.map +1 -0
  48. package/lib/{services → cjs/services}/types.d.ts +1 -1
  49. package/lib/cjs/services/types.js +13 -0
  50. package/lib/cjs/services/types.js.map +1 -0
  51. package/lib/cjs/structured-output/bot-executor.js +18 -0
  52. package/lib/cjs/structured-output/bot-executor.js.map +1 -0
  53. package/lib/cjs/structured-output/carousel.js +23 -0
  54. package/lib/cjs/structured-output/carousel.js.map +1 -0
  55. package/lib/cjs/structured-output/do-nothing.d.ts +6 -0
  56. package/lib/cjs/structured-output/do-nothing.js +11 -0
  57. package/lib/cjs/structured-output/do-nothing.js.map +1 -0
  58. package/lib/cjs/structured-output/exit.js +11 -0
  59. package/lib/cjs/structured-output/exit.js.map +1 -0
  60. package/lib/{structured-output → cjs/structured-output}/index.d.ts +14 -0
  61. package/lib/cjs/structured-output/index.js +47 -0
  62. package/lib/cjs/structured-output/index.js.map +1 -0
  63. package/lib/cjs/structured-output/request-contact-info.d.ts +9 -0
  64. package/lib/cjs/structured-output/request-contact-info.js +14 -0
  65. package/lib/cjs/structured-output/request-contact-info.js.map +1 -0
  66. package/lib/cjs/structured-output/text-with-buttons.js +24 -0
  67. package/lib/cjs/structured-output/text-with-buttons.js.map +1 -0
  68. package/lib/cjs/structured-output/text.js +14 -0
  69. package/lib/cjs/structured-output/text.js.map +1 -0
  70. package/lib/{tools → cjs/tools}/index.d.ts +2 -2
  71. package/lib/cjs/tools/index.js +8 -0
  72. package/lib/cjs/tools/index.js.map +1 -0
  73. package/lib/{tools → cjs/tools}/retrieve-knowledge.d.ts +2 -2
  74. package/lib/cjs/tools/retrieve-knowledge.js +34 -0
  75. package/lib/cjs/tools/retrieve-knowledge.js.map +1 -0
  76. package/lib/{types.d.ts → cjs/types.d.ts} +1 -1
  77. package/lib/cjs/types.js +3 -0
  78. package/lib/cjs/types.js.map +1 -0
  79. package/lib/esm/agents/base-agent.d.ts +28 -0
  80. package/lib/esm/agents/base-agent.js +39 -0
  81. package/lib/esm/agents/base-agent.js.map +1 -0
  82. package/lib/esm/agents/index.d.ts +2 -0
  83. package/lib/esm/agents/index.js +8 -0
  84. package/lib/esm/agents/index.js.map +1 -0
  85. package/lib/esm/agents/router-agent.d.ts +25 -0
  86. package/lib/esm/agents/router-agent.js +33 -0
  87. package/lib/esm/agents/router-agent.js.map +1 -0
  88. package/lib/esm/agents/specialist-agent.d.ts +39 -0
  89. package/lib/esm/agents/specialist-agent.js +108 -0
  90. package/lib/esm/agents/specialist-agent.js.map +1 -0
  91. package/lib/esm/bot-config-tools.d.ts +7 -0
  92. package/lib/esm/bot-config-tools.js +18 -0
  93. package/lib/esm/bot-config-tools.js.map +1 -0
  94. package/lib/esm/constants.d.ts +21 -0
  95. package/lib/esm/constants.js +25 -0
  96. package/lib/esm/constants.js.map +1 -0
  97. package/lib/esm/debug-logger.d.ts +33 -0
  98. package/lib/esm/debug-logger.js +116 -0
  99. package/lib/esm/debug-logger.js.map +1 -0
  100. package/lib/esm/guardrails/index.d.ts +1 -0
  101. package/lib/esm/guardrails/index.js +5 -0
  102. package/lib/esm/guardrails/index.js.map +1 -0
  103. package/lib/esm/guardrails/input.d.ts +10 -0
  104. package/lib/esm/guardrails/input.js +96 -0
  105. package/lib/esm/guardrails/input.js.map +1 -0
  106. package/lib/esm/index.d.ts +22 -0
  107. package/lib/esm/index.js +220 -0
  108. package/lib/esm/index.js.map +1 -0
  109. package/lib/esm/llm-config.d.ts +30 -0
  110. package/lib/esm/llm-config.js +121 -0
  111. package/lib/esm/llm-config.js.map +1 -0
  112. package/lib/esm/runners/base-runner.d.ts +31 -0
  113. package/lib/esm/runners/base-runner.js +194 -0
  114. package/lib/esm/runners/base-runner.js.map +1 -0
  115. package/lib/esm/runners/index.d.ts +2 -0
  116. package/lib/esm/runners/index.js +8 -0
  117. package/lib/esm/runners/index.js.map +1 -0
  118. package/lib/esm/runners/router-runner.d.ts +8 -0
  119. package/lib/esm/runners/router-runner.js +44 -0
  120. package/lib/esm/runners/router-runner.js.map +1 -0
  121. package/lib/esm/runners/specialist-runner.d.ts +4 -0
  122. package/lib/esm/runners/specialist-runner.js +8 -0
  123. package/lib/esm/runners/specialist-runner.js.map +1 -0
  124. package/lib/esm/services/hubtype-api-client.d.ts +13 -0
  125. package/lib/esm/services/hubtype-api-client.js +176 -0
  126. package/lib/esm/services/hubtype-api-client.js.map +1 -0
  127. package/lib/esm/services/types.d.ts +72 -0
  128. package/lib/esm/services/types.js +13 -0
  129. package/lib/esm/services/types.js.map +1 -0
  130. package/lib/esm/structured-output/bot-executor.d.ts +13 -0
  131. package/lib/esm/structured-output/bot-executor.js +18 -0
  132. package/lib/esm/structured-output/bot-executor.js.map +1 -0
  133. package/lib/esm/structured-output/carousel.d.ts +18 -0
  134. package/lib/esm/structured-output/carousel.js +23 -0
  135. package/lib/esm/structured-output/carousel.js.map +1 -0
  136. package/lib/esm/structured-output/do-nothing.d.ts +6 -0
  137. package/lib/esm/structured-output/do-nothing.js +11 -0
  138. package/lib/esm/structured-output/do-nothing.js.map +1 -0
  139. package/lib/esm/structured-output/exit.d.ts +6 -0
  140. package/lib/esm/structured-output/exit.js +11 -0
  141. package/lib/esm/structured-output/exit.js.map +1 -0
  142. package/lib/esm/structured-output/index.d.ts +112 -0
  143. package/lib/esm/structured-output/index.js +47 -0
  144. package/lib/esm/structured-output/index.js.map +1 -0
  145. package/lib/esm/structured-output/request-contact-info.d.ts +9 -0
  146. package/lib/esm/structured-output/request-contact-info.js +14 -0
  147. package/lib/esm/structured-output/request-contact-info.js.map +1 -0
  148. package/lib/esm/structured-output/text-with-buttons.d.ts +17 -0
  149. package/lib/esm/structured-output/text-with-buttons.js +24 -0
  150. package/lib/esm/structured-output/text-with-buttons.js.map +1 -0
  151. package/lib/esm/structured-output/text.d.ts +9 -0
  152. package/lib/esm/structured-output/text.js +14 -0
  153. package/lib/esm/structured-output/text.js.map +1 -0
  154. package/lib/esm/tools/index.d.ts +3 -0
  155. package/lib/esm/tools/index.js +8 -0
  156. package/lib/esm/tools/index.js.map +1 -0
  157. package/lib/esm/tools/retrieve-knowledge.d.ts +6 -0
  158. package/lib/esm/tools/retrieve-knowledge.js +34 -0
  159. package/lib/esm/tools/retrieve-knowledge.js.map +1 -0
  160. package/lib/esm/types.d.ts +53 -0
  161. package/lib/esm/types.js +3 -0
  162. package/lib/esm/types.js.map +1 -0
  163. package/package.json +9 -11
  164. package/src/index.ts +1 -0
  165. package/src/runners/base-runner.ts +20 -10
  166. package/src/structured-output/do-nothing.ts +12 -0
  167. package/src/structured-output/index.ts +4 -0
  168. package/src/structured-output/request-contact-info.ts +18 -0
  169. package/lib/agents/base-agent.js +0 -66
  170. package/lib/agents/base-agent.js.map +0 -1
  171. package/lib/agents/index.d.ts +0 -2
  172. package/lib/agents/index.js +0 -9
  173. package/lib/agents/index.js.map +0 -1
  174. package/lib/agents/router-agent.js +0 -50
  175. package/lib/agents/router-agent.js.map +0 -1
  176. package/lib/agents/specialist-agent.js.map +0 -1
  177. package/lib/bot-config-tools.js +0 -20
  178. package/lib/bot-config-tools.js.map +0 -1
  179. package/lib/constants.js +0 -26
  180. package/lib/constants.js.map +0 -1
  181. package/lib/debug-logger.js.map +0 -1
  182. package/lib/guardrails/index.d.ts +0 -1
  183. package/lib/guardrails/index.js +0 -6
  184. package/lib/guardrails/index.js.map +0 -1
  185. package/lib/guardrails/input.js +0 -119
  186. package/lib/guardrails/input.js.map +0 -1
  187. package/lib/index.js.map +0 -1
  188. package/lib/llm-config.js +0 -150
  189. package/lib/llm-config.js.map +0 -1
  190. package/lib/runners/base-runner.js.map +0 -1
  191. package/lib/runners/index.d.ts +0 -2
  192. package/lib/runners/index.js +0 -9
  193. package/lib/runners/index.js.map +0 -1
  194. package/lib/runners/router-runner.js.map +0 -1
  195. package/lib/runners/specialist-runner.js +0 -10
  196. package/lib/runners/specialist-runner.js.map +0 -1
  197. package/lib/services/hubtype-api-client.js +0 -191
  198. package/lib/services/hubtype-api-client.js.map +0 -1
  199. package/lib/services/types.js +0 -13
  200. package/lib/services/types.js.map +0 -1
  201. package/lib/structured-output/bot-executor.js +0 -21
  202. package/lib/structured-output/bot-executor.js.map +0 -1
  203. package/lib/structured-output/carousel.js +0 -26
  204. package/lib/structured-output/carousel.js.map +0 -1
  205. package/lib/structured-output/exit.js +0 -14
  206. package/lib/structured-output/exit.js.map +0 -1
  207. package/lib/structured-output/index.js +0 -55
  208. package/lib/structured-output/index.js.map +0 -1
  209. package/lib/structured-output/text-with-buttons.js +0 -25
  210. package/lib/structured-output/text-with-buttons.js.map +0 -1
  211. package/lib/structured-output/text.js +0 -17
  212. package/lib/structured-output/text.js.map +0 -1
  213. package/lib/tools/index.js +0 -8
  214. package/lib/tools/index.js.map +0 -1
  215. package/lib/tools/retrieve-knowledge.js +0 -40
  216. package/lib/tools/retrieve-knowledge.js.map +0 -1
  217. package/lib/types.js +0 -5
  218. package/lib/types.js.map +0 -1
  219. /package/lib/{constants.d.ts → cjs/constants.d.ts} +0 -0
  220. /package/lib/{structured-output → cjs/structured-output}/bot-executor.d.ts +0 -0
  221. /package/lib/{structured-output → cjs/structured-output}/carousel.d.ts +0 -0
  222. /package/lib/{structured-output → cjs/structured-output}/exit.d.ts +0 -0
  223. /package/lib/{structured-output → cjs/structured-output}/text-with-buttons.d.ts +0 -0
  224. /package/lib/{structured-output → cjs/structured-output}/text.d.ts +0 -0
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HubtypeApiClient = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const constants_1 = require("../constants");
7
+ class HubtypeApiClient {
8
+ constructor(authToken) {
9
+ this.authToken = authToken;
10
+ }
11
+ async retrieveSimilarChunks(query, sourceIds) {
12
+ const url = `${constants_1.HUBTYPE_API_URL}/external/v1/ai/knowledge_base/similar_chunks/`;
13
+ const headers = {
14
+ 'Content-Type': 'application/json',
15
+ Authorization: `Bearer ${this.authToken}`,
16
+ };
17
+ const params = {
18
+ query,
19
+ source_ids: sourceIds,
20
+ num_chunks: 5,
21
+ };
22
+ const response = await axios_1.default.post(url, params, { headers });
23
+ const chunks = response.data.chunks.map((chunk) => ({
24
+ id: chunk.id,
25
+ text: chunk.text,
26
+ }));
27
+ return chunks;
28
+ }
29
+ async getLocalMessages(maxMemoryLength, previousHubtypeMessages, localStorageKey) {
30
+ const localBotonicState = typeof globalThis !== 'undefined' && globalThis.localStorage
31
+ ? globalThis.localStorage.getItem(localStorageKey)
32
+ : null;
33
+ const botonicState = JSON.parse(localBotonicState || '{}');
34
+ const messages = botonicState.messages;
35
+ const filteredMessages = messages
36
+ .filter(message => message.data.text)
37
+ .map(message => ({
38
+ role: message.sentBy === 'user' ? 'user' : 'assistant',
39
+ content: message.data.text,
40
+ }))
41
+ .map(message => this.formatMessage(message));
42
+ const resultMessages = [...filteredMessages, ...previousHubtypeMessages];
43
+ return resultMessages.slice(-maxMemoryLength);
44
+ }
45
+ async getMessagesV2(botContext, options, previousHubtypeMessages) {
46
+ const url = `${constants_1.HUBTYPE_API_URL}/external/v2/ai/agent/message_history/`;
47
+ const headers = {
48
+ 'Content-Type': 'application/json',
49
+ Authorization: `Bearer ${this.authToken}`,
50
+ };
51
+ const params = {
52
+ last_message_id: botContext.input.message_id,
53
+ max_messages: options.maxMessages,
54
+ include_tool_calls: options.includeToolCalls,
55
+ max_full_tool_results: options.maxFullToolResults,
56
+ debug_mode: options.debugMode,
57
+ };
58
+ try {
59
+ const response = await axios_1.default.get(url, {
60
+ headers,
61
+ params,
62
+ });
63
+ const { messages, conversation_id, truncated } = response.data;
64
+ const formattedMessages = [...messages, ...previousHubtypeMessages]
65
+ .map(message => this.formatMessageV2(message))
66
+ .filter((message) => message !== null);
67
+ return {
68
+ messages: formattedMessages,
69
+ conversationId: conversation_id,
70
+ truncated,
71
+ };
72
+ }
73
+ catch (error) {
74
+ console.error(error);
75
+ throw new Error('Failed to get messages from Hubtype V2 API');
76
+ }
77
+ }
78
+ formatMessageV2(message) {
79
+ switch (message.role) {
80
+ case 'user':
81
+ return {
82
+ role: 'user',
83
+ content: message.content ?? '',
84
+ };
85
+ case 'assistant': {
86
+ const assistantMessage = message;
87
+ // If assistant message has tool_calls, include them for context
88
+ // Using double assertion as the OpenAI API supports this format,
89
+ // but the agents SDK types are more restrictive
90
+ if (assistantMessage.tool_calls &&
91
+ assistantMessage.tool_calls.length > 0) {
92
+ return {
93
+ role: 'assistant',
94
+ content: assistantMessage.content ?? '',
95
+ tool_calls: assistantMessage.tool_calls.map(tc => ({
96
+ id: tc.id,
97
+ type: tc.type,
98
+ function: {
99
+ name: tc.function.name,
100
+ arguments: tc.function.arguments,
101
+ },
102
+ })),
103
+ };
104
+ }
105
+ // Regular assistant message without tool_calls
106
+ return {
107
+ role: 'assistant',
108
+ content: [
109
+ {
110
+ type: 'output_text',
111
+ text: assistantMessage.content ?? '',
112
+ },
113
+ ],
114
+ status: 'completed',
115
+ };
116
+ }
117
+ case 'tool': {
118
+ // Tool messages provide context about previous tool executions
119
+ // Using double assertion as the OpenAI API supports this format,
120
+ // but the agents SDK types are more restrictive
121
+ const toolMessage = message;
122
+ return {
123
+ role: 'tool',
124
+ tool_call_id: toolMessage.tool_call_id,
125
+ content: toolMessage.content ?? '',
126
+ };
127
+ }
128
+ case 'system':
129
+ return {
130
+ role: 'system',
131
+ content: message.content ?? '',
132
+ };
133
+ default:
134
+ throw new Error(`Invalid message role: ${message.role}`);
135
+ }
136
+ }
137
+ async trackLlmRuns(botId, data) {
138
+ // Not stop the bot execution if the tracking fails, just log the error
139
+ try {
140
+ const url = `${constants_1.HUBTYPE_API_URL}/external/v2/conversational_apps/${botId}/track_llm_runs/`;
141
+ const headers = {
142
+ 'Content-Type': 'application/json',
143
+ Authorization: `Bearer ${this.authToken}`,
144
+ };
145
+ await axios_1.default.post(url, data, { headers });
146
+ }
147
+ catch (error) {
148
+ console.error('Failed to track LLM runs:', error);
149
+ }
150
+ }
151
+ formatMessage(message) {
152
+ if (message.role === 'user') {
153
+ return {
154
+ content: message.content,
155
+ role: 'user',
156
+ };
157
+ }
158
+ else if (message.role === 'assistant') {
159
+ return {
160
+ role: 'assistant',
161
+ content: [
162
+ {
163
+ type: 'output_text',
164
+ text: message.content,
165
+ },
166
+ ],
167
+ status: 'completed',
168
+ };
169
+ }
170
+ else {
171
+ throw new Error('Invalid message role');
172
+ }
173
+ }
174
+ }
175
+ exports.HubtypeApiClient = HubtypeApiClient;
176
+ //# sourceMappingURL=hubtype-api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hubtype-api-client.js","sourceRoot":"","sources":["../../../src/services/hubtype-api-client.ts"],"names":[],"mappings":";;;;AAEA,0DAAyB;AAEzB,4CAA8C;AAa9C,MAAa,gBAAgB;IAG3B,YAAY,SAAiB;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,qBAAqB,CACzB,KAAa,EACb,SAAmB;QAEnB,MAAM,GAAG,GAAG,GAAG,2BAAe,gDAAgD,CAAA;QA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AE,WAAW;gBACjB,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,aAAa;wBACnB,IAAI,EAAE,OAAO,CAAC,OAAO;qBACtB;iBACF;gBACD,MAAM,EAAE,WAAW;aACpB,CAAA;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;QACzC,CAAC;IACH,CAAC;CACF;AAhMD,4CAgMC"}
@@ -0,0 +1,72 @@
1
+ import type { HubtypeAssistantMessage, HubtypeUserMessage } from '@botonic/core';
2
+ import type { AgenticInputMessage } from '../types';
3
+ export declare enum TrackProductName {
4
+ AI_AGENT = "ai_agent"
5
+ }
6
+ export declare enum TrackFeature {
7
+ AI_AGENT_RUN = "ai_agent_run",
8
+ AI_AGENT_GUARDRAIL = "ai_agent_guardrail"
9
+ }
10
+ export interface LlmRunData {
11
+ inference_id: string;
12
+ is_test: boolean;
13
+ product_name: string;
14
+ deployment_name: string;
15
+ model_name: string;
16
+ feature: string;
17
+ api_version?: string;
18
+ num_prompt_tokens: number;
19
+ num_completion_tokens: number;
20
+ duration_in_milliseconds: number;
21
+ temperature: number;
22
+ error: string | null;
23
+ }
24
+ export interface TrackLlmRunsData {
25
+ llm_runs: LlmRunData[];
26
+ }
27
+ export type HubtypeMessage = HubtypeAssistantMessage | HubtypeUserMessage;
28
+ interface HubtypeToolCall {
29
+ id: string;
30
+ type: 'function';
31
+ function: {
32
+ name: string;
33
+ arguments: string;
34
+ };
35
+ }
36
+ interface HubtypeUserMessageV2 {
37
+ role: 'user';
38
+ content: string | null;
39
+ }
40
+ export interface HubtypeAssistantMessageV2 {
41
+ role: 'assistant';
42
+ content: string | null;
43
+ tool_calls?: HubtypeToolCall[] | null;
44
+ }
45
+ export interface HubtypeToolMessageV2 {
46
+ role: 'tool';
47
+ content: string | null;
48
+ tool_call_id: string;
49
+ }
50
+ interface HubtypeSystemMessageV2 {
51
+ role: 'system';
52
+ content: string | null;
53
+ }
54
+ export type HubtypeMessageV2 = HubtypeUserMessageV2 | HubtypeAssistantMessageV2 | HubtypeToolMessageV2 | HubtypeSystemMessageV2;
55
+ export interface MessageHistoryResponseV2 {
56
+ messages: HubtypeMessageV2[];
57
+ conversation_id: string | null;
58
+ truncated: boolean;
59
+ }
60
+ export interface GetMessagesV2Result {
61
+ messages: AgenticInputMessage[];
62
+ conversationId: string | null;
63
+ truncated: boolean;
64
+ }
65
+ export interface MessageHistoryV2Params {
66
+ last_message_id: string;
67
+ max_messages?: number;
68
+ include_tool_calls?: boolean;
69
+ max_full_tool_results?: number;
70
+ debug_mode?: boolean;
71
+ }
72
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrackFeature = exports.TrackProductName = void 0;
4
+ var TrackProductName;
5
+ (function (TrackProductName) {
6
+ TrackProductName["AI_AGENT"] = "ai_agent";
7
+ })(TrackProductName || (exports.TrackProductName = TrackProductName = {}));
8
+ var TrackFeature;
9
+ (function (TrackFeature) {
10
+ TrackFeature["AI_AGENT_RUN"] = "ai_agent_run";
11
+ TrackFeature["AI_AGENT_GUARDRAIL"] = "ai_agent_guardrail";
12
+ })(TrackFeature || (exports.TrackFeature = TrackFeature = {}));
13
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/types.ts"],"names":[],"mappings":";;;AAGA,IAAY,gBAEX;AAFD,WAAY,gBAAgB;IAC1B,yCAAqB,CAAA;AACvB,CAAC,EAFW,gBAAgB,gCAAhB,gBAAgB,QAE3B;AAED,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,6CAA6B,CAAA;IAC7B,yDAAyC,CAAA;AAC3C,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
@@ -0,0 +1,13 @@
1
+ import { type BotExecutorMessage, OutputMessageType } from '@botonic/core';
2
+ import { z } from 'zod';
3
+ export type { BotExecutorMessage };
4
+ export declare const BotExecutorSchema: z.ZodObject<{
5
+ type: z.ZodLiteral<OutputMessageType.BotExecutor>;
6
+ content: z.ZodObject<{
7
+ text: z.ZodString;
8
+ buttons: z.ZodArray<z.ZodObject<{
9
+ text: z.ZodString;
10
+ payload: z.ZodString;
11
+ }, z.core.$strip>>;
12
+ }, z.core.$strip>;
13
+ }, z.core.$strip>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BotExecutorSchema = void 0;
4
+ const core_1 = require("@botonic/core");
5
+ const zod_1 = require("zod");
6
+ exports.BotExecutorSchema = zod_1.z
7
+ .object({
8
+ type: zod_1.z.literal(core_1.OutputMessageType.BotExecutor),
9
+ content: zod_1.z.object({
10
+ text: zod_1.z.string(),
11
+ buttons: zod_1.z.array(zod_1.z.object({
12
+ text: zod_1.z.string(),
13
+ payload: zod_1.z.string(),
14
+ })),
15
+ }),
16
+ })
17
+ .describe('A text message with buttons to allow the bot to execute a specific action. Use it only when asked explicitly in the prompt');
18
+ //# sourceMappingURL=bot-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bot-executor.js","sourceRoot":"","sources":["../../../src/structured-output/bot-executor.ts"],"names":[],"mappings":";;;AAAA,wCAA0E;AAC1E,6BAAuB;AAIV,QAAA,iBAAiB,GAAG,OAAC;KAC/B,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,wBAAiB,CAAC,WAAW,CAAC;IAC9C,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,OAAC,CAAC,KAAK,CACd,OAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;SACpB,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CACP,4HAA4H,CAC7H,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { type CarouselMessage, OutputMessageType } from '@botonic/core';
2
+ import { z } from 'zod';
3
+ export type { CarouselMessage };
4
+ export declare const CarouselSchema: z.ZodObject<{
5
+ type: z.ZodLiteral<OutputMessageType.Carousel>;
6
+ content: z.ZodObject<{
7
+ text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ elements: z.ZodArray<z.ZodObject<{
9
+ title: z.ZodString;
10
+ subtitle: z.ZodString;
11
+ image: z.ZodString;
12
+ button: z.ZodObject<{
13
+ text: z.ZodString;
14
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15
+ }, z.core.$strip>;
16
+ }, z.core.$strip>>;
17
+ }, z.core.$strip>;
18
+ }, z.core.$strip>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CarouselSchema = void 0;
4
+ const core_1 = require("@botonic/core");
5
+ const zod_1 = require("zod");
6
+ exports.CarouselSchema = zod_1.z
7
+ .object({
8
+ type: zod_1.z.literal(core_1.OutputMessageType.Carousel),
9
+ content: zod_1.z.object({
10
+ text: zod_1.z.string().nullable().optional(),
11
+ elements: zod_1.z.array(zod_1.z.object({
12
+ title: zod_1.z.string(),
13
+ subtitle: zod_1.z.string(),
14
+ image: zod_1.z.string(),
15
+ button: zod_1.z.object({
16
+ text: zod_1.z.string(),
17
+ url: zod_1.z.string().nullable().optional(),
18
+ }),
19
+ })),
20
+ }),
21
+ })
22
+ .describe('A carousel message containing a list of elements');
23
+ //# sourceMappingURL=carousel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carousel.js","sourceRoot":"","sources":["../../../src/structured-output/carousel.ts"],"names":[],"mappings":";;;AAAA,wCAAuE;AACvE,6BAAuB;AAIV,QAAA,cAAc,GAAG,OAAC;KAC5B,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,wBAAiB,CAAC,QAAQ,CAAC;IAC3C,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QACtC,QAAQ,EAAE,OAAC,CAAC,KAAK,CACf,OAAC,CAAC,MAAM,CAAC;YACP,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;YACjB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;YACpB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;YACjB,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;gBACf,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;gBAChB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;aACtC,CAAC;SACH,CAAC,CACH;KACF,CAAC;CACH,CAAC;KACD,QAAQ,CAAC,kDAAkD,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { type DoNothingMessage, OutputMessageType } from '@botonic/core';
2
+ import { z } from 'zod';
3
+ export type { DoNothingMessage };
4
+ export declare const DoNothingSchema: z.ZodObject<{
5
+ type: z.ZodLiteral<OutputMessageType.DoNothing>;
6
+ }, z.core.$strip>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DoNothingSchema = void 0;
4
+ const core_1 = require("@botonic/core");
5
+ const zod_1 = require("zod");
6
+ exports.DoNothingSchema = zod_1.z
7
+ .object({
8
+ type: zod_1.z.literal(core_1.OutputMessageType.DoNothing),
9
+ })
10
+ .describe('A do nothing message is used to end the conversation without send a reply. Use it only when asked explicitly in the prompt.');
11
+ //# sourceMappingURL=do-nothing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"do-nothing.js","sourceRoot":"","sources":["../../../src/structured-output/do-nothing.ts"],"names":[],"mappings":";;;AAAA,wCAAwE;AACxE,6BAAuB;AAIV,QAAA,eAAe,GAAG,OAAC;KAC7B,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,wBAAiB,CAAC,SAAS,CAAC;CAC7C,CAAC;KACD,QAAQ,CACP,6HAA6H,CAC9H,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { type ExitMessage, OutputMessageType } from '@botonic/core';
2
+ import { z } from 'zod';
3
+ export type { ExitMessage };
4
+ export declare const ExitSchema: z.ZodObject<{
5
+ type: z.ZodLiteral<OutputMessageType.Exit>;
6
+ }, z.core.$strip>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExitSchema = void 0;
4
+ const core_1 = require("@botonic/core");
5
+ const zod_1 = require("zod");
6
+ exports.ExitSchema = zod_1.z
7
+ .object({
8
+ type: zod_1.z.literal(core_1.OutputMessageType.Exit),
9
+ })
10
+ .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');
11
+ //# sourceMappingURL=exit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit.js","sourceRoot":"","sources":["../../../src/structured-output/exit.ts"],"names":[],"mappings":";;;AAAA,wCAAmE;AACnE,6BAAuB;AAIV,QAAA,UAAU,GAAG,OAAC;KACxB,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,wBAAiB,CAAC,IAAI,CAAC;CACxC,CAAC;KACD,QAAQ,CACP,uIAAuI,CACxI,CAAA"}
@@ -0,0 +1,112 @@
1
+ import type { OutputMessage } from '@botonic/core';
2
+ import { z } from 'zod';
3
+ export interface Output {
4
+ messages: OutputMessage[];
5
+ }
6
+ export declare const OutputSchema: z.ZodObject<{
7
+ messages: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
8
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Text>;
9
+ content: z.ZodObject<{
10
+ text: z.ZodString;
11
+ }, z.core.$strip>;
12
+ }, z.core.$strip>, z.ZodObject<{
13
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.TextWithButtons>;
14
+ content: z.ZodObject<{
15
+ text: z.ZodString;
16
+ buttons: z.ZodArray<z.ZodObject<{
17
+ text: z.ZodString;
18
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ target: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodEnum<{
20
+ _blank: "_blank";
21
+ _self: "_self";
22
+ }>>>>;
23
+ }, z.core.$strip>>;
24
+ }, z.core.$strip>;
25
+ }, z.core.$strip>, z.ZodObject<{
26
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Carousel>;
27
+ content: z.ZodObject<{
28
+ text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
+ elements: z.ZodArray<z.ZodObject<{
30
+ title: z.ZodString;
31
+ subtitle: z.ZodString;
32
+ image: z.ZodString;
33
+ button: z.ZodObject<{
34
+ text: z.ZodString;
35
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ }, z.core.$strip>;
37
+ }, z.core.$strip>>;
38
+ }, z.core.$strip>;
39
+ }, z.core.$strip>, z.ZodObject<{
40
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.DoNothing>;
41
+ }, z.core.$strip>, z.ZodObject<{
42
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Exit>;
43
+ }, z.core.$strip>, z.ZodObject<{
44
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.BotExecutor>;
45
+ content: z.ZodObject<{
46
+ text: z.ZodString;
47
+ buttons: z.ZodArray<z.ZodObject<{
48
+ text: z.ZodString;
49
+ payload: z.ZodString;
50
+ }, z.core.$strip>>;
51
+ }, z.core.$strip>;
52
+ }, z.core.$strip>, z.ZodObject<{
53
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.RequestContactInfo>;
54
+ content: z.ZodObject<{
55
+ text: z.ZodString;
56
+ }, z.core.$strip>;
57
+ }, z.core.$strip>]>>;
58
+ }, z.core.$strip>;
59
+ export declare function getOutputSchema(externalOutputMessagesSchemas: z.ZodObject<any>[]): z.ZodObject<{
60
+ messages: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
61
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Text>;
62
+ content: z.ZodObject<{
63
+ text: z.ZodString;
64
+ }, z.core.$strip>;
65
+ }, z.core.$strip>, z.ZodObject<{
66
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.TextWithButtons>;
67
+ content: z.ZodObject<{
68
+ text: z.ZodString;
69
+ buttons: z.ZodArray<z.ZodObject<{
70
+ text: z.ZodString;
71
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ target: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodEnum<{
73
+ _blank: "_blank";
74
+ _self: "_self";
75
+ }>>>>;
76
+ }, z.core.$strip>>;
77
+ }, z.core.$strip>;
78
+ }, z.core.$strip>, z.ZodObject<{
79
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Carousel>;
80
+ content: z.ZodObject<{
81
+ text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ elements: z.ZodArray<z.ZodObject<{
83
+ title: z.ZodString;
84
+ subtitle: z.ZodString;
85
+ image: z.ZodString;
86
+ button: z.ZodObject<{
87
+ text: z.ZodString;
88
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
89
+ }, z.core.$strip>;
90
+ }, z.core.$strip>>;
91
+ }, z.core.$strip>;
92
+ }, z.core.$strip>, z.ZodObject<{
93
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.DoNothing>;
94
+ }, z.core.$strip>, z.ZodObject<{
95
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.Exit>;
96
+ }, z.core.$strip>, z.ZodObject<{
97
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.BotExecutor>;
98
+ content: z.ZodObject<{
99
+ text: z.ZodString;
100
+ buttons: z.ZodArray<z.ZodObject<{
101
+ text: z.ZodString;
102
+ payload: z.ZodString;
103
+ }, z.core.$strip>>;
104
+ }, z.core.$strip>;
105
+ }, z.core.$strip>, z.ZodObject<{
106
+ type: z.ZodLiteral<import("@botonic/core").OutputMessageType.RequestContactInfo>;
107
+ content: z.ZodObject<{
108
+ text: z.ZodString;
109
+ }, z.core.$strip>;
110
+ }, z.core.$strip>, ...z.ZodObject<any, z.core.$strip>[]]>>;
111
+ }, z.core.$strip>;
112
+ export declare function getOutputInstructions(): string;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OutputSchema = void 0;
4
+ exports.getOutputSchema = getOutputSchema;
5
+ exports.getOutputInstructions = getOutputInstructions;
6
+ const zod_1 = require("zod");
7
+ const bot_executor_1 = require("./bot-executor");
8
+ const carousel_1 = require("./carousel");
9
+ const do_nothing_1 = require("./do-nothing");
10
+ const exit_1 = require("./exit");
11
+ const request_contact_info_1 = require("./request-contact-info");
12
+ const text_1 = require("./text");
13
+ const text_with_buttons_1 = require("./text-with-buttons");
14
+ const baseMessageSchemas = [
15
+ text_1.TextSchema,
16
+ text_with_buttons_1.TextWithButtonsSchema,
17
+ carousel_1.CarouselSchema,
18
+ do_nothing_1.DoNothingSchema,
19
+ exit_1.ExitSchema,
20
+ bot_executor_1.BotExecutorSchema,
21
+ request_contact_info_1.RequestContactInfoSchema,
22
+ ];
23
+ exports.OutputSchema = zod_1.z
24
+ .object({
25
+ messages: zod_1.z.array(zod_1.z.union(baseMessageSchemas)),
26
+ })
27
+ .describe('The messages to be sent to the user');
28
+ function getOutputSchema(externalOutputMessagesSchemas) {
29
+ return zod_1.z.object({
30
+ messages: zod_1.z.array(zod_1.z.union([...baseMessageSchemas, ...externalOutputMessagesSchemas])),
31
+ });
32
+ }
33
+ function getOutputInstructions() {
34
+ const example = {
35
+ messages: [
36
+ {
37
+ type: 'text',
38
+ content: {
39
+ text: 'Hello, how can I help you today?',
40
+ },
41
+ },
42
+ ],
43
+ };
44
+ 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>`;
45
+ return `<output>\n${output}\n</output>`;
46
+ }
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structured-output/index.ts"],"names":[],"mappings":";;;AA6BA,0CAQC;AAED,sDAaC;AAnDD,6BAAuB;AACvB,iDAAkD;AAClD,yCAA2C;AAC3C,6CAA8C;AAC9C,iCAAmC;AACnC,iEAAiE;AACjE,iCAAmC;AACnC,2DAA2D;AAM3D,MAAM,kBAAkB,GAAG;IACzB,iBAAU;IACV,yCAAqB;IACrB,yBAAc;IACd,4BAAe;IACf,iBAAU;IACV,gCAAiB;IACjB,+CAAwB;CAChB,CAAA;AACG,QAAA,YAAY,GAAG,OAAC;KAC1B,MAAM,CAAC;IACN,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;CAC/C,CAAC;KACD,QAAQ,CAAC,qCAAqC,CAAC,CAAA;AAElD,SAAgB,eAAe,CAC7B,6BAAiD;IAEjD,OAAO,OAAC,CAAC,MAAM,CAAC;QACd,QAAQ,EAAE,OAAC,CAAC,KAAK,CACf,OAAC,CAAC,KAAK,CAAC,CAAC,GAAG,kBAAkB,EAAE,GAAG,6BAA6B,CAAC,CAAC,CACnE;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAgB,qBAAqB;IACnC,MAAM,OAAO,GAAG;QACd,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,kCAAkC;iBACzC;aACF;SACF;KACF,CAAA;IACD,MAAM,MAAM,GAAG,yIAAyI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,cAAc,CAAA;IAC7L,OAAO,aAAa,MAAM,aAAa,CAAA;AACzC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { OutputMessageType, type RequestContactInfoMessage } from '@botonic/core';
2
+ import { z } from 'zod';
3
+ export type { RequestContactInfoMessage };
4
+ export declare const RequestContactInfoSchema: z.ZodObject<{
5
+ type: z.ZodLiteral<OutputMessageType.RequestContactInfo>;
6
+ content: z.ZodObject<{
7
+ text: z.ZodString;
8
+ }, z.core.$strip>;
9
+ }, z.core.$strip>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestContactInfoSchema = void 0;
4
+ const core_1 = require("@botonic/core");
5
+ const zod_1 = require("zod");
6
+ exports.RequestContactInfoSchema = zod_1.z
7
+ .object({
8
+ type: zod_1.z.literal(core_1.OutputMessageType.RequestContactInfo),
9
+ content: zod_1.z.object({
10
+ text: zod_1.z.string().describe('The text of the message'),
11
+ }),
12
+ })
13
+ .describe('A message to request phone number from the user. Use it only when asked explicitly in the prompt.');
14
+ //# sourceMappingURL=request-contact-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-contact-info.js","sourceRoot":"","sources":["../../../src/structured-output/request-contact-info.ts"],"names":[],"mappings":";;;AAAA,wCAGsB;AACtB,6BAAuB;AAIV,QAAA,wBAAwB,GAAG,OAAC;KACtC,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,wBAAiB,CAAC,kBAAkB,CAAC;IACrD,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;KACrD,CAAC;CACH,CAAC;KACD,QAAQ,CACP,mGAAmG,CACpG,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { OutputMessageType, type TextWithButtonsMessage } from '@botonic/core';
2
+ import { z } from 'zod';
3
+ export type { TextWithButtonsMessage };
4
+ export declare const TextWithButtonsSchema: z.ZodObject<{
5
+ type: z.ZodLiteral<OutputMessageType.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<{
12
+ _blank: "_blank";
13
+ _self: "_self";
14
+ }>>>>;
15
+ }, z.core.$strip>>;
16
+ }, z.core.$strip>;
17
+ }, z.core.$strip>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextWithButtonsSchema = void 0;
4
+ const core_1 = require("@botonic/core");
5
+ const zod_1 = require("zod");
6
+ exports.TextWithButtonsSchema = zod_1.z
7
+ .object({
8
+ type: zod_1.z.literal(core_1.OutputMessageType.TextWithButtons),
9
+ content: zod_1.z.object({
10
+ text: zod_1.z.string(),
11
+ buttons: zod_1.z.array(zod_1.z.object({
12
+ text: zod_1.z.string(),
13
+ url: zod_1.z.string().nullable().optional(),
14
+ target: zod_1.z
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-with-buttons.js","sourceRoot":"","sources":["../../../src/structured-output/text-with-buttons.ts"],"names":[],"mappings":";;;AAAA,wCAA8E;AAC9E,6BAAuB;AAIV,QAAA,qBAAqB,GAAG,OAAC;KACnC,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,wBAAiB,CAAC,eAAe,CAAC;IAClD,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,OAAC,CAAC,KAAK,CACd,OAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;YACrC,MAAM,EAAE,OAAC;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"}