@bikdotai/bik-component-library 0.0.831-beta.0 → 0.0.831-beta.1
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/components/CreateSubAgentPanel.js +2 -2
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.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 +8 -8
- package/dist/cjs/components/agent-builder/components/MentionPicker.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/esm/components/agent-builder/components/CreateSubAgentPanel.js +70 -70
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionField.js +39 -39
- package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.js +25 -25
- package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/esm/components/agent-builder/constants/tools.d.ts +13 -3
- package/dist/esm/components/agent-builder/constants/tools.js +13 -8
- package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { jsxs as rt, Fragment as Kt, jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import { useState as r, useRef as
|
|
2
|
+
import { useState as r, useRef as A, useMemo as Lt, useCallback as a } from "react";
|
|
3
3
|
import Nt from "styled-components";
|
|
4
4
|
import { addUnique as it } from "../../../utils/arrayUtils.js";
|
|
5
5
|
import { COLORS as F } from "../../../constants/Theme.js";
|
|
6
|
-
import { AGENT_CHAR_LIMITS as
|
|
7
|
-
import { CONFIG_TOOL_SOURCES as lt, ToolSource as p, TOOL_ACTION_SOURCES as
|
|
8
|
-
import { buildAgentMentionItems as
|
|
6
|
+
import { AGENT_CHAR_LIMITS as wt } from "../constants/charLimits.js";
|
|
7
|
+
import { CONFIG_TOOL_SOURCES as lt, ToolSource as p, TOOL_ACTION_SOURCES as Bt, TOOL_ACTION_LABELS as Dt, TOOL_SOURCE_LABELS as Gt } from "../constants/tools.js";
|
|
8
|
+
import { buildAgentMentionItems as Pt, buildCustomToolMentionItems as Ut, restApiMentionItem as zt, configToolMentionItem as Ht, restApiToolName as $t, configToolName as Ft, toolSourceLabel as jt } from "../utils/mentionSerialization.js";
|
|
9
9
|
import { sourceIcon as j, SOURCE_ICONS as W, renderSourceIcon as at } from "../utils/sourceIcons.js";
|
|
10
|
-
import { ConfigToolPanel as
|
|
11
|
-
import { DRAWER_BODY_STYLE as
|
|
10
|
+
import { ConfigToolPanel as Wt } from "./ConfigToolPanel.js";
|
|
11
|
+
import { DRAWER_BODY_STYLE as Yt, DRAWER_HEADER_STYLE as Xt, DrawerHeaderText as Zt } from "./DrawerHeaderText.js";
|
|
12
12
|
import { MentionEditor as ct } from "./MentionEditor.js";
|
|
13
|
-
import { RestApiToolPanel as
|
|
14
|
-
import { SelectableListSection as
|
|
15
|
-
import { SideModal as
|
|
16
|
-
import { Input as
|
|
17
|
-
import { Toaster as
|
|
18
|
-
const
|
|
19
|
-
const s =
|
|
13
|
+
import { RestApiToolPanel as qt } from "./RestApiToolPanel.js";
|
|
14
|
+
import { SelectableListSection as Jt } from "./SelectableListSection.js";
|
|
15
|
+
import { SideModal as Qt } from "../../side-modal/SideModal.js";
|
|
16
|
+
import { Input as Vt } from "../../input/Input.js";
|
|
17
|
+
import { Toaster as te } from "../../toaster/Toaster.js";
|
|
18
|
+
const ee = 1e3, ut = 1002, dt = (v, f) => {
|
|
19
|
+
const s = v ?? [];
|
|
20
20
|
return s.some((u) => u.id === f.id) ? s.map((u) => u.id === f.id ? f : u) : [...s, f];
|
|
21
21
|
}, mt = Nt.button`
|
|
22
22
|
align-self: flex-start;
|
|
@@ -34,8 +34,8 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
34
34
|
cursor: default;
|
|
35
35
|
opacity: 0.6;
|
|
36
36
|
}
|
|
37
|
-
`,
|
|
38
|
-
onClose:
|
|
37
|
+
`, be = ({
|
|
38
|
+
onClose: v,
|
|
39
39
|
onSave: f,
|
|
40
40
|
availableTools: s,
|
|
41
41
|
onImprove: u,
|
|
@@ -44,43 +44,43 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
44
44
|
title: Z = "Create sub-agent",
|
|
45
45
|
initial: g,
|
|
46
46
|
appLabel: q = "Manifest",
|
|
47
|
-
charLimits: h =
|
|
47
|
+
charLimits: h = wt
|
|
48
48
|
}) => {
|
|
49
|
-
const [k, pt] = r(g?.name ?? ""), [T, x] = r(g?.instructions ?? ""), [b,
|
|
49
|
+
const [k, pt] = r(g?.name ?? ""), [T, x] = r(g?.instructions ?? ""), [b, _] = r(g?.guardrail ?? ""), [M, R] = r(g?.tools ?? []), [m, K] = r(
|
|
50
50
|
g?.configTools ?? []
|
|
51
|
-
), [d,
|
|
51
|
+
), [d, L] = r(
|
|
52
52
|
g?.restApiTools ?? []
|
|
53
|
-
), [i, y] = r(null),
|
|
53
|
+
), [i, y] = r(null), O = A(0), [J, Q] = r(!1), [ft, N] = r(0), [gt, w] = r(0), [S, V] = r(null), B = Lt(
|
|
54
54
|
() => [
|
|
55
|
-
...
|
|
56
|
-
...
|
|
55
|
+
...Pt(s, [], q),
|
|
56
|
+
...Ut(m, d)
|
|
57
57
|
],
|
|
58
58
|
[s, q, m, d]
|
|
59
|
-
),
|
|
60
|
-
|
|
59
|
+
), E = A({}), D = A("instructions"), yt = a((t) => {
|
|
60
|
+
E.current.instructions = t ?? void 0;
|
|
61
61
|
}, []), ht = a((t) => {
|
|
62
|
-
|
|
62
|
+
E.current.guardrail = t ?? void 0;
|
|
63
63
|
}, []), Tt = a(() => {
|
|
64
64
|
D.current = "instructions";
|
|
65
65
|
}, []), bt = a(() => {
|
|
66
66
|
D.current = "guardrail";
|
|
67
67
|
}, []), tt = a(
|
|
68
68
|
(t, e) => {
|
|
69
|
-
t === "tool" &&
|
|
69
|
+
t === "tool" && R((o) => it(o, e));
|
|
70
70
|
},
|
|
71
71
|
[]
|
|
72
72
|
), C = a((t, e) => {
|
|
73
|
-
(
|
|
73
|
+
(E.current[D.current] ?? E.current.instructions)?.("tool", t, e);
|
|
74
74
|
}, []), G = a((t) => {
|
|
75
|
-
|
|
76
|
-
key:
|
|
75
|
+
O.current += 1, y({
|
|
76
|
+
key: O.current,
|
|
77
77
|
kind: "restapi",
|
|
78
78
|
initialRest: t
|
|
79
79
|
});
|
|
80
80
|
}, []), P = a(
|
|
81
81
|
(t, e) => {
|
|
82
|
-
|
|
83
|
-
key:
|
|
82
|
+
O.current += 1, y({
|
|
83
|
+
key: O.current,
|
|
84
84
|
kind: "config",
|
|
85
85
|
toolKey: t,
|
|
86
86
|
initialConfig: e
|
|
@@ -96,18 +96,18 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
96
96
|
), Ct = a(
|
|
97
97
|
(t) => {
|
|
98
98
|
const e = !d.some((o) => o.id === t.id);
|
|
99
|
-
|
|
99
|
+
L((o) => dt(o, t)), e && C(t.id, zt(t).label), y(null);
|
|
100
100
|
},
|
|
101
101
|
[d, C]
|
|
102
102
|
), It = a(
|
|
103
103
|
(t) => {
|
|
104
104
|
const e = !m.some((o) => o.id === t.id);
|
|
105
|
-
K((o) => dt(o, t)), e && C(t.id,
|
|
105
|
+
K((o) => dt(o, t)), e && C(t.id, Ht(t).label), y(null);
|
|
106
106
|
},
|
|
107
107
|
[m, C]
|
|
108
108
|
), [U, z] = r(
|
|
109
109
|
null
|
|
110
|
-
), H =
|
|
110
|
+
), H = A(null), et = A(0), At = (t) => {
|
|
111
111
|
const e = s.find((n) => n.tool_id === t)?.display_name ?? d.find((n) => n.id === t)?.name ?? "Tool", o = `{{tool:${t}}}`, l = (n) => n.split(o).join("");
|
|
112
112
|
H.current = {
|
|
113
113
|
instructions: T,
|
|
@@ -115,10 +115,10 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
115
115
|
tools: M,
|
|
116
116
|
configTools: m,
|
|
117
117
|
restApiTools: d
|
|
118
|
-
}, x((n) => l(n)),
|
|
119
|
-
},
|
|
118
|
+
}, x((n) => l(n)), _((n) => l(n)), R((n) => n.filter((I) => I !== t)), K((n) => n.filter((I) => I.id !== t)), L((n) => n.filter((I) => I.id !== t)), N((n) => n + 1), w((n) => n + 1), et.current += 1, z({ id: et.current, message: `Tool "${e}" removed` });
|
|
119
|
+
}, vt = () => {
|
|
120
120
|
const t = H.current;
|
|
121
|
-
t && (x(t.instructions),
|
|
121
|
+
t && (x(t.instructions), _(t.guardrail), R(t.tools), K(t.configTools), L(t.restApiTools), N((e) => e + 1), w((e) => e + 1), H.current = null), z(null);
|
|
122
122
|
}, ot = k.trim().length > 0 && (T.trim().length > 0 || b.trim().length > 0), xt = M.map((t) => {
|
|
123
123
|
const e = s.find((o) => o.tool_id === t);
|
|
124
124
|
return e ? {
|
|
@@ -126,31 +126,31 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
126
126
|
label: e.display_name,
|
|
127
127
|
icon: j(e.source ?? p.Manifest)
|
|
128
128
|
} : null;
|
|
129
|
-
}).filter((t) => t !== null),
|
|
129
|
+
}).filter((t) => t !== null), _t = d.map((t) => ({
|
|
130
130
|
id: t.id,
|
|
131
|
-
label:
|
|
131
|
+
label: $t(t),
|
|
132
132
|
icon: W[p.RestApi],
|
|
133
133
|
onConfigure: () => G(t)
|
|
134
|
-
})),
|
|
134
|
+
})), Rt = m.map((t) => ({
|
|
135
135
|
id: t.id,
|
|
136
|
-
label:
|
|
136
|
+
label: Ft(t),
|
|
137
137
|
icon: W[t.tool_key === "send_slack_message" ? p.Slack : p.EmailHandover],
|
|
138
138
|
onConfigure: () => P(t.tool_key, t)
|
|
139
|
-
})),
|
|
139
|
+
})), Ot = [
|
|
140
140
|
...xt,
|
|
141
|
-
...
|
|
142
|
-
...
|
|
143
|
-
], $ =
|
|
141
|
+
..._t,
|
|
142
|
+
...Rt
|
|
143
|
+
], $ = Bt.filter(
|
|
144
144
|
(t) => {
|
|
145
145
|
const e = lt[t];
|
|
146
146
|
return !e || !!X?.[e];
|
|
147
147
|
}
|
|
148
148
|
).map((t) => ({
|
|
149
149
|
source: t,
|
|
150
|
-
label: Dt[t],
|
|
150
|
+
label: Dt[t] ?? Gt[t],
|
|
151
151
|
icon: W[t],
|
|
152
152
|
onSelect: () => St(t)
|
|
153
|
-
})), nt = i?.kind === "config" && i.toolKey ? X?.[i.toolKey] : void 0,
|
|
153
|
+
})), nt = i?.kind === "config" && i.toolKey ? X?.[i.toolKey] : void 0, Et = s.map((t) => ({
|
|
154
154
|
label: t.display_name,
|
|
155
155
|
value: t.tool_id,
|
|
156
156
|
leadingIcon: at(j(t.source ?? p.Manifest)) ?? void 0
|
|
@@ -165,7 +165,7 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
165
165
|
});
|
|
166
166
|
}), t.map((o) => ({
|
|
167
167
|
source: o,
|
|
168
|
-
label:
|
|
168
|
+
label: jt(o),
|
|
169
169
|
options: e.get(o) ?? []
|
|
170
170
|
}));
|
|
171
171
|
})(), Mt = async () => {
|
|
@@ -192,7 +192,7 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
192
192
|
V(t);
|
|
193
193
|
try {
|
|
194
194
|
const o = await u(t, t === "instructions" ? T : b);
|
|
195
|
-
t === "instructions" ? (x(o), N((l) => l + 1)) : (
|
|
195
|
+
t === "instructions" ? (x(o), N((l) => l + 1)) : (_(o), w((l) => l + 1));
|
|
196
196
|
} finally {
|
|
197
197
|
V(null);
|
|
198
198
|
}
|
|
@@ -200,22 +200,22 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
200
200
|
};
|
|
201
201
|
return /* @__PURE__ */ rt(Kt, { children: [
|
|
202
202
|
/* @__PURE__ */ rt(
|
|
203
|
-
|
|
203
|
+
Qt,
|
|
204
204
|
{
|
|
205
205
|
header: Z,
|
|
206
206
|
closeOnEscapeKey: !1,
|
|
207
|
-
zIndex:
|
|
207
|
+
zIndex: ee,
|
|
208
208
|
headerCustomComponent: /* @__PURE__ */ c(
|
|
209
|
-
|
|
209
|
+
Zt,
|
|
210
210
|
{
|
|
211
211
|
title: Z,
|
|
212
212
|
subtitle: "Each sub-agent handles one piece of the job. Use @ in the main instructions to call them."
|
|
213
213
|
}
|
|
214
214
|
),
|
|
215
215
|
width: "421px",
|
|
216
|
-
headerStyle:
|
|
217
|
-
bodyStyle:
|
|
218
|
-
onClose:
|
|
216
|
+
headerStyle: Xt,
|
|
217
|
+
bodyStyle: Yt,
|
|
218
|
+
onClose: v,
|
|
219
219
|
saveButtonProps: {
|
|
220
220
|
"data-test": "subagent-save",
|
|
221
221
|
buttonText: "Save",
|
|
@@ -230,11 +230,11 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
230
230
|
buttonText: "Cancel",
|
|
231
231
|
buttonType: "tertiaryGray",
|
|
232
232
|
size: "small",
|
|
233
|
-
onClick:
|
|
233
|
+
onClick: v
|
|
234
234
|
},
|
|
235
235
|
children: [
|
|
236
236
|
/* @__PURE__ */ c(
|
|
237
|
-
|
|
237
|
+
Vt,
|
|
238
238
|
{
|
|
239
239
|
"data-test": "subagent-name",
|
|
240
240
|
labelText: "Agent name",
|
|
@@ -258,7 +258,7 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
258
258
|
placeholder: "Write the steps in plain English. Type @ to reference a tool.",
|
|
259
259
|
minHeight: "160px",
|
|
260
260
|
resetKey: `instr-${ft}`,
|
|
261
|
-
mentionItems:
|
|
261
|
+
mentionItems: B,
|
|
262
262
|
tools: s,
|
|
263
263
|
toolActions: $,
|
|
264
264
|
onMentionSelect: tt,
|
|
@@ -282,12 +282,12 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
282
282
|
"data-test": "subagent-guardrail",
|
|
283
283
|
label: "Guardrails",
|
|
284
284
|
value: b,
|
|
285
|
-
onChange:
|
|
285
|
+
onChange: _,
|
|
286
286
|
maxLength: h.guardrail,
|
|
287
287
|
placeholder: "e.g. Never discuss competitor pricing. Type @ to reference a tool.",
|
|
288
288
|
minHeight: "160px",
|
|
289
289
|
resetKey: `guard-${gt}`,
|
|
290
|
-
mentionItems:
|
|
290
|
+
mentionItems: B,
|
|
291
291
|
tools: s,
|
|
292
292
|
toolActions: $,
|
|
293
293
|
onMentionSelect: tt,
|
|
@@ -306,27 +306,27 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
306
306
|
}
|
|
307
307
|
),
|
|
308
308
|
/* @__PURE__ */ c(
|
|
309
|
-
|
|
309
|
+
Jt,
|
|
310
310
|
{
|
|
311
311
|
title: "Tools this agent can use",
|
|
312
312
|
dataTestPrefix: "subagent-tools",
|
|
313
|
-
items:
|
|
314
|
-
addableOptions:
|
|
313
|
+
items: Ot,
|
|
314
|
+
addableOptions: Et,
|
|
315
315
|
sourceGroups: kt,
|
|
316
|
-
mentionItems:
|
|
316
|
+
mentionItems: B,
|
|
317
317
|
actionSources: $,
|
|
318
318
|
emptyText: "No tools added yet.",
|
|
319
319
|
onAdd: (t) => {
|
|
320
|
-
C(t),
|
|
320
|
+
C(t), R((e) => it(e, t));
|
|
321
321
|
},
|
|
322
|
-
onRemove:
|
|
322
|
+
onRemove: At
|
|
323
323
|
}
|
|
324
324
|
)
|
|
325
325
|
]
|
|
326
326
|
}
|
|
327
327
|
),
|
|
328
328
|
i?.kind === "restapi" && /* @__PURE__ */ c(
|
|
329
|
-
|
|
329
|
+
qt,
|
|
330
330
|
{
|
|
331
331
|
initial: i.initialRest,
|
|
332
332
|
charLimits: h,
|
|
@@ -338,7 +338,7 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
338
338
|
i.key
|
|
339
339
|
),
|
|
340
340
|
i?.kind === "config" && i.toolKey && nt && /* @__PURE__ */ c(
|
|
341
|
-
|
|
341
|
+
Wt,
|
|
342
342
|
{
|
|
343
343
|
toolKey: i.toolKey,
|
|
344
344
|
template: nt,
|
|
@@ -352,7 +352,7 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
352
352
|
i.key
|
|
353
353
|
),
|
|
354
354
|
U && /* @__PURE__ */ c(
|
|
355
|
-
|
|
355
|
+
te,
|
|
356
356
|
{
|
|
357
357
|
text: U.message,
|
|
358
358
|
type: "info",
|
|
@@ -362,7 +362,7 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
362
362
|
buttonProps: {
|
|
363
363
|
buttonText: "Undo",
|
|
364
364
|
showButton: !0,
|
|
365
|
-
onButtonClick: () => (
|
|
365
|
+
onButtonClick: () => (vt(), {})
|
|
366
366
|
},
|
|
367
367
|
onCloseToast: () => z(null)
|
|
368
368
|
},
|
|
@@ -371,6 +371,6 @@ const te = 1e3, ut = 1002, dt = (A, f) => {
|
|
|
371
371
|
] });
|
|
372
372
|
};
|
|
373
373
|
export {
|
|
374
|
-
|
|
374
|
+
be as CreateSubAgentPanel
|
|
375
375
|
};
|
|
376
376
|
//# sourceMappingURL=CreateSubAgentPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateSubAgentPanel.js","sources":["../../../../../src/components/agent-builder/components/CreateSubAgentPanel.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Input } from '@src/components/input';\nimport { SideModal } from '@src/components/side-modal';\nimport { Toaster } from '@src/components/toaster';\nimport { addUnique } from '@src/utils/arrayUtils';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tParamsBlob,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport {\n\tCONFIG_TOOL_SOURCES,\n\tTOOL_ACTION_SOURCES,\n\tTOOL_SOURCE_LABELS,\n\tToolAction,\n\tToolSource,\n} from '../constants/tools';\nimport {\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n\tconfigToolMentionItem,\n\tconfigToolName,\n\trestApiMentionItem,\n\trestApiToolName,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tsourceIcon,\n} from '../utils/sourceIcons';\nimport { ConfigToolPanel } from './ConfigToolPanel';\nimport {\n\tDRAWER_BODY_STYLE,\n\tDRAWER_HEADER_STYLE,\n\tDrawerHeaderText,\n} from './DrawerHeaderText';\nimport { MentionEditor } from './MentionEditor';\nimport { RestApiToolPanel } from './RestApiToolPanel';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from './SelectableListSection';\n\n/**\n * The sub-agent drawer sits above the main builder; its own tool drawers\n * (Rest API / email / Slack) stack one level higher so they open ON TOP of it\n * rather than behind (SideModal defaults to z-index 10).\n */\nconst SUBAGENT_ZINDEX = 1000;\nconst TOOL_DRAWER_ZINDEX = 1002;\n\n/** Upsert an item by id (replace when present, append otherwise). */\nconst upsertById = <T extends { id: string }>(\n\tlist: T[] | undefined,\n\titem: T,\n): T[] => {\n\tconst arr = list ?? [];\n\treturn arr.some((x) => x.id === item.id)\n\t\t? arr.map((x) => (x.id === item.id ? item : x))\n\t\t: [...arr, item];\n};\n\n/** Config-tool / Rest API drawer state; `key` remounts fresh per open. */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Inline \"Improve with AI\" action rendered below a mention editor. */\nconst ImproveButton = styled.button`\n\talign-self: flex-start;\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tcolor: ${COLORS.content.primary};\n\tbackground: ${COLORS.surface.standard};\n\tborder-radius: 8px;\n\tpadding: 6px 12px;\n\tfont-size: 13px;\n\tline-height: 1.1;\n\tfont-weight: 600;\n\tcursor: pointer;\n\n\t&:disabled {\n\t\tcursor: default;\n\t\topacity: 0.6;\n\t}\n`;\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/** Optional \"Improve with AI\" for the Rest API / config-tool drawers. */\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n\t/**\n\t * Backend templates (email / Slack) that drive the shared config-tool drawer.\n\t * Each present key enables its tool action in this drawer; absent → hidden.\n\t * Same prop the main builder gets — sub-agents can add the same tools.\n\t */\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\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\t/** Resolved character limits (defaults to {@link AGENT_CHAR_LIMITS}). */\n\tcharLimits?: AgentCharLimits;\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\tonImproveToolInstructions,\n\tconfigToolTemplates,\n\ttitle = 'Create sub-agent',\n\tinitial,\n\tappLabel = 'Manifest',\n\tcharLimits = AGENT_CHAR_LIMITS,\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\t// Inline-configured tools owned by this sub-agent (same drawers as the main\n\t// agent). Local to the drawer; flow to the consumer via the saved draft.\n\tconst [configTools, setConfigTools] = useState<ConfigToolConfig[]>(\n\t\tinitial?.configTools ?? [],\n\t);\n\tconst [restApiTools, setRestApiTools] = useState<RestApiToolConfig[]>(\n\t\tinitial?.restApiTools ?? [],\n\t);\n\tconst [toolDrawer, setToolDrawer] = useState<ToolDrawerState | null>(null);\n\tconst toolDrawerKeyRef = useRef(0);\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), PLUS\n\t// this drawer's inline custom tools so their `{{tool:<id>}}` tokens rehydrate\n\t// as chips on remount (they aren't in `availableTools`).\n\tconst mentionItems = useMemo(\n\t\t() => [\n\t\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t\t...buildCustomToolMentionItems(configTools, restApiTools),\n\t\t],\n\t\t[availableTools, appLabel, configTools, restApiTools],\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) => addUnique(prev, id));\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst insertToolAtCursor = useCallback((id: string, label?: string) => {\n\t\tconst target =\n\t\t\tinsertersRef.current[lastFocusedRef.current] ??\n\t\t\tinsertersRef.current.instructions;\n\t\ttarget?.('tool', id, label);\n\t}, []);\n\n\t// Rest API (bespoke) + shared config-tool (email / Slack) drawers, same as the\n\t// main builder's Step 3 — here backed by the drawer's local state.\n\t// ponytail: mirrors Step3HowItResponds; kept local rather than sharing a hook\n\t// because Step3 is context-backed and this drawer is local-state.\n\tconst openRestApi = useCallback((tool?: RestApiToolConfig) => {\n\t\ttoolDrawerKeyRef.current += 1;\n\t\tsetToolDrawer({\n\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\tkind: 'restapi',\n\t\t\tinitialRest: tool,\n\t\t});\n\t}, []);\n\tconst openConfigTool = useCallback(\n\t\t(toolKey: ConfigToolKey, tool?: ConfigToolConfig) => {\n\t\t\ttoolDrawerKeyRef.current += 1;\n\t\t\tsetToolDrawer({\n\t\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\t\tkind: 'config',\n\t\t\t\ttoolKey,\n\t\t\t\tinitialConfig: tool,\n\t\t\t});\n\t\t},\n\t\t[],\n\t);\n\tconst openToolAction = useCallback(\n\t\t(source: ToolSource) => {\n\t\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\t\tif (toolKey) {\n\t\t\t\topenConfigTool(toolKey);\n\t\t\t} else {\n\t\t\t\topenRestApi();\n\t\t\t}\n\t\t},\n\t\t[openConfigTool, openRestApi],\n\t);\n\tconst handleSaveRestApi = useCallback(\n\t\t(tool: RestApiToolConfig) => {\n\t\t\tconst isNew = !restApiTools.some((t) => t.id === tool.id);\n\t\t\tsetRestApiTools((prev) => upsertById(prev, tool));\n\t\t\t// Drop a reference chip at the cursor on creation (edits keep the chip).\n\t\t\tif (isNew) {\n\t\t\t\tinsertToolAtCursor(tool.id, restApiMentionItem(tool).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[restApiTools, insertToolAtCursor],\n\t);\n\tconst handleSaveConfigTool = useCallback(\n\t\t(tool: ConfigToolConfig) => {\n\t\t\tconst isNew = !configTools.some((t) => t.id === tool.id);\n\t\t\tsetConfigTools((prev) => upsertById(prev, tool));\n\t\t\tif (isNew) {\n\t\t\t\tinsertToolAtCursor(tool.id, configToolMentionItem(tool).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[configTools, insertToolAtCursor],\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\tconfigTools: ConfigToolConfig[];\n\t\trestApiTools: RestApiToolConfig[];\n\t} | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\t// Remove ANY tool by id: strip its `{{tool:<id>}}` tokens, remount the fields,\n\t// and drop it from whichever list holds it (catalog `tools` or an inline\n\t// custom-tool list). One undo restores all of it.\n\tconst removeTool = (id: string) => {\n\t\tconst label =\n\t\t\tavailableTools.find((t) => t.tool_id === id)?.display_name ??\n\t\t\trestApiTools.find((t) => t.id === id)?.name ??\n\t\t\t'Tool';\n\t\t// The token stores the tool id (a tool's id is its tool_id).\n\t\tconst token = `{{tool:${id}}}`;\n\t\tconst strip = (text: string) => text.split(token).join('');\n\t\tundoSnapshotRef.current = {\n\t\t\tinstructions,\n\t\t\tguardrail,\n\t\t\ttools,\n\t\t\tconfigTools,\n\t\t\trestApiTools,\n\t\t};\n\t\tsetInstructions((prev) => strip(prev));\n\t\tsetGuardrail((prev) => strip(prev));\n\t\tsetTools((prev) => prev.filter((t) => t !== id));\n\t\tsetConfigTools((prev) => prev.filter((t) => t.id !== id));\n\t\tsetRestApiTools((prev) => prev.filter((t) => t.id !== id));\n\t\tsetInstrKey((k) => k + 1);\n\t\tsetGuardKey((k) => k + 1);\n\t\tundoIdRef.current += 1;\n\t\tsetUndo({ id: undoIdRef.current, message: `Tool \"${label}\" removed` });\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\tsetConfigTools(snap.configTools);\n\t\t\tsetRestApiTools(snap.restApiTools);\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: sourceIcon(tool.source ?? ToolSource.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// Inline-configured tools (Rest API + email / Slack) render as rows in the same\n\t// list, each with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = restApiTools.map((t) => ({\n\t\tid: t.id,\n\t\tlabel: restApiToolName(t),\n\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\tonConfigure: () => openRestApi(t),\n\t}));\n\tconst configToolItems: SelectableItem[] = configTools.map((t) => ({\n\t\tid: t.id,\n\t\tlabel: configToolName(t),\n\t\ticon: SOURCE_ICONS[\n\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t? ToolSource.Slack\n\t\t\t\t: ToolSource.EmailHandover\n\t\t],\n\t\tonConfigure: () => openConfigTool(t.tool_key, t),\n\t}));\n\tconst allToolItems: SelectableItem[] = [\n\t\t...toolItems,\n\t\t...restApiItems,\n\t\t...configToolItems,\n\t];\n\n\t// Built-in tool actions (Rest API / email / Slack); the shared email / Slack\n\t// forms appear only when their backend template was provided.\n\tconst toolActionSources: ToolAction[] = TOOL_ACTION_SOURCES.filter(\n\t\t(source) => {\n\t\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\t\treturn !toolKey || Boolean(configToolTemplates?.[toolKey]);\n\t\t},\n\t).map((source) => ({\n\t\tsource,\n\t\tlabel: TOOL_SOURCE_LABELS[source],\n\t\ticon: SOURCE_ICONS[source],\n\t\tonSelect: () => openToolAction(source),\n\t}));\n\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\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\tlabel: t.display_name,\n\t\tvalue: t.tool_id,\n\t\tleadingIcon:\n\t\t\trenderSourceIcon(sourceIcon(t.source ?? ToolSource.Manifest)) ??\n\t\t\tundefined,\n\t}));\n\n\t// Group tools by source (Manifest / Shopify / …) so the empty state shows the\n\t// same per-source buttons as the main builder's side panel.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? ToolSource.Manifest;\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push({\n\t\t\t\tlabel: t.display_name,\n\t\t\t\tvalue: t.tool_id,\n\t\t\t\tleadingIcon:\n\t\t\t\t\trenderSourceIcon(sourceIcon(t.source ?? ToolSource.Manifest)) ??\n\t\t\t\t\tundefined,\n\t\t\t});\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\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\tconfigTools,\n\t\t\trestApiTools,\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<SideModal\n\t\t\t\theader={title}\n\t\t\t\tcloseOnEscapeKey={false}\n\t\t\t\tzIndex={SUBAGENT_ZINDEX}\n\t\t\t\theaderCustomComponent={\n\t\t\t\t\t<DrawerHeaderText\n\t\t\t\t\t\ttitle={title}\n\t\t\t\t\t\tsubtitle=\"Each sub-agent handles one piece of the job. Use @ in the main instructions to call them.\"\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\twidth=\"421px\"\n\t\t\t\theaderStyle={DRAWER_HEADER_STYLE}\n\t\t\t\tbodyStyle={DRAWER_BODY_STYLE}\n\t\t\t\tonClose={onClose}\n\t\t\t\tsaveButtonProps={{\n\t\t\t\t\t'data-test': 'subagent-save',\n\t\t\t\t\tbuttonText: 'Save',\n\t\t\t\t\tbuttonType: 'primary',\n\t\t\t\t\tsize: 'small',\n\t\t\t\t\tdisabled: !canSave,\n\t\t\t\t\tisLoading: saving,\n\t\t\t\t\tonClick: handleSave,\n\t\t\t\t}}\n\t\t\t\tcancelButtonProps={{\n\t\t\t\t\t'data-test': 'subagent-cancel',\n\t\t\t\t\tbuttonText: 'Cancel',\n\t\t\t\t\tbuttonType: 'tertiaryGray',\n\t\t\t\t\tsize: 'small',\n\t\t\t\t\tonClick: onClose,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<Input\n\t\t\t\t\tdata-test=\"subagent-name\"\n\t\t\t\t\tlabelText=\"Agent name\"\n\t\t\t\t\tlabelTextBold\n\t\t\t\t\tplaceholder=\"Enter agent name\"\n\t\t\t\t\tvalue={name}\n\t\t\t\t\tmaxCharLimit={charLimits.name}\n\t\t\t\t\tmaxCharLimitPosition=\"TOP\"\n\t\t\t\t\tmaxCharStyle={{ fontSize: 12, lineHeight: '16px' }}\n\t\t\t\t\tonChangeText={setName}\n\t\t\t\t/>\n\n\t\t\t\t<MentionEditor\n\t\t\t\t\tdata-test=\"subagent-instructions\"\n\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\tvalue={instructions}\n\t\t\t\t\tonChange={setInstructions}\n\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\tplaceholder=\"Write the steps in plain English. Type @ to reference a tool.\"\n\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\tresetKey={`instr-${instrKey}`}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\ttools={availableTools}\n\t\t\t\t\ttoolActions={toolActionSources}\n\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\tonFocus={focusInstr}\n\t\t\t\t\tregisterInsert={registerInstr}\n\t\t\t\t\taction={\n\t\t\t\t\t\tonImprove ? (\n\t\t\t\t\t\t\t<ImproveButton\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test=\"subagent-improve-instructions\"\n\t\t\t\t\t\t\t\tdisabled={improving !== null}\n\t\t\t\t\t\t\t\tonClick={() => handleImprove('instructions')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{improving === 'instructions'\n\t\t\t\t\t\t\t\t\t? 'Improving…'\n\t\t\t\t\t\t\t\t\t: 'Improve with AI'}\n\t\t\t\t\t\t\t</ImproveButton>\n\t\t\t\t\t\t) : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<MentionEditor\n\t\t\t\t\tdata-test=\"subagent-guardrail\"\n\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\tvalue={guardrail}\n\t\t\t\t\tonChange={setGuardrail}\n\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\tplaceholder=\"e.g. Never discuss competitor pricing. Type @ to reference a tool.\"\n\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\tresetKey={`guard-${guardKey}`}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\ttools={availableTools}\n\t\t\t\t\ttoolActions={toolActionSources}\n\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\tonFocus={focusGuard}\n\t\t\t\t\tregisterInsert={registerGuard}\n\t\t\t\t\taction={\n\t\t\t\t\t\tonImprove ? (\n\t\t\t\t\t\t\t<ImproveButton\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test=\"subagent-improve-guardrail\"\n\t\t\t\t\t\t\t\tdisabled={improving !== null}\n\t\t\t\t\t\t\t\tonClick={() => handleImprove('guardrail')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{improving === 'guardrail' ? 'Improving…' : 'Improve with AI'}\n\t\t\t\t\t\t\t</ImproveButton>\n\t\t\t\t\t\t) : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<SelectableListSection\n\t\t\t\t\ttitle=\"Tools this agent can use\"\n\t\t\t\t\tdataTestPrefix=\"subagent-tools\"\n\t\t\t\t\titems={allToolItems}\n\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\tactionSources={toolActionSources}\n\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\tinsertToolAtCursor(id);\n\t\t\t\t\t\tsetTools((prev) => addUnique(prev, id));\n\t\t\t\t\t}}\n\t\t\t\t\tonRemove={removeTool}\n\t\t\t\t/>\n\t\t\t</SideModal>\n\n\t\t\t{toolDrawer?.kind === 'restapi' && (\n\t\t\t\t<RestApiToolPanel\n\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\tinitial={toolDrawer.initialRest}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\tonSave={handleSaveRestApi}\n\t\t\t\t\tzIndex={TOOL_DRAWER_ZINDEX}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'config' &&\n\t\t\t\ttoolDrawer.toolKey &&\n\t\t\t\topenConfigTemplate && (\n\t\t\t\t\t<ConfigToolPanel\n\t\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\t\ttoolKey={toolDrawer.toolKey}\n\t\t\t\t\t\ttemplate={openConfigTemplate}\n\t\t\t\t\t\tinitial={toolDrawer.initialConfig}\n\t\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\t\tonSave={handleSaveConfigTool}\n\t\t\t\t\t\tzIndex={TOOL_DRAWER_ZINDEX}\n\t\t\t\t\t/>\n\t\t\t\t)}\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":["SUBAGENT_ZINDEX","TOOL_DRAWER_ZINDEX","upsertById","list","item","arr","x","ImproveButton","styled","COLORS","CreateSubAgentPanel","onClose","onSave","availableTools","onImprove","onImproveToolInstructions","configToolTemplates","title","initial","appLabel","charLimits","AGENT_CHAR_LIMITS","name","setName","useState","instructions","setInstructions","guardrail","setGuardrail","tools","setTools","configTools","setConfigTools","restApiTools","setRestApiTools","toolDrawer","setToolDrawer","toolDrawerKeyRef","useRef","saving","setSaving","instrKey","setInstrKey","guardKey","setGuardKey","improving","setImproving","mentionItems","useMemo","buildAgentMentionItems","buildCustomToolMentionItems","insertersRef","lastFocusedRef","registerInstr","useCallback","fn","registerGuard","focusInstr","focusGuard","addToolMention","kind","id","prev","addUnique","insertToolAtCursor","label","openRestApi","tool","openConfigTool","toolKey","openToolAction","source","CONFIG_TOOL_SOURCES","handleSaveRestApi","isNew","t","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","undo","setUndo","undoSnapshotRef","undoIdRef","removeTool","token","strip","text","k","undoRemove","snap","canSave","toolItems","sourceIcon","ToolSource","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","TOOL_ACTION_SOURCES","TOOL_SOURCE_LABELS","openConfigTemplate","toolOptions","renderSourceIcon","toolSourceGroups","order","bySource","src","toolSourceLabel","handleSave","result","handleImprove","improved","jsxs","Fragment","SideModal","jsx","DrawerHeaderText","DRAWER_HEADER_STYLE","DRAWER_BODY_STYLE","Input","MentionEditor","SelectableListSection","RestApiToolPanel","ConfigToolPanel","Toaster"],"mappings":";;;;;;;;;;;;;;;;;AA0DA,MAAMA,KAAkB,KAClBC,KAAqB,MAGrBC,KAAa,CAClBC,GACAC,MACS;AACT,QAAMC,IAAMF,KAAQ,CAAA;AACpB,SAAOE,EAAI,KAAK,CAACC,MAAMA,EAAE,OAAOF,EAAK,EAAE,IACpCC,EAAI,IAAI,CAACC,MAAOA,EAAE,OAAOF,EAAK,KAAKA,IAAOE,CAAE,IAC5C,CAAC,GAAGD,GAAKD,CAAI;AACjB,GAYMG,KAAgBC,GAAO;AAAA;AAAA,qBAERC,EAAO,OAAO,OAAO;AAAA,UAChCA,EAAO,QAAQ,OAAO;AAAA,eACjBA,EAAO,QAAQ,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAmDzBC,KAA0D,CAAC;AAAA,EACvE,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,2BAAAC;AAAA,EACA,qBA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ACpB,YAAAf;AAAA,QACA,WAAWL;AAAA,QACX,SAAS,MAAMqB,EAAc,IAAI;AAAA,QACjC,QAAQqC;AAAA,QACR,QAAQxE;AAAA,MAAA;AAAA,MANHkC,EAAW;AAAA,IAAA;AAAA,IAUjBA,GAAY,SAAS,YACrBA,EAAW,WACXoE,MACC,gBAAAe;AAAA,MAACQ;AAAA,MAAA;AAAA,QAEA,SAAS3F,EAAW;AAAA,QACpB,UAAUoE;AAAA,QACV,SAASpE,EAAW;AAAA,QACpB,YAAAf;AAAA,QACA,WAAWL;AAAA,QACX,SAAS,MAAMqB,EAAc,IAAI;AAAA,QACjC,QAAQyC;AAAA,QACR,QAAQ5E;AAAA,MAAA;AAAA,MARHkC,EAAW;AAAA,IAAA;AAAA,IAYlB4C,KACA,gBAAAuC;AAAA,MAACS;AAAA,MAAA;AAAA,QAEA,MAAMhD,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,OACdS,GAAA,GACO,CAAA;AAAA,QACR;AAAA,QAED,cAAc,MAAMR,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 React, { useCallback, useMemo, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Input } from '@src/components/input';\nimport { SideModal } from '@src/components/side-modal';\nimport { Toaster } from '@src/components/toaster';\nimport { addUnique } from '@src/utils/arrayUtils';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tParamsBlob,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport {\n\tCONFIG_TOOL_SOURCES,\n\tTOOL_ACTION_LABELS,\n\tTOOL_ACTION_SOURCES,\n\tTOOL_SOURCE_LABELS,\n\tToolAction,\n\tToolSource,\n} from '../constants/tools';\nimport {\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n\tconfigToolMentionItem,\n\tconfigToolName,\n\trestApiMentionItem,\n\trestApiToolName,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tsourceIcon,\n} from '../utils/sourceIcons';\nimport { ConfigToolPanel } from './ConfigToolPanel';\nimport {\n\tDRAWER_BODY_STYLE,\n\tDRAWER_HEADER_STYLE,\n\tDrawerHeaderText,\n} from './DrawerHeaderText';\nimport { MentionEditor } from './MentionEditor';\nimport { RestApiToolPanel } from './RestApiToolPanel';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from './SelectableListSection';\n\n/**\n * The sub-agent drawer sits above the main builder; its own tool drawers\n * (Rest API / email / Slack) stack one level higher so they open ON TOP of it\n * rather than behind (SideModal defaults to z-index 10).\n */\nconst SUBAGENT_ZINDEX = 1000;\nconst TOOL_DRAWER_ZINDEX = 1002;\n\n/** Upsert an item by id (replace when present, append otherwise). */\nconst upsertById = <T extends { id: string }>(\n\tlist: T[] | undefined,\n\titem: T,\n): T[] => {\n\tconst arr = list ?? [];\n\treturn arr.some((x) => x.id === item.id)\n\t\t? arr.map((x) => (x.id === item.id ? item : x))\n\t\t: [...arr, item];\n};\n\n/** Config-tool / Rest API drawer state; `key` remounts fresh per open. */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Inline \"Improve with AI\" action rendered below a mention editor. */\nconst ImproveButton = styled.button`\n\talign-self: flex-start;\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tcolor: ${COLORS.content.primary};\n\tbackground: ${COLORS.surface.standard};\n\tborder-radius: 8px;\n\tpadding: 6px 12px;\n\tfont-size: 13px;\n\tline-height: 1.1;\n\tfont-weight: 600;\n\tcursor: pointer;\n\n\t&:disabled {\n\t\tcursor: default;\n\t\topacity: 0.6;\n\t}\n`;\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/** Optional \"Improve with AI\" for the Rest API / config-tool drawers. */\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n\t/**\n\t * Backend templates (email / Slack) that drive the shared config-tool drawer.\n\t * Each present key enables its tool action in this drawer; absent → hidden.\n\t * Same prop the main builder gets — sub-agents can add the same tools.\n\t */\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\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\t/** Resolved character limits (defaults to {@link AGENT_CHAR_LIMITS}). */\n\tcharLimits?: AgentCharLimits;\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\tonImproveToolInstructions,\n\tconfigToolTemplates,\n\ttitle = 'Create sub-agent',\n\tinitial,\n\tappLabel = 'Manifest',\n\tcharLimits = AGENT_CHAR_LIMITS,\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\t// Inline-configured tools owned by this sub-agent (same drawers as the main\n\t// agent). Local to the drawer; flow to the consumer via the saved draft.\n\tconst [configTools, setConfigTools] = useState<ConfigToolConfig[]>(\n\t\tinitial?.configTools ?? [],\n\t);\n\tconst [restApiTools, setRestApiTools] = useState<RestApiToolConfig[]>(\n\t\tinitial?.restApiTools ?? [],\n\t);\n\tconst [toolDrawer, setToolDrawer] = useState<ToolDrawerState | null>(null);\n\tconst toolDrawerKeyRef = useRef(0);\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), PLUS\n\t// this drawer's inline custom tools so their `{{tool:<id>}}` tokens rehydrate\n\t// as chips on remount (they aren't in `availableTools`).\n\tconst mentionItems = useMemo(\n\t\t() => [\n\t\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t\t...buildCustomToolMentionItems(configTools, restApiTools),\n\t\t],\n\t\t[availableTools, appLabel, configTools, restApiTools],\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) => addUnique(prev, id));\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst insertToolAtCursor = useCallback((id: string, label?: string) => {\n\t\tconst target =\n\t\t\tinsertersRef.current[lastFocusedRef.current] ??\n\t\t\tinsertersRef.current.instructions;\n\t\ttarget?.('tool', id, label);\n\t}, []);\n\n\t// Rest API (bespoke) + shared config-tool (email / Slack) drawers, same as the\n\t// main builder's Step 3 — here backed by the drawer's local state.\n\t// ponytail: mirrors Step3HowItResponds; kept local rather than sharing a hook\n\t// because Step3 is context-backed and this drawer is local-state.\n\tconst openRestApi = useCallback((tool?: RestApiToolConfig) => {\n\t\ttoolDrawerKeyRef.current += 1;\n\t\tsetToolDrawer({\n\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\tkind: 'restapi',\n\t\t\tinitialRest: tool,\n\t\t});\n\t}, []);\n\tconst openConfigTool = useCallback(\n\t\t(toolKey: ConfigToolKey, tool?: ConfigToolConfig) => {\n\t\t\ttoolDrawerKeyRef.current += 1;\n\t\t\tsetToolDrawer({\n\t\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\t\tkind: 'config',\n\t\t\t\ttoolKey,\n\t\t\t\tinitialConfig: tool,\n\t\t\t});\n\t\t},\n\t\t[],\n\t);\n\tconst openToolAction = useCallback(\n\t\t(source: ToolSource) => {\n\t\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\t\tif (toolKey) {\n\t\t\t\topenConfigTool(toolKey);\n\t\t\t} else {\n\t\t\t\topenRestApi();\n\t\t\t}\n\t\t},\n\t\t[openConfigTool, openRestApi],\n\t);\n\tconst handleSaveRestApi = useCallback(\n\t\t(tool: RestApiToolConfig) => {\n\t\t\tconst isNew = !restApiTools.some((t) => t.id === tool.id);\n\t\t\tsetRestApiTools((prev) => upsertById(prev, tool));\n\t\t\t// Drop a reference chip at the cursor on creation (edits keep the chip).\n\t\t\tif (isNew) {\n\t\t\t\tinsertToolAtCursor(tool.id, restApiMentionItem(tool).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[restApiTools, insertToolAtCursor],\n\t);\n\tconst handleSaveConfigTool = useCallback(\n\t\t(tool: ConfigToolConfig) => {\n\t\t\tconst isNew = !configTools.some((t) => t.id === tool.id);\n\t\t\tsetConfigTools((prev) => upsertById(prev, tool));\n\t\t\tif (isNew) {\n\t\t\t\tinsertToolAtCursor(tool.id, configToolMentionItem(tool).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[configTools, insertToolAtCursor],\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\tconfigTools: ConfigToolConfig[];\n\t\trestApiTools: RestApiToolConfig[];\n\t} | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\t// Remove ANY tool by id: strip its `{{tool:<id>}}` tokens, remount the fields,\n\t// and drop it from whichever list holds it (catalog `tools` or an inline\n\t// custom-tool list). One undo restores all of it.\n\tconst removeTool = (id: string) => {\n\t\tconst label =\n\t\t\tavailableTools.find((t) => t.tool_id === id)?.display_name ??\n\t\t\trestApiTools.find((t) => t.id === id)?.name ??\n\t\t\t'Tool';\n\t\t// The token stores the tool id (a tool's id is its tool_id).\n\t\tconst token = `{{tool:${id}}}`;\n\t\tconst strip = (text: string) => text.split(token).join('');\n\t\tundoSnapshotRef.current = {\n\t\t\tinstructions,\n\t\t\tguardrail,\n\t\t\ttools,\n\t\t\tconfigTools,\n\t\t\trestApiTools,\n\t\t};\n\t\tsetInstructions((prev) => strip(prev));\n\t\tsetGuardrail((prev) => strip(prev));\n\t\tsetTools((prev) => prev.filter((t) => t !== id));\n\t\tsetConfigTools((prev) => prev.filter((t) => t.id !== id));\n\t\tsetRestApiTools((prev) => prev.filter((t) => t.id !== id));\n\t\tsetInstrKey((k) => k + 1);\n\t\tsetGuardKey((k) => k + 1);\n\t\tundoIdRef.current += 1;\n\t\tsetUndo({ id: undoIdRef.current, message: `Tool \"${label}\" removed` });\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\tsetConfigTools(snap.configTools);\n\t\t\tsetRestApiTools(snap.restApiTools);\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: sourceIcon(tool.source ?? ToolSource.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// Inline-configured tools (Rest API + email / Slack) render as rows in the same\n\t// list, each with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = restApiTools.map((t) => ({\n\t\tid: t.id,\n\t\tlabel: restApiToolName(t),\n\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\tonConfigure: () => openRestApi(t),\n\t}));\n\tconst configToolItems: SelectableItem[] = configTools.map((t) => ({\n\t\tid: t.id,\n\t\tlabel: configToolName(t),\n\t\ticon: SOURCE_ICONS[\n\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t? ToolSource.Slack\n\t\t\t\t: ToolSource.EmailHandover\n\t\t],\n\t\tonConfigure: () => openConfigTool(t.tool_key, t),\n\t}));\n\tconst allToolItems: SelectableItem[] = [\n\t\t...toolItems,\n\t\t...restApiItems,\n\t\t...configToolItems,\n\t];\n\n\t// Built-in tool actions (Rest API / email / Slack); the shared email / Slack\n\t// forms appear only when their backend template was provided.\n\tconst toolActionSources: ToolAction[] = TOOL_ACTION_SOURCES.filter(\n\t\t(source) => {\n\t\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\t\treturn !toolKey || Boolean(configToolTemplates?.[toolKey]);\n\t\t},\n\t).map((source) => ({\n\t\tsource,\n\t\tlabel: TOOL_ACTION_LABELS[source] ?? TOOL_SOURCE_LABELS[source],\n\t\ticon: SOURCE_ICONS[source],\n\t\tonSelect: () => openToolAction(source),\n\t}));\n\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\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\tlabel: t.display_name,\n\t\tvalue: t.tool_id,\n\t\tleadingIcon:\n\t\t\trenderSourceIcon(sourceIcon(t.source ?? ToolSource.Manifest)) ??\n\t\t\tundefined,\n\t}));\n\n\t// Group tools by source (Manifest / Shopify / …) so the empty state shows the\n\t// same per-source buttons as the main builder's side panel.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? ToolSource.Manifest;\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push({\n\t\t\t\tlabel: t.display_name,\n\t\t\t\tvalue: t.tool_id,\n\t\t\t\tleadingIcon:\n\t\t\t\t\trenderSourceIcon(sourceIcon(t.source ?? ToolSource.Manifest)) ??\n\t\t\t\t\tundefined,\n\t\t\t});\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\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\tconfigTools,\n\t\t\trestApiTools,\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<SideModal\n\t\t\t\theader={title}\n\t\t\t\tcloseOnEscapeKey={false}\n\t\t\t\tzIndex={SUBAGENT_ZINDEX}\n\t\t\t\theaderCustomComponent={\n\t\t\t\t\t<DrawerHeaderText\n\t\t\t\t\t\ttitle={title}\n\t\t\t\t\t\tsubtitle=\"Each sub-agent handles one piece of the job. Use @ in the main instructions to call them.\"\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\twidth=\"421px\"\n\t\t\t\theaderStyle={DRAWER_HEADER_STYLE}\n\t\t\t\tbodyStyle={DRAWER_BODY_STYLE}\n\t\t\t\tonClose={onClose}\n\t\t\t\tsaveButtonProps={{\n\t\t\t\t\t'data-test': 'subagent-save',\n\t\t\t\t\tbuttonText: 'Save',\n\t\t\t\t\tbuttonType: 'primary',\n\t\t\t\t\tsize: 'small',\n\t\t\t\t\tdisabled: !canSave,\n\t\t\t\t\tisLoading: saving,\n\t\t\t\t\tonClick: handleSave,\n\t\t\t\t}}\n\t\t\t\tcancelButtonProps={{\n\t\t\t\t\t'data-test': 'subagent-cancel',\n\t\t\t\t\tbuttonText: 'Cancel',\n\t\t\t\t\tbuttonType: 'tertiaryGray',\n\t\t\t\t\tsize: 'small',\n\t\t\t\t\tonClick: onClose,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<Input\n\t\t\t\t\tdata-test=\"subagent-name\"\n\t\t\t\t\tlabelText=\"Agent name\"\n\t\t\t\t\tlabelTextBold\n\t\t\t\t\tplaceholder=\"Enter agent name\"\n\t\t\t\t\tvalue={name}\n\t\t\t\t\tmaxCharLimit={charLimits.name}\n\t\t\t\t\tmaxCharLimitPosition=\"TOP\"\n\t\t\t\t\tmaxCharStyle={{ fontSize: 12, lineHeight: '16px' }}\n\t\t\t\t\tonChangeText={setName}\n\t\t\t\t/>\n\n\t\t\t\t<MentionEditor\n\t\t\t\t\tdata-test=\"subagent-instructions\"\n\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\tvalue={instructions}\n\t\t\t\t\tonChange={setInstructions}\n\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\tplaceholder=\"Write the steps in plain English. Type @ to reference a tool.\"\n\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\tresetKey={`instr-${instrKey}`}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\ttools={availableTools}\n\t\t\t\t\ttoolActions={toolActionSources}\n\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\tonFocus={focusInstr}\n\t\t\t\t\tregisterInsert={registerInstr}\n\t\t\t\t\taction={\n\t\t\t\t\t\tonImprove ? (\n\t\t\t\t\t\t\t<ImproveButton\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test=\"subagent-improve-instructions\"\n\t\t\t\t\t\t\t\tdisabled={improving !== null}\n\t\t\t\t\t\t\t\tonClick={() => handleImprove('instructions')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{improving === 'instructions'\n\t\t\t\t\t\t\t\t\t? 'Improving…'\n\t\t\t\t\t\t\t\t\t: 'Improve with AI'}\n\t\t\t\t\t\t\t</ImproveButton>\n\t\t\t\t\t\t) : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<MentionEditor\n\t\t\t\t\tdata-test=\"subagent-guardrail\"\n\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\tvalue={guardrail}\n\t\t\t\t\tonChange={setGuardrail}\n\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\tplaceholder=\"e.g. Never discuss competitor pricing. Type @ to reference a tool.\"\n\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\tresetKey={`guard-${guardKey}`}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\ttools={availableTools}\n\t\t\t\t\ttoolActions={toolActionSources}\n\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\tonFocus={focusGuard}\n\t\t\t\t\tregisterInsert={registerGuard}\n\t\t\t\t\taction={\n\t\t\t\t\t\tonImprove ? (\n\t\t\t\t\t\t\t<ImproveButton\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test=\"subagent-improve-guardrail\"\n\t\t\t\t\t\t\t\tdisabled={improving !== null}\n\t\t\t\t\t\t\t\tonClick={() => handleImprove('guardrail')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{improving === 'guardrail' ? 'Improving…' : 'Improve with AI'}\n\t\t\t\t\t\t\t</ImproveButton>\n\t\t\t\t\t\t) : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<SelectableListSection\n\t\t\t\t\ttitle=\"Tools this agent can use\"\n\t\t\t\t\tdataTestPrefix=\"subagent-tools\"\n\t\t\t\t\titems={allToolItems}\n\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\tactionSources={toolActionSources}\n\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\tinsertToolAtCursor(id);\n\t\t\t\t\t\tsetTools((prev) => addUnique(prev, id));\n\t\t\t\t\t}}\n\t\t\t\t\tonRemove={removeTool}\n\t\t\t\t/>\n\t\t\t</SideModal>\n\n\t\t\t{toolDrawer?.kind === 'restapi' && (\n\t\t\t\t<RestApiToolPanel\n\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\tinitial={toolDrawer.initialRest}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\tonSave={handleSaveRestApi}\n\t\t\t\t\tzIndex={TOOL_DRAWER_ZINDEX}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'config' &&\n\t\t\t\ttoolDrawer.toolKey &&\n\t\t\t\topenConfigTemplate && (\n\t\t\t\t\t<ConfigToolPanel\n\t\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\t\ttoolKey={toolDrawer.toolKey}\n\t\t\t\t\t\ttemplate={openConfigTemplate}\n\t\t\t\t\t\tinitial={toolDrawer.initialConfig}\n\t\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\t\tonSave={handleSaveConfigTool}\n\t\t\t\t\t\tzIndex={TOOL_DRAWER_ZINDEX}\n\t\t\t\t\t/>\n\t\t\t\t)}\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":["SUBAGENT_ZINDEX","TOOL_DRAWER_ZINDEX","upsertById","list","item","arr","x","ImproveButton","styled","COLORS","CreateSubAgentPanel","onClose","onSave","availableTools","onImprove","onImproveToolInstructions","configToolTemplates","title","initial","appLabel","charLimits","AGENT_CHAR_LIMITS","name","setName","useState","instructions","setInstructions","guardrail","setGuardrail","tools","setTools","configTools","setConfigTools","restApiTools","setRestApiTools","toolDrawer","setToolDrawer","toolDrawerKeyRef","useRef","saving","setSaving","instrKey","setInstrKey","guardKey","setGuardKey","improving","setImproving","mentionItems","useMemo","buildAgentMentionItems","buildCustomToolMentionItems","insertersRef","lastFocusedRef","registerInstr","useCallback","fn","registerGuard","focusInstr","focusGuard","addToolMention","kind","id","prev","addUnique","insertToolAtCursor","label","openRestApi","tool","openConfigTool","toolKey","openToolAction","source","CONFIG_TOOL_SOURCES","handleSaveRestApi","isNew","t","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","undo","setUndo","undoSnapshotRef","undoIdRef","removeTool","token","strip","text","k","undoRemove","snap","canSave","toolItems","sourceIcon","ToolSource","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","TOOL_ACTION_SOURCES","TOOL_ACTION_LABELS","TOOL_SOURCE_LABELS","openConfigTemplate","toolOptions","renderSourceIcon","toolSourceGroups","order","bySource","src","toolSourceLabel","handleSave","result","handleImprove","improved","jsxs","Fragment","SideModal","jsx","DrawerHeaderText","DRAWER_HEADER_STYLE","DRAWER_BODY_STYLE","Input","MentionEditor","SelectableListSection","RestApiToolPanel","ConfigToolPanel","Toaster"],"mappings":";;;;;;;;;;;;;;;;;AA2DA,MAAMA,KAAkB,KAClBC,KAAqB,MAGrBC,KAAa,CAClBC,GACAC,MACS;AACT,QAAMC,IAAMF,KAAQ,CAAA;AACpB,SAAOE,EAAI,KAAK,CAACC,MAAMA,EAAE,OAAOF,EAAK,EAAE,IACpCC,EAAI,IAAI,CAACC,MAAOA,EAAE,OAAOF,EAAK,KAAKA,IAAOE,CAAE,IAC5C,CAAC,GAAGD,GAAKD,CAAI;AACjB,GAYMG,KAAgBC,GAAO;AAAA;AAAA,qBAERC,EAAO,OAAO,OAAO;AAAA,UAChCA,EAAO,QAAQ,OAAO;AAAA,eACjBA,EAAO,QAAQ,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAmDzBC,KAA0D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AA;AAAA,QACX;AAAA,MAAA;AAAA,IAAA;AAAA,IAGAhD,GAAY,SAAS,aACrB,gBAAAoF;AAAA,MAACO;AAAA,MAAA;AAAA,QAEA,SAAS3F,EAAW;AAAA,QACpB,YAAAf;AAAA,QACA,WAAWL;AAAA,QACX,SAAS,MAAMqB,EAAc,IAAI;AAAA,QACjC,QAAQqC;AAAA,QACR,QAAQxE;AAAA,MAAA;AAAA,MANHkC,EAAW;AAAA,IAAA;AAAA,IAUjBA,GAAY,SAAS,YACrBA,EAAW,WACXqE,MACC,gBAAAe;AAAA,MAACQ;AAAA,MAAA;AAAA,QAEA,SAAS5F,EAAW;AAAA,QACpB,UAAUqE;AAAA,QACV,SAASrE,EAAW;AAAA,QACpB,YAAAf;AAAA,QACA,WAAWL;AAAA,QACX,SAAS,MAAMqB,EAAc,IAAI;AAAA,QACjC,QAAQyC;AAAA,QACR,QAAQ5E;AAAA,MAAA;AAAA,MARHkC,EAAW;AAAA,IAAA;AAAA,IAYlB4C,KACA,gBAAAwC;AAAA,MAACS;AAAA,MAAA;AAAA,QAEA,MAAMjD,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,OACdS,GAAA,GACO,CAAA;AAAA,QACR;AAAA,QAED,cAAc,MAAMR,EAAQ,IAAI;AAAA,MAAA;AAAA,MAd3BD,EAAK;AAAA,IAAA;AAAA,EAeX,GAEF;AAEF;"}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { jsx as R } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as c, useCallback as
|
|
3
|
-
import { TOOL_ACTION_SOURCES as v,
|
|
4
|
-
import { useAgentBuilderContext as
|
|
5
|
-
import { buildAgentMentionItems as
|
|
6
|
-
import { SOURCE_ICONS as
|
|
7
|
-
import { MentionEditor as
|
|
8
|
-
const
|
|
2
|
+
import { useMemo as c, useCallback as T } from "react";
|
|
3
|
+
import { TOOL_ACTION_SOURCES as v, TOOL_ACTION_LABELS as F, TOOL_SOURCE_LABELS as B, CONFIG_TOOL_SOURCES as N } from "../constants/tools.js";
|
|
4
|
+
import { useAgentBuilderContext as U } from "../context/AgentBuilderContext.js";
|
|
5
|
+
import { buildAgentMentionItems as x, appTypeLabel as $, buildCustomToolMentionItems as h } from "../utils/mentionSerialization.js";
|
|
6
|
+
import { SOURCE_ICONS as q } from "../utils/sourceIcons.js";
|
|
7
|
+
import { MentionEditor as j } from "./MentionEditor.js";
|
|
8
|
+
const J = ({
|
|
9
9
|
fieldKey: t,
|
|
10
|
-
label:
|
|
11
|
-
placeholder:
|
|
12
|
-
maxLength:
|
|
13
|
-
minHeight:
|
|
14
|
-
...
|
|
10
|
+
label: O,
|
|
11
|
+
placeholder: u,
|
|
12
|
+
maxLength: C,
|
|
13
|
+
minHeight: S,
|
|
14
|
+
...A
|
|
15
15
|
}) => {
|
|
16
16
|
const {
|
|
17
17
|
value: e,
|
|
18
|
-
patch:
|
|
18
|
+
patch: g,
|
|
19
19
|
addReference: s,
|
|
20
20
|
availableTools: i,
|
|
21
21
|
availableSubAgents: r,
|
|
22
22
|
applicationType: a,
|
|
23
23
|
mentionResetKey: b,
|
|
24
24
|
registerMentionField: l,
|
|
25
|
-
notifyMentionFocus:
|
|
26
|
-
onCreateSubAgent:
|
|
27
|
-
requestCreateSubAgent:
|
|
25
|
+
notifyMentionFocus: L,
|
|
26
|
+
onCreateSubAgent: _,
|
|
27
|
+
requestCreateSubAgent: f,
|
|
28
28
|
requestToolAction: m,
|
|
29
29
|
configToolTemplates: p
|
|
30
|
-
} =
|
|
30
|
+
} = U(), I = c(
|
|
31
31
|
() => [
|
|
32
|
-
...
|
|
32
|
+
...x(
|
|
33
33
|
i,
|
|
34
34
|
r,
|
|
35
|
-
|
|
35
|
+
$(a)
|
|
36
36
|
),
|
|
37
|
-
|
|
37
|
+
...h(e.configTools, e.restApiTools)
|
|
38
38
|
],
|
|
39
39
|
[
|
|
40
40
|
i,
|
|
@@ -43,46 +43,46 @@ const H = ({
|
|
|
43
43
|
e.configTools,
|
|
44
44
|
e.restApiTools
|
|
45
45
|
]
|
|
46
|
-
),
|
|
46
|
+
), M = c(
|
|
47
47
|
() => v.filter((o) => {
|
|
48
|
-
const n =
|
|
48
|
+
const n = N[o];
|
|
49
49
|
return !n || !!p?.[n];
|
|
50
50
|
}).map((o) => ({
|
|
51
51
|
source: o,
|
|
52
|
-
label: F[o],
|
|
53
|
-
icon:
|
|
52
|
+
label: F[o] ?? B[o],
|
|
53
|
+
icon: q[o],
|
|
54
54
|
onSelect: () => m(o)
|
|
55
55
|
})),
|
|
56
56
|
[m, p]
|
|
57
|
-
),
|
|
57
|
+
), d = T(
|
|
58
58
|
(o) => l(t, o),
|
|
59
59
|
[l, t]
|
|
60
|
-
),
|
|
60
|
+
), E = T(
|
|
61
61
|
(o, n) => s(o, n),
|
|
62
62
|
[s]
|
|
63
63
|
);
|
|
64
64
|
return /* @__PURE__ */ R(
|
|
65
|
-
|
|
65
|
+
j,
|
|
66
66
|
{
|
|
67
|
-
label:
|
|
67
|
+
label: O,
|
|
68
68
|
value: e[t] ?? "",
|
|
69
|
-
onChange: (o) =>
|
|
70
|
-
maxLength:
|
|
71
|
-
placeholder:
|
|
72
|
-
minHeight:
|
|
69
|
+
onChange: (o) => g({ [t]: o }),
|
|
70
|
+
maxLength: C,
|
|
71
|
+
placeholder: u,
|
|
72
|
+
minHeight: S,
|
|
73
73
|
resetKey: `${e.id}:${t}:${b}`,
|
|
74
74
|
mentionItems: I,
|
|
75
75
|
tools: i,
|
|
76
|
-
onMentionSelect:
|
|
77
|
-
onFocus: () =>
|
|
78
|
-
registerInsert:
|
|
79
|
-
onCreateSubAgent:
|
|
80
|
-
toolActions:
|
|
81
|
-
"data-test":
|
|
76
|
+
onMentionSelect: E,
|
|
77
|
+
onFocus: () => L(t),
|
|
78
|
+
registerInsert: d,
|
|
79
|
+
onCreateSubAgent: _ ? f : void 0,
|
|
80
|
+
toolActions: M,
|
|
81
|
+
"data-test": A["data-test"]
|
|
82
82
|
}
|
|
83
83
|
);
|
|
84
84
|
};
|
|
85
85
|
export {
|
|
86
|
-
|
|
86
|
+
J as MentionField
|
|
87
87
|
};
|
|
88
88
|
//# sourceMappingURL=MentionField.js.map
|