@bikdotai/bik-component-library 0.0.839-beta.6 → 0.0.839
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/dist/cjs/components/BikGiftedChat/GiftedChat/GiftedChat.js +1 -1
- package/dist/cjs/components/BikGiftedChat/GiftedChat/GiftedChat.js.map +1 -1
- package/dist/cjs/components/agent-builder/AgentBuilder.js +1 -1
- package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js +20 -44
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/AgentBuilderFooter.js +1 -1
- package/dist/cjs/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/AgentBuilderTopBar.js +1 -1
- package/dist/cjs/components/agent-builder/components/AgentBuilderTopBar.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +2 -2
- package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/DiscardModal.js +1 -1
- package/dist/cjs/components/agent-builder/components/DiscardModal.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/GoLiveModal.js +1 -1
- package/dist/cjs/components/agent-builder/components/GoLiveModal.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionEditor.js +1 -1
- package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionPicker.js +13 -13
- package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +4 -4
- package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js +6 -6
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/StepSectionHeader.js +1 -1
- package/dist/cjs/components/agent-builder/components/StepSectionHeader.js.map +1 -1
- package/dist/cjs/components/agent-builder/constants/tools.js +1 -1
- package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -1
- package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
- package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js +1 -3
- package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +3 -5
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/cjs/components/agent-listing/AgentListing.js +1 -1
- package/dist/cjs/components/agent-listing/AgentListing.js.map +1 -1
- package/dist/cjs/components/agent-listing/AgentTable.js +1 -1
- package/dist/cjs/components/agent-listing/AgentTable.js.map +1 -1
- package/dist/cjs/components/agent-listing/AgentTableRow.js +1 -1
- package/dist/cjs/components/agent-listing/AgentTableRow.js.map +1 -1
- package/dist/cjs/components/agent-listing/DeleteAgentModal.js +1 -1
- package/dist/cjs/components/agent-listing/DeleteAgentModal.js.map +1 -1
- package/dist/cjs/components/button/Button.styled.js +0 -1
- package/dist/cjs/components/button/Button.styled.js.map +1 -1
- package/dist/cjs/components/button/themes.js +11 -11
- package/dist/cjs/components/button/themes.js.map +1 -1
- package/dist/cjs/components/dropdown/Dropdown.js +1 -1
- package/dist/cjs/components/dropdown/Dropdown.js.map +1 -1
- package/dist/cjs/components/dropdown-button/DropdownButton.js +1 -1
- package/dist/cjs/components/dropdown-button/DropdownButton.js.map +1 -1
- package/dist/cjs/editor/BikEditor.js +1 -1
- package/dist/cjs/editor/BikEditor.js.map +1 -1
- package/dist/cjs/editor/BikEditor.styles.js +54 -97
- package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
- package/dist/cjs/editor/extensions/jsonHighlight/JsonHighlightExtension.js +3 -3
- package/dist/cjs/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -1
- package/dist/cjs/icons/Media/Visual/FormkitNeutral.js +2 -0
- package/dist/cjs/icons/Media/Visual/FormkitNeutral.js.map +1 -0
- package/dist/cjs/icons/Media/Visual/FormkitSad.js +2 -0
- package/dist/cjs/icons/Media/Visual/FormkitSad.js.map +1 -0
- package/dist/cjs/icons/index.js +1 -1
- package/dist/esm/components/BikGiftedChat/GiftedChat/GiftedChat.js +66 -61
- package/dist/esm/components/BikGiftedChat/GiftedChat/GiftedChat.js.map +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.js +102 -106
- package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +0 -3
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js +82 -110
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js +21 -29
- package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
- package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js +26 -27
- package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js.map +1 -1
- package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +25 -25
- package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +23 -24
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/DiscardModal.d.ts +1 -3
- package/dist/esm/components/agent-builder/components/DiscardModal.js +16 -25
- package/dist/esm/components/agent-builder/components/DiscardModal.js.map +1 -1
- package/dist/esm/components/agent-builder/components/GoLiveModal.js +34 -36
- package/dist/esm/components/agent-builder/components/GoLiveModal.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionEditor.js +19 -19
- package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.js +60 -64
- package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.d.ts +0 -2
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +105 -111
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +4 -13
- package/dist/esm/components/agent-builder/components/SelectableListSection.js +148 -173
- package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/esm/components/agent-builder/components/StepSectionHeader.js +7 -7
- package/dist/esm/components/agent-builder/components/StepSectionHeader.js.map +1 -1
- package/dist/esm/components/agent-builder/constants/tools.js +1 -1
- package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +103 -104
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js +98 -102
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +142 -144
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js +79 -23
- package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js +23 -35
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentListing.js +65 -70
- package/dist/esm/components/agent-listing/AgentListing.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentTable.d.ts +0 -2
- package/dist/esm/components/agent-listing/AgentTable.js +15 -16
- package/dist/esm/components/agent-listing/AgentTable.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentTableRow.js +11 -11
- package/dist/esm/components/agent-listing/AgentTableRow.js.map +1 -1
- package/dist/esm/components/agent-listing/DeleteAgentModal.js +8 -8
- package/dist/esm/components/agent-listing/DeleteAgentModal.js.map +1 -1
- package/dist/esm/components/button/Button.styled.js +19 -25
- package/dist/esm/components/button/Button.styled.js.map +1 -1
- package/dist/esm/components/button/themes.d.ts +1 -0
- package/dist/esm/components/button/themes.js +61 -51
- package/dist/esm/components/button/themes.js.map +1 -1
- package/dist/esm/components/dropdown/Dropdown.js +13 -18
- package/dist/esm/components/dropdown/Dropdown.js.map +1 -1
- package/dist/esm/components/dropdown-button/DropdownButton.js +13 -13
- package/dist/esm/components/dropdown-button/DropdownButton.js.map +1 -1
- package/dist/esm/editor/BikEditor.js +160 -173
- package/dist/esm/editor/BikEditor.js.map +1 -1
- package/dist/esm/editor/BikEditor.styles.d.ts +3 -20
- package/dist/esm/editor/BikEditor.styles.js +57 -102
- package/dist/esm/editor/BikEditor.styles.js.map +1 -1
- package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.d.ts +8 -5
- package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js +68 -87
- package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -1
- package/dist/esm/icons/Media/Visual/FormkitNeutral.js +58 -0
- package/dist/esm/icons/Media/Visual/FormkitNeutral.js.map +1 -0
- package/dist/esm/icons/Media/Visual/FormkitSad.js +61 -0
- package/dist/esm/icons/Media/Visual/FormkitSad.js.map +1 -0
- package/dist/esm/icons/Media/Visual/index.d.ts +2 -0
- package/dist/esm/icons/index.d.ts +25 -25
- package/dist/esm/icons/index.js +420 -416
- package/dist/esm/icons/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/components/agent-listing/AgentTableShimmer.js +0 -2
- package/dist/cjs/components/agent-listing/AgentTableShimmer.js.map +0 -1
- package/dist/esm/components/agent-builder/__fixtures__/agentValue.d.ts +0 -11
- package/dist/esm/components/agent-listing/AgentTableShimmer.d.ts +0 -12
- package/dist/esm/components/agent-listing/AgentTableShimmer.js +0 -20
- package/dist/esm/components/agent-listing/AgentTableShimmer.js.map +0 -1
- package/dist/esm/components/agent-listing/__fixtures__/agents.d.ts +0 -3
|
@@ -1,28 +1,84 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { RadioButton as d } from "../../radioButton/RadioButton.js";
|
|
3
|
+
import { TitleSmall as a, BodyCaption as l } from "../../TypographyStyle.js";
|
|
4
|
+
import { COLORS as o } from "../../../constants/Theme.js";
|
|
5
|
+
import { SectionBodyWrap as u, FieldBlock as v, CardRow as g, RadioCard as h, RadioCardText as s } from "../AgentBuilder.styled.js";
|
|
6
|
+
import { AiTextArea as C } from "../components/AiTextArea.js";
|
|
7
|
+
import { StepSectionHeader as S } from "../components/StepSectionHeader.js";
|
|
8
|
+
import { STEP_DEFINITIONS as y } from "../constants/steps.js";
|
|
9
|
+
import { useAgentBuilderContext as x } from "../context/AgentBuilderContext.js";
|
|
10
|
+
const m = y[3], _ = () => {
|
|
11
|
+
const { value: p, patch: c, charLimits: f } = x(), { handover: n } = p, r = (i) => c({ handover: { ...n, method: i } });
|
|
12
|
+
return /* @__PURE__ */ t("div", { className: "bik-agent-step bik-agent-step--handover", children: [
|
|
13
|
+
/* @__PURE__ */ e(S, { title: m.title, helper: m.helper }),
|
|
14
|
+
/* @__PURE__ */ t(u, { children: [
|
|
15
|
+
/* @__PURE__ */ e(
|
|
16
|
+
C,
|
|
17
|
+
{
|
|
18
|
+
"data-test": "handover-when",
|
|
19
|
+
label: "Handover when",
|
|
20
|
+
value: n.when,
|
|
21
|
+
onChange: (i) => c({ handover: { ...n, when: i } }),
|
|
22
|
+
maxLength: f.handoverWhen,
|
|
23
|
+
placeholder: "e.g. Hand over if the customer is angry or requests a human agent.",
|
|
24
|
+
minHeight: "120px"
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
/* @__PURE__ */ t(v, { children: [
|
|
28
|
+
/* @__PURE__ */ e(a, { color: o.content.primary, children: "Handover method" }),
|
|
29
|
+
/* @__PURE__ */ t(g, { children: [
|
|
30
|
+
/* @__PURE__ */ t(
|
|
31
|
+
h,
|
|
32
|
+
{
|
|
33
|
+
"data-test": "handover-method-default",
|
|
34
|
+
selected: n.method === "default",
|
|
35
|
+
onClick: () => r("default"),
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ e(
|
|
38
|
+
d,
|
|
39
|
+
{
|
|
40
|
+
isActive: n.method === "default",
|
|
41
|
+
onValueChange: () => r("default"),
|
|
42
|
+
skipSelectingOff: !0,
|
|
43
|
+
activeColor: o.content.brand
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ t(s, { children: [
|
|
47
|
+
/* @__PURE__ */ e(a, { color: o.content.primary, children: "Use default settings" }),
|
|
48
|
+
/* @__PURE__ */ e(l, { color: o.content.secondary, children: "Defined in Customize > Agent handover" })
|
|
49
|
+
] })
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ t(
|
|
54
|
+
h,
|
|
55
|
+
{
|
|
56
|
+
"data-test": "handover-method-specific",
|
|
57
|
+
selected: n.method === "specific_channels",
|
|
58
|
+
onClick: () => r("specific_channels"),
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ e(
|
|
61
|
+
d,
|
|
62
|
+
{
|
|
63
|
+
isActive: n.method === "specific_channels",
|
|
64
|
+
onValueChange: () => r("specific_channels"),
|
|
65
|
+
skipSelectingOff: !0,
|
|
66
|
+
activeColor: o.content.brand
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ t(s, { children: [
|
|
70
|
+
/* @__PURE__ */ e(a, { color: o.content.primary, children: "Choose specific channels" }),
|
|
71
|
+
/* @__PURE__ */ e(l, { color: o.content.secondary, children: "Always hands over regardless of business hours." })
|
|
72
|
+
] })
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] })
|
|
77
|
+
] })
|
|
78
|
+
] })
|
|
23
79
|
] });
|
|
24
80
|
};
|
|
25
81
|
export {
|
|
26
|
-
|
|
82
|
+
_ as Step4HandoverRules
|
|
27
83
|
};
|
|
28
84
|
//# sourceMappingURL=Step4HandoverRules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Step4HandoverRules.js","sources":["../../../../../src/components/agent-builder/steps/Step4HandoverRules.tsx"],"sourcesContent":["import React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"Step4HandoverRules.js","sources":["../../../../../src/components/agent-builder/steps/Step4HandoverRules.tsx"],"sourcesContent":["import React from 'react';\nimport { RadioButton } from '@src/components/radioButton/RadioButton';\nimport { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { HandoverMethod } from '../AgentBuilder.model';\nimport {\n\tCardRow,\n\tFieldBlock,\n\tRadioCard,\n\tRadioCardText,\n\tSectionBodyWrap,\n} from '../AgentBuilder.styled';\nimport { AiTextArea } from '../components/AiTextArea';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\n\nconst STEP = STEP_DEFINITIONS[3];\n\nexport const Step4HandoverRules: React.FC = () => {\n\tconst { value, patch, charLimits } = useAgentBuilderContext();\n\tconst { handover } = value;\n\n\tconst setMethod = (method: HandoverMethod) =>\n\t\tpatch({ handover: { ...handover, method } });\n\n\treturn (\n\t\t<div className=\"bik-agent-step bik-agent-step--handover\">\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<SectionBodyWrap>\n\t\t\t\t<AiTextArea\n\t\t\t\t\tdata-test=\"handover-when\"\n\t\t\t\t\tlabel=\"Handover when\"\n\t\t\t\t\tvalue={handover.when}\n\t\t\t\t\tonChange={(text) => patch({ handover: { ...handover, when: text } })}\n\t\t\t\t\tmaxLength={charLimits.handoverWhen}\n\t\t\t\t\tplaceholder=\"e.g. Hand over if the customer is angry or requests a human agent.\"\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t/>\n\n\t\t\t\t<FieldBlock>\n\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\tHandover method\n\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t<CardRow>\n\t\t\t\t\t\t<RadioCard\n\t\t\t\t\t\t\tdata-test=\"handover-method-default\"\n\t\t\t\t\t\t\tselected={handover.method === 'default'}\n\t\t\t\t\t\t\tonClick={() => setMethod('default')}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<RadioButton\n\t\t\t\t\t\t\t\tisActive={handover.method === 'default'}\n\t\t\t\t\t\t\t\tonValueChange={() => setMethod('default')}\n\t\t\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\t\t\tactiveColor={COLORS.content.brand}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\tUse default settings\n\t\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\t\tDefined in Customize > Agent handover\n\t\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t</RadioCardText>\n\t\t\t\t\t\t</RadioCard>\n\n\t\t\t\t\t\t<RadioCard\n\t\t\t\t\t\t\tdata-test=\"handover-method-specific\"\n\t\t\t\t\t\t\tselected={handover.method === 'specific_channels'}\n\t\t\t\t\t\t\tonClick={() => setMethod('specific_channels')}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<RadioButton\n\t\t\t\t\t\t\t\tisActive={handover.method === 'specific_channels'}\n\t\t\t\t\t\t\t\tonValueChange={() => setMethod('specific_channels')}\n\t\t\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\t\t\tactiveColor={COLORS.content.brand}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\tChoose specific channels\n\t\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\t\tAlways hands over regardless of business hours.\n\t\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t</RadioCardText>\n\t\t\t\t\t\t</RadioCard>\n\t\t\t\t\t</CardRow>\n\t\t\t\t</FieldBlock>\n\t\t\t</SectionBodyWrap>\n\t\t</div>\n\t);\n};\n"],"names":["STEP","STEP_DEFINITIONS","Step4HandoverRules","value","patch","charLimits","useAgentBuilderContext","handover","setMethod","method","jsxs","jsx","StepSectionHeader","SectionBodyWrap","AiTextArea","text","FieldBlock","TitleSmall","COLORS","CardRow","RadioCard","RadioButton","RadioCardText","BodyCaption"],"mappings":";;;;;;;;;AAiBA,MAAMA,IAAOC,EAAiB,CAAC,GAElBC,IAA+B,MAAM;AACjD,QAAM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AA,EAAY,OAAOL,EAAO,QAAQ,WAAW,UAAA,wCAAA,CAE9C;AAAA,gBAAA,EAAA,CACD;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAGD,gBAAAR;AAAA,YAACU;AAAA,YAAA;AAAA,cACA,aAAU;AAAA,cACV,UAAUb,EAAS,WAAW;AAAA,cAC9B,SAAS,MAAMC,EAAU,mBAAmB;AAAA,cAE5C,UAAA;AAAA,gBAAA,gBAAAG;AAAA,kBAACU;AAAA,kBAAA;AAAA,oBACA,UAAUd,EAAS,WAAW;AAAA,oBAC9B,eAAe,MAAMC,EAAU,mBAAmB;AAAA,oBAClD,kBAAgB;AAAA,oBAChB,aAAaU,EAAO,QAAQ;AAAA,kBAAA;AAAA,gBAAA;AAAA,kCAE5BI,GAAA,EACA,UAAA;AAAA,kBAAA,gBAAAX,EAACM,GAAA,EAAW,OAAOC,EAAO,QAAQ,SAAS,UAAA,4BAE3C;AAAA,oCACCK,GAAA,EAAY,OAAOL,EAAO,QAAQ,WAAW,UAAA,kDAAA,CAE9C;AAAA,gBAAA,EAAA,CACD;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACD,EAAA,CACD;AAAA,MAAA,EAAA,CACD;AAAA,IAAA,EAAA,CACD;AAAA,EAAA,GACD;AAEF;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TOOL_SOURCE_LABELS as
|
|
2
|
-
const g = (e, t = "Manifest") => e ?
|
|
1
|
+
import { TOOL_SOURCE_LABELS as m, ToolSource as l } from "../constants/tools.js";
|
|
2
|
+
const g = (e, t = "Manifest") => e ? m[e] ?? e : t, L = (e) => {
|
|
3
3
|
const t = e ? String(e) : "";
|
|
4
4
|
return t === "BIK" ? "BIK" : t === "BSP" ? "BSP" : "Manifest";
|
|
5
|
-
},
|
|
5
|
+
}, E = (e, t, n = "Manifest") => [
|
|
6
6
|
...e.map(
|
|
7
7
|
(o) => ({
|
|
8
8
|
id: o.tool_id,
|
|
@@ -21,24 +21,24 @@ const g = (e, t = "Manifest") => e ? u[e] ?? e : t, E = (e) => {
|
|
|
21
21
|
meta: { kind: "subagent", plainLabel: o.name }
|
|
22
22
|
})
|
|
23
23
|
)
|
|
24
|
-
], b = (e) => e.tool_key === "send_slack_message" ? String(e.params.channelId?.value ?? "").trim() || "Send Slack message" : String(e.params.sendTo?.value ?? "").split(",").map((t) => t.trim()).filter(Boolean)[0] || "
|
|
24
|
+
], b = (e) => e.tool_key === "send_slack_message" ? String(e.params.channelId?.value ?? "").trim() || "Send Slack message" : String(e.params.sendTo?.value ?? "").split(",").map((t) => t.trim()).filter(Boolean)[0] || "Handover to email", k = (e) => e.name || "Rest API", S = (e) => {
|
|
25
25
|
const t = k(e);
|
|
26
26
|
return {
|
|
27
27
|
id: e.id,
|
|
28
|
-
label: `${
|
|
29
|
-
meta: { kind: "tool", plainLabel: t, source:
|
|
28
|
+
label: `${m[l.RestApi]} : ${t}`,
|
|
29
|
+
meta: { kind: "tool", plainLabel: t, source: l.RestApi }
|
|
30
30
|
};
|
|
31
|
-
},
|
|
32
|
-
const t = e.tool_key === "send_slack_message" ?
|
|
31
|
+
}, f = (e) => {
|
|
32
|
+
const t = e.tool_key === "send_slack_message" ? l.Slack : l.EmailHandover, n = b(e);
|
|
33
33
|
return {
|
|
34
34
|
id: e.id,
|
|
35
|
-
label: `${
|
|
35
|
+
label: `${m[t]} : ${n}`,
|
|
36
36
|
meta: { kind: "tool", plainLabel: n, source: t }
|
|
37
37
|
};
|
|
38
38
|
}, y = (e = [], t = []) => [
|
|
39
39
|
...t.map(S),
|
|
40
|
-
...e.map(
|
|
41
|
-
], i = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"),
|
|
40
|
+
...e.map(f)
|
|
41
|
+
], i = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), r = (e) => i(e).replace(/"/g, """), u = (e, t, n) => `<span data-type="mentionAgent" class="bik-mention bik-mention--agent" data-id="${r(e)}" data-label="${r(t)}" data-kind="${r(n)}">${i(t)}</span>`, A = (e, t, n) => u(e, t, n), $ = (e) => {
|
|
42
42
|
const t = /* @__PURE__ */ new Map();
|
|
43
43
|
for (const n of e) {
|
|
44
44
|
const o = n.meta;
|
|
@@ -54,7 +54,7 @@ const g = (e, t = "Manifest") => e ? u[e] ?? e : t, E = (e) => {
|
|
|
54
54
|
const s = t.get(a[1]);
|
|
55
55
|
if (s) {
|
|
56
56
|
const p = s.meta.kind;
|
|
57
|
-
n +=
|
|
57
|
+
n += u(String(s.id), s.label, p);
|
|
58
58
|
} else
|
|
59
59
|
n += i(a[0]);
|
|
60
60
|
o = c.lastIndex;
|
|
@@ -63,9 +63,9 @@ const g = (e, t = "Manifest") => e ? u[e] ?? e : t, E = (e) => {
|
|
|
63
63
|
}, M = (e, t = []) => {
|
|
64
64
|
if (!e)
|
|
65
65
|
return "";
|
|
66
|
-
const n =
|
|
66
|
+
const n = $(t);
|
|
67
67
|
return e.split(/\n{2,}/).map((o) => `<p>${T(o, n)}</p>`).join("");
|
|
68
|
-
},
|
|
68
|
+
}, _ = (e, t, n) => (t ?? (n.has(e) ? "tool" : "subagent")) === "tool" ? `{{tool:${e}}}` : `{{subagent:${e}}}`, d = (e, t) => {
|
|
69
69
|
switch (e.type) {
|
|
70
70
|
case "text":
|
|
71
71
|
return e.text ?? "";
|
|
@@ -75,7 +75,7 @@ const g = (e, t = "Manifest") => e ? u[e] ?? e : t, E = (e) => {
|
|
|
75
75
|
if (n == null)
|
|
76
76
|
return "";
|
|
77
77
|
const o = e.attrs?.kind;
|
|
78
|
-
return
|
|
78
|
+
return _(
|
|
79
79
|
String(n),
|
|
80
80
|
o == null ? null : String(o),
|
|
81
81
|
t
|
|
@@ -86,42 +86,30 @@ const g = (e, t = "Manifest") => e ? u[e] ?? e : t, E = (e) => {
|
|
|
86
86
|
case "hardBreak":
|
|
87
87
|
return `
|
|
88
88
|
`;
|
|
89
|
-
case "orderedList":
|
|
90
|
-
case "bulletList": {
|
|
91
|
-
const n = e.type === "orderedList";
|
|
92
|
-
return (e.content ?? []).map(
|
|
93
|
-
(o, a) => `${n ? `${a + 1}.` : "-"} ${m(
|
|
94
|
-
o,
|
|
95
|
-
t
|
|
96
|
-
).replace(/\n+$/, "")}`
|
|
97
|
-
).join(`
|
|
98
|
-
`) + `
|
|
99
|
-
`;
|
|
100
|
-
}
|
|
101
89
|
default: {
|
|
102
|
-
const n = (e.content ?? []).map((a) =>
|
|
90
|
+
const n = (e.content ?? []).map((a) => d(a, t)).join("");
|
|
103
91
|
return ["paragraph", "heading", "listItem", "blockquote"].includes(e.type) ? `${n}
|
|
104
92
|
` : n;
|
|
105
93
|
}
|
|
106
94
|
}
|
|
107
|
-
},
|
|
95
|
+
}, v = (e, t) => {
|
|
108
96
|
if (!e)
|
|
109
97
|
return "";
|
|
110
98
|
const n = new Set(t.map((o) => o.tool_id));
|
|
111
|
-
return
|
|
99
|
+
return d(e, n).replace(
|
|
112
100
|
/\n+$/,
|
|
113
101
|
""
|
|
114
102
|
);
|
|
115
103
|
};
|
|
116
104
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
m as TOOL_SOURCE_LABELS,
|
|
106
|
+
L as appTypeLabel,
|
|
107
|
+
E as buildAgentMentionItems,
|
|
120
108
|
y as buildCustomToolMentionItems,
|
|
121
109
|
A as buildMentionHtml,
|
|
122
|
-
|
|
110
|
+
f as configToolMentionItem,
|
|
123
111
|
b as configToolName,
|
|
124
|
-
|
|
112
|
+
v as editorDocToInstructions,
|
|
125
113
|
M as instructionsToEditorHtml,
|
|
126
114
|
S as restApiMentionItem,
|
|
127
115
|
k as restApiToolName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mentionSerialization.js","sources":["../../../../../src/components/agent-builder/utils/mentionSerialization.ts"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport { MentionItem } from '@src/editor';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tRestApiToolConfig,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { TOOL_SOURCE_LABELS, ToolSource } from '../constants/tools';\n\n/**\n * Serialization helpers between the BikEditor document and the firebase\n * `instructions` string.\n *\n * Firebase stores `instructions` as PLAIN TEXT with inline reference tokens:\n * - `{{subagent:<agentId>}}` — hand-off to another agent\n * - `{{tool:<tool_id>}}` — an action the agent can call\n * - `{{<variableName>}}` — a template variable\n *\n * In the editor those references are inserted via the `@` mention menu (which we\n * populate with BOTH tools and sub-agents). Mention nodes keep their `id` in the\n * ProseMirror doc JSON (the rendered HTML drops it), so we serialize from the doc\n * JSON — not from HTML.\n */\n\nexport interface MentionKindMeta {\n\t/** Distinguishes a tool reference from a sub-agent reference. */\n\tkind: 'tool' | 'subagent';\n\t/** Plain item name (no prefix) shown in the picker dropdown rows. */\n\tplainLabel?: string;\n\t/** For tools: the source bucket (manifest / shopify / …) the picker groups by. */\n\tsource?: string;\n}\n\n// Source labels moved to constants/tools.ts; re-exported for existing importers.\nexport { TOOL_SOURCE_LABELS };\n\n/** Human label for a tool source; falls back to the host-app label, then the raw key. */\nexport const toolSourceLabel = (\n\tsource: string | undefined,\n\tfallback = 'Manifest',\n): string => {\n\tif (!source) {\n\t\treturn fallback;\n\t}\n\treturn TOOL_SOURCE_LABELS[source as ToolSource] ?? source;\n};\n\n/** Human label for the host application, used as the tool-chip prefix. */\nexport const appTypeLabel = (applicationType?: ApplicationType): string => {\n\tconst key = applicationType ? String(applicationType) : '';\n\tif (key === 'BIK') {\n\t\treturn 'BIK';\n\t}\n\tif (key === 'BSP') {\n\t\treturn 'BSP';\n\t}\n\treturn 'Manifest';\n};\n\n/**\n * Build the combined `@` mention list from the available tools + sub-agents.\n *\n * The `label` is the CHIP text shown once inserted — tools read\n * `\"<App> : <tool name>\"` (e.g. \"Manifest : Look up order\"), sub-agents read\n * `\"sub-agent: <name>\"`. `meta.plainLabel` is the un-prefixed name for the\n * picker rows, and `meta.kind` drives the `{{tool}}` / `{{subagent}}` colour.\n */\nexport const buildAgentMentionItems = (\n\ttools: AgentTool[],\n\tsubAgents: SubAgentRef[],\n\tappLabel = 'Manifest',\n): MentionItem[] => [\n\t...tools.map(\n\t\t(t): MentionItem => ({\n\t\t\tid: t.tool_id,\n\t\t\tlabel: `${toolSourceLabel(t.source, appLabel)} : ${t.display_name}`,\n\t\t\tmeta: {\n\t\t\t\tkind: 'tool',\n\t\t\t\tplainLabel: t.display_name,\n\t\t\t\tsource: t.source,\n\t\t\t},\n\t\t}),\n\t),\n\t...subAgents.map(\n\t\t(s): MentionItem => ({\n\t\t\tid: s.id,\n\t\t\tlabel: `sub-agent: ${s.name}`,\n\t\t\tmeta: { kind: 'subagent', plainLabel: s.name },\n\t\t}),\n\t),\n];\n\n/** Display name for a shared config tool: first recipient / channel, else generic. */\nexport const configToolName = (t: ConfigToolConfig): string => {\n\tif (t.tool_key === 'send_slack_message') {\n\t\treturn (\n\t\t\tString(t.params['channelId']?.value ?? '').trim() || 'Send Slack message'\n\t\t);\n\t}\n\treturn (\n\t\tString(t.params['sendTo']?.value ?? '')\n\t\t\t.split(',')\n\t\t\t.map((s) => s.trim())\n\t\t\t.filter(Boolean)[0] || 'Send Email'\n\t);\n};\n\n/** Display name for a Rest API tool row / chip. */\nexport const restApiToolName = (t: RestApiToolConfig): string =>\n\tt.name || 'Rest API';\n\n/** The `@`-mention chip item for a Rest API tool (kind 'tool', restapi source). */\nexport const restApiMentionItem = (t: RestApiToolConfig): MentionItem => {\n\tconst name = restApiToolName(t);\n\treturn {\n\t\tid: t.id,\n\t\tlabel: `${TOOL_SOURCE_LABELS[ToolSource.RestApi]} : ${name}`,\n\t\tmeta: { kind: 'tool', plainLabel: name, source: ToolSource.RestApi },\n\t};\n};\n\n/** The `@`-mention chip item for a shared config tool (email / Slack). */\nexport const configToolMentionItem = (t: ConfigToolConfig): MentionItem => {\n\tconst source =\n\t\tt.tool_key === 'send_slack_message'\n\t\t\t? ToolSource.Slack\n\t\t\t: ToolSource.EmailHandover;\n\tconst name = configToolName(t);\n\treturn {\n\t\tid: t.id,\n\t\tlabel: `${TOOL_SOURCE_LABELS[source]} : ${name}`,\n\t\tmeta: { kind: 'tool', plainLabel: name, source },\n\t};\n};\n\n/**\n * Mention items for the inline-configured custom tools (Rest API + email / Slack)\n * so their `{{tool:<id>}}` tokens rehydrate as chips — they live on the agent\n * value, not in the catalog `availableTools`. Merge alongside\n * {@link buildAgentMentionItems} in the editor's mention list.\n */\nexport const buildCustomToolMentionItems = (\n\tconfigTools: ConfigToolConfig[] = [],\n\trestApiTools: RestApiToolConfig[] = [],\n): MentionItem[] => [\n\t...restApiTools.map(restApiMentionItem),\n\t...configTools.map(configToolMentionItem),\n];\n\nconst escapeHtml = (raw: string): string =>\n\traw.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n\nconst escapeAttr = (raw: string): string =>\n\tescapeHtml(raw).replace(/\"/g, '"');\n\n/**\n * The HTML for a single mention chip. Must round-trip through the TipTap mention\n * extension's `parseHTML` (`span[data-type=\"mentionAgent\"]`, reading\n * `data-id`/`data-label`/`data-kind`) — see MentionExtension.ts. `normalizeHtml`\n * is taught to keep `data-type=\"mention…\"` spans so this survives to the parser.\n */\nconst mentionSpanHtml = (id: string, label: string, kind: string): string =>\n\t`<span data-type=\"mentionAgent\" class=\"bik-mention bik-mention--agent\"` +\n\t` data-id=\"${escapeAttr(id)}\" data-label=\"${escapeAttr(label)}\"` +\n\t` data-kind=\"${escapeAttr(kind)}\">${escapeHtml(label)}</span>`;\n\n/**\n * Public: HTML for one mention chip, for inserting at the cursor (e.g. when a\n * tool / sub-agent is added from the Step-3 side panel). Round-trips through the\n * same parser path as the rehydrated chips.\n */\nexport const buildMentionHtml = (\n\tid: string,\n\tlabel: string,\n\tkind: 'tool' | 'subagent',\n): string => mentionSpanHtml(id, label, kind);\n\n/** `{{tool:<id>}}` / `{{subagent:<id>}}` → the mention item that produced them. */\nconst buildTokenLookup = (\n\tmentionItems: MentionItem[],\n): Map<string, MentionItem> => {\n\tconst byToken = new Map<string, MentionItem>();\n\tfor (const item of mentionItems) {\n\t\tconst meta = item.meta as unknown as MentionKindMeta | undefined;\n\t\t// Both tools and sub-agents are keyed by their id (a tool's id is its tool_id).\n\t\tif (meta?.kind === 'tool') {\n\t\t\tbyToken.set(`tool:${String(item.id)}`, item);\n\t\t} else if (meta?.kind === 'subagent') {\n\t\t\tbyToken.set(`subagent:${String(item.id)}`, item);\n\t\t}\n\t}\n\treturn byToken;\n};\n\n// Matches the reference tokens we render as chips. Other `{{var}}` tokens fall\n// through untouched (left as literal text for the variable decoration).\nconst REFERENCE_TOKEN = /\\{\\{(tool:[^}]+|subagent:[^}]+)\\}\\}/g;\n\n/** Escape plain text, swapping recognised reference tokens for mention spans. */\nconst inlineToHtml = (\n\tsegment: string,\n\tbyToken: Map<string, MentionItem>,\n): string => {\n\tlet out = '';\n\tlet lastIndex = 0;\n\tREFERENCE_TOKEN.lastIndex = 0;\n\tlet match: RegExpExecArray | null;\n\twhile ((match = REFERENCE_TOKEN.exec(segment)) !== null) {\n\t\tout += escapeHtml(segment.slice(lastIndex, match.index));\n\t\tconst item = byToken.get(match[1]);\n\t\tif (item) {\n\t\t\tconst kind = (item.meta as unknown as MentionKindMeta).kind;\n\t\t\tout += mentionSpanHtml(String(item.id), item.label, kind);\n\t\t} else {\n\t\t\t// Tool/sub-agent no longer in the available list → keep the raw token.\n\t\t\tout += escapeHtml(match[0]);\n\t\t}\n\t\tlastIndex = REFERENCE_TOKEN.lastIndex;\n\t}\n\tout += escapeHtml(segment.slice(lastIndex));\n\treturn out.replace(/\\n/g, '<br>');\n};\n\n/**\n * Convert the stored instructions string into HTML for `BikEditor.initialContent`.\n * `{{tool:KEY}}` / `{{subagent:ID}}` tokens are rehydrated into mention chips\n * (resolved via `mentionItems`); any other `{{…}}` token is left as literal text\n * for the editor's variable decoration. Newlines become paragraph / line breaks.\n */\nexport const instructionsToEditorHtml = (\n\ttext: string,\n\tmentionItems: MentionItem[] = [],\n): string => {\n\tif (!text) {\n\t\treturn '';\n\t}\n\tconst byToken = buildTokenLookup(mentionItems);\n\treturn text\n\t\t.split(/\\n{2,}/)\n\t\t.map((para) => `<p>${inlineToHtml(para, byToken)}</p>`)\n\t\t.join('');\n};\n\ninterface ProseMirrorNode {\n\ttype: string;\n\ttext?: string;\n\tattrs?: Record<string, unknown>;\n\tcontent?: ProseMirrorNode[];\n}\n\n/**\n * The token for a mention node. Both tools and sub-agents store their id in the\n * node, so the token value is just that id — the kind only picks the prefix. The\n * node's `kind` attr is authoritative; `toolIds` is a fallback for older content\n * saved before the kind attr existed.\n */\nconst resolveMentionToken = (\n\tid: string,\n\tkind: string | null,\n\ttoolIds: Set<string>,\n): string => {\n\tconst resolved = kind ?? (toolIds.has(id) ? 'tool' : 'subagent');\n\treturn resolved === 'tool' ? `{{tool:${id}}}` : `{{subagent:${id}}}`;\n};\n\nconst nodeToText = (node: ProseMirrorNode, toolIds: Set<string>): string => {\n\tswitch (node.type) {\n\t\tcase 'text':\n\t\t\treturn node.text ?? '';\n\t\tcase 'mentionAgent':\n\t\tcase 'mentionTeam': {\n\t\t\tconst id = node.attrs?.['id'];\n\t\t\tif (id == null) {\n\t\t\t\treturn '';\n\t\t\t}\n\t\t\tconst kind = node.attrs?.['kind'];\n\t\t\treturn resolveMentionToken(\n\t\t\t\tString(id),\n\t\t\t\tkind == null ? null : String(kind),\n\t\t\t\ttoolIds,\n\t\t\t);\n\t\t}\n\t\tcase 'variable':\n\t\t\treturn `{{${String(node.attrs?.['variableName'] ?? '')}}}`;\n\t\tcase 'hardBreak':\n\t\t\treturn '\\n';\n\t\tcase 'orderedList':\n\t\tcase 'bulletList': {\n\t\t\t// Flattening to plain text otherwise drops the list markers, so a\n\t\t\t// numbered / bulleted list looks \"removed\" after publish. Emit an\n\t\t\t// ordinal (\"1. \") / bullet (\"- \") prefix per item to preserve it.\n\t\t\tconst ordered = node.type === 'orderedList';\n\t\t\treturn (\n\t\t\t\t(node.content ?? [])\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(item, i) =>\n\t\t\t\t\t\t\t`${ordered ? `${i + 1}.` : '-'} ${nodeToText(\n\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\ttoolIds,\n\t\t\t\t\t\t\t).replace(/\\n+$/, '')}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join('\\n') + '\\n'\n\t\t\t);\n\t\t}\n\t\tdefault: {\n\t\t\tconst inner = (node.content ?? [])\n\t\t\t\t.map((child) => nodeToText(child, toolIds))\n\t\t\t\t.join('');\n\t\t\t// Block nodes terminate with a newline so paragraphs stay separated.\n\t\t\tconst BLOCK_NODES = ['paragraph', 'heading', 'listItem', 'blockquote'];\n\t\t\treturn BLOCK_NODES.includes(node.type) ? `${inner}\\n` : inner;\n\t\t}\n\t}\n};\n\n/**\n * Convert a BikEditor document (from `ref.getJSON()`) into the firebase\n * instructions string, replacing mention nodes with `{{subagent:<id>}}` /\n * `{{tool:<tool_id>}}` tokens.\n */\nexport const editorDocToInstructions = (\n\tdoc: Record<string, unknown> | null,\n\ttools: AgentTool[],\n): string => {\n\tif (!doc) {\n\t\treturn '';\n\t}\n\tconst toolIds = new Set(tools.map((t) => t.tool_id));\n\treturn nodeToText(doc as unknown as ProseMirrorNode, toolIds).replace(\n\t\t/\\n+$/,\n\t\t'',\n\t);\n};\n"],"names":["toolSourceLabel","source","fallback","TOOL_SOURCE_LABELS","appTypeLabel","applicationType","key","buildAgentMentionItems","tools","subAgents","appLabel","t","s","configToolName","restApiToolName","restApiMentionItem","name","ToolSource","configToolMentionItem","buildCustomToolMentionItems","configTools","restApiTools","escapeHtml","raw","escapeAttr","mentionSpanHtml","id","label","kind","buildMentionHtml","buildTokenLookup","mentionItems","byToken","item","meta","REFERENCE_TOKEN","inlineToHtml","segment","out","lastIndex","match","instructionsToEditorHtml","text","para","resolveMentionToken","toolIds","nodeToText","node","ordered","i","inner","child","editorDocToInstructions","doc"],"mappings":";AAsC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O,OAAO,OAAOA,CAAI;AAAA,QACjCiB;AAAA,MAAA;AAAA,IAEF;AAAA,IACA,KAAK;AACJ,aAAO,KAAK,OAAOE,EAAK,OAAQ,gBAAmB,EAAE,CAAC;AAAA,IACvD,KAAK;AACJ,aAAO;AAAA;AAAA,IACR,KAAK;AAAA,IACL,KAAK,cAAc;AAIlB,YAAMC,IAAUD,EAAK,SAAS;AAC9B,cACEA,EAAK,WAAW,CAAA,GACf;AAAA,QACA,CAACd,GAAMgB,MACN,GAAGD,IAAU,GAAGC,IAAI,CAAC,MAAM,GAAG,IAAIH;AAAA,UACjCb;AAAA,UACAY;AAAA,QAAA,EACC,QAAQ,QAAQ,EAAE,CAAC;AAAA,MAAA,EAEtB,KAAK;AAAA,CAAI,IAAI;AAAA;AAAA,IAEjB;AAAA,IACA,SAAS;AACR,YAAMK,KAASH,EAAK,WAAW,CAAA,GAC7B,IAAI,CAACI,MAAUL,EAAWK,GAAON,CAAO,CAAC,EACzC,KAAK,EAAE;AAGT,aADoB,CAAC,aAAa,WAAW,YAAY,YAAY,EAClD,SAASE,EAAK,IAAI,IAAI,GAAGG,CAAK;AAAA,IAAOA;AAAA,IACzD;AAAA,EAAA;AAEF,GAOaE,IAA0B,CACtCC,GACA7C,MACY;AACZ,MAAI,CAAC6C;AACJ,WAAO;AAER,QAAMR,IAAU,IAAI,IAAIrC,EAAM,IAAI,CAACG,MAAMA,EAAE,OAAO,CAAC;AACnD,SAAOmC,EAAWO,GAAmCR,CAAO,EAAE;AAAA,IAC7D;AAAA,IACA;AAAA,EAAA;AAEF;"}
|
|
1
|
+
{"version":3,"file":"mentionSerialization.js","sources":["../../../../../src/components/agent-builder/utils/mentionSerialization.ts"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport { MentionItem } from '@src/editor';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tRestApiToolConfig,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { TOOL_SOURCE_LABELS, ToolSource } from '../constants/tools';\n\n/**\n * Serialization helpers between the BikEditor document and the firebase\n * `instructions` string.\n *\n * Firebase stores `instructions` as PLAIN TEXT with inline reference tokens:\n * - `{{subagent:<agentId>}}` — hand-off to another agent\n * - `{{tool:<tool_id>}}` — an action the agent can call\n * - `{{<variableName>}}` — a template variable\n *\n * In the editor those references are inserted via the `@` mention menu (which we\n * populate with BOTH tools and sub-agents). Mention nodes keep their `id` in the\n * ProseMirror doc JSON (the rendered HTML drops it), so we serialize from the doc\n * JSON — not from HTML.\n */\n\nexport interface MentionKindMeta {\n\t/** Distinguishes a tool reference from a sub-agent reference. */\n\tkind: 'tool' | 'subagent';\n\t/** Plain item name (no prefix) shown in the picker dropdown rows. */\n\tplainLabel?: string;\n\t/** For tools: the source bucket (manifest / shopify / …) the picker groups by. */\n\tsource?: string;\n}\n\n// Source labels moved to constants/tools.ts; re-exported for existing importers.\nexport { TOOL_SOURCE_LABELS };\n\n/** Human label for a tool source; falls back to the host-app label, then the raw key. */\nexport const toolSourceLabel = (\n\tsource: string | undefined,\n\tfallback = 'Manifest',\n): string => {\n\tif (!source) {\n\t\treturn fallback;\n\t}\n\treturn TOOL_SOURCE_LABELS[source as ToolSource] ?? source;\n};\n\n/** Human label for the host application, used as the tool-chip prefix. */\nexport const appTypeLabel = (applicationType?: ApplicationType): string => {\n\tconst key = applicationType ? String(applicationType) : '';\n\tif (key === 'BIK') {\n\t\treturn 'BIK';\n\t}\n\tif (key === 'BSP') {\n\t\treturn 'BSP';\n\t}\n\treturn 'Manifest';\n};\n\n/**\n * Build the combined `@` mention list from the available tools + sub-agents.\n *\n * The `label` is the CHIP text shown once inserted — tools read\n * `\"<App> : <tool name>\"` (e.g. \"Manifest : Look up order\"), sub-agents read\n * `\"sub-agent: <name>\"`. `meta.plainLabel` is the un-prefixed name for the\n * picker rows, and `meta.kind` drives the `{{tool}}` / `{{subagent}}` colour.\n */\nexport const buildAgentMentionItems = (\n\ttools: AgentTool[],\n\tsubAgents: SubAgentRef[],\n\tappLabel = 'Manifest',\n): MentionItem[] => [\n\t...tools.map(\n\t\t(t): MentionItem => ({\n\t\t\tid: t.tool_id,\n\t\t\tlabel: `${toolSourceLabel(t.source, appLabel)} : ${t.display_name}`,\n\t\t\tmeta: {\n\t\t\t\tkind: 'tool',\n\t\t\t\tplainLabel: t.display_name,\n\t\t\t\tsource: t.source,\n\t\t\t},\n\t\t}),\n\t),\n\t...subAgents.map(\n\t\t(s): MentionItem => ({\n\t\t\tid: s.id,\n\t\t\tlabel: `sub-agent: ${s.name}`,\n\t\t\tmeta: { kind: 'subagent', plainLabel: s.name },\n\t\t}),\n\t),\n];\n\n/** Display name for a shared config tool: first recipient / channel, else generic. */\nexport const configToolName = (t: ConfigToolConfig): string => {\n\tif (t.tool_key === 'send_slack_message') {\n\t\treturn (\n\t\t\tString(t.params['channelId']?.value ?? '').trim() || 'Send Slack message'\n\t\t);\n\t}\n\treturn (\n\t\tString(t.params['sendTo']?.value ?? '')\n\t\t\t.split(',')\n\t\t\t.map((s) => s.trim())\n\t\t\t.filter(Boolean)[0] || 'Handover to email'\n\t);\n};\n\n/** Display name for a Rest API tool row / chip. */\nexport const restApiToolName = (t: RestApiToolConfig): string =>\n\tt.name || 'Rest API';\n\n/** The `@`-mention chip item for a Rest API tool (kind 'tool', restapi source). */\nexport const restApiMentionItem = (t: RestApiToolConfig): MentionItem => {\n\tconst name = restApiToolName(t);\n\treturn {\n\t\tid: t.id,\n\t\tlabel: `${TOOL_SOURCE_LABELS[ToolSource.RestApi]} : ${name}`,\n\t\tmeta: { kind: 'tool', plainLabel: name, source: ToolSource.RestApi },\n\t};\n};\n\n/** The `@`-mention chip item for a shared config tool (email / Slack). */\nexport const configToolMentionItem = (t: ConfigToolConfig): MentionItem => {\n\tconst source =\n\t\tt.tool_key === 'send_slack_message'\n\t\t\t? ToolSource.Slack\n\t\t\t: ToolSource.EmailHandover;\n\tconst name = configToolName(t);\n\treturn {\n\t\tid: t.id,\n\t\tlabel: `${TOOL_SOURCE_LABELS[source]} : ${name}`,\n\t\tmeta: { kind: 'tool', plainLabel: name, source },\n\t};\n};\n\n/**\n * Mention items for the inline-configured custom tools (Rest API + email / Slack)\n * so their `{{tool:<id>}}` tokens rehydrate as chips — they live on the agent\n * value, not in the catalog `availableTools`. Merge alongside\n * {@link buildAgentMentionItems} in the editor's mention list.\n */\nexport const buildCustomToolMentionItems = (\n\tconfigTools: ConfigToolConfig[] = [],\n\trestApiTools: RestApiToolConfig[] = [],\n): MentionItem[] => [\n\t...restApiTools.map(restApiMentionItem),\n\t...configTools.map(configToolMentionItem),\n];\n\nconst escapeHtml = (raw: string): string =>\n\traw.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n\nconst escapeAttr = (raw: string): string =>\n\tescapeHtml(raw).replace(/\"/g, '"');\n\n/**\n * The HTML for a single mention chip. Must round-trip through the TipTap mention\n * extension's `parseHTML` (`span[data-type=\"mentionAgent\"]`, reading\n * `data-id`/`data-label`/`data-kind`) — see MentionExtension.ts. `normalizeHtml`\n * is taught to keep `data-type=\"mention…\"` spans so this survives to the parser.\n */\nconst mentionSpanHtml = (id: string, label: string, kind: string): string =>\n\t`<span data-type=\"mentionAgent\" class=\"bik-mention bik-mention--agent\"` +\n\t` data-id=\"${escapeAttr(id)}\" data-label=\"${escapeAttr(label)}\"` +\n\t` data-kind=\"${escapeAttr(kind)}\">${escapeHtml(label)}</span>`;\n\n/**\n * Public: HTML for one mention chip, for inserting at the cursor (e.g. when a\n * tool / sub-agent is added from the Step-3 side panel). Round-trips through the\n * same parser path as the rehydrated chips.\n */\nexport const buildMentionHtml = (\n\tid: string,\n\tlabel: string,\n\tkind: 'tool' | 'subagent',\n): string => mentionSpanHtml(id, label, kind);\n\n/** `{{tool:<id>}}` / `{{subagent:<id>}}` → the mention item that produced them. */\nconst buildTokenLookup = (\n\tmentionItems: MentionItem[],\n): Map<string, MentionItem> => {\n\tconst byToken = new Map<string, MentionItem>();\n\tfor (const item of mentionItems) {\n\t\tconst meta = item.meta as unknown as MentionKindMeta | undefined;\n\t\t// Both tools and sub-agents are keyed by their id (a tool's id is its tool_id).\n\t\tif (meta?.kind === 'tool') {\n\t\t\tbyToken.set(`tool:${String(item.id)}`, item);\n\t\t} else if (meta?.kind === 'subagent') {\n\t\t\tbyToken.set(`subagent:${String(item.id)}`, item);\n\t\t}\n\t}\n\treturn byToken;\n};\n\n// Matches the reference tokens we render as chips. Other `{{var}}` tokens fall\n// through untouched (left as literal text for the variable decoration).\nconst REFERENCE_TOKEN = /\\{\\{(tool:[^}]+|subagent:[^}]+)\\}\\}/g;\n\n/** Escape plain text, swapping recognised reference tokens for mention spans. */\nconst inlineToHtml = (\n\tsegment: string,\n\tbyToken: Map<string, MentionItem>,\n): string => {\n\tlet out = '';\n\tlet lastIndex = 0;\n\tREFERENCE_TOKEN.lastIndex = 0;\n\tlet match: RegExpExecArray | null;\n\twhile ((match = REFERENCE_TOKEN.exec(segment)) !== null) {\n\t\tout += escapeHtml(segment.slice(lastIndex, match.index));\n\t\tconst item = byToken.get(match[1]);\n\t\tif (item) {\n\t\t\tconst kind = (item.meta as unknown as MentionKindMeta).kind;\n\t\t\tout += mentionSpanHtml(String(item.id), item.label, kind);\n\t\t} else {\n\t\t\t// Tool/sub-agent no longer in the available list → keep the raw token.\n\t\t\tout += escapeHtml(match[0]);\n\t\t}\n\t\tlastIndex = REFERENCE_TOKEN.lastIndex;\n\t}\n\tout += escapeHtml(segment.slice(lastIndex));\n\treturn out.replace(/\\n/g, '<br>');\n};\n\n/**\n * Convert the stored instructions string into HTML for `BikEditor.initialContent`.\n * `{{tool:KEY}}` / `{{subagent:ID}}` tokens are rehydrated into mention chips\n * (resolved via `mentionItems`); any other `{{…}}` token is left as literal text\n * for the editor's variable decoration. Newlines become paragraph / line breaks.\n */\nexport const instructionsToEditorHtml = (\n\ttext: string,\n\tmentionItems: MentionItem[] = [],\n): string => {\n\tif (!text) {\n\t\treturn '';\n\t}\n\tconst byToken = buildTokenLookup(mentionItems);\n\treturn text\n\t\t.split(/\\n{2,}/)\n\t\t.map((para) => `<p>${inlineToHtml(para, byToken)}</p>`)\n\t\t.join('');\n};\n\ninterface ProseMirrorNode {\n\ttype: string;\n\ttext?: string;\n\tattrs?: Record<string, unknown>;\n\tcontent?: ProseMirrorNode[];\n}\n\n/**\n * The token for a mention node. Both tools and sub-agents store their id in the\n * node, so the token value is just that id — the kind only picks the prefix. The\n * node's `kind` attr is authoritative; `toolIds` is a fallback for older content\n * saved before the kind attr existed.\n */\nconst resolveMentionToken = (\n\tid: string,\n\tkind: string | null,\n\ttoolIds: Set<string>,\n): string => {\n\tconst resolved = kind ?? (toolIds.has(id) ? 'tool' : 'subagent');\n\treturn resolved === 'tool' ? `{{tool:${id}}}` : `{{subagent:${id}}}`;\n};\n\nconst nodeToText = (node: ProseMirrorNode, toolIds: Set<string>): string => {\n\tswitch (node.type) {\n\t\tcase 'text':\n\t\t\treturn node.text ?? '';\n\t\tcase 'mentionAgent':\n\t\tcase 'mentionTeam': {\n\t\t\tconst id = node.attrs?.['id'];\n\t\t\tif (id == null) {\n\t\t\t\treturn '';\n\t\t\t}\n\t\t\tconst kind = node.attrs?.['kind'];\n\t\t\treturn resolveMentionToken(\n\t\t\t\tString(id),\n\t\t\t\tkind == null ? null : String(kind),\n\t\t\t\ttoolIds,\n\t\t\t);\n\t\t}\n\t\tcase 'variable':\n\t\t\treturn `{{${String(node.attrs?.['variableName'] ?? '')}}}`;\n\t\tcase 'hardBreak':\n\t\t\treturn '\\n';\n\t\tdefault: {\n\t\t\tconst inner = (node.content ?? [])\n\t\t\t\t.map((child) => nodeToText(child, toolIds))\n\t\t\t\t.join('');\n\t\t\t// Block nodes terminate with a newline so paragraphs stay separated.\n\t\t\tconst BLOCK_NODES = ['paragraph', 'heading', 'listItem', 'blockquote'];\n\t\t\treturn BLOCK_NODES.includes(node.type) ? `${inner}\\n` : inner;\n\t\t}\n\t}\n};\n\n/**\n * Convert a BikEditor document (from `ref.getJSON()`) into the firebase\n * instructions string, replacing mention nodes with `{{subagent:<id>}}` /\n * `{{tool:<tool_id>}}` tokens.\n */\nexport const editorDocToInstructions = (\n\tdoc: Record<string, unknown> | null,\n\ttools: AgentTool[],\n): string => {\n\tif (!doc) {\n\t\treturn '';\n\t}\n\tconst toolIds = new Set(tools.map((t) => t.tool_id));\n\treturn nodeToText(doc as unknown as ProseMirrorNode, toolIds).replace(\n\t\t/\\n+$/,\n\t\t'',\n\t);\n};\n"],"names":["toolSourceLabel","source","fallback","TOOL_SOURCE_LABELS","appTypeLabel","applicationType","key","buildAgentMentionItems","tools","subAgents","appLabel","t","s","configToolName","restApiToolName","restApiMentionItem","name","ToolSource","configToolMentionItem","buildCustomToolMentionItems","configTools","restApiTools","escapeHtml","raw","escapeAttr","mentionSpanHtml","id","label","kind","buildMentionHtml","buildTokenLookup","mentionItems","byToken","item","meta","REFERENCE_TOKEN","inlineToHtml","segment","out","lastIndex","match","instructionsToEditorHtml","text","para","resolveMentionToken","toolIds","nodeToText","node","inner","child","editorDocToInstructions","doc"],"mappings":";AAsCO,MAAMA,IAAkB,CAC9BC,GACAC,IAAW,eAEND,IAGEE,EAAmBF,CAAoB,KAAKA,IAF3CC,GAMIE,IAAe,CAACC,MAA8C;AAC1E,QAAMC,IAAMD,IAAkB,OAAOA,CAAe,IAAI;AACxD,SAAIC,MAAQ,QACJ,QAEJA,MAAQ,QACJ,QAED;AACR,GAUaC,IAAyB,CACrCC,GACAC,GACAC,IAAW,eACQ;AAAA,EACnB,GAAGF,EAAM;AAAA,IACR,CAACG,OAAoB;AAAA,MACpB,IAAIA,EAAE;AAAA,MACN,OAAO,GAAGX,EAAgBW,EAAE,QAAQD,CAAQ,CAAC,MAAMC,EAAE,YAAY;AAAA,MACjE,MAAM;AAAA,QACL,MAAM;AAAA,QACN,YAAYA,EAAE;AAAA,QACd,QAAQA,EAAE;AAAA,MAAA;AAAA,IACX;AAAA,EACD;AAAA,EAED,GAAGF,EAAU;AAAA,IACZ,CAACG,OAAo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SAAOmC,EAAWK,GAAmCN,CAAO,EAAE;AAAA,IAC7D;AAAA,IACA;AAAA,EAAA;AAEF;"}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
import { jsxs as z, jsx as i, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as D, useCallback as n } from "react";
|
|
3
3
|
import { TablePagination as U } from "../TablePagination/TablePagination.js";
|
|
4
4
|
import { ZeroState as W } from "../zeroState/ZeroState.js";
|
|
5
5
|
import { Page as X, Body as Y, EmptyHolder as _ } from "./AgentListing.styled.js";
|
|
6
6
|
import { AgentListingFilters as ee } from "./AgentListingFilters.js";
|
|
7
7
|
import { AgentListingHeader as te } from "./AgentListingHeader.js";
|
|
8
8
|
import { AgentTable as ne } from "./AgentTable.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
onSearchSubmit: l,
|
|
9
|
+
import { DeleteAgentModal as oe } from "./DeleteAgentModal.js";
|
|
10
|
+
import { unwrapDropdownValue as ie } from "../dropdown/utils.js";
|
|
11
|
+
const ae = ({
|
|
12
|
+
config: L,
|
|
13
|
+
onSearchChange: f,
|
|
14
|
+
onSearchSubmit: r,
|
|
16
15
|
onFilterChange: g,
|
|
17
16
|
onSortChange: d,
|
|
18
|
-
onNewAgent:
|
|
19
|
-
onBrowseTemplates:
|
|
20
|
-
onRunAgent:
|
|
21
|
-
onEditAgent:
|
|
22
|
-
onDeleteAgent:
|
|
23
|
-
onRowClick:
|
|
24
|
-
...
|
|
17
|
+
onNewAgent: A,
|
|
18
|
+
onBrowseTemplates: c,
|
|
19
|
+
onRunAgent: S,
|
|
20
|
+
onEditAgent: b,
|
|
21
|
+
onDeleteAgent: s,
|
|
22
|
+
onRowClick: m,
|
|
23
|
+
...R
|
|
25
24
|
}) => {
|
|
26
|
-
const [a, h] =
|
|
25
|
+
const [a, h] = D(
|
|
27
26
|
null
|
|
28
|
-
), [
|
|
29
|
-
agents:
|
|
30
|
-
isLoading:
|
|
31
|
-
searchValue:
|
|
27
|
+
), [C, N] = D(!1), {
|
|
28
|
+
agents: w,
|
|
29
|
+
isLoading: p,
|
|
30
|
+
searchValue: T,
|
|
32
31
|
searchPlaceholder: v = "Search",
|
|
33
32
|
filterOptions: x,
|
|
34
33
|
filterPlaceholder: B = "Filters",
|
|
@@ -37,103 +36,99 @@ const re = ({
|
|
|
37
36
|
title: I = "AI Agents",
|
|
38
37
|
headerActions: O,
|
|
39
38
|
pagination: o,
|
|
40
|
-
emptyState:
|
|
39
|
+
emptyState: u,
|
|
41
40
|
debugLog: y
|
|
42
|
-
} =
|
|
43
|
-
(e, ...
|
|
44
|
-
y && console.log(`[AgentListing] ${e}`, ...
|
|
41
|
+
} = L, k = !p && w.length === 0, t = n(
|
|
42
|
+
(e, ...l) => {
|
|
43
|
+
y && console.log(`[AgentListing] ${e}`, ...l);
|
|
45
44
|
},
|
|
46
45
|
[y]
|
|
47
46
|
), j = n(
|
|
48
47
|
(e) => {
|
|
49
|
-
t("onSearchChange", e),
|
|
48
|
+
t("onSearchChange", e), f(e);
|
|
50
49
|
},
|
|
51
|
-
[t,
|
|
50
|
+
[t, f]
|
|
52
51
|
), H = n(
|
|
53
52
|
(e) => {
|
|
54
|
-
t("onSearchSubmit", e),
|
|
53
|
+
t("onSearchSubmit", e), r?.(e);
|
|
55
54
|
},
|
|
56
|
-
[t,
|
|
57
|
-
),
|
|
55
|
+
[t, r]
|
|
56
|
+
), V = n(
|
|
58
57
|
(e) => {
|
|
59
58
|
t("onFilterChange", e), g?.(e);
|
|
60
59
|
},
|
|
61
60
|
[t, g]
|
|
62
|
-
),
|
|
61
|
+
), q = n(
|
|
63
62
|
(e) => {
|
|
64
63
|
t("onSortChange", e), d?.(e);
|
|
65
64
|
},
|
|
66
65
|
[t, d]
|
|
67
66
|
), P = n(() => {
|
|
68
|
-
t("onNewAgent"),
|
|
69
|
-
}, [t,
|
|
70
|
-
t("onBrowseTemplates"),
|
|
71
|
-
}, [t,
|
|
67
|
+
t("onNewAgent"), A();
|
|
68
|
+
}, [t, A]), M = n(() => {
|
|
69
|
+
t("onBrowseTemplates"), c?.();
|
|
70
|
+
}, [t, c]), Z = n(
|
|
72
71
|
(e) => {
|
|
73
|
-
t("onRunAgent", e.id),
|
|
72
|
+
t("onRunAgent", e.id), S(e);
|
|
74
73
|
},
|
|
75
|
-
[t,
|
|
74
|
+
[t, S]
|
|
76
75
|
), $ = n(
|
|
77
76
|
(e) => {
|
|
78
|
-
t("onEditAgent", e.id),
|
|
77
|
+
t("onEditAgent", e.id), b(e);
|
|
79
78
|
},
|
|
80
|
-
[t,
|
|
79
|
+
[t, b]
|
|
81
80
|
), G = n(
|
|
82
81
|
(e) => {
|
|
83
|
-
t("onRowClick", e.id),
|
|
82
|
+
t("onRowClick", e.id), m?.(e);
|
|
84
83
|
},
|
|
85
|
-
[t,
|
|
84
|
+
[t, m]
|
|
86
85
|
), J = n(
|
|
87
86
|
(e) => {
|
|
88
87
|
t("onDeleteAgent", e.id), h(e);
|
|
89
88
|
},
|
|
90
89
|
[t]
|
|
91
90
|
), K = n(async () => {
|
|
92
|
-
if (!(!a || !
|
|
93
|
-
|
|
91
|
+
if (!(!a || !s)) {
|
|
92
|
+
N(!0);
|
|
94
93
|
try {
|
|
95
|
-
await
|
|
94
|
+
await s(a), h(null);
|
|
96
95
|
} finally {
|
|
97
|
-
|
|
96
|
+
N(!1);
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
|
-
}, [a,
|
|
101
|
-
return /* @__PURE__ */ z(X, { "data-test":
|
|
99
|
+
}, [a, s]);
|
|
100
|
+
return /* @__PURE__ */ z(X, { "data-test": R["data-test"] ?? "agent-listing", children: [
|
|
102
101
|
/* @__PURE__ */ i(
|
|
103
102
|
te,
|
|
104
103
|
{
|
|
105
104
|
title: I,
|
|
106
105
|
onNewAgent: P,
|
|
107
|
-
onBrowseTemplates:
|
|
106
|
+
onBrowseTemplates: c ? M : void 0,
|
|
108
107
|
headerActions: O
|
|
109
108
|
}
|
|
110
109
|
),
|
|
111
110
|
/* @__PURE__ */ i(
|
|
112
111
|
ee,
|
|
113
112
|
{
|
|
114
|
-
searchValue:
|
|
113
|
+
searchValue: T,
|
|
115
114
|
onSearchChange: j,
|
|
116
|
-
onSearchSubmit:
|
|
115
|
+
onSearchSubmit: r ? H : void 0,
|
|
117
116
|
searchPlaceholder: v,
|
|
118
117
|
filterOptions: x,
|
|
119
|
-
onFilterChange: g ?
|
|
118
|
+
onFilterChange: g ? V : void 0,
|
|
120
119
|
filterPlaceholder: B,
|
|
121
120
|
sortOptions: E,
|
|
122
121
|
selectedSort: F,
|
|
123
|
-
onSortChange: d ?
|
|
122
|
+
onSortChange: d ? q : void 0
|
|
124
123
|
}
|
|
125
124
|
),
|
|
126
|
-
/* @__PURE__ */ i(Y, { children:
|
|
127
|
-
// Table-shaped shimmer: refetches (page/page-size/sort/search) load in
|
|
128
|
-
// place instead of collapsing to a spinner. Keep the page
|
|
129
|
-
// height by matching the current page size.
|
|
130
|
-
/* @__PURE__ */ i(oe, { rows: Math.min(o?.pageSize ?? 5, 10) })
|
|
131
|
-
) : k ? /* @__PURE__ */ i(_, { children: /* @__PURE__ */ i(
|
|
125
|
+
/* @__PURE__ */ i(Y, { children: p || k ? /* @__PURE__ */ i(_, { children: /* @__PURE__ */ i(
|
|
132
126
|
W,
|
|
133
127
|
{
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
isLoading: p,
|
|
129
|
+
title: u?.title ?? "No agents yet",
|
|
130
|
+
subTitle: u?.subTitle ?? "Create your first AI agent to start automating conversations.",
|
|
131
|
+
actionButton: u?.actionButton ?? {
|
|
137
132
|
buttonText: "New AI agent",
|
|
138
133
|
buttonType: "primary",
|
|
139
134
|
size: "small",
|
|
@@ -144,11 +139,11 @@ const re = ({
|
|
|
144
139
|
/* @__PURE__ */ i(
|
|
145
140
|
ne,
|
|
146
141
|
{
|
|
147
|
-
agents:
|
|
142
|
+
agents: w,
|
|
148
143
|
onRunAgent: Z,
|
|
149
144
|
onEditAgent: $,
|
|
150
|
-
onDeleteAgent:
|
|
151
|
-
onRowClick:
|
|
145
|
+
onDeleteAgent: s ? J : void 0,
|
|
146
|
+
onRowClick: m ? G : void 0
|
|
152
147
|
}
|
|
153
148
|
),
|
|
154
149
|
o && o.totalRows > 0 && /* @__PURE__ */ i(
|
|
@@ -160,25 +155,25 @@ const re = ({
|
|
|
160
155
|
hidePageSizeOptions: o.hidePageSizeOptions,
|
|
161
156
|
updatePageNumber: o.onPageChange,
|
|
162
157
|
updatePageSize: (e) => {
|
|
163
|
-
const
|
|
164
|
-
Number.isNaN(
|
|
158
|
+
const l = Number(ie(e));
|
|
159
|
+
Number.isNaN(l) || o.onPageSizeChange(l);
|
|
165
160
|
}
|
|
166
161
|
}
|
|
167
162
|
)
|
|
168
163
|
] }) }),
|
|
169
164
|
a && /* @__PURE__ */ i(
|
|
170
|
-
|
|
165
|
+
oe,
|
|
171
166
|
{
|
|
172
167
|
agentName: a.name,
|
|
173
|
-
isDeleting:
|
|
174
|
-
onClose: () =>
|
|
168
|
+
isDeleting: C,
|
|
169
|
+
onClose: () => C ? void 0 : h(null),
|
|
175
170
|
onConfirm: K
|
|
176
171
|
}
|
|
177
172
|
)
|
|
178
173
|
] });
|
|
179
174
|
};
|
|
180
|
-
|
|
175
|
+
ae.displayName = "AgentListing";
|
|
181
176
|
export {
|
|
182
|
-
|
|
177
|
+
ae as AgentListing
|
|
183
178
|
};
|
|
184
179
|
//# sourceMappingURL=AgentListing.js.map
|