@botonic/react 0.48.1 → 0.49.0-alpha.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/cjs/components/system-debug-trace/debug-message.js +2 -0
- package/lib/cjs/components/system-debug-trace/debug-message.js.map +1 -1
- package/lib/cjs/components/system-debug-trace/events/ai-agent/ai-agent.js +1 -1
- package/lib/cjs/components/system-debug-trace/events/ai-agent/ai-agent.js.map +1 -1
- package/lib/cjs/components/system-debug-trace/events/ai-agent/parse-tools.d.ts +1 -1
- package/lib/cjs/components/system-debug-trace/events/ai-agent/parse-tools.js +6 -2
- package/lib/cjs/components/system-debug-trace/events/ai-agent/parse-tools.js.map +1 -1
- package/lib/cjs/components/system-debug-trace/events/ai-agent-router/ai-agent-router.d.ts +4 -0
- package/lib/cjs/components/system-debug-trace/events/ai-agent-router/ai-agent-router.js +23 -0
- package/lib/cjs/components/system-debug-trace/events/ai-agent-router/ai-agent-router.js.map +1 -0
- package/lib/cjs/components/system-debug-trace/events/ai-agent-router/index.d.ts +2 -0
- package/lib/cjs/components/system-debug-trace/events/ai-agent-router/index.js +6 -0
- package/lib/cjs/components/system-debug-trace/events/ai-agent-router/index.js.map +1 -0
- package/lib/cjs/components/system-debug-trace/events/ai-agent-router/types.d.ts +23 -0
- package/lib/cjs/components/system-debug-trace/events/ai-agent-router/types.js +3 -0
- package/lib/cjs/components/system-debug-trace/events/ai-agent-router/types.js.map +1 -0
- package/lib/cjs/components/system-debug-trace/events/constants.d.ts +4 -0
- package/lib/cjs/components/system-debug-trace/events/constants.js +4 -0
- package/lib/cjs/components/system-debug-trace/events/constants.js.map +1 -1
- package/lib/cjs/components/system-debug-trace/events/index.d.ts +1 -0
- package/lib/cjs/components/system-debug-trace/events/index.js +1 -0
- package/lib/cjs/components/system-debug-trace/events/index.js.map +1 -1
- package/lib/cjs/components/system-debug-trace/hooks/use-last-label-position.js +36 -28
- package/lib/cjs/components/system-debug-trace/hooks/use-last-label-position.js.map +1 -1
- package/lib/cjs/components/system-debug-trace/icons/ai-router.d.ts +1 -0
- package/lib/cjs/components/system-debug-trace/icons/ai-router.js +11 -0
- package/lib/cjs/components/system-debug-trace/icons/ai-router.js.map +1 -0
- package/lib/cjs/components/system-debug-trace/icons/index.d.ts +2 -0
- package/lib/cjs/components/system-debug-trace/icons/index.js +2 -0
- package/lib/cjs/components/system-debug-trace/icons/index.js.map +1 -1
- package/lib/cjs/components/system-debug-trace/types.d.ts +2 -2
- package/lib/cjs/debug-system-messages.d.ts +198 -0
- package/lib/cjs/debug-system-messages.js +240 -0
- package/lib/cjs/debug-system-messages.js.map +1 -0
- package/lib/cjs/dev-app.d.ts +199 -0
- package/lib/cjs/dev-app.js +22 -0
- package/lib/cjs/dev-app.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/components/system-debug-trace/debug-message.js +2 -0
- package/lib/esm/components/system-debug-trace/debug-message.js.map +1 -1
- package/lib/esm/components/system-debug-trace/events/ai-agent/ai-agent.js +1 -1
- package/lib/esm/components/system-debug-trace/events/ai-agent/ai-agent.js.map +1 -1
- package/lib/esm/components/system-debug-trace/events/ai-agent/parse-tools.d.ts +1 -1
- package/lib/esm/components/system-debug-trace/events/ai-agent/parse-tools.js +6 -2
- package/lib/esm/components/system-debug-trace/events/ai-agent/parse-tools.js.map +1 -1
- package/lib/esm/components/system-debug-trace/events/ai-agent-router/ai-agent-router.d.ts +4 -0
- package/lib/esm/components/system-debug-trace/events/ai-agent-router/ai-agent-router.js +23 -0
- package/lib/esm/components/system-debug-trace/events/ai-agent-router/ai-agent-router.js.map +1 -0
- package/lib/esm/components/system-debug-trace/events/ai-agent-router/index.d.ts +2 -0
- package/lib/esm/components/system-debug-trace/events/ai-agent-router/index.js +6 -0
- package/lib/esm/components/system-debug-trace/events/ai-agent-router/index.js.map +1 -0
- package/lib/esm/components/system-debug-trace/events/ai-agent-router/types.d.ts +23 -0
- package/lib/esm/components/system-debug-trace/events/ai-agent-router/types.js +3 -0
- package/lib/esm/components/system-debug-trace/events/ai-agent-router/types.js.map +1 -0
- package/lib/esm/components/system-debug-trace/events/constants.d.ts +4 -0
- package/lib/esm/components/system-debug-trace/events/constants.js +4 -0
- package/lib/esm/components/system-debug-trace/events/constants.js.map +1 -1
- package/lib/esm/components/system-debug-trace/events/index.d.ts +1 -0
- package/lib/esm/components/system-debug-trace/events/index.js +1 -0
- package/lib/esm/components/system-debug-trace/events/index.js.map +1 -1
- package/lib/esm/components/system-debug-trace/hooks/use-last-label-position.js +36 -28
- package/lib/esm/components/system-debug-trace/hooks/use-last-label-position.js.map +1 -1
- package/lib/esm/components/system-debug-trace/icons/ai-router.d.ts +1 -0
- package/lib/esm/components/system-debug-trace/icons/ai-router.js +11 -0
- package/lib/esm/components/system-debug-trace/icons/ai-router.js.map +1 -0
- package/lib/esm/components/system-debug-trace/icons/index.d.ts +2 -0
- package/lib/esm/components/system-debug-trace/icons/index.js +2 -0
- package/lib/esm/components/system-debug-trace/icons/index.js.map +1 -1
- package/lib/esm/components/system-debug-trace/types.d.ts +2 -2
- package/lib/esm/debug-system-messages.d.ts +198 -0
- package/lib/esm/debug-system-messages.js +240 -0
- package/lib/esm/debug-system-messages.js.map +1 -0
- package/lib/esm/dev-app.d.ts +199 -0
- package/lib/esm/dev-app.js +22 -0
- package/lib/esm/dev-app.js.map +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +3 -1
- package/lib/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/system-debug-trace/debug-message.tsx +3 -0
- package/src/components/system-debug-trace/events/ai-agent/ai-agent.tsx +1 -1
- package/src/components/system-debug-trace/events/ai-agent/parse-tools.ts +14 -2
- package/src/components/system-debug-trace/events/ai-agent-router/ai-agent-router.tsx +75 -0
- package/src/components/system-debug-trace/events/ai-agent-router/index.ts +2 -0
- package/src/components/system-debug-trace/events/ai-agent-router/types.ts +26 -0
- package/src/components/system-debug-trace/events/constants.ts +4 -0
- package/src/components/system-debug-trace/events/index.ts +1 -0
- package/src/components/system-debug-trace/hooks/use-last-label-position.ts +42 -32
- package/src/components/system-debug-trace/icons/ai-router.tsx +45 -0
- package/src/components/system-debug-trace/icons/index.ts +2 -0
- package/src/components/system-debug-trace/types.ts +2 -0
- package/src/debug-system-messages.ts +276 -0
- package/src/dev-app.jsx +24 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { EventAction } from '@botonic/core'
|
|
2
|
+
import { AiRouterSvg, HandSvg, HeadSetSvg } from '../../icons'
|
|
3
|
+
import {
|
|
4
|
+
StyledDebugDetail,
|
|
5
|
+
StyledDebugItemWithIcon,
|
|
6
|
+
StyledDebugLabel,
|
|
7
|
+
StyledDebugValue,
|
|
8
|
+
StyledGuardrailLabel,
|
|
9
|
+
StyledGuardrailValue,
|
|
10
|
+
} from '../../styles'
|
|
11
|
+
import type { DebugEventConfig } from '../../types'
|
|
12
|
+
import { LABELS } from '../constants'
|
|
13
|
+
import type { AiAgentRouterDebugEvent } from './types'
|
|
14
|
+
|
|
15
|
+
export const AiAgentRouter = ({
|
|
16
|
+
input_guardrails_triggered,
|
|
17
|
+
available_specialists,
|
|
18
|
+
is_transferred_to_specialist,
|
|
19
|
+
last_agent_name,
|
|
20
|
+
}: AiAgentRouterDebugEvent) => {
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
{available_specialists.length > 0 && (
|
|
24
|
+
<StyledDebugDetail data-line-end>
|
|
25
|
+
<StyledDebugLabel>{LABELS.SPECIALISTS_AVAILABLE}</StyledDebugLabel>
|
|
26
|
+
{available_specialists.map(h => (
|
|
27
|
+
<StyledDebugItemWithIcon key={h.name}>
|
|
28
|
+
<HeadSetSvg />
|
|
29
|
+
{h.name}
|
|
30
|
+
</StyledDebugItemWithIcon>
|
|
31
|
+
))}
|
|
32
|
+
</StyledDebugDetail>
|
|
33
|
+
)}
|
|
34
|
+
|
|
35
|
+
<StyledDebugDetail>
|
|
36
|
+
{is_transferred_to_specialist ? (
|
|
37
|
+
<StyledDebugValue>
|
|
38
|
+
{LABELS.TRANSFERRED_TO}{' '}
|
|
39
|
+
<span style={{ fontWeight: 400 }}>- {last_agent_name}</span>
|
|
40
|
+
</StyledDebugValue>
|
|
41
|
+
) : input_guardrails_triggered.length > 0 ? (
|
|
42
|
+
<>
|
|
43
|
+
{input_guardrails_triggered.map(guardrail => (
|
|
44
|
+
<StyledDebugItemWithIcon key={`input-guardrail-${guardrail}`}>
|
|
45
|
+
<HandSvg />
|
|
46
|
+
<StyledGuardrailLabel>
|
|
47
|
+
{LABELS.GUARDRAIL_TRIGGERED}
|
|
48
|
+
</StyledGuardrailLabel>
|
|
49
|
+
<StyledGuardrailValue>- {guardrail}</StyledGuardrailValue>
|
|
50
|
+
</StyledDebugItemWithIcon>
|
|
51
|
+
))}
|
|
52
|
+
</>
|
|
53
|
+
) : (
|
|
54
|
+
<StyledDebugValue>{LABELS.NO_TRANSFER}</StyledDebugValue>
|
|
55
|
+
)}
|
|
56
|
+
</StyledDebugDetail>
|
|
57
|
+
</>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const getAiAgentRouterEventConfig = (
|
|
62
|
+
data: AiAgentRouterDebugEvent
|
|
63
|
+
): DebugEventConfig => {
|
|
64
|
+
return {
|
|
65
|
+
action: EventAction.AiAgentRouter,
|
|
66
|
+
title: (
|
|
67
|
+
<>
|
|
68
|
+
Router triggered <span>- {data.flow_node_content_id}</span>
|
|
69
|
+
</>
|
|
70
|
+
),
|
|
71
|
+
component: AiAgentRouter,
|
|
72
|
+
icon: <AiRouterSvg />,
|
|
73
|
+
collapsible: true,
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { EventAction } from '@botonic/core'
|
|
2
|
+
import type { ToolExecuted } from '../ai-agent/types'
|
|
3
|
+
import type { ChunkIdsGroupedBySourceData } from '../knowledge-bases-types'
|
|
4
|
+
|
|
5
|
+
export type { ToolExecuted }
|
|
6
|
+
|
|
7
|
+
export interface SpecialistDebugEvent {
|
|
8
|
+
name: string
|
|
9
|
+
description: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AiAgentRouterDebugEvent {
|
|
13
|
+
action: EventAction.AiAgentRouter
|
|
14
|
+
flow_node_content_id: string
|
|
15
|
+
tools_executed: ToolExecuted[]
|
|
16
|
+
memory_length: number
|
|
17
|
+
input_guardrails_triggered: string[]
|
|
18
|
+
output_guardrails_triggered: string[]
|
|
19
|
+
exit: boolean
|
|
20
|
+
starting_agent_name: string
|
|
21
|
+
last_agent_name: string
|
|
22
|
+
available_specialists: SpecialistDebugEvent[]
|
|
23
|
+
is_transferred_to_specialist: boolean
|
|
24
|
+
knowledge_base_chunks_with_sources?: ChunkIdsGroupedBySourceData[]
|
|
25
|
+
messageId?: string
|
|
26
|
+
}
|
|
@@ -25,4 +25,8 @@ export const LABELS = {
|
|
|
25
25
|
OPEN: 'Open',
|
|
26
26
|
CLOSED: 'Closed',
|
|
27
27
|
AGENTS_AVAILABLE: 'Agents available',
|
|
28
|
+
AVAILABLE_TRANSFERS: 'Available transfers',
|
|
29
|
+
SPECIALISTS_AVAILABLE: 'Specialists available',
|
|
30
|
+
NO_TRANSFER: 'No transfer',
|
|
31
|
+
TRANSFERRED_TO: 'Transferred to',
|
|
28
32
|
} as const
|
|
@@ -38,43 +38,53 @@ export function useLastLabelPosition({
|
|
|
38
38
|
return
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (el.tagName === 'STRONG') {
|
|
47
|
-
return true
|
|
48
|
-
}
|
|
41
|
+
// If an explicit line-end marker exists, use its bottom edge
|
|
42
|
+
const lineEndMarker =
|
|
43
|
+
wrapper.querySelector<HTMLElement>('[data-line-end]')
|
|
44
|
+
|
|
45
|
+
let labelBottomPosition: number
|
|
49
46
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
if (lineEndMarker) {
|
|
48
|
+
const wrapperTop = wrapper.getBoundingClientRect().top
|
|
49
|
+
labelBottomPosition =
|
|
50
|
+
lineEndMarker.getBoundingClientRect().bottom - wrapperTop
|
|
51
|
+
} else {
|
|
52
|
+
// Find all label elements in order (both <strong> for DebugLabel and <span> for GuardrailLabel)
|
|
53
|
+
// We need to get them in DOM order to find the actual last one
|
|
54
|
+
const allElements =
|
|
55
|
+
wrapper.querySelectorAll<HTMLElement>('strong, span')
|
|
56
|
+
const allLabels = Array.from(allElements).filter(el => {
|
|
57
|
+
// Include all <strong> elements (they're DebugLabels)
|
|
58
|
+
if (el.tagName === 'STRONG') {
|
|
59
|
+
return true
|
|
62
60
|
}
|
|
63
|
-
}
|
|
64
|
-
return false
|
|
65
|
-
})
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
// For <span>, only include if it's a direct child of a flex container (GuardrailLabel pattern)
|
|
63
|
+
// and has no child elements (just text)
|
|
64
|
+
if (
|
|
65
|
+
el.tagName === 'SPAN' &&
|
|
66
|
+
el.children.length === 0 &&
|
|
67
|
+
el.textContent?.trim()
|
|
68
|
+
) {
|
|
69
|
+
const parent = el.parentElement
|
|
70
|
+
if (parent) {
|
|
71
|
+
const parentStyle = window.getComputedStyle(parent)
|
|
72
|
+
// GuardrailItem has display: flex
|
|
73
|
+
return parentStyle.display === 'flex'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return false
|
|
77
|
+
})
|
|
70
78
|
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
if (allLabels.length === 0) {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
const lastLabel = allLabels[allLabels.length - 1]
|
|
84
|
+
const wrapperTop = wrapper.getBoundingClientRect().top
|
|
85
|
+
labelBottomPosition =
|
|
86
|
+
lastLabel.getBoundingClientRect().bottom - wrapperTop
|
|
87
|
+
}
|
|
78
88
|
|
|
79
89
|
// Set CSS variable for line height calculation
|
|
80
90
|
wrapper.style.setProperty(
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const AiRouterSvg = () => {
|
|
2
|
+
return (
|
|
3
|
+
// biome-ignore lint/a11y/noSvgWithoutTitle: This is a SVG icon
|
|
4
|
+
<svg
|
|
5
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
6
|
+
width='18'
|
|
7
|
+
height='18'
|
|
8
|
+
viewBox='0 0 18 18'
|
|
9
|
+
fill='none'
|
|
10
|
+
>
|
|
11
|
+
<path
|
|
12
|
+
d='M3.93749 3.63077C4.42648 3.63077 4.85794 3.22807 4.85794 2.71032C4.85794 2.22132 4.42648 1.78986 3.93749 1.78986C3.41974 1.78986 3.01703 2.22132 3.01703 2.71032C3.01703 3.22807 3.41974 3.63077 3.93749 3.63077ZM6.23863 2.71032C6.23863 3.74582 5.54828 4.63752 4.62783 4.92516V7.77282C5.20312 7.34136 5.92222 7.08248 6.69885 7.08248H9.46022C10.582 7.08248 11.5313 6.16202 11.5313 5.01145V4.92516C10.582 4.63752 9.92044 3.74582 9.92044 2.71032C9.92044 1.44469 10.9272 0.40918 12.2216 0.40918C13.4872 0.40918 14.5227 1.44469 14.5227 2.71032C14.5227 3.74582 13.8323 4.63752 12.9119 4.92516V5.01145C12.9119 6.93865 11.3586 8.4632 9.46022 8.4632H6.69885C5.54828 8.4632 4.62783 9.41237 4.62783 10.5342V10.6492C5.54828 10.9369 6.23863 11.8285 6.23863 12.8353C6.23863 14.1297 5.20312 15.1365 3.93749 15.1365C2.6431 15.1365 1.63635 14.1297 1.63635 12.8353C1.63635 11.8285 2.29793 10.9369 3.24715 10.6492V10.5342V4.92516C2.29793 4.63752 1.63635 3.74582 1.63635 2.71032C1.63635 1.44469 2.6431 0.40918 3.93749 0.40918C5.20312 0.40918 6.23863 1.44469 6.23863 2.71032ZM13.142 2.71032C13.142 2.22132 12.7106 1.78986 12.2216 1.78986C11.7038 1.78986 11.3011 2.22132 11.3011 2.71032C11.3011 3.22807 11.7038 3.63077 12.2216 3.63077C12.7106 3.63077 13.142 3.22807 13.142 2.71032ZM3.93749 13.7558C4.42648 13.7558 4.85794 13.3531 4.85794 12.8353C4.85794 12.3463 4.42648 11.9149 3.93749 11.9149C3.41974 11.9149 3.01703 12.3463 3.01703 12.8353C3.01703 13.3531 3.41974 13.7558 3.93749 13.7558Z'
|
|
13
|
+
fill='url(#ai-router-gradient-0)'
|
|
14
|
+
/>
|
|
15
|
+
<path
|
|
16
|
+
d='M12.5839 10.0164C12.5285 9.89486 12.4069 9.81812 12.2748 9.81812C12.1427 9.81812 12.0211 9.89486 11.9657 10.0164L10.8337 12.4672L8.38215 13.5989C8.25851 13.6565 8.18176 13.778 8.18176 13.9101C8.18176 14.0422 8.25851 14.1637 8.38002 14.2191L10.8316 15.3508L11.9636 17.8017C12.019 17.9232 12.1405 17.9999 12.2727 17.9999C12.4048 17.9999 12.5264 17.9232 12.5818 17.8017L13.7137 15.3508L16.1653 14.2191C16.2868 14.1637 16.3636 14.0422 16.3636 13.9101C16.3636 13.778 16.2868 13.6565 16.1653 13.6011L13.7137 12.4694L12.5818 10.0185L12.5839 10.0164Z'
|
|
17
|
+
fill='url(#ai-router-gradient-1)'
|
|
18
|
+
/>
|
|
19
|
+
<defs>
|
|
20
|
+
<linearGradient
|
|
21
|
+
id='ai-router-gradient-0'
|
|
22
|
+
x1='1.63635'
|
|
23
|
+
y1='7.77282'
|
|
24
|
+
x2='14.5227'
|
|
25
|
+
y2='7.77282'
|
|
26
|
+
gradientUnits='userSpaceOnUse'
|
|
27
|
+
>
|
|
28
|
+
<stop stopColor='#6E49FF' />
|
|
29
|
+
<stop offset='1' stopColor='#CC3559' />
|
|
30
|
+
</linearGradient>
|
|
31
|
+
<linearGradient
|
|
32
|
+
id='ai-router-gradient-1'
|
|
33
|
+
x1='8.18176'
|
|
34
|
+
y1='13.909'
|
|
35
|
+
x2='16.3636'
|
|
36
|
+
y2='13.909'
|
|
37
|
+
gradientUnits='userSpaceOnUse'
|
|
38
|
+
>
|
|
39
|
+
<stop stopColor='#6E49FF' />
|
|
40
|
+
<stop offset='1' stopColor='#CC3559' />
|
|
41
|
+
</linearGradient>
|
|
42
|
+
</defs>
|
|
43
|
+
</svg>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './ai-router'
|
|
1
2
|
export * from './brain'
|
|
2
3
|
export * from './caret-down'
|
|
3
4
|
export * from './caret-up'
|
|
@@ -10,4 +11,5 @@ export * from './life-ring'
|
|
|
10
11
|
export * from './link'
|
|
11
12
|
export * from './quote-right'
|
|
12
13
|
export * from './screwdriver-wrench'
|
|
14
|
+
export * from './split'
|
|
13
15
|
export * from './wand'
|
|
@@ -2,6 +2,7 @@ import type React from 'react'
|
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
4
|
AiAgentDebugEvent,
|
|
5
|
+
AiAgentRouterDebugEvent,
|
|
5
6
|
BotActionDebugEvent,
|
|
6
7
|
ConditionalChannelDebugEvent,
|
|
7
8
|
ConditionalCountryDebugEvent,
|
|
@@ -24,6 +25,7 @@ export interface IconProps {
|
|
|
24
25
|
export type DebugEvent =
|
|
25
26
|
| KeywordDebugEvent
|
|
26
27
|
| AiAgentDebugEvent
|
|
28
|
+
| AiAgentRouterDebugEvent
|
|
27
29
|
| KnowledgeBaseDebugEvent
|
|
28
30
|
| FallbackDebugEvent
|
|
29
31
|
| SmartIntentDebugEvent
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-only mock payloads for every SystemDebugTrace event type.
|
|
3
|
+
*
|
|
4
|
+
* Usage from dev-entry.ts:
|
|
5
|
+
* import { DEBUG_SYSTEM_MESSAGES } from '@botonic/react/src/debug-system-messages'
|
|
6
|
+
* app.addDebugSystemMessage(DEBUG_SYSTEM_MESSAGES.keyword)
|
|
7
|
+
*
|
|
8
|
+
* Usage from the browser console (window.Botonic is the DevApp instance):
|
|
9
|
+
* Botonic.addDebugSystemMessage({ action: 'nlu_keyword', nlu_keyword_name: 'hello', ... })
|
|
10
|
+
* // or use the pre-built fixtures exposed on the DevApp:
|
|
11
|
+
* Botonic.addDebugSystemMessage(Botonic.debugSystemMessages.aiAgent)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { EventAction } from '@botonic/core'
|
|
15
|
+
|
|
16
|
+
import type {
|
|
17
|
+
AiAgentDebugEvent,
|
|
18
|
+
AiAgentRouterDebugEvent,
|
|
19
|
+
BotActionDebugEvent,
|
|
20
|
+
ConditionalChannelDebugEvent,
|
|
21
|
+
ConditionalCountryDebugEvent,
|
|
22
|
+
ConditionalCustomDebugEvent,
|
|
23
|
+
ConditionalQueueStatusDebugEvent,
|
|
24
|
+
FallbackDebugEvent,
|
|
25
|
+
HandoffSuccessDebugEvent,
|
|
26
|
+
KeywordDebugEvent,
|
|
27
|
+
KnowledgeBaseDebugEvent,
|
|
28
|
+
RedirectFlowDebugEvent,
|
|
29
|
+
SmartIntentDebugEvent,
|
|
30
|
+
WebviewActionTriggeredDebugEvent,
|
|
31
|
+
} from './components/system-debug-trace/events'
|
|
32
|
+
import type { ChunkIdsGroupedBySourceData } from './components/system-debug-trace/events/knowledge-bases-types'
|
|
33
|
+
|
|
34
|
+
const mockChunksWithSources: ChunkIdsGroupedBySourceData[] = [
|
|
35
|
+
{
|
|
36
|
+
source: {
|
|
37
|
+
id: 'src-mock-001',
|
|
38
|
+
name: 'Help Center',
|
|
39
|
+
type: 'url',
|
|
40
|
+
scrapingCountryCode: null,
|
|
41
|
+
createdAt: '2026-01-01T00:00:00Z',
|
|
42
|
+
createdBy: 'mock',
|
|
43
|
+
lastUpdatedAt: '2026-01-01T00:00:00Z',
|
|
44
|
+
lastUpdatedBy: 'mock',
|
|
45
|
+
activeExtractionJob: null as any,
|
|
46
|
+
lastExtractionJob: null as any,
|
|
47
|
+
},
|
|
48
|
+
chunks: [
|
|
49
|
+
{
|
|
50
|
+
id: 'chunk-mock-001',
|
|
51
|
+
text: 'To reset your password, go to Settings > Security > Reset Password.',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
export const DEBUG_SYSTEM_MESSAGES = {
|
|
58
|
+
keyword: {
|
|
59
|
+
action: EventAction.Keyword,
|
|
60
|
+
flow_id: 'flow-mock-001',
|
|
61
|
+
flow_node_id: 'node-mock-001',
|
|
62
|
+
nlu_keyword_is_regex: false,
|
|
63
|
+
nlu_keyword_name: 'hello',
|
|
64
|
+
} satisfies KeywordDebugEvent,
|
|
65
|
+
|
|
66
|
+
smartIntent: {
|
|
67
|
+
action: EventAction.IntentSmart,
|
|
68
|
+
nlu_intent_smart_title: 'Greeting smart intent',
|
|
69
|
+
} satisfies SmartIntentDebugEvent,
|
|
70
|
+
|
|
71
|
+
fallback: {
|
|
72
|
+
action: EventAction.Fallback,
|
|
73
|
+
user_input: "I don't understand this bot",
|
|
74
|
+
fallback_out: 1,
|
|
75
|
+
fallback_message_id: 'msg-mock-002',
|
|
76
|
+
} satisfies FallbackDebugEvent,
|
|
77
|
+
|
|
78
|
+
handoffSuccess: {
|
|
79
|
+
action: EventAction.HandoffSuccess,
|
|
80
|
+
handoff_queue_name: 'Support Team',
|
|
81
|
+
handoff_is_queue_open: true,
|
|
82
|
+
handoff_has_auto_assign: true,
|
|
83
|
+
handoff_note_id: '',
|
|
84
|
+
} satisfies HandoffSuccessDebugEvent,
|
|
85
|
+
|
|
86
|
+
botAction: {
|
|
87
|
+
action: EventAction.BotAction,
|
|
88
|
+
payload: 'custom-action-result',
|
|
89
|
+
} satisfies BotActionDebugEvent,
|
|
90
|
+
|
|
91
|
+
knowledgeBase: {
|
|
92
|
+
action: EventAction.Knowledgebase,
|
|
93
|
+
flow_id: 'flow-mock-001',
|
|
94
|
+
flow_node_id: 'node-mock-004',
|
|
95
|
+
knowledgebase_inference_id: 'inf-mock-001',
|
|
96
|
+
knowledgebase_fail_reason: '',
|
|
97
|
+
knowledgebase_sources_ids: ['src-mock-001'],
|
|
98
|
+
knowledgebase_chunks_ids: ['chunk-mock-001'],
|
|
99
|
+
user_input: 'How do I reset my password?',
|
|
100
|
+
knowledge_base_chunks_with_sources: mockChunksWithSources,
|
|
101
|
+
} satisfies KnowledgeBaseDebugEvent,
|
|
102
|
+
|
|
103
|
+
knowledgeBaseFailed: {
|
|
104
|
+
action: EventAction.Knowledgebase,
|
|
105
|
+
flow_id: 'flow-mock-001',
|
|
106
|
+
flow_node_id: 'node-mock-004',
|
|
107
|
+
knowledgebase_inference_id: 'inf-mock-002',
|
|
108
|
+
knowledgebase_fail_reason: 'no_relevant_content',
|
|
109
|
+
knowledgebase_sources_ids: [],
|
|
110
|
+
knowledgebase_chunks_ids: [],
|
|
111
|
+
user_input: 'What is the meaning of life?',
|
|
112
|
+
knowledge_base_chunks_with_sources: [],
|
|
113
|
+
} satisfies KnowledgeBaseDebugEvent,
|
|
114
|
+
|
|
115
|
+
conditionalChannel: {
|
|
116
|
+
action: EventAction.ConditionalChannel,
|
|
117
|
+
channel: 'whatsapp',
|
|
118
|
+
} satisfies ConditionalChannelDebugEvent,
|
|
119
|
+
|
|
120
|
+
conditionalCountry: {
|
|
121
|
+
action: EventAction.ConditionalCountry,
|
|
122
|
+
country: 'ES',
|
|
123
|
+
} satisfies ConditionalCountryDebugEvent,
|
|
124
|
+
|
|
125
|
+
conditionalCustom: {
|
|
126
|
+
action: EventAction.ConditionalCustom,
|
|
127
|
+
conditional_variable: 'user_plan',
|
|
128
|
+
variable_format: 'string',
|
|
129
|
+
} satisfies ConditionalCustomDebugEvent,
|
|
130
|
+
|
|
131
|
+
conditionalQueueStatus: {
|
|
132
|
+
action: EventAction.ConditionalQueueStatus,
|
|
133
|
+
queue_id: 'queue-mock-001',
|
|
134
|
+
queue_name: 'Support Team',
|
|
135
|
+
is_queue_open: true,
|
|
136
|
+
is_available_agent: true,
|
|
137
|
+
} satisfies ConditionalQueueStatusDebugEvent,
|
|
138
|
+
|
|
139
|
+
redirectFlow: {
|
|
140
|
+
action: EventAction.RedirectFlow,
|
|
141
|
+
flow_id: 'flow-mock-001',
|
|
142
|
+
flow_name: 'Main Flow',
|
|
143
|
+
flow_target_id: 'flow-mock-002',
|
|
144
|
+
flow_target_name: 'Billing Flow',
|
|
145
|
+
} satisfies RedirectFlowDebugEvent,
|
|
146
|
+
|
|
147
|
+
webviewActionTriggered: {
|
|
148
|
+
action: EventAction.WebviewActionTriggered,
|
|
149
|
+
webview_target_id: 'webview-mock-001',
|
|
150
|
+
webview_name: 'Payment Form',
|
|
151
|
+
} satisfies WebviewActionTriggeredDebugEvent,
|
|
152
|
+
|
|
153
|
+
aiAgent: {
|
|
154
|
+
action: EventAction.AiAgent,
|
|
155
|
+
flow_node_content_id: 'content-mock-001',
|
|
156
|
+
user_input: 'Can you help me with my subscription?',
|
|
157
|
+
tools_executed: [
|
|
158
|
+
{
|
|
159
|
+
tool_name: 'retrieve_knowledge',
|
|
160
|
+
tool_arguments: { query: 'subscription management' },
|
|
161
|
+
tool_results:
|
|
162
|
+
'Found 3 relevant articles about subscription management.',
|
|
163
|
+
knowledgebase_sources_ids: ['src-mock-001'],
|
|
164
|
+
knowledgebase_chunks_ids: ['chunk-mock-001'],
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
tool_name: 'get_user_subscription',
|
|
168
|
+
tool_arguments: { user_id: 'user-mock-001' },
|
|
169
|
+
tool_results: '{"plan": "pro", "renewal_date": "2026-06-01"}',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
input_guardrails_triggered: [],
|
|
173
|
+
output_guardrails_triggered: [],
|
|
174
|
+
exit: false,
|
|
175
|
+
error: false,
|
|
176
|
+
knowledge_base_chunks_with_sources: mockChunksWithSources,
|
|
177
|
+
} satisfies AiAgentDebugEvent,
|
|
178
|
+
|
|
179
|
+
aiAgentWithGuardrails: {
|
|
180
|
+
action: EventAction.AiAgent,
|
|
181
|
+
flow_node_content_id: 'content-mock-002',
|
|
182
|
+
user_input: 'Tell me something inappropriate',
|
|
183
|
+
tools_executed: [],
|
|
184
|
+
input_guardrails_triggered: ['content_safety', 'topic_restriction'],
|
|
185
|
+
output_guardrails_triggered: [],
|
|
186
|
+
exit: false,
|
|
187
|
+
error: false,
|
|
188
|
+
} satisfies AiAgentDebugEvent,
|
|
189
|
+
|
|
190
|
+
aiAgentError: {
|
|
191
|
+
action: EventAction.AiAgent,
|
|
192
|
+
flow_node_content_id: 'content-mock-003',
|
|
193
|
+
user_input: 'Hello',
|
|
194
|
+
tools_executed: [],
|
|
195
|
+
input_guardrails_triggered: [],
|
|
196
|
+
output_guardrails_triggered: [],
|
|
197
|
+
exit: false,
|
|
198
|
+
error: true,
|
|
199
|
+
} satisfies AiAgentDebugEvent,
|
|
200
|
+
|
|
201
|
+
aiAgentRouter: {
|
|
202
|
+
noTransfer: {
|
|
203
|
+
action: EventAction.AiAgentRouter,
|
|
204
|
+
flow_node_content_id: 'customer_support_router',
|
|
205
|
+
tools_executed: [],
|
|
206
|
+
memory_length: 2,
|
|
207
|
+
input_guardrails_triggered: [],
|
|
208
|
+
output_guardrails_triggered: [],
|
|
209
|
+
exit: false,
|
|
210
|
+
starting_agent_name: 'customer_support_router',
|
|
211
|
+
last_agent_name: 'customer_support_router',
|
|
212
|
+
available_specialists: [
|
|
213
|
+
{
|
|
214
|
+
name: 'billing_specialist',
|
|
215
|
+
description: 'Handles billing and invoice queries',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: 'technical_support_specialist',
|
|
219
|
+
description: 'Handles technical issues',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
is_transferred_to_specialist: false,
|
|
223
|
+
} satisfies AiAgentRouterDebugEvent,
|
|
224
|
+
|
|
225
|
+
inputGuardrail: {
|
|
226
|
+
action: EventAction.AiAgentRouter,
|
|
227
|
+
flow_node_content_id: 'customer_support_router',
|
|
228
|
+
tools_executed: [],
|
|
229
|
+
memory_length: 0,
|
|
230
|
+
input_guardrails_triggered: ['is_competence'],
|
|
231
|
+
output_guardrails_triggered: [],
|
|
232
|
+
exit: false,
|
|
233
|
+
starting_agent_name: 'customer_support_router',
|
|
234
|
+
last_agent_name: 'customer_support_router',
|
|
235
|
+
available_specialists: [
|
|
236
|
+
{
|
|
237
|
+
name: 'billing_specialist',
|
|
238
|
+
description: 'Handles billing and invoice queries',
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: 'technical_support_specialist',
|
|
242
|
+
description: 'Handles technical issues',
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
is_transferred_to_specialist: false,
|
|
246
|
+
} satisfies AiAgentRouterDebugEvent,
|
|
247
|
+
|
|
248
|
+
transfer: {
|
|
249
|
+
action: EventAction.AiAgentRouter,
|
|
250
|
+
flow_node_content_id: 'customer_support_router',
|
|
251
|
+
tools_executed: [],
|
|
252
|
+
memory_length: 3,
|
|
253
|
+
input_guardrails_triggered: [],
|
|
254
|
+
output_guardrails_triggered: [],
|
|
255
|
+
exit: true,
|
|
256
|
+
starting_agent_name: 'customer_support_router',
|
|
257
|
+
last_agent_name: 'billing_specialist',
|
|
258
|
+
available_specialists: [
|
|
259
|
+
{
|
|
260
|
+
name: 'billing_specialist',
|
|
261
|
+
description: 'Handles billing and invoice queries',
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'technical_support_specialist',
|
|
265
|
+
description: 'Handles technical issues',
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: 'sales_specialist',
|
|
269
|
+
description: 'Handles sales and pricing queries',
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
is_transferred_to_specialist: true,
|
|
273
|
+
knowledge_base_chunks_with_sources: [],
|
|
274
|
+
} satisfies AiAgentRouterDebugEvent,
|
|
275
|
+
},
|
|
276
|
+
}
|
package/src/dev-app.jsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { INPUT } from '@botonic/core'
|
|
1
2
|
import { createRoot } from 'react-dom/client'
|
|
2
3
|
|
|
4
|
+
import { DEBUG_SYSTEM_MESSAGES } from './debug-system-messages'
|
|
3
5
|
import { SENDERS } from './index-types'
|
|
4
6
|
import { ReactBot } from './react-bot'
|
|
5
7
|
import { onDOMLoaded } from './util/dom'
|
|
@@ -104,6 +106,28 @@ export class DevApp extends WebchatApp {
|
|
|
104
106
|
})
|
|
105
107
|
}
|
|
106
108
|
|
|
109
|
+
/** Pre-built mock payloads for every debug event type. Handy from the console:
|
|
110
|
+
* Botonic.addDebugSystemMessage(Botonic.debugSystemMessages.aiAgent) */
|
|
111
|
+
get debugSystemMessages() {
|
|
112
|
+
return DEBUG_SYSTEM_MESSAGES
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Inject a mock SystemDebugTrace event into the preview webchat.
|
|
117
|
+
* Accepts any DebugEvent payload (plain object with an `action` field).
|
|
118
|
+
*
|
|
119
|
+
* From code:
|
|
120
|
+
* import { DEBUG_SYSTEM_MESSAGES } from '@botonic/react/src/debug-system-messages'
|
|
121
|
+
* app.addDebugSystemMessage(DEBUG_SYSTEM_MESSAGES.aiAgent)
|
|
122
|
+
*
|
|
123
|
+
* From the browser console:
|
|
124
|
+
* Botonic.addDebugSystemMessage(Botonic.debugSystemMessages.conditionalQueueStatus)
|
|
125
|
+
* Botonic.addDebugSystemMessage({ action: 'nlu_keyword', nlu_keyword_name: 'hi', nlu_keyword_is_regex: false, flow_id: 'f1', flow_node_id: 'n1' })
|
|
126
|
+
*/
|
|
127
|
+
addDebugSystemMessage(eventData) {
|
|
128
|
+
this.addSystemMessage({ type: INPUT.SYSTEM_DEBUG_TRACE, data: eventData })
|
|
129
|
+
}
|
|
130
|
+
|
|
107
131
|
async onUserInput({ input, session, lastRoutePath }) {
|
|
108
132
|
this.onMessage?.(this, {
|
|
109
133
|
sentBy: SENDERS.user,
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { BotonicInputTester, BotonicOutputTester } from './botonic-tester'
|
|
2
2
|
export * from './components'
|
|
3
3
|
export * from './contexts'
|
|
4
|
+
export { DEBUG_SYSTEM_MESSAGES } from './debug-system-messages'
|
|
4
5
|
export { DevApp } from './dev-app'
|
|
5
6
|
export * from './index-types'
|
|
6
7
|
export { msgsToBotonic, msgToBotonic } from './msg-to-botonic'
|