@bikdotai/bik-component-library 0.0.849-beta.4 → 0.0.849-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/cjs/components/agent-builder/components/AddDataPill.js +10 -0
  2. package/dist/cjs/components/agent-builder/components/AddDataPill.js.map +1 -0
  3. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +1 -1
  4. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  5. package/dist/cjs/components/agent-builder/components/MentionEditor.js +1 -1
  6. package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
  7. package/dist/cjs/components/agent-builder/components/MentionField.js +1 -1
  8. package/dist/cjs/components/agent-builder/components/MentionField.js.map +1 -1
  9. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +1 -1
  10. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  11. package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +1 -1
  12. package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
  13. package/dist/cjs/components/agent-builder/components/VariableTriggerArea.js +9 -3
  14. package/dist/cjs/components/agent-builder/components/VariableTriggerArea.js.map +1 -1
  15. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +4 -4
  16. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  17. package/dist/cjs/editor/BikEditor.js +1 -1
  18. package/dist/cjs/editor/BikEditor.js.map +1 -1
  19. package/dist/cjs/editor/BikEditor.styles.js +5 -3
  20. package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
  21. package/dist/cjs/editor/BikEditor.types.js.map +1 -1
  22. package/dist/esm/components/agent-builder/components/AddDataPill.d.ts +18 -0
  23. package/dist/esm/components/agent-builder/components/AddDataPill.js +32 -0
  24. package/dist/esm/components/agent-builder/components/AddDataPill.js.map +1 -0
  25. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +21 -19
  26. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  27. package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +7 -2
  28. package/dist/esm/components/agent-builder/components/MentionEditor.js +119 -102
  29. package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
  30. package/dist/esm/components/agent-builder/components/MentionField.js +30 -29
  31. package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
  32. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +25 -21
  33. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  34. package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +20 -19
  35. package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
  36. package/dist/esm/components/agent-builder/components/VariableTriggerArea.d.ts +6 -0
  37. package/dist/esm/components/agent-builder/components/VariableTriggerArea.js +102 -70
  38. package/dist/esm/components/agent-builder/components/VariableTriggerArea.js.map +1 -1
  39. package/dist/esm/components/agent-builder/utils/mentionSerialization.js +26 -20
  40. package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  41. package/dist/esm/editor/BikEditor.js +24 -18
  42. package/dist/esm/editor/BikEditor.js.map +1 -1
  43. package/dist/esm/editor/BikEditor.styles.js +5 -3
  44. package/dist/esm/editor/BikEditor.styles.js.map +1 -1
  45. package/dist/esm/editor/BikEditor.types.d.ts +9 -0
  46. package/dist/esm/editor/BikEditor.types.js.map +1 -1
  47. package/package.json +1 -1
