@bikdotai/bik-component-library 0.0.841-beta.0 → 0.0.841
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/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 +51 -39
- 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 +22 -22
- 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 +3 -1
- 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 +5 -3
- 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/AgentTableShimmer.js +2 -0
- package/dist/cjs/components/agent-listing/AgentTableShimmer.js.map +1 -0
- 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/avatar/Avatar.js +1 -1
- package/dist/cjs/components/avatar/Avatar.js.map +1 -1
- package/dist/cjs/components/avatar/Avatar.styled.js +4 -12
- package/dist/cjs/components/avatar/Avatar.styled.js.map +1 -1
- package/dist/cjs/components/button/Button.styled.js +1 -0
- package/dist/cjs/components/button/Button.styled.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/editor/BikEditor.js +1 -1
- package/dist/cjs/editor/BikEditor.js.map +1 -1
- package/dist/cjs/editor/BikEditor.styles.js +97 -54
- 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/Informational/Common UI/Shield.js +2 -0
- package/dist/cjs/icons/Informational/Common UI/Shield.js.map +1 -0
- package/dist/cjs/icons/index.js +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.js +106 -102
- package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +3 -6
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js +118 -106
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/esm/components/agent-builder/__fixtures__/agentValue.d.ts +11 -0
- package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js +29 -21
- package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
- package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js +27 -26
- 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 +24 -23
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/DiscardModal.d.ts +3 -1
- package/dist/esm/components/agent-builder/components/DiscardModal.js +33 -24
- package/dist/esm/components/agent-builder/components/DiscardModal.js.map +1 -1
- package/dist/esm/components/agent-builder/components/GoLiveModal.js +23 -21
- 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 +174 -144
- package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.d.ts +2 -0
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +111 -105
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +13 -4
- package/dist/esm/components/agent-builder/components/SelectableListSection.js +161 -136
- 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 +6 -6
- package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +104 -103
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js +101 -102
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +146 -144
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js +23 -79
- package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js +35 -23
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentListing.js +65 -65
- package/dist/esm/components/agent-listing/AgentListing.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentTable.d.ts +2 -0
- package/dist/esm/components/agent-listing/AgentTable.js +16 -15
- 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/AgentTableShimmer.d.ts +12 -0
- package/dist/esm/components/agent-listing/AgentTableShimmer.js +20 -0
- package/dist/esm/components/agent-listing/AgentTableShimmer.js.map +1 -0
- 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/agent-listing/__fixtures__/agents.d.ts +3 -0
- package/dist/esm/components/avatar/Avatar.d.ts +1 -2
- package/dist/esm/components/avatar/Avatar.js +24 -34
- package/dist/esm/components/avatar/Avatar.js.map +1 -1
- package/dist/esm/components/avatar/Avatar.styled.d.ts +0 -1
- package/dist/esm/components/avatar/Avatar.styled.js +8 -17
- package/dist/esm/components/avatar/Avatar.styled.js.map +1 -1
- package/dist/esm/components/button/Button.styled.js +25 -19
- package/dist/esm/components/button/Button.styled.js.map +1 -1
- package/dist/esm/components/dropdown/Dropdown.js +18 -13
- package/dist/esm/components/dropdown/Dropdown.js.map +1 -1
- package/dist/esm/editor/BikEditor.js +173 -160
- package/dist/esm/editor/BikEditor.js.map +1 -1
- package/dist/esm/editor/BikEditor.styles.d.ts +20 -3
- package/dist/esm/editor/BikEditor.styles.js +102 -57
- package/dist/esm/editor/BikEditor.styles.js.map +1 -1
- package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.d.ts +5 -8
- package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js +87 -68
- package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -1
- package/dist/esm/icons/Informational/Common UI/Shield.d.ts +7 -0
- package/dist/esm/icons/Informational/Common UI/Shield.js +34 -0
- package/dist/esm/icons/Informational/Common UI/Shield.js.map +1 -0
- package/dist/esm/icons/Informational/Common UI/index.d.ts +1 -0
- package/dist/esm/icons/index.d.ts +1 -1
- package/dist/esm/icons/index.js +156 -154
- package/dist/esm/icons/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,84 +1,28 @@
|
|
|
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
|
-
|
|
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
|
-
] })
|
|
1
|
+
import { jsxs as h, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { SectionBodyWrap as s } from "../AgentBuilder.styled.js";
|
|
3
|
+
import { AiTextArea as d } from "../components/AiTextArea.js";
|
|
4
|
+
import { StepSectionHeader as m } from "../components/StepSectionHeader.js";
|
|
5
|
+
import { STEP_DEFINITIONS as p } from "../constants/steps.js";
|
|
6
|
+
import { useAgentBuilderContext as l } from "../context/AgentBuilderContext.js";
|
|
7
|
+
const t = p[3], S = () => {
|
|
8
|
+
const { value: o, patch: n, charLimits: a } = l(), { handover: r } = o;
|
|
9
|
+
return /* @__PURE__ */ h("div", { className: "bik-agent-step bik-agent-step--handover", children: [
|
|
10
|
+
/* @__PURE__ */ e(m, { title: t.title, helper: t.helper }),
|
|
11
|
+
/* @__PURE__ */ e(s, { children: /* @__PURE__ */ e(
|
|
12
|
+
d,
|
|
13
|
+
{
|
|
14
|
+
"data-test": "handover-when",
|
|
15
|
+
label: "Handover when",
|
|
16
|
+
value: r.when,
|
|
17
|
+
onChange: (i) => n({ handover: { ...r, when: i } }),
|
|
18
|
+
maxLength: a.handoverWhen,
|
|
19
|
+
placeholder: "e.g. Hand over if the customer is angry or asks for a human three times. Hand over if the order value exceeds ₹5,000.",
|
|
20
|
+
minHeight: "120px"
|
|
21
|
+
}
|
|
22
|
+
) })
|
|
79
23
|
] });
|
|
80
24
|
};
|
|
81
25
|
export {
|
|
82
|
-
|
|
26
|
+
S as Step4HandoverRules
|
|
83
27
|
};
|
|
84
28
|
//# 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 { SectionBodyWrap } 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\n// The \"Handover method\" radio section was removed: the method is UI-only and the\n// consumer always sends the seeded default ('default'); handover.method stays on\n// the value shape untouched.\nexport const Step4HandoverRules: React.FC = () => {\n\tconst { value, patch, charLimits } = useAgentBuilderContext();\n\tconst { handover } = value;\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 asks for a human three times. Hand over if the order value exceeds ₹5,000.\"\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t/>\n\t\t\t</SectionBodyWrap>\n\t\t</div>\n\t);\n};\n"],"names":["STEP","STEP_DEFINITIONS","Step4HandoverRules","value","patch","charLimits","useAgentBuilderContext","handover","jsxs","jsx","StepSectionHeader","SectionBodyWrap","AiTextArea","text"],"mappings":";;;;;;AAOA,MAAMA,IAAOC,EAAiB,CAAC,GAKlBC,IAA+B,MAAM;AACjD,QAAM,EAAE,OAAAC,GAAO,OAAAC,GAAO,YAAAC,EAAA,IAAeC,EAAA,GAC/B,EAAE,UAAAC,MAAaJ;AAErB,SACC,gBAAAK,EAAC,OAAA,EAAI,WAAU,2CACd,UAAA;AAAA,IAAA,gBAAAC,EAACC,KAAkB,OAAOV,EAAK,OAAO,QAAQA,EAAK,QAAQ;AAAA,sBAE1DW,GAAA,EACA,UAAA,gBAAAF;AAAA,MAACG;AAAA,MAAA;AAAA,QACA,aAAU;AAAA,QACV,OAAM;AAAA,QACN,OAAOL,EAAS;AAAA,QAChB,UAAU,CAACM,MAAST,EAAM,EAAE,UAAU,EAAE,GAAGG,GAAU,MAAMM,EAAA,GAAQ;AAAA,QACnE,WAAWR,EAAW;AAAA,QACtB,aAAY;AAAA,QACZ,WAAU;AAAA,MAAA;AAAA,IAAA,EACX,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 u, ToolSource as r } from "../constants/tools.js";
|
|
2
|
+
const g = (e, t = "Manifest") => e ? u[e] ?? e : t, E = (e) => {
|
|
3
3
|
const t = e ? String(e) : "";
|
|
4
4
|
return t === "BIK" ? "BIK" : t === "BSP" ? "BSP" : "Manifest";
|
|
5
|
-
},
|
|
5
|
+
}, I = (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 ? m[e] ?? e : t, L = (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] || "Send 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: `${u[r.RestApi]} : ${t}`,
|
|
29
|
+
meta: { kind: "tool", plainLabel: t, source: r.RestApi }
|
|
30
30
|
};
|
|
31
|
-
},
|
|
32
|
-
const t = e.tool_key === "send_slack_message" ?
|
|
31
|
+
}, $ = (e) => {
|
|
32
|
+
const t = e.tool_key === "send_slack_message" ? r.Slack : r.EmailHandover, n = b(e);
|
|
33
33
|
return {
|
|
34
34
|
id: e.id,
|
|
35
|
-
label: `${
|
|
35
|
+
label: `${u[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($)
|
|
41
|
+
], i = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), l = (e) => i(e).replace(/"/g, """), d = (e, t, n) => `<span data-type="mentionAgent" class="bik-mention bik-mention--agent" data-id="${l(e)}" data-label="${l(t)}" data-kind="${l(n)}">${i(t)}</span>`, A = (e, t, n) => d(e, t, n), f = (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 ? m[e] ?? e : t, L = (e) => {
|
|
|
54
54
|
const s = t.get(a[1]);
|
|
55
55
|
if (s) {
|
|
56
56
|
const p = s.meta.kind;
|
|
57
|
-
n +=
|
|
57
|
+
n += d(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 ? m[e] ?? e : t, L = (e) => {
|
|
|
63
63
|
}, M = (e, t = []) => {
|
|
64
64
|
if (!e)
|
|
65
65
|
return "";
|
|
66
|
-
const n =
|
|
66
|
+
const n = f(t);
|
|
67
67
|
return e.split(/\n{2,}/).map((o) => `<p>${T(o, n)}</p>`).join("");
|
|
68
|
-
},
|
|
68
|
+
}, L = (e, t, n) => (t ?? (n.has(e) ? "tool" : "subagent")) === "tool" ? `{{tool:${e}}}` : `{{subagent:${e}}}`, m = (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 ? m[e] ?? e : t, L = (e) => {
|
|
|
75
75
|
if (n == null)
|
|
76
76
|
return "";
|
|
77
77
|
const o = e.attrs?.kind;
|
|
78
|
-
return
|
|
78
|
+
return L(
|
|
79
79
|
String(n),
|
|
80
80
|
o == null ? null : String(o),
|
|
81
81
|
t
|
|
@@ -86,30 +86,42 @@ const g = (e, t = "Manifest") => e ? m[e] ?? e : t, L = (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
|
+
}
|
|
89
101
|
default: {
|
|
90
|
-
const n = (e.content ?? []).map((a) =>
|
|
102
|
+
const n = (e.content ?? []).map((a) => m(a, t)).join("");
|
|
91
103
|
return ["paragraph", "heading", "listItem", "blockquote"].includes(e.type) ? `${n}
|
|
92
104
|
` : n;
|
|
93
105
|
}
|
|
94
106
|
}
|
|
95
|
-
},
|
|
107
|
+
}, B = (e, t) => {
|
|
96
108
|
if (!e)
|
|
97
109
|
return "";
|
|
98
110
|
const n = new Set(t.map((o) => o.tool_id));
|
|
99
|
-
return
|
|
111
|
+
return m(e, n).replace(
|
|
100
112
|
/\n+$/,
|
|
101
113
|
""
|
|
102
114
|
);
|
|
103
115
|
};
|
|
104
116
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
u as TOOL_SOURCE_LABELS,
|
|
118
|
+
E as appTypeLabel,
|
|
119
|
+
I as buildAgentMentionItems,
|
|
108
120
|
y as buildCustomToolMentionItems,
|
|
109
121
|
A as buildMentionHtml,
|
|
110
|
-
|
|
122
|
+
$ as configToolMentionItem,
|
|
111
123
|
b as configToolName,
|
|
112
|
-
|
|
124
|
+
B as editorDocToInstructions,
|
|
113
125
|
M as instructionsToEditorHtml,
|
|
114
126
|
S as restApiMentionItem,
|
|
115
127
|
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] || '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,Y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D;AAAA,EAAA;AAEF,GAOaE,IAA0B,CACtCC,GACA3C,MACY;AACZ,MAAI,CAAC2C;AACJ,WAAO;AAER,QAAMN,IAAU,IAAI,IAAIrC,EAAM,IAAI,CAACG,MAAMA,EAAE,OAAO,CAAC;AACnD,SAAOmC,EAAWK,GAAmCN,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] || '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":";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,OAAoB;AAAA,MACpB,IAAIA,EAAE;AAAA,MACN,OAAO,cAAcA,EAAE,IAAI;AAAA,MAC3B,MAAM,EAAE,MAAM,YAAY,YAAYA,EAAE,KAAA;AAAA,IAAK;AAAA,EAC9C;AAEF,GAGaC,IAAiB,CAACF,MAC1BA,EAAE,aAAa,uBAEjB,OAAOA,EAAE,OAAO,WAAc,SAAS,EA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O;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,33 +1,34 @@
|
|
|
1
1
|
import { jsxs as z, jsx as i, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as T, 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
|
-
|
|
9
|
+
import { AgentTableShimmer as oe } from "./AgentTableShimmer.js";
|
|
10
|
+
import { DeleteAgentModal as ie } from "./DeleteAgentModal.js";
|
|
11
|
+
import { unwrapDropdownValue as ae } from "../dropdown/utils.js";
|
|
12
|
+
const re = ({
|
|
13
|
+
config: D,
|
|
14
|
+
onSearchChange: u,
|
|
15
|
+
onSearchSubmit: l,
|
|
15
16
|
onFilterChange: g,
|
|
16
17
|
onSortChange: d,
|
|
17
|
-
onNewAgent:
|
|
18
|
-
onBrowseTemplates:
|
|
19
|
-
onRunAgent:
|
|
20
|
-
onEditAgent:
|
|
21
|
-
onDeleteAgent:
|
|
22
|
-
onRowClick:
|
|
23
|
-
...
|
|
18
|
+
onNewAgent: f,
|
|
19
|
+
onBrowseTemplates: m,
|
|
20
|
+
onRunAgent: A,
|
|
21
|
+
onEditAgent: S,
|
|
22
|
+
onDeleteAgent: r,
|
|
23
|
+
onRowClick: c,
|
|
24
|
+
...L
|
|
24
25
|
}) => {
|
|
25
|
-
const [a, h] =
|
|
26
|
+
const [a, h] = T(
|
|
26
27
|
null
|
|
27
|
-
), [
|
|
28
|
-
agents:
|
|
29
|
-
isLoading:
|
|
30
|
-
searchValue:
|
|
28
|
+
), [b, w] = T(!1), {
|
|
29
|
+
agents: C,
|
|
30
|
+
isLoading: N,
|
|
31
|
+
searchValue: R,
|
|
31
32
|
searchPlaceholder: v = "Search",
|
|
32
33
|
filterOptions: x,
|
|
33
34
|
filterPlaceholder: B = "Filters",
|
|
@@ -36,99 +37,98 @@ const ae = ({
|
|
|
36
37
|
title: I = "AI Agents",
|
|
37
38
|
headerActions: O,
|
|
38
39
|
pagination: o,
|
|
39
|
-
emptyState:
|
|
40
|
+
emptyState: p,
|
|
40
41
|
debugLog: y
|
|
41
|
-
} =
|
|
42
|
-
(e, ...
|
|
43
|
-
y && console.log(`[AgentListing] ${e}`, ...
|
|
42
|
+
} = D, k = !N && C.length === 0, t = n(
|
|
43
|
+
(e, ...s) => {
|
|
44
|
+
y && console.log(`[AgentListing] ${e}`, ...s);
|
|
44
45
|
},
|
|
45
46
|
[y]
|
|
46
47
|
), j = n(
|
|
47
48
|
(e) => {
|
|
48
|
-
t("onSearchChange", e),
|
|
49
|
+
t("onSearchChange", e), u(e);
|
|
49
50
|
},
|
|
50
|
-
[t,
|
|
51
|
+
[t, u]
|
|
51
52
|
), H = n(
|
|
52
53
|
(e) => {
|
|
53
|
-
t("onSearchSubmit", e),
|
|
54
|
+
t("onSearchSubmit", e), l?.(e);
|
|
54
55
|
},
|
|
55
|
-
[t,
|
|
56
|
-
),
|
|
56
|
+
[t, l]
|
|
57
|
+
), M = n(
|
|
57
58
|
(e) => {
|
|
58
59
|
t("onFilterChange", e), g?.(e);
|
|
59
60
|
},
|
|
60
61
|
[t, g]
|
|
61
|
-
),
|
|
62
|
+
), V = n(
|
|
62
63
|
(e) => {
|
|
63
64
|
t("onSortChange", e), d?.(e);
|
|
64
65
|
},
|
|
65
66
|
[t, d]
|
|
66
67
|
), P = n(() => {
|
|
67
|
-
t("onNewAgent"),
|
|
68
|
-
}, [t,
|
|
69
|
-
t("onBrowseTemplates"),
|
|
70
|
-
}, [t,
|
|
68
|
+
t("onNewAgent"), f();
|
|
69
|
+
}, [t, f]), q = n(() => {
|
|
70
|
+
t("onBrowseTemplates"), m?.();
|
|
71
|
+
}, [t, m]), Z = n(
|
|
71
72
|
(e) => {
|
|
72
|
-
t("onRunAgent", e.id),
|
|
73
|
+
t("onRunAgent", e.id), A(e);
|
|
73
74
|
},
|
|
74
|
-
[t,
|
|
75
|
+
[t, A]
|
|
75
76
|
), $ = n(
|
|
76
77
|
(e) => {
|
|
77
|
-
t("onEditAgent", e.id),
|
|
78
|
+
t("onEditAgent", e.id), S(e);
|
|
78
79
|
},
|
|
79
|
-
[t,
|
|
80
|
+
[t, S]
|
|
80
81
|
), G = n(
|
|
81
82
|
(e) => {
|
|
82
|
-
t("onRowClick", e.id),
|
|
83
|
+
t("onRowClick", e.id), c?.(e);
|
|
83
84
|
},
|
|
84
|
-
[t,
|
|
85
|
+
[t, c]
|
|
85
86
|
), J = n(
|
|
86
87
|
(e) => {
|
|
87
88
|
t("onDeleteAgent", e.id), h(e);
|
|
88
89
|
},
|
|
89
90
|
[t]
|
|
90
91
|
), K = n(async () => {
|
|
91
|
-
if (!(!a || !
|
|
92
|
-
|
|
92
|
+
if (!(!a || !r)) {
|
|
93
|
+
w(!0);
|
|
93
94
|
try {
|
|
94
|
-
await
|
|
95
|
+
await r(a), h(null);
|
|
95
96
|
} finally {
|
|
96
|
-
|
|
97
|
+
w(!1);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
|
-
}, [a,
|
|
100
|
-
return /* @__PURE__ */ z(X, { "data-test":
|
|
100
|
+
}, [a, r]);
|
|
101
|
+
return /* @__PURE__ */ z(X, { "data-test": L["data-test"] ?? "agent-listing", children: [
|
|
101
102
|
/* @__PURE__ */ i(
|
|
102
103
|
te,
|
|
103
104
|
{
|
|
104
105
|
title: I,
|
|
105
106
|
onNewAgent: P,
|
|
106
|
-
onBrowseTemplates:
|
|
107
|
+
onBrowseTemplates: m ? q : void 0,
|
|
107
108
|
headerActions: O
|
|
108
109
|
}
|
|
109
110
|
),
|
|
110
111
|
/* @__PURE__ */ i(
|
|
111
112
|
ee,
|
|
112
113
|
{
|
|
113
|
-
searchValue:
|
|
114
|
+
searchValue: R,
|
|
114
115
|
onSearchChange: j,
|
|
115
|
-
onSearchSubmit:
|
|
116
|
+
onSearchSubmit: l ? H : void 0,
|
|
116
117
|
searchPlaceholder: v,
|
|
117
118
|
filterOptions: x,
|
|
118
|
-
onFilterChange: g ?
|
|
119
|
+
onFilterChange: g ? M : void 0,
|
|
119
120
|
filterPlaceholder: B,
|
|
120
121
|
sortOptions: E,
|
|
121
122
|
selectedSort: F,
|
|
122
|
-
onSortChange: d ?
|
|
123
|
+
onSortChange: d ? V : void 0
|
|
123
124
|
}
|
|
124
125
|
),
|
|
125
|
-
/* @__PURE__ */ i(Y, { children:
|
|
126
|
+
/* @__PURE__ */ i(Y, { children: N ? /* @__PURE__ */ i(oe, { rows: Math.min(o?.pageSize ?? 5, 10) }) : k ? /* @__PURE__ */ i(_, { children: /* @__PURE__ */ i(
|
|
126
127
|
W,
|
|
127
128
|
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
actionButton: u?.actionButton ?? {
|
|
129
|
+
title: p?.title ?? "No agents yet",
|
|
130
|
+
subTitle: p?.subTitle ?? "Create your first AI agent to start automating conversations.",
|
|
131
|
+
actionButton: p?.actionButton ?? {
|
|
132
132
|
buttonText: "New AI agent",
|
|
133
133
|
buttonType: "primary",
|
|
134
134
|
size: "small",
|
|
@@ -139,11 +139,11 @@ const ae = ({
|
|
|
139
139
|
/* @__PURE__ */ i(
|
|
140
140
|
ne,
|
|
141
141
|
{
|
|
142
|
-
agents:
|
|
142
|
+
agents: C,
|
|
143
143
|
onRunAgent: Z,
|
|
144
144
|
onEditAgent: $,
|
|
145
|
-
onDeleteAgent:
|
|
146
|
-
onRowClick:
|
|
145
|
+
onDeleteAgent: r ? J : void 0,
|
|
146
|
+
onRowClick: c ? G : void 0
|
|
147
147
|
}
|
|
148
148
|
),
|
|
149
149
|
o && o.totalRows > 0 && /* @__PURE__ */ i(
|
|
@@ -155,25 +155,25 @@ const ae = ({
|
|
|
155
155
|
hidePageSizeOptions: o.hidePageSizeOptions,
|
|
156
156
|
updatePageNumber: o.onPageChange,
|
|
157
157
|
updatePageSize: (e) => {
|
|
158
|
-
const
|
|
159
|
-
Number.isNaN(
|
|
158
|
+
const s = Number(ae(e));
|
|
159
|
+
Number.isNaN(s) || o.onPageSizeChange(s);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
)
|
|
163
163
|
] }) }),
|
|
164
164
|
a && /* @__PURE__ */ i(
|
|
165
|
-
|
|
165
|
+
ie,
|
|
166
166
|
{
|
|
167
167
|
agentName: a.name,
|
|
168
|
-
isDeleting:
|
|
169
|
-
onClose: () =>
|
|
168
|
+
isDeleting: b,
|
|
169
|
+
onClose: () => b ? void 0 : h(null),
|
|
170
170
|
onConfirm: K
|
|
171
171
|
}
|
|
172
172
|
)
|
|
173
173
|
] });
|
|
174
174
|
};
|
|
175
|
-
|
|
175
|
+
re.displayName = "AgentListing";
|
|
176
176
|
export {
|
|
177
|
-
|
|
177
|
+
re as AgentListing
|
|
178
178
|
};
|
|
179
179
|
//# sourceMappingURL=AgentListing.js.map
|