@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.
- package/lib/{agents → cjs/agents}/base-agent.d.ts +4 -4
- package/lib/cjs/agents/base-agent.js +39 -0
- package/lib/cjs/agents/base-agent.js.map +1 -0
- package/lib/cjs/agents/index.d.ts +2 -0
- package/lib/cjs/agents/index.js +8 -0
- package/lib/cjs/agents/index.js.map +1 -0
- package/lib/{agents → cjs/agents}/router-agent.d.ts +5 -5
- package/lib/cjs/agents/router-agent.js +33 -0
- package/lib/cjs/agents/router-agent.js.map +1 -0
- package/lib/{agents → cjs/agents}/specialist-agent.d.ts +5 -5
- package/lib/{agents → cjs/agents}/specialist-agent.js +45 -65
- package/lib/cjs/agents/specialist-agent.js.map +1 -0
- package/lib/{bot-config-tools.d.ts → cjs/bot-config-tools.d.ts} +1 -1
- package/lib/cjs/bot-config-tools.js +18 -0
- package/lib/cjs/bot-config-tools.js.map +1 -0
- package/lib/cjs/constants.js +25 -0
- package/lib/cjs/constants.js.map +1 -0
- package/lib/{debug-logger.d.ts → cjs/debug-logger.d.ts} +1 -1
- package/lib/{debug-logger.js → cjs/debug-logger.js} +9 -14
- package/lib/cjs/debug-logger.js.map +1 -0
- package/lib/cjs/guardrails/index.d.ts +1 -0
- package/lib/cjs/guardrails/index.js +5 -0
- package/lib/cjs/guardrails/index.js.map +1 -0
- package/lib/{guardrails → cjs/guardrails}/input.d.ts +2 -2
- package/lib/cjs/guardrails/input.js +96 -0
- package/lib/cjs/guardrails/input.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +3 -3
- package/lib/{index.js → cjs/index.js} +75 -114
- package/lib/cjs/index.js.map +1 -0
- package/lib/{llm-config.d.ts → cjs/llm-config.d.ts} +1 -1
- package/lib/cjs/llm-config.js +121 -0
- package/lib/cjs/llm-config.js.map +1 -0
- package/lib/{runners → cjs/runners}/base-runner.d.ts +4 -4
- package/lib/{runners → cjs/runners}/base-runner.js +74 -81
- package/lib/cjs/runners/base-runner.js.map +1 -0
- package/lib/cjs/runners/index.d.ts +2 -0
- package/lib/cjs/runners/index.js +8 -0
- package/lib/cjs/runners/index.js.map +1 -0
- package/lib/{runners → cjs/runners}/router-runner.d.ts +2 -2
- package/lib/{runners → cjs/runners}/router-runner.js +14 -19
- package/lib/cjs/runners/router-runner.js.map +1 -0
- package/lib/{runners → cjs/runners}/specialist-runner.d.ts +1 -1
- package/lib/cjs/runners/specialist-runner.js +8 -0
- package/lib/cjs/runners/specialist-runner.js.map +1 -0
- package/lib/{services → cjs/services}/hubtype-api-client.d.ts +2 -2
- package/lib/cjs/services/hubtype-api-client.js +176 -0
- package/lib/cjs/services/hubtype-api-client.js.map +1 -0
- package/lib/{services → cjs/services}/types.d.ts +1 -1
- package/lib/cjs/services/types.js +13 -0
- package/lib/cjs/services/types.js.map +1 -0
- package/lib/cjs/structured-output/bot-executor.js +18 -0
- package/lib/cjs/structured-output/bot-executor.js.map +1 -0
- package/lib/cjs/structured-output/carousel.js +23 -0
- package/lib/cjs/structured-output/carousel.js.map +1 -0
- package/lib/cjs/structured-output/do-nothing.d.ts +6 -0
- package/lib/cjs/structured-output/do-nothing.js +11 -0
- package/lib/cjs/structured-output/do-nothing.js.map +1 -0
- package/lib/cjs/structured-output/exit.js +11 -0
- package/lib/cjs/structured-output/exit.js.map +1 -0
- package/lib/{structured-output → cjs/structured-output}/index.d.ts +14 -0
- package/lib/cjs/structured-output/index.js +47 -0
- package/lib/cjs/structured-output/index.js.map +1 -0
- package/lib/cjs/structured-output/request-contact-info.d.ts +9 -0
- package/lib/cjs/structured-output/request-contact-info.js +14 -0
- package/lib/cjs/structured-output/request-contact-info.js.map +1 -0
- package/lib/cjs/structured-output/text-with-buttons.js +24 -0
- package/lib/cjs/structured-output/text-with-buttons.js.map +1 -0
- package/lib/cjs/structured-output/text.js +14 -0
- package/lib/cjs/structured-output/text.js.map +1 -0
- package/lib/{tools → cjs/tools}/index.d.ts +2 -2
- package/lib/cjs/tools/index.js +8 -0
- package/lib/cjs/tools/index.js.map +1 -0
- package/lib/{tools → cjs/tools}/retrieve-knowledge.d.ts +2 -2
- package/lib/cjs/tools/retrieve-knowledge.js +34 -0
- package/lib/cjs/tools/retrieve-knowledge.js.map +1 -0
- package/lib/{types.d.ts → cjs/types.d.ts} +1 -1
- package/lib/cjs/types.js +3 -0
- package/lib/cjs/types.js.map +1 -0
- package/lib/esm/agents/base-agent.d.ts +28 -0
- package/lib/esm/agents/base-agent.js +39 -0
- package/lib/esm/agents/base-agent.js.map +1 -0
- package/lib/esm/agents/index.d.ts +2 -0
- package/lib/esm/agents/index.js +8 -0
- package/lib/esm/agents/index.js.map +1 -0
- package/lib/esm/agents/router-agent.d.ts +25 -0
- package/lib/esm/agents/router-agent.js +33 -0
- package/lib/esm/agents/router-agent.js.map +1 -0
- package/lib/esm/agents/specialist-agent.d.ts +39 -0
- package/lib/esm/agents/specialist-agent.js +108 -0
- package/lib/esm/agents/specialist-agent.js.map +1 -0
- package/lib/esm/bot-config-tools.d.ts +7 -0
- package/lib/esm/bot-config-tools.js +18 -0
- package/lib/esm/bot-config-tools.js.map +1 -0
- package/lib/esm/constants.d.ts +21 -0
- package/lib/esm/constants.js +25 -0
- package/lib/esm/constants.js.map +1 -0
- package/lib/esm/debug-logger.d.ts +33 -0
- package/lib/esm/debug-logger.js +116 -0
- package/lib/esm/debug-logger.js.map +1 -0
- package/lib/esm/guardrails/index.d.ts +1 -0
- package/lib/esm/guardrails/index.js +5 -0
- package/lib/esm/guardrails/index.js.map +1 -0
- package/lib/esm/guardrails/input.d.ts +10 -0
- package/lib/esm/guardrails/input.js +96 -0
- package/lib/esm/guardrails/input.js.map +1 -0
- package/lib/esm/index.d.ts +22 -0
- package/lib/esm/index.js +220 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/llm-config.d.ts +30 -0
- package/lib/esm/llm-config.js +121 -0
- package/lib/esm/llm-config.js.map +1 -0
- package/lib/esm/runners/base-runner.d.ts +31 -0
- package/lib/esm/runners/base-runner.js +194 -0
- package/lib/esm/runners/base-runner.js.map +1 -0
- package/lib/esm/runners/index.d.ts +2 -0
- package/lib/esm/runners/index.js +8 -0
- package/lib/esm/runners/index.js.map +1 -0
- package/lib/esm/runners/router-runner.d.ts +8 -0
- package/lib/esm/runners/router-runner.js +44 -0
- package/lib/esm/runners/router-runner.js.map +1 -0
- package/lib/esm/runners/specialist-runner.d.ts +4 -0
- package/lib/esm/runners/specialist-runner.js +8 -0
- package/lib/esm/runners/specialist-runner.js.map +1 -0
- package/lib/esm/services/hubtype-api-client.d.ts +13 -0
- package/lib/esm/services/hubtype-api-client.js +176 -0
- package/lib/esm/services/hubtype-api-client.js.map +1 -0
- package/lib/esm/services/types.d.ts +72 -0
- package/lib/esm/services/types.js +13 -0
- package/lib/esm/services/types.js.map +1 -0
- package/lib/esm/structured-output/bot-executor.d.ts +13 -0
- package/lib/esm/structured-output/bot-executor.js +18 -0
- package/lib/esm/structured-output/bot-executor.js.map +1 -0
- package/lib/esm/structured-output/carousel.d.ts +18 -0
- package/lib/esm/structured-output/carousel.js +23 -0
- package/lib/esm/structured-output/carousel.js.map +1 -0
- package/lib/esm/structured-output/do-nothing.d.ts +6 -0
- package/lib/esm/structured-output/do-nothing.js +11 -0
- package/lib/esm/structured-output/do-nothing.js.map +1 -0
- package/lib/esm/structured-output/exit.d.ts +6 -0
- package/lib/esm/structured-output/exit.js +11 -0
- package/lib/esm/structured-output/exit.js.map +1 -0
- package/lib/esm/structured-output/index.d.ts +112 -0
- package/lib/esm/structured-output/index.js +47 -0
- package/lib/esm/structured-output/index.js.map +1 -0
- package/lib/esm/structured-output/request-contact-info.d.ts +9 -0
- package/lib/esm/structured-output/request-contact-info.js +14 -0
- package/lib/esm/structured-output/request-contact-info.js.map +1 -0
- package/lib/esm/structured-output/text-with-buttons.d.ts +17 -0
- package/lib/esm/structured-output/text-with-buttons.js +24 -0
- package/lib/esm/structured-output/text-with-buttons.js.map +1 -0
- package/lib/esm/structured-output/text.d.ts +9 -0
- package/lib/esm/structured-output/text.js +14 -0
- package/lib/esm/structured-output/text.js.map +1 -0
- package/lib/esm/tools/index.d.ts +3 -0
- package/lib/esm/tools/index.js +8 -0
- package/lib/esm/tools/index.js.map +1 -0
- package/lib/esm/tools/retrieve-knowledge.d.ts +6 -0
- package/lib/esm/tools/retrieve-knowledge.js +34 -0
- package/lib/esm/tools/retrieve-knowledge.js.map +1 -0
- package/lib/esm/types.d.ts +53 -0
- package/lib/esm/types.js +3 -0
- package/lib/esm/types.js.map +1 -0
- package/package.json +9 -11
- package/src/index.ts +1 -0
- package/src/runners/base-runner.ts +20 -10
- package/src/structured-output/do-nothing.ts +12 -0
- package/src/structured-output/index.ts +4 -0
- package/src/structured-output/request-contact-info.ts +18 -0
- package/lib/agents/base-agent.js +0 -66
- package/lib/agents/base-agent.js.map +0 -1
- package/lib/agents/index.d.ts +0 -2
- package/lib/agents/index.js +0 -9
- package/lib/agents/index.js.map +0 -1
- package/lib/agents/router-agent.js +0 -50
- package/lib/agents/router-agent.js.map +0 -1
- package/lib/agents/specialist-agent.js.map +0 -1
- package/lib/bot-config-tools.js +0 -20
- package/lib/bot-config-tools.js.map +0 -1
- package/lib/constants.js +0 -26
- package/lib/constants.js.map +0 -1
- package/lib/debug-logger.js.map +0 -1
- package/lib/guardrails/index.d.ts +0 -1
- package/lib/guardrails/index.js +0 -6
- package/lib/guardrails/index.js.map +0 -1
- package/lib/guardrails/input.js +0 -119
- package/lib/guardrails/input.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/llm-config.js +0 -150
- package/lib/llm-config.js.map +0 -1
- package/lib/runners/base-runner.js.map +0 -1
- package/lib/runners/index.d.ts +0 -2
- package/lib/runners/index.js +0 -9
- package/lib/runners/index.js.map +0 -1
- package/lib/runners/router-runner.js.map +0 -1
- package/lib/runners/specialist-runner.js +0 -10
- package/lib/runners/specialist-runner.js.map +0 -1
- package/lib/services/hubtype-api-client.js +0 -191
- package/lib/services/hubtype-api-client.js.map +0 -1
- package/lib/services/types.js +0 -13
- package/lib/services/types.js.map +0 -1
- package/lib/structured-output/bot-executor.js +0 -21
- package/lib/structured-output/bot-executor.js.map +0 -1
- package/lib/structured-output/carousel.js +0 -26
- package/lib/structured-output/carousel.js.map +0 -1
- package/lib/structured-output/exit.js +0 -14
- package/lib/structured-output/exit.js.map +0 -1
- package/lib/structured-output/index.js +0 -55
- package/lib/structured-output/index.js.map +0 -1
- package/lib/structured-output/text-with-buttons.js +0 -25
- package/lib/structured-output/text-with-buttons.js.map +0 -1
- package/lib/structured-output/text.js +0 -17
- package/lib/structured-output/text.js.map +0 -1
- package/lib/tools/index.js +0 -8
- package/lib/tools/index.js.map +0 -1
- package/lib/tools/retrieve-knowledge.js +0 -40
- package/lib/tools/retrieve-knowledge.js.map +0 -1
- package/lib/types.js +0 -5
- package/lib/types.js.map +0 -1
- /package/lib/{constants.d.ts → cjs/constants.d.ts} +0 -0
- /package/lib/{structured-output → cjs/structured-output}/bot-executor.d.ts +0 -0
- /package/lib/{structured-output → cjs/structured-output}/carousel.d.ts +0 -0
- /package/lib/{structured-output → cjs/structured-output}/exit.d.ts +0 -0
- /package/lib/{structured-output → cjs/structured-output}/text-with-buttons.d.ts +0 -0
- /package/lib/{structured-output → cjs/structured-output}/text.d.ts +0 -0
package/lib/services/types.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var types_TrackProductName = /*#__PURE__*/ function(TrackProductName) {
|
|
2
|
-
TrackProductName["AI_AGENT"] = "ai_agent";
|
|
3
|
-
return TrackProductName;
|
|
4
|
-
}({});
|
|
5
|
-
var types_TrackFeature = /*#__PURE__*/ function(TrackFeature) {
|
|
6
|
-
TrackFeature["AI_AGENT_RUN"] = "ai_agent_run";
|
|
7
|
-
TrackFeature["AI_AGENT_GUARDRAIL"] = "ai_agent_guardrail";
|
|
8
|
-
return TrackFeature;
|
|
9
|
-
}({});
|
|
10
|
-
|
|
11
|
-
export { types_TrackFeature as TrackFeature, types_TrackProductName as TrackProductName };
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"services/types.js","sources":["../../src/services/types.ts"],"sourcesContent":["import type { HubtypeAssistantMessage, HubtypeUserMessage } from '@botonic/core'\nimport type { AgenticInputMessage } from '../types'\n\nexport enum TrackProductName {\n AI_AGENT = 'ai_agent',\n}\n\nexport enum TrackFeature {\n AI_AGENT_RUN = 'ai_agent_run',\n AI_AGENT_GUARDRAIL = 'ai_agent_guardrail',\n}\n\nexport interface LlmRunData {\n inference_id: string\n is_test: boolean\n product_name: string\n deployment_name: string\n model_name: string\n feature: string\n api_version?: string\n num_prompt_tokens: number\n num_completion_tokens: number\n duration_in_milliseconds: number\n temperature: number\n error: string | null\n}\n\nexport interface TrackLlmRunsData {\n llm_runs: LlmRunData[]\n}\n\nexport type HubtypeMessage = HubtypeAssistantMessage | HubtypeUserMessage\n\n// V2 API Types\ninterface HubtypeToolCall {\n id: string\n type: 'function'\n function: {\n name: string\n arguments: string\n }\n}\n\ninterface HubtypeUserMessageV2 {\n role: 'user'\n content: string | null\n}\n\nexport interface HubtypeAssistantMessageV2 {\n role: 'assistant'\n content: string | null\n tool_calls?: HubtypeToolCall[] | null\n}\n\nexport interface HubtypeToolMessageV2 {\n role: 'tool'\n content: string | null\n tool_call_id: string\n}\n\ninterface HubtypeSystemMessageV2 {\n role: 'system'\n content: string | null\n}\n\nexport type HubtypeMessageV2 =\n | HubtypeUserMessageV2\n | HubtypeAssistantMessageV2\n | HubtypeToolMessageV2\n | HubtypeSystemMessageV2\n\nexport interface MessageHistoryResponseV2 {\n messages: HubtypeMessageV2[]\n conversation_id: string | null\n truncated: boolean\n}\n\nexport interface GetMessagesV2Result {\n messages: AgenticInputMessage[]\n conversationId: string | null\n truncated: boolean\n}\n\nexport interface MessageHistoryV2Params {\n last_message_id: string\n max_messages?: number\n include_tool_calls?: boolean\n max_full_tool_results?: number\n debug_mode?: boolean\n}\n"],"names":["TrackProductName","TrackFeature"],"mappings":"AAGO,IAAKA,sBAAgBA,0BAAhBA;;WAAAA;MAEX;AAEM,IAAKC,kBAAYA,0BAAZA;;;WAAAA;MAGX"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { OutputMessageType } from "@botonic/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const BotExecutorSchema = z.object({
|
|
9
|
-
type: z.literal(OutputMessageType.BotExecutor),
|
|
10
|
-
content: z.object({
|
|
11
|
-
text: z.string(),
|
|
12
|
-
buttons: z.array(z.object({
|
|
13
|
-
text: z.string(),
|
|
14
|
-
payload: z.string()
|
|
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
|
-
|
|
19
|
-
export { BotExecutorSchema };
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=bot-executor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"structured-output/bot-executor.js","sources":["../../src/structured-output/bot-executor.ts"],"sourcesContent":["import { type BotExecutorMessage, OutputMessageType } from '@botonic/core'\nimport { z } from 'zod'\n\nexport type { BotExecutorMessage }\n\nexport const BotExecutorSchema = z\n .object({\n type: z.literal(OutputMessageType.BotExecutor),\n content: z.object({\n text: z.string(),\n buttons: z.array(\n z.object({\n text: z.string(),\n payload: z.string(),\n })\n ),\n }),\n })\n .describe(\n 'A text message with buttons to allow the bot to execute a specific action. Use it only when asked explicitly in the prompt'\n )\n"],"names":["OutputMessageType","z","BotExecutorSchema"],"mappings":";;;;;AAA0E;AACnD;AAIhB,MAAME,iBAAiBA,GAAGD,QACxB,CAAC;IACN,MAAMA,SAAS,CAACD,6BAA6B;IAC7C,SAASC,QAAQ,CAAC;QAChB,MAAMA,QAAQ;QACd,SAASA,OAAO,CACdA,QAAQ,CAAC;YACP,MAAMA,QAAQ;YACd,SAASA,QAAQ;QACnB;IAEJ;AACF,GACC,QAAQ,CACP,8HACD"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { OutputMessageType } from "@botonic/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const CarouselSchema = z.object({
|
|
9
|
-
type: z.literal(OutputMessageType.Carousel),
|
|
10
|
-
content: z.object({
|
|
11
|
-
text: z.string().nullable().optional(),
|
|
12
|
-
elements: z.array(z.object({
|
|
13
|
-
title: z.string(),
|
|
14
|
-
subtitle: z.string(),
|
|
15
|
-
image: z.string(),
|
|
16
|
-
button: z.object({
|
|
17
|
-
text: z.string(),
|
|
18
|
-
url: z.string().nullable().optional()
|
|
19
|
-
})
|
|
20
|
-
}))
|
|
21
|
-
})
|
|
22
|
-
}).describe('A carousel message containing a list of elements');
|
|
23
|
-
|
|
24
|
-
export { CarouselSchema };
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=carousel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"structured-output/carousel.js","sources":["../../src/structured-output/carousel.ts"],"sourcesContent":["import { type CarouselMessage, OutputMessageType } from '@botonic/core'\nimport { z } from 'zod'\n\nexport type { CarouselMessage }\n\nexport const CarouselSchema = z\n .object({\n type: z.literal(OutputMessageType.Carousel),\n content: z.object({\n text: z.string().nullable().optional(),\n elements: z.array(\n z.object({\n title: z.string(),\n subtitle: z.string(),\n image: z.string(),\n button: z.object({\n text: z.string(),\n url: z.string().nullable().optional(),\n }),\n })\n ),\n }),\n })\n .describe('A carousel message containing a list of elements')\n"],"names":["OutputMessageType","z","CarouselSchema"],"mappings":";;;;;AAAuE;AAChD;AAIhB,MAAME,cAAcA,GAAGD,QACrB,CAAC;IACN,MAAMA,SAAS,CAACD,0BAA0B;IAC1C,SAASC,QAAQ,CAAC;QAChB,MAAMA,QAAQ,GAAG,QAAQ,GAAG,QAAQ;QACpC,UAAUA,OAAO,CACfA,QAAQ,CAAC;YACP,OAAOA,QAAQ;YACf,UAAUA,QAAQ;YAClB,OAAOA,QAAQ;YACf,QAAQA,QAAQ,CAAC;gBACf,MAAMA,QAAQ;gBACd,KAAKA,QAAQ,GAAG,QAAQ,GAAG,QAAQ;YACrC;QACF;IAEJ;AACF,GACC,QAAQ,CAAC,oDAAmD"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { OutputMessageType } from "@botonic/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const ExitSchema = z.object({
|
|
9
|
-
type: z.literal(OutputMessageType.Exit)
|
|
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
|
-
|
|
12
|
-
export { ExitSchema };
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=exit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"structured-output/exit.js","sources":["../../src/structured-output/exit.ts"],"sourcesContent":["import { type ExitMessage, OutputMessageType } from '@botonic/core'\nimport { z } from 'zod'\n\nexport type { ExitMessage }\n\nexport const ExitSchema = z\n .object({\n type: z.literal(OutputMessageType.Exit),\n })\n .describe(\n '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'\n )\n"],"names":["OutputMessageType","z","ExitSchema"],"mappings":";;;;;AAAmE;AAC5C;AAIhB,MAAME,UAAUA,GAAGD,QACjB,CAAC;IACN,MAAMA,SAAS,CAACD,sBAAsB;AACxC,GACC,QAAQ,CACP,yIACD"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { BotExecutorSchema } from "./bot-executor.js";
|
|
3
|
-
import { CarouselSchema } from "./carousel.js";
|
|
4
|
-
import { ExitSchema } from "./exit.js";
|
|
5
|
-
import { TextSchema } from "./text.js";
|
|
6
|
-
import { TextWithButtonsSchema } from "./text-with-buttons.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const baseMessageSchemas = [
|
|
21
|
-
TextSchema,
|
|
22
|
-
TextWithButtonsSchema,
|
|
23
|
-
CarouselSchema,
|
|
24
|
-
ExitSchema,
|
|
25
|
-
BotExecutorSchema
|
|
26
|
-
];
|
|
27
|
-
const OutputSchema = z.object({
|
|
28
|
-
messages: z.array(z.union(baseMessageSchemas))
|
|
29
|
-
}).describe('The messages to be sent to the user');
|
|
30
|
-
function getOutputSchema(externalOutputMessagesSchemas) {
|
|
31
|
-
return z.object({
|
|
32
|
-
messages: z.array(z.union([
|
|
33
|
-
...baseMessageSchemas,
|
|
34
|
-
...externalOutputMessagesSchemas
|
|
35
|
-
]))
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
function getOutputInstructions() {
|
|
39
|
-
const example = {
|
|
40
|
-
messages: [
|
|
41
|
-
{
|
|
42
|
-
type: 'text',
|
|
43
|
-
content: {
|
|
44
|
-
text: 'Hello, how can I help you today?'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
};
|
|
49
|
-
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>`;
|
|
50
|
-
return `<output>\n${output}\n</output>`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { OutputSchema, getOutputInstructions, getOutputSchema };
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"structured-output/index.js","sources":["../../src/structured-output/index.ts"],"sourcesContent":["import type { OutputMessage } from '@botonic/core'\nimport { z } from 'zod'\nimport { BotExecutorSchema } from './bot-executor'\nimport { CarouselSchema } from './carousel'\nimport { ExitSchema } from './exit'\nimport { TextSchema } from './text'\nimport { TextWithButtonsSchema } from './text-with-buttons'\n\nexport interface Output {\n messages: OutputMessage[]\n}\n\nconst baseMessageSchemas = [\n TextSchema,\n TextWithButtonsSchema,\n CarouselSchema,\n ExitSchema,\n BotExecutorSchema,\n] as const\nexport const OutputSchema = z\n .object({\n messages: z.array(z.union(baseMessageSchemas)),\n })\n .describe('The messages to be sent to the user')\n\nexport function getOutputSchema(\n externalOutputMessagesSchemas: z.ZodObject<any>[]\n) {\n return z.object({\n messages: z.array(\n z.union([...baseMessageSchemas, ...externalOutputMessagesSchemas])\n ),\n })\n}\n\nexport function getOutputInstructions(): string {\n const example = {\n messages: [\n {\n type: 'text',\n content: {\n text: 'Hello, how can I help you today?',\n },\n },\n ],\n }\n 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>`\n return `<output>\\n${output}\\n</output>`\n}\n"],"names":["z","BotExecutorSchema","CarouselSchema","ExitSchema","TextSchema","TextWithButtonsSchema","baseMessageSchemas","OutputSchema","getOutputSchema","externalOutputMessagesSchemas","getOutputInstructions","example","output","JSON"],"mappings":";;;;;;;;;;;;;AACuB;AAC2B;AACP;AACR;AACA;AACwB;AAM3D,MAAMM,kBAAkBA,GAAG;IACzBF,UAAUA;IACVC,qBAAqBA;IACrBH,cAAcA;IACdC,UAAUA;IACVF,iBAAiBA;CAClB;AACM,MAAMM,YAAYA,GAAGP,QACnB,CAAC;IACN,UAAUA,OAAO,CAACA,OAAO,CAACM,kBAAkBA;AAC9C,GACC,QAAQ,CAAC,uCAAsC;AAE3C,SAASE,eAAeA,CAC7BC,6BAAiD;IAEjD,OAAOT,QAAQ,CAAC;QACd,UAAUA,OAAO,CACfA,OAAO,CAAC;eAAIM,kBAAkBA;eAAKG;SAA8B;IAErE;AACF;AAEO,SAASC,qBAAqBA;IACnC,MAAMC,UAAU;QACd,UAAU;YACR;gBACE,MAAM;gBACN,SAAS;oBACP,MAAM;gBACR;YACF;SACD;IACH;IACA,MAAMC,SAAS,CAAC,sIAAsI,EAAEC,KAAK,SAAS,CAACF,SAAS,YAAY,CAAC;IAC7L,OAAO,CAAC,UAAU,EAAEC,OAAO,WAAW,CAAC;AACzC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { OutputMessageType } from "@botonic/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const TextWithButtonsSchema = z.object({
|
|
9
|
-
type: z.literal(OutputMessageType.TextWithButtons),
|
|
10
|
-
content: z.object({
|
|
11
|
-
text: z.string(),
|
|
12
|
-
buttons: z.array(z.object({
|
|
13
|
-
text: z.string(),
|
|
14
|
-
url: z.string().nullable().optional(),
|
|
15
|
-
target: z["enum"]([
|
|
16
|
-
'_blank',
|
|
17
|
-
'_self'
|
|
18
|
-
]).default('_blank').nullable().optional().describe('The target of the button when it has an url. If not provided, it will default to _blank.')
|
|
19
|
-
}))
|
|
20
|
-
})
|
|
21
|
-
}).describe('A text message with buttons to allow the user to use quick replies');
|
|
22
|
-
|
|
23
|
-
export { TextWithButtonsSchema };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=text-with-buttons.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"structured-output/text-with-buttons.js","sources":["../../src/structured-output/text-with-buttons.ts"],"sourcesContent":["import { OutputMessageType, type TextWithButtonsMessage } from '@botonic/core'\nimport { z } from 'zod'\n\nexport type { TextWithButtonsMessage }\n\nexport const TextWithButtonsSchema = z\n .object({\n type: z.literal(OutputMessageType.TextWithButtons),\n content: z.object({\n text: z.string(),\n buttons: z.array(\n z.object({\n text: z.string(),\n url: z.string().nullable().optional(),\n target: z\n .enum(['_blank', '_self'])\n .default('_blank')\n .nullable()\n .optional()\n .describe(\n 'The target of the button when it has an url. If not provided, it will default to _blank.'\n ),\n })\n ),\n }),\n })\n .describe(\n 'A text message with buttons to allow the user to use quick replies'\n )\n"],"names":["OutputMessageType","z","TextWithButtonsSchema"],"mappings":";;;;;AAA8E;AACvD;AAIhB,MAAME,qBAAqBA,GAAGD,QAC5B,CAAC;IACN,MAAMA,SAAS,CAACD,iCAAiC;IACjD,SAASC,QAAQ,CAAC;QAChB,MAAMA,QAAQ;QACd,SAASA,OAAO,CACdA,QAAQ,CAAC;YACP,MAAMA,QAAQ;YACd,KAAKA,QAAQ,GAAG,QAAQ,GAAG,QAAQ;YACnC,QAAQA,SACD,CAAC;gBAAC;gBAAU;aAAQ,EACxB,OAAO,CAAC,UACR,QAAQ,GACR,QAAQ,GACR,QAAQ,CACP;QAEN;IAEJ;AACF,GACC,QAAQ,CACP,sEACD"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { OutputMessageType } from "@botonic/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const TextSchema = z.object({
|
|
9
|
-
type: z.literal(OutputMessageType.Text),
|
|
10
|
-
content: z.object({
|
|
11
|
-
text: z.string()
|
|
12
|
-
})
|
|
13
|
-
}).describe('A text message');
|
|
14
|
-
|
|
15
|
-
export { TextSchema };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=text.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"structured-output/text.js","sources":["../../src/structured-output/text.ts"],"sourcesContent":["import { OutputMessageType, type TextMessage } from '@botonic/core'\nimport { z } from 'zod'\n\nexport type { TextMessage }\n\nexport const TextSchema = z\n .object({\n type: z.literal(OutputMessageType.Text),\n content: z.object({\n text: z.string(),\n }),\n })\n .describe('A text message')\n"],"names":["OutputMessageType","z","TextSchema"],"mappings":";;;;;AAAmE;AAC5C;AAIhB,MAAME,UAAUA,GAAGD,QACjB,CAAC;IACN,MAAMA,SAAS,CAACD,sBAAsB;IACtC,SAASC,QAAQ,CAAC;QAChB,MAAMA,QAAQ;IAChB;AACF,GACC,QAAQ,CAAC,kBAAiB"}
|
package/lib/tools/index.js
DELETED
package/lib/tools/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools/index.js","sources":["../../src/tools/index.ts"],"sourcesContent":["import type { Tool } from '../types'\n\nexport {\n createRetrieveKnowledge,\n RETRIEVE_KNOWLEDGE_TOOL_NAME,\n} from './retrieve-knowledge'\n\nexport const mandatoryTools: Tool[] = []\n"],"names":["createRetrieveKnowledge","RETRIEVE_KNOWLEDGE_TOOL_NAME","mandatoryTools"],"mappings":";AAK6B;AAEtB,MAAME,cAAcA,GAAW,EAAE"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { tool } from "@openai/agents";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { HubtypeApiClient } from "../services/hubtype-api-client.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const RETRIEVE_KNOWLEDGE_TOOL_NAME = 'retrieve_knowledge';
|
|
12
|
-
const createRetrieveKnowledge = (sourceIds)=>tool({
|
|
13
|
-
name: RETRIEVE_KNOWLEDGE_TOOL_NAME,
|
|
14
|
-
description: 'Consult the knowledge base for information before answering. Use this tool to make sure the information you provide is faithful.',
|
|
15
|
-
parameters: z.object({
|
|
16
|
-
query: z.string().describe('The query to search the knowledge base for')
|
|
17
|
-
}),
|
|
18
|
-
execute: async (input, runContext)=>{
|
|
19
|
-
const context = runContext?.context;
|
|
20
|
-
const query = input.query;
|
|
21
|
-
if (!context) {
|
|
22
|
-
throw new Error('Context is required');
|
|
23
|
-
}
|
|
24
|
-
const client = new HubtypeApiClient(context.authToken);
|
|
25
|
-
const chunks = await client.retrieveSimilarChunks(query, sourceIds);
|
|
26
|
-
const chunksIds = chunks.map((chunk)=>chunk.id);
|
|
27
|
-
const chunkTexts = chunks.map((chunk)=>chunk.text);
|
|
28
|
-
context.knowledgeUsed = {
|
|
29
|
-
query,
|
|
30
|
-
sourceIds,
|
|
31
|
-
chunksIds,
|
|
32
|
-
chunkTexts
|
|
33
|
-
};
|
|
34
|
-
return chunkTexts;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
export { RETRIEVE_KNOWLEDGE_TOOL_NAME, createRetrieveKnowledge };
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=retrieve-knowledge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools/retrieve-knowledge.js","sources":["../../src/tools/retrieve-knowledge.ts"],"sourcesContent":["import { type RunContext, tool } from '@openai/agents'\nimport { z } from 'zod'\n\nimport { HubtypeApiClient } from '../services/hubtype-api-client'\nimport type { Context } from '../types'\n\nexport const RETRIEVE_KNOWLEDGE_TOOL_NAME = 'retrieve_knowledge'\n\nexport const createRetrieveKnowledge = (sourceIds: string[]) =>\n tool({\n name: RETRIEVE_KNOWLEDGE_TOOL_NAME,\n description:\n 'Consult the knowledge base for information before answering. Use this tool to make sure the information you provide is faithful.',\n parameters: z.object({\n query: z.string().describe('The query to search the knowledge base for'),\n }),\n execute: async (\n input: { query: string },\n runContext?: RunContext<Context>\n ): Promise<string[]> => {\n const context = runContext?.context\n const query = input.query\n if (!context) {\n throw new Error('Context is required')\n }\n const client = new HubtypeApiClient(context.authToken)\n const chunks = await client.retrieveSimilarChunks(query, sourceIds)\n const chunksIds = chunks.map(chunk => chunk.id)\n const chunkTexts = chunks.map(chunk => chunk.text)\n\n context.knowledgeUsed = {\n query,\n sourceIds,\n chunksIds,\n chunkTexts,\n }\n\n return chunkTexts\n },\n })\n"],"names":["tool","z","HubtypeApiClient","RETRIEVE_KNOWLEDGE_TOOL_NAME","createRetrieveKnowledge","sourceIds","input","runContext","context","query","Error","client","chunks","chunksIds","chunk","chunkTexts"],"mappings":";;;;;;;AAAsD;AAC/B;AAE0C;AAG1D,MAAMG,4BAA4BA,GAAG,qBAAoB;AAEzD,MAAMC,uBAAuBA,GAAG,CAACC,YACtCL,IAAIA,CAAC;QACH,MAAMG,4BAA4BA;QAClC,aACE;QACF,YAAYF,QAAQ,CAAC;YACnB,OAAOA,QAAQ,GAAG,QAAQ,CAAC;QAC7B;QACA,SAAS,OACPK,OACAC;YAEA,MAAMC,UAAUD,YAAY;YAC5B,MAAME,QAAQH,MAAM,KAAK;YACzB,IAAI,CAACE,SAAS;gBACZ,MAAM,IAAIE,MAAM;YAClB;YACA,MAAMC,SAAS,IAAIT,gBAAgBA,CAACM,QAAQ,SAAS;YACrD,MAAMI,SAAS,MAAMD,OAAO,qBAAqB,CAACF,OAAOJ;YACzD,MAAMQ,YAAYD,OAAO,GAAG,CAACE,CAAAA,QAASA,MAAM,EAAE;YAC9C,MAAMC,aAAaH,OAAO,GAAG,CAACE,CAAAA,QAASA,MAAM,IAAI;YAEjDN,QAAQ,aAAa,GAAG;gBACtBC;gBACAJ;gBACAQ;gBACAE;YACF;YAEA,OAAOA;QACT;IACF,GAAE"}
|
package/lib/types.js
DELETED
package/lib/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n AgenticOutputMessage,\n AiAgentArgs,\n BotContext,\n GuardrailRule,\n InferenceResponse,\n ResolvedPlugins,\n RunResult,\n} from '@botonic/core'\nimport type {\n Agent,\n AgentInputItem,\n AgentOutputType,\n RunContext as OpenAIRunContext,\n Tool as OpenAITool,\n} from '@openai/agents'\nimport type { ZodType } from 'zod'\n\nimport type { OutputSchema } from './structured-output'\n\nexport interface Context<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> {\n authToken: string\n knowledgeUsed: {\n query: string\n sourceIds: string[]\n chunksIds: string[]\n chunkTexts: string[]\n }\n request: BotContext<TPlugins, TExtraData>\n}\n\nexport type RunContext<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = OpenAIRunContext<Context<TPlugins, TExtraData>>\n\nexport interface CustomTool<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> {\n name: string\n description: string\n schema: ZodType\n func: (\n input?: any,\n runContext?: RunContext<TPlugins, TExtraData>\n ) => Promise<any>\n}\n\nexport interface Chunk {\n id: string\n text: string\n}\n\nexport type Tool<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = OpenAITool<Context<TPlugins, TExtraData>>\n\nexport type AIAgent<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = Agent<Context<TPlugins, TExtraData>, AgentOutputType<typeof OutputSchema>>\n\nexport interface MemoryOptions {\n maxMessages: number\n includeToolCalls: boolean\n maxFullToolResults: number\n debugMode: boolean\n}\n\nexport interface PluginAiAgentOptions<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> {\n authToken?: string\n customTools?: CustomTool<TPlugins, TExtraData>[]\n maxRetries?: number\n timeout?: number\n memory?: Partial<MemoryOptions>\n /** Enable debug logging for AI agent configuration and execution details. */\n enableDebug?: boolean\n /** Key for the local storage to to get messages in local development mode */\n localStorageKey?: string\n}\n\nexport interface ResultRawResponse {\n usage: {\n inputTokens: number\n outputTokens: number\n }\n providerData?: Record<string, unknown>\n}\n\nexport type AgenticInputMessage = AgentInputItem\n\nexport type {\n AgenticOutputMessage,\n AiAgentArgs,\n GuardrailRule,\n InferenceResponse,\n RunResult,\n}\n"],"names":[],"mappings":"AAyGC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|