@@ -1,127 +1,144 @@
1
- import { jsxs as r, jsx as a } from "react/jsx-runtime";
2
- import { useRef as F, useState as _, useCallback as b, useEffect as S, useMemo as G } from "react";
3
- import { TitleSmall as J, BodyCaption as P } from "../../TypographyStyle.js";
4
- import { COLORS as h } from "../../../constants/Theme.js";
5
- import { FieldBlock as Y, FieldLabelRow as q, AiTextAreaShell as z } from "../AgentBuilder.styled.js";
6
- import { AGENT_EDITOR_STYLE as Q } from "../constants/editorStyle.js";
7
- import { variableTokenName as U, buildMentionHtml as g, instructionsToEditorHtml as W, buildVariableMentionItems as X, editorDocToInstructions as Z } from "../utils/mentionSerialization.js";
8
- import { MentionPicker as v } from "./MentionPicker.js";
9
- import { BikEditor as I } from "../../../editor/BikEditor.js";
10
- const at = ({
11
- label: C,
12
- value: l,
13
- onChange: T,
1
+ import { jsxs as r, jsx as l } from "react/jsx-runtime";
2
+ import { useRef as G, useState as h, useCallback as g, useEffect as C, useMemo as J } from "react";
3
+ import { TitleSmall as Y, BodyCaption as q } from "../../TypographyStyle.js";
4
+ import { COLORS as T } from "../../../constants/Theme.js";
5
+ import { FieldBlock as z, FieldLabelRow as Q, AiTextAreaShell as U } from "../AgentBuilder.styled.js";
6
+ import { AGENT_EDITOR_STYLE as W } from "../constants/editorStyle.js";
7
+ import { variableTokenName as X, buildMentionHtml as k, instructionsToEditorHtml as Z, buildVariableMentionItems as I, editorDocToInstructions as K } from "../utils/mentionSerialization.js";
8
+ import { AddDataPill as tt } from "./AddDataPill.js";
9
+ import { MentionPicker as nt } from "./MentionPicker.js";
10
+ import { BikEditor as ot } from "../../../editor/BikEditor.js";
11
+ const ft = ({
12
+ label: x,
13
+ value: c,
14
+ onChange: E,
14
15
  maxLength: s,
15
- placeholder: k,
16
- minHeight: x = "200px",
17
- resetKey: c,
18
- mentionItems: o,
19
- tools: E,
20
- onMentionSelect: H,
21
- onFocus: M,
22
- registerInsert: e,
23
- onCreateSubAgent: O,
24
- toolActions: R,
25
- integrationStatus: y,
26
- onConnectIntegration: L,
16
+ placeholder: M,
17
+ minHeight: O = "200px",
18
+ resetKey: a,
19
+ mentionItems: e,
20
+ tools: H,
21
+ onMentionSelect: R,
22
+ onFocus: y,
23
+ registerInsert: i,
24
+ onCreateSubAgent: A,
25
+ toolActions: B,
26
+ integrationStatus: D,
27
+ onConnectIntegration: F,
27
28
  variablesData: d,
29
+ addDataButton: L,
28
30
  action: N,
29
31
  ...V
30
32
  }) => {
31
- const i = F(null), [A, m] = _(l.length), B = b((t) => {
32
- const n = U(t.actualValue);
33
- i.current?.insertInlineContent(
34
- `${g(
35
- n,
36
- `Variable: ${t.displayName}`,
37
- "variable"
38
- )} `
33
+ const o = G(null), [$, u] = h(c.length), [m, f] = h(!1), j = g((n) => {
34
+ const t = X(n.actualValue);
35
+ o.current?.insertInlineContent(
36
+ `${k(t, `{{${t}}}`, "variable")} `
39
37
  );
40
- }, []), u = b(
41
- (t, n, $) => {
42
- const f = i.current;
43
- if (!f)
38
+ }, []), p = g(
39
+ (n, t, P) => {
40
+ const b = o.current;
41
+ if (!b)
44
42
  return;
45
- const j = o.find(
46
- (p) => String(p.id) === String(n) && p.meta?.kind === t
47
- ), w = $ ?? j?.label ?? n;
48
- f.insertInlineContent(
49
- `${g(String(n), w, t)} `
43
+ const _ = e.find(
44
+ (S) => String(S.id) === String(t) && S.meta?.kind === n
45
+ ), v = P ?? _?.label ?? t;
46
+ b.insertInlineContent(
47
+ `${k(String(t), v, n)} `
50
48
  );
51
49
  },
52
- [o]
50
+ [e]
53
51
  );
54
- S(() => {
55
- if (e)
56
- return e(u), () => e(null);
57
- }, [e, u]);
58
- const D = G(
59
- () => W(l, [
60
- ...o,
61
- ...X(d)
52
+ C(() => {
53
+ if (i)
54
+ return i(p), () => i(null);
55
+ }, [i, p]);
56
+ const w = J(
57
+ () => Z(c, [
58
+ ...e,
59
+ ...I(d)
62
60
  ]),
63
61
  // eslint-disable-next-line react-hooks/exhaustive-deps
64
- [c]
62
+ [a]
65
63
  );
66
- return S(
67
- () => m(l.length),
64
+ return C(
65
+ () => u(c.length),
68
66
  // eslint-disable-next-line react-hooks/exhaustive-deps
69
- [c]
70
- ), /* @__PURE__ */ r(Y, { children: [
71
- /* @__PURE__ */ r(q, { children: [
72
- /* @__PURE__ */ a(J, { color: h.content.primary, children: C }),
73
- /* @__PURE__ */ r(P, { color: h.content.secondary, children: [
74
- A,
67
+ [a]
68
+ ), /* @__PURE__ */ r(z, { children: [
69
+ /* @__PURE__ */ r(Q, { children: [
70
+ /* @__PURE__ */ l(Y, { color: T.content.primary, children: x }),
71
+ /* @__PURE__ */ r(q, { color: T.content.secondary, children: [
72
+ $,
75
73
  "/",
76
74
  s
77
75
  ] })
78
76
  ] }),
79
- /* @__PURE__ */ r(z, { minHeight: x, "data-test": V["data-test"], children: [
80
- /* @__PURE__ */ a(
81
- I,
82
- {
83
- ref: i,
84
- initialContent: D,
85
- placeholder: k,
86
- characterLimit: s,
87
- minHeight: "120px",
88
- maxHeight: "320px",
89
- style: { border: "none" },
90
- editorStyle: Q,
91
- onFocus: M,
92
- mentions: {
93
- agents: o,
94
- removeTriggerOnDismiss: !0,
95
- renderDropdown: (t) => /* @__PURE__ */ a(
96
- v,
97
- {
98
- ...t,
99
- onCreateSubAgent: O,
100
- toolActions: R,
101
- integrationStatus: y,
102
- onConnectIntegration: L,
103
- variablesData: d,
104
- onSelectVariable: B
77
+ /* @__PURE__ */ r(
78
+ U,
79
+ {
80
+ minHeight: O,
81
+ focused: m,
82
+ style: { position: "relative" },
83
+ "data-test": V["data-test"],
84
+ children: [
85
+ /* @__PURE__ */ l(
86
+ ot,
87
+ {
88
+ ref: o,
89
+ initialContent: w,
90
+ placeholder: M,
91
+ characterLimit: s,
92
+ minHeight: "120px",
93
+ maxHeight: "320px",
94
+ style: { border: "none" },
95
+ editorStyle: W,
96
+ onFocus: () => {
97
+ f(!0), y?.();
98
+ },
99
+ onBlur: () => f(!1),
100
+ mentions: {
101
+ agents: e,
102
+ removeTriggerOnDismiss: !0,
103
+ renderDropdown: (n) => /* @__PURE__ */ l(
104
+ nt,
105
+ {
106
+ ...n,
107
+ onCreateSubAgent: A,
108
+ toolActions: B,
109
+ integrationStatus: D,
110
+ onConnectIntegration: F,
111
+ variablesData: d,
112
+ onSelectVariable: j
113
+ }
114
+ ),
115
+ onSelect: (n) => {
116
+ const t = n.meta?.kind;
117
+ (t === "tool" || t === "subagent") && R?.(t, String(n.id));
118
+ }
119
+ },
120
+ onChange: (n) => {
121
+ u(n.characterCount);
122
+ const t = o.current?.getJSON() ?? null;
123
+ E(K(t, H));
105
124
  }
106
- ),
107
- onSelect: (t) => {
108
- const n = t.meta?.kind;
109
- (n === "tool" || n === "subagent") && H?.(n, String(t.id));
125
+ },
126
+ a
127
+ ),
128
+ N,
129
+ L && m && /* @__PURE__ */ l(
130
+ tt,
131
+ {
132
+ "data-test": "mention-add-data",
133
+ onOpen: () => o.current?.actions.openMentionMenu("@")
110
134
  }
111
- },
112
- onChange: (t) => {
113
- m(t.characterCount);
114
- const n = i.current?.getJSON() ?? null;
115
- T(Z(n, E));
116
- }
117
- },
118
- c
119
- ),
120
- N
121
- ] })
135
+ )
136
+ ]
137
+ }
138
+ )
122
139
  ] });
123
140
  };
124
141
  export {
125
- at as MentionEditor
142
+ ft as MentionEditor
126
143
  };
127
144
  //# sourceMappingURL=MentionEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MentionEditor.js","sources":["../../../../../src/components/agent-builder/components/MentionEditor.tsx"],"sourcesContent":["import { BikEditor, BikEditorRef, MentionItem } from '@src/editor';\nimport React, {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport type {\n\tVariableListInterfaceV3,\n\tVariableV3,\n} from '../../variable-picker-v3/model';\nimport { AgentTool } from '../AgentBuilder.model';\nimport {\n\tAiTextAreaShell,\n\tFieldBlock,\n\tFieldLabelRow,\n} from '../AgentBuilder.styled';\nimport { AGENT_EDITOR_STYLE } from '../constants/editorStyle';\nimport type { ToolAction, ToolSource } from '../constants/tools';\nimport {\n\tbuildMentionHtml,\n\tbuildVariableMentionItems,\n\teditorDocToInstructions,\n\tinstructionsToEditorHtml,\n\tMentionKindMeta,\n\tvariableTokenName,\n} from '../utils/mentionSerialization';\nimport { MentionPicker } from './MentionPicker';\n\ntype InsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;\n\ninterface MentionEditorProps {\n\tlabel: string;\n\tvalue: string;\n\tonChange: (text: string) => void;\n\tmaxLength: number;\n\tplaceholder?: string;\n\tminHeight?: string;\n\t/** Changing this remounts the editor with fresh content. */\n\tresetKey?: string | number;\n\t/** Items shown in the `@` picker (tools, and sub-agents where allowed). */\n\tmentionItems: MentionItem[];\n\t/** Tools used to serialise mention nodes back to `{{tool:KEY}}`. */\n\ttools: AgentTool[];\n\t/** Called when an item is picked from the `@` menu (to attach it upstream). */\n\tonMentionSelect?: (kind: 'tool' | 'subagent', id: string) => void;\n\tonFocus?: () => void;\n\t/** Receives an insert-at-cursor fn (and null on unmount) for side-panel adds. */\n\tregisterInsert?: (fn: InsertFn | null) => void;\n\t/**\n\t * When set, the `@` picker's Sub-agent view shows a \"Create new\" row that calls\n\t * this (opens the create-sub-agent drawer). Omit to hide it (e.g. the drawer's\n\t * own editors, which can't nest sub-agents).\n\t */\n\tonCreateSubAgent?: () => void;\n\t/**\n\t * Built-in tool actions (Rest API / Handover to email) shown in the `@` picker's\n\t * Tools view. Picking one opens its drawer instead of inserting a mention.\n\t */\n\ttoolActions?: ToolAction[];\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\tonConnectIntegration?: (source: ToolSource) => void;\n\t/**\n\t * Variable catalog for the `@` picker's \"Variables\" view. Picking one inserts\n\t * a `Variable: <name>` mention chip at the cursor, persisted as a\n\t * `{{variable:<name>}}` token. Omit to hide the category.\n\t */\n\tvariablesData?: VariableListInterfaceV3[];\n\t/** Optional action(s) rendered inside the shell, below the editor. */\n\taction?: React.ReactNode;\n\t'data-test'?: string;\n}\n\n/**\n * Presentational BikEditor field with `@` mentions. Stores firebase token text\n * (`{{tool:KEY}}` / `{{subagent:ID}}`). Context-free — both the builder's\n * Step-3 fields and the create-sub-agent drawer compose it.\n */\nexport const MentionEditor: React.FC<MentionEditorProps> = ({\n\tlabel,\n\tvalue,\n\tonChange,\n\tmaxLength,\n\tplaceholder,\n\tminHeight = '200px',\n\tresetKey,\n\tmentionItems,\n\ttools,\n\tonMentionSelect,\n\tonFocus,\n\tregisterInsert,\n\tonCreateSubAgent,\n\ttoolActions,\n\tintegrationStatus,\n\tonConnectIntegration,\n\tvariablesData,\n\taction,\n\t...rest\n}) => {\n\tconst editorRef = useRef<BikEditorRef>(null);\n\tconst [count, setCount] = useState(value.length);\n\n\t// The picker dismissed itself already (stripping the \"@\" + query) — drop a\n\t// `Variable: <name>` mention chip at the cursor, same shape as tool /\n\t// sub-agent chips. `editorDocToInstructions` serializes it back to a\n\t// `{{variable:<name>}}` token.\n\tconst onSelectVariable = useCallback((variable: VariableV3) => {\n\t\tconst name = variableTokenName(variable.actualValue);\n\t\teditorRef.current?.insertInlineContent(\n\t\t\t`${buildMentionHtml(\n\t\t\t\tname,\n\t\t\t\t`Variable: ${variable.displayName}`,\n\t\t\t\t'variable',\n\t\t\t)}&nbsp;`,\n\t\t);\n\t}, []);\n\n\tconst insert = useCallback<InsertFn>(\n\t\t(kind, id, overrideLabel) => {\n\t\t\tconst editor = editorRef.current;\n\t\t\tif (!editor) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst item = mentionItems.find(\n\t\t\t\t(m) =>\n\t\t\t\t\tString(m.id) === String(id) &&\n\t\t\t\t\t(m.meta as unknown as MentionKindMeta | undefined)?.kind === kind,\n\t\t\t);\n\t\t\tconst finalLabel = overrideLabel ?? item?.label ?? id;\n\t\t\teditor.insertInlineContent(\n\t\t\t\t`${buildMentionHtml(String(id), finalLabel, kind)}&nbsp;`,\n\t\t\t);\n\t\t},\n\t\t[mentionItems],\n\t);\n\n\tuseEffect(() => {\n\t\tif (!registerInsert) {\n\t\t\treturn;\n\t\t}\n\t\tregisterInsert(insert);\n\t\treturn () => registerInsert(null);\n\t}, [registerInsert, insert]);\n\n\t// Mount-only initial HTML; recomputed (editor remounted via key) on resetKey.\n\t// Variable items are merged in so stored `{{name}}` tokens rehydrate as chips.\n\tconst initialHtml = useMemo(\n\t\t() =>\n\t\t\tinstructionsToEditorHtml(value, [\n\t\t\t\t...mentionItems,\n\t\t\t\t...buildVariableMentionItems(variablesData),\n\t\t\t]),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\tuseEffect(\n\t\t() => setCount(value.length),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\treturn (\n\t\t<FieldBlock>\n\t\t\t<FieldLabelRow>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t{count}/{maxLength}\n\t\t\t\t</BodyCaption>\n\t\t\t</FieldLabelRow>\n\n\t\t\t<AiTextAreaShell minHeight={minHeight} data-test={rest['data-test']}>\n\t\t\t\t<BikEditor\n\t\t\t\t\tkey={resetKey}\n\t\t\t\t\tref={editorRef}\n\t\t\t\t\tinitialContent={initialHtml}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t// Soft limit: blocks typing past the cap but lets a paste through\n\t\t\t\t\t// (overflow rendered grey) instead of rejecting the whole paste.\n\t\t\t\t\tcharacterLimit={maxLength}\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\tmaxHeight=\"320px\"\n\t\t\t\t\tstyle={{ border: 'none' }}\n\t\t\t\t\teditorStyle={AGENT_EDITOR_STYLE}\n\t\t\t\t\tonFocus={onFocus}\n\t\t\t\t\tmentions={{\n\t\t\t\t\t\tagents: mentionItems,\n\t\t\t\t\t\tremoveTriggerOnDismiss: true,\n\t\t\t\t\t\trenderDropdown: (props) => (\n\t\t\t\t\t\t\t<MentionPicker\n\t\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\t\tonCreateSubAgent={onCreateSubAgent}\n\t\t\t\t\t\t\t\ttoolActions={toolActions}\n\t\t\t\t\t\t\t\tintegrationStatus={integrationStatus}\n\t\t\t\t\t\t\t\tonConnectIntegration={onConnectIntegration}\n\t\t\t\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\t\t\t\tonSelectVariable={onSelectVariable}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t),\n\t\t\t\t\t\tonSelect: (item) => {\n\t\t\t\t\t\t\tconst kind = (item.meta as unknown as MentionKindMeta | undefined)\n\t\t\t\t\t\t\t\t?.kind;\n\t\t\t\t\t\t\t// Variables never come through this path (they use the embedded\n\t\t\t\t\t\t\t// picker's onSelectVariable) and have nothing to attach upstream.\n\t\t\t\t\t\t\tif (kind === 'tool' || kind === 'subagent') {\n\t\t\t\t\t\t\t\tonMentionSelect?.(kind, String(item.id));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonChange={(snapshot) => {\n\t\t\t\t\t\tsetCount(snapshot.characterCount);\n\t\t\t\t\t\tconst doc = editorRef.current?.getJSON() ?? null;\n\t\t\t\t\t\tonChange(editorDocToInstructions(doc, tools));\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t{action}\n\t\t\t</AiTextAreaShell>\n\t\t</FieldBlock>\n\t);\n};\n"],"names":["MentionEditor","label","value","onChange","maxLength","placeholder","minHeight","resetKey","mentionItems","tools","onMentionSelect","onFocus","registerInsert","onCreateSubAgent","toolActions","integrationStatus","onConnectIntegration","variablesData","action","rest","editorRef","useRef","count","setCount","useState","onSelectVariable","useCallback","variable","name","variableTokenName","buildMentionHtml","insert","kind","id","overrideLabel","editor","item","m","finalLabel","useEffect","initialHtml","useMemo","instructionsToEditorHtml","buildVariableMentionItems","FieldBlock","jsxs","FieldLabelRow","jsx","TitleSmall","COLORS","BodyCaption","AiTextAreaShell","BikEditor","AGENT_EDITOR_STYLE","props","MentionPicker","snapshot","doc","editorDocToInstructions"],"mappings":";;;;;;;;;AAiFO,MAAMA,KAA8C,CAAC;AAAA,EAC3D,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,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,OAAOI,EAAK,EAAE,CAAC;AAAA,YAEzC;AAAA,UAAA;AAAA,UAED,UAAU,CAACoB,MAAa;AACvB,YAAAjC,EAASiC,EAAS,cAAc;AAChC,kBAAMC,IAAMrC,EAAU,SAAS,QAAA,KAAa;AAC5C,YAAAjB,EAASuD,EAAwBD,GAAKhD,CAAK,CAAC;AAAA,UAC7C;AAAA,QAAA;AAAA,QAxCKF;AAAA,MAAA;AAAA,MA0CLW;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACD;AAEF;"}
1
+ {"version":3,"file":"MentionEditor.js","sources":["../../../../../src/components/agent-builder/components/MentionEditor.tsx"],"sourcesContent":["import { BikEditor, BikEditorRef, MentionItem } from '@src/editor';\nimport React, {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport type {\n\tVariableListInterfaceV3,\n\tVariableV3,\n} from '../../variable-picker-v3/model';\nimport { AgentTool } from '../AgentBuilder.model';\nimport {\n\tAiTextAreaShell,\n\tFieldBlock,\n\tFieldLabelRow,\n} from '../AgentBuilder.styled';\nimport { AGENT_EDITOR_STYLE } from '../constants/editorStyle';\nimport type { ToolAction, ToolSource } from '../constants/tools';\nimport {\n\tbuildMentionHtml,\n\tbuildVariableMentionItems,\n\teditorDocToInstructions,\n\tinstructionsToEditorHtml,\n\tMentionKindMeta,\n\tvariableTokenName,\n} from '../utils/mentionSerialization';\nimport { AddDataPill } from './AddDataPill';\nimport { MentionPicker } from './MentionPicker';\n\ntype InsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;\n\ninterface MentionEditorProps {\n\tlabel: string;\n\tvalue: string;\n\tonChange: (text: string) => void;\n\tmaxLength: number;\n\tplaceholder?: string;\n\tminHeight?: string;\n\t/** Changing this remounts the editor with fresh content. */\n\tresetKey?: string | number;\n\t/** Items shown in the `@` picker (tools, and sub-agents where allowed). */\n\tmentionItems: MentionItem[];\n\t/** Tools used to serialise mention nodes back to `{{tool:KEY}}`. */\n\ttools: AgentTool[];\n\t/** Called when an item is picked from the `@` menu (to attach it upstream). */\n\tonMentionSelect?: (kind: 'tool' | 'subagent', id: string) => void;\n\tonFocus?: () => void;\n\t/** Receives an insert-at-cursor fn (and null on unmount) for side-panel adds. */\n\tregisterInsert?: (fn: InsertFn | null) => void;\n\t/**\n\t * When set, the `@` picker's Sub-agent view shows a \"Create new\" row that calls\n\t * this (opens the create-sub-agent drawer). Omit to hide it (e.g. the drawer's\n\t * own editors, which can't nest sub-agents).\n\t */\n\tonCreateSubAgent?: () => void;\n\t/**\n\t * Built-in tool actions (Rest API / Handover to email) shown in the `@` picker's\n\t * Tools view. Picking one opens its drawer instead of inserting a mention.\n\t */\n\ttoolActions?: ToolAction[];\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\tonConnectIntegration?: (source: ToolSource) => void;\n\t/**\n\t * Variable catalog for the `@` picker's \"Variables\" view. Picking one inserts\n\t * a `{{<name>}}` mention chip (rendered as the purple raw token) at the\n\t * cursor, persisted as `{{variable:<name>}}`. Omit to hide the category.\n\t */\n\tvariablesData?: VariableListInterfaceV3[];\n\t/**\n\t * Show a floating \"+ Add data\" pill at the field's bottom-right while it is\n\t * focused. Clicking it opens the same `@` reference menu at the cursor.\n\t */\n\taddDataButton?: boolean;\n\t/** Optional action(s) rendered inside the shell, below the editor. */\n\taction?: React.ReactNode;\n\t'data-test'?: string;\n}\n\n/**\n * Presentational BikEditor field with `@` mentions. Stores firebase token text\n * (`{{tool:KEY}}` / `{{subagent:ID}}`). Context-free — both the builder's\n * Step-3 fields and the create-sub-agent drawer compose it.\n */\nexport const MentionEditor: React.FC<MentionEditorProps> = ({\n\tlabel,\n\tvalue,\n\tonChange,\n\tmaxLength,\n\tplaceholder,\n\tminHeight = '200px',\n\tresetKey,\n\tmentionItems,\n\ttools,\n\tonMentionSelect,\n\tonFocus,\n\tregisterInsert,\n\tonCreateSubAgent,\n\ttoolActions,\n\tintegrationStatus,\n\tonConnectIntegration,\n\tvariablesData,\n\taddDataButton,\n\taction,\n\t...rest\n}) => {\n\tconst editorRef = useRef<BikEditorRef>(null);\n\tconst [count, setCount] = useState(value.length);\n\tconst [focused, setFocused] = useState(false);\n\n\t// The picker dismissed itself already (stripping the \"@\" + query) — drop a\n\t// mention chip at the cursor whose text is the raw token (`{{<name>}}`,\n\t// rendered purple by the editor). `editorDocToInstructions` serializes it\n\t// back to a `{{variable:<name>}}` token.\n\tconst onSelectVariable = useCallback((variable: VariableV3) => {\n\t\tconst name = variableTokenName(variable.actualValue);\n\t\teditorRef.current?.insertInlineContent(\n\t\t\t`${buildMentionHtml(name, `{{${name}}}`, 'variable')}&nbsp;`,\n\t\t);\n\t}, []);\n\n\tconst insert = useCallback<InsertFn>(\n\t\t(kind, id, overrideLabel) => {\n\t\t\tconst editor = editorRef.current;\n\t\t\tif (!editor) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst item = mentionItems.find(\n\t\t\t\t(m) =>\n\t\t\t\t\tString(m.id) === String(id) &&\n\t\t\t\t\t(m.meta as unknown as MentionKindMeta | undefined)?.kind === kind,\n\t\t\t);\n\t\t\tconst finalLabel = overrideLabel ?? item?.label ?? id;\n\t\t\teditor.insertInlineContent(\n\t\t\t\t`${buildMentionHtml(String(id), finalLabel, kind)}&nbsp;`,\n\t\t\t);\n\t\t},\n\t\t[mentionItems],\n\t);\n\n\tuseEffect(() => {\n\t\tif (!registerInsert) {\n\t\t\treturn;\n\t\t}\n\t\tregisterInsert(insert);\n\t\treturn () => registerInsert(null);\n\t}, [registerInsert, insert]);\n\n\t// Mount-only initial HTML; recomputed (editor remounted via key) on resetKey.\n\t// Variable items are merged in so stored `{{name}}` tokens rehydrate as chips.\n\tconst initialHtml = useMemo(\n\t\t() =>\n\t\t\tinstructionsToEditorHtml(value, [\n\t\t\t\t...mentionItems,\n\t\t\t\t...buildVariableMentionItems(variablesData),\n\t\t\t]),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\tuseEffect(\n\t\t() => setCount(value.length),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\treturn (\n\t\t<FieldBlock>\n\t\t\t<FieldLabelRow>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t{count}/{maxLength}\n\t\t\t\t</BodyCaption>\n\t\t\t</FieldLabelRow>\n\n\t\t\t<AiTextAreaShell\n\t\t\t\tminHeight={minHeight}\n\t\t\t\tfocused={focused}\n\t\t\t\t// Anchors the floating \"+ Add data\" pill to the shell's corner.\n\t\t\t\tstyle={{ position: 'relative' }}\n\t\t\t\tdata-test={rest['data-test']}\n\t\t\t>\n\t\t\t\t<BikEditor\n\t\t\t\t\tkey={resetKey}\n\t\t\t\t\tref={editorRef}\n\t\t\t\t\tinitialContent={initialHtml}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t// Soft limit: blocks typing past the cap but lets a paste through\n\t\t\t\t\t// (overflow rendered grey) instead of rejecting the whole paste.\n\t\t\t\t\tcharacterLimit={maxLength}\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\tmaxHeight=\"320px\"\n\t\t\t\t\tstyle={{ border: 'none' }}\n\t\t\t\t\teditorStyle={AGENT_EDITOR_STYLE}\n\t\t\t\t\tonFocus={() => {\n\t\t\t\t\t\tsetFocused(true);\n\t\t\t\t\t\tonFocus?.();\n\t\t\t\t\t}}\n\t\t\t\t\tonBlur={() => setFocused(false)}\n\t\t\t\t\tmentions={{\n\t\t\t\t\t\tagents: mentionItems,\n\t\t\t\t\t\tremoveTriggerOnDismiss: true,\n\t\t\t\t\t\trenderDropdown: (props) => (\n\t\t\t\t\t\t\t<MentionPicker\n\t\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\t\tonCreateSubAgent={onCreateSubAgent}\n\t\t\t\t\t\t\t\ttoolActions={toolActions}\n\t\t\t\t\t\t\t\tintegrationStatus={integrationStatus}\n\t\t\t\t\t\t\t\tonConnectIntegration={onConnectIntegration}\n\t\t\t\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\t\t\t\tonSelectVariable={onSelectVariable}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t),\n\t\t\t\t\t\tonSelect: (item) => {\n\t\t\t\t\t\t\tconst kind = (item.meta as unknown as MentionKindMeta | undefined)\n\t\t\t\t\t\t\t\t?.kind;\n\t\t\t\t\t\t\t// Variables never come through this path (they use the embedded\n\t\t\t\t\t\t\t// picker's onSelectVariable) and have nothing to attach upstream.\n\t\t\t\t\t\t\tif (kind === 'tool' || kind === 'subagent') {\n\t\t\t\t\t\t\t\tonMentionSelect?.(kind, String(item.id));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonChange={(snapshot) => {\n\t\t\t\t\t\tsetCount(snapshot.characterCount);\n\t\t\t\t\t\tconst doc = editorRef.current?.getJSON() ?? null;\n\t\t\t\t\t\tonChange(editorDocToInstructions(doc, tools));\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t{action}\n\t\t\t\t{addDataButton && focused && (\n\t\t\t\t\t<AddDataPill\n\t\t\t\t\t\tdata-test=\"mention-add-data\"\n\t\t\t\t\t\tonOpen={() => editorRef.current?.actions.openMentionMenu('@')}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</AiTextAreaShell>\n\t\t</FieldBlock>\n\t);\n};\n"],"names":["MentionEditor","label","value","onChange","maxLength","placeholder","minHeight","resetKey","mentionItems","tools","onMentionSelect","onFocus","registerInsert","onCreateSubAgent","toolActions","integrationStatus","onConnectIntegration","variablesData","addDataButton","action","rest","editorRef","useRef","count","setCount","useState","focused","setFocused","onSelectVariable","useCallback","variable","name","variableTokenName","buildMentionHtml","insert","kind","id","overrideLabel","editor","item","m","finalLabel","useEffect","initialHtml","useMemo","instructionsToEditorHtml","buildVariableMentionItems","FieldBlock","jsxs","FieldLabelRow","jsx","TitleSmall","COLORS","BodyCaption","AiTextAreaShell","BikEditor","AGENT_EDITOR_STYLE","props","MentionPicker","snapshot","doc","editorDocToInstructions","AddDataPill"],"mappings":";;;;;;;;;;AAuFO,MAAMA,KAA8C,CAAC;AAAA,EAC3D,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,OAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;AAAA,EACA,GAAGC;AACJ,MAAM;AACL,QAAMC,IAAYC,EAAqB,IAAI,GACrC,CAACC,GAAOC,CAAQ,IAAIC,EAASvB,EAAM,MAAM,GACzC,CAACwB,GAASC,CAAU,IAAIF,EAAS,EAAK,GAMtCG,IAAmBC,EAAY,CAACC,MAAyB;AAC9D,UAAMC,IAAOC,EAAkBF,EAAS,WAAW;AACnD,IAAAT,EAAU,SAAS;AAAA,MAClB,GAAGY,EAAiBF,GAAM,KAAKA,CAAI,MAAM,UAAU,CAAC;AAAA,IAAA;AAAA,EAEtD,GAAG,CAAA,CAAE,GAECG,IAASL;AAAA,IACd,CAACM,GAAMC,GAAIC,MAAkB;AAC5B,YAAMC,IAASjB,EAAU;AACzB,UAAI,CAACiB;AACJ;AAED,YAAMC,IAAO/B,EAAa;AAAA,QACzB,CAACgC,MACA,OAAOA,EAAE,EAAE,MAAM,OAAOJ,CAAE,KACzBI,EAAE,MAAiD,SAASL;AAAA,MAAA,GAEzDM,IAAaJ,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AE,QAAQ,OAAA;AAAA,cACjB,aAAaoD;AAAA,cACb,SAAS,MAAM;AACd,gBAAA7B,EAAW,EAAI,GACfhB,IAAA;AAAA,cACD;AAAA,cACA,QAAQ,MAAMgB,EAAW,EAAK;AAAA,cAC9B,UAAU;AAAA,gBACT,QAAQnB;AAAA,gBACR,wBAAwB;AAAA,gBACxB,gBAAgB,CAACiD,MAChB,gBAAAP;AAAA,kBAACQ;AAAA,kBAAA;AAAA,oBACC,GAAGD;AAAA,oBACJ,kBAAA5C;AAAA,oBACA,aAAAC;AAAA,oBACA,mBAAAC;AAAA,oBACA,sBAAAC;AAAA,oBACA,eAAAC;AAAA,oBACA,kBAAAW;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAGF,UAAU,CAACW,MAAS;AACnB,wBAAMJ,IAAQI,EAAK,MAChB;AAGH,mBAAIJ,MAAS,UAAUA,MAAS,eAC/BzB,IAAkByB,GAAM,OAAOI,EAAK,EAAE,CAAC;AAAA,gBAEzC;AAAA,cAAA;AAAA,cAED,UAAU,CAACoB,MAAa;AACvB,gBAAAnC,EAASmC,EAAS,cAAc;AAChC,sBAAMC,IAAMvC,EAAU,SAAS,QAAA,KAAa;AAC5C,gBAAAlB,EAAS0D,EAAwBD,GAAKnD,CAAK,CAAC;AAAA,cAC7C;AAAA,YAAA;AAAA,YA5CKF;AAAA,UAAA;AAAA,UA8CLY;AAAA,UACAD,KAAiBQ,KACjB,gBAAAwB;AAAA,YAACY;AAAA,YAAA;AAAA,cACA,aAAU;AAAA,cACV,QAAQ,MAAMzC,EAAU,SAAS,QAAQ,gBAAgB,GAAG;AAAA,YAAA;AAAA,UAAA;AAAA,QAC7D;AAAA,MAAA;AAAA,IAAA;AAAA,EAEF,GACD;AAEF;"}
@@ -1,11 +1,11 @@
1
- import { jsx as j } from "react/jsx-runtime";
1
+ import { jsx as D } from "react/jsx-runtime";
2
2
  import { useMemo as p, useCallback as g } from "react";
3
- import { useAgentBuilderContext as k } from "../context/AgentBuilderContext.js";
4
- import { buildAgentMentionItems as B, appTypeLabel as D, buildCustomToolMentionItems as E } from "../utils/mentionSerialization.js";
3
+ import { useAgentBuilderContext as R } from "../context/AgentBuilderContext.js";
4
+ import { buildAgentMentionItems as j, appTypeLabel as k, buildCustomToolMentionItems as E } from "../utils/mentionSerialization.js";
5
5
  import { buildToolActions as L } from "../utils/toolActions.js";
6
6
  import { MentionEditor as w } from "./MentionEditor.js";
7
7
  const O = ({
8
- fieldKey: o,
8
+ fieldKey: t,
9
9
  label: b,
10
10
  placeholder: T,
11
11
  maxLength: A,
@@ -13,78 +13,79 @@ const O = ({
13
13
  ...C
14
14
  }) => {
15
15
  const {
16
- value: t,
16
+ value: o,
17
17
  patch: M,
18
- addReference: r,
18
+ addReference: a,
19
19
  availableTools: n,
20
- availableSubAgents: a,
20
+ availableSubAgents: r,
21
21
  applicationType: l,
22
22
  mentionResetKey: f,
23
- registerMentionField: c,
23
+ registerMentionField: u,
24
24
  notifyMentionFocus: v,
25
25
  onCreateSubAgent: S,
26
26
  requestCreateSubAgent: I,
27
- requestToolAction: m,
28
- configToolTemplates: u,
27
+ requestToolAction: c,
28
+ configToolTemplates: m,
29
29
  integrationStatus: s,
30
30
  onConnectIntegration: i,
31
31
  variablesData: F
32
- } = k(), x = p(
32
+ } = R(), x = p(
33
33
  () => [
34
- ...B(
34
+ ...j(
35
35
  n,
36
- a,
37
- D(l)
36
+ r,
37
+ k(l)
38
38
  ),
39
- ...E(t.configTools, t.restApiTools)
39
+ ...E(o.configTools, o.restApiTools)
40
40
  ],
41
41
  [
42
42
  n,
43
- a,
43
+ r,
44
44
  l,
45
- t.configTools,
46
- t.restApiTools
45
+ o.configTools,
46
+ o.restApiTools
47
47
  ]
48
48
  ), $ = p(
49
49
  () => L(
50
- u,
51
50
  m,
51
+ c,
52
52
  s,
53
53
  i
54
54
  ),
55
55
  [
56
+ c,
56
57
  m,
57
- u,
58
58
  s,
59
59
  i
60
60
  ]
61
61
  ), h = g(
62
- (e) => c(o, e),
63
- [c, o]
62
+ (e) => u(t, e),
63
+ [u, t]
64
64
  ), q = g(
65
- (e, R) => r(e, R),
66
- [r]
65
+ (e, B) => a(e, B),
66
+ [a]
67
67
  );
68
- return /* @__PURE__ */ j(
68
+ return /* @__PURE__ */ D(
69
69
  w,
70
70
  {
71
71
  label: b,
72
- value: t[o] ?? "",
73
- onChange: (e) => M({ [o]: e }),
72
+ value: o[t] ?? "",
73
+ onChange: (e) => M({ [t]: e }),
74
74
  maxLength: A,
75
75
  placeholder: T,
76
76
  minHeight: d,
77
- resetKey: `${t.id}:${o}:${f}`,
77
+ resetKey: `${o.id}:${t}:${f}`,
78
78
  mentionItems: x,
79
79
  tools: n,
80
80
  onMentionSelect: q,
81
- onFocus: () => v(o),
81
+ onFocus: () => v(t),
82
82
  registerInsert: h,
83
83
  onCreateSubAgent: S ? I : void 0,
84
84
  toolActions: $,
85
85
  integrationStatus: s,
86
86
  onConnectIntegration: i,
87
87
  variablesData: F,
88
+ addDataButton: !0,
88
89
  "data-test": C["data-test"]
89
90
  }
90
91
  );
@@ -1 +1 @@
1
- {"version":3,"file":"MentionField.js","sources":["../../../../../src/components/agent-builder/components/MentionField.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from 'react';\nimport { AgentValue } from '../AgentBuilder.model';\nimport { ToolAction } from '../constants/tools';\nimport {\n\tMentionFieldKey,\n\tuseAgentBuilderContext,\n} from '../context/AgentBuilderContext';\nimport {\n\tappTypeLabel,\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n} from '../utils/mentionSerialization';\nimport { buildToolActions } from '../utils/toolActions';\nimport { MentionEditor } from './MentionEditor';\n\ninterface MentionFieldProps {\n\t/** Which AgentValue field this editor reads / writes. */\n\tfieldKey: MentionFieldKey;\n\tlabel: string;\n\tplaceholder?: string;\n\tmaxLength: number;\n\tminHeight?: string;\n\t'data-test'?: string;\n}\n\n/**\n * Context-bound {@link MentionEditor} for the builder's Step-3 Instructions /\n * Guardrails. Both `@` tools and sub-agents are offered; the field registers its\n * insert + focus with the context so side-panel adds drop a chip into whichever\n * field was last focused, and remounts on `mentionResetKey`.\n */\nexport const MentionField: React.FC<MentionFieldProps> = ({\n\tfieldKey,\n\tlabel,\n\tplaceholder,\n\tmaxLength,\n\tminHeight,\n\t...rest\n}) => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\taddReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tapplicationType,\n\t\tmentionResetKey,\n\t\tregisterMentionField,\n\t\tnotifyMentionFocus,\n\t\tonCreateSubAgent,\n\t\trequestCreateSubAgent,\n\t\trequestToolAction,\n\t\tconfigToolTemplates,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t\tvariablesData,\n\t} = useAgentBuilderContext();\n\n\t// Catalog tools + sub-agents, PLUS the inline custom tools (Rest API / email /\n\t// Slack) so their `{{tool:<id>}}` tokens rehydrate as chips on remount — they\n\t// live on the value, not in `availableTools`.\n\tconst mentionItems = useMemo(\n\t\t() => [\n\t\t\t...buildAgentMentionItems(\n\t\t\t\tavailableTools,\n\t\t\t\tavailableSubAgents,\n\t\t\t\tappTypeLabel(applicationType),\n\t\t\t),\n\t\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t\t],\n\t\t[\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tapplicationType,\n\t\t\tvalue.configTools,\n\t\t\tvalue.restApiTools,\n\t\t],\n\t);\n\n\t// Built-in tool actions (Rest API / email / Slack) shown in the `@` picker's\n\t// Tools view — picking one opens its drawer (Step 3) instead of inserting text.\n\t// The shared email / Slack forms are backend-driven: each is offered only when\n\t// its template was provided.\n\tconst toolActions = useMemo<ToolAction[]>(\n\t\t() =>\n\t\t\tbuildToolActions(\n\t\t\t\tconfigToolTemplates,\n\t\t\t\trequestToolAction,\n\t\t\t\tintegrationStatus,\n\t\t\t\tonConnectIntegration,\n\t\t\t),\n\t\t[\n\t\t\trequestToolAction,\n\t\t\tconfigToolTemplates,\n\t\t\tintegrationStatus,\n\t\t\tonConnectIntegration,\n\t\t],\n\t);\n\n\tconst registerInsert = useCallback(\n\t\t(fn: Parameters<typeof registerMentionField>[1]) =>\n\t\t\tregisterMentionField(fieldKey, fn),\n\t\t[registerMentionField, fieldKey],\n\t);\n\n\t// Route through the context's ref-backed `addReference`: BikEditor captures\n\t// this handler at mount, so reading `value.tools` here would keep only the last\n\t// pick. `addReference` always appends against the latest lists.\n\tconst onMentionSelect = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => addReference(kind, id),\n\t\t[addReference],\n\t);\n\n\treturn (\n\t\t<MentionEditor\n\t\t\tlabel={label}\n\t\t\tvalue={(value[fieldKey] as string | undefined) ?? ''}\n\t\t\tonChange={(text) => patch({ [fieldKey]: text } as Partial<AgentValue>)}\n\t\t\tmaxLength={maxLength}\n\t\t\tplaceholder={placeholder}\n\t\t\tminHeight={minHeight}\n\t\t\tresetKey={`${value.id}:${fieldKey}:${mentionResetKey}`}\n\t\t\tmentionItems={mentionItems}\n\t\t\ttools={availableTools}\n\t\t\tonMentionSelect={onMentionSelect}\n\t\t\tonFocus={() => notifyMentionFocus(fieldKey)}\n\t\t\tregisterInsert={registerInsert}\n\t\t\tonCreateSubAgent={onCreateSubAgent ? requestCreateSubAgent : undefined}\n\t\t\ttoolActions={toolActions}\n\t\t\tintegrationStatus={integrationStatus}\n\t\t\tonConnectIntegration={onConnectIntegration}\n\t\t\tvariablesData={variablesData}\n\t\t\tdata-test={rest['data-test']}\n\t\t/>\n\t);\n};\n"],"names":["MentionField","fieldKey","label","placeholder","maxLength","minHeight","rest","value","patch","addReference","availableTools","availableSubAgents","applicationType","mentionResetKey","registerMentionField","notifyMentionFocus","onCreateSubAgent","requestCreateSubAgent","requestToolAction","configToolTemplates","integrationStatus","onConnectIntegration","variablesData","useAgentBuilderContext","mentionItems","useMemo","buildAgentMentionItems","appTypeLabel","buildCustomToolMentionItems","toolActions","buildToolActions","registerInsert","useCallback","fn","onMent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gBAAA4B;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,OAAApC;AAAA,MACA,OAAQK,EAAMN,CAAQ,KAA4B;AAAA,MAClD,UAAU,CAACsC,MAAS/B,EAAM,EAAE,CAACP,CAAQ,GAAGsC,GAA6B;AAAA,MACrE,WAAAnC;AAAA,MACA,aAAAD;AAAA,MACA,WAAAE;AAAA,MACA,UAAU,GAAGE,EAAM,EAAE,IAAIN,CAAQ,IAAIY,CAAe;AAAA,MACpD,cAAAW;AAAA,MACA,OAAOd;AAAA,MACP,iBAAAwB;AAAA,MACA,SAAS,MAAMnB,EAAmBd,CAAQ;AAAA,MAC1C,gBAAA8B;AAAA,MACA,kBAAkBf,IAAmBC,IAAwB;AAAA,MAC7D,aAAAY;AAAA,MACA,mBAAAT;AAAA,MACA,sBAAAC;AAAA,MACA,eAAAC;AAAA,MACA,aAAWhB,EAAK,WAAW;AAAA,IAAA;AAAA,EAAA;AAG9B;"}
1
+ {"version":3,"file":"MentionField.js","sources":["../../../../../src/components/agent-builder/components/MentionField.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from 'react';\nimport { AgentValue } from '../AgentBuilder.model';\nimport { ToolAction } from '../constants/tools';\nimport {\n\tMentionFieldKey,\n\tuseAgentBuilderContext,\n} from '../context/AgentBuilderContext';\nimport {\n\tappTypeLabel,\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n} from '../utils/mentionSerialization';\nimport { buildToolActions } from '../utils/toolActions';\nimport { MentionEditor } from './MentionEditor';\n\ninterface MentionFieldProps {\n\t/** Which AgentValue field this editor reads / writes. */\n\tfieldKey: MentionFieldKey;\n\tlabel: string;\n\tplaceholder?: string;\n\tmaxLength: number;\n\tminHeight?: string;\n\t'data-test'?: string;\n}\n\n/**\n * Context-bound {@link MentionEditor} for the builder's Step-3 Instructions /\n * Guardrails. Both `@` tools and sub-agents are offered; the field registers its\n * insert + focus with the context so side-panel adds drop a chip into whichever\n * field was last focused, and remounts on `mentionResetKey`.\n */\nexport const MentionField: React.FC<MentionFieldProps> = ({\n\tfieldKey,\n\tlabel,\n\tplaceholder,\n\tmaxLength,\n\tminHeight,\n\t...rest\n}) => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\taddReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tapplicationType,\n\t\tmentionResetKey,\n\t\tregisterMentionField,\n\t\tnotifyMentionFocus,\n\t\tonCreateSubAgent,\n\t\trequestCreateSubAgent,\n\t\trequestToolAction,\n\t\tconfigToolTemplates,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t\tvariablesData,\n\t} = useAgentBuilderContext();\n\n\t// Catalog tools + sub-agents, PLUS the inline custom tools (Rest API / email /\n\t// Slack) so their `{{tool:<id>}}` tokens rehydrate as chips on remount — they\n\t// live on the value, not in `availableTools`.\n\tconst mentionItems = useMemo(\n\t\t() => [\n\t\t\t...buildAgentMentionItems(\n\t\t\t\tavailableTools,\n\t\t\t\tavailableSubAgents,\n\t\t\t\tappTypeLabel(applicationType),\n\t\t\t),\n\t\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t\t],\n\t\t[\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tapplicationType,\n\t\t\tvalue.configTools,\n\t\t\tvalue.restApiTools,\n\t\t],\n\t);\n\n\t// Built-in tool actions (Rest API / email / Slack) shown in the `@` picker's\n\t// Tools view — picking one opens its drawer (Step 3) instead of inserting text.\n\t// The shared email / Slack forms are backend-driven: each is offered only when\n\t// its template was provided.\n\tconst toolActions = useMemo<ToolAction[]>(\n\t\t() =>\n\t\t\tbuildToolActions(\n\t\t\t\tconfigToolTemplates,\n\t\t\t\trequestToolAction,\n\t\t\t\tintegrationStatus,\n\t\t\t\tonConnectIntegration,\n\t\t\t),\n\t\t[\n\t\t\trequestToolAction,\n\t\t\tconfigToolTemplates,\n\t\t\tintegrationStatus,\n\t\t\tonConnectIntegration,\n\t\t],\n\t);\n\n\tconst registerInsert = useCallback(\n\t\t(fn: Parameters<typeof registerMentionField>[1]) =>\n\t\t\tregisterMentionField(fieldKey, fn),\n\t\t[registerMentionField, fieldKey],\n\t);\n\n\t// Route through the context's ref-backed `addReference`: BikEditor captures\n\t// this handler at mount, so reading `value.tools` here would keep only the last\n\t// pick. `addReference` always appends against the latest lists.\n\tconst onMentionSelect = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => addReference(kind, id),\n\t\t[addReference],\n\t);\n\n\treturn (\n\t\t<MentionEditor\n\t\t\tlabel={label}\n\t\t\tvalue={(value[fieldKey] as string | undefined) ?? ''}\n\t\t\tonChange={(text) => patch({ [fieldKey]: text } as Partial<AgentValue>)}\n\t\t\tmaxLength={maxLength}\n\t\t\tplaceholder={placeholder}\n\t\t\tminHeight={minHeight}\n\t\t\tresetKey={`${value.id}:${fieldKey}:${mentionResetKey}`}\n\t\t\tmentionItems={mentionItems}\n\t\t\ttools={availableTools}\n\t\t\tonMentionSelect={onMentionSelect}\n\t\t\tonFocus={() => notifyMentionFocus(fieldKey)}\n\t\t\tregisterInsert={registerInsert}\n\t\t\tonCreateSubAgent={onCreateSubAgent ? requestCreateSubAgent : undefined}\n\t\t\ttoolActions={toolActions}\n\t\t\tintegrationStatus={integrationStatus}\n\t\t\tonConnectIntegration={onConnectIntegration}\n\t\t\tvariablesData={variablesData}\n\t\t\t// Step-3 fields get the floating \"+ Add data\" pill (same as typing @).\n\t\t\taddDataButton\n\t\t\tdata-test={rest['data-test']}\n\t\t/>\n\t);\n};\n"],"names":["MentionField","fieldKey","label","placeholder","maxLength","minHeight","rest","value","patch","addReference","availableTools","availableSubAgents","applicationType","mentionResetKey","registerMentionField","notifyMentionFocus","onCreateSubAgent","requestCreateSubAgent","requestToolAction","configToolTemplates","integrationStatus","onConnectIntegration","variablesData","useAgentBuilderContext","mentionItems","useMemo","buildAgentMentionItems","appTypeLabel","buildCustomToolMentionItems","toolActions","buildToolActions","registerInsert","useCallback","fn","onMentionSelect","kind","id","jsx","MentionEditor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AA,IAAA;AAAA,MACA,OAAApC;AAAA,MACA,OAAQK,EAAMN,CAAQ,KAA4B;AAAA,MAClD,UAAU,CAACsC,MAAS/B,EAAM,EAAE,CAACP,CAAQ,GAAGsC,GAA6B;AAAA,MACrE,WAAAnC;AAAA,MACA,aAAAD;AAAA,MACA,WAAAE;AAAA,MACA,UAAU,GAAGE,EAAM,EAAE,IAAIN,CAAQ,IAAIY,CAAe;AAAA,MACpD,cAAAW;AAAA,MACA,OAAOd;AAAA,MACP,iBAAAwB;AAAA,MACA,SAAS,MAAMnB,EAAmBd,CAAQ;AAAA,MAC1C,gBAAA8B;AAAA,MACA,kBAAkBf,IAAmBC,IAAwB;AAAA,MAC7D,aAAAY;AAAA,MACA,mBAAAT;AAAA,MACA,sBAAAC;AAAA,MACA,eAAAC;AAAA,MAEA,eAAa;AAAA,MACb,aAAWhB,EAAK,WAAW;AAAA,IAAA;AAAA,EAAA;AAG9B;"}
@@ -1,7 +1,7 @@
1
1
  import { jsxs as d, jsx as t } from "react/jsx-runtime";
2
2
  import K from "../../../assets/icons/delete.svg.js";
3
3
  import Q from "../../../assets/icons/plus.svg.js";
4
- import { useState as l, useRef as D } from "react";
4
+ import { useState as l, useRef as $ } from "react";
5
5
  import b from "styled-components";
6
6
  import { TitleSmall as u } from "../../TypographyStyle.js";
7
7
  import { COLORS as i } from "../../../constants/Theme.js";
@@ -19,7 +19,7 @@ import { BikEditor as q } from "../../../editor/BikEditor.js";
19
19
  const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
20
20
  label: s,
21
21
  value: s
22
- })), M = (s, y) => (y.textBefore.match(new RegExp('(?<!\\\\)"', "g"))?.length ?? 0) % 2 === 1 ? s : `"${s}"`, Be = ({
22
+ })), M = (s, y) => (y.textBefore.match(new RegExp('(?<!\\\\)"', "g"))?.length ?? 0) % 2 === 1 ? s : `"${s}"`, Ae = ({
23
23
  onClose: s,
24
24
  onSave: y,
25
25
  initial: n,
@@ -29,17 +29,17 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
29
29
  existingNames: z = [],
30
30
  variablesData: c
31
31
  }) => {
32
- const [x, F] = l(n?.name ?? ""), E = D(null), H = D(null), [w, G] = l(n?.instructions ?? ""), [T, k] = l(n?.url ?? "https://"), [g, J] = l(
32
+ const [x, F] = l(n?.name ?? ""), E = $(null), H = $(null), [w, G] = l(n?.instructions ?? ""), [T, B] = l(n?.url ?? "https://"), [g, J] = l(
33
33
  n?.method ?? "POST"
34
- ), [A, v] = l(
34
+ ), [k, v] = l(
35
35
  n?.headers ?? [{ key: "", value: "" }]
36
- ), [B, U] = l(n?.requestBody ?? ""), [P, W] = l(
36
+ ), [A, U] = l(n?.requestBody ?? ""), [D, W] = l(
37
37
  n?.responseSample ?? ""
38
- ), [L, O] = l(!1), S = (e, r) => v(
38
+ ), [P, L] = l(!1), S = (e, r) => v(
39
39
  (o) => o.map((a, m) => m === e ? { ...a, ...r } : a)
40
40
  ), Y = () => v((e) => [...e, { key: "", value: "" }]), V = (e) => v((r) => r.filter((o, a) => a !== e)), C = x.trim(), R = C.length > 0 && z.some(
41
41
  (e) => e.trim().toLowerCase() === C.toLowerCase()
42
- ), $ = C.length > 0 && T.trim().length > 0 && !R;
42
+ ), O = C.length > 0 && T.trim().length > 0 && !R;
43
43
  return /* @__PURE__ */ d(
44
44
  oe,
45
45
  {
@@ -62,10 +62,10 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
62
62
  buttonText: "Save",
63
63
  buttonType: "primary",
64
64
  size: "small",
65
- disabled: !$,
66
- isLoading: L,
65
+ disabled: !O,
66
+ isLoading: P,
67
67
  onClick: async () => {
68
- if (!$ || L)
68
+ if (!O || P)
69
69
  return;
70
70
  const e = {
71
71
  id: n?.id ?? `restapi_${Date.now().toString(36)}`,
@@ -74,16 +74,16 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
74
74
  url: T.trim(),
75
75
  method: g,
76
76
  // Drop fully-empty header rows.
77
- headers: A.filter((o) => o.key.trim() || o.value.trim()),
78
- requestBody: B,
79
- responseSample: P
77
+ headers: k.filter((o) => o.key.trim() || o.value.trim()),
78
+ requestBody: A,
79
+ responseSample: D
80
80
  }, r = y(e);
81
81
  if (r && typeof r.then == "function") {
82
- O(!0);
82
+ L(!0);
83
83
  try {
84
84
  await r;
85
85
  } finally {
86
- O(!1);
86
+ L(!1);
87
87
  }
88
88
  }
89
89
  }
@@ -127,8 +127,9 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
127
127
  /* @__PURE__ */ t(p, { children: /* @__PURE__ */ t(
128
128
  h,
129
129
  {
130
+ addDataButton: !0,
130
131
  variablesData: c,
131
- onInsert: (e, r) => k((o) => {
132
+ onInsert: (e, r) => B((o) => {
132
133
  const a = r ?? o.length;
133
134
  return `${o.slice(0, a)}${e}${o.slice(a)}`;
134
135
  }),
@@ -142,7 +143,7 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
142
143
  placeholder: "https://",
143
144
  type: "url",
144
145
  value: T,
145
- onChangeText: k
146
+ onChangeText: B
146
147
  }
147
148
  )
148
149
  }
@@ -167,7 +168,7 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
167
168
  ] }),
168
169
  /* @__PURE__ */ d(p, { children: [
169
170
  /* @__PURE__ */ t(u, { color: i.content.primary, children: "Headers" }),
170
- A.map((e, r) => (
171
+ k.map((e, r) => (
171
172
  // eslint-disable-next-line react/no-array-index-key
172
173
  /* @__PURE__ */ d(de, { "data-test": `restapi-header-${r}`, children: [
173
174
  /* @__PURE__ */ t(
@@ -183,6 +184,7 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
183
184
  /* @__PURE__ */ t(
184
185
  h,
185
186
  {
187
+ addDataButton: !0,
186
188
  variablesData: c,
187
189
  onInsert: (o, a) => {
188
190
  const m = a ?? e.value.length;
@@ -238,6 +240,7 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
238
240
  /* @__PURE__ */ t(
239
241
  h,
240
242
  {
243
+ addDataButton: !0,
241
244
  variablesData: c,
242
245
  transformToken: M,
243
246
  onInsert: (e) => E.current?.insertInlineContent(e),
@@ -246,7 +249,7 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
246
249
  {
247
250
  ref: E,
248
251
  features: { jsonMode: !0 },
249
- initialContent: B,
252
+ initialContent: A,
250
253
  style: _,
251
254
  placeholder: "Type or paste JSON here",
252
255
  onChange: (e) => U(e.text),
@@ -262,6 +265,7 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
262
265
  /* @__PURE__ */ t(
263
266
  h,
264
267
  {
268
+ addDataButton: !0,
265
269
  variablesData: c,
266
270
  transformToken: M,
267
271
  onInsert: (e) => H.current?.insertInlineContent(e),
@@ -271,7 +275,7 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
271
275
  ref: H,
272
276
  features: { jsonMode: !0 },
273
277
  style: _,
274
- initialContent: P,
278
+ initialContent: D,
275
279
  placeholder: "Type or paste JSON here",
276
280
  onChange: (e) => W(e.text),
277
281
  minHeight: "120px",
@@ -311,7 +315,7 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
311
315
  };
312
316
  export {
313
317
  _ as JsonFieldBox,
314
- Be as RestApiToolPanel,
318
+ Ae as RestApiToolPanel,
315
319
  M as jsonQuoteToken
316
320
  };
317
321
  //# sourceMappingURL=RestApiToolPanel.js.map