@bikdotai/bik-component-library 0.0.821-beta.8 → 0.0.821
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/assets/icons/Shopify.svg.js +2 -0
- package/dist/cjs/assets/icons/Shopify.svg.js.map +1 -0
- 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 +57 -23
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/GoLiveModal.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionEditor.js +1 -1
- package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/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 +37 -6
- package/dist/cjs/components/agent-builder/components/MentionPicker.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/charLimits.js +1 -1
- package/dist/cjs/components/agent-builder/constants/charLimits.js.map +1 -1
- package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
- package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +1 -1
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/cjs/components/agent-builder/utils/sourceIcons.js +2 -0
- package/dist/cjs/components/agent-builder/utils/sourceIcons.js.map +1 -0
- package/dist/cjs/components/agent-listing/AgentListing.js +1 -1
- package/dist/cjs/components/agent-listing/AgentListing.js.map +1 -1
- package/dist/cjs/components/agent-listing/AgentListingFilters.js +1 -1
- package/dist/cjs/components/agent-listing/AgentListingFilters.js.map +1 -1
- package/dist/cjs/editor/BikEditor.types.js.map +1 -1
- package/dist/cjs/editor/extensions/mention/MentionDropdown.js +1 -1
- package/dist/cjs/editor/extensions/mention/MentionDropdown.js.map +1 -1
- package/dist/cjs/editor/extensions/mention/MentionExtension.js +1 -1
- package/dist/cjs/editor/extensions/mention/MentionExtension.js.map +1 -1
- package/dist/esm/assets/icons/Shopify.svg.js +6 -0
- package/dist/esm/assets/icons/Shopify.svg.js.map +1 -0
- package/dist/esm/components/agent-builder/AgentBuilder.js +47 -47
- package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.model.d.ts +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +6 -0
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js +82 -42
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +84 -76
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/GoLiveModal.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +6 -0
- package/dist/esm/components/agent-builder/components/MentionEditor.js +31 -30
- package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionField.js +40 -37
- package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.d.ts +6 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.js +202 -101
- package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +18 -2
- package/dist/esm/components/agent-builder/components/SelectableListSection.js +159 -91
- package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/esm/components/agent-builder/constants/charLimits.d.ts +1 -1
- package/dist/esm/components/agent-builder/constants/charLimits.js +1 -1
- package/dist/esm/components/agent-builder/constants/charLimits.js.map +1 -1
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +7 -0
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +107 -99
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js +7 -7
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +131 -106
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js +2 -2
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/sourceIcons.d.ts +10 -0
- package/dist/esm/components/agent-builder/utils/sourceIcons.js +10 -0
- package/dist/esm/components/agent-builder/utils/sourceIcons.js.map +1 -0
- package/dist/esm/components/agent-listing/AgentListing.js +108 -101
- package/dist/esm/components/agent-listing/AgentListing.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentListing.model.d.ts +8 -0
- package/dist/esm/components/agent-listing/AgentListingFilters.d.ts +2 -0
- package/dist/esm/components/agent-listing/AgentListingFilters.js +37 -33
- package/dist/esm/components/agent-listing/AgentListingFilters.js.map +1 -1
- package/dist/esm/editor/BikEditor.types.d.ts +7 -0
- package/dist/esm/editor/BikEditor.types.js.map +1 -1
- package/dist/esm/editor/extensions/mention/MentionDropdown.d.ts +2 -0
- package/dist/esm/editor/extensions/mention/MentionDropdown.js +21 -20
- package/dist/esm/editor/extensions/mention/MentionDropdown.js.map +1 -1
- package/dist/esm/editor/extensions/mention/MentionExtension.js +66 -55
- package/dist/esm/editor/extensions/mention/MentionExtension.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,63 +1,71 @@
|
|
|
1
|
-
import { jsxs as a, Fragment as
|
|
2
|
-
import
|
|
3
|
-
import { useState as r, useMemo as
|
|
4
|
-
import { TitleRegular as
|
|
1
|
+
import { jsxs as a, Fragment as et, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import nt from "../../../assets/icons/cross.svg.js";
|
|
3
|
+
import ot, { useState as r, useMemo as rt, useRef as p, useCallback as l } from "react";
|
|
4
|
+
import { TitleRegular as st, BodySecondary as it } from "../../TypographyStyle.js";
|
|
5
5
|
import { COLORS as A } from "../../../constants/Theme.js";
|
|
6
|
-
import { SubAgentScrim as
|
|
6
|
+
import { SubAgentScrim as at, SubAgentPanel as lt, SubAgentPanelHeader as ct, SubAgentPanelHeaderText as ut, SubAgentCloseButton as dt, SubAgentPanelBody as mt, SubAgentPanelFooter as gt } from "../AgentBuilder.styled.js";
|
|
7
7
|
import { AGENT_CHAR_LIMITS as v } from "../constants/charLimits.js";
|
|
8
|
-
import { buildAgentMentionItems as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
8
|
+
import { buildAgentMentionItems as pt } from "../utils/mentionSerialization.js";
|
|
9
|
+
import { SOURCE_ICONS as H } from "../utils/sourceIcons.js";
|
|
10
|
+
import { MentionEditor as K } from "./MentionEditor.js";
|
|
11
|
+
import { SelectableListSection as ht } from "./SelectableListSection.js";
|
|
12
|
+
import { Input as ft } from "../../input/Input.js";
|
|
13
|
+
import { Button as w } from "../../button/Button.js";
|
|
14
|
+
import { Toaster as bt } from "../../toaster/Toaster.js";
|
|
15
|
+
const Gt = ({
|
|
15
16
|
onClose: h,
|
|
16
17
|
onSave: F,
|
|
17
18
|
availableTools: i,
|
|
18
|
-
onImprove:
|
|
19
|
-
title:
|
|
19
|
+
onImprove: yt,
|
|
20
|
+
title: N = "Create sub-agent",
|
|
20
21
|
initial: c,
|
|
21
|
-
appLabel:
|
|
22
|
+
appLabel: R = "Manifest"
|
|
22
23
|
}) => {
|
|
23
|
-
const [f, j] = r(c?.name ?? ""), [u, b] = r(c?.instructions ?? ""), [d, y] = r(c?.guardrail ?? ""), [S, m] = r(c?.tools ?? []), [
|
|
24
|
-
() =>
|
|
25
|
-
[i,
|
|
24
|
+
const [f, j] = r(c?.name ?? ""), [u, b] = r(c?.instructions ?? ""), [d, y] = r(c?.guardrail ?? ""), [S, m] = r(c?.tools ?? []), [_, P] = r(!1), [U, k] = r(0), [$, B] = r(0), [St, Ct] = r(null), M = rt(
|
|
25
|
+
() => pt(i, [], R),
|
|
26
|
+
[i, R]
|
|
26
27
|
), g = p({}), C = p("instructions"), z = l((t) => {
|
|
27
28
|
g.current.instructions = t ?? void 0;
|
|
28
|
-
}, []),
|
|
29
|
+
}, []), W = l((t) => {
|
|
29
30
|
g.current.guardrail = t ?? void 0;
|
|
30
|
-
}, []), W = l(() => {
|
|
31
|
-
C.current = "instructions";
|
|
32
31
|
}, []), q = l(() => {
|
|
32
|
+
C.current = "instructions";
|
|
33
|
+
}, []), D = l(() => {
|
|
33
34
|
C.current = "guardrail";
|
|
34
|
-
}, []),
|
|
35
|
+
}, []), E = l(
|
|
35
36
|
(t, e) => {
|
|
36
37
|
t === "tool" && m((s) => s.includes(e) ? s : [...s, e]);
|
|
37
38
|
},
|
|
38
39
|
[]
|
|
39
|
-
),
|
|
40
|
+
), J = l((t) => {
|
|
40
41
|
(g.current[C.current] ?? g.current.instructions)?.("tool", t);
|
|
41
42
|
}, []), [x, T] = r(
|
|
42
43
|
null
|
|
43
|
-
), I = p(null),
|
|
44
|
-
const e = i.find((n) => n.tool_id === t), s = e ? `{{tool:${e.function_key}}}` : null,
|
|
45
|
-
I.current = { instructions: u, guardrail: d, tools: S }, b((n) =>
|
|
46
|
-
id:
|
|
47
|
-
message: `Tool "${e?.
|
|
44
|
+
), I = p(null), L = p(0), Q = (t) => {
|
|
45
|
+
const e = i.find((n) => n.tool_id === t), s = e ? `{{tool:${e.function_key}}}` : null, G = (n) => s ? n.split(s).join("") : n;
|
|
46
|
+
I.current = { instructions: u, guardrail: d, tools: S }, b((n) => G(n)), y((n) => G(n)), m((n) => n.filter((tt) => tt !== t)), k((n) => n + 1), B((n) => n + 1), L.current += 1, T({
|
|
47
|
+
id: L.current,
|
|
48
|
+
message: `Tool "${e?.display_name ?? "Tool"}" removed`
|
|
48
49
|
});
|
|
49
|
-
},
|
|
50
|
+
}, V = () => {
|
|
50
51
|
const t = I.current;
|
|
51
|
-
t && (b(t.instructions), y(t.guardrail), m(t.tools),
|
|
52
|
-
},
|
|
52
|
+
t && (b(t.instructions), y(t.guardrail), m(t.tools), k((e) => e + 1), B((e) => e + 1), I.current = null), T(null);
|
|
53
|
+
}, O = f.trim().length > 0 && (u.trim().length > 0 || d.trim().length > 0), X = S.map((t) => {
|
|
53
54
|
const e = i.find((s) => s.tool_id === t);
|
|
54
|
-
return e ? {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})), Y =
|
|
60
|
-
|
|
55
|
+
return e ? {
|
|
56
|
+
id: t,
|
|
57
|
+
label: e.display_name,
|
|
58
|
+
icon: H[e.source ?? "manifest"]
|
|
59
|
+
} : null;
|
|
60
|
+
}).filter((t) => t !== null), Y = i.map((t) => {
|
|
61
|
+
const e = H[t.source ?? "manifest"];
|
|
62
|
+
return {
|
|
63
|
+
label: t.display_name,
|
|
64
|
+
value: t.tool_id,
|
|
65
|
+
leadingIcon: e ? ot.createElement(e.Icon, { width: e.w, height: e.h }) : void 0
|
|
66
|
+
};
|
|
67
|
+
}), Z = async () => {
|
|
68
|
+
if (!O || _)
|
|
61
69
|
return;
|
|
62
70
|
const t = F({
|
|
63
71
|
name: f.trim(),
|
|
@@ -66,24 +74,24 @@ const Nt = ({
|
|
|
66
74
|
tools: S
|
|
67
75
|
});
|
|
68
76
|
if (t && typeof t.then == "function") {
|
|
69
|
-
|
|
77
|
+
P(!0);
|
|
70
78
|
try {
|
|
71
79
|
await t;
|
|
72
80
|
} finally {
|
|
73
|
-
|
|
81
|
+
P(!1);
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
84
|
};
|
|
77
|
-
return /* @__PURE__ */ a(
|
|
78
|
-
/* @__PURE__ */ o(
|
|
79
|
-
/* @__PURE__ */ a(
|
|
80
|
-
/* @__PURE__ */ a(
|
|
81
|
-
/* @__PURE__ */ a(
|
|
82
|
-
/* @__PURE__ */ o(
|
|
83
|
-
/* @__PURE__ */ o(
|
|
85
|
+
return /* @__PURE__ */ a(et, { children: [
|
|
86
|
+
/* @__PURE__ */ o(at, { onClick: h, "data-test": "subagent-scrim" }),
|
|
87
|
+
/* @__PURE__ */ a(lt, { "data-test": "create-subagent-panel", children: [
|
|
88
|
+
/* @__PURE__ */ a(ct, { children: [
|
|
89
|
+
/* @__PURE__ */ a(ut, { children: [
|
|
90
|
+
/* @__PURE__ */ o(st, { color: A.content.primary, children: N }),
|
|
91
|
+
/* @__PURE__ */ o(it, { color: A.content.secondary, children: "Each sub-agent handles one piece of the job. Use @ in the main instructions to call them." })
|
|
84
92
|
] }),
|
|
85
|
-
/* @__PURE__ */ o(
|
|
86
|
-
|
|
93
|
+
/* @__PURE__ */ o(dt, { onClick: h, "aria-label": "Close", children: /* @__PURE__ */ o(
|
|
94
|
+
nt,
|
|
87
95
|
{
|
|
88
96
|
width: 20,
|
|
89
97
|
height: 20,
|
|
@@ -91,9 +99,9 @@ const Nt = ({
|
|
|
91
99
|
}
|
|
92
100
|
) })
|
|
93
101
|
] }),
|
|
94
|
-
/* @__PURE__ */ a(
|
|
102
|
+
/* @__PURE__ */ a(mt, { children: [
|
|
95
103
|
/* @__PURE__ */ o(
|
|
96
|
-
|
|
104
|
+
ft,
|
|
97
105
|
{
|
|
98
106
|
"data-test": "subagent-name",
|
|
99
107
|
labelText: "Agent name",
|
|
@@ -107,7 +115,7 @@ const Nt = ({
|
|
|
107
115
|
}
|
|
108
116
|
),
|
|
109
117
|
/* @__PURE__ */ o(
|
|
110
|
-
|
|
118
|
+
K,
|
|
111
119
|
{
|
|
112
120
|
"data-test": "subagent-instructions",
|
|
113
121
|
label: "Instructions",
|
|
@@ -116,16 +124,16 @@ const Nt = ({
|
|
|
116
124
|
maxLength: v.instructions,
|
|
117
125
|
placeholder: "Write the steps in plain English. Type @ to reference a tool.",
|
|
118
126
|
minHeight: "160px",
|
|
119
|
-
resetKey: `instr-${
|
|
120
|
-
mentionItems:
|
|
127
|
+
resetKey: `instr-${U}`,
|
|
128
|
+
mentionItems: M,
|
|
121
129
|
tools: i,
|
|
122
|
-
onMentionSelect:
|
|
123
|
-
onFocus:
|
|
130
|
+
onMentionSelect: E,
|
|
131
|
+
onFocus: q,
|
|
124
132
|
registerInsert: z
|
|
125
133
|
}
|
|
126
134
|
),
|
|
127
135
|
/* @__PURE__ */ o(
|
|
128
|
-
|
|
136
|
+
K,
|
|
129
137
|
{
|
|
130
138
|
"data-test": "subagent-guardrail",
|
|
131
139
|
label: "Guardrails",
|
|
@@ -134,44 +142,44 @@ const Nt = ({
|
|
|
134
142
|
maxLength: v.guardrail,
|
|
135
143
|
placeholder: "e.g. Never discuss competitor pricing. Type @ to reference a tool.",
|
|
136
144
|
minHeight: "160px",
|
|
137
|
-
resetKey: `guard-${
|
|
138
|
-
mentionItems:
|
|
145
|
+
resetKey: `guard-${$}`,
|
|
146
|
+
mentionItems: M,
|
|
139
147
|
tools: i,
|
|
140
|
-
onMentionSelect:
|
|
141
|
-
onFocus:
|
|
142
|
-
registerInsert:
|
|
148
|
+
onMentionSelect: E,
|
|
149
|
+
onFocus: D,
|
|
150
|
+
registerInsert: W
|
|
143
151
|
}
|
|
144
152
|
),
|
|
145
153
|
/* @__PURE__ */ o(
|
|
146
|
-
|
|
154
|
+
ht,
|
|
147
155
|
{
|
|
148
156
|
title: "Tools this agent can use",
|
|
149
157
|
dataTestPrefix: "subagent-tools",
|
|
150
|
-
items:
|
|
151
|
-
addableOptions:
|
|
158
|
+
items: X,
|
|
159
|
+
addableOptions: Y,
|
|
152
160
|
emptyText: "No tools added yet.",
|
|
153
161
|
onAdd: (t) => {
|
|
154
|
-
|
|
162
|
+
J(t), m((e) => e.includes(t) ? e : [...e, t]);
|
|
155
163
|
},
|
|
156
|
-
onRemove:
|
|
164
|
+
onRemove: Q
|
|
157
165
|
}
|
|
158
166
|
)
|
|
159
167
|
] }),
|
|
160
|
-
/* @__PURE__ */ a(
|
|
168
|
+
/* @__PURE__ */ a(gt, { children: [
|
|
161
169
|
/* @__PURE__ */ o(
|
|
162
|
-
|
|
170
|
+
w,
|
|
163
171
|
{
|
|
164
172
|
"data-test": "subagent-save",
|
|
165
173
|
buttonType: "primary",
|
|
166
174
|
size: "small",
|
|
167
175
|
buttonText: "Save",
|
|
168
|
-
disabled: !
|
|
169
|
-
isLoading:
|
|
170
|
-
onClick:
|
|
176
|
+
disabled: !O,
|
|
177
|
+
isLoading: _,
|
|
178
|
+
onClick: Z
|
|
171
179
|
}
|
|
172
180
|
),
|
|
173
181
|
/* @__PURE__ */ o(
|
|
174
|
-
|
|
182
|
+
w,
|
|
175
183
|
{
|
|
176
184
|
"data-test": "subagent-cancel",
|
|
177
185
|
buttonType: "secondary",
|
|
@@ -183,7 +191,7 @@ const Nt = ({
|
|
|
183
191
|
] })
|
|
184
192
|
] }),
|
|
185
193
|
x && /* @__PURE__ */ o(
|
|
186
|
-
|
|
194
|
+
bt,
|
|
187
195
|
{
|
|
188
196
|
text: x.message,
|
|
189
197
|
type: "info",
|
|
@@ -193,7 +201,7 @@ const Nt = ({
|
|
|
193
201
|
buttonProps: {
|
|
194
202
|
buttonText: "Undo",
|
|
195
203
|
showButton: !0,
|
|
196
|
-
onButtonClick: () => (
|
|
204
|
+
onButtonClick: () => (V(), {})
|
|
197
205
|
},
|
|
198
206
|
onCloseToast: () => T(null)
|
|
199
207
|
},
|
|
@@ -202,6 +210,6 @@ const Nt = ({
|
|
|
202
210
|
] });
|
|
203
211
|
};
|
|
204
212
|
export {
|
|
205
|
-
|
|
213
|
+
Gt as CreateSubAgentPanel
|
|
206
214
|
};
|
|
207
215
|
//# sourceMappingURL=CreateSubAgentPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateSubAgentPanel.js","sources":["../../../../../src/components/agent-builder/components/CreateSubAgentPanel.tsx"],"sourcesContent":["import CrossIcon from '@src/assets/icons/cross.svg';\nimport React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { Button } from '@src/components/button';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Input } from '@src/components/input';\nimport { Toaster } from '@src/components/toaster';\nimport { BodySecondary, TitleRegular } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { AgentTool, SubAgentDraft } from '../AgentBuilder.model';\nimport {\n\tFieldActionRow,\n\tSubAgentCloseButton,\n\tSubAgentPanel,\n\tSubAgentPanelBody,\n\tSubAgentPanelFooter,\n\tSubAgentPanelHeader,\n\tSubAgentPanelHeaderText,\n\tSubAgentScrim,\n} from '../AgentBuilder.styled';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport { buildAgentMentionItems } from '../utils/mentionSerialization';\nimport { MentionEditor } from './MentionEditor';\nimport { SelectableItem, SelectableListSection } from './SelectableListSection';\n\ntype InsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;\n\ninterface CreateSubAgentPanelProps {\n\tonClose: () => void;\n\t/** Persist the draft. The drawer shows a loader while the returned promise is pending. */\n\tonSave: (draft: SubAgentDraft) => void | Promise<void>;\n\tavailableTools: AgentTool[];\n\t/** Optional \"Improve with AI\" for instructions / guardrails. Omit to hide the buttons. */\n\tonImprove?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\t/** Header title — \"Create sub-agent\" (default) or \"Edit sub-agent\". */\n\ttitle?: string;\n\t/** Initial values, e.g. when configuring an existing sub-agent. */\n\tinitial?: SubAgentDraft;\n\t/** Tool-source fallback label for chips (host app). */\n\tappLabel?: string;\n}\n\n/**\n * Right-side drawer for creating / editing a sub-agent (name, instructions,\n * guardrails, tools). Instructions & Guardrails are `@`-mention editors (tools\n * only — sub-agents can't nest); adding a tool from the list inserts it at the\n * last-focused field's cursor. Mount it fresh per open (key it) so `initial`\n * seeds the draft.\n */\nexport const CreateSubAgentPanel: React.FC<CreateSubAgentPanelProps> = ({\n\tonClose,\n\tonSave,\n\tavailableTools,\n\tonImprove,\n\ttitle = 'Create sub-agent',\n\tinitial,\n\tappLabel = 'Manifest',\n}) => {\n\tconst [name, setName] = useState(initial?.name ?? '');\n\tconst [instructions, setInstructions] = useState(initial?.instructions ?? '');\n\tconst [guardrail, setGuardrail] = useState(initial?.guardrail ?? '');\n\tconst [tools, setTools] = useState<string[]>(initial?.tools ?? []);\n\tconst [saving, setSaving] = useState(false);\n\t// Bumped to remount a field after its text is replaced (e.g. by Improve).\n\tconst [instrKey, setInstrKey] = useState(0);\n\tconst [guardKey, setGuardKey] = useState(0);\n\tconst [improving, setImproving] = useState<\n\t\t'instructions' | 'guardrail' | null\n\t>(null);\n\n\t// Tools-only mention list (sub-agents can't reference other sub-agents).\n\tconst mentionItems = useMemo(\n\t\t() => buildAgentMentionItems(availableTools, [], appLabel),\n\t\t[availableTools, appLabel],\n\t);\n\n\t// Per-field insert + focus registry, so the Tools list inserts a chip into the\n\t// last-focused editor at its cursor.\n\tconst insertersRef = useRef<\n\t\tPartial<Record<'instructions' | 'guardrail', InsertFn>>\n\t>({});\n\tconst lastFocusedRef = useRef<'instructions' | 'guardrail'>('instructions');\n\tconst registerInstr = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.instructions = fn ?? undefined;\n\t}, []);\n\tconst registerGuard = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.guardrail = fn ?? undefined;\n\t}, []);\n\tconst focusInstr = useCallback(() => {\n\t\tlastFocusedRef.current = 'instructions';\n\t}, []);\n\tconst focusGuard = useCallback(() => {\n\t\tlastFocusedRef.current = 'guardrail';\n\t}, []);\n\tconst addToolMention = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tif (kind === 'tool') {\n\t\t\t\tsetTools((prev) => (prev.includes(id) ? prev : [...prev, id]));\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst insertToolAtCursor = useCallback((id: string) => {\n\t\tconst target =\n\t\t\tinsertersRef.current[lastFocusedRef.current] ??\n\t\t\tinsertersRef.current.instructions;\n\t\ttarget?.('tool', id);\n\t}, []);\n\n\t// Local undo toast for tool removal (drawer state isn't in AgentValue).\n\tconst [undo, setUndo] = useState<{ id: number; message: string } | null>(\n\t\tnull,\n\t);\n\tconst undoSnapshotRef = useRef<{\n\t\tinstructions: string;\n\t\tguardrail: string;\n\t\ttools: string[];\n\t} | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\tconst removeTool = (id: string) => {\n\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\tconst token = tool ? `{{tool:${tool.function_key}}}` : null;\n\t\tconst strip = (text: string) => (token ? text.split(token).join('') : text);\n\t\tundoSnapshotRef.current = { instructions, guardrail, tools };\n\t\tsetInstructions((prev) => strip(prev));\n\t\tsetGuardrail((prev) => strip(prev));\n\t\tsetTools((prev) => prev.filter((t) => t !== id));\n\t\tsetInstrKey((k) => k + 1);\n\t\tsetGuardKey((k) => k + 1);\n\t\tundoIdRef.current += 1;\n\t\tsetUndo({\n\t\t\tid: undoIdRef.current,\n\t\t\tmessage: `Tool \"${tool?.displayName ?? 'Tool'}\" removed`,\n\t\t});\n\t};\n\n\tconst undoRemove = () => {\n\t\tconst snap = undoSnapshotRef.current;\n\t\tif (snap) {\n\t\t\tsetInstructions(snap.instructions);\n\t\t\tsetGuardrail(snap.guardrail);\n\t\t\tsetTools(snap.tools);\n\t\t\tsetInstrKey((k) => k + 1);\n\t\t\tsetGuardKey((k) => k + 1);\n\t\t\tundoSnapshotRef.current = null;\n\t\t}\n\t\tsetUndo(null);\n\t};\n\n\tconst canSave =\n\t\tname.trim().length > 0 &&\n\t\t(instructions.trim().length > 0 || guardrail.trim().length > 0);\n\n\tconst toolItems: SelectableItem[] = tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool ? { id, label: tool.displayName } : null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Offer all tools (re-add allowed); the chip list stays deduped.\n\tconst toolOptions: SingleOption[] = availableTools.map((t) => ({\n\t\tlabel: t.displayName,\n\t\tvalue: t.tool_id,\n\t\tsubText: t.description,\n\t}));\n\n\tconst handleSave = async () => {\n\t\tif (!canSave || saving) {\n\t\t\treturn;\n\t\t}\n\t\tconst result = onSave({\n\t\t\tname: name.trim(),\n\t\t\tinstructions,\n\t\t\tguardrail,\n\t\t\ttools,\n\t\t});\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetSaving(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} finally {\n\t\t\t\tsetSaving(false);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleImprove = async (kind: 'instructions' | 'guardrail') => {\n\t\tif (!onImprove || improving) {\n\t\t\treturn;\n\t\t}\n\t\tsetImproving(kind);\n\t\ttry {\n\t\t\tconst current = kind === 'instructions' ? instructions : guardrail;\n\t\t\tconst improved = await onImprove(kind, current);\n\t\t\tif (kind === 'instructions') {\n\t\t\t\tsetInstructions(improved);\n\t\t\t\tsetInstrKey((k) => k + 1);\n\t\t\t} else {\n\t\t\t\tsetGuardrail(improved);\n\t\t\t\tsetGuardKey((k) => k + 1);\n\t\t\t}\n\t\t} finally {\n\t\t\tsetImproving(null);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SubAgentScrim onClick={onClose} data-test=\"subagent-scrim\" />\n\t\t\t<SubAgentPanel data-test=\"create-subagent-panel\">\n\t\t\t\t<SubAgentPanelHeader>\n\t\t\t\t\t<SubAgentPanelHeaderText>\n\t\t\t\t\t\t<TitleRegular color={COLORS.content.primary}>{title}</TitleRegular>\n\t\t\t\t\t\t<BodySecondary color={COLORS.content.secondary}>\n\t\t\t\t\t\t\tEach sub-agent handles one piece of the job. Use @ in the main\n\t\t\t\t\t\t\tinstructions to call them.\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</SubAgentPanelHeaderText>\n\t\t\t\t\t<SubAgentCloseButton onClick={onClose} aria-label=\"Close\">\n\t\t\t\t\t\t<CrossIcon\n\t\t\t\t\t\t\twidth={20}\n\t\t\t\t\t\t\theight={20}\n\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</SubAgentCloseButton>\n\t\t\t\t</SubAgentPanelHeader>\n\n\t\t\t\t<SubAgentPanelBody>\n\t\t\t\t\t<Input\n\t\t\t\t\t\tdata-test=\"subagent-name\"\n\t\t\t\t\t\tlabelText=\"Agent name\"\n\t\t\t\t\t\tlabelTextBold\n\t\t\t\t\t\tplaceholder=\"Enter agent name\"\n\t\t\t\t\t\tvalue={name}\n\t\t\t\t\t\tmaxCharLimit={AGENT_CHAR_LIMITS.name}\n\t\t\t\t\t\tmaxCharLimitPosition=\"TOP\"\n\t\t\t\t\t\tmaxCharStyle={{ fontSize: 12, lineHeight: '16px' }}\n\t\t\t\t\t\tonChangeText={setName}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionEditor\n\t\t\t\t\t\tdata-test=\"subagent-instructions\"\n\t\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\t\tvalue={instructions}\n\t\t\t\t\t\tonChange={setInstructions}\n\t\t\t\t\t\tmaxLength={AGENT_CHAR_LIMITS.instructions}\n\t\t\t\t\t\tplaceholder=\"Write the steps in plain English. Type @ to reference a tool.\"\n\t\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\t\tresetKey={`instr-${instrKey}`}\n\t\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\t\ttools={availableTools}\n\t\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\t\tonFocus={focusInstr}\n\t\t\t\t\t\tregisterInsert={registerInstr}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionEditor\n\t\t\t\t\t\tdata-test=\"subagent-guardrail\"\n\t\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\t\tvalue={guardrail}\n\t\t\t\t\t\tonChange={setGuardrail}\n\t\t\t\t\t\tmaxLength={AGENT_CHAR_LIMITS.guardrail}\n\t\t\t\t\t\tplaceholder=\"e.g. Never discuss competitor pricing. Type @ to reference a tool.\"\n\t\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\t\tresetKey={`guard-${guardKey}`}\n\t\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\t\ttools={availableTools}\n\t\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\t\tonFocus={focusGuard}\n\t\t\t\t\t\tregisterInsert={registerGuard}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Tools this agent can use\"\n\t\t\t\t\t\tdataTestPrefix=\"subagent-tools\"\n\t\t\t\t\t\titems={toolItems}\n\t\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\tinsertToolAtCursor(id);\n\t\t\t\t\t\t\tsetTools((prev) => (prev.includes(id) ? prev : [...prev, id]));\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonRemove={removeTool}\n\t\t\t\t\t/>\n\t\t\t\t</SubAgentPanelBody>\n\n\t\t\t\t<SubAgentPanelFooter>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tdata-test=\"subagent-save\"\n\t\t\t\t\t\tbuttonType=\"primary\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tbuttonText=\"Save\"\n\t\t\t\t\t\tdisabled={!canSave}\n\t\t\t\t\t\tisLoading={saving}\n\t\t\t\t\t\tonClick={handleSave}\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tdata-test=\"subagent-cancel\"\n\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tbuttonText=\"Cancel\"\n\t\t\t\t\t\tonClick={onClose}\n\t\t\t\t\t/>\n\t\t\t\t</SubAgentPanelFooter>\n\t\t\t</SubAgentPanel>\n\n\t\t\t{undo && (\n\t\t\t\t<Toaster\n\t\t\t\t\tkey={undo.id}\n\t\t\t\t\ttext={undo.message}\n\t\t\t\t\ttype=\"info\"\n\t\t\t\t\tposition=\"top-right\"\n\t\t\t\t\tautoClose={5000}\n\t\t\t\t\thideCloseButton\n\t\t\t\t\tbuttonProps={{\n\t\t\t\t\t\tbuttonText: 'Undo',\n\t\t\t\t\t\tshowButton: true,\n\t\t\t\t\t\tonButtonClick: () => {\n\t\t\t\t\t\t\tundoRemove();\n\t\t\t\t\t\t\treturn {} as Record<string, never>;\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonCloseToast={() => setUndo(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</>\n\t);\n};\n"],"names":["CreateSubAgentPanel","onClose","onSave","availableTools","onImprove","title","initial","appLabel","name","setName","useState","instructions","setInstructions","guardrail","setGuardrail","tools","setTools","saving","setSaving","instrKey","setInstrKey","guardKey","setGuardKey","improving","setImproving","mentionItems","useMemo","buildAgentMentionItems","insertersRef","useRef","lastFocusedRef","registerInstr","useCallback","fn","registerGuard","focusInstr","focusGuard","addToolMention","kind","id","prev","insertToolAtCursor","undo","setUndo","undoSnapshotRef","undoIdRef","removeTool","tool","t","token","strip","text","k","undoRemove","snap","canSave","toolItems","x","toolOptions","handleSave","result","jsxs","Fragment","jsx","SubAgentScrim","SubAgentPanel","SubAgentPanelHeader","SubAgentPanelHeaderText","TitleRegular","COLORS","BodySecondary","SubAgentCloseButton","CrossIcon","SubAgentPanelBody","Input","AGENT_CHAR_LIMITS","MentionEditor","SelectableListSection","SubAgentPanelFooter","Button","Toaster"],"mappings":";;;;;;;;;;;;;AAmDO,MAAMA,KAA0D,CAAC;AAAA,EACvE,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,SAAAC;AAAA,EACA,UAAAC,IAAW;AACZ,MAAM;AACL,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAASJ,GAAS,QAAQ,EAAE,GAC9C,CAACK,GAAcC,CAAe,IAAIF,EAASJ,GAAS,gBAAgB,EAAE,GACtE,CAACO,GAAWC,CAAY,IAAIJ,EAASJ,GAAS,aAAa,EAAE,GAC7D,CAACS,GAAOC,CAAQ,IAAIN,EAAmBJ,GAAS,SAAS,EAAE,GAC3D,CAACW,GAAQC,CAAS,IAAIR,EAAS,EAAK,GAEpC,CAACS,GAAUC,CAAW,IAAIV,EAAS,CAAC,GACpC,CAACW,GAAUC,CAAW,IAAIZ,EAAS,CAAC,GACpC,CAACa,IAAWC,EAAY,IAAId,EAEhC,IAAI,GAGAe,IAAeC;AAAA,IACpB,MAAMC,GAAuBxB,GAAgB,CAAA,GAAII,CAAQ;AAAA,IACzD,CAACJ,GAAgBI,CAAQ;AAAA,EAAA,GAKpBqB,IAAeC,EAEnB,EAAE,GACEC,IAAiBD,EAAqC,cAAc,GACpEE,IAAgBC,EAAY,CAACC,MAAwB;AAC1D,IAAAL,EAAa,QAAQ,eAAeK,KAAM;AAAA,EAC3C,GAAG,CAAA,CAAE,GACCC,IAAgBF,EAAY,CAACC,MAAwB;AAC1D,IAAAL,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A;AAAA,QAEA,MAAMtC,EAAK;AAAA,QACX,MAAK;AAAA,QACL,UAAS;AAAA,QACT,WAAW;AAAA,QACX,iBAAe;AAAA,QACf,aAAa;AAAA,UACZ,YAAY;AAAA,UACZ,YAAY;AAAA,UACZ,eAAe,OACdW,EAAA,GACO,CAAA;AAAA,QACR;AAAA,QAED,cAAc,MAAMV,EAAQ,IAAI;AAAA,MAAA;AAAA,MAd3BD,EAAK;AAAA,IAAA;AAAA,EAeX,GAEF;AAEF;"}
|
|
1
|
+
{"version":3,"file":"CreateSubAgentPanel.js","sources":["../../../../../src/components/agent-builder/components/CreateSubAgentPanel.tsx"],"sourcesContent":["import CrossIcon from '@src/assets/icons/cross.svg';\nimport React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { Button } from '@src/components/button';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Input } from '@src/components/input';\nimport { Toaster } from '@src/components/toaster';\nimport { BodySecondary, TitleRegular } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { AgentTool, SubAgentDraft } from '../AgentBuilder.model';\nimport {\n\tSubAgentCloseButton,\n\tSubAgentPanel,\n\tSubAgentPanelBody,\n\tSubAgentPanelFooter,\n\tSubAgentPanelHeader,\n\tSubAgentPanelHeaderText,\n\tSubAgentScrim,\n} from '../AgentBuilder.styled';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport { buildAgentMentionItems } from '../utils/mentionSerialization';\nimport { SOURCE_ICONS } from '../utils/sourceIcons';\nimport { MentionEditor } from './MentionEditor';\nimport { SelectableItem, SelectableListSection } from './SelectableListSection';\n\ntype InsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;\n\ninterface CreateSubAgentPanelProps {\n\tonClose: () => void;\n\t/** Persist the draft. The drawer shows a loader while the returned promise is pending. */\n\tonSave: (draft: SubAgentDraft) => void | Promise<void>;\n\tavailableTools: AgentTool[];\n\t/** Optional \"Improve with AI\" for instructions / guardrails. Omit to hide the buttons. */\n\tonImprove?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\t/** Header title — \"Create sub-agent\" (default) or \"Edit sub-agent\". */\n\ttitle?: string;\n\t/** Initial values, e.g. when configuring an existing sub-agent. */\n\tinitial?: SubAgentDraft;\n\t/** Tool-source fallback label for chips (host app). */\n\tappLabel?: string;\n}\n\n/**\n * Right-side drawer for creating / editing a sub-agent (name, instructions,\n * guardrails, tools). Instructions & Guardrails are `@`-mention editors (tools\n * only — sub-agents can't nest); adding a tool from the list inserts it at the\n * last-focused field's cursor. Mount it fresh per open (key it) so `initial`\n * seeds the draft.\n */\nexport const CreateSubAgentPanel: React.FC<CreateSubAgentPanelProps> = ({\n\tonClose,\n\tonSave,\n\tavailableTools,\n\tonImprove,\n\ttitle = 'Create sub-agent',\n\tinitial,\n\tappLabel = 'Manifest',\n}) => {\n\tconst [name, setName] = useState(initial?.name ?? '');\n\tconst [instructions, setInstructions] = useState(initial?.instructions ?? '');\n\tconst [guardrail, setGuardrail] = useState(initial?.guardrail ?? '');\n\tconst [tools, setTools] = useState<string[]>(initial?.tools ?? []);\n\tconst [saving, setSaving] = useState(false);\n\t// Bumped to remount a field after its text is replaced (e.g. by Improve).\n\tconst [instrKey, setInstrKey] = useState(0);\n\tconst [guardKey, setGuardKey] = useState(0);\n\tconst [improving, setImproving] = useState<\n\t\t'instructions' | 'guardrail' | null\n\t>(null);\n\n\t// Tools-only mention list (sub-agents can't reference other sub-agents).\n\tconst mentionItems = useMemo(\n\t\t() => buildAgentMentionItems(availableTools, [], appLabel),\n\t\t[availableTools, appLabel],\n\t);\n\n\t// Per-field insert + focus registry, so the Tools list inserts a chip into the\n\t// last-focused editor at its cursor.\n\tconst insertersRef = useRef<\n\t\tPartial<Record<'instructions' | 'guardrail', InsertFn>>\n\t>({});\n\tconst lastFocusedRef = useRef<'instructions' | 'guardrail'>('instructions');\n\tconst registerInstr = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.instructions = fn ?? undefined;\n\t}, []);\n\tconst registerGuard = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.guardrail = fn ?? undefined;\n\t}, []);\n\tconst focusInstr = useCallback(() => {\n\t\tlastFocusedRef.current = 'instructions';\n\t}, []);\n\tconst focusGuard = useCallback(() => {\n\t\tlastFocusedRef.current = 'guardrail';\n\t}, []);\n\tconst addToolMention = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tif (kind === 'tool') {\n\t\t\t\tsetTools((prev) => (prev.includes(id) ? prev : [...prev, id]));\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst insertToolAtCursor = useCallback((id: string) => {\n\t\tconst target =\n\t\t\tinsertersRef.current[lastFocusedRef.current] ??\n\t\t\tinsertersRef.current.instructions;\n\t\ttarget?.('tool', id);\n\t}, []);\n\n\t// Local undo toast for tool removal (drawer state isn't in AgentValue).\n\tconst [undo, setUndo] = useState<{ id: number; message: string } | null>(\n\t\tnull,\n\t);\n\tconst undoSnapshotRef = useRef<{\n\t\tinstructions: string;\n\t\tguardrail: string;\n\t\ttools: string[];\n\t} | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\tconst removeTool = (id: string) => {\n\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\tconst token = tool ? `{{tool:${tool.function_key}}}` : null;\n\t\tconst strip = (text: string) => (token ? text.split(token).join('') : text);\n\t\tundoSnapshotRef.current = { instructions, guardrail, tools };\n\t\tsetInstructions((prev) => strip(prev));\n\t\tsetGuardrail((prev) => strip(prev));\n\t\tsetTools((prev) => prev.filter((t) => t !== id));\n\t\tsetInstrKey((k) => k + 1);\n\t\tsetGuardKey((k) => k + 1);\n\t\tundoIdRef.current += 1;\n\t\tsetUndo({\n\t\t\tid: undoIdRef.current,\n\t\t\tmessage: `Tool \"${tool?.display_name ?? 'Tool'}\" removed`,\n\t\t});\n\t};\n\n\tconst undoRemove = () => {\n\t\tconst snap = undoSnapshotRef.current;\n\t\tif (snap) {\n\t\t\tsetInstructions(snap.instructions);\n\t\t\tsetGuardrail(snap.guardrail);\n\t\t\tsetTools(snap.tools);\n\t\t\tsetInstrKey((k) => k + 1);\n\t\t\tsetGuardKey((k) => k + 1);\n\t\t\tundoSnapshotRef.current = null;\n\t\t}\n\t\tsetUndo(null);\n\t};\n\n\tconst canSave =\n\t\tname.trim().length > 0 &&\n\t\t(instructions.trim().length > 0 || guardrail.trim().length > 0);\n\n\tconst toolItems: SelectableItem[] = tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: SOURCE_ICONS[tool.source ?? 'manifest'],\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Offer all tools (re-add allowed); the chip list stays deduped. Icon left of\n\t// the name, no description.\n\tconst toolOptions: SingleOption[] = availableTools.map((t) => {\n\t\tconst ic = SOURCE_ICONS[t.source ?? 'manifest'];\n\t\treturn {\n\t\t\tlabel: t.display_name,\n\t\t\tvalue: t.tool_id,\n\t\t\tleadingIcon: ic\n\t\t\t\t? React.createElement(ic.Icon, { width: ic.w, height: ic.h })\n\t\t\t\t: undefined,\n\t\t};\n\t});\n\n\tconst handleSave = async () => {\n\t\tif (!canSave || saving) {\n\t\t\treturn;\n\t\t}\n\t\tconst result = onSave({\n\t\t\tname: name.trim(),\n\t\t\tinstructions,\n\t\t\tguardrail,\n\t\t\ttools,\n\t\t});\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetSaving(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} finally {\n\t\t\t\tsetSaving(false);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleImprove = async (kind: 'instructions' | 'guardrail') => {\n\t\tif (!onImprove || improving) {\n\t\t\treturn;\n\t\t}\n\t\tsetImproving(kind);\n\t\ttry {\n\t\t\tconst current = kind === 'instructions' ? instructions : guardrail;\n\t\t\tconst improved = await onImprove(kind, current);\n\t\t\tif (kind === 'instructions') {\n\t\t\t\tsetInstructions(improved);\n\t\t\t\tsetInstrKey((k) => k + 1);\n\t\t\t} else {\n\t\t\t\tsetGuardrail(improved);\n\t\t\t\tsetGuardKey((k) => k + 1);\n\t\t\t}\n\t\t} finally {\n\t\t\tsetImproving(null);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SubAgentScrim onClick={onClose} data-test=\"subagent-scrim\" />\n\t\t\t<SubAgentPanel data-test=\"create-subagent-panel\">\n\t\t\t\t<SubAgentPanelHeader>\n\t\t\t\t\t<SubAgentPanelHeaderText>\n\t\t\t\t\t\t<TitleRegular color={COLORS.content.primary}>{title}</TitleRegular>\n\t\t\t\t\t\t<BodySecondary color={COLORS.content.secondary}>\n\t\t\t\t\t\t\tEach sub-agent handles one piece of the job. Use @ in the main\n\t\t\t\t\t\t\tinstructions to call them.\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</SubAgentPanelHeaderText>\n\t\t\t\t\t<SubAgentCloseButton onClick={onClose} aria-label=\"Close\">\n\t\t\t\t\t\t<CrossIcon\n\t\t\t\t\t\t\twidth={20}\n\t\t\t\t\t\t\theight={20}\n\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</SubAgentCloseButton>\n\t\t\t\t</SubAgentPanelHeader>\n\n\t\t\t\t<SubAgentPanelBody>\n\t\t\t\t\t<Input\n\t\t\t\t\t\tdata-test=\"subagent-name\"\n\t\t\t\t\t\tlabelText=\"Agent name\"\n\t\t\t\t\t\tlabelTextBold\n\t\t\t\t\t\tplaceholder=\"Enter agent name\"\n\t\t\t\t\t\tvalue={name}\n\t\t\t\t\t\tmaxCharLimit={AGENT_CHAR_LIMITS.name}\n\t\t\t\t\t\tmaxCharLimitPosition=\"TOP\"\n\t\t\t\t\t\tmaxCharStyle={{ fontSize: 12, lineHeight: '16px' }}\n\t\t\t\t\t\tonChangeText={setName}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionEditor\n\t\t\t\t\t\tdata-test=\"subagent-instructions\"\n\t\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\t\tvalue={instructions}\n\t\t\t\t\t\tonChange={setInstructions}\n\t\t\t\t\t\tmaxLength={AGENT_CHAR_LIMITS.instructions}\n\t\t\t\t\t\tplaceholder=\"Write the steps in plain English. Type @ to reference a tool.\"\n\t\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\t\tresetKey={`instr-${instrKey}`}\n\t\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\t\ttools={availableTools}\n\t\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\t\tonFocus={focusInstr}\n\t\t\t\t\t\tregisterInsert={registerInstr}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionEditor\n\t\t\t\t\t\tdata-test=\"subagent-guardrail\"\n\t\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\t\tvalue={guardrail}\n\t\t\t\t\t\tonChange={setGuardrail}\n\t\t\t\t\t\tmaxLength={AGENT_CHAR_LIMITS.guardrail}\n\t\t\t\t\t\tplaceholder=\"e.g. Never discuss competitor pricing. Type @ to reference a tool.\"\n\t\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\t\tresetKey={`guard-${guardKey}`}\n\t\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\t\ttools={availableTools}\n\t\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\t\tonFocus={focusGuard}\n\t\t\t\t\t\tregisterInsert={registerGuard}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Tools this agent can use\"\n\t\t\t\t\t\tdataTestPrefix=\"subagent-tools\"\n\t\t\t\t\t\titems={toolItems}\n\t\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\tinsertToolAtCursor(id);\n\t\t\t\t\t\t\tsetTools((prev) => (prev.includes(id) ? prev : [...prev, id]));\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonRemove={removeTool}\n\t\t\t\t\t/>\n\t\t\t\t</SubAgentPanelBody>\n\n\t\t\t\t<SubAgentPanelFooter>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tdata-test=\"subagent-save\"\n\t\t\t\t\t\tbuttonType=\"primary\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tbuttonText=\"Save\"\n\t\t\t\t\t\tdisabled={!canSave}\n\t\t\t\t\t\tisLoading={saving}\n\t\t\t\t\t\tonClick={handleSave}\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tdata-test=\"subagent-cancel\"\n\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tbuttonText=\"Cancel\"\n\t\t\t\t\t\tonClick={onClose}\n\t\t\t\t\t/>\n\t\t\t\t</SubAgentPanelFooter>\n\t\t\t</SubAgentPanel>\n\n\t\t\t{undo && (\n\t\t\t\t<Toaster\n\t\t\t\t\tkey={undo.id}\n\t\t\t\t\ttext={undo.message}\n\t\t\t\t\ttype=\"info\"\n\t\t\t\t\tposition=\"top-right\"\n\t\t\t\t\tautoClose={5000}\n\t\t\t\t\thideCloseButton\n\t\t\t\t\tbuttonProps={{\n\t\t\t\t\t\tbuttonText: 'Undo',\n\t\t\t\t\t\tshowButton: true,\n\t\t\t\t\t\tonButtonClick: () => {\n\t\t\t\t\t\t\tundoRemove();\n\t\t\t\t\t\t\treturn {} as Record<string, never>;\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonCloseToast={() => setUndo(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</>\n\t);\n};\n"],"names":["CreateSubAgentPanel","onClose","onSave","availableTools","onImprove","title","initial","appLabel","name","setName","useState","instructions","setInstructions","guardrail","setGuardrail","tools","setTools","saving","setSaving","instrKey","setInstrKey","guardKey","setGuardKey","improving","setImproving","mentionItems","useMemo","buildAgentMentionItems","insertersRef","useRef","lastFocusedRef","registerInstr","useCallback","fn","registerGuard","focusInstr","focusGuard","addToolMention","kind","id","prev","insertToolAtCursor","undo","setUndo","undoSnapshotRef","undoIdRef","removeTool","tool","t","token","strip","text","k","undoRemove","snap","canSave","toolItems","SOURCE_ICONS","x","toolOptions","ic","React","handleSave","result","jsxs","Fragment","jsx","SubAgentScrim","SubAgentPanel","SubAgentPanelHeader","SubAgentPanelHeaderText","TitleRegular","COLORS","BodySecondary","SubAgentCloseButton","CrossIcon","SubAgentPanelBody","Input","AGENT_CHAR_LIMITS","MentionEditor","SelectableListSection","SubAgentPanelFooter","Button","Toaster"],"mappings":";;;;;;;;;;;;;;AAmDO,MAAMA,KAA0D,CAAC;AAAA,EACvE,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,SAAAC;AAAA,EACA,UAAAC,IAAW;AACZ,MAAM;AACL,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAASJ,GAAS,QAAQ,EAAE,GAC9C,CAACK,GAAcC,CAAe,IAAIF,EAASJ,GAAS,gBAAgB,EAAE,GACtE,CAACO,GAAWC,CAAY,IAAIJ,EAASJ,GAAS,aAAa,EAAE,GAC7D,CAACS,GAAOC,CAAQ,IAAIN,EAAmBJ,GAAS,SAAS,EAAE,GAC3D,CAACW,GAAQC,CAAS,IAAIR,EAAS,EAAK,GAEpC,CAACS,GAAUC,CAAW,IAAIV,EAAS,CAAC,GACpC,CAACW,GAAUC,CAAW,IAAIZ,EAAS,CAAC,GACpC,CAACa,IAAWC,EAAY,IAAId,EAEhC,IAAI,GAGAe,I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,YAC9D;AAAA,YACA,UAAUO;AAAA,UAAA;AAAA,QAAA;AAAA,MACX,GACD;AAAA,wBAECmC,IAAA,EACA,UAAA;AAAA,QAAA,gBAAAf;AAAA,UAACgB;AAAA,UAAA;AAAA,YACA,aAAU;AAAA,YACV,YAAW;AAAA,YACX,MAAK;AAAA,YACL,YAAW;AAAA,YACX,UAAU,CAAC3B;AAAA,YACX,WAAWtC;AAAA,YACX,SAAS6C;AAAA,UAAA;AAAA,QAAA;AAAA,QAEV,gBAAAI;AAAA,UAACgB;AAAA,UAAA;AAAA,YACA,aAAU;AAAA,YACV,YAAW;AAAA,YACX,MAAK;AAAA,YACL,YAAW;AAAA,YACX,SAASjF;AAAA,UAAA;AAAA,QAAA;AAAA,MACV,EAAA,CACD;AAAA,IAAA,GACD;AAAA,IAECyC,KACA,gBAAAwB;AAAA,MAACiB;AAAA,MAAA;AAAA,QAEA,MAAMzC,EAAK;AAAA,QACX,MAAK;AAAA,QACL,UAAS;AAAA,QACT,WAAW;AAAA,QACX,iBAAe;AAAA,QACf,aAAa;AAAA,UACZ,YAAY;AAAA,UACZ,YAAY;AAAA,UACZ,eAAe,OACdW,EAAA,GACO,CAAA;AAAA,QACR;AAAA,QAED,cAAc,MAAMV,EAAQ,IAAI;AAAA,MAAA;AAAA,MAd3BD,EAAK;AAAA,IAAA;AAAA,EAeX,GAEF;AAEF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoLiveModal.js","sources":["../../../../../src/components/agent-builder/components/GoLiveModal.tsx"],"sourcesContent":["import ManifestGlass from '@src/assets/icons/ManifestGlass.svg';\nimport SuccessIcon from '@src/assets/icons/successIcon.svg';\nimport React from 'react';\nimport { Button } from '@src/components/button';\nimport { StyledModal } from '@src/components/modals';\nimport { BodySecondary, TitleRegular } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { ModalActions, ModalBody, ModalIcon } from '../AgentBuilder.styled';\n\nexport type GoLiveModalMode = 'confirm' | 'success' | null;\n\ninterface GoLiveModalProps {\n\tmode: GoLiveModalMode;\n\tonClose: () => void;\n\tonConfirm: () => void;\n\tonSaveDraft: () => void;\n\tonGoToDashboard?: () => void;\n\tisPublishing?: boolean;\n}\n\n/**\n * Confirm / success dialog for going live. Uses `StyledModal` as the shell but\n * renders the actions INSIDE the body (not StyledModal's footer) — the footer's\n * `margin-top:auto` detaches from this short, centered hero layout and spills\n * out of the card. Body-level actions stay anchored under the content.\n */\nexport const GoLiveModal: React.FC<GoLiveModalProps> = ({\n\tmode,\n\tonClose,\n\tonConfirm,\n\tonSaveDraft,\n\tonGoToDashboard,\n\tisPublishing,\n}) => {\n\tif (!mode) {\n\t\treturn null;\n\t}\n\n\tconst isSuccess = mode === 'success';\n\n\treturn (\n\t\t<StyledModal\n\t\t\tdata-test=\"agent-go-live-modal\"\n\t\t\topen\n\t\t\tonClose={onClose}\n\t\t\twidth={isSuccess ? '400px' : '520px'}\n\t\t
|
|
1
|
+
{"version":3,"file":"GoLiveModal.js","sources":["../../../../../src/components/agent-builder/components/GoLiveModal.tsx"],"sourcesContent":["import ManifestGlass from '@src/assets/icons/ManifestGlass.svg';\nimport SuccessIcon from '@src/assets/icons/successIcon.svg';\nimport React from 'react';\nimport { Button } from '@src/components/button';\nimport { StyledModal } from '@src/components/modals';\nimport { BodySecondary, TitleRegular } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { ModalActions, ModalBody, ModalIcon } from '../AgentBuilder.styled';\n\nexport type GoLiveModalMode = 'confirm' | 'success' | null;\n\ninterface GoLiveModalProps {\n\tmode: GoLiveModalMode;\n\tonClose: () => void;\n\tonConfirm: () => void;\n\tonSaveDraft: () => void;\n\tonGoToDashboard?: () => void;\n\tisPublishing?: boolean;\n}\n\n/**\n * Confirm / success dialog for going live. Uses `StyledModal` as the shell but\n * renders the actions INSIDE the body (not StyledModal's footer) — the footer's\n * `margin-top:auto` detaches from this short, centered hero layout and spills\n * out of the card. Body-level actions stay anchored under the content.\n */\nexport const GoLiveModal: React.FC<GoLiveModalProps> = ({\n\tmode,\n\tonClose,\n\tonConfirm,\n\tonSaveDraft,\n\tonGoToDashboard,\n\tisPublishing,\n}) => {\n\tif (!mode) {\n\t\treturn null;\n\t}\n\n\tconst isSuccess = mode === 'success';\n\n\treturn (\n\t\t<StyledModal\n\t\t\tdata-test=\"agent-go-live-modal\"\n\t\t\topen\n\t\t\tonClose={onClose}\n\t\t\twidth={isSuccess ? '400px' : '520px'}\n\t\t>\n\t\t\t<ModalBody>\n\t\t\t\t<ModalIcon>\n\t\t\t\t\t{isSuccess ? (\n\t\t\t\t\t\t<SuccessIcon width={64} height={64} />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<ManifestGlass width={64} height={64} />\n\t\t\t\t\t)}\n\t\t\t\t</ModalIcon>\n\n\t\t\t\t<TitleRegular color={COLORS.content.primary}>\n\t\t\t\t\t{isSuccess ? 'Your agent is live!' : 'Ready to go live?'}\n\t\t\t\t</TitleRegular>\n\t\t\t\t<BodySecondary color={COLORS.content.secondary}>\n\t\t\t\t\t{isSuccess\n\t\t\t\t\t\t? 'You can manage your agents from the AI agent dashboard.'\n\t\t\t\t\t\t: 'This agent will start handling customer conversations immediately. You can pause it at any time.'}\n\t\t\t\t</BodySecondary>\n\n\t\t\t\t<ModalActions>\n\t\t\t\t\t{isSuccess ? (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdata-test=\"agent-go-dashboard\"\n\t\t\t\t\t\t\tbuttonType=\"primary\"\n\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\tbuttonText=\"Go to Agent dashboard\"\n\t\t\t\t\t\t\tonClick={onGoToDashboard ?? onClose}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tdata-test=\"agent-confirm-save-draft\"\n\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\tbuttonText=\"Save as draft\"\n\t\t\t\t\t\t\t\tonClick={onSaveDraft}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tdata-test=\"agent-confirm-go-live\"\n\t\t\t\t\t\t\t\tbuttonType=\"primary\"\n\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\tbuttonText=\"Go live now\"\n\t\t\t\t\t\t\t\tisLoading={isPublishing}\n\t\t\t\t\t\t\t\tonClick={onConfirm}\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</ModalActions>\n\t\t\t</ModalBody>\n\t\t</StyledModal>\n\t);\n};\n"],"names":["GoLiveModal","mode","onClose","onConfirm","onSaveDraft","onGoToDashboard","isPublishing","isSuccess","jsx","StyledModal","ModalBody","ModalIcon","SuccessIcon","ManifestGlass","TitleRegular","COLORS","BodySecondary","ModalActions","Button","jsxs","Fragment"],"mappings":";;;;;;;;AA0BO,MAAMA,IAA0C,CAAC;AAAA,EACvD,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,cAAAC;AACD,MAAM;AACL,MAAI,CAACL;AACJ,WAAO;AAGR,QAAMM,IAAYN,MAAS;AAE3B,SACC,gBAAAO;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,aAAU;AAAA,MACV,MAAI;AAAA,MACJ,SAAAP;AAAA,MACA,OAAOK,IAAY,UAAU;AAAA,MAE7B,4BAACG,GAAA,EACA,UAAA;AAAA,QAAA,gBAAAF,EAACG,GAAA,EACC,UAAAJ,IACA,gBAAAC,EAACI,GAAA,EAAY,OAAO,IAAI,QAAQ,IAAI,sBAEnCC,GAAA,EAAc,OAAO,IAAI,QAAQ,IAAI,GAExC;AAAA,QAEA,gBAAAL,EAACM,KAAa,OAAOC,EAAO,QAAQ,SAClC,UAAAR,IAAY,wBAAwB,oBAAA,CACtC;AAAA,QACA,gBAAAC,EAACQ,KAAc,OAAOD,EAAO,QAAQ,WACnC,UAAAR,IACE,4DACA,mGAAA,CACJ;AAAA,QAEA,gBAAAC,EAACS,KACC,UAAAV,IACA,gBAAAC;AAAA,UAACU;AAAA,UAAA;AAAA,YACA,aAAU;AAAA,YACV,YAAW;AAAA,YACX,MAAK;AAAA,YACL,kBAAgB;AAAA,YAChB,YAAW;AAAA,YACX,SAASb,KAAmBH;AAAA,UAAA;AAAA,QAAA,IAG7B,gBAAAiB,EAAAC,GAAA,EACC,UAAA;AAAA,UAAA,gBAAAZ;AAAA,YAACU;AAAA,YAAA;AAAA,cACA,aAAU;AAAA,cACV,YAAW;AAAA,cACX,MAAK;AAAA,cACL,kBAAgB;AAAA,cAChB,YAAW;AAAA,cACX,SAASd;AAAA,YAAA;AAAA,UAAA;AAAA,UAEV,gBAAAI;AAAA,YAACU;AAAA,YAAA;AAAA,cACA,aAAU;AAAA,cACV,YAAW;AAAA,cACX,MAAK;AAAA,cACL,kBAAgB;AAAA,cAChB,YAAW;AAAA,cACX,WAAWZ;AAAA,cACX,SAASH;AAAA,YAAA;AAAA,UAAA;AAAA,QACV,EAAA,CACD,EAAA,CAEF;AAAA,MAAA,EAAA,CACD;AAAA,IAAA;AAAA,EAAA;AAGH;"}
|
|
@@ -20,6 +20,12 @@ interface MentionEditorProps {
|
|
|
20
20
|
onFocus?: () => void;
|
|
21
21
|
/** Receives an insert-at-cursor fn (and null on unmount) for side-panel adds. */
|
|
22
22
|
registerInsert?: (fn: InsertFn | null) => void;
|
|
23
|
+
/**
|
|
24
|
+
* When set, the `@` picker's Sub-agent view shows a "Create new" row that calls
|
|
25
|
+
* this (opens the create-sub-agent drawer). Omit to hide it (e.g. the drawer's
|
|
26
|
+
* own editors, which can't nest sub-agents).
|
|
27
|
+
*/
|
|
28
|
+
onCreateSubAgent?: () => void;
|
|
23
29
|
/** Optional action(s) rendered inside the shell, below the editor. */
|
|
24
30
|
action?: React.ReactNode;
|
|
25
31
|
'data-test'?: string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as i, jsx as d } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { TitleSmall as
|
|
2
|
+
import { useRef as B, useState as L, useCallback as j, useEffect as p, useMemo as w } from "react";
|
|
3
|
+
import { TitleSmall as F, BodyCaption as N } 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 { buildMentionHtml as
|
|
8
|
-
import { MentionPicker as
|
|
9
|
-
import { BikEditor as
|
|
10
|
-
const
|
|
5
|
+
import { FieldBlock as _, FieldLabelRow as G, AiTextAreaShell as J } from "../AgentBuilder.styled.js";
|
|
6
|
+
import { AGENT_EDITOR_STYLE as P } from "../constants/editorStyle.js";
|
|
7
|
+
import { buildMentionHtml as Y, instructionsToEditorHtml as $, editorDocToInstructions as q } from "../utils/mentionSerialization.js";
|
|
8
|
+
import { MentionPicker as z } from "./MentionPicker.js";
|
|
9
|
+
import { BikEditor as Q } from "../../../editor/BikEditor.js";
|
|
10
|
+
const ot = ({
|
|
11
11
|
label: S,
|
|
12
12
|
value: e,
|
|
13
13
|
onChange: g,
|
|
@@ -20,19 +20,20 @@ const tt = ({
|
|
|
20
20
|
onMentionSelect: b,
|
|
21
21
|
onFocus: E,
|
|
22
22
|
registerInsert: r,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
onCreateSubAgent: k,
|
|
24
|
+
action: H,
|
|
25
|
+
...O
|
|
25
26
|
}) => {
|
|
26
|
-
const c =
|
|
27
|
-
(t, o,
|
|
27
|
+
const c = B(null), [R, s] = L(e.length), m = j(
|
|
28
|
+
(t, o, M) => {
|
|
28
29
|
const f = c.current;
|
|
29
30
|
if (!f)
|
|
30
31
|
return;
|
|
31
|
-
const
|
|
32
|
+
const y = n.find(
|
|
32
33
|
(u) => String(u.id) === String(o) && u.meta?.kind === t
|
|
33
|
-
),
|
|
34
|
+
), A = M ?? y?.label ?? o;
|
|
34
35
|
f.insertInlineContent(
|
|
35
|
-
`${
|
|
36
|
+
`${Y(String(o), A, t)} `
|
|
36
37
|
);
|
|
37
38
|
},
|
|
38
39
|
[n]
|
|
@@ -41,8 +42,8 @@ const tt = ({
|
|
|
41
42
|
if (r)
|
|
42
43
|
return r(m), () => r(null);
|
|
43
44
|
}, [r, m]);
|
|
44
|
-
const
|
|
45
|
-
() =>
|
|
45
|
+
const D = w(
|
|
46
|
+
() => $(e, n),
|
|
46
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
48
|
[l]
|
|
48
49
|
);
|
|
@@ -50,32 +51,32 @@ const tt = ({
|
|
|
50
51
|
() => s(e.length),
|
|
51
52
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
53
|
[l]
|
|
53
|
-
), /* @__PURE__ */ i(
|
|
54
|
-
/* @__PURE__ */ i(
|
|
55
|
-
/* @__PURE__ */ d(
|
|
56
|
-
/* @__PURE__ */ i(
|
|
57
|
-
|
|
54
|
+
), /* @__PURE__ */ i(_, { children: [
|
|
55
|
+
/* @__PURE__ */ i(G, { children: [
|
|
56
|
+
/* @__PURE__ */ d(F, { color: h.content.primary, children: S }),
|
|
57
|
+
/* @__PURE__ */ i(N, { color: h.content.secondary, children: [
|
|
58
|
+
R,
|
|
58
59
|
"/",
|
|
59
60
|
a
|
|
60
61
|
] })
|
|
61
62
|
] }),
|
|
62
|
-
/* @__PURE__ */ i(
|
|
63
|
+
/* @__PURE__ */ i(J, { minHeight: x, "data-test": O["data-test"], children: [
|
|
63
64
|
/* @__PURE__ */ d(
|
|
64
|
-
|
|
65
|
+
Q,
|
|
65
66
|
{
|
|
66
67
|
ref: c,
|
|
67
|
-
initialContent:
|
|
68
|
+
initialContent: D,
|
|
68
69
|
placeholder: C,
|
|
69
70
|
maxCharacters: a,
|
|
70
71
|
minHeight: "120px",
|
|
71
72
|
maxHeight: "320px",
|
|
72
73
|
style: { border: "none" },
|
|
73
|
-
editorStyle:
|
|
74
|
+
editorStyle: P,
|
|
74
75
|
onFocus: E,
|
|
75
76
|
mentions: {
|
|
76
77
|
agents: n,
|
|
77
78
|
removeTriggerOnDismiss: !0,
|
|
78
|
-
renderDropdown: (t) => /* @__PURE__ */ d(
|
|
79
|
+
renderDropdown: (t) => /* @__PURE__ */ d(z, { ...t, onCreateSubAgent: k }),
|
|
79
80
|
onSelect: (t) => {
|
|
80
81
|
const o = t.meta?.kind;
|
|
81
82
|
o && b?.(o, String(t.id));
|
|
@@ -84,16 +85,16 @@ const tt = ({
|
|
|
84
85
|
onChange: (t) => {
|
|
85
86
|
s(t.characterCount);
|
|
86
87
|
const o = c.current?.getJSON() ?? null;
|
|
87
|
-
g(
|
|
88
|
+
g(q(o, T));
|
|
88
89
|
}
|
|
89
90
|
},
|
|
90
91
|
l
|
|
91
92
|
),
|
|
92
|
-
|
|
93
|
+
H
|
|
93
94
|
] })
|
|
94
95
|
] });
|
|
95
96
|
};
|
|
96
97
|
export {
|
|
97
|
-
|
|
98
|
+
ot as MentionEditor
|
|
98
99
|
};
|
|
99
100
|
//# 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 { AgentTool } from '../AgentBuilder.model';\nimport {\n\tAiTextAreaShell,\n\tFieldBlock,\n\tFieldLabelRow,\n} from '../AgentBuilder.styled';\nimport { AGENT_EDITOR_STYLE } from '../constants/editorStyle';\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/** 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\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\tmaxCharacters={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) => <MentionPicker {...props}
|
|
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 {\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/** 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\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\tmaxCharacters={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 {...props} onCreateSubAgent={onCreateSubAgent} />\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","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":";;;;;;;;;AA6DO,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,QAAAC;AAAA,EACA,GAAGC;AACJ,MAAM;AACL,QAAMC,IAAYC,EAAqB,IAAI,GACrC,CAACC,GAAOC,CAAQ,IAAIC,EAASlB,EAAM,MAAM,GAEzCmB,IAASC;AAAA,IACd,CAACC,GAAMC,GAAIC,MAAkB;AAC5B,YAAMC,IAASV,EAAU;AACzB,UAAI,CAACU;AACJ;AAED,YAAMC,IAAOnB,EAAa;AAAA,QACzB,CAACoB,MACA,OAAOA,EAAE,EAAE,MAAM,OAAOJ,CAAE,KACzBI,EAAE,MAAiD,SAASL;AAAA,MAAA,GAEzDM,IAAaJ,KAAiBE,GAAM,SAASH;AACnD,MAAAE,EAAO;AAAA,QACN,GAAGI,EAAiB,OAAON,CAAE,GAAGK,GAAYN,CAAI,CAAC;AAAA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