@bikdotai/bik-component-library 0.0.849-beta.2 → 0.0.849
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 +28 -16
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +2 -2
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.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/MentionField.js +1 -1
- package/dist/cjs/components/agent-builder/components/MentionField.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionPicker.js +11 -11
- package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/RequireVerificationModal.js +1 -1
- package/dist/cjs/components/agent-builder/components/RequireVerificationModal.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js +1 -1
- package/dist/cjs/components/agent-builder/components/SelectableListSection.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/Step3HowItResponds.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +4 -4
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.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/editor/BikEditor.styles.js +0 -6
- package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
- package/dist/cjs/icons/Informational/Common UI/ShieldOutline.js +2 -0
- package/dist/cjs/icons/Informational/Common UI/ShieldOutline.js.map +1 -0
- package/dist/cjs/icons/index.js +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.js +69 -71
- package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.model.d.ts +0 -8
- package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +3 -0
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js +46 -33
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.d.ts +0 -3
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +110 -113
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +0 -7
- package/dist/esm/components/agent-builder/components/MentionEditor.js +74 -89
- package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionField.js +26 -28
- package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.d.ts +1 -14
- package/dist/esm/components/agent-builder/components/MentionPicker.js +138 -167
- package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/esm/components/agent-builder/components/RequireVerificationModal.js +5 -5
- package/dist/esm/components/agent-builder/components/RequireVerificationModal.js.map +1 -1
- package/dist/esm/components/agent-builder/components/SelectableListSection.js +72 -63
- package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/esm/components/agent-builder/constants/tools.d.ts +1 -1
- package/dist/esm/components/agent-builder/constants/tools.js +5 -6
- package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +0 -7
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +96 -99
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +174 -165
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/mentionSerialization.d.ts +4 -14
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js +38 -50
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentTableRow.js +1 -1
- package/dist/esm/components/agent-listing/AgentTableRow.js.map +1 -1
- package/dist/esm/editor/BikEditor.styles.js +0 -6
- package/dist/esm/editor/BikEditor.styles.js.map +1 -1
- package/dist/esm/icons/Informational/Common UI/ShieldOutline.d.ts +7 -0
- package/dist/esm/icons/Informational/Common UI/ShieldOutline.js +35 -0
- package/dist/esm/icons/Informational/Common UI/ShieldOutline.js.map +1 -0
- package/dist/esm/icons/Informational/Common UI/index.d.ts +1 -0
- package/dist/esm/icons/index.d.ts +25 -25
- package/dist/esm/icons/index.js +172 -170
- package/dist/esm/icons/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,127 +1,112 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { TitleSmall as
|
|
1
|
+
import { jsxs as i, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as w, useState as F, useCallback as N, useEffect as p, useMemo as _ } from "react";
|
|
3
|
+
import { TitleSmall as G, BodyCaption as J } from "../../TypographyStyle.js";
|
|
4
4
|
import { COLORS as h } from "../../../constants/Theme.js";
|
|
5
|
-
import { FieldBlock as
|
|
6
|
-
import { AGENT_EDITOR_STYLE as
|
|
7
|
-
import {
|
|
8
|
-
import { MentionPicker as
|
|
9
|
-
import { BikEditor as
|
|
10
|
-
const
|
|
11
|
-
label:
|
|
12
|
-
value:
|
|
13
|
-
onChange:
|
|
14
|
-
maxLength:
|
|
15
|
-
placeholder:
|
|
16
|
-
minHeight:
|
|
17
|
-
resetKey:
|
|
18
|
-
mentionItems:
|
|
19
|
-
tools:
|
|
20
|
-
onMentionSelect:
|
|
21
|
-
onFocus:
|
|
22
|
-
registerInsert:
|
|
23
|
-
onCreateSubAgent:
|
|
24
|
-
toolActions:
|
|
25
|
-
integrationStatus:
|
|
26
|
-
onConnectIntegration:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
...V
|
|
5
|
+
import { FieldBlock as P, FieldLabelRow as Y, AiTextAreaShell as $ } from "../AgentBuilder.styled.js";
|
|
6
|
+
import { AGENT_EDITOR_STYLE as q } from "../constants/editorStyle.js";
|
|
7
|
+
import { buildMentionHtml as z, instructionsToEditorHtml as Q, editorDocToInstructions as U } from "../utils/mentionSerialization.js";
|
|
8
|
+
import { MentionPicker as V } from "./MentionPicker.js";
|
|
9
|
+
import { BikEditor as W } from "../../../editor/BikEditor.js";
|
|
10
|
+
const it = ({
|
|
11
|
+
label: S,
|
|
12
|
+
value: e,
|
|
13
|
+
onChange: g,
|
|
14
|
+
maxLength: a,
|
|
15
|
+
placeholder: C,
|
|
16
|
+
minHeight: T = "200px",
|
|
17
|
+
resetKey: l,
|
|
18
|
+
mentionItems: n,
|
|
19
|
+
tools: b,
|
|
20
|
+
onMentionSelect: x,
|
|
21
|
+
onFocus: E,
|
|
22
|
+
registerInsert: r,
|
|
23
|
+
onCreateSubAgent: k,
|
|
24
|
+
toolActions: H,
|
|
25
|
+
integrationStatus: O,
|
|
26
|
+
onConnectIntegration: R,
|
|
27
|
+
action: D,
|
|
28
|
+
...L
|
|
30
29
|
}) => {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`${g(
|
|
35
|
-
n,
|
|
36
|
-
`Variable: ${t.displayName}`,
|
|
37
|
-
"variable"
|
|
38
|
-
)} `
|
|
39
|
-
);
|
|
40
|
-
}, []), u = b(
|
|
41
|
-
(t, n, $) => {
|
|
42
|
-
const f = i.current;
|
|
30
|
+
const c = w(null), [M, m] = F(e.length), s = N(
|
|
31
|
+
(t, o, A) => {
|
|
32
|
+
const f = c.current;
|
|
43
33
|
if (!f)
|
|
44
34
|
return;
|
|
45
|
-
const
|
|
46
|
-
(
|
|
47
|
-
),
|
|
35
|
+
const B = n.find(
|
|
36
|
+
(u) => String(u.id) === String(o) && u.meta?.kind === t
|
|
37
|
+
), j = A ?? B?.label ?? o;
|
|
48
38
|
f.insertInlineContent(
|
|
49
|
-
`${
|
|
39
|
+
`${z(String(o), j, t)} `
|
|
50
40
|
);
|
|
51
41
|
},
|
|
52
|
-
[
|
|
42
|
+
[n]
|
|
53
43
|
);
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
return
|
|
57
|
-
}, [
|
|
58
|
-
const
|
|
59
|
-
() =>
|
|
60
|
-
...o,
|
|
61
|
-
...X(d)
|
|
62
|
-
]),
|
|
44
|
+
p(() => {
|
|
45
|
+
if (r)
|
|
46
|
+
return r(s), () => r(null);
|
|
47
|
+
}, [r, s]);
|
|
48
|
+
const y = _(
|
|
49
|
+
() => Q(e, n),
|
|
63
50
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
-
[
|
|
51
|
+
[l]
|
|
65
52
|
);
|
|
66
|
-
return
|
|
67
|
-
() => m(
|
|
53
|
+
return p(
|
|
54
|
+
() => m(e.length),
|
|
68
55
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
69
|
-
[
|
|
70
|
-
), /* @__PURE__ */
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
|
|
56
|
+
[l]
|
|
57
|
+
), /* @__PURE__ */ i(P, { children: [
|
|
58
|
+
/* @__PURE__ */ i(Y, { children: [
|
|
59
|
+
/* @__PURE__ */ d(G, { color: h.content.primary, children: S }),
|
|
60
|
+
/* @__PURE__ */ i(J, { color: h.content.secondary, children: [
|
|
61
|
+
M,
|
|
75
62
|
"/",
|
|
76
|
-
|
|
63
|
+
a
|
|
77
64
|
] })
|
|
78
65
|
] }),
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
|
|
66
|
+
/* @__PURE__ */ i($, { minHeight: T, "data-test": L["data-test"], children: [
|
|
67
|
+
/* @__PURE__ */ d(
|
|
68
|
+
W,
|
|
82
69
|
{
|
|
83
|
-
ref:
|
|
84
|
-
initialContent:
|
|
85
|
-
placeholder:
|
|
86
|
-
characterLimit:
|
|
70
|
+
ref: c,
|
|
71
|
+
initialContent: y,
|
|
72
|
+
placeholder: C,
|
|
73
|
+
characterLimit: a,
|
|
87
74
|
minHeight: "120px",
|
|
88
75
|
maxHeight: "320px",
|
|
89
76
|
style: { border: "none" },
|
|
90
|
-
editorStyle:
|
|
91
|
-
onFocus:
|
|
77
|
+
editorStyle: q,
|
|
78
|
+
onFocus: E,
|
|
92
79
|
mentions: {
|
|
93
|
-
agents:
|
|
80
|
+
agents: n,
|
|
94
81
|
removeTriggerOnDismiss: !0,
|
|
95
|
-
renderDropdown: (t) => /* @__PURE__ */
|
|
96
|
-
|
|
82
|
+
renderDropdown: (t) => /* @__PURE__ */ d(
|
|
83
|
+
V,
|
|
97
84
|
{
|
|
98
85
|
...t,
|
|
99
|
-
onCreateSubAgent:
|
|
100
|
-
toolActions:
|
|
101
|
-
integrationStatus:
|
|
102
|
-
onConnectIntegration:
|
|
103
|
-
variablesData: d,
|
|
104
|
-
onSelectVariable: B
|
|
86
|
+
onCreateSubAgent: k,
|
|
87
|
+
toolActions: H,
|
|
88
|
+
integrationStatus: O,
|
|
89
|
+
onConnectIntegration: R
|
|
105
90
|
}
|
|
106
91
|
),
|
|
107
92
|
onSelect: (t) => {
|
|
108
|
-
const
|
|
109
|
-
|
|
93
|
+
const o = t.meta?.kind;
|
|
94
|
+
o && x?.(o, String(t.id));
|
|
110
95
|
}
|
|
111
96
|
},
|
|
112
97
|
onChange: (t) => {
|
|
113
98
|
m(t.characterCount);
|
|
114
|
-
const
|
|
115
|
-
|
|
99
|
+
const o = c.current?.getJSON() ?? null;
|
|
100
|
+
g(U(o, b));
|
|
116
101
|
}
|
|
117
102
|
},
|
|
118
|
-
|
|
103
|
+
l
|
|
119
104
|
),
|
|
120
|
-
|
|
105
|
+
D
|
|
121
106
|
] })
|
|
122
107
|
] });
|
|
123
108
|
};
|
|
124
109
|
export {
|
|
125
|
-
|
|
110
|
+
it as MentionEditor
|
|
126
111
|
};
|
|
127
112
|
//# 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)} `,\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)} `,\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,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,kBAA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AC5C,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 { 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\teditorDocToInstructions,\n\tinstructionsToEditorHtml,\n\tMentionKindMeta,\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/** 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\taction,\n\t...rest\n}) => {\n\tconst editorRef = useRef<BikEditorRef>(null);\n\tconst [count, setCount] = useState(value.length);\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)} `,\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\tconst initialHtml = useMemo(\n\t\t() => instructionsToEditorHtml(value, mentionItems),\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/>\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\tif (kind) {\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","action","rest","editorRef","useRef","count","setCount","useState","insert","useCallback","kind","id","overrideLabel","editor","item","m","finalLabel","buildMentionHtml","useEffect","initialHtml","useMemo","instructionsToEditorHtml","FieldBlock","jsxs","FieldLabelRow","jsx","TitleSmall","COLORS","BodyCaption","AiTextAreaShell","BikEditor","AGENT_EDITOR_STYLE","props","MentionPicker","snapshot","doc","editorDocToInstructions"],"mappings":";;;;;;;;;AAqEO,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,iBA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A,QAAAtB;AAAA,QAAM;AAAA,QAAEjB;AAAA,MAAA,EAAA,CACV;AAAA,IAAA,GACD;AAAA,sBAECyC,GAAA,EAAgB,WAAAvC,GAAsB,aAAWY,EAAK,WAAW,GACjE,UAAA;AAAA,MAAA,gBAAAuB;AAAA,QAACK;AAAA,QAAA;AAAA,UAEA,KAAK3B;AAAA,UACL,gBAAgBgB;AAAA,UAChB,aAAA9B;AAAA,UAGA,gBAAgBD;AAAA,UAChB,WAAU;AAAA,UACV,WAAU;AAAA,UACV,OAAO,EAAE,QAAQ,OAAA;AAAA,UACjB,aAAa2C;AAAA,UACb,SAAApC;AAAA,UACA,UAAU;AAAA,YACT,QAAQH;AAAA,YACR,wBAAwB;AAAA,YACxB,gBAAgB,CAACwC,MAChB,gBAAAP;AAAA,cAACQ;AAAA,cAAA;AAAA,gBACC,GAAGD;AAAA,gBACJ,kBAAAnC;AAAA,gBACA,aAAAC;AAAA,gBACA,mBAAAC;AAAA,gBACA,sBAAAC;AAAA,cAAA;AAAA,YAAA;AAAA,YAGF,UAAU,CAACc,MAAS;AACnB,oBAAMJ,IAAQI,EAAK,MAChB;AACH,cAAIJ,KACHhB,IAAkBgB,GAAM,OAAOI,EAAK,EAAE,CAAC;AAAA,YAEzC;AAAA,UAAA;AAAA,UAED,UAAU,CAACoB,MAAa;AACvB,YAAA5B,EAAS4B,EAAS,cAAc;AAChC,kBAAMC,IAAMhC,EAAU,SAAS,QAAA,KAAa;AAC5C,YAAAhB,EAASiD,EAAwBD,GAAK1C,CAAK,CAAC;AAAA,UAC7C;AAAA,QAAA;AAAA,QApCKF;AAAA,MAAA;AAAA,MAsCLU;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACD;AAEF;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as R } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as p, useCallback as g } from "react";
|
|
3
|
-
import { useAgentBuilderContext as
|
|
4
|
-
import { buildAgentMentionItems as
|
|
3
|
+
import { useAgentBuilderContext as j } from "../context/AgentBuilderContext.js";
|
|
4
|
+
import { buildAgentMentionItems as k, appTypeLabel as B, 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
|
-
const
|
|
7
|
+
const N = ({
|
|
8
8
|
fieldKey: o,
|
|
9
|
-
label:
|
|
10
|
-
placeholder:
|
|
9
|
+
label: T,
|
|
10
|
+
placeholder: b,
|
|
11
11
|
maxLength: A,
|
|
12
12
|
minHeight: d,
|
|
13
13
|
...C
|
|
@@ -21,20 +21,19 @@ const O = ({
|
|
|
21
21
|
applicationType: l,
|
|
22
22
|
mentionResetKey: f,
|
|
23
23
|
registerMentionField: c,
|
|
24
|
-
notifyMentionFocus:
|
|
25
|
-
onCreateSubAgent:
|
|
24
|
+
notifyMentionFocus: S,
|
|
25
|
+
onCreateSubAgent: v,
|
|
26
26
|
requestCreateSubAgent: I,
|
|
27
27
|
requestToolAction: m,
|
|
28
28
|
configToolTemplates: u,
|
|
29
29
|
integrationStatus: s,
|
|
30
|
-
onConnectIntegration: i
|
|
31
|
-
|
|
32
|
-
} = k(), x = p(
|
|
30
|
+
onConnectIntegration: i
|
|
31
|
+
} = j(), F = p(
|
|
33
32
|
() => [
|
|
34
|
-
...
|
|
33
|
+
...k(
|
|
35
34
|
n,
|
|
36
35
|
a,
|
|
37
|
-
|
|
36
|
+
B(l)
|
|
38
37
|
),
|
|
39
38
|
...E(t.configTools, t.restApiTools)
|
|
40
39
|
],
|
|
@@ -45,7 +44,7 @@ const O = ({
|
|
|
45
44
|
t.configTools,
|
|
46
45
|
t.restApiTools
|
|
47
46
|
]
|
|
48
|
-
),
|
|
47
|
+
), x = p(
|
|
49
48
|
() => L(
|
|
50
49
|
u,
|
|
51
50
|
m,
|
|
@@ -58,38 +57,37 @@ const O = ({
|
|
|
58
57
|
s,
|
|
59
58
|
i
|
|
60
59
|
]
|
|
61
|
-
),
|
|
60
|
+
), $ = g(
|
|
62
61
|
(e) => c(o, e),
|
|
63
62
|
[c, o]
|
|
64
|
-
),
|
|
65
|
-
(e,
|
|
63
|
+
), h = g(
|
|
64
|
+
(e, q) => r(e, q),
|
|
66
65
|
[r]
|
|
67
66
|
);
|
|
68
|
-
return /* @__PURE__ */
|
|
67
|
+
return /* @__PURE__ */ R(
|
|
69
68
|
w,
|
|
70
69
|
{
|
|
71
|
-
label:
|
|
70
|
+
label: T,
|
|
72
71
|
value: t[o] ?? "",
|
|
73
72
|
onChange: (e) => M({ [o]: e }),
|
|
74
73
|
maxLength: A,
|
|
75
|
-
placeholder:
|
|
74
|
+
placeholder: b,
|
|
76
75
|
minHeight: d,
|
|
77
76
|
resetKey: `${t.id}:${o}:${f}`,
|
|
78
|
-
mentionItems:
|
|
77
|
+
mentionItems: F,
|
|
79
78
|
tools: n,
|
|
80
|
-
onMentionSelect:
|
|
81
|
-
onFocus: () =>
|
|
82
|
-
registerInsert:
|
|
83
|
-
onCreateSubAgent:
|
|
84
|
-
toolActions:
|
|
79
|
+
onMentionSelect: h,
|
|
80
|
+
onFocus: () => S(o),
|
|
81
|
+
registerInsert: $,
|
|
82
|
+
onCreateSubAgent: v ? I : void 0,
|
|
83
|
+
toolActions: x,
|
|
85
84
|
integrationStatus: s,
|
|
86
85
|
onConnectIntegration: i,
|
|
87
|
-
variablesData: F,
|
|
88
86
|
"data-test": C["data-test"]
|
|
89
87
|
}
|
|
90
88
|
);
|
|
91
89
|
};
|
|
92
90
|
export {
|
|
93
|
-
|
|
91
|
+
N as MentionField
|
|
94
92
|
};
|
|
95
93
|
//# sourceMappingURL=MentionField.js.map
|
|
@@ -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
|
|
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} = 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\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","useAgentBuilderContext","mentionItems","useMemo","buildAgentMentionItems","appTypeLabel","buildCustomToolMentionItems","toolActions","buildToolActions","registerInsert","useCallback","fn","onMentionSelect","kind","id","jsx","MentionEditor","text"],"mappings":";;;;;;AA+BO,MAAMA,IAA4C,CAAC;AAAA,EACzD,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACJ,MAAM;AACL,QAAM;AAAA,IACL,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,sBAAAC;AAAA,EAAA,IACGC,EAAA,GAKEC,IAAeC;AAAA,IACpB,MAAM;AAAA,MACL,GAAGC;AAAA,QACFf;AAAA,QACAC;AAAA,QACAe,EAAad,CAAe;AAAA,MAAA;AAAA,MAE7B,GAAGe,EAA4BpB,EAAM,aAAaA,EAAM,YAAY;AAAA,IAAA;AAAA,IAErE;AAAA,MACCG;AAAA,MACAC;AAAA,MACAC;AAAA,MACAL,EAAM;AAAA,MACNA,EAAM;AAAA,IAAA;AAAA,EACP,GAOKqB,IAAcJ;AAAA,IACnB,MACCK;AAAA,MACCV;AAAA,MACAD;AAAA,MACAE;AAAA,MACAC;AAAA,IAAA;AAAA,IAEF;AAAA,MACCH;AAAA,MACAC;AAAA,MACAC;AAAA,MACAC;AAAA,IAAA;AAAA,EACD,GAGKS,IAAiBC;AAAA,IACtB,CAACC,MACAlB,EAAqBb,GAAU+B,CAAE;AAAA,IAClC,CAAClB,GAAsBb,CAAQ;AAAA,EAAA,GAM1BgC,IAAkBF;AAAA,IACvB,CAACG,GAA2BC,MAAe1B,EAAayB,GAAMC,CAAE;AAAA,IAChE,CAAC1B,CAAY;AAAA,EAAA;AAGd,SACC,gBAAA2B;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,OAAAnC;AAAA,MACA,OAAQK,EAAMN,CAAQ,KAA4B;AAAA,MAClD,UAAU,CAACqC,MAAS9B,EAAM,EAAE,CAACP,CAAQ,GAAGqC,GAA6B;AAAA,MACrE,WAAAlC;AAAA,MACA,aAAAD;AAAA,MACA,WAAAE;AAAA,MACA,UAAU,GAAGE,EAAM,EAAE,IAAIN,CAAQ,IAAIY,CAAe;AAAA,MACpD,cAAAU;AAAA,MACA,OAAOb;AAAA,MACP,iBAAAuB;AAAA,MACA,SAAS,MAAMlB,EAAmBd,CAAQ;AAAA,MAC1C,gBAAA6B;AAAA,MACA,kBAAkBd,IAAmBC,IAAwB;AAAA,MAC7D,aAAAW;AAAA,MACA,mBAAAR;AAAA,MACA,sBAAAC;AAAA,MACA,aAAWf,EAAK,WAAW;AAAA,IAAA;AAAA,EAAA;AAG9B;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MentionDropdownRenderProps } from '../../../editor';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
-
import { VariableListInterfaceV3, VariableV3 } from '../../variable-picker-v3/model';
|
|
4
3
|
import { ToolAction, ToolSource } from '../constants/tools';
|
|
5
4
|
type MentionPickerProps = MentionDropdownRenderProps & {
|
|
6
5
|
/** Opens the create-sub-agent drawer (shows a "Create new" row in the Sub-agent view). */
|
|
@@ -24,24 +23,12 @@ type MentionPickerProps = MentionDropdownRenderProps & {
|
|
|
24
23
|
integrationStatus?: Partial<Record<ToolSource, boolean>>;
|
|
25
24
|
/** Open the connect flow for an unconnected source (used by the Connect row). */
|
|
26
25
|
onConnectIntegration?: (source: ToolSource) => void;
|
|
27
|
-
/**
|
|
28
|
-
* Variable catalog for the "Variables" view (the shared VariablePicker's
|
|
29
|
-
* `data`). Omitted / empty → the Variables category is not offered.
|
|
30
|
-
*/
|
|
31
|
-
variablesData?: VariableListInterfaceV3[];
|
|
32
|
-
/**
|
|
33
|
-
* A variable was picked from the Variables view. The picker dismisses itself
|
|
34
|
-
* (stripping the typed `@`) BEFORE calling this — the handler inserts a
|
|
35
|
-
* `Variable: <name>` mention chip (see MentionEditor).
|
|
36
|
-
*/
|
|
37
|
-
onSelectVariable?: (variable: VariableV3) => void;
|
|
38
26
|
};
|
|
39
27
|
/**
|
|
40
28
|
* `@` reference picker. Drills:
|
|
41
29
|
* root → Tools → <source> (Manifest / Shopify / …) → tool
|
|
42
30
|
* → Sub-agent → sub-agent
|
|
43
|
-
*
|
|
44
|
-
* ("Add condition" is intentionally not shown yet.)
|
|
31
|
+
* ("Add condition" and "Variables" are intentionally not shown yet.)
|
|
45
32
|
*
|
|
46
33
|
* Owns keyboard navigation (↑/↓ move, →/Enter activate, ← go back) over the
|
|
47
34
|
* CURRENTLY visible rows — registered with the editor via `registerKeyHandler`.
|